Skip to content

Commit 7b2e157

Browse files
committed
Rename plugin from config to config-sync
1 parent e981aa7 commit 7b2e157

File tree

8 files changed

+33
-33
lines changed

8 files changed

+33
-33
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# Strapi plugin config
1+
# Strapi plugin config-sync
22

3-
A quick description of config.
3+
A quick description of config-sync.

admin/src/components/Header/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ const HeaderComponent = () => {
1313

1414
const headerProps = {
1515
title: {
16-
label: formatMessage({ id: 'config.Header.Title' }),
16+
label: formatMessage({ id: 'config-sync.Header.Title' }),
1717
},
18-
content: formatMessage({ id: 'config.Header.Description' }),
18+
content: formatMessage({ id: 'config-sync.Header.Description' }),
1919
};
2020

2121
return (

admin/src/state/actions/Config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export function getAllConfig() {
1111
return async function(dispatch) {
1212
dispatch(setLoadingState(true));
1313
try {
14-
const databaseConfig = await request('/config/all/from-database', { method: 'GET' });
15-
const fileConfig = await request('/config/all/from-files', { method: 'GET' });
14+
const databaseConfig = await request('/config-sync/all/from-database', { method: 'GET' });
15+
const fileConfig = await request('/config-sync/all/from-files', { method: 'GET' });
1616
dispatch(setFileConfigInState(fileConfig));
1717
dispatch(setDatabaseConfigInState(databaseConfig));
1818
dispatch(setLoadingState(false));
@@ -43,7 +43,7 @@ export function exportAllConfig() {
4343
return async function(dispatch) {
4444
dispatch(setLoadingState(true));
4545
try {
46-
const { message } = await request('/config/export', { method: 'GET' });
46+
const { message } = await request('/config-sync/export', { method: 'GET' });
4747
dispatch(setFileConfigInState(Map({})));
4848
dispatch(setDatabaseConfigInState(Map({})));
4949

@@ -60,7 +60,7 @@ export function importAllConfig() {
6060
return async function(dispatch) {
6161
dispatch(setLoadingState(true));
6262
try {
63-
const { message } = await request('/config/import', { method: 'GET' });
63+
const { message } = await request('/config-sync/import', { method: 'GET' });
6464
dispatch(setFileConfigInState(Map({})));
6565
dispatch(setDatabaseConfigInState(Map({})));
6666

config/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"destination": "extensions/config/files/",
2+
"destination": "extensions/config-sync/files/",
33
"minify": false,
44
"importOnBootstrap": false,
55
"exclude": []

config/functions/bootstrap.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ const fs = require('fs');
1313
*/
1414

1515
module.exports = () => {
16-
if (strapi.plugins.config.config.importOnBootstrap) {
17-
if (fs.existsSync(strapi.plugins.config.config.destination)) {
18-
const configFiles = fs.readdirSync(strapi.plugins.config.config.destination);
16+
if (strapi.plugins['config-sync'].config.importOnBootstrap) {
17+
if (fs.existsSync(strapi.plugins['config-sync'].config.destination)) {
18+
const configFiles = fs.readdirSync(strapi.plugins['config-sync'].config.destination);
1919

2020
configFiles.map((file) => {
21-
strapi.plugins.config.services.config.importFromFile(file.slice(0, -5));
21+
strapi.plugins['config-sync'].services.config.importFromFile(file.slice(0, -5));
2222
});
2323
}
2424
}

controllers/config.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ module.exports = {
1818
const coreStore = await coreStoreAPI.find({ _limit: -1 });
1919

2020
Object.values(coreStore).map(async ({ key, value }) => {
21-
await strapi.plugins.config.services.config.writeConfigFile(key, value);
21+
await strapi.plugins['config-sync'].services.config.writeConfigFile(key, value);
2222
});
2323

2424
ctx.send({
25-
message: `Config was successfully exported to ${strapi.plugins.config.config.destination}.`
25+
message: `Config was successfully exported to ${strapi.plugins['config-sync'].config.destination}.`
2626
});
2727
},
2828

@@ -34,18 +34,18 @@ module.exports = {
3434
*/
3535
import: async (ctx) => {
3636
// Check for existance of the config file destination dir.
37-
if (!fs.existsSync(strapi.plugins.config.config.destination)) {
37+
if (!fs.existsSync(strapi.plugins['config-sync'].config.destination)) {
3838
ctx.send({
3939
message: 'No config files were found.'
4040
});
4141

4242
return;
4343
}
4444

45-
const configFiles = fs.readdirSync(strapi.plugins.config.config.destination);
45+
const configFiles = fs.readdirSync(strapi.plugins['config-sync'].config.destination);
4646

4747
configFiles.map((file) => {
48-
strapi.plugins.config.services.config.importFromFile(file.slice(0, -5));
48+
strapi.plugins['config-sync'].services.config.importFromFile(file.slice(0, -5));
4949
});
5050

5151
ctx.send({
@@ -61,21 +61,21 @@ module.exports = {
6161
*/
6262
getConfigsFromFiles: async (ctx) => {
6363
// Check for existance of the config file destination dir.
64-
if (!fs.existsSync(strapi.plugins.config.config.destination)) {
64+
if (!fs.existsSync(strapi.plugins['config-sync'].config.destination)) {
6565
ctx.send({
6666
message: 'No config files were found.'
6767
});
6868

6969
return;
7070
}
7171

72-
const configFiles = fs.readdirSync(strapi.plugins.config.config.destination);
72+
const configFiles = fs.readdirSync(strapi.plugins['config-sync'].config.destination);
7373
let formattedConfigs = {};
7474

7575
const getConfigs = async () => {
7676
return Promise.all(configFiles.map(async (file) => {
7777
const formattedConfigName = file.slice(0, -5); // remove the .json extension.
78-
const fileContents = await strapi.plugins.config.services.config.readConfigFile(formattedConfigName);
78+
const fileContents = await strapi.plugins['config-sync'].services.config.readConfigFile(formattedConfigName);
7979
formattedConfigs[formattedConfigName] = fileContents;
8080
}));
8181
};

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"name": "strapi-plugin-config",
2+
"name": "strapi-plugin-config-sync",
33
"version": "0.0.1",
4-
"description": "Manage your Strapi core_store configuration as partial json files which can be imported/exported across environments. ",
4+
"description": "Manage your Strapi database configuration as partial json files which can be imported/exported across environments. ",
55
"strapi": {
6-
"name": "config",
6+
"name": "config-sync",
77
"icon": "plug",
8-
"description": "Manage your Strapi core_store configuration as partial json files which can be imported/exported across environments. "
8+
"description": "Manage your Strapi database configuration as partial json files which can be imported/exported across environments. "
99
},
1010
"dependencies": {
1111
"immutable": "^4.0.0-rc.12",

services/config.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@ module.exports = {
1717
*/
1818
writeConfigFile: async (configName, fileContents) => {
1919
// Check if the config should be excluded.
20-
const shouldExclude = strapi.plugins.config.config.exclude.includes(configName);
20+
const shouldExclude = strapi.plugins['config-sync'].config.exclude.includes(configName);
2121
if (shouldExclude) return;
2222

2323
// Check if the JSON content should be minified.
2424
const json =
25-
!strapi.plugins.config.config.minify ?
25+
!strapi.plugins['config-sync'].config.minify ?
2626
JSON.stringify(JSON.parse(fileContents), null, 2)
2727
: fileContents;
2828

29-
if (!fs.existsSync(strapi.plugins.config.config.destination)) {
30-
fs.mkdirSync(strapi.plugins.config.config.destination, { recursive: true });
29+
if (!fs.existsSync(strapi.plugins['config-sync'].config.destination)) {
30+
fs.mkdirSync(strapi.plugins['config-sync'].config.destination, { recursive: true });
3131
}
3232

3333
const writeFile = util.promisify(fs.writeFile);
34-
await writeFile(`${strapi.plugins.config.config.destination}${configName}.json`, json);
34+
await writeFile(`${strapi.plugins['config-sync'].config.destination}${configName}.json`, json);
3535
},
3636

3737
/**
@@ -42,7 +42,7 @@ module.exports = {
4242
*/
4343
readConfigFile: async (configName) => {
4444
const readFile = util.promisify(fs.readFile);
45-
return await readFile(`${strapi.plugins.config.config.destination}${configName}.json`)
45+
return await readFile(`${strapi.plugins['config-sync'].config.destination}${configName}.json`)
4646
.then((data) => {
4747
return JSON.parse(data);
4848
})
@@ -59,11 +59,11 @@ module.exports = {
5959
*/
6060
importFromFile: async (configName) => {
6161
// Check if the config should be excluded.
62-
const shouldExclude = strapi.plugins.config.config.exclude.includes(configName);
62+
const shouldExclude = strapi.plugins['config-sync'].config.exclude.includes(configName);
6363
if (shouldExclude) return;
6464

6565
const coreStoreAPI = strapi.query('core_store');
66-
const fileContents = await strapi.plugins.config.services.config.readConfigFile(configName);
66+
const fileContents = await strapi.plugins['config-sync'].services.config.readConfigFile(configName);
6767

6868
const configExists = await strapi
6969
.query('core_store')

0 commit comments

Comments
 (0)