In case you store your project configurations in the database you will need to make sure that both changes made in production as well as new changes added for new features all end up at the right time in all your environments.
So here we describe one possible approach to sync project configurations between local, development, staging and production environments.
For easier working with multiple projects and environments first set up a .livingdocs-cli
dotfile: Set up your cli dotfile
Download:
npx livingdocs-cli project-config:download --format json --project projectA --env development
# plan update and verify only the expected properties are updatednpx livingdocs-cli project-config:plan --project projectA --env development# if everything looks ok, do the updatenpx livingdocs-cli project-config:publish --project projectA --env development
Here we can simply use git diff --no-index
to use git to compare to files.
# --no-index diffs the two folders without regard to their current# status in gitgit diff --no-index sync-projectA/local sync-projectA/development
This workflow is for enterprise customers who also have a local setup of livingdocs on their machine.
Step 1: Download all configs
npx livingdocs-cli project-config:download --format json -p projectA --env dev &&npx livingdocs-cli project-config:download --format json -p projectA --env staging &&npx livingdocs-cli project-config:download --format json -p projectA --env productionnpx livingdocs-cli project-config:download --format json -p projectB --env dev &&npx livingdocs-cli project-config:download --format json -p projectB --env staging &&npx livingdocs-cli project-config:download --format json -p projectB --env production
Step 2: Commit these changes
Step 3: Download local configs (these usually have the latest changes)
npx livingdocs-cli project-config:download --format json -p projectA --env localnpx livingdocs-cli project-config:download --format json -p projectB --env local
Step 4: Compare configs
One example:
git diff --no-index sync-projectA/local sync-projectA/development
Note that some configs like renditions or preview urls are always different between environments.
Step 5: Make changes to config files
Step 6: Publish changed configs
One example:
# plan update and verify only the expected properties are updatednpx livingdocs-cli project-config:plan -p projectA --env development# if everything looks ok, do the updatenpx livingdocs-cli project-config:publish -p projectA --env development
Step 7: Discard sync-projectA/local
and sync-projectB/local
Step 8: Commit the rest