Skip to content

Commit c93546b

Browse files
committed
feat: Allow excluding configs by giving part of the config name
1 parent 724f56f commit c93546b

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

server/config/type.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const { isEmpty } = require('lodash');
12
const { logMessage, sanitizeConfig, dynamicSort, noLimit } = require('../utils');
23
const difference = require('../utils/getArrayDiff');
34

@@ -31,7 +32,7 @@ const ConfigType = class ConfigType {
3132
*/
3233
importSingle = async (configName, configContent) => {
3334
// Check if the config should be excluded.
34-
const shouldExclude = strapi.config.get('plugin.config-sync.excludedConfig').includes(`${this.configPrefix}.${configName}`);
35+
const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => `${this.configPrefix}.${configName}`.startsWith(option)));
3536
if (shouldExclude) return;
3637

3738
const queryAPI = strapi.query(this.queryString);
@@ -134,7 +135,7 @@ const ConfigType = class ConfigType {
134135
const formattedDiff = await strapi.plugin('config-sync').service('main').getFormattedDiff(this.configPrefix);
135136

136137
// Check if the config should be excluded.
137-
const shouldExclude = strapi.config.get('plugin.config-sync.excludedConfig').includes(`${configName}`);
138+
const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => configName.startsWith(option)));
138139
if (shouldExclude) return;
139140

140141
const currentConfig = formattedDiff.databaseConfig[configName];
@@ -160,7 +161,7 @@ const ConfigType = class ConfigType {
160161

161162
await Promise.all(Object.values(AllConfig).map(async (config) => {
162163
// Check if the config should be excluded.
163-
const shouldExclude = strapi.config.get('plugin.config-sync.excludedConfig').includes(`${this.configPrefix}.${config[this.uid]}`);
164+
const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => `${this.configPrefix}.${config[this.uid]}`.startsWith(option)));
164165
if (shouldExclude) return;
165166

166167
const formattedConfig = { ...sanitizeConfig(config) };

server/services/main.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
22

3+
const { isEmpty } = require('lodash');
34
const fs = require('fs');
45
const util = require('util');
56
const difference = require('../utils/getObjectDiff');
@@ -19,7 +20,7 @@ module.exports = () => ({
1920
*/
2021
writeConfigFile: async (configType, configName, fileContents) => {
2122
// Check if the config should be excluded.
22-
const shouldExclude = strapi.config.get('plugin.config-sync.excludedConfig').includes(`${configType}.${configName}`);
23+
const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => `${configType}.${configName}`.startsWith(option)));
2324
if (shouldExclude) return;
2425

2526
// Replace ':' with '#' in filenames for Windows support.
@@ -54,7 +55,7 @@ module.exports = () => ({
5455
*/
5556
deleteConfigFile: async (configName) => {
5657
// Check if the config should be excluded.
57-
const shouldExclude = strapi.config.get('plugin.config-sync.excludedConfig').includes(`${configName}`);
58+
const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => configName.startsWith(option)));
5859
if (shouldExclude) return;
5960

6061
// Replace ':' with '#' in filenames for Windows support.
@@ -111,7 +112,7 @@ module.exports = () => ({
111112
if (
112113
configType && configType !== type
113114
|| !strapi.plugin('config-sync').types[type]
114-
|| strapi.config.get('plugin.config-sync.excludedConfig').includes(`${type}.${name}`)
115+
|| !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => `${type}.${name}`.startsWith(option)))
115116
) {
116117
return;
117118
}
@@ -210,7 +211,7 @@ module.exports = () => ({
210211
*/
211212
importSingleConfig: async (configName, onSuccess) => {
212213
// Check if the config should be excluded.
213-
const shouldExclude = strapi.config.get('plugin.config-sync.excludedConfig').includes(configName);
214+
const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => configName.startsWith(option)));
214215
if (shouldExclude) return;
215216

216217
const type = configName.split('.')[0]; // Grab the first part of the filename.
@@ -236,7 +237,7 @@ module.exports = () => ({
236237
*/
237238
exportSingleConfig: async (configName, onSuccess) => {
238239
// Check if the config should be excluded.
239-
const shouldExclude = strapi.config.get('plugin.config-sync.excludedConfig').includes(configName);
240+
const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => configName.startsWith(option)));
240241
if (shouldExclude) return;
241242

242243
const type = configName.split('.')[0]; // Grab the first part of the filename.

0 commit comments

Comments
 (0)