commit
148a92e6e1
Binary file not shown.
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 30 KiB |
64
README.md
64
README.md
|
@ -10,7 +10,7 @@ Importing, exporting and keeping track of config changes is done in the admin pa
|
|||
|
||||
**PLEASE USE WITH CARE**
|
||||
|
||||

|
||||
<img src=".github/config-diff.png" alt="Strapi config-sync changes" />
|
||||
|
||||
## Installation
|
||||
|
||||
|
@ -20,42 +20,44 @@ Use `npm` or `yarn` to install and build the plugin.
|
|||
yarn build
|
||||
yarn develop
|
||||
|
||||
## 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:
|
||||
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.
|
||||
|
||||
#### `destination`
|
||||
##### `config/server.js`:
|
||||
|
||||
The path for reading and writing the config JSON files.
|
||||
admin: {
|
||||
auth: {
|
||||
...
|
||||
},
|
||||
watchIgnoreFiles: [
|
||||
'**/config-sync/files/**',
|
||||
]
|
||||
},
|
||||
|
||||
> `required:` NO | `type:` string | `default:` extensions/config-sync/files/
|
||||
|
||||
#### `minify`
|
||||
## Settings
|
||||
Some settings for the plugin are able to be modified by creating a file `extensions/config-sync/config/config.json` and overwriting the default settings.
|
||||
|
||||
Setting to minify the JSON that's being exported. It defaults to false for better readability in git commits.
|
||||
#### Default settings:
|
||||
{
|
||||
"destination": "extensions/config-sync/files/",
|
||||
"minify": false,
|
||||
"importOnBootstrap": false,
|
||||
"include": [
|
||||
"core-store",
|
||||
"role-permissions",
|
||||
"webhooks"
|
||||
],
|
||||
"exclude": []
|
||||
}
|
||||
|
||||
> `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
|
||||
|
||||
#### `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"]
|
||||
|
||||
#### `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.
|
||||
|
||||
*Currently not working*
|
||||
|
||||
> `required:` NO | `type:` array | `default:` []
|
||||
| Property | Default | Description |
|
||||
| -------- | ------- | ----------- |
|
||||
| destination | extensions/config-sync/files/ | The path for reading and writing the config JSON files. |
|
||||
| minify | false | Setting to minify the JSON that's being exported. It defaults to false for better readability in git commits. |
|
||||
| importOnBootstrap | false | 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. |
|
||||
| include | ["core-store", "role-permissions", "webhooks"] | Configs you want to include. Allowed values: `core-store`, `role-permissions`, `webhooks`. |
|
||||
| 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. *Currently not working* |
|
||||
|
||||
## Naming convention
|
||||
All the config files written in the file destination have the same naming convention. It goes as follows:
|
||||
|
|
|
@ -35,7 +35,7 @@ const ConfigList = ({ diff, isLoading }) => {
|
|||
let formattedRows = [];
|
||||
Object.keys(diff.fileConfig).map((configName) => {
|
||||
const type = configName.split('.')[0]; // Grab the first part of the filename.
|
||||
const name = configName.split(/\.(.+)/)[1].split('.')[0] // Grab the rest of the filename minus the file extension.
|
||||
const name = configName.split(/\.(.+)/)[1]; // Grab the rest of the filename minus the file extension.
|
||||
|
||||
formattedRows.push({
|
||||
config_name: name,
|
||||
|
|
|
@ -15,19 +15,11 @@ module.exports = {
|
|||
* @returns {void}
|
||||
*/
|
||||
exportAll: async (ctx) => {
|
||||
if (strapi.config.get('autoReload')) {
|
||||
ctx.send({
|
||||
message: `Config was successfully exported to ${strapi.plugins['config-sync'].config.destination}.`
|
||||
});
|
||||
}
|
||||
|
||||
await strapi.plugins['config-sync'].services.main.exportAllConfig();
|
||||
|
||||
if (!strapi.config.get('autoReload')) {
|
||||
ctx.send({
|
||||
message: `Config was successfully exported to ${strapi.plugins['config-sync'].config.destination}.`
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "strapi-plugin-config-sync",
|
||||
"version": "0.1.2",
|
||||
"version": "0.1.3",
|
||||
"description": "Manage your Strapi database configuration as partial json files which can be imported/exported across environments. ",
|
||||
"strapi": {
|
||||
"name": "config-sync",
|
||||
|
|
|
@ -52,8 +52,8 @@ module.exports = {
|
|||
const coreStore = await strapi.query(coreStoreQueryString).find({ _limit: -1 });
|
||||
let configs = {};
|
||||
|
||||
Object.values(coreStore).map( ({ id, value, ...config }) => {
|
||||
configs[`${configPrefix}.${config.key}`] = { value: JSON.parse(value), ...config };
|
||||
Object.values(coreStore).map( ({ id, value, key, ...config }) => {
|
||||
configs[`${configPrefix}.${key}`] = { key, value: JSON.parse(value), ...config };
|
||||
});
|
||||
|
||||
return configs;
|
||||
|
|
Loading…
Reference in New Issue