@sasjs/cli 4.0.4 → 4.0.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 (43) hide show
  1. package/build/cli.js +2 -5
  2. package/build/commands/add/spec/addCommand.spec.js +7 -0
  3. package/build/commands/build/build.d.ts +1 -1
  4. package/build/commands/build/build.js +9 -14
  5. package/build/commands/build/internal/config.js +14 -21
  6. package/build/commands/build/spec/buildCommand.spec.js +8 -1
  7. package/build/commands/build/spec/compileBuildCommand.spec.js +8 -1
  8. package/build/commands/compile/compile.js +22 -24
  9. package/build/commands/compile/internal/compileTestFile.d.ts +1 -1
  10. package/build/commands/compile/internal/compileTestFile.js +16 -24
  11. package/build/commands/compile/internal/getAllFolders.d.ts +1 -1
  12. package/build/commands/compile/internal/getAllFolders.js +28 -40
  13. package/build/commands/compile/internal/getServerType.js +6 -12
  14. package/build/commands/compile/internal/loadDependencies.d.ts +1 -1
  15. package/build/commands/compile/internal/loadDependencies.js +6 -7
  16. package/build/commands/compile/internal/spec/getAllFolders.spec.js +1 -1
  17. package/build/commands/compile/spec/compile.spec.js +43 -29
  18. package/build/commands/compile/spec/compileCommand.spec.js +11 -3
  19. package/build/commands/compile/spec/loadDependencies.spec.js +11 -6
  20. package/build/commands/context/spec/contextCommand.spec.js +8 -0
  21. package/build/commands/deploy/internal/getDeployScripts.js +4 -15
  22. package/build/commands/deploy/spec/cbd.spec.js +26 -22
  23. package/build/commands/deploy/spec/compileBuildDeployCommand.spec.js +9 -2
  24. package/build/commands/deploy/spec/deployCommand.spec.js +7 -0
  25. package/build/commands/docs/docsCommand.js +4 -9
  26. package/build/commands/docs/spec/docsCommand.spec.js +4 -0
  27. package/build/commands/flow/spec/flowCommand.spec.js +7 -11
  28. package/build/commands/folder/spec/folderCommand.spec.js +7 -0
  29. package/build/commands/fs/spec/fsCommand.spec.js +19 -22
  30. package/build/commands/job/spec/jobCommand.spec.js +6 -0
  31. package/build/commands/request/spec/requestCommand.spec.js +7 -11
  32. package/build/commands/run/spec/runCommand.spec.js +7 -11
  33. package/build/commands/servicepack/spec/servicepackCommand.spec.js +7 -11
  34. package/build/commands/testing/spec/testCommand.spec.js +7 -11
  35. package/build/commands/web/spec/web.spec.js +12 -7
  36. package/build/commands/web/spec/webCommand.spec.js +8 -1
  37. package/build/types/command/targetCommand.js +25 -5
  38. package/build/utils/config.js +60 -74
  39. package/build/utils/setConstants.d.ts +2 -3
  40. package/build/utils/setConstants.js +55 -77
  41. package/build/utils/spec/setConstants.spec.js +1 -1
  42. package/build/utils/test.js +32 -17
  43. package/package.json +1 -1
@@ -469,6 +469,7 @@ describe('sasjs compile outside project', function () {
469
469
  });
470
470
  }); });
471
471
  beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () {
472
+ var configuration;
472
473
  return __generator(this, function (_a) {
473
474
  switch (_a.label) {
474
475
  case 0:
@@ -482,12 +483,16 @@ describe('sasjs compile outside project', function () {
482
483
  case 1:
483
484
  _a.sent();
484
485
  process.projectDir = '';
485
- return [4 /*yield*/, (0, utils_2.setConstants)()];
486
+ return [4 /*yield*/, (0, config_1.getGlobalRcFile)()];
486
487
  case 2:
488
+ configuration = _a.sent();
489
+ return [4 /*yield*/, (0, utils_2.setConstants)(false, undefined, configuration)];
490
+ case 3:
487
491
  _a.sent();
492
+ process.sasjsConfig = configuration;
488
493
  process.currentDir = path_1.default.join(__dirname, appName);
489
494
  return [4 /*yield*/, (0, utils_1.createFolder)(process.currentDir)];
490
- case 3:
495
+ case 4:
491
496
  _a.sent();
492
497
  return [2 /*return*/];
493
498
  }
@@ -541,19 +546,17 @@ describe('sasjs compile outside project', function () {
541
546
  '-s',
542
547
  '../services/example1.sas'
543
548
  ]);
544
- return [4 /*yield*/, command.output];
545
- case 1:
546
- output = _a.sent();
549
+ output = command.output;
547
550
  return [4 /*yield*/, expect((0, compileSingleFile_1.compileSingleFile)(undefined, 'service', command.source, output)).resolves.toEqual({
548
551
  destinationPath: destinationPath
549
552
  })];
550
- case 2:
553
+ case 1:
551
554
  _a.sent();
552
555
  return [4 /*yield*/, expect((0, utils_1.fileExists)(destinationPath)).resolves.toEqual(true)];
553
- case 3:
556
+ case 2:
554
557
  _a.sent();
555
558
  return [4 /*yield*/, (0, utils_1.readFile)(destinationPath)];
556
- case 4:
559
+ case 3:
557
560
  compiledContent = _a.sent();
558
561
  macrosToTest = [
559
562
  'mf_nobs',
@@ -561,7 +564,7 @@ describe('sasjs compile outside project', function () {
561
564
  'yetanothermacro'
562
565
  ];
563
566
  return [4 /*yield*/, (0, test_1.verifyCompiledService)(compiledContent, macrosToTest, false, false)];
564
- case 5:
567
+ case 4:
565
568
  _a.sent();
566
569
  return [2 /*return*/];
567
570
  }
@@ -619,7 +622,7 @@ describe('sasjs compile outside project', function () {
619
622
  });
620
623
  }); });
621
624
  it('should fail to compile single file', function () { return __awaiter(void 0, void 0, void 0, function () {
622
- var buildOutputFolder, dependencies, command, output;
625
+ var buildOutputFolder, dependencies, configuration, command, output;
623
626
  return __generator(this, function (_a) {
624
627
  switch (_a.label) {
625
628
  case 0:
@@ -631,6 +634,10 @@ describe('sasjs compile outside project', function () {
631
634
  }, false)];
632
635
  case 1:
633
636
  _a.sent();
637
+ return [4 /*yield*/, (0, config_1.getGlobalRcFile)()];
638
+ case 2:
639
+ configuration = _a.sent();
640
+ process.sasjsConfig = configuration;
634
641
  command = new compileCommand_1.CompileCommand([
635
642
  'node',
636
643
  'sasjs',
@@ -640,17 +647,17 @@ describe('sasjs compile outside project', function () {
640
647
  '../services/example1.sas'
641
648
  ]);
642
649
  return [4 /*yield*/, command.output];
643
- case 2:
650
+ case 3:
644
651
  output = _a.sent();
645
652
  return [4 /*yield*/, expect((0, compileSingleFile_1.compileSingleFile)(undefined, 'service', command.source, output)).rejects.toEqual("Unable to locate dependencies: ".concat(dependencies.join(', ')))];
646
- case 3:
653
+ case 4:
647
654
  _a.sent();
648
655
  return [2 /*return*/];
649
656
  }
650
657
  });
651
658
  }); });
652
- it('should compile single file at absolute path in global config.buildConfig.buildOutputFolder', function () { return __awaiter(void 0, void 0, void 0, function () {
653
- var buildOutputFolder, destinationPath, command, output, compiledContent, macrosToTest;
659
+ it('should compile single file at absolute path in global config.sasjsBuildFolder', function () { return __awaiter(void 0, void 0, void 0, function () {
660
+ var buildOutputFolder, destinationPath, configuration, command, output, compiledContent, macrosToTest;
654
661
  return __generator(this, function (_a) {
655
662
  switch (_a.label) {
656
663
  case 0:
@@ -663,8 +670,11 @@ describe('sasjs compile outside project', function () {
663
670
  }, false)];
664
671
  case 1:
665
672
  _a.sent();
666
- return [4 /*yield*/, (0, utils_2.setConstants)()];
673
+ return [4 /*yield*/, (0, config_1.getGlobalRcFile)()];
667
674
  case 2:
675
+ configuration = _a.sent();
676
+ return [4 /*yield*/, (0, utils_2.setConstants)(false, undefined, configuration)];
677
+ case 3:
668
678
  _a.sent();
669
679
  command = new compileCommand_1.CompileCommand([
670
680
  'node',
@@ -675,18 +685,18 @@ describe('sasjs compile outside project', function () {
675
685
  '../services/example1.sas'
676
686
  ]);
677
687
  return [4 /*yield*/, command.output];
678
- case 3:
688
+ case 4:
679
689
  output = _a.sent();
680
690
  return [4 /*yield*/, expect((0, compileSingleFile_1.compileSingleFile)(undefined, 'service', command.source, output)).resolves.toEqual({
681
691
  destinationPath: destinationPath
682
692
  })];
683
- case 4:
693
+ case 5:
684
694
  _a.sent();
685
695
  return [4 /*yield*/, expect((0, utils_1.fileExists)(destinationPath)).resolves.toEqual(true)];
686
- case 5:
696
+ case 6:
687
697
  _a.sent();
688
698
  return [4 /*yield*/, (0, utils_1.readFile)(destinationPath)];
689
- case 6:
699
+ case 7:
690
700
  compiledContent = _a.sent();
691
701
  macrosToTest = [
692
702
  'mf_nobs',
@@ -694,14 +704,14 @@ describe('sasjs compile outside project', function () {
694
704
  'yetanothermacro'
695
705
  ];
696
706
  return [4 /*yield*/, (0, test_1.verifyCompiledService)(compiledContent, macrosToTest, false, false)];
697
- case 7:
707
+ case 8:
698
708
  _a.sent();
699
709
  return [2 /*return*/];
700
710
  }
701
711
  });
702
712
  }); });
703
- it('should compile single file at relative path in global config.buildConfig.buildOutputFolder', function () { return __awaiter(void 0, void 0, void 0, function () {
704
- var buildOutputFolder, destinationPath, command, output, compiledContent, macrosToTest;
713
+ it('should compile single file at relative path in global config.sasjsBuildFolder', function () { return __awaiter(void 0, void 0, void 0, function () {
714
+ var buildOutputFolder, destinationPath, configuration, command, output, compiledContent, macrosToTest;
705
715
  return __generator(this, function (_a) {
706
716
  switch (_a.label) {
707
717
  case 0:
@@ -714,8 +724,11 @@ describe('sasjs compile outside project', function () {
714
724
  }, false)];
715
725
  case 1:
716
726
  _a.sent();
717
- return [4 /*yield*/, (0, utils_2.setConstants)()];
727
+ return [4 /*yield*/, (0, config_1.getGlobalRcFile)()];
718
728
  case 2:
729
+ configuration = _a.sent();
730
+ return [4 /*yield*/, (0, utils_2.setConstants)(false, undefined, configuration)];
731
+ case 3:
719
732
  _a.sent();
720
733
  command = new compileCommand_1.CompileCommand([
721
734
  'node',
@@ -726,18 +739,18 @@ describe('sasjs compile outside project', function () {
726
739
  '../services/example1.sas'
727
740
  ]);
728
741
  return [4 /*yield*/, command.output];
729
- case 3:
742
+ case 4:
730
743
  output = _a.sent();
731
744
  return [4 /*yield*/, expect((0, compileSingleFile_1.compileSingleFile)(undefined, 'service', command.source, output)).resolves.toEqual({
732
745
  destinationPath: destinationPath
733
746
  })];
734
- case 4:
747
+ case 5:
735
748
  _a.sent();
736
749
  return [4 /*yield*/, expect((0, utils_1.fileExists)(destinationPath)).resolves.toEqual(true)];
737
- case 5:
750
+ case 6:
738
751
  _a.sent();
739
752
  return [4 /*yield*/, (0, utils_1.readFile)(destinationPath)];
740
- case 6:
753
+ case 7:
741
754
  compiledContent = _a.sent();
742
755
  macrosToTest = [
743
756
  'mf_nobs',
@@ -745,7 +758,7 @@ describe('sasjs compile outside project', function () {
745
758
  'yetanothermacro'
746
759
  ];
747
760
  return [4 /*yield*/, (0, test_1.verifyCompiledService)(compiledContent, macrosToTest, false, false)];
748
- case 7:
761
+ case 8:
749
762
  _a.sent();
750
763
  return [2 /*return*/];
751
764
  }
@@ -761,9 +774,10 @@ describe('sasjs compile outside project', function () {
761
774
  return [4 /*yield*/, (0, config_1.saveGlobalRcFile)('')];
762
775
  case 1:
763
776
  _a.sent();
764
- return [4 /*yield*/, (0, utils_2.setConstants)()];
777
+ return [4 /*yield*/, (0, utils_2.setConstants)(false)];
765
778
  case 2:
766
779
  _a.sent();
780
+ process.sasjsConfig = {};
767
781
  process.projectDir = '';
768
782
  process.currentDir = path_1.default.join(__dirname, appName);
769
783
  return [4 /*yield*/, (0, utils_1.createFolder)(process.currentDir)];
@@ -93,9 +93,10 @@ var compileModule = __importStar(require("../compile"));
93
93
  var compileSingleFileModule = __importStar(require("../compileSingleFile"));
94
94
  var compileCommand_1 = require("../compileCommand");
95
95
  var utils_1 = require("@sasjs/utils");
96
+ var utils_2 = require("../../../utils");
96
97
  var configUtils = __importStar(require("../../../utils/config"));
98
+ var setConstantsUtils = __importStar(require("../../../utils/setConstants"));
97
99
  var command_1 = require("../../../types/command");
98
- var utils_2 = require("../../../utils");
99
100
  var target = new utils_1.Target({
100
101
  name: 'test',
101
102
  appLoc: '/Public/test/',
@@ -107,7 +108,7 @@ describe('CompileCommand', function () {
107
108
  beforeAll(function () { return __awaiter(void 0, void 0, void 0, function () {
108
109
  return __generator(this, function (_a) {
109
110
  switch (_a.label) {
110
- case 0: return [4 /*yield*/, (0, utils_2.setConstants)()];
111
+ case 0: return [4 /*yield*/, (0, utils_2.setConstants)(false)];
111
112
  case 1:
112
113
  _a.sent();
113
114
  return [2 /*return*/];
@@ -229,7 +230,7 @@ describe('CompileCommand', function () {
229
230
  beforeAll(function () { return __awaiter(void 0, void 0, void 0, function () {
230
231
  return __generator(this, function (_a) {
231
232
  switch (_a.label) {
232
- case 0: return [4 /*yield*/, (0, utils_2.setConstants)()];
233
+ case 0: return [4 /*yield*/, (0, utils_2.setConstants)(false)];
233
234
  case 1:
234
235
  _a.sent();
235
236
  return [2 /*return*/];
@@ -441,12 +442,19 @@ var setupMocks = function () {
441
442
  jest.mock('../compile');
442
443
  jest.mock('../compileSingleFile');
443
444
  jest.mock('../../../utils/config');
445
+ jest.mock('../../../utils/setConstants');
444
446
  jest
445
447
  .spyOn(compileModule, 'compile')
446
448
  .mockImplementation(function () { return Promise.resolve(); });
447
449
  jest
448
450
  .spyOn(configUtils, 'findTargetInConfiguration')
449
451
  .mockImplementation(function () { return Promise.resolve({ target: target, isLocal: true }); });
452
+ jest
453
+ .spyOn(configUtils, 'getLocalConfig')
454
+ .mockImplementation(function () { return Promise.resolve({}); });
455
+ jest
456
+ .spyOn(setConstantsUtils, 'setConstants')
457
+ .mockImplementation(function () { return Promise.resolve(); });
450
458
  process.logger = new utils_1.Logger(utils_1.LogLevel.Off);
451
459
  jest.spyOn(process.logger, 'success');
452
460
  jest.spyOn(process.logger, 'error');
@@ -140,21 +140,26 @@ describe('loadDependencies', function () {
140
140
  var target = new utils_1.Target(__assign(__assign({}, temp.toJson()), { jobConfig: jobConfig(false), serviceConfig: serviceConfig(false) }));
141
141
  var compileTree;
142
142
  beforeAll(function () { return __awaiter(void 0, void 0, void 0, function () {
143
- return __generator(this, function (_a) {
144
- switch (_a.label) {
145
- case 0: return [4 /*yield*/, (0, utils_2.setConstants)()];
143
+ var _a;
144
+ return __generator(this, function (_b) {
145
+ switch (_b.label) {
146
+ case 0: return [4 /*yield*/, (0, utils_2.setConstants)(false)];
146
147
  case 1:
147
- _a.sent();
148
+ _b.sent();
148
149
  compileTree = (0, loadDependencies_1.getCompileTree)(target);
149
150
  return [4 /*yield*/, (0, test_1.createTestMinimalApp)(__dirname, target.name)];
150
151
  case 2:
151
- _a.sent();
152
+ _b.sent();
152
153
  return [4 /*yield*/, (0, test_1.updateConfig)({
153
154
  jobConfig: jobConfig(),
154
155
  serviceConfig: serviceConfig()
155
156
  })];
156
157
  case 3:
157
- _a.sent();
158
+ _b.sent();
159
+ _a = process;
160
+ return [4 /*yield*/, (0, utils_2.getLocalConfig)()];
161
+ case 4:
162
+ _a.sasjsConfig = _b.sent();
158
163
  return [2 /*return*/];
159
164
  }
160
165
  });
@@ -93,6 +93,7 @@ var contextCommand_1 = require("../contextCommand");
93
93
  var utils_1 = require("@sasjs/utils");
94
94
  var fileModule = __importStar(require("@sasjs/utils/file"));
95
95
  var configUtils = __importStar(require("../../../utils/config"));
96
+ var setConstantsUtils = __importStar(require("../../../utils/setConstants"));
96
97
  var command_1 = require("../../../types/command");
97
98
  var mocks_1 = require("./mocks");
98
99
  var defaultArgs = ['node', 'sasjs'];
@@ -964,6 +965,7 @@ var setupMocks = function () {
964
965
  jest.mock('../export');
965
966
  jest.mock('../list');
966
967
  jest.mock('../../../utils/config');
968
+ jest.mock('../../../utils/setConstants');
967
969
  jest
968
970
  .spyOn(fileModule, 'readFile')
969
971
  .mockImplementation(function () { return Promise.resolve(JSON.stringify(mocks_1.mockContext)); });
@@ -982,9 +984,15 @@ var setupMocks = function () {
982
984
  jest
983
985
  .spyOn(configUtils, 'findTargetInConfiguration')
984
986
  .mockImplementation(function () { return Promise.resolve({ target: target, isLocal: true }); });
987
+ jest
988
+ .spyOn(configUtils, 'getLocalConfig')
989
+ .mockImplementation(function () { return Promise.resolve({}); });
985
990
  jest
986
991
  .spyOn(configUtils, 'getAuthConfig')
987
992
  .mockImplementation(function () { return Promise.resolve(mocks_1.mockAuthConfig); });
993
+ jest
994
+ .spyOn(setConstantsUtils, 'setConstants')
995
+ .mockImplementation(function () { return Promise.resolve(); });
988
996
  process.logger = new utils_1.Logger(utils_1.LogLevel.Off);
989
997
  jest.spyOn(process.logger, 'success');
990
998
  jest.spyOn(process.logger, 'error');
@@ -60,27 +60,16 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
60
60
  }
61
61
  return to.concat(ar || Array.prototype.slice.call(from));
62
62
  };
63
- var __importDefault = (this && this.__importDefault) || function (mod) {
64
- return (mod && mod.__esModule) ? mod : { "default": mod };
65
- };
66
63
  Object.defineProperty(exports, "__esModule", { value: true });
67
64
  exports.getDeployScripts = void 0;
68
- var path_1 = __importDefault(require("path"));
69
- var config_1 = require("../../../utils/config");
70
65
  function getDeployScripts(target) {
71
66
  var _a, _b;
72
67
  return __awaiter(this, void 0, void 0, function () {
73
- var buildSourceFolder, configuration, allDeployScripts;
68
+ var configuration, allDeployScripts;
74
69
  return __generator(this, function (_c) {
75
- switch (_c.label) {
76
- case 0:
77
- buildSourceFolder = process.sasjsConstants.buildSourceFolder;
78
- return [4 /*yield*/, (0, config_1.getConfiguration)(path_1.default.join(buildSourceFolder, 'sasjs', 'sasjsconfig.json'))];
79
- case 1:
80
- configuration = _c.sent();
81
- allDeployScripts = __spreadArray(__spreadArray([], __read((((_a = configuration === null || configuration === void 0 ? void 0 : configuration.deployConfig) === null || _a === void 0 ? void 0 : _a.deployScripts) || [])), false), __read((((_b = target.deployConfig) === null || _b === void 0 ? void 0 : _b.deployScripts) || [])), false);
82
- return [2 /*return*/, __spreadArray([], __read(new Set(allDeployScripts.filter(function (d) { return !!d; }))), false)];
83
- }
70
+ configuration = process.sasjsConfig;
71
+ allDeployScripts = __spreadArray(__spreadArray([], __read((((_a = configuration === null || configuration === void 0 ? void 0 : configuration.deployConfig) === null || _a === void 0 ? void 0 : _a.deployScripts) || [])), false), __read((((_b = target.deployConfig) === null || _b === void 0 ? void 0 : _b.deployScripts) || [])), false);
72
+ return [2 /*return*/, __spreadArray([], __read(new Set(allDeployScripts.filter(function (d) { return !!d; }))), false)];
84
73
  });
85
74
  });
86
75
  }
@@ -104,9 +104,9 @@ describe('sasjs cbd with server type SASJS', function () {
104
104
  });
105
105
  }); });
106
106
  it("should deploy compile and build to sasjs/server", function () { return __awaiter(void 0, void 0, void 0, function () {
107
- var deployMock, customTarget, macroCorePath, mf_getuser, _a, mp_jsonout, ms_webout, webout, mocksPath, appinitJSPath, getdataJSPath, appinitJSContents, getdataJSContents, depsInserts, appinit, getdata, getCode;
108
- return __generator(this, function (_b) {
109
- switch (_b.label) {
107
+ var deployMock, _a, customTarget, macroCorePath, mf_getuser, _b, mp_jsonout, ms_webout, webout, mocksPath, appinitJSPath, getdataJSPath, appinitJSContents, getdataJSContents, depsInserts, appinit, getdata, getCode;
108
+ return __generator(this, function (_c) {
109
+ switch (_c.label) {
110
110
  case 0:
111
111
  jest.spyOn(fileModule, 'fileExists').mockImplementation(function (filePath) {
112
112
  if (filePath.endsWith('.zip'))
@@ -130,7 +130,7 @@ describe('sasjs cbd with server type SASJS', function () {
130
130
  }
131
131
  })];
132
132
  case 1:
133
- _b.sent();
133
+ _c.sent();
134
134
  return [4 /*yield*/, (0, utils_2.updateLocalTarget)(target.name, {
135
135
  jobConfig: undefined,
136
136
  serviceConfig: undefined,
@@ -140,37 +140,41 @@ describe('sasjs cbd with server type SASJS', function () {
140
140
  }
141
141
  })];
142
142
  case 2:
143
- _b.sent();
144
- return [4 /*yield*/, (0, config_1.findTargetInConfiguration)(target.name, types_1.TargetScope.Local)];
143
+ _c.sent();
144
+ _a = process;
145
+ return [4 /*yield*/, (0, config_1.getLocalConfig)()];
145
146
  case 3:
146
- customTarget = (_b.sent()).target;
147
- return [4 /*yield*/, expect((0, build_1.build)(customTarget)).toResolve()];
147
+ _a.sasjsConfig = _c.sent();
148
+ return [4 /*yield*/, (0, config_1.findTargetInConfiguration)(target.name, types_1.TargetScope.Local)];
148
149
  case 4:
149
- _b.sent();
150
- return [4 /*yield*/, (0, deploy_1.deploy)(customTarget, true)];
150
+ customTarget = (_c.sent()).target;
151
+ return [4 /*yield*/, expect((0, build_1.build)(customTarget)).toResolve()];
151
152
  case 5:
152
- _b.sent();
153
+ _c.sent();
154
+ return [4 /*yield*/, (0, deploy_1.deploy)(customTarget, true)];
155
+ case 6:
156
+ _c.sent();
153
157
  macroCorePath = process.sasjsConstants.macroCorePath;
154
- _a = utils_1.removeHeader;
158
+ _b = utils_1.removeHeader;
155
159
  return [4 /*yield*/, (0, utils_1.readFile)("".concat(macroCorePath, "/base/mf_getuser.sas"))];
156
- case 6:
157
- mf_getuser = _a.apply(void 0, [_b.sent()]);
158
- return [4 /*yield*/, (0, utils_1.readFile)("".concat(macroCorePath, "/base/mp_jsonout.sas"))];
159
160
  case 7:
160
- mp_jsonout = _b.sent();
161
- return [4 /*yield*/, (0, utils_1.readFile)("".concat(macroCorePath, "/server/ms_webout.sas"))];
161
+ mf_getuser = _b.apply(void 0, [_c.sent()]);
162
+ return [4 /*yield*/, (0, utils_1.readFile)("".concat(macroCorePath, "/base/mp_jsonout.sas"))];
162
163
  case 8:
163
- ms_webout = _b.sent();
164
+ mp_jsonout = _c.sent();
165
+ return [4 /*yield*/, (0, utils_1.readFile)("".concat(macroCorePath, "/server/ms_webout.sas"))];
166
+ case 9:
167
+ ms_webout = _c.sent();
164
168
  webout = "%macro webout(action,ds,dslabel=,fmt=,missing=NULL,showmeta=NO,maxobs=MAX);\n %ms_webout(&action,ds=&ds,dslabel=&dslabel,fmt=&fmt\n ,missing=&missing\n ,showmeta=&showmeta\n ,maxobs=&maxobs\n ) %mend;\n";
165
169
  mocksPath = path_1.default.join(__dirname, appName, 'sasjs', 'mocks');
166
170
  appinitJSPath = path_1.default.join(mocksPath, 'services', 'common', 'appinit.js');
167
171
  getdataJSPath = path_1.default.join(mocksPath, 'services', 'common', 'getdata.js');
168
172
  return [4 /*yield*/, (0, utils_1.readFile)(appinitJSPath)];
169
- case 9:
170
- appinitJSContents = _b.sent();
171
- return [4 /*yield*/, (0, utils_1.readFile)(getdataJSPath)];
172
173
  case 10:
173
- getdataJSContents = _b.sent();
174
+ appinitJSContents = _c.sent();
175
+ return [4 /*yield*/, (0, utils_1.readFile)(getdataJSPath)];
176
+ case 11:
177
+ getdataJSContents = _c.sent();
174
178
  depsInserts = "\n\n* Service Variables start;\n\n\n* Service Variables end;\n* SAS Macros start;\n\n\n\n* SAS Macros end;\n* SAS Includes start;\n\n* SAS Includes end;\n* Binary Files start;\n\n* Binary Files end;\n\n \n* Service start;\n";
175
179
  appinit = "/**\n @file appinit.sas\n @brief Initialisation service - runs on app startup\n @details This is always the first service called when the app is opened.\n\n <h4> SAS Macros </h4>\n\n**/\n\nproc sql;\ncreate table areas as select distinct area\n from mydb.springs;\n\n%webout(OPEN)\n%webout(OBJ,areas)\n%webout(CLOSE)\n\n";
176
180
  getdata = "/**\n @file getdata.sas\n @brief Get Data service - runs on app startup\n @details This is always the first service called when the app is opened.\n\n <h4> SAS Macros </h4>\n\n**/\n\n%webout(FETCH)\n\nproc sql;\ncreate table springs as select * from mydb.springs\n where area in (select area from work.areas);\n\n%webout(OPEN)\n%webout(OBJ,springs)\n%webout(CLOSE)\n\n";
@@ -90,8 +90,9 @@ var deployModule = __importStar(require("../deploy"));
90
90
  var compileBuildDeployCommand_1 = require("../compileBuildDeployCommand");
91
91
  var utils_1 = require("@sasjs/utils");
92
92
  var configUtils = __importStar(require("../../../utils/config"));
93
- var command_1 = require("../../../types/command");
93
+ var setConstantsUtils = __importStar(require("../../../utils/setConstants"));
94
94
  var utils_2 = require("../../../utils");
95
+ var command_1 = require("../../../types/command");
95
96
  describe('CompileBuildDeployCommand', function () {
96
97
  var defaultArgs = ['node', 'sasjs'];
97
98
  var target = new utils_1.Target({
@@ -103,7 +104,7 @@ describe('CompileBuildDeployCommand', function () {
103
104
  beforeAll(function () { return __awaiter(void 0, void 0, void 0, function () {
104
105
  return __generator(this, function (_a) {
105
106
  switch (_a.label) {
106
- case 0: return [4 /*yield*/, (0, utils_2.setConstants)()];
107
+ case 0: return [4 /*yield*/, (0, utils_2.setConstants)(false)];
107
108
  case 1:
108
109
  _a.sent();
109
110
  return [2 /*return*/];
@@ -126,6 +127,12 @@ describe('CompileBuildDeployCommand', function () {
126
127
  jest
127
128
  .spyOn(configUtils, 'findTargetInConfiguration')
128
129
  .mockImplementation(function () { return Promise.resolve({ target: target, isLocal: true }); });
130
+ jest
131
+ .spyOn(configUtils, 'getLocalConfig')
132
+ .mockImplementation(function () { return Promise.resolve({}); });
133
+ jest
134
+ .spyOn(setConstantsUtils, 'setConstants')
135
+ .mockImplementation(function () { return Promise.resolve(); });
129
136
  process.logger = new utils_1.Logger(utils_1.LogLevel.Off);
130
137
  jest.spyOn(process.logger, 'success');
131
138
  jest.spyOn(process.logger, 'error');
@@ -88,6 +88,7 @@ var deployModule = __importStar(require("../deploy"));
88
88
  var deployCommand_1 = require("../deployCommand");
89
89
  var utils_1 = require("@sasjs/utils");
90
90
  var configUtils = __importStar(require("../../../utils/config"));
91
+ var setConstantsUtils = __importStar(require("../../../utils/setConstants"));
91
92
  var command_1 = require("../../../types/command");
92
93
  var defaultArgs = ['node', 'sasjs'];
93
94
  var target = new utils_1.Target({
@@ -183,6 +184,12 @@ var setupMocks = function () {
183
184
  jest
184
185
  .spyOn(configUtils, 'findTargetInConfiguration')
185
186
  .mockImplementation(function () { return Promise.resolve({ target: target, isLocal: true }); });
187
+ jest
188
+ .spyOn(configUtils, 'getLocalConfig')
189
+ .mockImplementation(function () { return Promise.resolve({}); });
190
+ jest
191
+ .spyOn(setConstantsUtils, 'setConstants')
192
+ .mockImplementation(function () { return Promise.resolve(); });
186
193
  process.logger = new utils_1.Logger(utils_1.LogLevel.Off);
187
194
  jest.spyOn(process.logger, 'success');
188
195
  jest.spyOn(process.logger, 'error');
@@ -55,7 +55,6 @@ exports.DocsCommand = void 0;
55
55
  var __1 = require("..");
56
56
  var command_1 = require("../../types/command");
57
57
  var targetCommand_1 = require("../../types/command/targetCommand");
58
- var utils_1 = require("../../utils");
59
58
  var DocSubCommand;
60
59
  (function (DocSubCommand) {
61
60
  DocSubCommand["Init"] = "init";
@@ -137,9 +136,7 @@ var DocsCommand = /** @class */ (function (_super) {
137
136
  case 0: return [4 /*yield*/, this.getTargetInfo()];
138
137
  case 1:
139
138
  target = (_a.sent()).target;
140
- return [4 /*yield*/, (0, utils_1.getLocalConfig)()];
141
- case 2:
142
- config = _a.sent();
139
+ config = process.sasjsConfig;
143
140
  return [4 /*yield*/, (0, __1.generateDocs)(target, config, this.parsed.outDirectory)
144
141
  .then(function (res) {
145
142
  var _a;
@@ -151,7 +148,7 @@ var DocsCommand = /** @class */ (function (_super) {
151
148
  (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('Error generating docs: ', err);
152
149
  return command_1.ReturnCode.InternalError;
153
150
  })];
154
- case 3:
151
+ case 2:
155
152
  returnCode = _a.sent();
156
153
  return [2 /*return*/, returnCode];
157
154
  }
@@ -166,9 +163,7 @@ var DocsCommand = /** @class */ (function (_super) {
166
163
  case 0: return [4 /*yield*/, this.getTargetInfo()];
167
164
  case 1:
168
165
  target = (_a.sent()).target;
169
- return [4 /*yield*/, (0, utils_1.getLocalConfig)()];
170
- case 2:
171
- config = _a.sent();
166
+ config = process.sasjsConfig;
172
167
  return [4 /*yield*/, (0, __1.generateDot)(target, config, this.parsed.outDirectory)
173
168
  .then(function (res) {
174
169
  var _a;
@@ -180,7 +175,7 @@ var DocsCommand = /** @class */ (function (_super) {
180
175
  (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('Error generating docs: ', err);
181
176
  return command_1.ReturnCode.InternalError;
182
177
  })];
183
- case 3:
178
+ case 2:
184
179
  returnCode = _a.sent();
185
180
  return [2 /*return*/, returnCode];
186
181
  }
@@ -90,6 +90,7 @@ var generateDotModule = __importStar(require("../generateDot"));
90
90
  var initDocsModule = __importStar(require("../initDocs"));
91
91
  var command_1 = require("../../../types/command");
92
92
  var configUtils = __importStar(require("../../../utils/config"));
93
+ var setConstantsUtils = __importStar(require("../../../utils/setConstants"));
93
94
  var logger_1 = require("@sasjs/utils/logger");
94
95
  var utils_1 = require("@sasjs/utils");
95
96
  var target = new utils_1.Target({
@@ -361,4 +362,7 @@ var setupMocks = function () {
361
362
  jest
362
363
  .spyOn(configUtils, 'getLocalConfig')
363
364
  .mockImplementation(function () { return Promise.resolve(config); });
365
+ jest
366
+ .spyOn(setConstantsUtils, 'setConstants')
367
+ .mockImplementation(function () { return Promise.resolve(); });
364
368
  };
@@ -88,8 +88,8 @@ var executeModule = __importStar(require("../execute"));
88
88
  var flowCommand_1 = require("../flowCommand");
89
89
  var utils_1 = require("@sasjs/utils");
90
90
  var configUtils = __importStar(require("../../../utils/config"));
91
+ var setConstantsUtils = __importStar(require("../../../utils/setConstants"));
91
92
  var command_1 = require("../../../types/command");
92
- var utils_2 = require("../../../utils");
93
93
  var defaultArgs = ['node', 'sasjs'];
94
94
  var target = new utils_1.Target({
95
95
  name: 'test',
@@ -102,16 +102,6 @@ var source = 'path/to/json';
102
102
  var logFolder = 'path/to/logs/folder';
103
103
  var csvFile = 'path/to/csv/file';
104
104
  describe('FlowCommand', function () {
105
- beforeAll(function () { return __awaiter(void 0, void 0, void 0, function () {
106
- return __generator(this, function (_a) {
107
- switch (_a.label) {
108
- case 0: return [4 /*yield*/, (0, utils_2.setConstants)()];
109
- case 1:
110
- _a.sent();
111
- return [2 /*return*/];
112
- }
113
- });
114
- }); });
115
105
  beforeEach(function () {
116
106
  setupMocks();
117
107
  });
@@ -250,6 +240,12 @@ var setupMocks = function () {
250
240
  jest
251
241
  .spyOn(configUtils, 'findTargetInConfiguration')
252
242
  .mockImplementation(function () { return Promise.resolve({ target: target, isLocal: true }); });
243
+ jest
244
+ .spyOn(configUtils, 'getLocalConfig')
245
+ .mockImplementation(function () { return Promise.resolve({}); });
246
+ jest
247
+ .spyOn(setConstantsUtils, 'setConstants')
248
+ .mockImplementation(function () { return Promise.resolve(); });
253
249
  jest
254
250
  .spyOn(configUtils, 'getAuthConfig')
255
251
  .mockImplementation(function () { return Promise.resolve(authConfig); });
@@ -90,6 +90,7 @@ var deleteModule = __importStar(require("../delete"));
90
90
  var listModule = __importStar(require("../list"));
91
91
  var command_1 = require("../../../types/command");
92
92
  var configUtils = __importStar(require("../../../utils/config"));
93
+ var setConstantsUtils = __importStar(require("../../../utils/setConstants"));
93
94
  var logger_1 = require("@sasjs/utils/logger");
94
95
  var utils_1 = require("@sasjs/utils");
95
96
  var mocks_1 = require("./mocks");
@@ -345,7 +346,13 @@ var setupMocks = function () {
345
346
  jest
346
347
  .spyOn(configUtils, 'findTargetInConfiguration')
347
348
  .mockImplementation(function () { return Promise.resolve({ target: target, isLocal: true }); });
349
+ jest
350
+ .spyOn(configUtils, 'getLocalConfig')
351
+ .mockImplementation(function () { return Promise.resolve({}); });
348
352
  jest
349
353
  .spyOn(configUtils, 'getAuthConfig')
350
354
  .mockImplementation(function () { return Promise.resolve(mocks_1.mockAuthConfig); });
355
+ jest
356
+ .spyOn(setConstantsUtils, 'setConstants')
357
+ .mockImplementation(function () { return Promise.resolve(); });
351
358
  };