@sasjs/cli 3.12.0 → 3.12.3

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.
@@ -60,7 +60,7 @@ var addCredential_1 = require("./addCredential");
60
60
  function addTarget(insecure) {
61
61
  var _a, _b, _c;
62
62
  return __awaiter(this, void 0, void 0, function () {
63
- var _d, scope, serverType, name, appLoc, serverUrl, existingTarget, saveWithDefaultValues, targetJson, target, filePath, _e, _f, serverName, repositoryName, userName, password, _g, contextName, updatedViyaTarget, updatedSasjsTarget, isDefault;
63
+ var _d, scope, serverType, name, appLoc, serverUrl, existingTarget, targetJson, target, filePath, _e, _f, serverName, repositoryName, userName, password, _g, contextName, updatedViyaTarget, updatedSasjsTarget, isDefault;
64
64
  return __generator(this, function (_h) {
65
65
  switch (_h.label) {
66
66
  case 0:
@@ -69,10 +69,9 @@ function addTarget(insecure) {
69
69
  return [4 /*yield*/, (0, input_1.getCommonFields)()];
70
70
  case 1:
71
71
  _d = _h.sent(), scope = _d.scope, serverType = _d.serverType, name = _d.name, appLoc = _d.appLoc, serverUrl = _d.serverUrl, existingTarget = _d.existingTarget;
72
- saveWithDefaultValues = !existingTarget;
73
72
  targetJson = __assign(__assign({}, existingTarget), { name: name, serverType: serverType, serverUrl: serverUrl, appLoc: appLoc });
74
73
  target = new types_1.Target(targetJson);
75
- return [4 /*yield*/, (0, saveConfig_1.saveConfig)(scope, target, false, saveWithDefaultValues)];
74
+ return [4 /*yield*/, (0, saveConfig_1.saveConfig)(scope, target, false, false)];
76
75
  case 2:
77
76
  filePath = _h.sent();
78
77
  (_b = process.logger) === null || _b === void 0 ? void 0 : _b.info("Target configuration has been saved to ".concat(filePath, " ."));
@@ -98,11 +97,7 @@ function addTarget(insecure) {
98
97
  case 6:
99
98
  _g = _h.sent(), contextName = _g.contextName, updatedViyaTarget = _g.target;
100
99
  targetJson = {
101
- contextName: contextName,
102
- deployConfig: {
103
- deployServicePack: true,
104
- deployScripts: []
105
- }
100
+ contextName: contextName
106
101
  };
107
102
  targetJson = __assign(__assign({}, updatedViyaTarget.toJson(false)), targetJson);
108
103
  return [3 /*break*/, 10];
@@ -115,7 +110,7 @@ function addTarget(insecure) {
115
110
  case 10: return [4 /*yield*/, (0, input_1.getIsDefault)()];
116
111
  case 11:
117
112
  isDefault = _h.sent();
118
- return [4 /*yield*/, (0, saveConfig_1.saveConfig)(scope, new types_1.Target(targetJson), isDefault, saveWithDefaultValues)];
113
+ return [4 /*yield*/, (0, saveConfig_1.saveConfig)(scope, new types_1.Target(targetJson), isDefault, false)];
119
114
  case 12:
120
115
  filePath = _h.sent();
121
116
  (_c = process.logger) === null || _c === void 0 ? void 0 : _c.info("Target configuration has been saved to ".concat(filePath));
@@ -324,6 +324,7 @@ function recreateBuildFolder() {
324
324
  });
325
325
  });
326
326
  }
327
+ // REFACTOR: combine compileServiceFolder and compileJobFolder
327
328
  var compileServiceFolder = function (target, serviceFolder, macroFolders, programFolders, compileTree) { return __awaiter(void 0, void 0, void 0, function () {
328
329
  var destinationPath, subFolders, filesNamesInPath;
329
330
  return __generator(this, function (_a) {
@@ -333,9 +334,30 @@ var compileServiceFolder = function (target, serviceFolder, macroFolders, progra
333
334
  return [4 /*yield*/, (0, utils_1.listSubFoldersInFolder)(destinationPath)];
334
335
  case 1:
335
336
  subFolders = _a.sent();
336
- return [4 /*yield*/, (0, utils_1.listFilesInFolder)(destinationPath)];
337
+ return [4 /*yield*/, (0, utils_1.listFilesInFolder)(destinationPath)
338
+ // Checks if file in sasjsbuild folder exists in source folder.
339
+ // If not, it means that the file shouldn't be compiled.
340
+ ];
337
341
  case 2:
338
342
  filesNamesInPath = _a.sent();
343
+ // Checks if file in sasjsbuild folder exists in source folder.
344
+ // 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 () {
346
+ return __generator(this, function (_a) {
347
+ switch (_a.label) {
348
+ case 0: return [4 /*yield*/, (0, utils_1.fileExists)(path_1.default.join(serviceFolder, fileName))];
349
+ case 1:
350
+ if (!(_a.sent())) {
351
+ filesNamesInPath.splice(i, 1);
352
+ }
353
+ return [2 /*return*/];
354
+ }
355
+ });
356
+ }); })];
357
+ case 3:
358
+ // Checks if file in sasjsbuild folder exists in source folder.
359
+ // If not, it means that the file shouldn't be compiled.
360
+ _a.sent();
339
361
  return [4 /*yield*/, (0, utils_1.asyncForEach)(filesNamesInPath, function (fileName) { return __awaiter(void 0, void 0, void 0, function () {
340
362
  var filePath;
341
363
  return __generator(this, function (_a) {
@@ -355,7 +377,7 @@ var compileServiceFolder = function (target, serviceFolder, macroFolders, progra
355
377
  }
356
378
  });
357
379
  }); })];
358
- case 3:
380
+ case 4:
359
381
  _a.sent();
360
382
  return [4 /*yield*/, (0, utils_1.asyncForEach)(subFolders, function (subFolder) { return __awaiter(void 0, void 0, void 0, function () {
361
383
  var fileNames;
@@ -389,7 +411,7 @@ var compileServiceFolder = function (target, serviceFolder, macroFolders, progra
389
411
  }
390
412
  });
391
413
  }); })];
392
- case 4:
414
+ case 5:
393
415
  _a.sent();
394
416
  compileTree.saveTree();
395
417
  return [2 /*return*/];
@@ -405,9 +427,30 @@ var compileJobFolder = function (target, jobFolder, macroFolders, programFolders
405
427
  return [4 /*yield*/, (0, utils_1.listSubFoldersInFolder)(destinationPath)];
406
428
  case 1:
407
429
  subFolders = _a.sent();
408
- return [4 /*yield*/, (0, utils_1.listFilesInFolder)(destinationPath)];
430
+ return [4 /*yield*/, (0, utils_1.listFilesInFolder)(destinationPath)
431
+ // Checks if file in sasjsbuild folder exists in source folder.
432
+ // If not, it means that the file shouldn't be compiled.
433
+ ];
409
434
  case 2:
410
435
  filesNamesInPath = _a.sent();
436
+ // Checks if file in sasjsbuild folder exists in source folder.
437
+ // 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 () {
439
+ return __generator(this, function (_a) {
440
+ switch (_a.label) {
441
+ case 0: return [4 /*yield*/, (0, utils_1.fileExists)(path_1.default.join(jobFolder, fileName))];
442
+ case 1:
443
+ if (!(_a.sent())) {
444
+ filesNamesInPath.splice(i, 1);
445
+ }
446
+ return [2 /*return*/];
447
+ }
448
+ });
449
+ }); })];
450
+ case 3:
451
+ // Checks if file in sasjsbuild folder exists in source folder.
452
+ // If not, it means that the file shouldn't be compiled.
453
+ _a.sent();
411
454
  return [4 /*yield*/, (0, utils_1.asyncForEach)(filesNamesInPath, function (fileName) { return __awaiter(void 0, void 0, void 0, function () {
412
455
  var filePath;
413
456
  return __generator(this, function (_a) {
@@ -427,7 +470,7 @@ var compileJobFolder = function (target, jobFolder, macroFolders, programFolders
427
470
  }
428
471
  });
429
472
  }); })];
430
- case 3:
473
+ case 4:
431
474
  _a.sent();
432
475
  return [4 /*yield*/, (0, utils_1.asyncForEach)(subFolders, function (subFolder) { return __awaiter(void 0, void 0, void 0, function () {
433
476
  var fileNames;
@@ -461,7 +504,7 @@ var compileJobFolder = function (target, jobFolder, macroFolders, programFolders
461
504
  }
462
505
  });
463
506
  }); })];
464
- case 4:
507
+ case 5:
465
508
  _a.sent();
466
509
  return [2 /*return*/];
467
510
  }
@@ -739,10 +739,10 @@ describe('sasjs compile outside project', function () {
739
739
  return [4 /*yield*/, (0, config_1.saveGlobalRcFile)('')];
740
740
  case 1:
741
741
  _a.sent();
742
- process.projectDir = '';
743
742
  return [4 /*yield*/, (0, utils_2.setConstants)()];
744
743
  case 2:
745
744
  _a.sent();
745
+ process.projectDir = '';
746
746
  process.currentDir = path_1.default.join(__dirname, appName);
747
747
  return [4 /*yield*/, (0, utils_1.createFolder)(process.currentDir)];
748
748
  case 3:
@@ -785,6 +785,38 @@ describe('sasjs compile outside project', function () {
785
785
  }
786
786
  });
787
787
  }); });
788
+ it('should compile without duplicates', function () { return __awaiter(void 0, void 0, void 0, function () {
789
+ var testServicePath, appPath, command, compiledTestService;
790
+ var _a;
791
+ return __generator(this, function (_b) {
792
+ switch (_b.label) {
793
+ case 0:
794
+ testServicePath = path_1.default.join('services', 'admin', 'test.sas');
795
+ appPath = path_1.default.join(__dirname, appName);
796
+ return [4 /*yield*/, (0, test_1.createTestApp)(__dirname, appName)];
797
+ case 1:
798
+ _b.sent();
799
+ return [4 /*yield*/, (0, utils_1.createFile)(path_1.default.join(appPath, 'sasjs', 'targets', 'viya', testServicePath), '')];
800
+ case 2:
801
+ _b.sent();
802
+ command = new compileCommand_1.CompileCommand([
803
+ 'node',
804
+ 'sasjs',
805
+ 'compile',
806
+ '-t',
807
+ 'viya'
808
+ ]);
809
+ return [4 /*yield*/, command.executeCompile()];
810
+ case 3:
811
+ _b.sent();
812
+ return [4 /*yield*/, (0, utils_1.readFile)(path_1.default.join(appPath, 'sasjsbuild', testServicePath))];
813
+ case 4:
814
+ compiledTestService = _b.sent();
815
+ expect((_a = compiledTestService.match(/^\*\sService start;$/gm)) === null || _a === void 0 ? void 0 : _a.length).toEqual(1);
816
+ return [2 /*return*/];
817
+ }
818
+ });
819
+ }); });
788
820
  });
789
821
  });
790
822
  var prefixConfigWithPath = function (prefixPath) { return ({
package/package.json CHANGED
@@ -47,10 +47,10 @@
47
47
  "access": "public"
48
48
  },
49
49
  "dependencies": {
50
- "@sasjs/adapter": "3.8.0",
50
+ "@sasjs/adapter": "3.8.1",
51
51
  "@sasjs/core": "4.15.3",
52
52
  "@sasjs/lint": "1.11.2",
53
- "@sasjs/utils": "2.40.0",
53
+ "@sasjs/utils": "2.40.1",
54
54
  "chalk": "4.1.2",
55
55
  "csv-stringify": "5.6.5",
56
56
  "dotenv": "10.0.0",
@@ -94,5 +94,5 @@
94
94
  "typescript": "4.5.4",
95
95
  "util": "0.12.4"
96
96
  },
97
- "version": "3.12.0"
97
+ "version": "3.12.3"
98
98
  }