mcdev 3.1.1 → 4.0.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/.eslintrc.json +67 -7
- package/.github/ISSUE_TEMPLATE/bug.yml +5 -1
- package/.github/ISSUE_TEMPLATE/task.md +1 -1
- package/.github/PULL_REQUEST_TEMPLATE.md +5 -3
- package/.github/dependabot.yml +14 -0
- package/.github/workflows/code-analysis.yml +57 -0
- package/.husky/commit-msg +10 -0
- package/.husky/post-checkout +5 -0
- package/.husky/pre-commit +2 -1
- package/.prettierrc +8 -0
- package/.vscode/settings.json +1 -1
- package/LICENSE +2 -2
- package/README.md +134 -45
- package/boilerplate/config.json +5 -11
- package/boilerplate/files/.prettierrc +8 -0
- package/boilerplate/files/.vscode/extensions.json +0 -1
- package/boilerplate/files/.vscode/settings.json +28 -2
- package/boilerplate/files/README.md +2 -2
- package/boilerplate/forcedUpdates.json +10 -0
- package/boilerplate/npm-dependencies.json +5 -5
- package/docs/dist/documentation.md +2795 -1724
- package/jsconfig.json +1 -1
- package/lib/Builder.js +166 -75
- package/lib/Deployer.js +244 -96
- package/lib/MetadataTypeDefinitions.js +2 -0
- package/lib/MetadataTypeInfo.js +2 -0
- package/lib/Retriever.js +61 -84
- package/lib/cli.js +133 -25
- package/lib/index.js +242 -563
- package/lib/metadataTypes/AccountUser.js +101 -95
- package/lib/metadataTypes/Asset.js +677 -248
- package/lib/metadataTypes/AttributeGroup.js +23 -12
- package/lib/metadataTypes/Automation.js +456 -357
- package/lib/metadataTypes/Campaign.js +33 -93
- package/lib/metadataTypes/ContentArea.js +31 -11
- package/lib/metadataTypes/DataExtension.js +391 -376
- package/lib/metadataTypes/DataExtensionField.js +131 -54
- package/lib/metadataTypes/DataExtensionTemplate.js +22 -4
- package/lib/metadataTypes/DataExtract.js +67 -50
- package/lib/metadataTypes/DataExtractType.js +14 -8
- package/lib/metadataTypes/Discovery.js +21 -16
- package/lib/metadataTypes/Email.js +32 -12
- package/lib/metadataTypes/EmailSendDefinition.js +85 -80
- package/lib/metadataTypes/EventDefinition.js +69 -47
- package/lib/metadataTypes/FileTransfer.js +78 -54
- package/lib/metadataTypes/Filter.js +11 -4
- package/lib/metadataTypes/Folder.js +149 -117
- package/lib/metadataTypes/FtpLocation.js +14 -8
- package/lib/metadataTypes/ImportFile.js +69 -69
- package/lib/metadataTypes/Interaction.js +19 -4
- package/lib/metadataTypes/List.js +54 -13
- package/lib/metadataTypes/MetadataType.js +687 -479
- package/lib/metadataTypes/MobileCode.js +46 -0
- package/lib/metadataTypes/MobileKeyword.js +114 -0
- package/lib/metadataTypes/Query.js +204 -103
- package/lib/metadataTypes/Role.js +76 -61
- package/lib/metadataTypes/Script.js +146 -82
- package/lib/metadataTypes/SetDefinition.js +20 -8
- package/lib/metadataTypes/TriggeredSendDefinition.js +78 -58
- package/lib/metadataTypes/definitions/Asset.definition.js +21 -10
- package/lib/metadataTypes/definitions/AttributeGroup.definition.js +12 -0
- package/lib/metadataTypes/definitions/Automation.definition.js +10 -5
- package/lib/metadataTypes/definitions/Campaign.definition.js +44 -1
- package/lib/metadataTypes/definitions/DataExtension.definition.js +4 -0
- package/lib/metadataTypes/definitions/DataExtensionTemplate.definition.js +6 -0
- package/lib/metadataTypes/definitions/DataExtract.definition.js +18 -14
- package/lib/metadataTypes/definitions/Discovery.definition.js +12 -0
- package/lib/metadataTypes/definitions/EmailSendDefinition.definition.js +4 -0
- package/lib/metadataTypes/definitions/EventDefinition.definition.js +22 -0
- package/lib/metadataTypes/definitions/FileTransfer.definition.js +4 -0
- package/lib/metadataTypes/definitions/Filter.definition.js +4 -0
- package/lib/metadataTypes/definitions/Folder.definition.js +6 -0
- package/lib/metadataTypes/definitions/FtpLocation.definition.js +4 -0
- package/lib/metadataTypes/definitions/ImportFile.definition.js +10 -5
- package/lib/metadataTypes/definitions/Interaction.definition.js +4 -0
- package/lib/metadataTypes/definitions/MobileCode.definition.js +163 -0
- package/lib/metadataTypes/definitions/MobileKeyword.definition.js +253 -0
- package/lib/metadataTypes/definitions/Query.definition.js +4 -0
- package/lib/metadataTypes/definitions/Role.definition.js +5 -0
- package/lib/metadataTypes/definitions/Script.definition.js +4 -0
- package/lib/metadataTypes/definitions/SetDefinition.definition.js +28 -0
- package/lib/metadataTypes/definitions/TriggeredSendDefinition.definition.js +4 -0
- package/lib/retrieveChangelog.js +7 -6
- package/lib/util/auth.js +117 -0
- package/lib/util/businessUnit.js +55 -66
- package/lib/util/cache.js +194 -0
- package/lib/util/cli.js +90 -116
- package/lib/util/config.js +302 -0
- package/lib/util/devops.js +240 -50
- package/lib/util/file.js +120 -191
- package/lib/util/init.config.js +195 -69
- package/lib/util/init.git.js +45 -50
- package/lib/util/init.js +72 -59
- package/lib/util/init.npm.js +48 -39
- package/lib/util/util.js +280 -564
- package/package.json +44 -33
- package/test/dataExtension.test.js +152 -0
- package/test/mockRoot/.mcdev-auth.json +8 -0
- package/test/mockRoot/.mcdevrc.json +67 -0
- package/test/mockRoot/deploy/testInstance/testBU/dataExtension/childBU_dataextension_test.dataExtension-meta.json +39 -0
- package/test/mockRoot/deploy/testInstance/testBU/dataExtension/testDataExtension.dataExtension-meta.json +23 -0
- package/test/mockRoot/deploy/testInstance/testBU/query/testExistingQuery.query-meta.json +11 -0
- package/test/mockRoot/deploy/testInstance/testBU/query/testExistingQuery.query-meta.sql +4 -0
- package/test/mockRoot/deploy/testInstance/testBU/query/testQuery.query-meta.json +11 -0
- package/test/mockRoot/deploy/testInstance/testBU/query/testQuery.query-meta.sql +4 -0
- package/test/query.test.js +149 -0
- package/test/resourceFactory.js +142 -0
- package/test/resources/1111111/dataFolder/retrieve-response.xml +43 -0
- package/test/resources/9999999/automation/v1/queries/549f0568-607c-4940-afef-437965094dat/patch-response.json +18 -0
- package/test/resources/9999999/automation/v1/queries/get-response.json +24 -0
- package/test/resources/9999999/automation/v1/queries/post-response.json +18 -0
- package/test/resources/9999999/dataExtension/build-expected.json +51 -0
- package/test/resources/9999999/dataExtension/create-expected.json +23 -0
- package/test/resources/9999999/dataExtension/create-response.xml +54 -0
- package/test/resources/9999999/dataExtension/retrieve-expected.json +51 -0
- package/test/resources/9999999/dataExtension/retrieve-response.xml +47 -0
- package/test/resources/9999999/dataExtension/template-expected.json +51 -0
- package/test/resources/9999999/dataExtension/update-expected.json +55 -0
- package/test/resources/9999999/dataExtension/update-response.xml +52 -0
- package/test/resources/9999999/dataExtensionField/retrieve-response.xml +93 -0
- package/test/resources/9999999/dataExtensionTemplate/retrieve-response.xml +303 -0
- package/test/resources/9999999/dataFolder/retrieve-response.xml +65 -0
- package/test/resources/9999999/query/build-expected.json +8 -0
- package/test/resources/9999999/query/get-expected.json +11 -0
- package/test/resources/9999999/query/patch-expected.json +11 -0
- package/test/resources/9999999/query/post-expected.json +11 -0
- package/test/resources/9999999/query/template-expected.json +8 -0
- package/test/resources/auth.json +32 -0
- package/test/resources/rest404-response.json +5 -0
- package/test/resources/retrieve-response.xml +21 -0
- package/test/utils.js +107 -0
- package/types/mcdev.d.js +301 -0
- package/CHANGELOG.md +0 -126
- package/PULL_REQUEST_TEMPLATE.md +0 -19
- package/test/util/file.js +0 -51
package/lib/util/cli.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const TYPE = require('../../types/mcdev.d');
|
|
3
4
|
const BuHelper = require('./businessUnit');
|
|
4
5
|
const File = require('./file');
|
|
6
|
+
const config = require('./config');
|
|
5
7
|
const inquirer = require('inquirer');
|
|
6
8
|
const MetadataDefinitions = require('./../MetadataTypeDefinitions');
|
|
7
9
|
const Util = require('./util');
|
|
10
|
+
const auth = require('./auth');
|
|
8
11
|
|
|
9
12
|
/**
|
|
10
13
|
* CLI helper class
|
|
@@ -14,17 +17,14 @@ const Cli = {
|
|
|
14
17
|
/**
|
|
15
18
|
* used when initially setting up a project.
|
|
16
19
|
* loads default config and adds first credential
|
|
17
|
-
*
|
|
18
|
-
* @param {
|
|
19
|
-
* @
|
|
20
|
-
* @param {String} skipInteraction.tenant client id of installed package
|
|
21
|
-
* @param {String} skipInteraction.credentialsName how you would like the credential to be named
|
|
22
|
-
* @returns {Promise<boolean>} success of init
|
|
20
|
+
*
|
|
21
|
+
* @param {TYPE.skipInteraction} [skipInteraction] signals what to insert automatically for things usually asked via wizard
|
|
22
|
+
* @returns {Promise.<boolean>} success of init
|
|
23
23
|
*/
|
|
24
24
|
async initMcdevConfig(skipInteraction) {
|
|
25
25
|
Util.logger.info('-- Initialising server connection --');
|
|
26
26
|
Util.logger.info('Please enter a name for your "Installed Package" credentials:');
|
|
27
|
-
const propertiesTemplate =
|
|
27
|
+
const propertiesTemplate = await config.getDefaultProperties();
|
|
28
28
|
delete propertiesTemplate.credentials.default;
|
|
29
29
|
|
|
30
30
|
// wait for the interaction to finish or else an outer await will run before this is done
|
|
@@ -32,17 +32,13 @@ const Cli = {
|
|
|
32
32
|
},
|
|
33
33
|
/**
|
|
34
34
|
* Extends template file for properties.json
|
|
35
|
-
*
|
|
36
|
-
* @param {
|
|
37
|
-
* @param {
|
|
38
|
-
* @
|
|
39
|
-
* @param {String} skipInteraction.clientSecret client id of installed package
|
|
40
|
-
* @param {String} skipInteraction.tenant client id of installed package
|
|
41
|
-
* @param {String} skipInteraction.credentialsName how you would like the credential to be named
|
|
42
|
-
* @returns {Promise<void>} -
|
|
35
|
+
*
|
|
36
|
+
* @param {TYPE.Mcdevrc} properties config file's json
|
|
37
|
+
* @param {TYPE.skipInteraction} [skipInteraction] signals what to insert automatically for things usually asked via wizard
|
|
38
|
+
* @returns {Promise.<void>} -
|
|
43
39
|
*/
|
|
44
40
|
async addExtraCredential(properties, skipInteraction) {
|
|
45
|
-
if (!
|
|
41
|
+
if (!(await config.checkProperties(properties))) {
|
|
46
42
|
// return null here to avoid seeing 2 error messages for the same issue
|
|
47
43
|
return null;
|
|
48
44
|
} else {
|
|
@@ -53,9 +49,9 @@ const Cli = {
|
|
|
53
49
|
}
|
|
54
50
|
}
|
|
55
51
|
Util.logger.info('\nPlease enter your new credentials');
|
|
56
|
-
if (skipInteraction && properties.credentials[skipInteraction.
|
|
52
|
+
if (skipInteraction && properties.credentials[skipInteraction.credentialName]) {
|
|
57
53
|
Util.logger.error(
|
|
58
|
-
`Credential '${skipInteraction.
|
|
54
|
+
`Credential '${skipInteraction.credentialName}' already existing. If you tried updating please provide run 'mcdev init ${skipInteraction.credentialName}'`
|
|
59
55
|
);
|
|
60
56
|
}
|
|
61
57
|
return this._setCredential(properties, null, skipInteraction);
|
|
@@ -64,14 +60,11 @@ const Cli = {
|
|
|
64
60
|
/**
|
|
65
61
|
* Extends template file for properties.json
|
|
66
62
|
* update credentials
|
|
67
|
-
*
|
|
63
|
+
*
|
|
64
|
+
* @param {TYPE.Mcdevrc} properties config file's json
|
|
68
65
|
* @param {string} credName name of credential that needs updating
|
|
69
|
-
* @param {
|
|
70
|
-
* @
|
|
71
|
-
* @param {String} skipInteraction.clientSecret client id of installed package
|
|
72
|
-
* @param {String} skipInteraction.tenant client id of installed package
|
|
73
|
-
* @param {String} skipInteraction.credentialsName how you would like the credential to be named
|
|
74
|
-
* @returns {Promise<Boolean>} success of update
|
|
66
|
+
* @param {TYPE.skipInteraction} [skipInteraction] signals what to insert automatically for things usually asked via wizard
|
|
67
|
+
* @returns {Promise.<boolean>} success of update
|
|
75
68
|
*/
|
|
76
69
|
async updateCredential(properties, credName, skipInteraction) {
|
|
77
70
|
if (credName) {
|
|
@@ -83,15 +76,16 @@ const Cli = {
|
|
|
83
76
|
},
|
|
84
77
|
/**
|
|
85
78
|
* Returns Object with parameters required for accessing API
|
|
86
|
-
*
|
|
87
|
-
* @param {
|
|
79
|
+
*
|
|
80
|
+
* @param {TYPE.Mcdevrc} properties object of all configuration including credentials
|
|
81
|
+
* @param {string} target code of BU to use
|
|
88
82
|
* @param {boolean|string} [isCredentialOnly] true:don't ask for BU | string: name of BU
|
|
89
83
|
* @param {boolean} [allowAll] Offer ALL as option in BU selection
|
|
90
|
-
* @returns {Promise
|
|
84
|
+
* @returns {Promise.<TYPE.BuObject>} credential to be used for Business Unit
|
|
91
85
|
*/
|
|
92
86
|
async getCredentialObject(properties, target, isCredentialOnly, allowAll) {
|
|
93
87
|
try {
|
|
94
|
-
if (!
|
|
88
|
+
if (!(await config.checkProperties(properties))) {
|
|
95
89
|
// return null here to avoid seeing 2 error messages for the same issue
|
|
96
90
|
return null;
|
|
97
91
|
}
|
|
@@ -137,9 +131,6 @@ const Cli = {
|
|
|
137
131
|
);
|
|
138
132
|
}
|
|
139
133
|
return {
|
|
140
|
-
clientId: properties.credentials[credential].clientId,
|
|
141
|
-
clientSecret: properties.credentials[credential].clientSecret,
|
|
142
|
-
tenant: properties.credentials[credential].tenant,
|
|
143
134
|
eid: properties.credentials[credential].eid,
|
|
144
135
|
mid: properties.credentials[credential].businessUnits[businessUnit],
|
|
145
136
|
businessUnit: businessUnit,
|
|
@@ -153,11 +144,11 @@ const Cli = {
|
|
|
153
144
|
/**
|
|
154
145
|
* helps select the right credential in case of bad initial input
|
|
155
146
|
*
|
|
156
|
-
* @param {
|
|
147
|
+
* @param {TYPE.Mcdevrc} properties config file's json
|
|
157
148
|
* @param {string} [credential] name of valid credential
|
|
158
149
|
* @param {boolean} [isCredentialOnly] don't ask for BU if true
|
|
159
150
|
* @param {boolean} [allowAll] Offer ALL as option in BU selection
|
|
160
|
-
* @returns {Promise
|
|
151
|
+
* @returns {Promise.<Array>} selected credential/BU combo
|
|
161
152
|
*/
|
|
162
153
|
async _selectBU(properties, credential, isCredentialOnly, allowAll) {
|
|
163
154
|
const credList = [];
|
|
@@ -177,7 +168,7 @@ const Cli = {
|
|
|
177
168
|
name: 'credential',
|
|
178
169
|
message: 'Please select the credential you were looking for:',
|
|
179
170
|
choices: credList,
|
|
180
|
-
// eslint-disable-next-line require-jsdoc
|
|
171
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
181
172
|
filter: function (answer) {
|
|
182
173
|
if (!isCredentialOnly) {
|
|
183
174
|
for (const bu in properties.credentials[answer].businessUnits) {
|
|
@@ -217,18 +208,9 @@ const Cli = {
|
|
|
217
208
|
let responses = null;
|
|
218
209
|
if (questions.length) {
|
|
219
210
|
try {
|
|
220
|
-
responses = await
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
.then((answers) => {
|
|
224
|
-
resolve(answers);
|
|
225
|
-
})
|
|
226
|
-
.catch((err) => {
|
|
227
|
-
Util.logger.error(err);
|
|
228
|
-
});
|
|
229
|
-
});
|
|
230
|
-
} catch (e) {
|
|
231
|
-
Util.logger.info(e);
|
|
211
|
+
responses = await inquirer.prompt(questions);
|
|
212
|
+
} catch (ex) {
|
|
213
|
+
Util.logger.info(ex);
|
|
232
214
|
}
|
|
233
215
|
if (responses.businessUnit && responses.businessUnit === allBUsAnswer) {
|
|
234
216
|
// remove textual explanation of *
|
|
@@ -242,15 +224,10 @@ const Cli = {
|
|
|
242
224
|
/**
|
|
243
225
|
* helper around _askCredentials
|
|
244
226
|
*
|
|
245
|
-
* @param {
|
|
227
|
+
* @param {TYPE.Mcdevrc} properties from config file
|
|
246
228
|
* @param {string} [credName] name of credential that needs updating
|
|
247
|
-
* @param {
|
|
248
|
-
* @
|
|
249
|
-
* @param {String} skipInteraction.clientSecret client id of installed package
|
|
250
|
-
* @param {String} skipInteraction.tenant client id of installed package
|
|
251
|
-
* @param {String} skipInteraction.credentialsName how you would like the credential to be named
|
|
252
|
-
*
|
|
253
|
-
* @returns {Promise<boolean|String>} success of refresh or credential name
|
|
229
|
+
* @param {TYPE.skipInteraction} [skipInteraction] signals what to insert automatically for things usually asked via wizard
|
|
230
|
+
* @returns {Promise.<boolean | string>} success of refresh or credential name
|
|
254
231
|
*/
|
|
255
232
|
async _setCredential(properties, credName, skipInteraction) {
|
|
256
233
|
// Get user input
|
|
@@ -259,37 +236,40 @@ const Cli = {
|
|
|
259
236
|
do {
|
|
260
237
|
if (skipInteraction) {
|
|
261
238
|
if (
|
|
262
|
-
skipInteraction.
|
|
263
|
-
skipInteraction.
|
|
264
|
-
skipInteraction.
|
|
265
|
-
skipInteraction.
|
|
239
|
+
skipInteraction.client_id &&
|
|
240
|
+
skipInteraction.client_secret &&
|
|
241
|
+
skipInteraction.auth_url &&
|
|
242
|
+
skipInteraction.account_id &&
|
|
243
|
+
skipInteraction.credentialName
|
|
266
244
|
) {
|
|
267
|
-
// assume skipInteraction=={
|
|
245
|
+
// assume skipInteraction=={client_id,client_secret,auth_url,credentialName}
|
|
268
246
|
inputData = skipInteraction;
|
|
269
247
|
} else {
|
|
270
248
|
throw new Error(
|
|
271
|
-
'--skipInteraction flag found but missing required input for
|
|
249
|
+
'--skipInteraction flag found but missing required input for client_id,client_secret,auth_url,account_id,credentialName'
|
|
272
250
|
);
|
|
273
251
|
}
|
|
274
252
|
} else {
|
|
275
253
|
inputData = await this._askCredentials(properties, credName);
|
|
276
254
|
}
|
|
277
|
-
// Replace defaults with user input
|
|
278
|
-
const buObject = {
|
|
279
|
-
clientId: inputData.clientId,
|
|
280
|
-
clientSecret: inputData.clientSecret,
|
|
281
|
-
tenant: inputData.tenant,
|
|
282
|
-
eid: null,
|
|
283
|
-
businessUnits: null,
|
|
284
|
-
};
|
|
285
255
|
|
|
286
256
|
// test if credentials are valid
|
|
287
257
|
try {
|
|
288
|
-
await
|
|
258
|
+
await auth.saveCredential(
|
|
259
|
+
{
|
|
260
|
+
client_id: inputData.client_id,
|
|
261
|
+
client_secret: inputData.client_secret,
|
|
262
|
+
auth_url: inputData.auth_url,
|
|
263
|
+
account_id: Number.parseInt(inputData.account_id),
|
|
264
|
+
},
|
|
265
|
+
inputData.credentialName
|
|
266
|
+
);
|
|
289
267
|
credentialsGood = true;
|
|
290
|
-
|
|
291
268
|
// update central config now that the credentials are verified
|
|
292
|
-
properties.credentials[inputData.
|
|
269
|
+
properties.credentials[inputData.credentialName] = {
|
|
270
|
+
eid: Number.parseInt(inputData.account_id),
|
|
271
|
+
businessUnits: {},
|
|
272
|
+
};
|
|
293
273
|
} catch (ex) {
|
|
294
274
|
Util.logger.error(ex.message);
|
|
295
275
|
credentialsGood = false;
|
|
@@ -300,25 +280,25 @@ const Cli = {
|
|
|
300
280
|
}
|
|
301
281
|
} while (!credentialsGood);
|
|
302
282
|
// Get all business units and add them to the properties
|
|
303
|
-
const status = await BuHelper.refreshBUProperties(properties, inputData.
|
|
304
|
-
return status ? inputData.
|
|
283
|
+
const status = await BuHelper.refreshBUProperties(properties, inputData.credentialName);
|
|
284
|
+
return status ? inputData.credentialName : status;
|
|
305
285
|
},
|
|
306
286
|
|
|
307
287
|
/**
|
|
308
288
|
* helper for addExtraCredential()
|
|
309
289
|
*
|
|
310
|
-
* @param {
|
|
290
|
+
* @param {TYPE.Mcdevrc} properties from config file
|
|
311
291
|
* @param {string} [credName] name of credential that needs updating
|
|
312
|
-
* @returns {Promise
|
|
292
|
+
* @returns {Promise.<object>} credential info
|
|
313
293
|
*/
|
|
314
294
|
async _askCredentials(properties, credName) {
|
|
315
295
|
const questions = [];
|
|
316
296
|
if (!credName) {
|
|
317
297
|
questions.push({
|
|
318
298
|
type: 'input',
|
|
319
|
-
name: '
|
|
299
|
+
name: 'credentialName',
|
|
320
300
|
message: 'Credential name (your choice)',
|
|
321
|
-
// eslint-disable-next-line require-jsdoc
|
|
301
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
322
302
|
validate: function (value) {
|
|
323
303
|
if (!value || value.trim().length < 2) {
|
|
324
304
|
return 'Please enter at least 2 characters';
|
|
@@ -334,13 +314,14 @@ const Cli = {
|
|
|
334
314
|
},
|
|
335
315
|
});
|
|
336
316
|
}
|
|
337
|
-
const tenantRegex =
|
|
317
|
+
const tenantRegex =
|
|
318
|
+
/^https:\/\/([\w-]{28})\.(auth|soap|rest)\.marketingcloudapis\.com[/]?$/iu;
|
|
338
319
|
questions.push(
|
|
339
320
|
{
|
|
340
321
|
type: 'input',
|
|
341
|
-
name: '
|
|
322
|
+
name: 'client_id',
|
|
342
323
|
message: 'Client Id',
|
|
343
|
-
// eslint-disable-next-line require-jsdoc
|
|
324
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
344
325
|
validate: function (value) {
|
|
345
326
|
if (!value || value.trim().length < 10) {
|
|
346
327
|
return 'Please enter valid client id';
|
|
@@ -350,9 +331,9 @@ const Cli = {
|
|
|
350
331
|
},
|
|
351
332
|
{
|
|
352
333
|
type: 'input',
|
|
353
|
-
name: '
|
|
334
|
+
name: 'client_secret',
|
|
354
335
|
message: 'Client Secret',
|
|
355
|
-
// eslint-disable-next-line require-jsdoc
|
|
336
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
356
337
|
validate: function (value) {
|
|
357
338
|
if (!value || value.trim().length < 10) {
|
|
358
339
|
return 'Please enter valid client secret';
|
|
@@ -362,7 +343,7 @@ const Cli = {
|
|
|
362
343
|
},
|
|
363
344
|
{
|
|
364
345
|
type: 'input',
|
|
365
|
-
name: '
|
|
346
|
+
name: 'auth_url',
|
|
366
347
|
message: 'Authentication Base URI',
|
|
367
348
|
validate: (value) => {
|
|
368
349
|
if (!value || value.trim().length < 10) {
|
|
@@ -374,35 +355,32 @@ const Cli = {
|
|
|
374
355
|
return true;
|
|
375
356
|
}
|
|
376
357
|
},
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
type: 'number',
|
|
361
|
+
name: 'account_id',
|
|
362
|
+
message: 'MID of Parent Business Unit',
|
|
377
363
|
}
|
|
378
364
|
);
|
|
379
|
-
const responses = await
|
|
380
|
-
inquirer.prompt(questions).then((answers) => {
|
|
381
|
-
resolve(answers);
|
|
382
|
-
});
|
|
383
|
-
});
|
|
365
|
+
const responses = await inquirer.prompt(questions);
|
|
384
366
|
// remove extra white space
|
|
385
|
-
responses.
|
|
386
|
-
responses.
|
|
387
|
-
responses.
|
|
388
|
-
|
|
389
|
-
// extract the tenant sub-domain from the URI; the format was already validated above
|
|
390
|
-
responses.tenant = responses.tenant.match(tenantRegex)[1];
|
|
367
|
+
responses.client_id = responses.client_id.trim();
|
|
368
|
+
responses.client_secret = responses.client_secret.trim();
|
|
369
|
+
responses.auth_url = responses.auth_url.trim();
|
|
391
370
|
|
|
392
371
|
if (credName) {
|
|
393
372
|
// if credential name was provided as parameter, we didn't ask the user for it
|
|
394
|
-
responses.
|
|
373
|
+
responses.credentialName = credName;
|
|
395
374
|
}
|
|
396
375
|
|
|
397
376
|
return responses;
|
|
398
377
|
},
|
|
399
378
|
/**
|
|
400
379
|
* allows updating the metadata types that shall be retrieved
|
|
401
|
-
*
|
|
402
|
-
* @param {
|
|
403
|
-
* @param {
|
|
404
|
-
* @
|
|
405
|
-
* @returns {Promise<void>} -
|
|
380
|
+
*
|
|
381
|
+
* @param {TYPE.Mcdevrc} properties config file's json
|
|
382
|
+
* @param {string[]} [setTypesArr] skip user prompt and overwrite with this list if given
|
|
383
|
+
* @returns {Promise.<void>} -
|
|
406
384
|
*/
|
|
407
385
|
async selectTypes(properties, setTypesArr) {
|
|
408
386
|
let responses;
|
|
@@ -446,7 +424,7 @@ const Cli = {
|
|
|
446
424
|
name:
|
|
447
425
|
def.typeName +
|
|
448
426
|
(Util.logger.level === 'debug' && !def.typeRetrieveByDefault
|
|
449
|
-
? ' \
|
|
427
|
+
? ' \x1B[1;30;40m(non-default)\u001B[0m'
|
|
450
428
|
: ''),
|
|
451
429
|
value: def.type,
|
|
452
430
|
disabled: !(Util.logger.level === 'debug' || def.typeRetrieveByDefault)
|
|
@@ -479,8 +457,7 @@ const Cli = {
|
|
|
479
457
|
});
|
|
480
458
|
// add end-of-list marker
|
|
481
459
|
typeChoices.push(new inquirer.Separator(' ==== '));
|
|
482
|
-
|
|
483
|
-
const questions = [
|
|
460
|
+
responses = await inquirer.prompt([
|
|
484
461
|
{
|
|
485
462
|
type: 'checkbox',
|
|
486
463
|
message: 'Select Metadata types for retrieval',
|
|
@@ -488,12 +465,7 @@ const Cli = {
|
|
|
488
465
|
pageSize: 10,
|
|
489
466
|
choices: typeChoices,
|
|
490
467
|
},
|
|
491
|
-
];
|
|
492
|
-
responses = await new Promise((resolve) => {
|
|
493
|
-
inquirer.prompt(questions).then((answers) => {
|
|
494
|
-
resolve(answers);
|
|
495
|
-
});
|
|
496
|
-
});
|
|
468
|
+
]);
|
|
497
469
|
} else {
|
|
498
470
|
responses = {
|
|
499
471
|
selectedTypes: setTypesArr,
|
|
@@ -510,9 +482,10 @@ const Cli = {
|
|
|
510
482
|
/**
|
|
511
483
|
* helper for this.selectTypes() that converts subtypes back to main type if all and only defaults were selected
|
|
512
484
|
* this keeps the config automatically upgradable when we add new subtypes or change what is selected by default
|
|
513
|
-
*
|
|
514
|
-
* @param {
|
|
515
|
-
* @param {
|
|
485
|
+
*
|
|
486
|
+
* @param {object} responses wrapper object for respones
|
|
487
|
+
* @param {string[]} responses.selectedTypes what types the user selected
|
|
488
|
+
* @param {string} type metadata type
|
|
516
489
|
* @returns {void}
|
|
517
490
|
*/
|
|
518
491
|
_summarizeSubtypes(responses, type) {
|
|
@@ -541,7 +514,8 @@ const Cli = {
|
|
|
541
514
|
|
|
542
515
|
/**
|
|
543
516
|
* shows metadata type descriptions
|
|
544
|
-
*
|
|
517
|
+
*
|
|
518
|
+
* @returns {void}
|
|
545
519
|
*/
|
|
546
520
|
explainTypes() {
|
|
547
521
|
// overwrites default layout of console.table
|
|
@@ -570,7 +544,7 @@ const Cli = {
|
|
|
570
544
|
(lastCountdown > 0 ? '├ ' : '└ ') +
|
|
571
545
|
(subTypeRetrieveByDefault ? 'yes' : '-'),
|
|
572
546
|
Description:
|
|
573
|
-
definition.length > 90 ? definition.
|
|
547
|
+
definition.length > 90 ? definition.slice(0, 90) + '...' : definition,
|
|
574
548
|
});
|
|
575
549
|
}
|
|
576
550
|
// change leading symbol of last subtype to close the tree visually
|
|
@@ -592,7 +566,7 @@ const Cli = {
|
|
|
592
566
|
}
|
|
593
567
|
return 0;
|
|
594
568
|
});
|
|
595
|
-
console.table(typeChoices);
|
|
569
|
+
console.table(typeChoices); // eslint-disable-line no-console
|
|
596
570
|
},
|
|
597
571
|
};
|
|
598
572
|
|