From b85bb25a09645dbcb3d4116769b7d3cb971e001c Mon Sep 17 00:00:00 2001 From: Sebastien Date: Mon, 22 Feb 2021 16:06:37 +0100 Subject: [PATCH] Workaround SharingRule and Workflow deployability (#102) * Add the parent type for Workflow and SharingRule sub type By calling the parent method to add element Only if not a custom label type (this type is tricky) CustomLabel could be refactored in their own handler * Fix issue when CustomLabel file is added It generated a false package.xml with false type for custom label * Add test case scenario * Improve test case scenario for CustomLabels * Add more precise commands for execution context --- .github/ISSUE_TEMPLATE/issue.md | 23 ++++++------------- .github/PULL_REQUEST_TEMPLATE.md | 12 ++++++---- .../unit/lib/service/inFileHandler.test.js | 19 ++++++++++++++- src/service/inFileHandler.js | 7 +++++- src/utils/metadataConstants.js | 4 +++- 5 files changed, 41 insertions(+), 24 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/issue.md b/.github/ISSUE_TEMPLATE/issue.md index 9b4da118..fd60995f 100644 --- a/.github/ISSUE_TEMPLATE/issue.md +++ b/.github/ISSUE_TEMPLATE/issue.md @@ -67,30 +67,21 @@ _(Write your answer here.)_ --- **Operating System:** … -**Yarn version:** … - -**Node version:** … +**yarn version:** … -**sgd version:** … +**node version:** … **git version:** … +**sfdx version:** … + +**sgd plugin version:** … + ## Optional more information --- diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 3f2fb009..c54fafa4 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -68,15 +68,17 @@ _(Write your answer here.)_ --- **Operating System:** … -**Yarn version:** … +**yarn version:** … -**Node version:** … - -**sgd version:** … +**node version:** … **git version:** … + +**sfdx version:** … + +**sgd plugin version:** … diff --git a/__tests__/unit/lib/service/inFileHandler.test.js b/__tests__/unit/lib/service/inFileHandler.test.js index 28afa49b..a09e516d 100644 --- a/__tests__/unit/lib/service/inFileHandler.test.js +++ b/__tests__/unit/lib/service/inFileHandler.test.js @@ -103,6 +103,11 @@ describe(`test if inFileHandler`, () => { expect(work.diffs.package).toMatchObject( testContext.expectedData[expectedType] ) + if (expectedType === mc.LABEL_EXTENSION) { + expect(work.diffs.package).not.toHaveProperty(expectedType) + } else { + expect(work.diffs.package).toHaveProperty(expectedType) + } }) test('deletion', () => { const work = { @@ -127,7 +132,9 @@ describe(`test if inFileHandler`, () => { testContext.expectedData[expectedType] ) expect(work.diffs.destructiveChanges).not.toHaveProperty('workflows') - expect(work.diffs.destructiveChanges).not.toHaveProperty('labels') + expect(work.diffs.destructiveChanges).not.toHaveProperty( + mc.LABEL_EXTENSION + ) expect(work.diffs.destructiveChanges).not.toHaveProperty('sharingRules') }) test('modification', () => { @@ -154,6 +161,11 @@ describe(`test if inFileHandler`, () => { expect(work.diffs.package).toBeDefined() expect(work.diffs.destructiveChanges).toBeDefined() + if (expectedType === mc.LABEL_EXTENSION) { + expect(work.diffs.package).not.toHaveProperty(expectedType) + } else { + expect(work.diffs.package).toHaveProperty(expectedType) + } }) test('modification without delta generation', () => { @@ -178,6 +190,11 @@ describe(`test if inFileHandler`, () => { expect(work.diffs.package).toMatchObject( testContext.expectedData[expectedType] ) + if (expectedType === mc.LABEL_EXTENSION) { + expect(work.diffs.package).not.toHaveProperty(expectedType) + } else { + expect(work.diffs.package).toHaveProperty(expectedType) + } }) } ) diff --git a/src/service/inFileHandler.js b/src/service/inFileHandler.js index 28f25314..e221bb10 100644 --- a/src/service/inFileHandler.js +++ b/src/service/inFileHandler.js @@ -37,7 +37,9 @@ class InFileHandler extends StandardHandler { } handleAddition() { - super.handleAddition() + if (this.type !== mc.LABEL_EXTENSION) { + super.handleAddition() + } this._fillPackageFromFile(this.diffs.package) } @@ -46,6 +48,9 @@ class InFileHandler extends StandardHandler { } handleModification() { + if (this.type !== mc.LABEL_EXTENSION) { + super.handleAddition() + } const toAdd = this._handleInFile() this._handleFileWriting(toAdd) } diff --git a/src/utils/metadataConstants.js b/src/utils/metadataConstants.js index f55c63bd..6e507701 100644 --- a/src/utils/metadataConstants.js +++ b/src/utils/metadataConstants.js @@ -4,7 +4,8 @@ const META_REGEX = new RegExp(`${METAFILE_SUFFIX}$`) const OBJECT_META_XML_SUFFIX = `object${METAFILE_SUFFIX}` const MASTER_DETAIL_TAG = 'MasterDetail' const FIELD_DIRECTORY_NAME = 'fields' -const LABEL_DIRECTORY_NAME = 'labels.labels' +const LABEL_EXTENSION = 'labels' +const LABEL_DIRECTORY_NAME = `labels.${LABEL_EXTENSION}` const OBJECT_TRANSLATION_META_XML_SUFFIX = `objectTranslation${METAFILE_SUFFIX}` const INFOLDER_SUFFIX = `Folder` const WAVE_SUB_TYPES_PREFIX = 'Wave' @@ -13,6 +14,7 @@ module.exports.META_REGEX = META_REGEX module.exports.OBJECT_META_XML_SUFFIX = OBJECT_META_XML_SUFFIX module.exports.MASTER_DETAIL_TAG = MASTER_DETAIL_TAG module.exports.FIELD_DIRECTORY_NAME = FIELD_DIRECTORY_NAME +module.exports.LABEL_EXTENSION = LABEL_EXTENSION module.exports.LABEL_DIRECTORY_NAME = LABEL_DIRECTORY_NAME module.exports.INFOLDER_SUFFIX = INFOLDER_SUFFIX module.exports.OBJECT_TRANSLATION_META_XML_SUFFIX = OBJECT_TRANSLATION_META_XML_SUFFIX