From cba53e3eefaeeab29d46e2c215dfd48cf955b91f Mon Sep 17 00:00:00 2001 From: "Torgeir S. hos Sykehuspartner" <93591857+torgst@users.noreply.github.com> Date: Sat, 14 Sep 2024 13:39:39 +0000 Subject: [PATCH 1/3] update comments from #249 I found the logic behind some of what happened here hard to follow and updated the comments to try to make it easier to follow. --- lib/plugins/diffable.js | 3 ++- lib/plugins/environments.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/plugins/diffable.js b/lib/plugins/diffable.js index 74871691..8db6a0ef 100644 --- a/lib/plugins/diffable.js +++ b/lib/plugins/diffable.js @@ -93,7 +93,7 @@ module.exports = class Diffable extends ErrorStash { } } - // Filter out all empty entries (usually from repo override) + // Remove any null or undefined values from the diffables (usually comes from repo override) for (const entry of filteredEntries) { for (const key of Object.keys(entry)) { if (entry[key] === null || entry[key] === undefined) { @@ -101,6 +101,7 @@ module.exports = class Diffable extends ErrorStash { } } } + // Delete any diffable that now only has name and no other attributes filteredEntries = filteredEntries.filter(entry => Object.keys(entry).filter(key => !MergeDeep.NAME_FIELDS.includes(key)).length !== 0) const changes = [] diff --git a/lib/plugins/environments.js b/lib/plugins/environments.js index 6d52b409..dafb0ed5 100644 --- a/lib/plugins/environments.js +++ b/lib/plugins/environments.js @@ -296,7 +296,7 @@ module.exports = class Environments extends Diffable { let filteredEntries = this.filterEntries() return this.find().then(existingRecords => { - // Filter out all empty entries (usually from repo override) + // Remove any null or undefined values from the diffables (usually comes from repo override) for (const entry of filteredEntries) { for (const key of Object.keys(entry)) { if (entry[key] === null || entry[key] === undefined) { From 2bf5f876a39101a1274622c0bb70a28020ba75d9 Mon Sep 17 00:00:00 2001 From: "Torgeir S. hos Sykehuspartner" <93591857+torgst@users.noreply.github.com> Date: Sat, 14 Sep 2024 13:42:05 +0000 Subject: [PATCH 2/3] fix environments updating global array The environments plugin was changing `MergeDeep.NAME_FIELDS`, which is a global object. The reason was to avoid environments being filtered out from the change list if they only have a name field. However, the environments plugin has it's own overriden sync method, and thus we can simply drop the whole filtering from that method. Fixes #108 --- lib/plugins/environments.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/plugins/environments.js b/lib/plugins/environments.js index dafb0ed5..4ceaa9ff 100644 --- a/lib/plugins/environments.js +++ b/lib/plugins/environments.js @@ -17,10 +17,6 @@ module.exports = class Environments extends Diffable { } }) } - - // Remove 'name' from filtering list so Environments with only a name defined are processed. - MergeDeep.NAME_FIELDS.splice(MergeDeep.NAME_FIELDS.indexOf('name'), 1) - } async find() { @@ -304,7 +300,7 @@ module.exports = class Environments extends Diffable { } } } - filteredEntries = filteredEntries.filter(entry => Object.keys(entry).filter(key => !MergeDeep.NAME_FIELDS.includes(key)).length !== 0) + // For environments, we want to keep the entries with only name defined. const changes = [] From dae9cb7dcf8f193fa08e12e5c80de808b9c4b5ba Mon Sep 17 00:00:00 2001 From: "Torgeir S. hos Sykehuspartner" <93591857+torgst@users.noreply.github.com> Date: Sat, 14 Sep 2024 13:45:42 +0000 Subject: [PATCH 3/3] remove repeating line This has to be a "typo" from 9a74e05 calling the same assignment twice. Removing to clean up. --- lib/mergeDeep.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/mergeDeep.js b/lib/mergeDeep.js index a685a048..054a5b34 100644 --- a/lib/mergeDeep.js +++ b/lib/mergeDeep.js @@ -378,5 +378,4 @@ class MergeDeep { } } MergeDeep.NAME_FIELDS = NAME_FIELDS -MergeDeep.NAME_FIELDS = NAME_FIELDS module.exports = MergeDeep