@sasjs/cli 3.13.3 → 3.13.6

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 (32) hide show
  1. package/build/commands/compile/compile.js +33 -26
  2. package/build/commands/compile/compileSingleFile.js +8 -5
  3. package/build/commands/compile/internal/compileFile.d.ts +15 -0
  4. package/build/commands/compile/internal/{compileServiceFile.js → compileFile.js} +27 -5
  5. package/build/commands/compile/internal/compileTestFile.js +2 -2
  6. package/build/commands/compile/spec/compile.spec.js +24 -8
  7. package/build/commands/compile/spec/{compileJobFile.spec.d.ts → compileFile.spec.d.ts} +0 -0
  8. package/build/commands/compile/spec/{compileServiceFile.spec.js → compileFile.spec.js} +75 -37
  9. package/build/commands/deploy/deploy.js +6 -2
  10. package/build/commands/help/help.js +3 -2
  11. package/build/commands/job/internal/execute/sasjs.d.ts +2 -1
  12. package/build/commands/job/internal/execute/sasjs.js +2 -2
  13. package/build/commands/job/jobCommand.d.ts +1 -1
  14. package/build/commands/job/jobCommand.js +23 -12
  15. package/build/commands/job/spec/execute.spec.js +1 -1
  16. package/build/commands/request/request.js +4 -4
  17. package/build/commands/request/requestCommand.js +21 -10
  18. package/build/commands/shared/deployToSasViyaWithServicePack.js +6 -1
  19. package/build/commands/testing/spec/testCommand.spec.js +5 -3
  20. package/build/commands/testing/spec/testing.spec.js +32 -4
  21. package/build/commands/testing/test.d.ts +1 -1
  22. package/build/commands/testing/test.js +13 -2
  23. package/build/commands/testing/testCommand.js +13 -7
  24. package/build/commands/web/internal/sasjsout.d.ts +1 -1
  25. package/build/commands/web/internal/sasjsout.js +1 -1
  26. package/build/utils/displayResult.js +5 -1
  27. package/package.json +6 -5
  28. package/build/commands/compile/internal/compileJobFile.d.ts +0 -3
  29. package/build/commands/compile/internal/compileJobFile.js +0 -60
  30. package/build/commands/compile/internal/compileServiceFile.d.ts +0 -4
  31. package/build/commands/compile/spec/compileJobFile.spec.js +0 -140
  32. package/build/commands/compile/spec/compileServiceFile.spec.d.ts +0 -1
@@ -75,11 +75,11 @@ var config_1 = require("../../utils/config");
75
75
  var utils_1 = require("@sasjs/utils");
76
76
  var web_1 = require("../web/web");
77
77
  var file_1 = require("../../utils/file");
78
+ var types_1 = require("@sasjs/utils/types");
78
79
  var checkCompileStatus_1 = require("./internal/checkCompileStatus");
79
80
  var compileModule = __importStar(require("./compile"));
80
81
  var getAllFolders_1 = require("./internal/getAllFolders");
81
- var compileServiceFile_1 = require("./internal/compileServiceFile");
82
- var compileJobFile_1 = require("./internal/compileJobFile");
82
+ var compileFile_1 = require("./internal/compileFile");
83
83
  var compileTestFile_1 = require("./internal/compileTestFile");
84
84
  var getDestinationPath_1 = require("./internal/getDestinationPath");
85
85
  var loadDependencies_1 = require("./internal/loadDependencies");
@@ -138,7 +138,10 @@ function compile(target, forceCompile) {
138
138
  macroTestFiles = _c.sent();
139
139
  return [4 /*yield*/, (0, utils_1.asyncForEach)(macroTestFiles, function (macroTestFile) { return __awaiter(_this, void 0, void 0, function () {
140
140
  return __generator(this, function (_a) {
141
- return [2 /*return*/, (0, compileServiceFile_1.compileServiceFile)(target, path_1.default.join(buildMacroTestFolder_1, macroTestFile), macroFolders, programFolders_1, undefined, compileTree)];
141
+ switch (_a.label) {
142
+ case 0: return [4 /*yield*/, (0, compileFile_1.compileFile)(target, path_1.default.join(buildMacroTestFolder_1, macroTestFile), macroFolders, programFolders_1, undefined, compileTree, types_1.SASJsFileType.service, '')];
143
+ case 1: return [2 /*return*/, _a.sent()];
144
+ }
142
145
  });
143
146
  }); })];
144
147
  case 10:
@@ -326,7 +329,7 @@ function recreateBuildFolder() {
326
329
  }
327
330
  // REFACTOR: combine compileServiceFolder and compileJobFolder
328
331
  var compileServiceFolder = function (target, serviceFolder, macroFolders, programFolders, compileTree) { return __awaiter(void 0, void 0, void 0, function () {
329
- var destinationPath, subFolders, filesNamesInPath;
332
+ var destinationPath, subFolders, sourceFiles;
330
333
  return __generator(this, function (_a) {
331
334
  switch (_a.label) {
332
335
  case 0:
@@ -334,21 +337,21 @@ var compileServiceFolder = function (target, serviceFolder, macroFolders, progra
334
337
  return [4 /*yield*/, (0, utils_1.listSubFoldersInFolder)(destinationPath)];
335
338
  case 1:
336
339
  subFolders = _a.sent();
337
- return [4 /*yield*/, (0, utils_1.listFilesInFolder)(destinationPath)
340
+ return [4 /*yield*/, (0, utils_1.listFilesInFolder)(serviceFolder)
338
341
  // Checks if file in sasjsbuild folder exists in source folder.
339
342
  // If not, it means that the file shouldn't be compiled.
340
343
  ];
341
344
  case 2:
342
- filesNamesInPath = _a.sent();
345
+ sourceFiles = _a.sent();
343
346
  // Checks if file in sasjsbuild folder exists in source folder.
344
347
  // If not, it means that the file shouldn't be compiled.
345
- return [4 /*yield*/, (0, utils_1.asyncForEach)(filesNamesInPath, function (fileName, i) { return __awaiter(void 0, void 0, void 0, function () {
348
+ return [4 /*yield*/, (0, utils_1.asyncForEach)(sourceFiles, function (fileName, i) { return __awaiter(void 0, void 0, void 0, function () {
346
349
  return __generator(this, function (_a) {
347
350
  switch (_a.label) {
348
351
  case 0: return [4 /*yield*/, (0, utils_1.fileExists)(path_1.default.join(serviceFolder, fileName))];
349
352
  case 1:
350
353
  if (!(_a.sent())) {
351
- filesNamesInPath.splice(i, 1);
354
+ sourceFiles.splice(i, 1);
352
355
  }
353
356
  return [2 /*return*/];
354
357
  }
@@ -358,7 +361,7 @@ var compileServiceFolder = function (target, serviceFolder, macroFolders, progra
358
361
  // Checks if file in sasjsbuild folder exists in source folder.
359
362
  // If not, it means that the file shouldn't be compiled.
360
363
  _a.sent();
361
- return [4 /*yield*/, (0, utils_1.asyncForEach)(filesNamesInPath, function (fileName) { return __awaiter(void 0, void 0, void 0, function () {
364
+ return [4 /*yield*/, (0, utils_1.asyncForEach)(sourceFiles, function (fileName) { return __awaiter(void 0, void 0, void 0, function () {
362
365
  var filePath;
363
366
  return __generator(this, function (_a) {
364
367
  switch (_a.label) {
@@ -369,7 +372,7 @@ var compileServiceFolder = function (target, serviceFolder, macroFolders, progra
369
372
  case 1:
370
373
  _a.sent();
371
374
  return [3 /*break*/, 4];
372
- case 2: return [4 /*yield*/, (0, compileServiceFile_1.compileServiceFile)(target, filePath, macroFolders, programFolders, undefined, compileTree)];
375
+ case 2: return [4 /*yield*/, (0, compileFile_1.compileFile)(target, filePath, macroFolders, programFolders, undefined, compileTree, types_1.SASJsFileType.service, serviceFolder)];
373
376
  case 3:
374
377
  _a.sent();
375
378
  _a.label = 4;
@@ -380,13 +383,15 @@ var compileServiceFolder = function (target, serviceFolder, macroFolders, progra
380
383
  case 4:
381
384
  _a.sent();
382
385
  return [4 /*yield*/, (0, utils_1.asyncForEach)(subFolders, function (subFolder) { return __awaiter(void 0, void 0, void 0, function () {
383
- var fileNames;
386
+ var sourceFolder, sourceFiles;
384
387
  return __generator(this, function (_a) {
385
388
  switch (_a.label) {
386
- case 0: return [4 /*yield*/, (0, utils_1.listFilesInFolder)(path_1.default.join(serviceFolder, subFolder))];
389
+ case 0:
390
+ sourceFolder = path_1.default.join(serviceFolder, subFolder);
391
+ return [4 /*yield*/, (0, utils_1.listFilesInFolder)(sourceFolder)];
387
392
  case 1:
388
- fileNames = _a.sent();
389
- return [4 /*yield*/, (0, utils_1.asyncForEach)(fileNames, function (fileName) { return __awaiter(void 0, void 0, void 0, function () {
393
+ sourceFiles = _a.sent();
394
+ return [4 /*yield*/, (0, utils_1.asyncForEach)(sourceFiles, function (fileName) { return __awaiter(void 0, void 0, void 0, function () {
390
395
  var filePath;
391
396
  return __generator(this, function (_a) {
392
397
  switch (_a.label) {
@@ -397,7 +402,7 @@ var compileServiceFolder = function (target, serviceFolder, macroFolders, progra
397
402
  case 1:
398
403
  _a.sent();
399
404
  return [3 /*break*/, 4];
400
- case 2: return [4 /*yield*/, (0, compileServiceFile_1.compileServiceFile)(target, filePath, macroFolders, programFolders, undefined, compileTree)];
405
+ case 2: return [4 /*yield*/, (0, compileFile_1.compileFile)(target, filePath, macroFolders, programFolders, undefined, compileTree, types_1.SASJsFileType.service, sourceFolder)];
401
406
  case 3:
402
407
  _a.sent();
403
408
  _a.label = 4;
@@ -419,7 +424,7 @@ var compileServiceFolder = function (target, serviceFolder, macroFolders, progra
419
424
  });
420
425
  }); };
421
426
  var compileJobFolder = function (target, jobFolder, macroFolders, programFolders, compileTree) { return __awaiter(void 0, void 0, void 0, function () {
422
- var destinationPath, subFolders, filesNamesInPath;
427
+ var destinationPath, subFolders, sourceFiles;
423
428
  return __generator(this, function (_a) {
424
429
  switch (_a.label) {
425
430
  case 0:
@@ -432,16 +437,16 @@ var compileJobFolder = function (target, jobFolder, macroFolders, programFolders
432
437
  // If not, it means that the file shouldn't be compiled.
433
438
  ];
434
439
  case 2:
435
- filesNamesInPath = _a.sent();
440
+ sourceFiles = _a.sent();
436
441
  // Checks if file in sasjsbuild folder exists in source folder.
437
442
  // If not, it means that the file shouldn't be compiled.
438
- return [4 /*yield*/, (0, utils_1.asyncForEach)(filesNamesInPath, function (fileName, i) { return __awaiter(void 0, void 0, void 0, function () {
443
+ return [4 /*yield*/, (0, utils_1.asyncForEach)(sourceFiles, function (fileName, i) { return __awaiter(void 0, void 0, void 0, function () {
439
444
  return __generator(this, function (_a) {
440
445
  switch (_a.label) {
441
446
  case 0: return [4 /*yield*/, (0, utils_1.fileExists)(path_1.default.join(jobFolder, fileName))];
442
447
  case 1:
443
448
  if (!(_a.sent())) {
444
- filesNamesInPath.splice(i, 1);
449
+ sourceFiles.splice(i, 1);
445
450
  }
446
451
  return [2 /*return*/];
447
452
  }
@@ -451,7 +456,7 @@ var compileJobFolder = function (target, jobFolder, macroFolders, programFolders
451
456
  // Checks if file in sasjsbuild folder exists in source folder.
452
457
  // If not, it means that the file shouldn't be compiled.
453
458
  _a.sent();
454
- return [4 /*yield*/, (0, utils_1.asyncForEach)(filesNamesInPath, function (fileName) { return __awaiter(void 0, void 0, void 0, function () {
459
+ return [4 /*yield*/, (0, utils_1.asyncForEach)(sourceFiles, function (fileName) { return __awaiter(void 0, void 0, void 0, function () {
455
460
  var filePath;
456
461
  return __generator(this, function (_a) {
457
462
  switch (_a.label) {
@@ -462,7 +467,7 @@ var compileJobFolder = function (target, jobFolder, macroFolders, programFolders
462
467
  case 1:
463
468
  _a.sent();
464
469
  return [3 /*break*/, 4];
465
- case 2: return [4 /*yield*/, (0, compileJobFile_1.compileJobFile)(target, filePath, macroFolders, programFolders, undefined, compileTree)];
470
+ case 2: return [4 /*yield*/, (0, compileFile_1.compileFile)(target, filePath, macroFolders, programFolders, undefined, compileTree, types_1.SASJsFileType.job, jobFolder)];
466
471
  case 3:
467
472
  _a.sent();
468
473
  _a.label = 4;
@@ -473,13 +478,15 @@ var compileJobFolder = function (target, jobFolder, macroFolders, programFolders
473
478
  case 4:
474
479
  _a.sent();
475
480
  return [4 /*yield*/, (0, utils_1.asyncForEach)(subFolders, function (subFolder) { return __awaiter(void 0, void 0, void 0, function () {
476
- var fileNames;
481
+ var sourcePath, sourceFiles;
477
482
  return __generator(this, function (_a) {
478
483
  switch (_a.label) {
479
- case 0: return [4 /*yield*/, (0, utils_1.listFilesInFolder)(path_1.default.join(jobFolder, subFolder))];
484
+ case 0:
485
+ sourcePath = path_1.default.join(jobFolder, subFolder);
486
+ return [4 /*yield*/, (0, utils_1.listFilesInFolder)(sourcePath)];
480
487
  case 1:
481
- fileNames = _a.sent();
482
- return [4 /*yield*/, (0, utils_1.asyncForEach)(fileNames, function (fileName) { return __awaiter(void 0, void 0, void 0, function () {
488
+ sourceFiles = _a.sent();
489
+ return [4 /*yield*/, (0, utils_1.asyncForEach)(sourceFiles, function (fileName) { return __awaiter(void 0, void 0, void 0, function () {
483
490
  var filePath;
484
491
  return __generator(this, function (_a) {
485
492
  switch (_a.label) {
@@ -490,7 +497,7 @@ var compileJobFolder = function (target, jobFolder, macroFolders, programFolders
490
497
  case 1:
491
498
  _a.sent();
492
499
  return [3 /*break*/, 4];
493
- case 2: return [4 /*yield*/, (0, compileJobFile_1.compileJobFile)(target, filePath, macroFolders, programFolders, undefined, compileTree)];
500
+ case 2: return [4 /*yield*/, (0, compileFile_1.compileFile)(target, filePath, macroFolders, programFolders, undefined, compileTree, types_1.SASJsFileType.job, sourcePath)];
494
501
  case 3:
495
502
  _a.sent();
496
503
  _a.label = 4;
@@ -43,8 +43,7 @@ exports.compileSingleFile = void 0;
43
43
  var path_1 = __importDefault(require("path"));
44
44
  var config_1 = require("../../utils/config");
45
45
  var utils_1 = require("@sasjs/utils");
46
- var compileServiceFile_1 = require("./internal/compileServiceFile");
47
- var compileJobFile_1 = require("./internal/compileJobFile");
46
+ var compileFile_1 = require("./internal/compileFile");
48
47
  var identifySasFile_1 = require("./internal/identifySasFile");
49
48
  var loadDependencies_1 = require("./internal/loadDependencies");
50
49
  function compileSingleFile(target, subCommand, source, output, insertProgramVar) {
@@ -52,7 +51,7 @@ function compileSingleFile(target, subCommand, source, output, insertProgramVar)
52
51
  if (subCommand === void 0) { subCommand = 'identify'; }
53
52
  if (insertProgramVar === void 0) { insertProgramVar = false; }
54
53
  return __awaiter(this, void 0, void 0, function () {
55
- var subCommands, commandExample, sourcePath, outputPathParts, leafFolderName, parentOutputFolder, pathExists, sourceFileName, destinationPath, sourceFileNameWithoutExt, macroFolders, programFolders, psMaxOption, programVar, compileTree, _b;
54
+ var subCommands, commandExample, sourcePath, outputPathParts, leafFolderName, parentOutputFolder, pathExists, sourceFileName, destinationPath, sourceFileNameWithoutExt, macroFolders, programFolders, psMaxOption, programVar, compileTree, sourceFolder, _b;
56
55
  return __generator(this, function (_c) {
57
56
  switch (_c.label) {
58
57
  case 0:
@@ -113,17 +112,21 @@ function compileSingleFile(target, subCommand, source, output, insertProgramVar)
113
112
  ? "%let _program=".concat(target.appLoc, "/").concat(subCommand, "s/").concat(leafFolderName, "/").concat(sourceFileNameWithoutExt, ";\n").concat(psMaxOption)
114
113
  : "".concat(psMaxOption);
115
114
  compileTree = (0, loadDependencies_1.getCompileTree)(target);
115
+ sourceFolder = sourcePath
116
+ .split(path_1.default.sep)
117
+ .slice(0, sourcePath.split(path_1.default.sep).length - 1)
118
+ .join(path_1.default.sep);
116
119
  _b = subCommand;
117
120
  switch (_b) {
118
121
  case subCommands.service: return [3 /*break*/, 11];
119
122
  case subCommands.job: return [3 /*break*/, 13];
120
123
  }
121
124
  return [3 /*break*/, 15];
122
- case 11: return [4 /*yield*/, (0, compileServiceFile_1.compileServiceFile)(target, destinationPath, macroFolders, programFolders, programVar, compileTree)];
125
+ case 11: return [4 /*yield*/, (0, compileFile_1.compileFile)(target, destinationPath, macroFolders, programFolders, programVar, compileTree, utils_1.SASJsFileType.service, sourceFolder)];
123
126
  case 12:
124
127
  _c.sent();
125
128
  return [3 /*break*/, 16];
126
- case 13: return [4 /*yield*/, (0, compileJobFile_1.compileJobFile)(target, destinationPath, macroFolders, programFolders, programVar, compileTree)];
129
+ case 13: return [4 /*yield*/, (0, compileFile_1.compileFile)(target, destinationPath, macroFolders, programFolders, programVar, compileTree, utils_1.SASJsFileType.job, sourceFolder)];
127
130
  case 14:
128
131
  _c.sent();
129
132
  return [3 /*break*/, 16];
@@ -0,0 +1,15 @@
1
+ import { CompileTree } from '@sasjs/utils';
2
+ import { Target, ServerType, SASJsFileType } from '@sasjs/utils/types';
3
+ /**
4
+ * Compiles file dependencies.
5
+ * @param {Target} target - SAS server configuration.
6
+ * @param {string} filePath - file path of the file to be compiled.
7
+ * @param {string[]} macroFolders - macro folders paths.
8
+ * @param {string[]} programFolders - program folders paths.
9
+ * @param {string} programVar - program variable.
10
+ * @param {object} compileTree - compilation tree that stores used compilation assets.
11
+ * @param {SASJsFileType} fileType - sasjs file type.
12
+ * @param {string} sourceFolder - folder path of the source folder.
13
+ */
14
+ export declare function compileFile(target: Target, filePath: string, macroFolders: string[], programFolders: string[], programVar: string | undefined, compileTree: CompileTree, fileType: SASJsFileType, sourceFolder: string): Promise<void>;
15
+ export declare function getPreCodeForServicePack(serverType: ServerType): Promise<string>;
@@ -35,22 +35,40 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
36
  }
37
37
  };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
38
41
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.getPreCodeForServicePack = exports.compileServiceFile = void 0;
42
+ exports.getPreCodeForServicePack = exports.compileFile = void 0;
40
43
  var utils_1 = require("@sasjs/utils");
41
44
  var types_1 = require("@sasjs/utils/types");
42
45
  var error_1 = require("@sasjs/utils/error");
43
46
  var loadDependencies_1 = require("./loadDependencies");
44
47
  var getServerType_1 = require("./getServerType");
45
- function compileServiceFile(target, filePath, macroFolders, programFolders, programVar, compileTree) {
48
+ var path_1 = __importDefault(require("path"));
49
+ /**
50
+ * Compiles file dependencies.
51
+ * @param {Target} target - SAS server configuration.
52
+ * @param {string} filePath - file path of the file to be compiled.
53
+ * @param {string[]} macroFolders - macro folders paths.
54
+ * @param {string[]} programFolders - program folders paths.
55
+ * @param {string} programVar - program variable.
56
+ * @param {object} compileTree - compilation tree that stores used compilation assets.
57
+ * @param {SASJsFileType} fileType - sasjs file type.
58
+ * @param {string} sourceFolder - folder path of the source folder.
59
+ */
60
+ function compileFile(target, filePath, macroFolders, programFolders, programVar, compileTree, fileType, sourceFolder) {
46
61
  if (programVar === void 0) { programVar = ''; }
47
62
  return __awaiter(this, void 0, void 0, function () {
48
63
  var dependencies, serverType, preCode;
49
64
  return __generator(this, function (_a) {
50
65
  switch (_a.label) {
51
- case 0: return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, filePath, macroFolders, programFolders, (0, utils_1.isTestFile)(filePath) ? types_1.SASJsFileType.test : types_1.SASJsFileType.service, compileTree)];
66
+ case 0: return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, sourceFolder
67
+ ? path_1.default.join(sourceFolder, filePath.split(path_1.default.sep).pop())
68
+ : filePath, macroFolders, programFolders, (0, utils_1.isTestFile)(filePath) ? types_1.SASJsFileType.test : fileType, compileTree)];
52
69
  case 1:
53
70
  dependencies = _a.sent();
71
+ if (!(fileType === types_1.SASJsFileType.service)) return [3 /*break*/, 4];
54
72
  return [4 /*yield*/, (0, getServerType_1.getServerType)(target)];
55
73
  case 2:
56
74
  serverType = _a.sent();
@@ -58,15 +76,19 @@ function compileServiceFile(target, filePath, macroFolders, programFolders, prog
58
76
  case 3:
59
77
  preCode = _a.sent();
60
78
  dependencies = "".concat(programVar, "\n").concat(preCode, "\n").concat(dependencies);
61
- return [4 /*yield*/, (0, utils_1.createFile)(filePath, dependencies)];
79
+ return [3 /*break*/, 5];
62
80
  case 4:
81
+ dependencies = "".concat(programVar ? programVar + '\n' : '').concat(dependencies);
82
+ _a.label = 5;
83
+ case 5: return [4 /*yield*/, (0, utils_1.createFile)(filePath, dependencies)];
84
+ case 6:
63
85
  _a.sent();
64
86
  return [2 /*return*/];
65
87
  }
66
88
  });
67
89
  });
68
90
  }
69
- exports.compileServiceFile = compileServiceFile;
91
+ exports.compileFile = compileFile;
70
92
  function getPreCodeForServicePack(serverType) {
71
93
  return __awaiter(this, void 0, void 0, function () {
72
94
  var content, macroCorePath, _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
@@ -72,7 +72,7 @@ var loadDependencies_1 = require("./loadDependencies");
72
72
  var file_1 = require("../../../utils/file");
73
73
  var chalk_1 = __importDefault(require("chalk"));
74
74
  var config_1 = require("../../../utils/config");
75
- var compileServiceFile_1 = require("./compileServiceFile");
75
+ var compileFile_1 = require("./compileFile");
76
76
  var testsBuildFolder = function () {
77
77
  return path_1.default.join(process.projectDir, 'sasjsbuild', 'tests');
78
78
  };
@@ -97,7 +97,7 @@ function compileTestFile(target, filePath, testVar, saveToRoot, removeOriginalFi
97
97
  compileTree]))];
98
98
  case 3:
99
99
  dependencies = _c.sent();
100
- return [4 /*yield*/, (0, compileServiceFile_1.getPreCodeForServicePack)(target.serverType)];
100
+ return [4 /*yield*/, (0, compileFile_1.getPreCodeForServicePack)(target.serverType)];
101
101
  case 4:
102
102
  preCode = _c.sent();
103
103
  dependencies = "".concat(testVar ? testVar + '\n' : '', "\n").concat(preCode, "\n").concat(dependencies);
@@ -75,8 +75,7 @@ var config_1 = require("../../../utils/config");
75
75
  var test_1 = require("../../../utils/test");
76
76
  var compileModule = __importStar(require("../compile"));
77
77
  var compileSingleFile_1 = require("../compileSingleFile");
78
- var compileJobFile = __importStar(require("../internal/compileJobFile"));
79
- var compileServiceFile = __importStar(require("../internal/compileServiceFile"));
78
+ var compileFile = __importStar(require("../internal/compileFile"));
80
79
  var utils_2 = require("../../../utils");
81
80
  var compileCommand_1 = require("../compileCommand");
82
81
  describe('sasjs compile', function () {
@@ -302,7 +301,7 @@ describe('sasjs compile single file', function () {
302
301
  return [4 /*yield*/, (0, config_1.findTargetInConfiguration)('viya')];
303
302
  case 2:
304
303
  target = (_a.sent()).target;
305
- jest.spyOn(compileJobFile, 'compileJobFile');
304
+ jest.spyOn(compileFile, 'compileFile');
306
305
  return [2 /*return*/];
307
306
  }
308
307
  });
@@ -326,7 +325,7 @@ describe('sasjs compile single file', function () {
326
325
  return [4 /*yield*/, expect((0, compileSingleFile_1.compileSingleFile)(target, 'job', command.source, output)).toResolve()];
327
326
  case 2:
328
327
  _a.sent();
329
- expect(compileJobFile.compileJobFile).toHaveBeenCalled();
328
+ expect(compileFile.compileFile).toHaveBeenCalled();
330
329
  return [2 /*return*/];
331
330
  }
332
331
  });
@@ -350,7 +349,7 @@ describe('sasjs compile single file', function () {
350
349
  return [4 /*yield*/, expect((0, compileSingleFile_1.compileSingleFile)(target, 'job', command.source, output)).toResolve()];
351
350
  case 2:
352
351
  _a.sent();
353
- expect(compileJobFile.compileJobFile).toHaveBeenCalled();
352
+ expect(compileFile.compileFile).toHaveBeenCalled();
354
353
  return [2 /*return*/];
355
354
  }
356
355
  });
@@ -368,7 +367,7 @@ describe('sasjs compile single file', function () {
368
367
  return [4 /*yield*/, (0, config_1.findTargetInConfiguration)('viya')];
369
368
  case 2:
370
369
  target = (_a.sent()).target;
371
- jest.spyOn(compileServiceFile, 'compileServiceFile');
370
+ jest.spyOn(compileFile, 'compileFile');
372
371
  return [2 /*return*/];
373
372
  }
374
373
  });
@@ -392,7 +391,7 @@ describe('sasjs compile single file', function () {
392
391
  return [4 /*yield*/, expect((0, compileSingleFile_1.compileSingleFile)(target, 'service', command.source, output)).toResolve()];
393
392
  case 2:
394
393
  _a.sent();
395
- expect(compileServiceFile.compileServiceFile).toHaveBeenCalled();
394
+ expect(compileFile.compileFile).toHaveBeenCalled();
396
395
  return [2 /*return*/];
397
396
  }
398
397
  });
@@ -416,7 +415,24 @@ describe('sasjs compile single file', function () {
416
415
  return [4 /*yield*/, expect((0, compileSingleFile_1.compileSingleFile)(target, 'service', command.source, output)).toResolve()];
417
416
  case 2:
418
417
  _a.sent();
419
- expect(compileServiceFile.compileServiceFile).toHaveBeenCalled();
418
+ expect(compileFile.compileFile).toHaveBeenCalled();
419
+ return [2 /*return*/];
420
+ }
421
+ });
422
+ }); });
423
+ it('should compile service without duplicates', function () { return __awaiter(void 0, void 0, void 0, function () {
424
+ var compiledPath, compiledService;
425
+ return __generator(this, function (_a) {
426
+ switch (_a.label) {
427
+ case 0:
428
+ compiledPath = path_1.default.join(process.projectDir, 'sasjsbuild', 'services', 'admin', 'dostuff.sas');
429
+ return [4 /*yield*/, compileModule.compile(target)];
430
+ case 1:
431
+ _a.sent();
432
+ return [4 /*yield*/, (0, utils_1.readFile)(compiledPath)];
433
+ case 2:
434
+ compiledService = _a.sent();
435
+ expect(compiledService.match(/%macro mv_webout/g).length).toEqual(1);
420
436
  return [2 /*return*/];
421
437
  }
422
438
  });
@@ -63,7 +63,7 @@ var utils_1 = require("@sasjs/utils");
63
63
  var internalModule = __importStar(require("@sasjs/utils/sasjsCli/getInitTerm"));
64
64
  var getInitTerm_1 = require("@sasjs/utils/sasjsCli/getInitTerm");
65
65
  var test_1 = require("../../../utils/test");
66
- var compileServiceFile_1 = require("../internal/compileServiceFile");
66
+ var compileFile_1 = require("../internal/compileFile");
67
67
  var utils_2 = require("@sasjs/utils");
68
68
  var loadDependencies_1 = require("../internal/loadDependencies");
69
69
  var fakeJobInit = "/**\n @file\n @brief This code is inserted into the beginning of each Viya Job.\n @details Inserted during the `sasjs compile` step. Add any code here that\n should go at the beginning of every deployed job.\n\n The path to this file should be listed in the `jobInit` property of the\n sasjsconfig file.\n\n ".concat(utils_1.DependencyHeader.DeprecatedInclude, "\n @li test.sas TEST\n\n ").concat(utils_1.DependencyHeader.Macro, "\n @li examplemacro.sas\n\n**/\n\n%example(Job Init is executing!)\n\n%let mylib=WORK;");
@@ -76,7 +76,7 @@ var fakeProgramLines = [
76
76
  'run;'
77
77
  ];
78
78
  var preCode = '/* provide additional debug info */\n%global _program;\n%put &=syscc;\n%put user=%mf_getuser();\n%put pgm=&_program;\n%put timestamp=%sysfunc(datetime(),datetime19.);\n';
79
- describe('compileServiceFile', function () {
79
+ describe('compileFile', function () {
80
80
  var appName = "cli-tests-compile-service-file-".concat((0, utils_1.generateTimestamp)());
81
81
  var target = (0, test_1.generateTestTarget)(appName, '/Public/app', {
82
82
  serviceFolders: [path_1.default.join('sasjs', 'services')],
@@ -104,39 +104,77 @@ describe('compileServiceFile', function () {
104
104
  }
105
105
  });
106
106
  }); });
107
- test('it should compile and create file', function () { return __awaiter(void 0, void 0, void 0, function () {
108
- var filePath, buildPath, destinationPath, compileTree, compiledContent, macrosToTest;
109
- return __generator(this, function (_a) {
110
- switch (_a.label) {
111
- case 0:
112
- (0, getInitTerm_1.mockGetProgram)(internalModule, fakeJobInit, fakeJobTerm);
113
- filePath = path_1.default.join(__dirname, './service.sas');
114
- buildPath = path_1.default.join(process.projectDir, 'sasjsbuild');
115
- destinationPath = path_1.default.join(buildPath, 'service.sas');
116
- compileTree = (0, loadDependencies_1.getCompileTree)(target);
117
- return [4 /*yield*/, (0, utils_2.createFolder)(buildPath)];
118
- case 1:
119
- _a.sent();
120
- return [4 /*yield*/, (0, utils_2.copy)(filePath, destinationPath)];
121
- case 2:
122
- _a.sent();
123
- return [4 /*yield*/, expect((0, compileServiceFile_1.compileServiceFile)(target, destinationPath, [path_1.default.join(__dirname, './macros')], [path_1.default.join(__dirname, './'), path_1.default.join(__dirname, './services')], undefined, compileTree)).toResolve()];
124
- case 3:
125
- _a.sent();
126
- return [4 /*yield*/, expect((0, utils_2.fileExists)(destinationPath)).resolves.toEqual(true)];
127
- case 4:
128
- _a.sent();
129
- return [4 /*yield*/, (0, utils_2.readFile)(destinationPath)];
130
- case 5:
131
- compiledContent = _a.sent();
132
- macrosToTest = ['mf_abort', 'mf_existds'];
133
- return [4 /*yield*/, (0, test_1.verifyCompiledService)(compiledContent, macrosToTest)];
134
- case 6:
135
- _a.sent();
136
- expect(compiledContent).toEqual(expect.stringContaining(fakeProgramLines.join('\n')));
137
- expect(compiledContent).toEqual(expect.stringContaining(preCode));
138
- return [2 /*return*/];
139
- }
140
- });
141
- }); });
107
+ describe('service', function () {
108
+ test('it should compile and create file', function () { return __awaiter(void 0, void 0, void 0, function () {
109
+ var filePath, buildPath, destinationPath, compileTree, compiledContent, macrosToTest;
110
+ return __generator(this, function (_a) {
111
+ switch (_a.label) {
112
+ case 0:
113
+ (0, getInitTerm_1.mockGetProgram)(internalModule, fakeJobInit, fakeJobTerm);
114
+ filePath = path_1.default.join(__dirname, './service.sas');
115
+ buildPath = path_1.default.join(process.projectDir, 'sasjsbuild');
116
+ destinationPath = path_1.default.join(buildPath, 'service.sas');
117
+ compileTree = (0, loadDependencies_1.getCompileTree)(target);
118
+ return [4 /*yield*/, (0, utils_2.createFolder)(buildPath)];
119
+ case 1:
120
+ _a.sent();
121
+ return [4 /*yield*/, (0, utils_2.copy)(filePath, destinationPath)];
122
+ case 2:
123
+ _a.sent();
124
+ return [4 /*yield*/, expect((0, compileFile_1.compileFile)(target, destinationPath, [path_1.default.join(__dirname, './macros')], [path_1.default.join(__dirname, './'), path_1.default.join(__dirname, './services')], undefined, compileTree, utils_1.SASJsFileType.service, __dirname)).toResolve()];
125
+ case 3:
126
+ _a.sent();
127
+ return [4 /*yield*/, expect((0, utils_2.fileExists)(destinationPath)).resolves.toEqual(true)];
128
+ case 4:
129
+ _a.sent();
130
+ return [4 /*yield*/, (0, utils_2.readFile)(destinationPath)];
131
+ case 5:
132
+ compiledContent = _a.sent();
133
+ macrosToTest = ['mf_abort', 'mf_existds'];
134
+ return [4 /*yield*/, (0, test_1.verifyCompiledService)(compiledContent, macrosToTest)];
135
+ case 6:
136
+ _a.sent();
137
+ expect(compiledContent).toEqual(expect.stringContaining(fakeProgramLines.join('\n')));
138
+ expect(compiledContent).toEqual(expect.stringContaining(preCode));
139
+ return [2 /*return*/];
140
+ }
141
+ });
142
+ }); });
143
+ });
144
+ describe('job', function () {
145
+ test('it should compile and create file', function () { return __awaiter(void 0, void 0, void 0, function () {
146
+ var filePath, buildPath, destinationPath, compileTree, compiledContent, macrosToTest;
147
+ return __generator(this, function (_a) {
148
+ switch (_a.label) {
149
+ case 0:
150
+ (0, getInitTerm_1.mockGetProgram)(internalModule, fakeJobInit, fakeJobTerm);
151
+ filePath = path_1.default.join(__dirname, './service.sas');
152
+ buildPath = path_1.default.join(process.projectDir, 'sasjsbuild');
153
+ destinationPath = path_1.default.join(buildPath, 'service.sas');
154
+ compileTree = (0, loadDependencies_1.getCompileTree)(target);
155
+ return [4 /*yield*/, (0, utils_2.createFolder)(buildPath)];
156
+ case 1:
157
+ _a.sent();
158
+ return [4 /*yield*/, (0, utils_2.copy)(filePath, destinationPath)];
159
+ case 2:
160
+ _a.sent();
161
+ return [4 /*yield*/, expect((0, compileFile_1.compileFile)(target, destinationPath, [path_1.default.join(__dirname, './macros')], [path_1.default.join(__dirname, './'), path_1.default.join(__dirname, './services')], undefined, compileTree, utils_1.SASJsFileType.job, __dirname)).toResolve()];
162
+ case 3:
163
+ _a.sent();
164
+ return [4 /*yield*/, expect((0, utils_2.fileExists)(destinationPath)).resolves.toEqual(true)];
165
+ case 4:
166
+ _a.sent();
167
+ return [4 /*yield*/, (0, utils_2.readFile)(destinationPath)];
168
+ case 5:
169
+ compiledContent = _a.sent();
170
+ macrosToTest = ['mf_abort', 'mf_existds'];
171
+ return [4 /*yield*/, (0, test_1.verifyCompiledJob)(compiledContent, macrosToTest)];
172
+ case 6:
173
+ _a.sent();
174
+ expect(compiledContent).toEqual(expect.stringContaining(fakeProgramLines.join('\n')));
175
+ return [2 /*return*/];
176
+ }
177
+ });
178
+ }); });
179
+ });
142
180
  });
@@ -215,7 +215,11 @@ function deployToSasViya(deployScriptName, target, isLocal, linesToExecute, logF
215
215
  return [4 /*yield*/, getSASjsAndAuthConfig(target, isLocal)];
216
216
  case 1:
217
217
  _f = _g.sent(), sasjs = _f.sasjs, authConfig = _f.authConfig;
218
- return [4 /*yield*/, sasjs.executeScriptSASViya(deployScriptName, linesToExecute, contextName, authConfig)];
218
+ return [4 /*yield*/, sasjs
219
+ .executeScriptSASViya(deployScriptName, linesToExecute, contextName, authConfig)
220
+ .catch(function (err) {
221
+ process.logger.error('executeScriptSASViya Error', err);
222
+ })];
219
223
  case 2:
220
224
  executionResult = _g.sent();
221
225
  try {
@@ -368,7 +372,7 @@ function deployToSasjs(target, sasjs, streamConfig) {
368
372
  .deployToSASjs(payload, undefined, authConfig)
369
373
  .catch(function (err) {
370
374
  var _a;
371
- (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error(err);
375
+ (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('deployToSASjs Error', err);
372
376
  })];
373
377
  case 6:
374
378
  result = _d.sent();
@@ -298,11 +298,12 @@ function printHelpText() {
298
298
  title: 'test',
299
299
  description: [
300
300
  "Triggers SAS unit tests.",
301
- "[2spaces]command example: sasjs test <filteringString> --source <testFlowPath> --outDirectory <folderPath> -t <targetName>",
301
+ "[2spaces]command example: sasjs test <filteringString> --source <testFlowPath> --outDirectory <folderPath> -t <targetName> --force",
302
302
  "",
303
303
  "[2spaces]NOTE: Providing <filteringString> is optional. If not present, all tests mentioned in test flow file will be executed.",
304
304
  "[2spaces]NOTE: Providing source flag is optional. If not present, CLI will use test flow located at sasjsbuild/testFlow.json.",
305
- "[2spaces]NOTE: Providing outDirectory flag is optional. If not present, CLI will use save outputs into sasjsresults folder."
305
+ "[2spaces]NOTE: Providing outDirectory flag is optional. If not present, CLI will use save outputs into sasjsresults folder.",
306
+ "[2spaces]NOTE: Providing force (--force or -f) flag is optional. If present, CLI will force command to finish running all tests and will not return an error code even when some are failing. Useful when the requirement is not to make CI Pipeline fail."
306
307
  ]
307
308
  }
308
309
  ];
@@ -1,5 +1,6 @@
1
1
  import SASjs from '@sasjs/adapter/node';
2
- export declare function executeJobSasjs(sasjs: SASjs, jobPath: string, logFile: string | undefined): Promise<{
2
+ import { AuthConfig } from '@sasjs/utils';
3
+ export declare function executeJobSasjs(sasjs: SASjs, jobPath: string, logFile: string | undefined, authConfig?: AuthConfig): Promise<{
3
4
  status: string;
4
5
  message: string;
5
6
  log?: string | undefined;
@@ -38,14 +38,14 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.executeJobSasjs = void 0;
40
40
  var utils_1 = require("../utils");
41
- function executeJobSasjs(sasjs, jobPath, logFile) {
41
+ function executeJobSasjs(sasjs, jobPath, logFile, authConfig) {
42
42
  return __awaiter(this, void 0, void 0, function () {
43
43
  var result;
44
44
  return __generator(this, function (_a) {
45
45
  switch (_a.label) {
46
46
  case 0: return [4 /*yield*/, sasjs.executeJobSASjs({
47
47
  _program: jobPath
48
- })];
48
+ }, authConfig)];
49
49
  case 1:
50
50
  result = _a.sent();
51
51
  if (!result) return [3 /*break*/, 5];
@@ -6,7 +6,7 @@ export declare class JobCommand extends TargetCommand {
6
6
  private jobSubCommands;
7
7
  constructor(args: string[]);
8
8
  execute(): Promise<ReturnCode>;
9
- executeJobSasjs(sasjs: SASjs, target: Target): Promise<ReturnCode>;
9
+ executeJobSasjs(sasjs: SASjs, target: Target, authConfig: AuthConfig | undefined): Promise<ReturnCode>;
10
10
  executeJobSas9(sasjs: SASjs, target: Target, config: {
11
11
  username: string;
12
12
  password: string;