mcdev 3.1.3 → 4.0.1

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.
Files changed (134) hide show
  1. package/.eslintrc.json +67 -7
  2. package/.github/ISSUE_TEMPLATE/bug.yml +2 -1
  3. package/.github/PULL_REQUEST_TEMPLATE.md +5 -3
  4. package/.github/dependabot.yml +14 -0
  5. package/.github/workflows/code-analysis.yml +57 -0
  6. package/.husky/commit-msg +10 -0
  7. package/.husky/post-checkout +5 -0
  8. package/.husky/pre-commit +2 -1
  9. package/.prettierrc +8 -0
  10. package/.vscode/settings.json +1 -1
  11. package/LICENSE +2 -2
  12. package/README.md +134 -45
  13. package/boilerplate/config.json +5 -11
  14. package/boilerplate/files/.prettierrc +8 -0
  15. package/boilerplate/files/.vscode/extensions.json +0 -1
  16. package/boilerplate/files/.vscode/settings.json +30 -2
  17. package/boilerplate/files/README.md +2 -2
  18. package/boilerplate/forcedUpdates.json +10 -0
  19. package/boilerplate/npm-dependencies.json +5 -5
  20. package/docs/dist/documentation.md +2807 -1730
  21. package/jsconfig.json +1 -1
  22. package/lib/Builder.js +171 -74
  23. package/lib/Deployer.js +244 -96
  24. package/lib/MetadataTypeDefinitions.js +2 -0
  25. package/lib/MetadataTypeInfo.js +2 -0
  26. package/lib/Retriever.js +61 -84
  27. package/lib/cli.js +116 -11
  28. package/lib/index.js +241 -561
  29. package/lib/metadataTypes/AccountUser.js +117 -103
  30. package/lib/metadataTypes/Asset.js +705 -255
  31. package/lib/metadataTypes/AttributeGroup.js +23 -12
  32. package/lib/metadataTypes/Automation.js +489 -392
  33. package/lib/metadataTypes/Campaign.js +33 -93
  34. package/lib/metadataTypes/ContentArea.js +31 -11
  35. package/lib/metadataTypes/DataExtension.js +387 -372
  36. package/lib/metadataTypes/DataExtensionField.js +131 -54
  37. package/lib/metadataTypes/DataExtensionTemplate.js +22 -4
  38. package/lib/metadataTypes/DataExtract.js +61 -48
  39. package/lib/metadataTypes/DataExtractType.js +14 -8
  40. package/lib/metadataTypes/Discovery.js +21 -16
  41. package/lib/metadataTypes/Email.js +32 -12
  42. package/lib/metadataTypes/EmailSendDefinition.js +85 -80
  43. package/lib/metadataTypes/EventDefinition.js +61 -43
  44. package/lib/metadataTypes/FileTransfer.js +72 -52
  45. package/lib/metadataTypes/Filter.js +11 -4
  46. package/lib/metadataTypes/Folder.js +149 -117
  47. package/lib/metadataTypes/FtpLocation.js +14 -8
  48. package/lib/metadataTypes/ImportFile.js +61 -64
  49. package/lib/metadataTypes/Interaction.js +19 -4
  50. package/lib/metadataTypes/List.js +54 -13
  51. package/lib/metadataTypes/MetadataType.js +664 -454
  52. package/lib/metadataTypes/MobileCode.js +46 -0
  53. package/lib/metadataTypes/MobileKeyword.js +114 -0
  54. package/lib/metadataTypes/Query.js +206 -105
  55. package/lib/metadataTypes/Role.js +76 -61
  56. package/lib/metadataTypes/Script.js +147 -83
  57. package/lib/metadataTypes/SetDefinition.js +20 -8
  58. package/lib/metadataTypes/TriggeredSendDefinition.js +78 -58
  59. package/lib/metadataTypes/definitions/Asset.definition.js +21 -10
  60. package/lib/metadataTypes/definitions/AttributeGroup.definition.js +12 -0
  61. package/lib/metadataTypes/definitions/Automation.definition.js +10 -5
  62. package/lib/metadataTypes/definitions/Campaign.definition.js +44 -1
  63. package/lib/metadataTypes/definitions/DataExtension.definition.js +4 -0
  64. package/lib/metadataTypes/definitions/DataExtensionTemplate.definition.js +6 -0
  65. package/lib/metadataTypes/definitions/DataExtract.definition.js +18 -14
  66. package/lib/metadataTypes/definitions/Discovery.definition.js +12 -0
  67. package/lib/metadataTypes/definitions/EmailSendDefinition.definition.js +4 -0
  68. package/lib/metadataTypes/definitions/EventDefinition.definition.js +22 -0
  69. package/lib/metadataTypes/definitions/FileTransfer.definition.js +4 -0
  70. package/lib/metadataTypes/definitions/Filter.definition.js +4 -0
  71. package/lib/metadataTypes/definitions/Folder.definition.js +6 -0
  72. package/lib/metadataTypes/definitions/FtpLocation.definition.js +4 -0
  73. package/lib/metadataTypes/definitions/ImportFile.definition.js +10 -5
  74. package/lib/metadataTypes/definitions/Interaction.definition.js +4 -0
  75. package/lib/metadataTypes/definitions/MobileCode.definition.js +163 -0
  76. package/lib/metadataTypes/definitions/MobileKeyword.definition.js +253 -0
  77. package/lib/metadataTypes/definitions/Query.definition.js +4 -0
  78. package/lib/metadataTypes/definitions/Role.definition.js +5 -0
  79. package/lib/metadataTypes/definitions/Script.definition.js +4 -0
  80. package/lib/metadataTypes/definitions/SetDefinition.definition.js +28 -0
  81. package/lib/metadataTypes/definitions/TriggeredSendDefinition.definition.js +4 -0
  82. package/lib/retrieveChangelog.js +7 -6
  83. package/lib/util/auth.js +117 -0
  84. package/lib/util/businessUnit.js +55 -66
  85. package/lib/util/cache.js +194 -0
  86. package/lib/util/cli.js +90 -116
  87. package/lib/util/config.js +302 -0
  88. package/lib/util/devops.js +250 -50
  89. package/lib/util/file.js +141 -201
  90. package/lib/util/init.config.js +208 -75
  91. package/lib/util/init.git.js +45 -50
  92. package/lib/util/init.js +72 -59
  93. package/lib/util/init.npm.js +48 -39
  94. package/lib/util/util.js +280 -564
  95. package/package.json +45 -34
  96. package/test/dataExtension.test.js +152 -0
  97. package/test/mockRoot/.mcdev-auth.json +8 -0
  98. package/test/mockRoot/.mcdevrc.json +67 -0
  99. package/test/mockRoot/deploy/testInstance/testBU/dataExtension/childBU_dataextension_test.dataExtension-meta.json +39 -0
  100. package/test/mockRoot/deploy/testInstance/testBU/dataExtension/testDataExtension.dataExtension-meta.json +23 -0
  101. package/test/mockRoot/deploy/testInstance/testBU/query/testExistingQuery.query-meta.json +11 -0
  102. package/test/mockRoot/deploy/testInstance/testBU/query/testExistingQuery.query-meta.sql +4 -0
  103. package/test/mockRoot/deploy/testInstance/testBU/query/testQuery.query-meta.json +11 -0
  104. package/test/mockRoot/deploy/testInstance/testBU/query/testQuery.query-meta.sql +4 -0
  105. package/test/query.test.js +149 -0
  106. package/test/resourceFactory.js +142 -0
  107. package/test/resources/1111111/dataFolder/retrieve-response.xml +43 -0
  108. package/test/resources/9999999/automation/v1/queries/549f0568-607c-4940-afef-437965094dat/patch-response.json +18 -0
  109. package/test/resources/9999999/automation/v1/queries/get-response.json +24 -0
  110. package/test/resources/9999999/automation/v1/queries/post-response.json +18 -0
  111. package/test/resources/9999999/dataExtension/build-expected.json +51 -0
  112. package/test/resources/9999999/dataExtension/create-expected.json +23 -0
  113. package/test/resources/9999999/dataExtension/create-response.xml +54 -0
  114. package/test/resources/9999999/dataExtension/retrieve-expected.json +51 -0
  115. package/test/resources/9999999/dataExtension/retrieve-response.xml +47 -0
  116. package/test/resources/9999999/dataExtension/template-expected.json +51 -0
  117. package/test/resources/9999999/dataExtension/update-expected.json +55 -0
  118. package/test/resources/9999999/dataExtension/update-response.xml +52 -0
  119. package/test/resources/9999999/dataExtensionField/retrieve-response.xml +93 -0
  120. package/test/resources/9999999/dataExtensionTemplate/retrieve-response.xml +303 -0
  121. package/test/resources/9999999/dataFolder/retrieve-response.xml +65 -0
  122. package/test/resources/9999999/query/build-expected.json +8 -0
  123. package/test/resources/9999999/query/get-expected.json +11 -0
  124. package/test/resources/9999999/query/patch-expected.json +11 -0
  125. package/test/resources/9999999/query/post-expected.json +11 -0
  126. package/test/resources/9999999/query/template-expected.json +8 -0
  127. package/test/resources/auth.json +32 -0
  128. package/test/resources/rest404-response.json +5 -0
  129. package/test/resources/retrieve-response.xml +21 -0
  130. package/test/utils.js +107 -0
  131. package/types/mcdev.d.js +301 -0
  132. package/CHANGELOG.md +0 -126
  133. package/PULL_REQUEST_TEMPLATE.md +0 -19
  134. 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
- * @param {Object} [skipInteraction] signals what to insert automatically for things usually asked via wizard
18
- * @param {String} skipInteraction.clientId client id of installed package
19
- * @param {String} skipInteraction.clientSecret client id of installed package
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 = Util.getDefaultProperties();
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
- * @param {Object} properties config file's json
36
- * @param {Object} properties.credentials list of existing credentials
37
- * @param {Object} [skipInteraction] signals what to insert automatically for things usually asked via wizard
38
- * @param {String} skipInteraction.clientId client id of installed package
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 (!Util.checkProperties(properties)) {
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.credentialsName]) {
52
+ if (skipInteraction && properties.credentials[skipInteraction.credentialName]) {
57
53
  Util.logger.error(
58
- `Credential '${skipInteraction.credentialsName}' already existing. If you tried updating please provide run 'mcdev init ${skipInteraction.credentialsName}'`
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
- * @param {object} properties config file's json
63
+ *
64
+ * @param {TYPE.Mcdevrc} properties config file's json
68
65
  * @param {string} credName name of credential that needs updating
69
- * @param {Object} [skipInteraction] signals what to insert automatically for things usually asked via wizard
70
- * @param {String} skipInteraction.clientId client id of installed package
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
- * @param {Object} properties object of all configuration including credentials
87
- * @param {String} target code of BU to use
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<Util.BuObject>} credential to be used for Business Unit
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 (!Util.checkProperties(properties)) {
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 {object} properties config file's json
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<Array>} selected credential/BU combo
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 new Promise((resolve) => {
221
- inquirer
222
- .prompt(questions)
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 {object} properties from config file
227
+ * @param {TYPE.Mcdevrc} properties from config file
246
228
  * @param {string} [credName] name of credential that needs updating
247
- * @param {Object} [skipInteraction] signals what to insert automatically for things usually asked via wizard
248
- * @param {String} skipInteraction.clientId client id of installed package
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.clientId &&
263
- skipInteraction.clientSecret &&
264
- skipInteraction.tenant &&
265
- skipInteraction.credentialsName
239
+ skipInteraction.client_id &&
240
+ skipInteraction.client_secret &&
241
+ skipInteraction.auth_url &&
242
+ skipInteraction.account_id &&
243
+ skipInteraction.credentialName
266
244
  ) {
267
- // assume skipInteraction=={clientId,clientSecret,tenant,credentialsName}
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 clientId,clientSecret,tenant,credentialsName'
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 Util.getETClient(buObject);
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.credentialsName] = buObject;
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.credentialsName);
304
- return status ? inputData.credentialsName : status;
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 {Object} properties from config file
290
+ * @param {TYPE.Mcdevrc} properties from config file
311
291
  * @param {string} [credName] name of credential that needs updating
312
- * @returns {Promise<Object>} credential info
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: 'credentialsName',
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 = /^https:\/\/([\w-]*).(auth|soap|rest).marketingcloudapis.com[/]?$/iu;
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: 'clientId',
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: 'clientSecret',
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: 'tenant',
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 new Promise((resolve) => {
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.clientId = responses.clientId.trim();
386
- responses.clientSecret = responses.clientSecret.trim();
387
- responses.tenant = responses.tenant.trim();
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.credentialsName = credName;
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
- * @param {object} properties config file's json
402
- * @param {object} properties.metaDataTypes -
403
- * @param {String[]} properties.metaDataTypes.retrieve list of currently retrieved types
404
- * @param {String[]} [setTypesArr] skip user prompt and overwrite with this list if given
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
- ? ' \x1b[1;30;40m(non-default)\u001b[0m'
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
- * @param {Object} responses wrapper object for respones
514
- * @param {String[]} responses.selectedTypes what types the user selected
515
- * @param {String} type metadata type
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
- * @returns {void} -
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.substr(0, 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