fix: Some bugs
parent
02e0d5bd13
commit
d0982f6390
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 }), {});
|
||||
|
|
Loading…
Reference in New Issue