@sasjs/cli 2.39.0 → 3.0.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.
Files changed (69) hide show
  1. package/build/commands/add/addCredential.d.ts +2 -2
  2. package/build/commands/add/addCredential.js +26 -28
  3. package/build/commands/add/internal/input.js +15 -2
  4. package/build/commands/build/build.js +11 -11
  5. package/build/commands/build/internal/config.d.ts +1 -1
  6. package/build/commands/build/internal/config.js +5 -6
  7. package/build/commands/compile/compile.js +4 -4
  8. package/build/commands/compile/compileCommand.js +2 -1
  9. package/build/commands/compile/compileSingleFile.d.ts +1 -1
  10. package/build/commands/compile/compileSingleFile.js +6 -7
  11. package/build/commands/compile/internal/compareFolders.js +1 -2
  12. package/build/commands/compile/internal/compileJobFile.js +1 -1
  13. package/build/commands/compile/internal/compileServiceFile.js +1 -1
  14. package/build/commands/compile/internal/compileTestFile.d.ts +0 -2
  15. package/build/commands/compile/internal/compileTestFile.js +11 -15
  16. package/build/commands/compile/internal/getAllJobFolders.js +1 -1
  17. package/build/commands/compile/internal/getAllServiceFolders.js +1 -1
  18. package/build/commands/compile/internal/loadDependencies.d.ts +2 -3
  19. package/build/commands/compile/internal/loadDependencies.js +43 -230
  20. package/build/commands/compile/internal/spec/compileTestFile.spec.js +24 -12
  21. package/build/commands/compile/spec/compile.spec.js +30 -0
  22. package/build/commands/compile/spec/compileJobFile.spec.js +3 -3
  23. package/build/commands/compile/spec/compileServiceFile.spec.js +3 -3
  24. package/build/commands/compile/spec/loadDependencies.spec.js +37 -37
  25. package/build/commands/context/contextCommand.js +5 -5
  26. package/build/commands/deploy/deploy.js +3 -3
  27. package/build/commands/docs/generateDocs.js +4 -5
  28. package/build/commands/docs/internal/getFileInputs.d.ts +1 -1
  29. package/build/commands/docs/internal/getFileInputs.js +2 -2
  30. package/build/commands/docs/internal/getFileOutputs.d.ts +1 -1
  31. package/build/commands/docs/internal/getFileOutputs.js +2 -2
  32. package/build/commands/docs/internal/getFoldersForDocs.d.ts +1 -1
  33. package/build/commands/docs/internal/getFoldersForDocs.js +1 -1
  34. package/build/commands/flow/flowCommand.js +1 -1
  35. package/build/commands/flow/spec/flow.spec.server.js +1 -1
  36. package/build/commands/folder/folderCommand.js +2 -2
  37. package/build/commands/folder/spec/folder.spec.server.js +1 -1
  38. package/build/commands/job/jobCommand.js +1 -1
  39. package/build/commands/job/spec/job.spec.server.js +2 -2
  40. package/build/commands/request/request.js +3 -3
  41. package/build/commands/run/run.js +3 -3
  42. package/build/commands/servicepack/deploy.js +1 -1
  43. package/build/commands/servicepack/spec/servicepack.spec.server.js +0 -1
  44. package/build/commands/shared/deployToSasViyaWithServicePack.js +1 -1
  45. package/build/commands/testing/test.js +1 -1
  46. package/build/commands/web/internal/getWebServiceContent.js +1 -2
  47. package/build/commands/web/web.js +12 -13
  48. package/build/config.json +3 -1
  49. package/build/utils/config.d.ts +1 -2
  50. package/build/utils/config.js +106 -66
  51. package/build/utils/file.d.ts +0 -6
  52. package/build/utils/file.js +1 -43
  53. package/build/utils/setConstants.js +1 -1
  54. package/build/utils/spec/utils.spec.js +31 -5
  55. package/build/utils/test.js +1 -1
  56. package/build/utils/utils.d.ts +0 -2
  57. package/build/utils/utils.js +2 -17
  58. package/package.json +5 -5
  59. package/CHANGELOG.md +0 -30
  60. package/build/commands/compile/internal/config.d.ts +0 -25
  61. package/build/commands/compile/internal/config.js +0 -259
  62. package/build/commands/compile/spec/getDependencyPaths.spec.d.ts +0 -1
  63. package/build/commands/compile/spec/getDependencyPaths.spec.js +0 -263
  64. package/build/commands/compile/spec/getProgramDependencies.spec.d.ts +0 -1
  65. package/build/commands/compile/spec/getProgramDependencies.spec.js +0 -403
  66. package/build/commands/shared/dependencies.d.ts +0 -12
  67. package/build/commands/shared/dependencies.js +0 -332
  68. package/build/utils/spec/utils.spec.server.d.ts +0 -1
  69. package/build/utils/spec/utils.spec.server.js +0 -72
@@ -82,10 +82,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
82
82
  return (mod && mod.__esModule) ? mod : { "default": mod };
83
83
  };
84
84
  Object.defineProperty(exports, "__esModule", { value: true });
85
- exports.terminateProcess = exports.isWindows = exports.prefixAppLoc = exports.loadEnvVariables = exports.getAbsolutePath = exports.displaySasjsRunnerError = exports.getAdapterInstance = exports.checkNodeVersion = exports.millisecondsToDdHhMmSs = exports.arrToObj = exports.parseLogLines = exports.chunk = exports.executeShellScript = exports.getUniqServicesObj = exports.removeComments = exports.setupDoxygen = exports.setupGhooks = exports.setupGitIgnore = exports.setupNpmProject = exports.createTemplateApp = exports.createMinimalApp = exports.createAngularApp = exports.createReactApp = exports.diff = exports.inExistingProject = void 0;
85
+ exports.terminateProcess = exports.isWindows = exports.prefixAppLoc = exports.loadEnvVariables = exports.displaySasjsRunnerError = exports.getAdapterInstance = exports.checkNodeVersion = exports.millisecondsToDdHhMmSs = exports.arrToObj = exports.parseLogLines = exports.executeShellScript = exports.getUniqServicesObj = exports.removeComments = exports.setupDoxygen = exports.setupGhooks = exports.setupGitIgnore = exports.setupNpmProject = exports.createTemplateApp = exports.createMinimalApp = exports.createAngularApp = exports.createReactApp = exports.diff = exports.inExistingProject = void 0;
86
86
  var shelljs_1 = __importDefault(require("shelljs"));
87
87
  var path_1 = __importDefault(require("path"));
88
- var os_1 = __importDefault(require("os"));
89
88
  var ora_1 = __importDefault(require("ora"));
90
89
  var utils_1 = require("@sasjs/utils");
91
90
  var node_1 = __importDefault(require("@sasjs/adapter/node"));
@@ -438,14 +437,6 @@ function executeShellScript(filePath, logFilePath) {
438
437
  });
439
438
  }
440
439
  exports.executeShellScript = executeShellScript;
441
- function chunk(text, maxLength) {
442
- if (maxLength === void 0) { maxLength = 220; }
443
- if (text.length <= maxLength) {
444
- return [text];
445
- }
446
- return (text.match(new RegExp('.{1,' + maxLength + '}', 'g')) || []).filter(function (m) { return !!m; });
447
- }
448
- exports.chunk = chunk;
449
440
  /**
450
441
  * Extracts plain text job log from fetched json log
451
442
  * @param {object} logJson
@@ -510,7 +501,7 @@ function getAdapterInstance(target) {
510
501
  var sasjs = new node_1.default({
511
502
  serverUrl: target.serverUrl,
512
503
  serverType: target.serverType,
513
- allowInsecureRequests: target.allowInsecureRequests,
504
+ httpsAgentOptions: target.httpsAgentOptions,
514
505
  contextName: target.contextName,
515
506
  useComputeApi: true,
516
507
  debug: process.env.LOG_LEVEL === utils_1.LogLevel.Debug
@@ -526,12 +517,6 @@ function displaySasjsRunnerError(username) {
526
517
  (_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Please deploy the SASjs runner by running the code below and try again:\n" + sasjsRunnerCode);
527
518
  }
528
519
  exports.displaySasjsRunnerError = displaySasjsRunnerError;
529
- var getAbsolutePath = function (providedPath, relativePath) {
530
- return path_1.default.isAbsolute(providedPath) || /^~/.exec(providedPath)
531
- ? path_1.default.normalize(providedPath.replace(/^~/, os_1.default.homedir()))
532
- : path_1.default.join(relativePath, providedPath);
533
- };
534
- exports.getAbsolutePath = getAbsolutePath;
535
520
  var loadEnvVariables = function (fileName) { return __awaiter(void 0, void 0, void 0, function () {
536
521
  var envFileExistsInCurrentPath, envFileExistsInParentPath, envFilePath;
537
522
  return __generator(this, function (_a) {
package/package.json CHANGED
@@ -53,10 +53,10 @@
53
53
  }
54
54
  },
55
55
  "dependencies": {
56
- "@sasjs/adapter": "2.12.0",
56
+ "@sasjs/adapter": "3.0.0",
57
57
  "@sasjs/core": "2.45.2",
58
58
  "@sasjs/lint": "1.11.2",
59
- "@sasjs/utils": "2.32.0",
59
+ "@sasjs/utils": "2.34.1",
60
60
  "chalk": "4.1.2",
61
61
  "csv-stringify": "5.6.5",
62
62
  "dotenv": "10.0.0",
@@ -93,7 +93,7 @@
93
93
  "ghooks": "2.0.4",
94
94
  "jest": "27.2.4",
95
95
  "jest-cli": "27.2.4",
96
- "jest-extended": "0.11.5",
96
+ "jest-extended": "1.1.0",
97
97
  "nodemon": "2.0.13",
98
98
  "semantic-release": "17.4.7",
99
99
  "ts-jest": "27.0.5",
@@ -101,7 +101,7 @@
101
101
  "tslib": "2.3.1",
102
102
  "typescript": "4.3.5",
103
103
  "util": "0.12.4",
104
- "validate-commit-msg": "2.14.0"
104
+ "validate-commit-msg": "1.1.3"
105
105
  },
106
- "version": "2.39.0"
106
+ "version": "3.0.3"
107
107
  }
package/CHANGELOG.md DELETED
@@ -1,30 +0,0 @@
1
- # Change Log
2
-
3
- Since March 7th, 2020, the changelog is managed by github releases. See [https://github.com/sasjs/cli/releases](https://github.com/sasjs/cli/releases).
4
-
5
- ## Changes Prior to March 7th 2020
6
-
7
- All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
8
-
9
- <a name="1.0.4"></a>
10
- ## [1.0.4](https://gitlab.com/macropeople/sasjs-cli/compare/v1.0.3...v1.0.4) (2020-03-07)
11
-
12
-
13
- ### Bug Fixes
14
-
15
- * redo comment stripping logic ([84a1a91](https://gitlab.com/macropeople/sasjs-cli/commit/84a1a91))
16
-
17
-
18
-
19
- <a name="1.0.3"></a>
20
- ## [1.0.3](https://gitlab.com/macropeople/sasjs-cli/compare/v1.0.2...v1.0.3) (2020-03-07)
21
-
22
-
23
-
24
- <a name="1.0.2"></a>
25
- ## [1.0.2](https://gitlab.com/macropeople/sasjs-cli/compare/v1.0.1...v1.0.2) (2020-03-07)
26
-
27
-
28
-
29
- <a name="1.0.1"></a>
30
- ## 1.0.1 (2020-03-07)
@@ -1,25 +0,0 @@
1
- import { Target } from '@sasjs/utils/types';
2
- export declare const getServiceInit: (target: Target) => Promise<{
3
- content: string;
4
- filePath: string;
5
- }>;
6
- export declare const getServiceTerm: (target: Target) => Promise<{
7
- content: string;
8
- filePath: string;
9
- }>;
10
- export declare const getJobInit: (target: Target) => Promise<{
11
- content: string;
12
- filePath: string;
13
- }>;
14
- export declare const getJobTerm: (target: Target) => Promise<{
15
- content: string;
16
- filePath: string;
17
- }>;
18
- export declare const getTestInit: (target: Target) => Promise<{
19
- content: string;
20
- filePath: string;
21
- }>;
22
- export declare const getTestTerm: (target: Target) => Promise<{
23
- content: string;
24
- filePath: string;
25
- }>;
@@ -1,259 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.getTestTerm = exports.getTestInit = exports.getJobTerm = exports.getJobInit = exports.getServiceTerm = exports.getServiceInit = void 0;
40
- var utils_1 = require("@sasjs/utils");
41
- var config_1 = require("../../../utils/config");
42
- var utils_2 = require("../../../utils/utils");
43
- // TODO: REFACTOR
44
- var getServiceInit = function (target) { return __awaiter(void 0, void 0, void 0, function () {
45
- var buildSourceFolder, serviceInitContent, filePath, configuration;
46
- var _a, _b;
47
- return __generator(this, function (_c) {
48
- switch (_c.label) {
49
- case 0:
50
- buildSourceFolder = process.sasjsConstants.buildSourceFolder;
51
- serviceInitContent = '', filePath = '';
52
- if (!((_a = target === null || target === void 0 ? void 0 : target.serviceConfig) === null || _a === void 0 ? void 0 : _a.initProgram)) return [3 /*break*/, 2];
53
- filePath = utils_2.getAbsolutePath(target.serviceConfig.initProgram, buildSourceFolder);
54
- return [4 /*yield*/, utils_1.readFile(filePath)];
55
- case 1:
56
- serviceInitContent = _c.sent();
57
- return [3 /*break*/, 5];
58
- case 2: return [4 /*yield*/, config_1.getLocalOrGlobalConfig()];
59
- case 3:
60
- configuration = (_c.sent()).configuration;
61
- if (!((_b = configuration === null || configuration === void 0 ? void 0 : configuration.serviceConfig) === null || _b === void 0 ? void 0 : _b.initProgram)) return [3 /*break*/, 5];
62
- filePath = utils_2.getAbsolutePath(configuration.serviceConfig.initProgram, buildSourceFolder);
63
- return [4 /*yield*/, utils_1.readFile(filePath)];
64
- case 4:
65
- serviceInitContent = _c.sent();
66
- _c.label = 5;
67
- case 5: return [2 /*return*/, serviceInitContent
68
- ? {
69
- content: "\n* ServiceInit start;\n" + serviceInitContent + "\n* ServiceInit end;",
70
- filePath: filePath
71
- }
72
- : {
73
- content: '',
74
- filePath: ''
75
- }];
76
- }
77
- });
78
- }); };
79
- exports.getServiceInit = getServiceInit;
80
- var getServiceTerm = function (target) { return __awaiter(void 0, void 0, void 0, function () {
81
- var buildSourceFolder, serviceTermContent, filePath, configuration;
82
- var _a, _b;
83
- return __generator(this, function (_c) {
84
- switch (_c.label) {
85
- case 0:
86
- buildSourceFolder = process.sasjsConstants.buildSourceFolder;
87
- serviceTermContent = '', filePath = '';
88
- if (!((_a = target === null || target === void 0 ? void 0 : target.serviceConfig) === null || _a === void 0 ? void 0 : _a.termProgram)) return [3 /*break*/, 2];
89
- filePath = utils_2.getAbsolutePath(target.serviceConfig.termProgram, buildSourceFolder);
90
- return [4 /*yield*/, utils_1.readFile(filePath)];
91
- case 1:
92
- serviceTermContent = _c.sent();
93
- return [3 /*break*/, 5];
94
- case 2: return [4 /*yield*/, config_1.getLocalOrGlobalConfig()];
95
- case 3:
96
- configuration = (_c.sent()).configuration;
97
- if (!((_b = configuration === null || configuration === void 0 ? void 0 : configuration.serviceConfig) === null || _b === void 0 ? void 0 : _b.termProgram)) return [3 /*break*/, 5];
98
- filePath = utils_2.getAbsolutePath(configuration.serviceConfig.termProgram, buildSourceFolder);
99
- return [4 /*yield*/, utils_1.readFile(filePath)];
100
- case 4:
101
- serviceTermContent = _c.sent();
102
- _c.label = 5;
103
- case 5: return [2 /*return*/, serviceTermContent
104
- ? {
105
- content: "\n* ServiceTerm start;\n" + serviceTermContent + "\n* ServiceTerm end;",
106
- filePath: filePath
107
- }
108
- : {
109
- content: '',
110
- filePath: ''
111
- }];
112
- }
113
- });
114
- }); };
115
- exports.getServiceTerm = getServiceTerm;
116
- var getJobInit = function (target) { return __awaiter(void 0, void 0, void 0, function () {
117
- var buildSourceFolder, jobInitContent, filePath, configuration;
118
- var _a, _b;
119
- return __generator(this, function (_c) {
120
- switch (_c.label) {
121
- case 0:
122
- buildSourceFolder = process.sasjsConstants.buildSourceFolder;
123
- jobInitContent = '', filePath = '';
124
- if (!((_a = target === null || target === void 0 ? void 0 : target.jobConfig) === null || _a === void 0 ? void 0 : _a.initProgram)) return [3 /*break*/, 2];
125
- filePath = utils_2.getAbsolutePath(target.jobConfig.initProgram, buildSourceFolder);
126
- return [4 /*yield*/, utils_1.readFile(filePath)];
127
- case 1:
128
- jobInitContent = _c.sent();
129
- return [3 /*break*/, 5];
130
- case 2: return [4 /*yield*/, config_1.getLocalOrGlobalConfig()];
131
- case 3:
132
- configuration = (_c.sent()).configuration;
133
- if (!((_b = configuration === null || configuration === void 0 ? void 0 : configuration.jobConfig) === null || _b === void 0 ? void 0 : _b.initProgram)) return [3 /*break*/, 5];
134
- filePath = utils_2.getAbsolutePath(configuration.jobConfig.initProgram, buildSourceFolder);
135
- return [4 /*yield*/, utils_1.readFile(filePath)];
136
- case 4:
137
- jobInitContent = _c.sent();
138
- _c.label = 5;
139
- case 5: return [2 /*return*/, jobInitContent
140
- ? {
141
- content: "\n* JobInit start;\n" + jobInitContent + "\n* JobInit end;",
142
- filePath: filePath
143
- }
144
- : {
145
- content: '',
146
- filePath: ''
147
- }];
148
- }
149
- });
150
- }); };
151
- exports.getJobInit = getJobInit;
152
- var getJobTerm = function (target) { return __awaiter(void 0, void 0, void 0, function () {
153
- var buildSourceFolder, jobTermContent, filePath, configuration;
154
- var _a, _b;
155
- return __generator(this, function (_c) {
156
- switch (_c.label) {
157
- case 0:
158
- buildSourceFolder = process.sasjsConstants.buildSourceFolder;
159
- jobTermContent = '', filePath = '';
160
- if (!((_a = target === null || target === void 0 ? void 0 : target.jobConfig) === null || _a === void 0 ? void 0 : _a.termProgram)) return [3 /*break*/, 2];
161
- filePath = utils_2.getAbsolutePath(target.jobConfig.termProgram, buildSourceFolder);
162
- return [4 /*yield*/, utils_1.readFile(filePath)];
163
- case 1:
164
- jobTermContent = _c.sent();
165
- return [3 /*break*/, 5];
166
- case 2: return [4 /*yield*/, config_1.getLocalOrGlobalConfig()];
167
- case 3:
168
- configuration = (_c.sent()).configuration;
169
- if (!((_b = configuration === null || configuration === void 0 ? void 0 : configuration.jobConfig) === null || _b === void 0 ? void 0 : _b.termProgram)) return [3 /*break*/, 5];
170
- filePath = utils_2.getAbsolutePath(configuration.jobConfig.termProgram, buildSourceFolder);
171
- return [4 /*yield*/, utils_1.readFile(filePath)];
172
- case 4:
173
- jobTermContent = _c.sent();
174
- _c.label = 5;
175
- case 5: return [2 /*return*/, jobTermContent
176
- ? {
177
- content: "\n* JobTerm start;\n" + jobTermContent + "\n* JobTerm end;",
178
- filePath: filePath
179
- }
180
- : {
181
- content: '',
182
- filePath: ''
183
- }];
184
- }
185
- });
186
- }); };
187
- exports.getJobTerm = getJobTerm;
188
- var getTestInit = function (target) { return __awaiter(void 0, void 0, void 0, function () {
189
- var buildSourceFolder, testInitContent, filePath, configuration;
190
- var _a, _b;
191
- return __generator(this, function (_c) {
192
- switch (_c.label) {
193
- case 0:
194
- buildSourceFolder = process.sasjsConstants.buildSourceFolder;
195
- testInitContent = '', filePath = '';
196
- if (!((_a = target === null || target === void 0 ? void 0 : target.testConfig) === null || _a === void 0 ? void 0 : _a.initProgram)) return [3 /*break*/, 2];
197
- filePath = utils_2.getAbsolutePath(target.testConfig.initProgram, buildSourceFolder);
198
- return [4 /*yield*/, utils_1.readFile(filePath)];
199
- case 1:
200
- testInitContent = _c.sent();
201
- return [3 /*break*/, 5];
202
- case 2: return [4 /*yield*/, config_1.getLocalOrGlobalConfig()];
203
- case 3:
204
- configuration = (_c.sent()).configuration;
205
- if (!((_b = configuration === null || configuration === void 0 ? void 0 : configuration.testConfig) === null || _b === void 0 ? void 0 : _b.initProgram)) return [3 /*break*/, 5];
206
- filePath = utils_2.getAbsolutePath(configuration.testConfig.initProgram, buildSourceFolder);
207
- return [4 /*yield*/, utils_1.readFile(filePath)];
208
- case 4:
209
- testInitContent = _c.sent();
210
- _c.label = 5;
211
- case 5: return [2 /*return*/, testInitContent
212
- ? {
213
- content: "\n* TestInit start;\n" + testInitContent + "\n* TestInit end;",
214
- filePath: filePath
215
- }
216
- : {
217
- content: '',
218
- filePath: ''
219
- }];
220
- }
221
- });
222
- }); };
223
- exports.getTestInit = getTestInit;
224
- var getTestTerm = function (target) { return __awaiter(void 0, void 0, void 0, function () {
225
- var buildSourceFolder, testTermContent, filePath, configuration;
226
- var _a, _b;
227
- return __generator(this, function (_c) {
228
- switch (_c.label) {
229
- case 0:
230
- buildSourceFolder = process.sasjsConstants.buildSourceFolder;
231
- testTermContent = '', filePath = '';
232
- if (!((_a = target === null || target === void 0 ? void 0 : target.testConfig) === null || _a === void 0 ? void 0 : _a.termProgram)) return [3 /*break*/, 2];
233
- filePath = utils_2.getAbsolutePath(target.testConfig.termProgram, buildSourceFolder);
234
- return [4 /*yield*/, utils_1.readFile(filePath)];
235
- case 1:
236
- testTermContent = _c.sent();
237
- return [3 /*break*/, 5];
238
- case 2: return [4 /*yield*/, config_1.getLocalOrGlobalConfig()];
239
- case 3:
240
- configuration = (_c.sent()).configuration;
241
- if (!((_b = configuration === null || configuration === void 0 ? void 0 : configuration.testConfig) === null || _b === void 0 ? void 0 : _b.termProgram)) return [3 /*break*/, 5];
242
- filePath = utils_2.getAbsolutePath(configuration.testConfig.termProgram, buildSourceFolder);
243
- return [4 /*yield*/, utils_1.readFile(filePath)];
244
- case 4:
245
- testTermContent = _c.sent();
246
- _c.label = 5;
247
- case 5: return [2 /*return*/, testTermContent
248
- ? {
249
- content: "\n* TestTerm start;\n" + testTermContent + "\n* TestTerm end;",
250
- filePath: filePath
251
- }
252
- : {
253
- content: '',
254
- filePath: ''
255
- }];
256
- }
257
- });
258
- }); };
259
- exports.getTestTerm = getTestTerm;
@@ -1,263 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- var __importDefault = (this && this.__importDefault) || function (mod) {
39
- return (mod && mod.__esModule) ? mod : { "default": mod };
40
- };
41
- Object.defineProperty(exports, "__esModule", { value: true });
42
- var utils_1 = require("@sasjs/utils");
43
- var path_1 = __importDefault(require("path"));
44
- var utils_2 = require("@sasjs/utils");
45
- var test_1 = require("../../../utils/test");
46
- var dependencies_1 = require("../../shared/dependencies");
47
- describe('getDependencyPaths', function () {
48
- var appName = "cli-tests-dependency-paths-" + utils_1.generateTimestamp();
49
- var target = test_1.generateTestTarget(appName, '/Public/app', {
50
- serviceFolders: [path_1.default.join('sasjs', 'services')],
51
- initProgram: '',
52
- termProgram: '',
53
- macroVars: {}
54
- }, utils_1.ServerType.SasViya);
55
- beforeAll(function () { return __awaiter(void 0, void 0, void 0, function () {
56
- return __generator(this, function (_a) {
57
- switch (_a.label) {
58
- case 0: return [4 /*yield*/, test_1.createTestMinimalApp(__dirname, target.name)];
59
- case 1:
60
- _a.sent();
61
- return [2 /*return*/];
62
- }
63
- });
64
- }); });
65
- afterAll(function () { return __awaiter(void 0, void 0, void 0, function () {
66
- return __generator(this, function (_a) {
67
- switch (_a.label) {
68
- case 0: return [4 /*yield*/, test_1.removeTestApp(__dirname, target.name)];
69
- case 1:
70
- _a.sent();
71
- return [2 /*return*/];
72
- }
73
- });
74
- }); });
75
- test('it should recursively get all dependency paths', function () { return __awaiter(void 0, void 0, void 0, function () {
76
- var fileContent, dependenciesList, dependencyPaths;
77
- return __generator(this, function (_a) {
78
- switch (_a.label) {
79
- case 0: return [4 /*yield*/, utils_2.readFile(path_1.default.join(__dirname, './example.sas'))];
80
- case 1:
81
- fileContent = _a.sent();
82
- dependenciesList = [
83
- 'mp_abort.sas',
84
- 'mf_getuniquefileref.sas',
85
- 'mf_getuniquelibref.sas',
86
- 'mf_isblank.sas',
87
- 'mf_mval.sas',
88
- 'mf_trimstr.sas',
89
- 'mf_getplatform.sas',
90
- 'mf_abort.sas',
91
- 'mfv_existfolder.sas',
92
- 'mv_createfolder.sas'
93
- ];
94
- return [4 /*yield*/, dependencies_1.getDependencyPaths(fileContent)];
95
- case 2:
96
- dependencyPaths = _a.sent();
97
- dependencyPaths.forEach(function (dep) {
98
- expect(dependenciesList.some(function (x) { return dep.includes(x); })).toBeTruthy();
99
- });
100
- return [2 /*return*/];
101
- }
102
- });
103
- }); });
104
- test('it should get third level dependencies', function () { return __awaiter(void 0, void 0, void 0, function () {
105
- var fileContent, dependenciesList, dependencyPaths;
106
- return __generator(this, function (_a) {
107
- switch (_a.label) {
108
- case 0: return [4 /*yield*/, utils_2.readFile(path_1.default.join(__dirname, './nested-deps.sas'))];
109
- case 1:
110
- fileContent = _a.sent();
111
- dependenciesList = [
112
- 'mf_isblank.sas',
113
- 'mm_createwebservice.sas',
114
- 'mm_createstp.sas',
115
- 'mf_getuser.sas',
116
- 'mm_createfolder.sas',
117
- 'mm_deletestp.sas',
118
- 'mf_nobs.sas',
119
- 'mf_getattrn.sas',
120
- 'mf_abort.sas',
121
- 'mf_verifymacvars.sas',
122
- 'mm_getdirectories.sas',
123
- 'mm_updatestpsourcecode.sas',
124
- 'mp_dropmembers.sas',
125
- 'mm_getservercontexts.sas',
126
- 'mm_getrepos.sas'
127
- ];
128
- return [4 /*yield*/, dependencies_1.getDependencyPaths(fileContent)];
129
- case 2:
130
- dependencyPaths = _a.sent();
131
- dependenciesList.forEach(function (expectedDep) {
132
- expect(dependencyPaths.some(function (dep) { return dep.includes(expectedDep); })).toBeTruthy();
133
- });
134
- return [2 /*return*/];
135
- }
136
- });
137
- }); });
138
- test('it should throw an error when a dependency is not found', function () { return __awaiter(void 0, void 0, void 0, function () {
139
- var missingDependencies, missingDependencyFile, fileContent;
140
- return __generator(this, function (_a) {
141
- switch (_a.label) {
142
- case 0:
143
- missingDependencies = ['foobar.sas', 'foobar2.sas'];
144
- missingDependencyFile = './missing-dependency.sas';
145
- return [4 /*yield*/, utils_2.readFile(path_1.default.join(__dirname, missingDependencyFile))];
146
- case 1:
147
- fileContent = _a.sent();
148
- return [4 /*yield*/, expect(dependencies_1.getDependencyPaths(fileContent)).rejects.toEqual("Unable to locate dependencies: " + missingDependencies.join(', '))];
149
- case 2:
150
- _a.sent();
151
- return [2 /*return*/];
152
- }
153
- });
154
- }); });
155
- test('it should ignore non-sas dependencies', function () { return __awaiter(void 0, void 0, void 0, function () {
156
- var fileContent, dependenciesList, dependencyPaths;
157
- return __generator(this, function (_a) {
158
- switch (_a.label) {
159
- case 0: return [4 /*yield*/, utils_2.readFile(path_1.default.join(__dirname, './non-sas-dependency.sas'))];
160
- case 1:
161
- fileContent = _a.sent();
162
- dependenciesList = [
163
- 'mp_abort.sas',
164
- 'mf_getuniquefileref.sas',
165
- 'mf_getuniquelibref.sas',
166
- 'mf_isblank.sas',
167
- 'mf_mval.sas',
168
- 'mf_trimstr.sas',
169
- 'mf_getplatform.sas',
170
- 'mf_abort.sas',
171
- 'mfv_existfolder.sas',
172
- 'mv_createfolder.sas'
173
- ];
174
- return [4 /*yield*/, expect(dependencies_1.getDependencyPaths(fileContent)).resolves.not.toThrow()];
175
- case 2:
176
- _a.sent();
177
- return [4 /*yield*/, dependencies_1.getDependencyPaths(fileContent)];
178
- case 3:
179
- dependencyPaths = _a.sent();
180
- dependencyPaths.forEach(function (dep) {
181
- expect(dependenciesList.some(function (x) { return dep.includes(x); })).toBeTruthy();
182
- });
183
- return [2 /*return*/];
184
- }
185
- });
186
- }); });
187
- test('it should prioritise overridden dependencies', function () {
188
- var dependencyNames = ['mf_abort.sas'];
189
- var mfAbortPath = path_1.default.join('sas', 'macros', 'mf_abort.sas');
190
- var dependencyPaths = [
191
- path_1.default.join('node_modules', '@sasjs', 'core', 'core', 'mf_abort.sas'),
192
- mfAbortPath
193
- ];
194
- var result = dependencies_1.prioritiseDependencyOverrides(dependencyNames, dependencyPaths);
195
- expect(result).toEqual([mfAbortPath]);
196
- });
197
- test('it should prioritise overridden dependencies, if both are non-core', function () {
198
- var dependencyNames = ['mf_abort.sas'];
199
- var mfAbortPath = path_1.default.join('sas', 'macros', 'mf_abort.sas');
200
- var dependencyPaths = [
201
- mfAbortPath,
202
- path_1.default.join('sas', 'macros2', 'mf_abort.sas')
203
- ];
204
- var result = dependencies_1.prioritiseDependencyOverrides(dependencyNames, dependencyPaths, ['macros', 'macros2']);
205
- expect(result).toEqual([mfAbortPath]);
206
- });
207
- test('it should prioritise overridden dependencies with windows file paths', function () {
208
- var dependencyNames = ['mf_abort.sas'];
209
- var dependencyPaths = [
210
- 'node_modules\\@sasjs\\core\\core\\mf_abort.sas',
211
- 'sas\\macros\\mf_abort.sas'
212
- ];
213
- var result = dependencies_1.prioritiseDependencyOverrides(dependencyNames, dependencyPaths, [], '\\');
214
- expect(result).toEqual(['sas\\macros\\mf_abort.sas']);
215
- });
216
- test('it should prioritise overridden dependencies provided specific macros', function () {
217
- var dependencyNames = ['mf_abort.sas'];
218
- var mfAbortPath = path_1.default.join('sas', 'sas9macros', 'mf_abort.sas');
219
- var dependencyPaths = [
220
- path_1.default.join('node_modules', '@sasjs', 'core', 'core', 'mf_abort.sas'),
221
- mfAbortPath,
222
- path_1.default.join('sas', 'macros', 'mf_abort.sas')
223
- ];
224
- var result = dependencies_1.prioritiseDependencyOverrides(dependencyNames, dependencyPaths, ['sas9macros']);
225
- expect(result).toEqual([mfAbortPath]);
226
- });
227
- test("it should prioritise overridden dependencies, if specific 'macroLoc' was provided, but macro at such 'macroLoc' is not present", function () {
228
- var dependencyNames = ['mf_abort.sas'];
229
- var mfAbortPath = path_1.default.join('sas', 'macros', 'mf_abort.sas');
230
- var dependencyPaths = [
231
- path_1.default.join('node_modules', '@sasjs', 'core', 'core', 'mf_abort.sas'),
232
- mfAbortPath
233
- ];
234
- var result = dependencies_1.prioritiseDependencyOverrides(dependencyNames, dependencyPaths, ['sas9macros']);
235
- expect(result).toEqual([mfAbortPath]);
236
- });
237
- test('it should prioritise overridden dependencies and remove extra dependencies, if specific macros were provided', function () {
238
- var dependencyNames = ['mf_abort.sas'];
239
- var mfAbortPath = path_1.default.join('sas', 'sas9macros', 'mf_abort.sas');
240
- var dependencyPaths = [
241
- path_1.default.join('node_modules', '@sasjs', 'core', 'core', 'mf_abort.sas'),
242
- path_1.default.join('sas', 'sasviyamacros', 'mf_abort.sas'),
243
- mfAbortPath,
244
- path_1.default.join('sas', 'macros2', 'mf_abort.sas'),
245
- path_1.default.join('sas', 'macros', 'mf_abort.sas')
246
- ];
247
- var result = dependencies_1.prioritiseDependencyOverrides(dependencyNames, dependencyPaths, ['sas9macros']);
248
- expect(result).toEqual([mfAbortPath]);
249
- });
250
- test('it should prioritise overridden dependencies and remove duplicated dependencies, if specific macros were provided', function () {
251
- var dependencyNames = ['mf_abort.sas'];
252
- var mfAbortPath = path_1.default.join('sas', 'sas9macros', 'mf_abort.sas');
253
- var dependencyPaths = [
254
- path_1.default.join('node_modules', '@sasjs', 'core', 'core', 'mf_abort.sas'),
255
- mfAbortPath,
256
- mfAbortPath,
257
- path_1.default.join('sas', 'macros', 'mf_abort.sas'),
258
- path_1.default.join('sas', 'macros', 'mf_abort.sas')
259
- ];
260
- var result = dependencies_1.prioritiseDependencyOverrides(dependencyNames, dependencyPaths, ['sas9macros']);
261
- expect(result).toEqual([mfAbortPath]);
262
- });
263
- });