feat(deletion): delete on import
parent
4d90117796
commit
8b0f688d3f
|
@ -38,11 +38,18 @@ module.exports = {
|
|||
const shouldExclude = strapi.plugins['config-sync'].config.exclude.includes(`${configPrefix}.${configName}`);
|
||||
if (shouldExclude) return;
|
||||
|
||||
const { value, ...fileContent } = configContent;
|
||||
const coreStoreAPI = strapi.query(coreStoreQueryString);
|
||||
|
||||
const configExists = await coreStoreAPI
|
||||
.findOne({ key: configName, environment: fileContent.environment });
|
||||
.findOne({ key: configName });
|
||||
|
||||
if (configExists && configContent === null) {
|
||||
await coreStoreAPI.delete({ key: configName });
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const { value, ...fileContent } = configContent;
|
||||
|
||||
if (!configExists) {
|
||||
await coreStoreAPI.create({ value: JSON.stringify(value), ...fileContent });
|
||||
|
|
|
@ -61,6 +61,15 @@ module.exports = {
|
|||
.query('role', 'users-permissions')
|
||||
.findOne({ type: configName });
|
||||
|
||||
if (role && configContent === null) {
|
||||
const publicRole = await strapi.query('role', 'users-permissions').findOne({ type: 'public' });
|
||||
const publicRoleID = publicRole.id;
|
||||
|
||||
await service.deleteRole(role.id, publicRoleID);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const users = role ? role.users : [];
|
||||
configContent.users = users;
|
||||
|
||||
|
|
|
@ -44,6 +44,9 @@ module.exports = {
|
|||
if (!configExists) {
|
||||
await webhookAPI.create(configContent);
|
||||
} else {
|
||||
if (configContent === null) {
|
||||
await webhookAPI.delete({ id: configName });
|
||||
}
|
||||
await webhookAPI.update({ id: configName }, configContent);
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue