diff --git a/bin/config-sync b/bin/config-sync old mode 100755 new mode 100644 diff --git a/server/config/type.js b/server/config/type.js index cf07732..ff82ed8 100644 --- a/server/config/type.js +++ b/server/config/type.js @@ -13,9 +13,9 @@ const ConfigType = class ConfigType { process.exit(0); } // uid could be a single key or an array for a combined uid. So the type of uid is either string or string[] - if(typeof uid === "string"){ + if (typeof uid === "string") { this.uidKeys = [uid]; - } else if(Array.isArray(uid)){ + } else if (Array.isArray(uid)) { this.uidKeys = uid.sort(); } else { strapi.log.error(logMessage(`Wrong uid config for the '${configName}' config type.`)); @@ -139,7 +139,6 @@ const ConfigType = class ConfigType { if (shouldExclude) return; const currentConfig = formattedDiff.databaseConfig[configName]; - const combinedUid = getCombinedUid(this.uidKeys, currentConfig); if ( !currentConfig @@ -147,6 +146,7 @@ const ConfigType = class ConfigType { ) { await strapi.plugin('config-sync').service('main').deleteConfigFile(configName); } else { + const combinedUid = getCombinedUid(this.uidKeys, currentConfig); await strapi.plugin('config-sync').service('main').writeConfigFile(this.configPrefix, combinedUid, currentConfig); } } diff --git a/server/utils/index.js b/server/utils/index.js index 2c1f91f..847d799 100644 --- a/server/utils/index.js +++ b/server/utils/index.js @@ -3,7 +3,7 @@ const COMBINED_UID_JOINSTR = '+.+'; const escapeUid = (uid) => typeof uid === "string" ? uid.replace(/\+\.\+/g, '+_._+') : uid; -const unEscapeUid = (uid) => typeof uid === "string" ? uid.replace(/\+_\._\+_/g, '+.+') : uid; +const unEscapeUid = (uid) => typeof uid === "string" ? uid.replace(/\+_\._\+/g, '+.+') : uid; const getCombinedUid = (uidKeys, params) => uidKeys.map((uidKey) => escapeUid(params[uidKey])).join(COMBINED_UID_JOINSTR); const getCombinedUidWhereFilter = (uidKeys, params) => uidKeys.reduce(((akku, uidKey) => ({ ...akku, [uidKey]: params[uidKey] })), {}); const getUidParamsFromName = (uidKeys, configName) => configName.split(COMBINED_UID_JOINSTR).map(unEscapeUid).reduce((akku, param, i) => ({ ...akku, [uidKeys[i]]: param }), {}); diff --git a/yarn.lock b/yarn.lock index e6a158d..6b7c508 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12493,4 +12493,4 @@ yup@^0.32.9: lodash-es "^4.17.21" nanoclone "^0.2.1" property-expr "^2.0.4" - toposort "^2.0.2" \ No newline at end of file + toposort "^2.0.2"