mcdev 5.0.2 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.coverage-comment-template.svelte +177 -161
- package/.eslintrc.json +4 -4
- package/.github/ISSUE_TEMPLATE/bug.yml +2 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +2 -2
- package/.github/dependabot.yml +8 -0
- package/.github/workflows/coverage-base-update.yml +6 -2
- package/.github/workflows/coverage-develop-branch.yml +7 -8
- package/.github/workflows/coverage-main-branch.yml +7 -8
- package/.github/workflows/coverage.yml +7 -4
- package/.husky/post-checkout +4 -2
- package/.husky/post-merge +1 -0
- package/.vscode/extensions.json +4 -0
- package/docs/dist/documentation.md +756 -294
- package/lib/Deployer.js +28 -28
- package/lib/MetadataTypeDefinitions.js +1 -1
- package/lib/MetadataTypeInfo.js +1 -1
- package/lib/Retriever.js +1 -1
- package/lib/cli.js +184 -6
- package/lib/index.js +493 -22
- package/lib/metadataTypes/Asset.js +10 -11
- package/lib/metadataTypes/AttributeGroup.js +76 -2
- package/lib/metadataTypes/AttributeSet.js +260 -0
- package/lib/metadataTypes/Automation.js +771 -247
- package/lib/metadataTypes/DataExtension.js +7 -7
- package/lib/metadataTypes/DataExtensionField.js +1 -1
- package/lib/metadataTypes/Event.js +2 -3
- package/lib/metadataTypes/Folder.js +1 -1
- package/lib/metadataTypes/Journey.js +5 -6
- package/lib/metadataTypes/MetadataType.js +187 -60
- package/lib/metadataTypes/MobileKeyword.js +8 -8
- package/lib/metadataTypes/MobileMessage.js +5 -5
- package/lib/metadataTypes/Query.js +47 -5
- package/lib/metadataTypes/Script.js +3 -3
- package/lib/metadataTypes/TransactionalSMS.js +5 -5
- package/lib/metadataTypes/TriggeredSend.js +25 -50
- package/lib/metadataTypes/User.js +7 -4
- package/lib/metadataTypes/definitions/Asset.definition.js +1 -0
- package/lib/metadataTypes/definitions/AttributeGroup.definition.js +117 -106
- package/lib/metadataTypes/definitions/{SetDefinition.definition.js → AttributeSet.definition.js} +54 -27
- package/lib/metadataTypes/definitions/Automation.definition.js +74 -21
- package/lib/metadataTypes/definitions/DataExtension.definition.js +1 -0
- package/lib/metadataTypes/definitions/DataExtract.definition.js +1 -0
- package/lib/metadataTypes/definitions/EmailSend.definition.js +1 -0
- package/lib/metadataTypes/definitions/Event.definition.js +1 -0
- package/lib/metadataTypes/definitions/Filter.definition.js +1 -0
- package/lib/metadataTypes/definitions/ImportFile.definition.js +37 -6
- package/lib/metadataTypes/definitions/MobileKeyword.definition.js +1 -0
- package/lib/metadataTypes/definitions/Query.definition.js +1 -0
- package/lib/metadataTypes/definitions/Role.definition.js +1 -0
- package/lib/metadataTypes/definitions/TriggeredSend.definition.js +2 -0
- package/lib/metadataTypes/definitions/User.definition.js +1 -0
- package/lib/util/cache.js +9 -4
- package/lib/util/cli.js +40 -0
- package/lib/util/devops.js +13 -11
- package/lib/util/file.js +2 -2
- package/lib/util/init.js +84 -0
- package/lib/util/util.js +268 -137
- package/package.json +11 -11
- package/test/general.test.js +26 -0
- package/test/mockRoot/.mcdevrc.json +1 -1
- package/test/mockRoot/deploy/testInstance/testBU/automation/testExisting_automation.automation-meta.json +52 -0
- package/test/mockRoot/deploy/testInstance/testBU/automation/testNew_automation.automation-meta.json +45 -0
- package/test/mockRoot/deploy/testInstance/testBU/dataExtract/testExisting_dataExtract.dataExtract-meta.json +35 -0
- package/test/mockRoot/deploy/testInstance/testBU/dataExtract/testNew_dataExtract.dataExtract-meta.json +35 -0
- package/test/mockRoot/deploy/testInstance/testBU/fileTransfer/testExisting_fileTransfer.fileTransfer-meta.json +17 -0
- package/test/mockRoot/deploy/testInstance/testBU/fileTransfer/testNew_fileTransfer.fileTransfer-meta.json +17 -0
- package/test/mockRoot/deploy/testInstance/testBU/importFile/testExisting_importFile.importFile-meta.json +29 -0
- package/test/mockRoot/deploy/testInstance/testBU/importFile/testNew_importFile.importFile-meta.json +29 -0
- package/test/mockRoot/deploy/testInstance/testBU/query/{testExistingQuery.query-meta.json → testExisting_query.query-meta.json} +2 -2
- package/test/mockRoot/deploy/testInstance/testBU/query/testExisting_query_fixKeys.query-meta.json +11 -0
- package/test/mockRoot/deploy/testInstance/testBU/query/testExisting_query_fixKeys.query-meta.sql +6 -0
- package/test/mockRoot/deploy/testInstance/testBU/query/{testNewQuery.query-meta.json → testNew_query.query-meta.json} +2 -2
- package/test/mockRoot/deploy/testInstance/testBU/script/testExisting_script.script-meta.json +6 -0
- package/test/mockRoot/deploy/testInstance/testBU/script/testExisting_script.script-meta.ssjs +1 -0
- package/test/mockRoot/deploy/testInstance/testBU/script/testNew_script.script-meta.json +6 -0
- package/test/mockRoot/deploy/testInstance/testBU/script/testNew_script.script-meta.ssjs +1 -0
- package/test/mockRoot/deploy/testInstance/testBU/triggeredSend/testExisting_triggeredSend.triggeredSend-meta.json +29 -0
- package/test/mockRoot/deploy/testInstance/testBU/triggeredSend/testNew_triggeredSend.triggeredSend-meta.json +29 -0
- package/test/resourceFactory.js +132 -24
- package/test/resources/1111111/accountUser/retrieve-ActiveFlag=falseANDCustomerKey=testExisting_userANDEmaillike@-response.xml +27 -0
- package/test/resources/1111111/accountUser/retrieve-ActiveFlag=falseANDEmaillike@-response.xml +156 -0
- package/test/resources/1111111/accountUser/retrieve-ActiveFlag=trueANDEmailisNullORNamelikeapp userANDMustChangePassword=false-response.xml +87 -0
- package/test/resources/1111111/accountUser/retrieve-ActiveFlag=trueANDEmaillike@-response.xml +156 -0
- package/test/resources/1111111/accountUser/retrieve-CustomerKey=testExisting_userANDActiveFlag=trueANDEmailisNullORNamelikeapp userANDMustChangePassword=false-response.xml +27 -0
- package/test/resources/1111111/accountUserAccount/retrieve-AccountUser.AccountUserID=700301950-response.xml +60 -0
- package/test/resources/1111111/user/retrieve-expected.md +4 -2
- package/test/resources/9999999/attributeGroup/retrieve-expected.json +25 -0
- package/test/resources/9999999/attributeSet/retrieve-expected.json +748 -0
- package/test/resources/9999999/automation/build-expected.json +57 -0
- package/test/resources/9999999/automation/create-expected.json +45 -0
- package/test/resources/9999999/automation/create-testNew_automation-expected.md +28 -0
- package/test/resources/9999999/automation/delete-response.xml +40 -0
- package/test/resources/9999999/automation/patch_fixKeys-pause-expected.json +44 -0
- package/test/resources/9999999/automation/patch_fixKeys-schedule-expected.json +44 -0
- package/test/resources/9999999/automation/perform-08afb0e2-b00a-4c88-ad2e-1f7f8788c560-response.xml +42 -0
- package/test/resources/9999999/automation/perform-08afb0e2-b00a-4c88-fixKey_pause-response.xml +42 -0
- package/test/resources/9999999/automation/perform-08afb0e2-b00a-4c88-fixKey_schedule-response.xml +42 -0
- package/test/resources/9999999/automation/perform-a8afb0e2-b00a-4c88-ad2e-1f7f8788c560-response.xml +42 -0
- package/test/resources/9999999/automation/retrieve-expected.json +57 -0
- package/test/resources/9999999/automation/retrieve-testExisting_automation-expected.md +30 -0
- package/test/resources/9999999/automation/schedule-08afb0e2-b00a-4c88-ad2e-1f7f8788c560-response.xml +52 -0
- package/test/resources/9999999/automation/schedule-08afb0e2-b00a-4c88-ad2e-pause-response.xml +38 -0
- package/test/resources/9999999/automation/schedule-08afb0e2-b00a-4c88-fixKey_pause-response.xml +52 -0
- package/test/resources/9999999/automation/schedule-08afb0e2-b00a-4c88-fixKey_schedule-response.xml +52 -0
- package/test/resources/9999999/automation/schedule-a8afb0e2-b00a-4c88-ad2e-1f7f8788c560-response.xml +52 -0
- package/test/resources/9999999/automation/template-expected.json +57 -0
- package/test/resources/9999999/automation/update-expected.json +45 -0
- package/test/resources/9999999/automation/update-testExisting_automation-expected.md +28 -0
- package/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-1f7f8788c560/get-response.json +85 -0
- package/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-1f7f8788c560/patch-response.json +85 -0
- package/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-pause/get-response.json +85 -0
- package/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-pause/patch-response.json +85 -0
- package/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-fixKey_pause/get-response.json +85 -0
- package/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-fixKey_pause/patch-response.json +85 -0
- package/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-fixKey_schedule/get-response.json +85 -0
- package/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-fixKey_schedule/patch-response.json +85 -0
- package/test/resources/9999999/automation/v1/automations/a8afb0e2-b00a-4c88-ad2e-1f7f8788c560/get-response.json +85 -0
- package/test/resources/9999999/automation/v1/automations/post-response.json +86 -0
- package/test/resources/9999999/automation/v1/dataextracts/56c5370a-f988-4f36-b0ee-0f876573f6d7/get-response.json +38 -0
- package/test/resources/9999999/automation/v1/dataextracts/56c5370a-f988-4f36-b0ee-0f876573f6d7/patch-response.json +38 -0
- package/test/resources/9999999/automation/v1/dataextracts/get-response.json +20 -0
- package/test/resources/9999999/automation/v1/dataextracts/post-response.json +38 -0
- package/test/resources/9999999/automation/v1/dataextracttypes/get-response.json +50 -0
- package/test/resources/9999999/automation/v1/filetransfers/72c328ac-f5b0-4e37-91d3-a775666f15a6/get-response.json +18 -0
- package/test/resources/9999999/automation/v1/filetransfers/72c328ac-f5b0-4e37-91d3-a775666f15a6/patch-response.json +18 -0
- package/test/resources/9999999/automation/v1/filetransfers/get-response.json +15 -0
- package/test/resources/9999999/automation/v1/filetransfers/post-response.json +18 -0
- package/test/resources/9999999/automation/v1/ftplocations/get-response.json +18 -0
- package/test/resources/9999999/automation/v1/imports/9d16f42c-2260-ed11-b849-48df37d1de8b/patch-response.json +31 -0
- package/test/resources/9999999/automation/v1/imports/get-response.json +38 -0
- package/test/resources/9999999/automation/v1/imports/post-response.json +30 -0
- package/test/resources/9999999/automation/v1/queries/549f0568-607c-4940-afef-437965094dae/actions/start/post-response.txt +1 -0
- package/test/resources/9999999/automation/v1/queries/549f0568-607c-4940-afef-437965094dat/actions/start/post-response.txt +1 -0
- package/test/resources/9999999/automation/v1/queries/549f0568-607c-4940-afef-437965094dat/get-response.json +2 -2
- package/test/resources/9999999/automation/v1/queries/549f0568-607c-4940-afef-437965094dat/patch-response.json +2 -2
- package/test/resources/9999999/automation/v1/queries/549f0568-607c-4940-afef-437965094dat_fixKeys/get-response.json +17 -0
- package/test/resources/9999999/automation/v1/queries/549f0568-607c-4940-afef-437965094dat_fixKeys/patch-response.json +18 -0
- package/test/resources/9999999/automation/v1/queries/get-response.json +22 -5
- package/test/resources/9999999/automation/v1/queries/post-response.json +2 -2
- package/test/resources/9999999/automation/v1/scripts/39f6a488-20eb-4ba0-b0b9-023725b574e4/patch-response.json +10 -0
- package/test/resources/9999999/automation/v1/scripts/get-response.json +27 -0
- package/test/resources/9999999/automation/v1/scripts/post-response.json +10 -0
- package/test/resources/9999999/dataExtension/retrieve-Name=testExisting_dataExtension-response.xml +52 -0
- package/test/resources/9999999/dataExtensionField/retrieve-DataExtension.CustomerKey=testExisting_dataExtension-response.xml +98 -0
- package/test/resources/9999999/dataExtensionField/retrieve-DataExtension.CustomerKey=testNew_dataExtensionORDataExtension.CustomerKey=testExisting_dataExtension-response.xml +99 -0
- package/test/resources/9999999/dataExtract/build-expected.json +35 -0
- package/test/resources/9999999/dataExtract/get-expected.json +39 -0
- package/test/resources/9999999/dataExtract/patch-expected.json +37 -0
- package/test/resources/9999999/dataExtract/post-expected.json +37 -0
- package/test/resources/9999999/dataExtract/template-expected.json +35 -0
- package/test/resources/9999999/dataFolder/retrieve-ContentType=automations-response.xml +48 -0
- package/test/resources/9999999/dataFolder/retrieve-ContentType=contextual_suppression_listORContentType=publicationORContentType=suppression_listORContentType=mysubsORContentType=list-response.xml +136 -0
- package/test/resources/9999999/dataFolder/retrieve-ContentType=queryactivity-response.xml +48 -0
- package/test/resources/9999999/dataFolder/retrieve-ContentType=ssjsactivity-response.xml +48 -0
- package/test/resources/9999999/dataFolder/retrieve-ContentType=triggered_send_journeybuilderORContentType=triggered_sendORContentType=hidden-response.xml +276 -0
- package/test/resources/9999999/dataFolder/retrieve-response.xml +45 -0
- package/test/resources/9999999/email/retrieve-response.xml +203 -0
- package/test/resources/9999999/emailSendDefinition/retrieve-IsPlatformObject=falseANDDescriptionnotEqualsSFSendDefinition-response.xml +85 -0
- package/test/resources/9999999/fileTransfer/build-expected.json +15 -0
- package/test/resources/9999999/fileTransfer/get-expected.json +17 -0
- package/test/resources/9999999/fileTransfer/patch-expected.json +17 -0
- package/test/resources/9999999/fileTransfer/post-expected.json +17 -0
- package/test/resources/9999999/fileTransfer/template-expected.json +15 -0
- package/test/resources/9999999/hub/v1/contacts/schema/attributeGroups/get-response.json +585 -0
- package/test/resources/9999999/hub/v1/contacts/schema/setDefinitions/get-response.json +19807 -0
- package/test/resources/9999999/importFile/build-expected.json +27 -0
- package/test/resources/9999999/importFile/get-expected.json +29 -0
- package/test/resources/9999999/importFile/patch-expected.json +29 -0
- package/test/resources/9999999/importFile/post-expected.json +29 -0
- package/test/resources/9999999/importFile/template-expected.json +27 -0
- package/test/resources/9999999/legacy/v1/beta/automations/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow/get-response.json +21 -0
- package/test/resources/9999999/legacy/v1/beta/automations/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow/post-response.json +0 -0
- package/test/resources/9999999/legacy/v1/beta/bulk/automations/automation/definition/get-response.json +30 -0
- package/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation-response.xml +30 -0
- package/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_fixKey_pause-response.xml +32 -0
- package/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_fixKey_schedule-response.xml +32 -0
- package/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_fixedKey_paused-response.xml +32 -0
- package/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_fixedKey_scheduled-response.xml +32 -0
- package/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_pause-response.xml +30 -0
- package/test/resources/9999999/program/retrieve-CustomerKey=testNew_automation-response.xml +30 -0
- package/test/resources/9999999/program/retrieve-Name=testExisting_automation-response.xml +31 -0
- package/test/resources/9999999/program/retrieve-response.xml +50 -0
- package/test/resources/9999999/query/build-expected.json +2 -2
- package/test/resources/9999999/query/get-expected.json +2 -2
- package/test/resources/9999999/query/get2-expected.json +2 -2
- package/test/resources/9999999/query/patch-expected.json +2 -2
- package/test/resources/9999999/query/patch_fixKeys-expected.json +11 -0
- package/test/resources/9999999/query/patch_fixKeys-expected.sql +6 -0
- package/test/resources/9999999/query/post-expected.json +2 -2
- package/test/resources/9999999/query/template-expected.json +2 -2
- package/test/resources/9999999/queryDefinition/retrieve-CustomerKey=testExisting_query_fixKeysANDStatus=Active-response.xml +30 -0
- package/test/resources/9999999/queryDefinition/retrieve-CustomerKey=testExisting_query_fixedKeysANDStatus=Active-response.xml +30 -0
- package/test/resources/9999999/queryDefinition/retrieve-CustomerKey=testNew_queryANDStatus=Active-response.xml +30 -0
- package/test/resources/9999999/script/build-expected.json +6 -0
- package/test/resources/9999999/script/build-expected.ssjs +1 -0
- package/test/resources/9999999/script/get-expected.json +8 -0
- package/test/resources/9999999/script/get-expected.ssjs +1 -0
- package/test/resources/9999999/script/get_noScriptTag-expected.html +1 -0
- package/test/resources/9999999/script/get_noScriptTag-expected.json +8 -0
- package/test/resources/9999999/script/patch-expected.json +8 -0
- package/test/resources/9999999/script/patch-expected.ssjs +1 -0
- package/test/resources/9999999/script/post-expected.json +8 -0
- package/test/resources/9999999/script/post-expected.ssjs +1 -0
- package/test/resources/9999999/script/template-expected.json +6 -0
- package/test/resources/9999999/script/template-expected.ssjs +1 -0
- package/test/resources/9999999/triggeredSend/build-expected.json +29 -0
- package/test/resources/9999999/triggeredSend/get-expected.json +29 -0
- package/test/resources/9999999/triggeredSend/patch-expected.json +29 -0
- package/test/resources/9999999/triggeredSend/post-expected.json +29 -0
- package/test/resources/9999999/triggeredSend/template-expected.json +29 -0
- package/test/resources/9999999/triggeredSendDefinition/create-response.xml +75 -0
- package/test/resources/9999999/triggeredSendDefinition/delete-response.xml +36 -0
- package/test/resources/9999999/triggeredSendDefinition/{retrieve-response.xml → retrieve-TriggeredSendStatusINNew,Active,Inactive,Moved,Canceled-response.xml} +4 -4
- package/test/resources/9999999/triggeredSendDefinition/update-response.xml +74 -0
- package/test/type.attributeGroup.test.js +55 -0
- package/test/type.attributeSet.test.js +55 -0
- package/test/type.automation.test.js +886 -0
- package/test/type.dataExtension.test.js +3 -1
- package/test/type.dataExtract.test.js +187 -0
- package/test/type.fileTransfer.test.js +185 -0
- package/test/type.importFile.test.js +186 -0
- package/test/type.mobileKeyword.test.js +0 -1
- package/test/type.query.test.js +497 -33
- package/test/type.script.test.js +367 -0
- package/test/type.triggeredSend.test.js +152 -0
- package/test/type.user.test.js +37 -11
- package/test/utils.js +10 -6
- package/.coverage-comment-template.md +0 -20
- package/lib/metadataTypes/SetDefinition.js +0 -37
- /package/test/mockRoot/deploy/testInstance/testBU/query/{testExistingQuery.query-meta.sql → testExisting_query.query-meta.sql} +0 -0
- /package/test/mockRoot/deploy/testInstance/testBU/query/{testNewQuery.query-meta.sql → testNew_query.query-meta.sql} +0 -0
- /package/test/resources/1111111/accountUser/{retrieve-response.xml → retrieve-ActiveFlag=trueANDCustomerKey=testExisting_userANDEmaillike@-response.xml} +0 -0
- /package/test/resources/1111111/accountUserAccount/{retrieve-response.xml → retrieve-AccountUser.AccountUserIDIN700301950,700301951,7471228-response.xml} +0 -0
- /package/test/resources/1111111/businessUnit/{retrieve-response.xml → retrieve-ID=1111111-response.xml} +0 -0
- /package/test/resources/1111111/list/{retrieve-response.xml → retrieve-CustomerKey=All SubscribersORListName=All Subscribers-response.xml} +0 -0
- /package/test/resources/1111111/role/{retrieve-response.xml → retrieve-IsPrivate=false-response.xml} +0 -0
- /package/test/resources/9999999/queryDefinition/{retrieve-response.xml → retrieve-CustomerKey=testExisting_queryANDStatus=Active-response.xml} +0 -0
package/lib/index.js
CHANGED
|
@@ -51,13 +51,18 @@ class Mcdev {
|
|
|
51
51
|
static setOptions(argv) {
|
|
52
52
|
const knownOptions = [
|
|
53
53
|
'api',
|
|
54
|
-
'commitHistory',
|
|
55
54
|
'changeKeyField',
|
|
56
55
|
'changeKeyValue',
|
|
56
|
+
'commitHistory',
|
|
57
|
+
'execute',
|
|
57
58
|
'filter',
|
|
58
59
|
'fromRetrieve',
|
|
59
60
|
'json',
|
|
61
|
+
'like',
|
|
62
|
+
'noLogColors',
|
|
63
|
+
'noLogFile',
|
|
60
64
|
'refresh',
|
|
65
|
+
'schedule',
|
|
61
66
|
'skipInteraction',
|
|
62
67
|
];
|
|
63
68
|
for (const option of knownOptions) {
|
|
@@ -89,6 +94,7 @@ class Mcdev {
|
|
|
89
94
|
* @returns {Promise.<TYPE.DeltaPkgItem[]>} list of changed items
|
|
90
95
|
*/
|
|
91
96
|
static async createDeltaPkg(argv) {
|
|
97
|
+
Util.startLogger();
|
|
92
98
|
Util.logger.info('Create Delta Package ::');
|
|
93
99
|
const properties = await config.getProperties();
|
|
94
100
|
if (!(await config.checkProperties(properties))) {
|
|
@@ -111,6 +117,7 @@ class Mcdev {
|
|
|
111
117
|
* @returns {Promise} .
|
|
112
118
|
*/
|
|
113
119
|
static async selectTypes() {
|
|
120
|
+
Util.startLogger();
|
|
114
121
|
const properties = await config.getProperties();
|
|
115
122
|
if (!(await config.checkProperties(properties))) {
|
|
116
123
|
return null;
|
|
@@ -127,6 +134,7 @@ class Mcdev {
|
|
|
127
134
|
* @returns {Promise.<boolean>} success flag
|
|
128
135
|
*/
|
|
129
136
|
static async upgrade() {
|
|
137
|
+
Util.startLogger();
|
|
130
138
|
const properties = await config.getProperties();
|
|
131
139
|
if (!properties) {
|
|
132
140
|
Util.logger.error('No config found. Please run mcdev init');
|
|
@@ -149,6 +157,8 @@ class Mcdev {
|
|
|
149
157
|
* @returns {Promise.<object>} -
|
|
150
158
|
*/
|
|
151
159
|
static async retrieve(businessUnit, selectedTypesArr, keys, changelogOnly) {
|
|
160
|
+
console.time('Time'); // eslint-disable-line no-console
|
|
161
|
+
Util.startLogger();
|
|
152
162
|
Util.logger.info('mcdev:: Retrieve');
|
|
153
163
|
const properties = await config.getProperties();
|
|
154
164
|
if (!(await config.checkProperties(properties))) {
|
|
@@ -166,22 +176,32 @@ class Mcdev {
|
|
|
166
176
|
}
|
|
167
177
|
}
|
|
168
178
|
}
|
|
169
|
-
|
|
179
|
+
const resultsObj = {};
|
|
170
180
|
if (businessUnit === '*') {
|
|
171
|
-
Util.logger.info('
|
|
181
|
+
Util.logger.info(':: Retrieving all BUs for all credentials');
|
|
172
182
|
let counter_credTotal = 0;
|
|
173
183
|
for (const cred in properties.credentials) {
|
|
174
|
-
Util.logger.info(
|
|
184
|
+
Util.logger.info(`:: Retrieving all BUs for ${cred}`);
|
|
175
185
|
let counter_credBu = 0;
|
|
176
186
|
for (const bu in properties.credentials[cred].businessUnits) {
|
|
177
|
-
await this
|
|
187
|
+
resultsObj[`${cred}/${bu}`] = await this.#retrieveBU(
|
|
188
|
+
cred,
|
|
189
|
+
bu,
|
|
190
|
+
selectedTypesArr,
|
|
191
|
+
keys
|
|
192
|
+
);
|
|
178
193
|
counter_credBu++;
|
|
179
|
-
Util.
|
|
194
|
+
Util.startLogger(true);
|
|
180
195
|
}
|
|
181
196
|
counter_credTotal += counter_credBu;
|
|
182
|
-
Util.logger.info(
|
|
197
|
+
Util.logger.info(`:: ${counter_credBu} BUs of ${cred}\n`);
|
|
183
198
|
}
|
|
184
|
-
|
|
199
|
+
const credentialCount = Object.keys(properties.credentials).length;
|
|
200
|
+
Util.logger.info(
|
|
201
|
+
`:: Done for ${counter_credTotal} BUs of ${credentialCount} credential${
|
|
202
|
+
credentialCount === 1 ? '' : 's'
|
|
203
|
+
} in total\n`
|
|
204
|
+
);
|
|
185
205
|
} else {
|
|
186
206
|
let [cred, bu] = businessUnit ? businessUnit.split('/') : [null, null];
|
|
187
207
|
// to allow all-BU via user selection we need to run this here already
|
|
@@ -205,17 +225,22 @@ class Mcdev {
|
|
|
205
225
|
}
|
|
206
226
|
|
|
207
227
|
if (bu === '*' && properties.credentials && properties.credentials[cred]) {
|
|
208
|
-
Util.logger.info(
|
|
228
|
+
Util.logger.info(`:: Retrieving all BUs for ${cred}`);
|
|
209
229
|
let counter_credBu = 0;
|
|
210
230
|
for (const bu in properties.credentials[cred].businessUnits) {
|
|
211
|
-
await this
|
|
231
|
+
resultsObj[`${cred}/${bu}`] = await this.#retrieveBU(
|
|
232
|
+
cred,
|
|
233
|
+
bu,
|
|
234
|
+
selectedTypesArr,
|
|
235
|
+
keys
|
|
236
|
+
);
|
|
212
237
|
counter_credBu++;
|
|
213
|
-
Util.
|
|
238
|
+
Util.startLogger(true);
|
|
214
239
|
}
|
|
215
|
-
Util.logger.info(
|
|
240
|
+
Util.logger.info(`:: Done for ${counter_credBu} BUs of ${cred}\n`);
|
|
216
241
|
} else {
|
|
217
242
|
// retrieve a single BU; return
|
|
218
|
-
const retrieveChangelog = await this
|
|
243
|
+
const retrieveChangelog = await this.#retrieveBU(
|
|
219
244
|
cred,
|
|
220
245
|
bu,
|
|
221
246
|
selectedTypesArr,
|
|
@@ -223,14 +248,33 @@ class Mcdev {
|
|
|
223
248
|
changelogOnly
|
|
224
249
|
);
|
|
225
250
|
if (changelogOnly) {
|
|
251
|
+
console.timeEnd('Time'); // eslint-disable-line no-console
|
|
226
252
|
return retrieveChangelog;
|
|
253
|
+
} else {
|
|
254
|
+
resultsObj[`${cred}/${bu}`] = retrieveChangelog;
|
|
227
255
|
}
|
|
228
256
|
Util.logger.info(`:: Done\n`);
|
|
229
257
|
}
|
|
230
258
|
}
|
|
259
|
+
|
|
260
|
+
// merge all results into one object
|
|
261
|
+
for (const credBu in resultsObj) {
|
|
262
|
+
for (const type in resultsObj[credBu]) {
|
|
263
|
+
const base = resultsObj[credBu][type][0];
|
|
264
|
+
|
|
265
|
+
for (let i = 1; i < resultsObj[credBu][type].length; i++) {
|
|
266
|
+
// merge all items into the first array
|
|
267
|
+
Object.assign(base, resultsObj[credBu][type][i]);
|
|
268
|
+
}
|
|
269
|
+
resultsObj[credBu][type] = resultsObj[credBu][type][0];
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
console.timeEnd('Time'); // eslint-disable-line no-console
|
|
273
|
+
|
|
274
|
+
return resultsObj;
|
|
231
275
|
}
|
|
232
276
|
/**
|
|
233
|
-
* helper for {@link retrieve}
|
|
277
|
+
* helper for {@link Mcdev.retrieve}
|
|
234
278
|
*
|
|
235
279
|
* @private
|
|
236
280
|
* @param {string} cred name of Credential
|
|
@@ -240,7 +284,7 @@ class Mcdev {
|
|
|
240
284
|
* @param {boolean} [changelogOnly] skip saving, only create json in memory
|
|
241
285
|
* @returns {Promise.<object>} ensure that BUs are worked on sequentially
|
|
242
286
|
*/
|
|
243
|
-
static async
|
|
287
|
+
static async #retrieveBU(cred, bu, selectedTypesArr, keys, changelogOnly) {
|
|
244
288
|
const properties = await config.getProperties();
|
|
245
289
|
if (!(await config.checkProperties(properties))) {
|
|
246
290
|
return null;
|
|
@@ -258,6 +302,7 @@ class Mcdev {
|
|
|
258
302
|
// clean up old folders after types were renamed
|
|
259
303
|
// TODO: Remove renamedTypes-logic 6 months after version 5 release
|
|
260
304
|
const renamedTypes = {
|
|
305
|
+
attributeSet: 'setDefinition',
|
|
261
306
|
emailSend: 'emailSendDefinition',
|
|
262
307
|
event: 'eventDefinition',
|
|
263
308
|
fileLocation: 'ftpLocation',
|
|
@@ -265,7 +310,7 @@ class Mcdev {
|
|
|
265
310
|
triggeredSend: 'triggeredSendDefinition',
|
|
266
311
|
user: 'accountUser',
|
|
267
312
|
};
|
|
268
|
-
Util.logger.info(
|
|
313
|
+
Util.logger.info(`:: Retrieving ${cred}/${bu}\n`);
|
|
269
314
|
const retrieveTypesArr = [];
|
|
270
315
|
if (selectedTypesArr) {
|
|
271
316
|
for (const selectedType of Array.isArray(selectedTypesArr)
|
|
@@ -332,9 +377,7 @@ class Mcdev {
|
|
|
332
377
|
null,
|
|
333
378
|
changelogOnly
|
|
334
379
|
);
|
|
335
|
-
|
|
336
|
-
return retrieveChangelog;
|
|
337
|
-
}
|
|
380
|
+
return retrieveChangelog;
|
|
338
381
|
} catch (ex) {
|
|
339
382
|
Util.logger.errorStack(ex, 'mcdev.retrieve failed');
|
|
340
383
|
}
|
|
@@ -347,11 +390,14 @@ class Mcdev {
|
|
|
347
390
|
* @param {string} businessUnit references credentials from properties.json
|
|
348
391
|
* @param {TYPE.SupportedMetadataTypes[]} [selectedTypesArr] limit deployment to given metadata type
|
|
349
392
|
* @param {string[]} [keyArr] limit deployment to given metadata keys
|
|
350
|
-
* @param {boolean} [fromRetrieve] optionally deploy whats defined via selectedTypesArr + keyArr directly from retrieve folder instead of from deploy folder
|
|
351
393
|
* @returns {Promise.<Object.<string,TYPE.MultiMetadataTypeMap>>} deployed metadata per BU (first key: bu name, second key: metadata type)
|
|
352
394
|
*/
|
|
353
|
-
static async deploy(businessUnit, selectedTypesArr, keyArr
|
|
354
|
-
|
|
395
|
+
static async deploy(businessUnit, selectedTypesArr, keyArr) {
|
|
396
|
+
console.time('Time'); // eslint-disable-line no-console
|
|
397
|
+
Util.startLogger();
|
|
398
|
+
const deployResult = await Deployer.deploy(businessUnit, selectedTypesArr, keyArr);
|
|
399
|
+
console.timeEnd('Time'); // eslint-disable-line no-console
|
|
400
|
+
return deployResult;
|
|
355
401
|
}
|
|
356
402
|
|
|
357
403
|
/**
|
|
@@ -361,6 +407,7 @@ class Mcdev {
|
|
|
361
407
|
* @returns {Promise.<void>} -
|
|
362
408
|
*/
|
|
363
409
|
static async initProject(credentialsName) {
|
|
410
|
+
Util.startLogger();
|
|
364
411
|
Util.logger.info('mcdev:: Setting up project');
|
|
365
412
|
const properties = await config.getProperties(!!credentialsName, true);
|
|
366
413
|
await Init.initProject(properties, credentialsName);
|
|
@@ -371,6 +418,7 @@ class Mcdev {
|
|
|
371
418
|
* @returns {Promise.<void>} -
|
|
372
419
|
*/
|
|
373
420
|
static async joinProject() {
|
|
421
|
+
Util.startLogger();
|
|
374
422
|
Util.logger.info('mcdev:: Joining an existing project');
|
|
375
423
|
await Init.joinProject();
|
|
376
424
|
}
|
|
@@ -382,6 +430,7 @@ class Mcdev {
|
|
|
382
430
|
* @returns {Promise.<void>} -
|
|
383
431
|
*/
|
|
384
432
|
static async findBUs(credentialsName) {
|
|
433
|
+
Util.startLogger();
|
|
385
434
|
Util.logger.info('mcdev:: Load BUs');
|
|
386
435
|
const properties = await config.getProperties();
|
|
387
436
|
if (!(await config.checkProperties(properties))) {
|
|
@@ -401,6 +450,7 @@ class Mcdev {
|
|
|
401
450
|
* @returns {Promise.<void>} -
|
|
402
451
|
*/
|
|
403
452
|
static async document(businessUnit, type) {
|
|
453
|
+
Util.startLogger();
|
|
404
454
|
Util.logger.info('mcdev:: Document');
|
|
405
455
|
const properties = await config.getProperties();
|
|
406
456
|
if (!(await config.checkProperties(properties))) {
|
|
@@ -440,6 +490,7 @@ class Mcdev {
|
|
|
440
490
|
* @returns {Promise.<boolean>} true if successful, false otherwise
|
|
441
491
|
*/
|
|
442
492
|
static async deleteByKey(businessUnit, type, customerKey) {
|
|
493
|
+
Util.startLogger();
|
|
443
494
|
Util.logger.info('mcdev:: delete');
|
|
444
495
|
if (!Util._isValidType(type)) {
|
|
445
496
|
return;
|
|
@@ -477,6 +528,7 @@ class Mcdev {
|
|
|
477
528
|
* @returns {Promise.<void>} -
|
|
478
529
|
*/
|
|
479
530
|
static async refresh(businessUnit, type, keyArr) {
|
|
531
|
+
Util.startLogger();
|
|
480
532
|
Util.logger.info('mcdev:: refresh');
|
|
481
533
|
if (!type || !Util._isValidType(type, true)) {
|
|
482
534
|
type = 'triggeredSend';
|
|
@@ -512,6 +564,7 @@ class Mcdev {
|
|
|
512
564
|
* @returns {Promise.<void>} -
|
|
513
565
|
*/
|
|
514
566
|
static async badKeys(businessUnit) {
|
|
567
|
+
Util.startLogger();
|
|
515
568
|
const properties = await config.getProperties();
|
|
516
569
|
if (!(await config.checkProperties(properties))) {
|
|
517
570
|
return null;
|
|
@@ -585,6 +638,7 @@ class Mcdev {
|
|
|
585
638
|
* @returns {Promise.<TYPE.MultiMetadataTypeList>} -
|
|
586
639
|
*/
|
|
587
640
|
static async retrieveAsTemplate(businessUnit, selectedType, name, market) {
|
|
641
|
+
Util.startLogger();
|
|
588
642
|
Util.logger.info('mcdev:: Retrieve as Template');
|
|
589
643
|
const properties = await config.getProperties();
|
|
590
644
|
if (!(await config.checkProperties(properties))) {
|
|
@@ -626,6 +680,7 @@ class Mcdev {
|
|
|
626
680
|
* @returns {Promise.<TYPE.MultiMetadataTypeList>} -
|
|
627
681
|
*/
|
|
628
682
|
static async buildTemplate(businessUnit, selectedType, keyArr, market) {
|
|
683
|
+
Util.startLogger();
|
|
629
684
|
Util.logger.info('mcdev:: Build Template from retrieved files');
|
|
630
685
|
return Builder.buildTemplate(businessUnit, selectedType, keyArr, market);
|
|
631
686
|
}
|
|
@@ -639,6 +694,7 @@ class Mcdev {
|
|
|
639
694
|
* @returns {Promise.<void>} -
|
|
640
695
|
*/
|
|
641
696
|
static async buildDefinition(businessUnit, selectedType, name, market) {
|
|
697
|
+
Util.startLogger();
|
|
642
698
|
Util.logger.info('mcdev:: Build Definition from Template');
|
|
643
699
|
return Builder.buildDefinition(businessUnit, selectedType, name, market);
|
|
644
700
|
}
|
|
@@ -652,6 +708,7 @@ class Mcdev {
|
|
|
652
708
|
* @returns {Promise.<void>} -
|
|
653
709
|
*/
|
|
654
710
|
static async buildDefinitionBulk(listName, type, name) {
|
|
711
|
+
Util.startLogger();
|
|
655
712
|
Util.logger.info('mcdev:: Build Definition from Template Bulk');
|
|
656
713
|
return Builder.buildDefinitionBulk(listName, type, name);
|
|
657
714
|
}
|
|
@@ -663,6 +720,7 @@ class Mcdev {
|
|
|
663
720
|
* @returns {Promise.<string[]>} list of all files that need to be committed in a flat array ['path/file1.ext', 'path/file2.ext']
|
|
664
721
|
*/
|
|
665
722
|
static async getFilesToCommit(businessUnit, selectedType, keyArr) {
|
|
723
|
+
Util.startLogger();
|
|
666
724
|
Util.logger.info('mcdev:: getFilesToCommit');
|
|
667
725
|
const properties = await config.getProperties();
|
|
668
726
|
if (!(await config.checkProperties(properties))) {
|
|
@@ -682,6 +740,419 @@ class Mcdev {
|
|
|
682
740
|
return DevOps.getFilesToCommit(properties, buObject, selectedType, keyArr);
|
|
683
741
|
}
|
|
684
742
|
}
|
|
743
|
+
/**
|
|
744
|
+
* Schedule an item (shortcut for execute --schedule)
|
|
745
|
+
*
|
|
746
|
+
* @param {string} businessUnit name of BU
|
|
747
|
+
* @param {TYPE.SupportedMetadataTypes} [selectedType] limit to given metadata types
|
|
748
|
+
* @param {string[]} [keys] customerkey of the metadata
|
|
749
|
+
* @returns {Promise.<Object.<string, string[]>>} key: business unit name, value: list of scheduled item keys
|
|
750
|
+
*/
|
|
751
|
+
static async schedule(businessUnit, selectedType, keys) {
|
|
752
|
+
this.setOptions({ schedule: true });
|
|
753
|
+
return this.#runMethod('execute', businessUnit, selectedType, keys);
|
|
754
|
+
}
|
|
755
|
+
/**
|
|
756
|
+
* Start/execute an item
|
|
757
|
+
*
|
|
758
|
+
* @param {string} businessUnit name of BU
|
|
759
|
+
* @param {TYPE.SupportedMetadataTypes} [selectedType] limit to given metadata types
|
|
760
|
+
* @param {string[]} [keys] customerkey of the metadata
|
|
761
|
+
* @returns {Promise.<Object.<string, string[]>>} key: business unit name, value: list of executed item keys
|
|
762
|
+
*/
|
|
763
|
+
static async execute(businessUnit, selectedType, keys) {
|
|
764
|
+
return this.#runMethod('execute', businessUnit, selectedType, keys);
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* pause an item
|
|
768
|
+
*
|
|
769
|
+
* @param {string} businessUnit name of BU
|
|
770
|
+
* @param {TYPE.SupportedMetadataTypes} [selectedType] limit to given metadata types
|
|
771
|
+
* @param {string[]} [keys] customerkey of the metadata
|
|
772
|
+
* @returns {Promise.<Object.<string, string[]>>} key: business unit name, value: list of paused item keys
|
|
773
|
+
*/
|
|
774
|
+
static async pause(businessUnit, selectedType, keys) {
|
|
775
|
+
return this.#runMethod('pause', businessUnit, selectedType, keys);
|
|
776
|
+
}
|
|
777
|
+
/**
|
|
778
|
+
* Updates the key to match the name field
|
|
779
|
+
*
|
|
780
|
+
* @param {string} businessUnit name of BU
|
|
781
|
+
* @param {TYPE.SupportedMetadataTypes} selectedType limit to given metadata types
|
|
782
|
+
* @param {string[]} [keys] customerkey of the metadata
|
|
783
|
+
* @returns {Promise.<Object.<string, string[]>>} key: business unit name, value: list of paused item keys
|
|
784
|
+
*/
|
|
785
|
+
static async fixKeys(businessUnit, selectedType, keys) {
|
|
786
|
+
return this.#runMethod('fixKeys', businessUnit, selectedType, keys);
|
|
787
|
+
}
|
|
788
|
+
/**
|
|
789
|
+
* run a method across BUs
|
|
790
|
+
*
|
|
791
|
+
* @param {'execute'|'pause'|'fixKeys'} methodName what to run
|
|
792
|
+
* @param {string} businessUnit name of BU
|
|
793
|
+
* @param {TYPE.SupportedMetadataTypes} [selectedType] limit to given metadata types
|
|
794
|
+
* @param {string[]} [keys] customerkey of the metadata
|
|
795
|
+
* @returns {Promise.<Object.<string, string[]>>} key: business unit name, value: list of affected item keys
|
|
796
|
+
*/
|
|
797
|
+
static async #runMethod(methodName, businessUnit, selectedType, keys) {
|
|
798
|
+
Util.startLogger();
|
|
799
|
+
let lang_past;
|
|
800
|
+
let lang_present;
|
|
801
|
+
let requireKeyOrLike;
|
|
802
|
+
let checkMetadataSupport;
|
|
803
|
+
const resultObj = {};
|
|
804
|
+
|
|
805
|
+
switch (methodName) {
|
|
806
|
+
case 'execute': {
|
|
807
|
+
lang_past = 'executed';
|
|
808
|
+
lang_present = 'executing';
|
|
809
|
+
requireKeyOrLike = true;
|
|
810
|
+
checkMetadataSupport = true;
|
|
811
|
+
break;
|
|
812
|
+
}
|
|
813
|
+
case 'pause': {
|
|
814
|
+
lang_past = 'paused';
|
|
815
|
+
lang_present = 'pausing';
|
|
816
|
+
requireKeyOrLike = true;
|
|
817
|
+
checkMetadataSupport = true;
|
|
818
|
+
break;
|
|
819
|
+
}
|
|
820
|
+
case 'fixKeys': {
|
|
821
|
+
lang_past = 'fixed keys';
|
|
822
|
+
lang_present = 'fixing keys';
|
|
823
|
+
requireKeyOrLike = false;
|
|
824
|
+
checkMetadataSupport = false;
|
|
825
|
+
break;
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
Util.logger.info(`mcdev:: ${methodName} ${selectedType}`);
|
|
830
|
+
const properties = await config.getProperties();
|
|
831
|
+
let counter_credBu = 0;
|
|
832
|
+
let counter_credKeys = 0;
|
|
833
|
+
if (!(await config.checkProperties(properties))) {
|
|
834
|
+
// return null here to avoid seeing 2 error messages for the same issue
|
|
835
|
+
return resultObj;
|
|
836
|
+
}
|
|
837
|
+
if (!Util._isValidType(selectedType)) {
|
|
838
|
+
return resultObj;
|
|
839
|
+
}
|
|
840
|
+
if (
|
|
841
|
+
checkMetadataSupport &&
|
|
842
|
+
!Object.prototype.hasOwnProperty.call(MetadataTypeInfo[selectedType], methodName)
|
|
843
|
+
) {
|
|
844
|
+
Util.logger.error(
|
|
845
|
+
` ☇ skipping ${selectedType}: ${methodName} is not supported yet for ${selectedType}`
|
|
846
|
+
);
|
|
847
|
+
return resultObj;
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
if (
|
|
851
|
+
requireKeyOrLike &&
|
|
852
|
+
(!Array.isArray(keys) || !keys.length) &&
|
|
853
|
+
(!Util.OPTIONS.like || !Object.keys(Util.OPTIONS.like).length)
|
|
854
|
+
) {
|
|
855
|
+
Util.logger.error('At least one key or a --like filter is required.');
|
|
856
|
+
return resultObj;
|
|
857
|
+
} else if (
|
|
858
|
+
Array.isArray(keys) &&
|
|
859
|
+
keys.length &&
|
|
860
|
+
Util.OPTIONS.like &&
|
|
861
|
+
Object.keys(Util.OPTIONS.like).length
|
|
862
|
+
) {
|
|
863
|
+
Util.logger.error('You can either specify keys OR a --like filter.');
|
|
864
|
+
return resultObj;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
if (businessUnit === '*') {
|
|
868
|
+
Util.OPTIONS._multiBuExecution = true;
|
|
869
|
+
Util.logger.info(
|
|
870
|
+
`:: ${lang_present} the ${selectedType} on all BUs for all credentials`
|
|
871
|
+
);
|
|
872
|
+
let counter_credTotal = 0;
|
|
873
|
+
for (const cred in properties.credentials) {
|
|
874
|
+
Util.logger.info(`:: ${lang_present} ${selectedType} on all BUs for ${cred}`);
|
|
875
|
+
// reset counter per cred
|
|
876
|
+
counter_credKeys = 0;
|
|
877
|
+
counter_credBu = 0;
|
|
878
|
+
for (const bu in properties.credentials[cred].businessUnits) {
|
|
879
|
+
resultObj[cred + '/' + bu] = await this.#runOnBU(
|
|
880
|
+
methodName,
|
|
881
|
+
cred,
|
|
882
|
+
bu,
|
|
883
|
+
selectedType,
|
|
884
|
+
keys
|
|
885
|
+
);
|
|
886
|
+
counter_credBu++;
|
|
887
|
+
counter_credKeys += resultObj[cred + '/' + bu].length;
|
|
888
|
+
Util.startLogger(true);
|
|
889
|
+
}
|
|
890
|
+
counter_credTotal += counter_credBu;
|
|
891
|
+
Util.logger.info(
|
|
892
|
+
`:: ${lang_past} for ${counter_credKeys} ${selectedType}s on ${counter_credBu} BUs for ${cred}`
|
|
893
|
+
);
|
|
894
|
+
}
|
|
895
|
+
Util.logger.info(
|
|
896
|
+
`:: ${lang_past} ${selectedType} on ${counter_credTotal} BUs in total\n`
|
|
897
|
+
);
|
|
898
|
+
} else {
|
|
899
|
+
let [cred, bu] = businessUnit ? businessUnit.split('/') : [null, null];
|
|
900
|
+
// to allow all-BU via user selection we need to run this here already
|
|
901
|
+
if (
|
|
902
|
+
properties.credentials &&
|
|
903
|
+
(!properties.credentials[cred] ||
|
|
904
|
+
(bu !== '*' && !properties.credentials[cred].businessUnits[bu]))
|
|
905
|
+
) {
|
|
906
|
+
const buObject = await Cli.getCredentialObject(
|
|
907
|
+
properties,
|
|
908
|
+
cred === null ? null : cred + '/' + bu,
|
|
909
|
+
null,
|
|
910
|
+
true
|
|
911
|
+
);
|
|
912
|
+
if (buObject === null) {
|
|
913
|
+
return resultObj;
|
|
914
|
+
} else {
|
|
915
|
+
cred = buObject.credential;
|
|
916
|
+
bu = buObject.businessUnit;
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
if (bu === '*' && properties.credentials && properties.credentials[cred]) {
|
|
920
|
+
Util.OPTIONS._multiBuExecution = true;
|
|
921
|
+
Util.logger.info(`:: ${lang_present} ${selectedType} on all BUs for ${cred}`);
|
|
922
|
+
for (const bu in properties.credentials[cred].businessUnits) {
|
|
923
|
+
resultObj[cred + '/' + bu] = await this.#runOnBU(
|
|
924
|
+
methodName,
|
|
925
|
+
cred,
|
|
926
|
+
bu,
|
|
927
|
+
selectedType,
|
|
928
|
+
keys
|
|
929
|
+
);
|
|
930
|
+
counter_credBu++;
|
|
931
|
+
counter_credKeys += resultObj[cred + '/' + bu].length;
|
|
932
|
+
Util.startLogger(true);
|
|
933
|
+
}
|
|
934
|
+
Util.logger.info(
|
|
935
|
+
`:: ${lang_past} for ${counter_credKeys} ${selectedType}s on ${counter_credBu} BUs for ${cred}`
|
|
936
|
+
);
|
|
937
|
+
} else {
|
|
938
|
+
// execute runMethod for the entity on one BU only
|
|
939
|
+
resultObj[cred + '/' + bu] = await this.#runOnBU(
|
|
940
|
+
methodName,
|
|
941
|
+
cred,
|
|
942
|
+
bu,
|
|
943
|
+
selectedType,
|
|
944
|
+
keys
|
|
945
|
+
);
|
|
946
|
+
Util.logger.info(`:: Done`);
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
return resultObj;
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* helper for {@link Mcdev.#runMethod}
|
|
953
|
+
*
|
|
954
|
+
* @param {'execute'|'pause'|'fixKeys'} methodName what to run
|
|
955
|
+
* @param {string} cred name of Credential
|
|
956
|
+
* @param {string} bu name of BU
|
|
957
|
+
* @param {TYPE.SupportedMetadataTypes} [type] limit execution to given metadata type
|
|
958
|
+
* @param {string[]} keyArr customerkey of the metadata
|
|
959
|
+
* @returns {Promise.<string[]>} list of keys that were affected
|
|
960
|
+
*/
|
|
961
|
+
static async #runOnBU(methodName, cred, bu, type, keyArr) {
|
|
962
|
+
const properties = await config.getProperties();
|
|
963
|
+
const resultArr = [];
|
|
964
|
+
const buObject = await Cli.getCredentialObject(
|
|
965
|
+
properties,
|
|
966
|
+
cred === null ? null : cred + '/' + bu,
|
|
967
|
+
null,
|
|
968
|
+
true
|
|
969
|
+
);
|
|
970
|
+
try {
|
|
971
|
+
if (!type) {
|
|
972
|
+
throw new Error('No type was provided');
|
|
973
|
+
}
|
|
974
|
+
if (buObject !== null) {
|
|
975
|
+
cache.initCache(buObject);
|
|
976
|
+
cred = buObject.credential;
|
|
977
|
+
bu = buObject.businessUnit;
|
|
978
|
+
}
|
|
979
|
+
Util.logger.info(`:: ${methodName} ${type} on ${cred}/${bu}`);
|
|
980
|
+
MetadataTypeInfo[type].client = auth.getSDK(buObject);
|
|
981
|
+
|
|
982
|
+
MetadataTypeInfo[type].properties = properties;
|
|
983
|
+
MetadataTypeInfo[type].buObject = buObject;
|
|
984
|
+
switch (methodName) {
|
|
985
|
+
case 'fixKeys': {
|
|
986
|
+
{
|
|
987
|
+
resultArr.push(...(await this.#fixKeys(cred, bu, type, keyArr)));
|
|
988
|
+
|
|
989
|
+
break;
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
default: {
|
|
993
|
+
if (Util.OPTIONS.like && Object.keys(Util.OPTIONS.like).length) {
|
|
994
|
+
keyArr = await this.#retrieveKeysWithLike(type, buObject);
|
|
995
|
+
}
|
|
996
|
+
if (!keyArr || (Array.isArray(keyArr) && !keyArr.length)) {
|
|
997
|
+
throw new Error('No keys were provided');
|
|
998
|
+
} // result will be undefined (false) if methodName is not supported for the type
|
|
999
|
+
resultArr.push(...(await MetadataTypeInfo[type][methodName](keyArr)));
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
} catch (ex) {
|
|
1003
|
+
Util.logger.errorStack(ex, 'mcdev.' + methodName + ' failed');
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
return resultArr;
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
/**
|
|
1010
|
+
* helper for {@link Mcdev.#runOnBU}
|
|
1011
|
+
*
|
|
1012
|
+
* @param {TYPE.SupportedMetadataTypes} selectedType limit execution to given metadata type
|
|
1013
|
+
* @param {TYPE.BuObject} buObject properties for auth
|
|
1014
|
+
* @returns {string[]} keyArr
|
|
1015
|
+
*/
|
|
1016
|
+
static async #retrieveKeysWithLike(selectedType, buObject) {
|
|
1017
|
+
const properties = await config.getProperties();
|
|
1018
|
+
|
|
1019
|
+
// cache depenencies
|
|
1020
|
+
const deployOrder = Util.getMetadataHierachy([selectedType]);
|
|
1021
|
+
for (const type in deployOrder) {
|
|
1022
|
+
const subTypeArr = deployOrder[type];
|
|
1023
|
+
MetadataTypeInfo[type].client = auth.getSDK(buObject);
|
|
1024
|
+
MetadataTypeInfo[type].properties = properties;
|
|
1025
|
+
MetadataTypeInfo[type].buObject = buObject;
|
|
1026
|
+
Util.logger.info(`Caching dependent Metadata: ${type}`);
|
|
1027
|
+
Util.logSubtypes(subTypeArr);
|
|
1028
|
+
const result = await MetadataTypeInfo[type].retrieveForCache(null, subTypeArr);
|
|
1029
|
+
if (result) {
|
|
1030
|
+
if (Array.isArray(result)) {
|
|
1031
|
+
for (const result_i of result) {
|
|
1032
|
+
if (result_i?.metadata && Object.keys(result_i.metadata).length) {
|
|
1033
|
+
cache.mergeMetadata(type, result_i.metadata);
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
} else {
|
|
1037
|
+
cache.setMetadata(type, result.metadata);
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
// find all keys in chosen type that match the like-filter
|
|
1043
|
+
const keyArr = [];
|
|
1044
|
+
const metadataMap = cache.getCache()[selectedType];
|
|
1045
|
+
if (!metadataMap) {
|
|
1046
|
+
throw new Error(`Selected type ${selectedType} could not be cached`);
|
|
1047
|
+
}
|
|
1048
|
+
Util.logger.info(
|
|
1049
|
+
Util.getGrayMsg(`Found ${Object.keys(metadataMap).length} ${selectedType}s`)
|
|
1050
|
+
);
|
|
1051
|
+
for (const originalKey in metadataMap) {
|
|
1052
|
+
// hide postRetrieveOutput
|
|
1053
|
+
Util.setLoggingLevel({ silent: true });
|
|
1054
|
+
metadataMap[originalKey] = MetadataTypeInfo[selectedType].postRetrieveTasks(
|
|
1055
|
+
metadataMap[originalKey]
|
|
1056
|
+
);
|
|
1057
|
+
// reactivate logging
|
|
1058
|
+
Util.setLoggingLevel({});
|
|
1059
|
+
if (Util.fieldsLike(metadataMap[originalKey])) {
|
|
1060
|
+
keyArr.push(originalKey);
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
Util.logger.info(
|
|
1064
|
+
Util.getGrayMsg(
|
|
1065
|
+
`Identified ${keyArr.length} ${selectedType}${
|
|
1066
|
+
keyArr.length === 1 ? '' : 's'
|
|
1067
|
+
} that match${keyArr.length === 1 ? 'es' : ''} the like-filter`
|
|
1068
|
+
)
|
|
1069
|
+
);
|
|
1070
|
+
|
|
1071
|
+
return keyArr;
|
|
1072
|
+
}
|
|
1073
|
+
/**
|
|
1074
|
+
* Updates the key to match the name field
|
|
1075
|
+
*
|
|
1076
|
+
* @param {string} cred name of Credential
|
|
1077
|
+
* @param {string} bu name of BU
|
|
1078
|
+
* @param {TYPE.SupportedMetadataTypes} type limit execution to given metadata type
|
|
1079
|
+
* @param {string[]} [keyArr] customerkey of the metadata
|
|
1080
|
+
* @returns {Promise.<string[]>} list of keys that were affected
|
|
1081
|
+
*/
|
|
1082
|
+
static async #fixKeys(cred, bu, type, keyArr) {
|
|
1083
|
+
const properties = await config.getProperties();
|
|
1084
|
+
let actuallyFixedKeys = [];
|
|
1085
|
+
const resultArr = [];
|
|
1086
|
+
|
|
1087
|
+
if (
|
|
1088
|
+
MetadataTypeDefinitions[type].keyIsFixed === true ||
|
|
1089
|
+
MetadataTypeDefinitions[type].keyField === MetadataTypeDefinitions[type].idField
|
|
1090
|
+
) {
|
|
1091
|
+
Util.logger.error(`Key cannot be updated for this type`);
|
|
1092
|
+
return resultArr;
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
const buObject = await Cli.getCredentialObject(
|
|
1096
|
+
properties,
|
|
1097
|
+
cred === null ? null : cred + '/' + bu,
|
|
1098
|
+
null,
|
|
1099
|
+
true
|
|
1100
|
+
);
|
|
1101
|
+
try {
|
|
1102
|
+
Util.logger.info(`Retrieving latest versions of ${type} from server`);
|
|
1103
|
+
const retriever = new Retriever(properties, buObject);
|
|
1104
|
+
const retrieved = await retriever.retrieve([type], keyArr, null, false);
|
|
1105
|
+
|
|
1106
|
+
const metadataMap = Object.values(retrieved)[0][0];
|
|
1107
|
+
const keysForDeploy = MetadataTypeInfo[type].getKeysForFixing(metadataMap);
|
|
1108
|
+
if (keysForDeploy.length < 1) {
|
|
1109
|
+
Util.logger.warn(
|
|
1110
|
+
`No items found with a key-name mismatch that match your criteria.\n`
|
|
1111
|
+
);
|
|
1112
|
+
return resultArr;
|
|
1113
|
+
}
|
|
1114
|
+
this.setOptions({
|
|
1115
|
+
changeKeyField: MetadataTypeDefinitions[type].nameField,
|
|
1116
|
+
fromRetrieve: true,
|
|
1117
|
+
});
|
|
1118
|
+
const deployed = await Deployer.deploy(cred + '/' + bu, [type], keysForDeploy);
|
|
1119
|
+
actuallyFixedKeys = Object.keys(Object.values(Object.values(deployed)[0])[0]);
|
|
1120
|
+
resultArr.push(...actuallyFixedKeys);
|
|
1121
|
+
const dependentTypes = await Util.getDependentMetadata(type);
|
|
1122
|
+
if (actuallyFixedKeys && actuallyFixedKeys.length) {
|
|
1123
|
+
Util.logger.info(
|
|
1124
|
+
`Successfully updated ${actuallyFixedKeys.length} key${
|
|
1125
|
+
actuallyFixedKeys.length === 1 ? '' : 's'
|
|
1126
|
+
} of type ${type}`
|
|
1127
|
+
);
|
|
1128
|
+
if (dependentTypes.length) {
|
|
1129
|
+
Util.logger.warn(
|
|
1130
|
+
`Please re-retrieve the following types as your local copies might now be outdated: ${Util.getGrayMsg(
|
|
1131
|
+
dependentTypes.join(', ')
|
|
1132
|
+
)}`
|
|
1133
|
+
);
|
|
1134
|
+
const reRetrieve = await Cli.postFixKeysReretrieve(type, dependentTypes);
|
|
1135
|
+
if (reRetrieve) {
|
|
1136
|
+
Util.logger.info(
|
|
1137
|
+
`Retrieving latest versions of ${dependentTypes.join(', ')} from server`
|
|
1138
|
+
);
|
|
1139
|
+
const retriever = new Retriever(properties, buObject);
|
|
1140
|
+
await retriever.retrieve(dependentTypes, null, null, false);
|
|
1141
|
+
}
|
|
1142
|
+
} else {
|
|
1143
|
+
Util.logger.info(
|
|
1144
|
+
`No dependent types found that need to be re-retrieved after fixing keys of type ${type}.`
|
|
1145
|
+
);
|
|
1146
|
+
}
|
|
1147
|
+
} else {
|
|
1148
|
+
Util.logger.warn(`No keys of type ${type} updated.`);
|
|
1149
|
+
}
|
|
1150
|
+
} catch (ex) {
|
|
1151
|
+
Util.logger.errorStack(ex, 'mcdev.fixKeys failed');
|
|
1152
|
+
}
|
|
1153
|
+
Util.logger.info(`:: Done\n`);
|
|
1154
|
+
return resultArr;
|
|
1155
|
+
}
|
|
685
1156
|
}
|
|
686
1157
|
|
|
687
1158
|
module.exports = Mcdev;
|