Rename plugin from config to config-sync
parent
e981aa7920
commit
7b2e1576c7
|
@ -1,3 +1,3 @@
|
|||
# Strapi plugin config
|
||||
# Strapi plugin config-sync
|
||||
|
||||
A quick description of config.
|
||||
A quick description of config-sync.
|
||||
|
|
|
@ -13,9 +13,9 @@ const HeaderComponent = () => {
|
|||
|
||||
const headerProps = {
|
||||
title: {
|
||||
label: formatMessage({ id: 'config.Header.Title' }),
|
||||
label: formatMessage({ id: 'config-sync.Header.Title' }),
|
||||
},
|
||||
content: formatMessage({ id: 'config.Header.Description' }),
|
||||
content: formatMessage({ id: 'config-sync.Header.Description' }),
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
|
@ -11,8 +11,8 @@ export function getAllConfig() {
|
|||
return async function(dispatch) {
|
||||
dispatch(setLoadingState(true));
|
||||
try {
|
||||
const databaseConfig = await request('/config/all/from-database', { method: 'GET' });
|
||||
const fileConfig = await request('/config/all/from-files', { method: 'GET' });
|
||||
const databaseConfig = await request('/config-sync/all/from-database', { method: 'GET' });
|
||||
const fileConfig = await request('/config-sync/all/from-files', { method: 'GET' });
|
||||
dispatch(setFileConfigInState(fileConfig));
|
||||
dispatch(setDatabaseConfigInState(databaseConfig));
|
||||
dispatch(setLoadingState(false));
|
||||
|
@ -43,7 +43,7 @@ export function exportAllConfig() {
|
|||
return async function(dispatch) {
|
||||
dispatch(setLoadingState(true));
|
||||
try {
|
||||
const { message } = await request('/config/export', { method: 'GET' });
|
||||
const { message } = await request('/config-sync/export', { method: 'GET' });
|
||||
dispatch(setFileConfigInState(Map({})));
|
||||
dispatch(setDatabaseConfigInState(Map({})));
|
||||
|
||||
|
@ -60,7 +60,7 @@ export function importAllConfig() {
|
|||
return async function(dispatch) {
|
||||
dispatch(setLoadingState(true));
|
||||
try {
|
||||
const { message } = await request('/config/import', { method: 'GET' });
|
||||
const { message } = await request('/config-sync/import', { method: 'GET' });
|
||||
dispatch(setFileConfigInState(Map({})));
|
||||
dispatch(setDatabaseConfigInState(Map({})));
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"destination": "extensions/config/files/",
|
||||
"destination": "extensions/config-sync/files/",
|
||||
"minify": false,
|
||||
"importOnBootstrap": false,
|
||||
"exclude": []
|
||||
|
|
|
@ -13,12 +13,12 @@ const fs = require('fs');
|
|||
*/
|
||||
|
||||
module.exports = () => {
|
||||
if (strapi.plugins.config.config.importOnBootstrap) {
|
||||
if (fs.existsSync(strapi.plugins.config.config.destination)) {
|
||||
const configFiles = fs.readdirSync(strapi.plugins.config.config.destination);
|
||||
if (strapi.plugins['config-sync'].config.importOnBootstrap) {
|
||||
if (fs.existsSync(strapi.plugins['config-sync'].config.destination)) {
|
||||
const configFiles = fs.readdirSync(strapi.plugins['config-sync'].config.destination);
|
||||
|
||||
configFiles.map((file) => {
|
||||
strapi.plugins.config.services.config.importFromFile(file.slice(0, -5));
|
||||
strapi.plugins['config-sync'].services.config.importFromFile(file.slice(0, -5));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,11 +18,11 @@ module.exports = {
|
|||
const coreStore = await coreStoreAPI.find({ _limit: -1 });
|
||||
|
||||
Object.values(coreStore).map(async ({ key, value }) => {
|
||||
await strapi.plugins.config.services.config.writeConfigFile(key, value);
|
||||
await strapi.plugins['config-sync'].services.config.writeConfigFile(key, value);
|
||||
});
|
||||
|
||||
ctx.send({
|
||||
message: `Config was successfully exported to ${strapi.plugins.config.config.destination}.`
|
||||
message: `Config was successfully exported to ${strapi.plugins['config-sync'].config.destination}.`
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -34,7 +34,7 @@ module.exports = {
|
|||
*/
|
||||
import: async (ctx) => {
|
||||
// Check for existance of the config file destination dir.
|
||||
if (!fs.existsSync(strapi.plugins.config.config.destination)) {
|
||||
if (!fs.existsSync(strapi.plugins['config-sync'].config.destination)) {
|
||||
ctx.send({
|
||||
message: 'No config files were found.'
|
||||
});
|
||||
|
@ -42,10 +42,10 @@ module.exports = {
|
|||
return;
|
||||
}
|
||||
|
||||
const configFiles = fs.readdirSync(strapi.plugins.config.config.destination);
|
||||
const configFiles = fs.readdirSync(strapi.plugins['config-sync'].config.destination);
|
||||
|
||||
configFiles.map((file) => {
|
||||
strapi.plugins.config.services.config.importFromFile(file.slice(0, -5));
|
||||
strapi.plugins['config-sync'].services.config.importFromFile(file.slice(0, -5));
|
||||
});
|
||||
|
||||
ctx.send({
|
||||
|
@ -61,7 +61,7 @@ module.exports = {
|
|||
*/
|
||||
getConfigsFromFiles: async (ctx) => {
|
||||
// Check for existance of the config file destination dir.
|
||||
if (!fs.existsSync(strapi.plugins.config.config.destination)) {
|
||||
if (!fs.existsSync(strapi.plugins['config-sync'].config.destination)) {
|
||||
ctx.send({
|
||||
message: 'No config files were found.'
|
||||
});
|
||||
|
@ -69,13 +69,13 @@ module.exports = {
|
|||
return;
|
||||
}
|
||||
|
||||
const configFiles = fs.readdirSync(strapi.plugins.config.config.destination);
|
||||
const configFiles = fs.readdirSync(strapi.plugins['config-sync'].config.destination);
|
||||
let formattedConfigs = {};
|
||||
|
||||
const getConfigs = async () => {
|
||||
return Promise.all(configFiles.map(async (file) => {
|
||||
const formattedConfigName = file.slice(0, -5); // remove the .json extension.
|
||||
const fileContents = await strapi.plugins.config.services.config.readConfigFile(formattedConfigName);
|
||||
const fileContents = await strapi.plugins['config-sync'].services.config.readConfigFile(formattedConfigName);
|
||||
formattedConfigs[formattedConfigName] = fileContents;
|
||||
}));
|
||||
};
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
{
|
||||
"name": "strapi-plugin-config",
|
||||
"name": "strapi-plugin-config-sync",
|
||||
"version": "0.0.1",
|
||||
"description": "Manage your Strapi core_store 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": {
|
||||
"name": "config",
|
||||
"name": "config-sync",
|
||||
"icon": "plug",
|
||||
"description": "Manage your Strapi core_store 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. "
|
||||
},
|
||||
"dependencies": {
|
||||
"immutable": "^4.0.0-rc.12",
|
||||
|
|
|
@ -17,21 +17,21 @@ module.exports = {
|
|||
*/
|
||||
writeConfigFile: async (configName, fileContents) => {
|
||||
// Check if the config should be excluded.
|
||||
const shouldExclude = strapi.plugins.config.config.exclude.includes(configName);
|
||||
const shouldExclude = strapi.plugins['config-sync'].config.exclude.includes(configName);
|
||||
if (shouldExclude) return;
|
||||
|
||||
// Check if the JSON content should be minified.
|
||||
const json =
|
||||
!strapi.plugins.config.config.minify ?
|
||||
!strapi.plugins['config-sync'].config.minify ?
|
||||
JSON.stringify(JSON.parse(fileContents), null, 2)
|
||||
: fileContents;
|
||||
|
||||
if (!fs.existsSync(strapi.plugins.config.config.destination)) {
|
||||
fs.mkdirSync(strapi.plugins.config.config.destination, { recursive: true });
|
||||
if (!fs.existsSync(strapi.plugins['config-sync'].config.destination)) {
|
||||
fs.mkdirSync(strapi.plugins['config-sync'].config.destination, { recursive: true });
|
||||
}
|
||||
|
||||
const writeFile = util.promisify(fs.writeFile);
|
||||
await writeFile(`${strapi.plugins.config.config.destination}${configName}.json`, json);
|
||||
await writeFile(`${strapi.plugins['config-sync'].config.destination}${configName}.json`, json);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -42,7 +42,7 @@ module.exports = {
|
|||
*/
|
||||
readConfigFile: async (configName) => {
|
||||
const readFile = util.promisify(fs.readFile);
|
||||
return await readFile(`${strapi.plugins.config.config.destination}${configName}.json`)
|
||||
return await readFile(`${strapi.plugins['config-sync'].config.destination}${configName}.json`)
|
||||
.then((data) => {
|
||||
return JSON.parse(data);
|
||||
})
|
||||
|
@ -59,11 +59,11 @@ module.exports = {
|
|||
*/
|
||||
importFromFile: async (configName) => {
|
||||
// Check if the config should be excluded.
|
||||
const shouldExclude = strapi.plugins.config.config.exclude.includes(configName);
|
||||
const shouldExclude = strapi.plugins['config-sync'].config.exclude.includes(configName);
|
||||
if (shouldExclude) return;
|
||||
|
||||
const coreStoreAPI = strapi.query('core_store');
|
||||
const fileContents = await strapi.plugins.config.services.config.readConfigFile(configName);
|
||||
const fileContents = await strapi.plugins['config-sync'].services.config.readConfigFile(configName);
|
||||
|
||||
const configExists = await strapi
|
||||
.query('core_store')
|
||||
|
|
Loading…
Reference in New Issue