feat(deletion): delete on import

pull/5/head
Boaz Poolman 2021-03-27 17:12:40 +01:00
parent 4d90117796
commit 8b0f688d3f
3 changed files with 21 additions and 2 deletions

View File

@ -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 });

View File

@ -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;

View File

@ -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);
}
},