Skip to content

Commit 148a92e

Browse files
authored
Merge pull request #4 from boazpoolman/develop
Develop
2 parents a1704d0 + 1587a97 commit 148a92e

6 files changed

Lines changed: 46 additions & 52 deletions

File tree

.github/config-diff.png

-23 KB
Loading

README.md

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Importing, exporting and keeping track of config changes is done in the admin pa
1010

1111
**PLEASE USE WITH CARE**
1212

13-
![Strapi config-sync changes](.github/config-diff.png)
13+
<img src=".github/config-diff.png" alt="Strapi config-sync changes" />
1414

1515
## Installation
1616

@@ -20,42 +20,44 @@ Use `npm` or `yarn` to install and build the plugin.
2020
yarn build
2121
yarn develop
2222

23-
## Configuration
24-
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:
25-
26-
#### `destination`
27-
28-
The path for reading and writing the config JSON files.
29-
30-
> `required:` NO | `type:` string | `default:` extensions/config-sync/files/
31-
32-
#### `minify`
33-
34-
Setting to minify the JSON that's being exported. It defaults to false for better readability in git commits.
35-
36-
> `required:` NO | `type:` bool | `default:` false
37-
38-
#### `importOnBootstrap`
39-
40-
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.
41-
42-
PLEASE USE WITH CARE.
43-
44-
> `required:` NO | `type:` bool | `default:` false
45-
46-
#### `include`
47-
48-
Configs you want to include. Allowed values: `core-store`, `role-permissions`, `webhooks`. By default these are all enabled.
49-
50-
> `required:` NO | `type:` array | `default:` ["core-store", "role-permissions", "webhooks"]
51-
52-
#### `exclude`
53-
54-
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.
55-
56-
*Currently not working*
57-
58-
> `required:` NO | `type:` array | `default:` []
23+
Add the export path to the `watchIgnoreFiles` list in `config/server.js`.
24+
This way your app won't reload when you export the config in development.
25+
26+
##### `config/server.js`:
27+
28+
admin: {
29+
auth: {
30+
...
31+
},
32+
watchIgnoreFiles: [
33+
'**/config-sync/files/**',
34+
]
35+
},
36+
37+
38+
## Settings
39+
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.
40+
41+
#### Default settings:
42+
{
43+
"destination": "extensions/config-sync/files/",
44+
"minify": false,
45+
"importOnBootstrap": false,
46+
"include": [
47+
"core-store",
48+
"role-permissions",
49+
"webhooks"
50+
],
51+
"exclude": []
52+
}
53+
54+
| Property | Default | Description |
55+
| -------- | ------- | ----------- |
56+
| destination | extensions/config-sync/files/ | The path for reading and writing the config JSON files. |
57+
| minify | false | Setting to minify the JSON that's being exported. It defaults to false for better readability in git commits. |
58+
| 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. |
59+
| include | ["core-store", "role-permissions", "webhooks"] | Configs you want to include. Allowed values: `core-store`, `role-permissions`, `webhooks`. |
60+
| 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* |
5961

6062
## Naming convention
6163
All the config files written in the file destination have the same naming convention. It goes as follows:

admin/src/components/ConfigList/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const ConfigList = ({ diff, isLoading }) => {
3535
let formattedRows = [];
3636
Object.keys(diff.fileConfig).map((configName) => {
3737
const type = configName.split('.')[0]; // Grab the first part of the filename.
38-
const name = configName.split(/\.(.+)/)[1].split('.')[0] // Grab the rest of the filename minus the file extension.
38+
const name = configName.split(/\.(.+)/)[1]; // Grab the rest of the filename minus the file extension.
3939

4040
formattedRows.push({
4141
config_name: name,

controllers/config.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,11 @@ module.exports = {
1515
* @returns {void}
1616
*/
1717
exportAll: async (ctx) => {
18-
if (strapi.config.get('autoReload')) {
19-
ctx.send({
20-
message: `Config was successfully exported to ${strapi.plugins['config-sync'].config.destination}.`
21-
});
22-
}
23-
2418
await strapi.plugins['config-sync'].services.main.exportAllConfig();
2519

26-
if (!strapi.config.get('autoReload')) {
27-
ctx.send({
28-
message: `Config was successfully exported to ${strapi.plugins['config-sync'].config.destination}.`
29-
});
30-
}
20+
ctx.send({
21+
message: `Config was successfully exported to ${strapi.plugins['config-sync'].config.destination}.`
22+
});
3123
},
3224

3325
/**

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "strapi-plugin-config-sync",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"description": "Manage your Strapi database configuration as partial json files which can be imported/exported across environments. ",
55
"strapi": {
66
"name": "config-sync",

services/core-store.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ module.exports = {
5252
const coreStore = await strapi.query(coreStoreQueryString).find({ _limit: -1 });
5353
let configs = {};
5454

55-
Object.values(coreStore).map( ({ id, value, ...config }) => {
56-
configs[`${configPrefix}.${config.key}`] = { value: JSON.parse(value), ...config };
55+
Object.values(coreStore).map( ({ id, value, key, ...config }) => {
56+
configs[`${configPrefix}.${key}`] = { key, value: JSON.parse(value), ...config };
5757
});
5858

5959
return configs;

0 commit comments

Comments
 (0)