@sasjs/cli 4.0.3 → 4.0.5

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 (38) 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/internal/config.js +14 -21
  4. package/build/commands/build/spec/buildCommand.spec.js +8 -1
  5. package/build/commands/build/spec/compileBuildCommand.spec.js +8 -1
  6. package/build/commands/compile/compile.js +16 -18
  7. package/build/commands/compile/internal/compileTestFile.js +12 -20
  8. package/build/commands/compile/internal/getAllFolders.js +28 -40
  9. package/build/commands/compile/internal/getServerType.js +6 -12
  10. package/build/commands/compile/internal/loadDependencies.js +5 -6
  11. package/build/commands/compile/internal/spec/getAllFolders.spec.js +1 -1
  12. package/build/commands/compile/spec/compile.spec.js +43 -29
  13. package/build/commands/compile/spec/compileCommand.spec.js +11 -3
  14. package/build/commands/compile/spec/loadDependencies.spec.js +11 -6
  15. package/build/commands/context/spec/contextCommand.spec.js +8 -0
  16. package/build/commands/deploy/internal/getDeployScripts.js +4 -15
  17. package/build/commands/deploy/spec/cbd.spec.js +26 -22
  18. package/build/commands/deploy/spec/compileBuildDeployCommand.spec.js +9 -2
  19. package/build/commands/deploy/spec/deployCommand.spec.js +7 -0
  20. package/build/commands/docs/generateDocs.js +49 -13
  21. package/build/commands/docs/spec/docsCommand.spec.js +4 -0
  22. package/build/commands/flow/spec/flowCommand.spec.js +7 -11
  23. package/build/commands/folder/spec/folderCommand.spec.js +7 -0
  24. package/build/commands/fs/spec/fsCommand.spec.js +19 -22
  25. package/build/commands/job/spec/jobCommand.spec.js +6 -0
  26. package/build/commands/request/spec/requestCommand.spec.js +7 -11
  27. package/build/commands/run/spec/runCommand.spec.js +7 -11
  28. package/build/commands/servicepack/spec/servicepackCommand.spec.js +7 -11
  29. package/build/commands/testing/spec/testCommand.spec.js +7 -11
  30. package/build/commands/web/spec/web.spec.js +12 -7
  31. package/build/commands/web/spec/webCommand.spec.js +8 -1
  32. package/build/types/command/targetCommand.js +25 -5
  33. package/build/utils/config.js +41 -60
  34. package/build/utils/setConstants.d.ts +2 -3
  35. package/build/utils/setConstants.js +55 -77
  36. package/build/utils/spec/setConstants.spec.js +1 -1
  37. package/build/utils/test.js +32 -17
  38. 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');
@@ -95,7 +95,8 @@ var getDocConfig_1 = require("./internal/getDocConfig");
95
95
  function generateDocs(target, config, outDirectory) {
96
96
  var _a, _b;
97
97
  return __awaiter(this, void 0, void 0, function () {
98
- var _c, serverUrl, newOutDirectory, enableLineage, doxyContentFromConfig, _d, macroCoreFolders, macroFolders, programFolders, serviceFolders, jobFolders, combinedFolders, PROJECT_NAME, PROJECT_BRIEF, packageJsonContent, packageJson, e_1, doxyContent, doxyParams, doxyConfigPath, spinner, pathExists, _e, stderr, code, foldersListForDot;
98
+ var _c, serverUrl, newOutDirectory, enableLineage, doxyContentFromConfig, _d, macroCoreFolders, macroFolders, programFolders, serviceFolders, jobFolders, combinedFolders, PROJECT_NAME, PROJECT_BRIEF, packageJsonContent, packageJson, e_1, doxyContent, layoutFilePath, LAYOUT_FILE, doxyParams, doxyConfigPath, spinner, pathExists, _e, stderr, code, foldersListForDot;
99
+ var _this = this;
99
100
  return __generator(this, function (_f) {
100
101
  switch (_f.label) {
101
102
  case 0:
@@ -132,6 +133,29 @@ function generateDocs(target, config, outDirectory) {
132
133
  doxyContent = __assign({ favIcon: 'favicon.ico', footer: 'new_footer.html', header: 'new_header.html', layout: 'DoxygenLayout.xml', logo: 'logo.png', readMe: '../../README.md', stylesheet: 'new_stylesheet.css', path: path_1.default.join(process.projectDir, 'sasjs', 'doxy') }, doxyContentFromConfig);
133
134
  if (doxyContentFromConfig === null || doxyContentFromConfig === void 0 ? void 0 : doxyContentFromConfig.path)
134
135
  doxyContent.path = (0, utils_1.getAbsolutePath)(doxyContentFromConfig.path, process.projectDir);
136
+ layoutFilePath = path_1.default.join(doxyContent.path, doxyContent.layout);
137
+ return [4 /*yield*/, (0, utils_1.readFile)(layoutFilePath).then(function (content) { return __awaiter(_this, void 0, void 0, function () {
138
+ var testString, replaced, timeStamp, tmpFilePath;
139
+ return __generator(this, function (_a) {
140
+ switch (_a.label) {
141
+ case 0:
142
+ if (enableLineage)
143
+ return [2 /*return*/, layoutFilePath
144
+ // if enableLineage is false, create a tmp layout file without lineage tab
145
+ ];
146
+ testString = "<tab type=\"user\" url=\"data_lineage.svg\" title=\"Lineage\"/>";
147
+ replaced = content.replace(testString, '');
148
+ timeStamp = (0, utils_1.generateTimestamp)();
149
+ tmpFilePath = path_1.default.join(doxyContent.path, "".concat(timeStamp, "-DoxygenLayout.xml"));
150
+ return [4 /*yield*/, (0, utils_1.createFile)(tmpFilePath, replaced)];
151
+ case 1:
152
+ _a.sent();
153
+ return [2 /*return*/, tmpFilePath];
154
+ }
155
+ });
156
+ }); })];
157
+ case 5:
158
+ LAYOUT_FILE = _f.sent();
135
159
  doxyParams = setVariableCmd({
136
160
  DOXY_HTML_OUTPUT: newOutDirectory,
137
161
  DOXY_INPUT: "\"".concat(path_1.default.join(doxyContent.path, doxyContent.readMe), "\" ").concat(combinedFolders),
@@ -139,47 +163,59 @@ function generateDocs(target, config, outDirectory) {
139
163
  HTML_EXTRA_STYLESHEET: "\"".concat(path_1.default.join(doxyContent.path, doxyContent.stylesheet), "\""),
140
164
  HTML_FOOTER: path_1.default.join(doxyContent.path, doxyContent.footer),
141
165
  HTML_HEADER: path_1.default.join(doxyContent.path, doxyContent.header),
142
- LAYOUT_FILE: path_1.default.join(doxyContent.path, doxyContent.layout),
166
+ LAYOUT_FILE: LAYOUT_FILE,
143
167
  PROJECT_BRIEF: PROJECT_BRIEF,
144
168
  PROJECT_LOGO: path_1.default.join(doxyContent.path, doxyContent.logo),
145
169
  PROJECT_NAME: PROJECT_NAME
146
170
  });
147
171
  return [4 /*yield*/, getDoxyConfigPath(doxyContent.path)];
148
- case 5:
172
+ case 6:
149
173
  doxyConfigPath = _f.sent();
150
174
  (_b = process.logger) === null || _b === void 0 ? void 0 : _b.info("Using ".concat(doxyConfigPath, " as Doxygen Configuration."));
151
175
  spinner = (0, ora_1.default)(chalk_1.default.greenBright('Generating docs', chalk_1.default.cyanBright(newOutDirectory)));
152
176
  if (process.env.LOG_LEVEL !== utils_1.LogLevel.Debug)
153
177
  spinner.start();
154
178
  return [4 /*yield*/, (0, utils_1.fileExists)(newOutDirectory)];
155
- case 6:
179
+ case 7:
156
180
  pathExists = _f.sent();
157
- if (!pathExists) return [3 /*break*/, 8];
181
+ if (!pathExists) return [3 /*break*/, 9];
158
182
  return [4 /*yield*/, (0, utils_1.deleteFolder)(newOutDirectory)];
159
- case 7:
183
+ case 8:
160
184
  _f.sent();
161
- _f.label = 8;
162
- case 8: return [4 /*yield*/, (0, utils_1.createFolder)(newOutDirectory)];
163
- case 9:
185
+ _f.label = 9;
186
+ case 9: return [4 /*yield*/, (0, utils_1.createFolder)(newOutDirectory)];
187
+ case 10:
164
188
  _f.sent();
165
189
  _e = shelljs_1.default.exec("".concat(doxyParams, " doxygen \"").concat(doxyConfigPath, "\""), {
166
190
  silent: process.env.LOG_LEVEL !== utils_1.LogLevel.Debug
167
191
  }), stderr = _e.stderr, code = _e.code;
168
192
  if (process.env.LOG_LEVEL !== utils_1.LogLevel.Debug)
169
193
  spinner.stop();
194
+ if (!!enableLineage) return [3 /*break*/, 12];
195
+ // when enable lineage is false, we are creating a tmp DoxygenLayout.xml file
196
+ // this is same a original but just with removed tab for lineage
197
+ // therefor, we are removing this tmp file once the shell command for doxygen is completed
198
+ return [4 /*yield*/, (0, utils_1.deleteFile)(LAYOUT_FILE)];
199
+ case 11:
200
+ // when enable lineage is false, we are creating a tmp DoxygenLayout.xml file
201
+ // this is same a original but just with removed tab for lineage
202
+ // therefor, we are removing this tmp file once the shell command for doxygen is completed
203
+ _f.sent();
204
+ _f.label = 12;
205
+ case 12:
170
206
  if (code !== 0) {
171
207
  if (stderr.startsWith('error: ')) {
172
208
  throw new Error("\n".concat(stderr));
173
209
  }
174
210
  throw new Error("The Doxygen application is not installed or configured. This external tool is used by 'sasjs doc'.\n".concat(stderr, "\nPlease download and install from here: https://www.doxygen.nl/download.html#srcbin"));
175
211
  }
176
- if (!enableLineage) return [3 /*break*/, 11];
212
+ if (!enableLineage) return [3 /*break*/, 14];
177
213
  foldersListForDot = __spreadArray([], __read(new Set(__spreadArray(__spreadArray([], __read(serviceFolders), false), __read(jobFolders), false))), false);
178
214
  return [4 /*yield*/, (0, createDotFiles_1.createDotFiles)(foldersListForDot, newOutDirectory, serverUrl)];
179
- case 10:
215
+ case 13:
180
216
  _f.sent();
181
- _f.label = 11;
182
- case 11: return [2 /*return*/, { outDirectory: newOutDirectory }];
217
+ _f.label = 14;
218
+ case 14: return [2 /*return*/, { outDirectory: newOutDirectory }];
183
219
  }
184
220
  });
185
221
  });
@@ -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
  };