Merge pull request #4 from boazpoolman/develop

Develop
pull/7/head 0.1.3
Boaz Poolman 2021-03-25 22:28:02 +01:00 committed by GitHub
commit 148a92e6e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 40 additions and 46 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 30 KiB

View File

@ -10,7 +10,7 @@ Importing, exporting and keeping track of config changes is done in the admin pa
**PLEASE USE WITH CARE** **PLEASE USE WITH CARE**
![Strapi config-sync changes](.github/config-diff.png) <img src=".github/config-diff.png" alt="Strapi config-sync changes" />
## Installation ## Installation
@ -20,42 +20,44 @@ Use `npm` or `yarn` to install and build the plugin.
yarn build yarn build
yarn develop yarn develop
## Configuration Add the export path to the `watchIgnoreFiles` list in `config/server.js`.
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: 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 | Property | Default | Description |
| -------- | ------- | ----------- |
#### `importOnBootstrap` | 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. |
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. | 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`. |
PLEASE USE WITH CARE. | 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:` 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:` []
## Naming convention ## Naming convention
All the config files written in the file destination have the same naming convention. It goes as follows: All the config files written in the file destination have the same naming convention. It goes as follows:

View File

@ -35,7 +35,7 @@ const ConfigList = ({ diff, isLoading }) => {
let formattedRows = []; let formattedRows = [];
Object.keys(diff.fileConfig).map((configName) => { Object.keys(diff.fileConfig).map((configName) => {
const type = configName.split('.')[0]; // Grab the first part of the filename. 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({ formattedRows.push({
config_name: name, config_name: name,

View File

@ -15,19 +15,11 @@ module.exports = {
* @returns {void} * @returns {void}
*/ */
exportAll: async (ctx) => { 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(); await strapi.plugins['config-sync'].services.main.exportAllConfig();
if (!strapi.config.get('autoReload')) { ctx.send({
ctx.send({ message: `Config was successfully exported to ${strapi.plugins['config-sync'].config.destination}.`
message: `Config was successfully exported to ${strapi.plugins['config-sync'].config.destination}.` });
});
}
}, },
/** /**

View File

@ -1,6 +1,6 @@
{ {
"name": "strapi-plugin-config-sync", "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. ", "description": "Manage your Strapi database configuration as partial json files which can be imported/exported across environments. ",
"strapi": { "strapi": {
"name": "config-sync", "name": "config-sync",

View File

@ -52,8 +52,8 @@ module.exports = {
const coreStore = await strapi.query(coreStoreQueryString).find({ _limit: -1 }); const coreStore = await strapi.query(coreStoreQueryString).find({ _limit: -1 });
let configs = {}; let configs = {};
Object.values(coreStore).map( ({ id, value, ...config }) => { Object.values(coreStore).map( ({ id, value, key, ...config }) => {
configs[`${configPrefix}.${config.key}`] = { value: JSON.parse(value), ...config }; configs[`${configPrefix}.${key}`] = { key, value: JSON.parse(value), ...config };
}); });
return configs; return configs;