strapi-plugin-config-sync/README.md

106 lines
3.6 KiB
Markdown
Raw Normal View History

2021-03-21 19:01:55 +01:00
# Strapi Plugin Config Sync
2021-03-19 19:04:22 +01:00
2021-03-21 19:01:55 +01:00
A lot of configuration of your Strapi project is stored in the database. Like core_store, user permissions, user roles & webhooks. Things you might want to have the same on all environments. But when you update them locally, you will have to manually update them on all other environments too.
That's where this plugin comes in to play. It allows you to export these configs as individual JSON files for each config, and write them somewhere in your project. With the configs written in your filesystem your can keep track of them through version control (git), and easily pull and import them across environments.
Importing, exporting and keeping track of config changes is done in the admin page of the plugin.
2021-03-24 19:50:44 +01:00
**THIS PLUGIN IS NOT STABLE**
2021-03-21 19:01:55 +01:00
**PLEASE USE WITH CARE**
2021-03-25 22:07:31 +01:00
<img src=".github/config-diff.png" alt="Strapi config-sync changes" />
2021-03-21 19:01:55 +01:00
## Installation
Use `npm` or `yarn` to install and build the plugin.
yarn add strapi-plugin-config-sync
yarn build
yarn develop
Add the export path to the `watchIgnoreFiles` list in `config/server.js`.
This way your app won't reload when you export the config in development.
admin: {
auth: {
...
},
watchIgnoreFiles: [
'**/config-sync/files/**',
]
},
2021-03-21 19:01:55 +01:00
## Configuration
Some settings for the plugin are able to be modified by creating a file `extensions/config-sync/config/config.json` and changing the following settings:
#### `destination`
The path for reading and writing the config JSON files.
> `required:` NO | `type:` string | `default:` extensions/config-sync/files/
#### `minify`
Setting to minify the JSON that's being exported. It defaults to false for better readability in git commits.
> `required:` NO | `type:` bool | `default:` false
#### `importOnBootstrap`
Allows you to let the config be imported automaticly when strapi is bootstrapping (on `yarn start`). This setting should only be used in production, and should be handled very carefully as it can unintendedly overwrite the changes in your database.
PLEASE USE WITH CARE.
> `required:` NO | `type:` bool | `default:` false
2021-03-24 19:50:44 +01:00
#### `include`
Configs you want to include. Allowed values: `core-store`, `role-permissions`, `webhooks`. By default these are all enabled.
> `required:` NO | `type:` array | `default:` ["core-store", "role-permissions", "webhooks"]
2021-03-21 19:01:55 +01:00
#### `exclude`
You might not want all your database config exported and managed in git. This settings allows you to add an array of config names which should not be tracked by the config-sync plugin.
2021-03-24 19:50:44 +01:00
*Currently not working*
2021-03-21 19:01:55 +01:00
> `required:` NO | `type:` array | `default:` []
2021-03-24 19:50:44 +01:00
## Naming convention
All the config files written in the file destination have the same naming convention. It goes as follows:
[config-type].[config-name].json
- `config-type` - Corresponds to the value in from the config.include setting.
- `config-name` - The unique identifier of the config.
- For `core-store` config this is the `key` value.
- For `role-permissions` config this is the `type` value.
- For `webhooks` config this is the `id` value
2021-03-21 19:01:55 +01:00
## TODOs
2021-03-24 19:50:44 +01:00
- ~~Exporting of user roles & permissions~~
- ~~Exporting of webhooks~~
- ~~Specify which tables you want to track in the plugin configurations~~
- Exporting of EE roles & permissions
2021-03-21 19:01:55 +01:00
- Add partial import/export functionality
- Add CLI commands for importing/exporting
2021-03-24 19:50:44 +01:00
- Track config deletions
2021-03-21 19:01:55 +01:00
## Resources
- [MIT License](LICENSE.md)
## Links
- [NPM package](https://www.npmjs.com/package/strapi-plugin-config-sync)
- [GitHub repository](https://github.com/boazpoolman/strapi-plugin-config-sync)
## ⭐️ Show your support
Give a star if this project helped you.