Skip to content

Commit

Permalink
Workaround SharingRule and Workflow deployability (#102)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
scolladon authored Feb 22, 2021
1 parent ef2388a commit b85bb25
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 24 deletions.
23 changes: 7 additions & 16 deletions .github/ISSUE_TEMPLATE/issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,30 +67,21 @@ _(Write your answer here.)_
---

<!--
Mac version / Window version / Linux version and distribution
Node version ($ node -v)
Yarn version ($ yarn -v)
sgd version ($ sgd -V)
Ex :
Mac OS Mojave Version 10.14.6
node v14.5.0
Yarn 1.22.5
sgd 3.1.2
git 2.30.0
$ uname -v ; yarn -v ; node -v ; sgd --version ; git --version
$ uname -v ; yarn -v ; node -v ; git --version ; sfdx --version ; sfdx plugins
-->

**Operating System:**

**Yarn version:**

**Node version:**
**yarn version:**

**sgd version:**
**node version:**

**git version:**

**sfdx version:**

**sgd plugin version:**

## Optional more information

---
Expand Down
12 changes: 7 additions & 5 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,17 @@ _(Write your answer here.)_
---

<!--
$ uname -v ; yarn -v ; node -v ; sgd --version ; git --version
$ uname -v ; yarn -v ; node -v ; git --version ; sfdx --version ; sfdx plugins
-->

**Operating System:**

**Yarn version:**
**yarn version:**

**Node version:**

**sgd version:**
**node version:**

**git version:**

**sfdx version:**

**sgd plugin version:**
19 changes: 18 additions & 1 deletion __tests__/unit/lib/service/inFileHandler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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', () => {
Expand All @@ -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', () => {
Expand All @@ -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)
}
})
}
)
Expand Down
7 changes: 6 additions & 1 deletion src/service/inFileHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ class InFileHandler extends StandardHandler {
}

handleAddition() {
super.handleAddition()
if (this.type !== mc.LABEL_EXTENSION) {
super.handleAddition()
}
this._fillPackageFromFile(this.diffs.package)
}

Expand All @@ -46,6 +48,9 @@ class InFileHandler extends StandardHandler {
}

handleModification() {
if (this.type !== mc.LABEL_EXTENSION) {
super.handleAddition()
}
const toAdd = this._handleInFile()
this._handleFileWriting(toAdd)
}
Expand Down
4 changes: 3 additions & 1 deletion src/utils/metadataConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ const META_REGEX = new RegExp(`${METAFILE_SUFFIX}$`)
const OBJECT_META_XML_SUFFIX = `object${METAFILE_SUFFIX}`
const MASTER_DETAIL_TAG = '<type>MasterDetail</type>'
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'
Expand All @@ -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
Expand Down

0 comments on commit b85bb25

Please sign in to comment.