Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: document extension handling #136

Merged
merged 6 commits into from
Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions __tests__/__utils__/testHandlerHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ global.testHandlerHelper = testContext => {
globalMetadata
)
handler.handle()
expect(testContext.work.diffs.package).toHaveProperty(
expectedType ?? type,
expected
)
})
test('deletion', () => {
const handler = new testContext.handler(
Expand All @@ -44,6 +48,10 @@ global.testHandlerHelper = testContext => {
globalMetadata
)
handler.handle()
expect(testContext.work.diffs.package).toHaveProperty(
expectedType ?? type,
expected
)
})
}
)
Expand Down
15 changes: 15 additions & 0 deletions __tests__/unit/lib/service/inFolderHandler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ const testContext = {
'force-app/main/default/reports/folder.reportFolder-meta.xml',
new Set(['folder']),
],
[
'documents',
'force-app/main/default/documents/folder.documentFolder-meta.xml',
new Set(['folder']),
],
[
'documents',
'force-app/main/default/documents/folder/document.test.ext',
new Set(['folder/document.test']),
],
[
'documents',
'force-app/main/default/documents/folder/document.test.document-meta.xml',
new Set(['folder/document.test']),
],
],
work: {
config: { output: '', repo: '.', generateDelta: true },
Expand Down
3 changes: 2 additions & 1 deletion src/metadata/a48.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@
"directoryName": "documents",
"inFolder": true,
"metaFile": true,
"suffix": "document",
"xmlName": "Document"
},
{
Expand Down Expand Up @@ -1277,4 +1278,4 @@
"xmlName": "WorkflowTask",
"xmlTag": "tasks"
}
]
]
8 changes: 6 additions & 2 deletions src/metadata/v46.json
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@
"directoryName": "documents",
"inFolder": true,
"metaFile": true,
"suffix": "document",
"xmlName": "Document"
},
{
Expand Down Expand Up @@ -569,7 +570,10 @@
"xmlName": "ContentAsset"
},
{
"childXmlNames": ["SharingOwnerRule", "SharingCriteriaRule"],
"childXmlNames": [
"SharingOwnerRule",
"SharingCriteriaRule"
],
"directoryName": "sharingRules",
"inFolder": false,
"metaFile": false,
Expand Down Expand Up @@ -1027,4 +1031,4 @@
"xmlName": "WorkflowTask",
"xmlTag": "tasks"
}
]
]
3 changes: 2 additions & 1 deletion src/metadata/v47.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@
"directoryName": "documents",
"inFolder": true,
"metaFile": true,
"suffix": "document",
"xmlName": "Document"
},
{
Expand Down Expand Up @@ -1255,4 +1256,4 @@
"xmlName": "WorkflowTask",
"xmlTag": "tasks"
}
]
]
3 changes: 2 additions & 1 deletion src/metadata/v49.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@
"directoryName": "documents",
"inFolder": true,
"metaFile": true,
"suffix": "document",
"xmlName": "Document"
},
{
Expand Down Expand Up @@ -1269,4 +1270,4 @@
"xmlName": "WorkflowTask",
"xmlTag": "tasks"
}
]
]
3 changes: 2 additions & 1 deletion src/metadata/v50.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@
"directoryName": "documents",
"inFolder": true,
"metaFile": true,
"suffix": "document",
"xmlName": "Document"
},
{
Expand Down Expand Up @@ -1269,4 +1270,4 @@
"xmlName": "WorkflowTask",
"xmlTag": "tasks"
}
]
]
7 changes: 2 additions & 5 deletions src/service/inFolderHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ const mc = require('../utils/metadataConstants')
const path = require('path')

const INFOLDER_SUFFIX_REGEX = new RegExp(`${mc.INFOLDER_SUFFIX}$`)
const EXTENSION_SUFFIX_REGEX = new RegExp(/\.[^/.]+$/)
class InFolderHandler extends StandardHandler {
handleDeletion() {
this._fillPackage(this.diffs.destructiveChanges)
}

handleAddition() {
super.handleAddition()
if (!this.config.generateDelta) return
Expand Down Expand Up @@ -45,7 +42,7 @@ class InFolderHandler extends StandardHandler {
.join(path.sep)
.replace(mc.META_REGEX, '')
.replace(INFOLDER_SUFFIX_REGEX, '')
.replace(this.suffixRegex, '')
.replace(EXTENSION_SUFFIX_REGEX, '')

packageObject[this.type].add(
StandardHandler.cleanUpPackageMember(packageMember)
Expand Down