fix: deprecation warning regarding plugin config
parent
9178f1e902
commit
ab82a0dbf6
|
@ -23,21 +23,21 @@ module.exports = async () => {
|
||||||
|
|
||||||
// The default types provided by the plugin.
|
// The default types provided by the plugin.
|
||||||
defaultTypes(strapi).map((type) => {
|
defaultTypes(strapi).map((type) => {
|
||||||
if (!strapi.config.get('plugin.config-sync.excludedTypes').includes(type.configName)) {
|
if (!strapi.config.get('plugin::config-sync.excludedTypes').includes(type.configName)) {
|
||||||
types[type.configName] = new ConfigType(type);
|
types[type.configName] = new ConfigType(type);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// The types provided by other plugins.
|
// The types provided by other plugins.
|
||||||
strapi.plugin('config-sync').pluginTypes.map((type) => {
|
strapi.plugin('config-sync').pluginTypes.map((type) => {
|
||||||
if (!strapi.config.get('plugin.config-sync.excludedTypes').includes(type.configName)) {
|
if (!strapi.config.get('plugin::config-sync.excludedTypes').includes(type.configName)) {
|
||||||
types[type.configName] = new ConfigType(type);
|
types[type.configName] = new ConfigType(type);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// The custom types provided by the user.
|
// The custom types provided by the user.
|
||||||
strapi.config.get('plugin.config-sync.customTypes').map((type) => {
|
strapi.config.get('plugin::config-sync.customTypes').map((type) => {
|
||||||
if (!strapi.config.get('plugin.config-sync.excludedTypes').includes(type.configName)) {
|
if (!strapi.config.get('plugin::config-sync.excludedTypes').includes(type.configName)) {
|
||||||
types[type.configName] = new ConfigType(type);
|
types[type.configName] = new ConfigType(type);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -47,10 +47,10 @@ module.exports = async () => {
|
||||||
strapi.plugin('config-sync').types = registerTypes();
|
strapi.plugin('config-sync').types = registerTypes();
|
||||||
|
|
||||||
// Import on bootstrap.
|
// Import on bootstrap.
|
||||||
if (strapi.config.get('plugin.config-sync.importOnBootstrap')) {
|
if (strapi.config.get('plugin::config-sync.importOnBootstrap')) {
|
||||||
if (strapi.server.app.env === 'development') {
|
if (strapi.server.app.env === 'development') {
|
||||||
strapi.log.warn(logMessage(`You can't use the 'importOnBootstrap' setting in the development env.`));
|
strapi.log.warn(logMessage(`You can't use the 'importOnBootstrap' setting in the development env.`));
|
||||||
} else if (fs.existsSync(strapi.config.get('plugin.config-sync.syncDir'))) {
|
} else if (fs.existsSync(strapi.config.get('plugin::config-sync.syncDir'))) {
|
||||||
await strapi.plugin('config-sync').service('main').importAllConfig();
|
await strapi.plugin('config-sync').service('main').importAllConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,7 @@ const getConfigState = (diff, configName, syncType) => {
|
||||||
|
|
||||||
const handleAction = async (syncType, skipConfirm, configType, partials, force) => {
|
const handleAction = async (syncType, skipConfirm, configType, partials, force) => {
|
||||||
const app = await getStrapiApp();
|
const app = await getStrapiApp();
|
||||||
const hasSyncDir = fs.existsSync(app.config.get('plugin.config-sync.syncDir'));
|
const hasSyncDir = fs.existsSync(app.config.get('plugin::config-sync.syncDir'));
|
||||||
|
|
||||||
// No import with empty sync dir.
|
// No import with empty sync dir.
|
||||||
if (!hasSyncDir && syncType === 'import') {
|
if (!hasSyncDir && syncType === 'import') {
|
||||||
|
|
|
@ -39,10 +39,10 @@ const ConfigType = class ConfigType {
|
||||||
*/
|
*/
|
||||||
importSingle = async (configName, configContent, force) => {
|
importSingle = async (configName, configContent, force) => {
|
||||||
// Check if the config should be excluded.
|
// Check if the config should be excluded.
|
||||||
const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => `${this.configPrefix}.${configName}`.startsWith(option)));
|
const shouldExclude = !isEmpty(strapi.config.get('plugin::config-sync.excludedConfig').filter((option) => `${this.configPrefix}.${configName}`.startsWith(option)));
|
||||||
if (shouldExclude) return;
|
if (shouldExclude) return;
|
||||||
|
|
||||||
const softImport = strapi.config.get('plugin.config-sync.soft');
|
const softImport = strapi.config.get('plugin::config-sync.soft');
|
||||||
const queryAPI = strapi.query(this.queryString);
|
const queryAPI = strapi.query(this.queryString);
|
||||||
const uidParams = getUidParamsFromName(this.uidKeys, configName);
|
const uidParams = getUidParamsFromName(this.uidKeys, configName);
|
||||||
const combinedUidWhereFilter = getCombinedUidWhereFilter(this.uidKeys, uidParams);
|
const combinedUidWhereFilter = getCombinedUidWhereFilter(this.uidKeys, uidParams);
|
||||||
|
@ -174,7 +174,7 @@ const ConfigType = class ConfigType {
|
||||||
const formattedDiff = await strapi.plugin('config-sync').service('main').getFormattedDiff(this.configPrefix);
|
const formattedDiff = await strapi.plugin('config-sync').service('main').getFormattedDiff(this.configPrefix);
|
||||||
|
|
||||||
// Check if the config should be excluded.
|
// Check if the config should be excluded.
|
||||||
const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => configName.startsWith(option)));
|
const shouldExclude = !isEmpty(strapi.config.get('plugin::config-sync.excludedConfig').filter((option) => configName.startsWith(option)));
|
||||||
if (shouldExclude) return;
|
if (shouldExclude) return;
|
||||||
|
|
||||||
const currentConfig = formattedDiff.databaseConfig[configName];
|
const currentConfig = formattedDiff.databaseConfig[configName];
|
||||||
|
@ -211,7 +211,7 @@ const ConfigType = class ConfigType {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the config should be excluded.
|
// Check if the config should be excluded.
|
||||||
const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => `${this.configPrefix}.${combinedUid}`.startsWith(option)));
|
const shouldExclude = !isEmpty(strapi.config.get('plugin::config-sync.excludedConfig').filter((option) => `${this.configPrefix}.${combinedUid}`.startsWith(option)));
|
||||||
if (shouldExclude) return;
|
if (shouldExclude) return;
|
||||||
|
|
||||||
const formattedConfig = { ...sanitizeConfig(config) };
|
const formattedConfig = { ...sanitizeConfig(config) };
|
||||||
|
|
|
@ -25,7 +25,7 @@ module.exports = {
|
||||||
|
|
||||||
|
|
||||||
ctx.send({
|
ctx.send({
|
||||||
message: `Config was successfully exported to ${strapi.config.get('plugin.config-sync.syncDir')}.`,
|
message: `Config was successfully exported to ${strapi.config.get('plugin::config-sync.syncDir')}.`,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ module.exports = {
|
||||||
*/
|
*/
|
||||||
importAll: async (ctx) => {
|
importAll: async (ctx) => {
|
||||||
// Check for existance of the config file sync dir.
|
// Check for existance of the config file sync dir.
|
||||||
if (!fs.existsSync(strapi.config.get('plugin.config-sync.syncDir'))) {
|
if (!fs.existsSync(strapi.config.get('plugin::config-sync.syncDir'))) {
|
||||||
ctx.send({
|
ctx.send({
|
||||||
message: 'No config files were found.',
|
message: 'No config files were found.',
|
||||||
});
|
});
|
||||||
|
@ -73,7 +73,7 @@ module.exports = {
|
||||||
*/
|
*/
|
||||||
getDiff: async (ctx) => {
|
getDiff: async (ctx) => {
|
||||||
// Check for existance of the config file sync dir.
|
// Check for existance of the config file sync dir.
|
||||||
if (!fs.existsSync(strapi.config.get('plugin.config-sync.syncDir'))) {
|
if (!fs.existsSync(strapi.config.get('plugin::config-sync.syncDir'))) {
|
||||||
ctx.send({
|
ctx.send({
|
||||||
message: 'No config files were found.',
|
message: 'No config files were found.',
|
||||||
});
|
});
|
||||||
|
@ -91,7 +91,7 @@ module.exports = {
|
||||||
getAppEnv: async () => {
|
getAppEnv: async () => {
|
||||||
return {
|
return {
|
||||||
env: strapi.server.app.env,
|
env: strapi.server.app.env,
|
||||||
config: strapi.config.get('plugin.config-sync'),
|
config: strapi.config.get('plugin::config-sync'),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -21,23 +21,23 @@ module.exports = () => ({
|
||||||
*/
|
*/
|
||||||
writeConfigFile: async (configType, configName, fileContents) => {
|
writeConfigFile: async (configType, configName, fileContents) => {
|
||||||
// Check if the config should be excluded.
|
// Check if the config should be excluded.
|
||||||
const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => `${configType}.${configName}`.startsWith(option)));
|
const shouldExclude = !isEmpty(strapi.config.get('plugin::config-sync.excludedConfig').filter((option) => `${configType}.${configName}`.startsWith(option)));
|
||||||
if (shouldExclude) return;
|
if (shouldExclude) return;
|
||||||
|
|
||||||
// Replace reserved characters in filenames.
|
// Replace reserved characters in filenames.
|
||||||
configName = configName.replace(/:/g, "#").replace(/\//g, "$");
|
configName = configName.replace(/:/g, "#").replace(/\//g, "$");
|
||||||
|
|
||||||
// Check if the JSON content should be minified.
|
// Check if the JSON content should be minified.
|
||||||
const json = !strapi.config.get('plugin.config-sync').minify
|
const json = !strapi.config.get('plugin::config-sync').minify
|
||||||
? JSON.stringify(fileContents, null, 2)
|
? JSON.stringify(fileContents, null, 2)
|
||||||
: JSON.stringify(fileContents);
|
: JSON.stringify(fileContents);
|
||||||
|
|
||||||
if (!fs.existsSync(strapi.config.get('plugin.config-sync.syncDir'))) {
|
if (!fs.existsSync(strapi.config.get('plugin::config-sync.syncDir'))) {
|
||||||
fs.mkdirSync(strapi.config.get('plugin.config-sync.syncDir'), { recursive: true });
|
fs.mkdirSync(strapi.config.get('plugin::config-sync.syncDir'), { recursive: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
const writeFile = util.promisify(fs.writeFile);
|
const writeFile = util.promisify(fs.writeFile);
|
||||||
await writeFile(`${strapi.config.get('plugin.config-sync.syncDir')}${configType}.${configName}.json`, json)
|
await writeFile(`${strapi.config.get('plugin::config-sync.syncDir')}${configType}.${configName}.json`, json)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// @TODO:
|
// @TODO:
|
||||||
// Add logging for successfull config export.
|
// Add logging for successfull config export.
|
||||||
|
@ -56,13 +56,13 @@ module.exports = () => ({
|
||||||
*/
|
*/
|
||||||
deleteConfigFile: async (configName) => {
|
deleteConfigFile: async (configName) => {
|
||||||
// Check if the config should be excluded.
|
// Check if the config should be excluded.
|
||||||
const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => configName.startsWith(option)));
|
const shouldExclude = !isEmpty(strapi.config.get('plugin::config-sync.excludedConfig').filter((option) => configName.startsWith(option)));
|
||||||
if (shouldExclude) return;
|
if (shouldExclude) return;
|
||||||
|
|
||||||
// Replace reserved characters in filenames.
|
// Replace reserved characters in filenames.
|
||||||
configName = configName.replace(/:/g, "#").replace(/\//g, "$");
|
configName = configName.replace(/:/g, "#").replace(/\//g, "$");
|
||||||
|
|
||||||
fs.unlinkSync(`${strapi.config.get('plugin.config-sync.syncDir')}${configName}.json`);
|
fs.unlinkSync(`${strapi.config.get('plugin::config-sync.syncDir')}${configName}.json`);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -77,7 +77,7 @@ module.exports = () => ({
|
||||||
configName = configName.replace(/:/g, "#").replace(/\//g, "$");
|
configName = configName.replace(/:/g, "#").replace(/\//g, "$");
|
||||||
|
|
||||||
const readFile = util.promisify(fs.readFile);
|
const readFile = util.promisify(fs.readFile);
|
||||||
return readFile(`${strapi.config.get('plugin.config-sync.syncDir')}${configType}.${configName}.json`)
|
return readFile(`${strapi.config.get('plugin::config-sync.syncDir')}${configType}.${configName}.json`)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
return JSON.parse(data);
|
return JSON.parse(data);
|
||||||
})
|
})
|
||||||
|
@ -94,11 +94,11 @@ module.exports = () => ({
|
||||||
* @returns {object} Object with key value pairs of configs.
|
* @returns {object} Object with key value pairs of configs.
|
||||||
*/
|
*/
|
||||||
getAllConfigFromFiles: async (configType = null) => {
|
getAllConfigFromFiles: async (configType = null) => {
|
||||||
if (!fs.existsSync(strapi.config.get('plugin.config-sync.syncDir'))) {
|
if (!fs.existsSync(strapi.config.get('plugin::config-sync.syncDir'))) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const configFiles = fs.readdirSync(strapi.config.get('plugin.config-sync.syncDir'));
|
const configFiles = fs.readdirSync(strapi.config.get('plugin::config-sync.syncDir'));
|
||||||
|
|
||||||
const getConfigs = async () => {
|
const getConfigs = async () => {
|
||||||
const fileConfigs = {};
|
const fileConfigs = {};
|
||||||
|
@ -113,7 +113,7 @@ module.exports = () => ({
|
||||||
if (
|
if (
|
||||||
configType && configType !== type
|
configType && configType !== type
|
||||||
|| !strapi.plugin('config-sync').types[type]
|
|| !strapi.plugin('config-sync').types[type]
|
||||||
|| !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => `${type}.${name}`.startsWith(option)))
|
|| !isEmpty(strapi.config.get('plugin::config-sync.excludedConfig').filter((option) => `${type}.${name}`.startsWith(option)))
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -219,7 +219,7 @@ module.exports = () => ({
|
||||||
*/
|
*/
|
||||||
importSingleConfig: async (configName, onSuccess, force) => {
|
importSingleConfig: async (configName, onSuccess, force) => {
|
||||||
// Check if the config should be excluded.
|
// Check if the config should be excluded.
|
||||||
const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => configName.startsWith(option)));
|
const shouldExclude = !isEmpty(strapi.config.get('plugin::config-sync.excludedConfig').filter((option) => configName.startsWith(option)));
|
||||||
if (shouldExclude) return;
|
if (shouldExclude) return;
|
||||||
|
|
||||||
const type = configName.split('.')[0]; // Grab the first part of the filename.
|
const type = configName.split('.')[0]; // Grab the first part of the filename.
|
||||||
|
@ -244,7 +244,7 @@ module.exports = () => ({
|
||||||
*/
|
*/
|
||||||
exportSingleConfig: async (configName, onSuccess) => {
|
exportSingleConfig: async (configName, onSuccess) => {
|
||||||
// Check if the config should be excluded.
|
// Check if the config should be excluded.
|
||||||
const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => configName.startsWith(option)));
|
const shouldExclude = !isEmpty(strapi.config.get('plugin::config-sync.excludedConfig').filter((option) => configName.startsWith(option)));
|
||||||
if (shouldExclude) return;
|
if (shouldExclude) return;
|
||||||
|
|
||||||
const type = configName.split('.')[0]; // Grab the first part of the filename.
|
const type = configName.split('.')[0]; // Grab the first part of the filename.
|
||||||
|
|
Loading…
Reference in New Issue