diff --git a/server/config/type.js b/server/config/type.js index 30ac5fa..f96fade 100644 --- a/server/config/type.js +++ b/server/config/type.js @@ -1,3 +1,4 @@ +const { isEmpty } = require('lodash'); const { logMessage, sanitizeConfig, dynamicSort, noLimit } = require('../utils'); const difference = require('../utils/getArrayDiff'); @@ -31,7 +32,7 @@ const ConfigType = class ConfigType { */ importSingle = async (configName, configContent) => { // Check if the config should be excluded. - const shouldExclude = strapi.config.get('plugin.config-sync.excludedConfig').includes(`${this.configPrefix}.${configName}`); + const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => `${this.configPrefix}.${configName}`.startsWith(option))); if (shouldExclude) return; const queryAPI = strapi.query(this.queryString); @@ -134,7 +135,7 @@ const ConfigType = class ConfigType { const formattedDiff = await strapi.plugin('config-sync').service('main').getFormattedDiff(this.configPrefix); // Check if the config should be excluded. - const shouldExclude = strapi.config.get('plugin.config-sync.excludedConfig').includes(`${configName}`); + const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => configName.startsWith(option))); if (shouldExclude) return; const currentConfig = formattedDiff.databaseConfig[configName]; @@ -160,7 +161,7 @@ const ConfigType = class ConfigType { await Promise.all(Object.values(AllConfig).map(async (config) => { // Check if the config should be excluded. - const shouldExclude = strapi.config.get('plugin.config-sync.excludedConfig').includes(`${this.configPrefix}.${config[this.uid]}`); + const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => `${this.configPrefix}.${config[this.uid]}`.startsWith(option))); if (shouldExclude) return; const formattedConfig = { ...sanitizeConfig(config) }; diff --git a/server/services/main.js b/server/services/main.js index f122df7..76d2d22 100644 --- a/server/services/main.js +++ b/server/services/main.js @@ -1,5 +1,6 @@ 'use strict'; +const { isEmpty } = require('lodash'); const fs = require('fs'); const util = require('util'); const difference = require('../utils/getObjectDiff'); @@ -19,7 +20,7 @@ module.exports = () => ({ */ writeConfigFile: async (configType, configName, fileContents) => { // Check if the config should be excluded. - const shouldExclude = strapi.config.get('plugin.config-sync.excludedConfig').includes(`${configType}.${configName}`); + const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => `${configType}.${configName}`.startsWith(option))); if (shouldExclude) return; // Replace ':' with '#' in filenames for Windows support. @@ -54,7 +55,7 @@ module.exports = () => ({ */ deleteConfigFile: async (configName) => { // Check if the config should be excluded. - const shouldExclude = strapi.config.get('plugin.config-sync.excludedConfig').includes(`${configName}`); + const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => configName.startsWith(option))); if (shouldExclude) return; // Replace ':' with '#' in filenames for Windows support. @@ -111,7 +112,7 @@ module.exports = () => ({ if ( configType && configType !== type || !strapi.plugin('config-sync').types[type] - || strapi.config.get('plugin.config-sync.excludedConfig').includes(`${type}.${name}`) + || !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => `${type}.${name}`.startsWith(option))) ) { return; } @@ -210,7 +211,7 @@ module.exports = () => ({ */ importSingleConfig: async (configName, onSuccess) => { // Check if the config should be excluded. - const shouldExclude = strapi.config.get('plugin.config-sync.excludedConfig').includes(configName); + const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => configName.startsWith(option))); if (shouldExclude) return; const type = configName.split('.')[0]; // Grab the first part of the filename. @@ -236,7 +237,7 @@ module.exports = () => ({ */ exportSingleConfig: async (configName, onSuccess) => { // Check if the config should be excluded. - const shouldExclude = strapi.config.get('plugin.config-sync.excludedConfig').includes(configName); + const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => configName.startsWith(option))); if (shouldExclude) return; const type = configName.split('.')[0]; // Grab the first part of the filename.