mcdev 5.0.1 → 5.1.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 +1 -0
- package/.github/ISSUE_TEMPLATE/bug.yml +2 -0
- package/.github/dependabot.yml +8 -0
- package/.github/workflows/coverage-base-update.yml +6 -2
- package/.github/workflows/coverage-develop-branch.yml +7 -6
- package/.github/workflows/coverage-main-branch.yml +7 -6
- package/.github/workflows/coverage.yml +7 -2
- package/.husky/commit-msg +1 -1
- package/.husky/post-checkout +35 -3
- package/.husky/post-merge +21 -0
- package/.husky/pre-commit +1 -0
- package/docs/dist/documentation.md +222 -62
- package/lib/Deployer.js +3 -4
- package/lib/cli.js +36 -8
- package/lib/index.js +175 -3
- package/lib/metadataTypes/Asset.js +4 -2
- package/lib/metadataTypes/Automation.js +413 -195
- package/lib/metadataTypes/DataExtension.js +6 -8
- package/lib/metadataTypes/DataExtensionField.js +5 -5
- package/lib/metadataTypes/Journey.js +11 -10
- package/lib/metadataTypes/MetadataType.js +76 -22
- package/lib/metadataTypes/MobileKeyword.js +165 -20
- package/lib/metadataTypes/MobileMessage.js +20 -28
- package/lib/metadataTypes/Query.js +26 -0
- package/lib/metadataTypes/Role.js +2 -3
- package/lib/metadataTypes/TransactionalSMS.js +5 -5
- package/lib/metadataTypes/User.js +3 -17
- package/lib/metadataTypes/definitions/Asset.definition.js +1 -0
- package/lib/metadataTypes/definitions/Automation.definition.js +52 -6
- 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 +1 -0
- package/lib/metadataTypes/definitions/MobileKeyword.definition.js +20 -7
- package/lib/metadataTypes/definitions/MobileMessage.definition.js +50 -8
- 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 +1 -0
- package/lib/metadataTypes/definitions/User.definition.js +2 -0
- package/lib/util/auth.js +4 -1
- package/lib/util/cli.js +1 -1
- package/lib/util/devops.js +13 -11
- package/lib/util/file.js +5 -3
- package/lib/util/util.js +153 -129
- package/package.json +11 -11
- package/test/general.test.js +26 -0
- package/test/mockRoot/.mcdevrc.json +3 -1
- package/test/mockRoot/deploy/testInstance/testBU/automation/testExisting_automation.automation-meta.json +53 -0
- package/test/mockRoot/deploy/testInstance/testBU/automation/testNew_automation.automation-meta.json +46 -0
- package/test/mockRoot/deploy/testInstance/testBU/mobileKeyword/{testNew_keyword.mobileKeyword-meta.json → 4912312345678.TESTNEW_KEYWORD.mobileKeyword-meta.json} +1 -4
- package/test/mockRoot/deploy/testInstance/testBU/mobileKeyword/{testNew_keyword_blocked.mobileKeyword-meta.json → 4912312345678.TESTNEW_KEYWORD_BLOCKED.mobileKeyword-meta.json} +1 -4
- 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/{testNewQuery.query-meta.json → testNew_query.query-meta.json} +2 -2
- package/test/mockRoot/deploy/testInstance/testBU/transactionalSMS/testExisting_tsms.transactionalSMS-meta.json +1 -1
- package/test/mockRoot/deploy/testInstance/testBU/transactionalSMS/testNew_tsms.transactionalSMS-meta.json +1 -1
- package/test/resourceFactory.js +64 -21
- package/test/resources/1111111/user/retrieve-expected.md +19 -0
- package/test/resources/9999999/automation/build-expected.json +58 -0
- package/test/resources/9999999/automation/create-expected.json +46 -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/retrieve-expected.json +58 -0
- package/test/resources/9999999/automation/retrieve-testExisting_automation-expected.md +30 -0
- package/test/resources/9999999/automation/template-expected.json +58 -0
- package/test/resources/9999999/automation/update-expected.json +46 -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/a8afb0e2-b00a-4c88-ad2e-1f7f8788c560/get-response.json +85 -0
- package/test/resources/9999999/automation/v1/automations/post-response.json +85 -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/get-response.json +20 -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/get-response.json +15 -0
- package/test/resources/9999999/automation/v1/imports/get-response.json +38 -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/get-response.json +4 -4
- package/test/resources/9999999/automation/v1/queries/post-response.json +2 -2
- package/test/resources/9999999/automation/v1/scripts/get-response.json +17 -0
- package/test/resources/9999999/dataExtension/retrieve-expected.md +18 -0
- package/test/resources/9999999/dataFolder/retrieve-ContentType=automations-response.xml +48 -0
- package/test/resources/9999999/dataFolder/retrieve-ContentType=queryactivity-response.xml +48 -0
- package/test/resources/9999999/dataFolder/retrieve-response.xml +22 -0
- package/test/resources/9999999/emailSendDefinition/retrieve-response.xml +85 -0
- package/test/resources/9999999/journey/build-expected.json +1 -1
- package/test/resources/9999999/journey/get-expected.json +1 -1
- package/test/resources/9999999/journey/put-expected.json +1 -1
- package/test/resources/9999999/journey/template-expected.json +1 -1
- 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/legacy/v1/beta/mobile/keyword/NXV4ZFMwTEFwRVczd3RaLUF5X3p5dzo4Njow/get-response.json +1 -1
- package/test/resources/9999999/legacy/v1/beta/mobile/keyword/get-response.json +1 -1
- package/test/resources/9999999/legacy/v1/beta/mobile/message/NTIzOjc4OjA/get-response.json +1 -1
- package/test/resources/9999999/legacy/v1/beta/mobile/message/get-response.json +1 -1
- package/test/resources/9999999/messaging/v1/sms/definitions/post-response.json +1 -1
- package/test/resources/9999999/messaging/v1/sms/definitions/testExisting_tsms/get-response.json +1 -1
- package/test/resources/9999999/messaging/v1/sms/definitions/testExisting_tsms/patch-response.json +1 -1
- package/test/resources/9999999/mobileKeyword/build-expected.json +1 -4
- package/test/resources/9999999/mobileKeyword/get-expected.json +1 -4
- package/test/resources/9999999/mobileKeyword/post-create-expected.json +1 -4
- package/test/resources/9999999/mobileKeyword/template-expected.json +1 -4
- package/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation-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 +32 -0
- package/test/resources/9999999/query/build-expected.json +2 -2
- package/test/resources/9999999/query/build-expected.sql +1 -1
- package/test/resources/9999999/query/get-expected.json +2 -2
- package/test/resources/9999999/query/get-expected.sql +1 -1
- 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-expected.sql +1 -1
- package/test/resources/9999999/query/post-expected.json +2 -2
- package/test/resources/9999999/query/post-expected.sql +1 -1
- package/test/resources/9999999/query/template-expected.json +2 -2
- package/test/resources/9999999/query/template-expected.sql +1 -1
- package/test/resources/9999999/transactionalSMS/build-expected.json +1 -1
- package/test/resources/9999999/transactionalSMS/get-expected.json +1 -1
- package/test/resources/9999999/transactionalSMS/patch-expected.json +1 -1
- package/test/resources/9999999/transactionalSMS/post-expected.json +1 -1
- package/test/resources/9999999/transactionalSMS/template-expected.json +1 -1
- package/test/type.automation.test.js +259 -0
- package/test/type.dataExtension.test.js +16 -1
- package/test/type.mobileKeyword.test.js +57 -19
- package/test/type.query.test.js +39 -26
- package/test/type.user.test.js +44 -1
- package/test/utils.js +16 -5
- package/.coverage-comment-template.md +0 -20
- /package/test/mockRoot/deploy/testInstance/testBU/mobileKeyword/{testNew_keyword.mobileKeyword-meta.amp → 4912312345678.TESTNEW_KEYWORD.mobileKeyword-meta.amp} +0 -0
- /package/test/mockRoot/deploy/testInstance/testBU/mobileKeyword/{testNew_keyword_blocked.mobileKeyword-meta.amp → 4912312345678.TESTNEW_KEYWORD_BLOCKED.mobileKeyword-meta.amp} +0 -0
- /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/lib/util/util.js
CHANGED
|
@@ -85,7 +85,6 @@ const Util = {
|
|
|
85
85
|
*
|
|
86
86
|
* @param {string} mlName name of marketList
|
|
87
87
|
* @param {TYPE.Mcdevrc} properties General configuration to be used in retrieve
|
|
88
|
-
* @returns {void} throws errors if problems were found
|
|
89
88
|
*/
|
|
90
89
|
verifyMarketList(mlName, properties) {
|
|
91
90
|
if (properties.marketList[mlName]) {
|
|
@@ -227,6 +226,65 @@ const Util = {
|
|
|
227
226
|
|
|
228
227
|
return typeChoices;
|
|
229
228
|
},
|
|
229
|
+
/**
|
|
230
|
+
* wrapper around our standard winston logging to console and logfile
|
|
231
|
+
*
|
|
232
|
+
* @param {boolean} [noLogFile=false] optional flag to indicate if we should log to file; CLI logs are always on
|
|
233
|
+
* @returns {object} initiated logger for console and file
|
|
234
|
+
*/
|
|
235
|
+
_createNewLoggerTransport: function (noLogFile = false) {
|
|
236
|
+
// {
|
|
237
|
+
// error: 0,
|
|
238
|
+
// warn: 1,
|
|
239
|
+
// info: 2,
|
|
240
|
+
// http: 3,
|
|
241
|
+
// verbose: 4,
|
|
242
|
+
// debug: 5,
|
|
243
|
+
// silly: 6
|
|
244
|
+
// }
|
|
245
|
+
const logFileName = new Date().toISOString().split(':').join('.');
|
|
246
|
+
const transports = {
|
|
247
|
+
console: new winston.transports.Console({
|
|
248
|
+
// Write logs to Console
|
|
249
|
+
level: Util.OPTIONS.loggerLevel || 'info',
|
|
250
|
+
format: winston.format.combine(
|
|
251
|
+
winston.format.colorize(),
|
|
252
|
+
winston.format.timestamp({ format: 'HH:mm:ss' }),
|
|
253
|
+
winston.format.simple(),
|
|
254
|
+
winston.format.printf(
|
|
255
|
+
(info) => `${info.timestamp} ${info.level}: ${info.message}`
|
|
256
|
+
)
|
|
257
|
+
),
|
|
258
|
+
}),
|
|
259
|
+
};
|
|
260
|
+
if (!noLogFile) {
|
|
261
|
+
transports.file = new winston.transports.File({
|
|
262
|
+
// Write logs to logfile
|
|
263
|
+
filename: 'logs/' + logFileName + '.log',
|
|
264
|
+
level: 'debug', // log everything
|
|
265
|
+
format: winston.format.combine(
|
|
266
|
+
winston.format.timestamp({ format: 'HH:mm:ss.SSS' }),
|
|
267
|
+
winston.format.simple(),
|
|
268
|
+
winston.format.printf(
|
|
269
|
+
(info) => `${info.timestamp} ${info.level}: ${info.message}`
|
|
270
|
+
)
|
|
271
|
+
),
|
|
272
|
+
});
|
|
273
|
+
transports.fileError = new winston.transports.File({
|
|
274
|
+
// Write logs to additional error-logfile for better visibility of errors
|
|
275
|
+
filename: 'logs/' + logFileName + '-errors.log',
|
|
276
|
+
level: 'error', // only log errors
|
|
277
|
+
format: winston.format.combine(
|
|
278
|
+
winston.format.timestamp({ format: 'HH:mm:ss.SSS' }),
|
|
279
|
+
winston.format.simple(),
|
|
280
|
+
winston.format.printf(
|
|
281
|
+
(info) => `${info.timestamp} ${info.level}: ${info.message}`
|
|
282
|
+
)
|
|
283
|
+
),
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
return transports;
|
|
287
|
+
},
|
|
230
288
|
|
|
231
289
|
loggerTransports: null,
|
|
232
290
|
/**
|
|
@@ -235,7 +293,91 @@ const Util = {
|
|
|
235
293
|
* @type {TYPE.Logger}
|
|
236
294
|
*/
|
|
237
295
|
logger: null,
|
|
238
|
-
|
|
296
|
+
/**
|
|
297
|
+
* initiate winston logger
|
|
298
|
+
*
|
|
299
|
+
* @param {boolean} [restart=false] if true, logger will be restarted; otherwise, an existing logger will be used
|
|
300
|
+
* @param {boolean} [noLogFile=false] if false, logger will log to file; otherwise, only to console
|
|
301
|
+
* @returns {void}
|
|
302
|
+
*/
|
|
303
|
+
startLogger: function (restart = false, noLogFile = false) {
|
|
304
|
+
if (
|
|
305
|
+
!(
|
|
306
|
+
Util.loggerTransports === null ||
|
|
307
|
+
restart ||
|
|
308
|
+
(!Util.loggerTransports?.file && !noLogFile && !Util.OPTIONS?.noLogFile)
|
|
309
|
+
)
|
|
310
|
+
) {
|
|
311
|
+
// logger already started
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
Util.loggerTransports = this._createNewLoggerTransport(
|
|
315
|
+
noLogFile || Util.OPTIONS?.noLogFile
|
|
316
|
+
);
|
|
317
|
+
const myWinston = winston.createLogger({
|
|
318
|
+
level: Util.OPTIONS.loggerLevel,
|
|
319
|
+
levels: winston.config.npm.levels,
|
|
320
|
+
transports: Object.values(Util.loggerTransports),
|
|
321
|
+
});
|
|
322
|
+
const winstonError = myWinston.error;
|
|
323
|
+
const winstonExtension = {
|
|
324
|
+
/**
|
|
325
|
+
* helper that prints better stack trace for errors
|
|
326
|
+
*
|
|
327
|
+
* @param {Error} ex the error
|
|
328
|
+
* @param {string} [message] optional custom message to be printed as error together with the exception's message
|
|
329
|
+
* @returns {void}
|
|
330
|
+
*/
|
|
331
|
+
errorStack: function (ex, message) {
|
|
332
|
+
if (message) {
|
|
333
|
+
// ! this method only sets exitCode=1 if message-param was set
|
|
334
|
+
// if not, then this method purely outputs debug information and should not change the exitCode
|
|
335
|
+
winstonError(message + ':');
|
|
336
|
+
winstonError(` ${ex.message} (${ex.code})`);
|
|
337
|
+
if (ex.endpoint) {
|
|
338
|
+
// ex.endpoint is only available if 'ex' is of type RestError
|
|
339
|
+
winstonError(' endpoint: ' + ex.endpoint);
|
|
340
|
+
}
|
|
341
|
+
Util.signalFatalError();
|
|
342
|
+
}
|
|
343
|
+
let stack;
|
|
344
|
+
/* eslint-disable unicorn/prefer-ternary */
|
|
345
|
+
if (
|
|
346
|
+
[
|
|
347
|
+
'ETIMEDOUT',
|
|
348
|
+
'EHOSTUNREACH',
|
|
349
|
+
'ENOTFOUND',
|
|
350
|
+
'ECONNRESET',
|
|
351
|
+
'ECONNABORTED',
|
|
352
|
+
].includes(ex.code)
|
|
353
|
+
) {
|
|
354
|
+
// the stack would just return a one-liner that does not help
|
|
355
|
+
stack = new Error().stack; // eslint-disable-line unicorn/error-message
|
|
356
|
+
} else {
|
|
357
|
+
stack = ex.stack;
|
|
358
|
+
}
|
|
359
|
+
/* eslint-enable unicorn/prefer-ternary */
|
|
360
|
+
myWinston.debug(stack);
|
|
361
|
+
},
|
|
362
|
+
/**
|
|
363
|
+
* errors should cause surrounding applications to take notice
|
|
364
|
+
* hence we overwrite the default error function here
|
|
365
|
+
*
|
|
366
|
+
* @param {string} msg - the message to log
|
|
367
|
+
* @returns {void}
|
|
368
|
+
*/
|
|
369
|
+
error: function (msg) {
|
|
370
|
+
winstonError(msg);
|
|
371
|
+
Util.signalFatalError();
|
|
372
|
+
},
|
|
373
|
+
};
|
|
374
|
+
Util.logger = Object.assign(myWinston, winstonExtension);
|
|
375
|
+
|
|
376
|
+
const processArgv = process.argv.slice(2);
|
|
377
|
+
Util.logger.debug(
|
|
378
|
+
`:: mcdev ${packageJsonMcdev.version} :: ⚡ mcdev ${processArgv.join(' ')}`
|
|
379
|
+
);
|
|
380
|
+
},
|
|
239
381
|
/**
|
|
240
382
|
* Logger helper for Metadata functions
|
|
241
383
|
*
|
|
@@ -416,7 +558,7 @@ const Util = {
|
|
|
416
558
|
* @param {string} cmd to be executed command
|
|
417
559
|
* @param {string[]} [args] list of arguments
|
|
418
560
|
* @param {boolean} [hideOutput] if true, output of command will be hidden from CLI
|
|
419
|
-
* @returns {string} output of command if hideOutput is true
|
|
561
|
+
* @returns {string|void} output of command if hideOutput is true
|
|
420
562
|
*/
|
|
421
563
|
execSync(cmd, args, hideOutput) {
|
|
422
564
|
args ||= [];
|
|
@@ -437,6 +579,7 @@ const Util = {
|
|
|
437
579
|
}
|
|
438
580
|
} catch {
|
|
439
581
|
// avoid errors from execSync to bubble up
|
|
582
|
+
return null;
|
|
440
583
|
}
|
|
441
584
|
},
|
|
442
585
|
/**
|
|
@@ -470,34 +613,30 @@ const Util = {
|
|
|
470
613
|
* @returns {void}
|
|
471
614
|
*/
|
|
472
615
|
setLoggingLevel(argv) {
|
|
473
|
-
Util.loggerTransports.console.file = 'debug';
|
|
474
616
|
if (argv.silent) {
|
|
475
617
|
// only errors printed to CLI
|
|
476
|
-
Util.logger.level = 'error';
|
|
477
618
|
Util.OPTIONS.loggerLevel = 'error';
|
|
478
|
-
Util.loggerTransports.console.level = 'error';
|
|
479
619
|
Util.logger.debug('CLI logger set to: silent');
|
|
480
620
|
} else if (argv.verbose) {
|
|
481
621
|
// chatty user cli logs
|
|
482
|
-
Util.logger.level = 'verbose';
|
|
483
622
|
Util.OPTIONS.loggerLevel = 'verbose';
|
|
484
|
-
Util.loggerTransports.console.level = 'verbose';
|
|
485
623
|
Util.logger.debug('CLI logger set to: verbose');
|
|
486
624
|
} else {
|
|
487
625
|
// default user cli logs
|
|
488
|
-
// TODO to be switched to "warn" when cli-process is integrated
|
|
489
|
-
Util.logger.level = 'info';
|
|
490
626
|
Util.OPTIONS.loggerLevel = 'info';
|
|
491
|
-
Util.loggerTransports.console.level = 'info';
|
|
492
627
|
Util.logger.debug('CLI logger set to: info / default');
|
|
493
628
|
}
|
|
494
629
|
if (argv.debug) {
|
|
495
630
|
// enables developer output & features. no change to actual logs
|
|
496
|
-
Util.logger.level = 'debug';
|
|
497
631
|
Util.OPTIONS.loggerLevel = 'debug';
|
|
498
|
-
Util.loggerTransports.console.level = 'debug';
|
|
499
632
|
Util.logger.debug('CLI logger set to: debug');
|
|
500
633
|
}
|
|
634
|
+
if (Util.loggerTransports?.console) {
|
|
635
|
+
Util.loggerTransports.console.level = Util.OPTIONS.loggerLevel;
|
|
636
|
+
}
|
|
637
|
+
if (Util.logger) {
|
|
638
|
+
Util.logger.level = Util.OPTIONS.loggerLevel;
|
|
639
|
+
}
|
|
501
640
|
},
|
|
502
641
|
/**
|
|
503
642
|
* outputs a warning that the given type is still in beta
|
|
@@ -642,122 +781,7 @@ const Util = {
|
|
|
642
781
|
return null;
|
|
643
782
|
},
|
|
644
783
|
};
|
|
645
|
-
/**
|
|
646
|
-
* wrapper around our standard winston logging to console and logfile
|
|
647
|
-
*
|
|
648
|
-
* @returns {object} initiated logger for console and file
|
|
649
|
-
*/
|
|
650
|
-
function createNewLoggerTransport() {
|
|
651
|
-
// {
|
|
652
|
-
// error: 0,
|
|
653
|
-
// warn: 1,
|
|
654
|
-
// info: 2,
|
|
655
|
-
// http: 3,
|
|
656
|
-
// verbose: 4,
|
|
657
|
-
// debug: 5,
|
|
658
|
-
// silly: 6
|
|
659
|
-
// }
|
|
660
|
-
const logFileName = new Date().toISOString().split(':').join('.');
|
|
661
|
-
return {
|
|
662
|
-
console: new winston.transports.Console({
|
|
663
|
-
// Write logs to Console
|
|
664
|
-
level: 'info', // log error, warn, info
|
|
665
|
-
format: winston.format.combine(
|
|
666
|
-
winston.format.colorize(),
|
|
667
|
-
winston.format.timestamp({ format: 'HH:mm:ss' }),
|
|
668
|
-
winston.format.simple(),
|
|
669
|
-
winston.format.printf((info) => `${info.timestamp} ${info.level}: ${info.message}`)
|
|
670
|
-
),
|
|
671
|
-
}),
|
|
672
|
-
file: new winston.transports.File({
|
|
673
|
-
// Write logs to logfile
|
|
674
|
-
filename: 'logs/' + logFileName + '.log',
|
|
675
|
-
level: 'debug', // log everything
|
|
676
|
-
format: winston.format.combine(
|
|
677
|
-
winston.format.timestamp({ format: 'HH:mm:ss.SSS' }),
|
|
678
|
-
winston.format.simple(),
|
|
679
|
-
winston.format.printf((info) => `${info.timestamp} ${info.level}: ${info.message}`)
|
|
680
|
-
),
|
|
681
|
-
}),
|
|
682
|
-
fileError: new winston.transports.File({
|
|
683
|
-
// Write logs to additional error-logfile for better visibility of errors
|
|
684
|
-
filename: 'logs/' + logFileName + '-errors.log',
|
|
685
|
-
level: 'error', // only log errors
|
|
686
|
-
format: winston.format.combine(
|
|
687
|
-
winston.format.timestamp({ format: 'HH:mm:ss.SSS' }),
|
|
688
|
-
winston.format.simple(),
|
|
689
|
-
winston.format.printf((info) => `${info.timestamp} ${info.level}: ${info.message}`)
|
|
690
|
-
),
|
|
691
|
-
}),
|
|
692
|
-
};
|
|
693
|
-
}
|
|
694
|
-
/**
|
|
695
|
-
* initiate winston logger
|
|
696
|
-
*
|
|
697
|
-
* @returns {void}
|
|
698
|
-
*/
|
|
699
|
-
function startLogger() {
|
|
700
|
-
Util.loggerTransports = createNewLoggerTransport();
|
|
701
|
-
const myWinston = winston.createLogger({
|
|
702
|
-
levels: winston.config.npm.levels,
|
|
703
|
-
transports: [
|
|
704
|
-
Util.loggerTransports.console,
|
|
705
|
-
Util.loggerTransports.file,
|
|
706
|
-
Util.loggerTransports.fileError,
|
|
707
|
-
],
|
|
708
|
-
});
|
|
709
|
-
const winstonError = myWinston.error;
|
|
710
|
-
const winstonExtension = {
|
|
711
|
-
/**
|
|
712
|
-
* helper that prints better stack trace for errors
|
|
713
|
-
*
|
|
714
|
-
* @param {Error} ex the error
|
|
715
|
-
* @param {string} [message] optional custom message to be printed as error together with the exception's message
|
|
716
|
-
* @returns {void}
|
|
717
|
-
*/
|
|
718
|
-
errorStack: function (ex, message) {
|
|
719
|
-
if (message) {
|
|
720
|
-
// ! this method only sets exitCode=1 if message-param was set
|
|
721
|
-
// if not, then this method purely outputs debug information and should not change the exitCode
|
|
722
|
-
winstonError(message + ':');
|
|
723
|
-
winstonError(` ${ex.message} (${ex.code})`);
|
|
724
|
-
if (ex.endpoint) {
|
|
725
|
-
// ex.endpoint is only available if 'ex' is of type RestError
|
|
726
|
-
winstonError(' endpoint: ' + ex.endpoint);
|
|
727
|
-
}
|
|
728
|
-
Util.signalFatalError();
|
|
729
|
-
}
|
|
730
|
-
let stack;
|
|
731
|
-
/* eslint-disable unicorn/prefer-ternary */
|
|
732
|
-
if (
|
|
733
|
-
['ETIMEDOUT', 'EHOSTUNREACH', 'ENOTFOUND', 'ECONNRESET', 'ECONNABORTED'].includes(
|
|
734
|
-
ex.code
|
|
735
|
-
)
|
|
736
|
-
) {
|
|
737
|
-
// the stack would just return a one-liner that does not help
|
|
738
|
-
stack = new Error().stack; // eslint-disable-line unicorn/error-message
|
|
739
|
-
} else {
|
|
740
|
-
stack = ex.stack;
|
|
741
|
-
}
|
|
742
|
-
/* eslint-enable unicorn/prefer-ternary */
|
|
743
|
-
myWinston.debug(stack);
|
|
744
|
-
},
|
|
745
|
-
/**
|
|
746
|
-
* errors should cause surrounding applications to take notice
|
|
747
|
-
* hence we overwrite the default error function here
|
|
748
|
-
*
|
|
749
|
-
* @param {string} msg - the message to log
|
|
750
|
-
* @returns {void}
|
|
751
|
-
*/
|
|
752
|
-
error: function (msg) {
|
|
753
|
-
winstonError(msg);
|
|
754
|
-
Util.signalFatalError();
|
|
755
|
-
},
|
|
756
|
-
};
|
|
757
|
-
Util.logger = Object.assign(myWinston, winstonExtension);
|
|
758
784
|
|
|
759
|
-
|
|
760
|
-
}
|
|
761
|
-
startLogger();
|
|
785
|
+
Util.startLogger(false, true);
|
|
762
786
|
|
|
763
787
|
module.exports = Util;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcdev",
|
|
3
|
-
"version": "5.0
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "Accenture Salesforce Marketing Cloud DevTools",
|
|
5
5
|
"author": "Accenture: joern.berkefeld, douglas.midgley, robert.zimmermann, maciej.barnas",
|
|
6
6
|
"license": "MIT",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"command-exists": "1.2.9",
|
|
64
64
|
"conf": "10.2.0",
|
|
65
65
|
"console.table": "0.10.0",
|
|
66
|
-
"deep-equal": "2.1
|
|
66
|
+
"deep-equal": "2.2.1",
|
|
67
67
|
"fs-extra": "11.1.0",
|
|
68
68
|
"inquirer": "8.2.5",
|
|
69
69
|
"json-to-table": "4.2.1",
|
|
@@ -72,29 +72,29 @@
|
|
|
72
72
|
"prettier": "2.8.8",
|
|
73
73
|
"prettier-plugin-sql": "0.14.0",
|
|
74
74
|
"semver": "7.5.0",
|
|
75
|
-
"sfmc-sdk": "1.0.
|
|
76
|
-
"simple-git": "3.
|
|
75
|
+
"sfmc-sdk": "1.0.1",
|
|
76
|
+
"simple-git": "3.18.0",
|
|
77
77
|
"toposort": "2.0.2",
|
|
78
78
|
"update-notifier": "5.1.0",
|
|
79
|
-
"winston": "3.
|
|
80
|
-
"yargs": "17.
|
|
79
|
+
"winston": "3.9.0",
|
|
80
|
+
"yargs": "17.7.2"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
83
|
"assert": "2.0.0",
|
|
84
84
|
"axios-mock-adapter": "1.21.3",
|
|
85
85
|
"chai": "4.3.7",
|
|
86
86
|
"chai-files": "1.4.0",
|
|
87
|
-
"eslint": "8.
|
|
87
|
+
"eslint": "8.42.0",
|
|
88
88
|
"eslint-config-prettier": "8.7.0",
|
|
89
89
|
"eslint-config-ssjs": "1.1.11",
|
|
90
|
-
"eslint-plugin-jsdoc": "
|
|
90
|
+
"eslint-plugin-jsdoc": "46.2.5",
|
|
91
91
|
"eslint-plugin-mocha": "10.1.0",
|
|
92
92
|
"eslint-plugin-prettier": "4.2.1",
|
|
93
|
-
"eslint-plugin-unicorn": "
|
|
94
|
-
"fast-xml-parser": "4.2.
|
|
93
|
+
"eslint-plugin-unicorn": "47.0.0",
|
|
94
|
+
"fast-xml-parser": "4.2.4",
|
|
95
95
|
"husky": "8.0.3",
|
|
96
96
|
"jsdoc-to-markdown": "8.0.0",
|
|
97
|
-
"lint-staged": "13.2.
|
|
97
|
+
"lint-staged": "13.2.2",
|
|
98
98
|
"mocha": "10.2.0",
|
|
99
99
|
"mock-fs": "5.2.0",
|
|
100
100
|
"npm-check": "6.0.1",
|
package/test/general.test.js
CHANGED
|
@@ -14,6 +14,22 @@ describe('GENERAL', () => {
|
|
|
14
14
|
testUtils.mockReset();
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
+
describe('init ================', () => {
|
|
18
|
+
it('should init a local project without downloading BUs');
|
|
19
|
+
it('should init a local project and download all BUs');
|
|
20
|
+
});
|
|
21
|
+
describe('join ================', () => {
|
|
22
|
+
it('should clone a project from git');
|
|
23
|
+
});
|
|
24
|
+
describe('upgrade ================', () => {
|
|
25
|
+
it('should upgrade a project to the latest version');
|
|
26
|
+
});
|
|
27
|
+
describe('reloadBUs ================', () => {
|
|
28
|
+
it('should load all BUs from the server and refresh the config');
|
|
29
|
+
});
|
|
30
|
+
describe('selectTypes ================', () => {
|
|
31
|
+
it('should change which types are selected for default retrieval');
|
|
32
|
+
});
|
|
17
33
|
describe('explainTypes ================', () => {
|
|
18
34
|
it('without options', () => {
|
|
19
35
|
handler.explainTypes();
|
|
@@ -59,4 +75,14 @@ describe('GENERAL', () => {
|
|
|
59
75
|
return;
|
|
60
76
|
});
|
|
61
77
|
});
|
|
78
|
+
describe('createDeltaPkg ================', () => {
|
|
79
|
+
it('should show diff to master branch');
|
|
80
|
+
// mcdev createDeltaPkg master # resolves to master..HEAD
|
|
81
|
+
it('should show diff between master and develop branch');
|
|
82
|
+
// mcdev createDeltaPkg master..develop
|
|
83
|
+
it(
|
|
84
|
+
'should show diff between master and develop branch and filter the results to only show MyProject/BU1'
|
|
85
|
+
);
|
|
86
|
+
// mcdev createDeltaPkg master..develop --filter 'MyProject/BU1'
|
|
87
|
+
});
|
|
62
88
|
});
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"sharedFolder": "/Shared Data Extensions/test",
|
|
42
42
|
"suffix": "_test",
|
|
43
43
|
"prefix": "testExisting_",
|
|
44
|
+
"prefixUpper": "TESTEXISTING_",
|
|
44
45
|
"description": "bla bla",
|
|
45
46
|
"countryCodeIn": "'test'"
|
|
46
47
|
},
|
|
@@ -51,6 +52,7 @@
|
|
|
51
52
|
"sharedFolder": "/Shared Data Extensions/test target",
|
|
52
53
|
"suffix": "_testTarget",
|
|
53
54
|
"prefix": "testTemplated_",
|
|
55
|
+
"prefixUpper": "TESTTEMPLATED_",
|
|
54
56
|
"description": "foobar",
|
|
55
57
|
"countryCodeIn": "'testTarget'"
|
|
56
58
|
}
|
|
@@ -76,5 +78,5 @@
|
|
|
76
78
|
"triggeredSend"
|
|
77
79
|
]
|
|
78
80
|
},
|
|
79
|
-
"version": "5.0
|
|
81
|
+
"version": "5.1.0"
|
|
80
82
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"description": "updated on deploy",
|
|
3
|
+
"key": "testExisting_automation",
|
|
4
|
+
"name": "testExisting_automation",
|
|
5
|
+
"r__folder_Path": "my automations",
|
|
6
|
+
"schedule": {
|
|
7
|
+
"endDate": "2022-07-30T00:00:00",
|
|
8
|
+
"icalRecur": "FREQ=DAILY;COUNT=1;INTERVAL=1",
|
|
9
|
+
"startDate": "2022-07-30T00:00:00",
|
|
10
|
+
"timezoneName": "W. Europe Standard Time",
|
|
11
|
+
"typeId": 3
|
|
12
|
+
},
|
|
13
|
+
"status": "PausedSchedule",
|
|
14
|
+
"steps": [
|
|
15
|
+
{
|
|
16
|
+
"activities": [
|
|
17
|
+
{
|
|
18
|
+
"name": "testExisting_dataExtract",
|
|
19
|
+
"r__type": "dataExtract"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"name": "testExisting_emailSend",
|
|
23
|
+
"r__type": "emailSend"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "testExisting_fileTransfer",
|
|
27
|
+
"r__type": "fileTransfer"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "testExisting_importFile",
|
|
31
|
+
"r__type": "importFile"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"name": "testExisting_query",
|
|
35
|
+
"r__type": "query"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"name": "testExisting_script",
|
|
39
|
+
"r__type": "script"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"name": ""
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"notifications": [
|
|
46
|
+
{
|
|
47
|
+
"email": ["error-updated@test.accenture.com"],
|
|
48
|
+
"message": "test updated",
|
|
49
|
+
"type": "Error"
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
"type": "scheduled"
|
|
53
|
+
}
|
package/test/mockRoot/deploy/testInstance/testBU/automation/testNew_automation.automation-meta.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"description": "created on deploy",
|
|
3
|
+
"key": "testNew_automation",
|
|
4
|
+
"name": "testNew_automation",
|
|
5
|
+
"r__folder_Path": "my automations",
|
|
6
|
+
"schedule": {
|
|
7
|
+
"endDate": "2022-07-30T00:00:00",
|
|
8
|
+
"icalRecur": "FREQ=DAILY;COUNT=1;INTERVAL=1",
|
|
9
|
+
"startDate": "2022-07-30T00:00:00",
|
|
10
|
+
"timezoneName": "W. Europe Standard Time",
|
|
11
|
+
"typeId": 3
|
|
12
|
+
},
|
|
13
|
+
"status": "PausedSchedule",
|
|
14
|
+
"steps": [
|
|
15
|
+
{
|
|
16
|
+
"activities": [
|
|
17
|
+
{
|
|
18
|
+
"name": "testExisting_dataExtract",
|
|
19
|
+
"r__type": "dataExtract"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"name": "testExisting_emailSend",
|
|
23
|
+
"r__type": "emailSend"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "testExisting_fileTransfer",
|
|
27
|
+
"r__type": "fileTransfer"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "testExisting_importFile",
|
|
31
|
+
"r__type": "importFile"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"name": "testExisting_query",
|
|
35
|
+
"r__type": "query"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"name": "testExisting_script",
|
|
39
|
+
"r__type": "script"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"name": ""
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"type": "scheduled"
|
|
46
|
+
}
|