@sasjs/cli 3.0.2 → 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 (53) hide show
  1. package/build/commands/build/build.js +11 -11
  2. package/build/commands/build/internal/config.d.ts +1 -1
  3. package/build/commands/build/internal/config.js +5 -6
  4. package/build/commands/compile/compile.js +4 -4
  5. package/build/commands/compile/compileCommand.js +2 -1
  6. package/build/commands/compile/compileSingleFile.d.ts +1 -1
  7. package/build/commands/compile/compileSingleFile.js +6 -7
  8. package/build/commands/compile/internal/compareFolders.js +1 -2
  9. package/build/commands/compile/internal/compileJobFile.js +1 -1
  10. package/build/commands/compile/internal/compileServiceFile.js +1 -2
  11. package/build/commands/compile/internal/compileTestFile.d.ts +0 -2
  12. package/build/commands/compile/internal/compileTestFile.js +10 -14
  13. package/build/commands/compile/internal/getAllJobFolders.js +1 -1
  14. package/build/commands/compile/internal/getAllServiceFolders.js +1 -1
  15. package/build/commands/compile/internal/loadDependencies.d.ts +2 -3
  16. package/build/commands/compile/internal/loadDependencies.js +43 -230
  17. package/build/commands/compile/internal/spec/compileTestFile.spec.js +8 -8
  18. package/build/commands/compile/spec/compileJobFile.spec.js +3 -3
  19. package/build/commands/compile/spec/compileServiceFile.spec.js +3 -3
  20. package/build/commands/compile/spec/loadDependencies.spec.js +37 -37
  21. package/build/commands/deploy/deploy.js +1 -1
  22. package/build/commands/docs/generateDocs.js +4 -5
  23. package/build/commands/docs/internal/getFileInputs.d.ts +1 -1
  24. package/build/commands/docs/internal/getFileInputs.js +2 -2
  25. package/build/commands/docs/internal/getFileOutputs.d.ts +1 -1
  26. package/build/commands/docs/internal/getFileOutputs.js +2 -2
  27. package/build/commands/docs/internal/getFoldersForDocs.d.ts +1 -1
  28. package/build/commands/docs/internal/getFoldersForDocs.js +1 -1
  29. package/build/commands/request/request.js +2 -2
  30. package/build/commands/run/run.js +1 -1
  31. package/build/commands/servicepack/deploy.js +1 -1
  32. package/build/commands/web/internal/getWebServiceContent.js +1 -2
  33. package/build/commands/web/web.js +12 -13
  34. package/build/utils/config.d.ts +1 -2
  35. package/build/utils/config.js +2 -2
  36. package/build/utils/file.d.ts +0 -6
  37. package/build/utils/file.js +1 -43
  38. package/build/utils/setConstants.js +1 -1
  39. package/build/utils/spec/utils.spec.js +31 -5
  40. package/build/utils/utils.d.ts +0 -2
  41. package/build/utils/utils.js +1 -16
  42. package/package.json +2 -2
  43. package/CHANGELOG.md +0 -30
  44. package/build/commands/compile/internal/config.d.ts +0 -25
  45. package/build/commands/compile/internal/config.js +0 -259
  46. package/build/commands/compile/spec/getDependencyPaths.spec.d.ts +0 -1
  47. package/build/commands/compile/spec/getDependencyPaths.spec.js +0 -263
  48. package/build/commands/compile/spec/getProgramDependencies.spec.d.ts +0 -1
  49. package/build/commands/compile/spec/getProgramDependencies.spec.js +0 -403
  50. package/build/commands/shared/dependencies.d.ts +0 -12
  51. package/build/commands/shared/dependencies.js +0 -332
  52. package/build/utils/spec/utils.spec.server.d.ts +0 -1
  53. package/build/utils/spec/utils.spec.server.js +0 -72
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -46,243 +35,67 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
46
35
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
36
  }
48
37
  };
49
- var __read = (this && this.__read) || function (o, n) {
50
- var m = typeof Symbol === "function" && o[Symbol.iterator];
51
- if (!m) return o;
52
- var i = m.call(o), r, ar = [], e;
53
- try {
54
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
55
- }
56
- catch (error) { e = { error: error }; }
57
- finally {
58
- try {
59
- if (r && !r.done && (m = i["return"])) m.call(i);
60
- }
61
- finally { if (e) throw e.error; }
62
- }
63
- return ar;
64
- };
65
- var __spreadArray = (this && this.__spreadArray) || function (to, from) {
66
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
67
- to[j] = from[i];
68
- return to;
69
- };
70
- var __values = (this && this.__values) || function(o) {
71
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
72
- if (m) return m.call(o);
73
- if (o && typeof o.length === "number") return {
74
- next: function () {
75
- if (o && i >= o.length) o = void 0;
76
- return { value: o && o[i++], done: !o };
77
- }
78
- };
79
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
80
- };
81
38
  Object.defineProperty(exports, "__esModule", { value: true });
82
- exports.getVars = exports.loadDependencies = void 0;
39
+ exports.loadDependencies = void 0;
83
40
  var utils_1 = require("@sasjs/utils");
84
41
  var config_1 = require("../../../utils/config");
85
- var utils_2 = require("../../../utils/utils");
86
- var dependencies_1 = require("../../shared/dependencies");
87
- var config_2 = require("./config");
88
- var compileTestFile_1 = require("./compileTestFile");
89
42
  function loadDependencies(target, filePath, macroFolders, programFolders, type) {
90
- var _a, _b, _c, _d;
91
- if (type === void 0) { type = 'service'; }
43
+ var _a;
92
44
  return __awaiter(this, void 0, void 0, function () {
93
- var fileContent, deprecationDate, today, deprecationDate, warningDate, today, message, init, initPath, term, termPath, serviceVars, jobVars, testVars, fileDependencyPaths, initDependencyPaths, termDependencyPaths, allDependencyPaths, initProgramDependencies, termProgramDependencies, programDependencies, dependenciesContent;
94
- var _e, _f, _g, _h, _j, _k;
95
- return __generator(this, function (_l) {
96
- switch (_l.label) {
45
+ var fileContent, configuration, _b, buildSourceFolder, macroCorePath;
46
+ return __generator(this, function (_c) {
47
+ switch (_c.label) {
97
48
  case 0:
98
49
  (_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Loading dependencies for " + filePath);
99
50
  return [4 /*yield*/, utils_1.readFile(filePath)];
100
51
  case 1:
101
- fileContent = _l.sent();
102
- if (fileContent.includes('<h4> Dependencies </h4>')) {
103
- deprecationDate = new Date(2021, 10, 2);
104
- today = new Date();
105
- if (today < deprecationDate) {
106
- (_b = process.logger) === null || _b === void 0 ? void 0 : _b.warn("Please use <h4> SAS Macros </h4> syntax to specify dependencies. Specifying dependencies with a <h4> Dependencies </h4> syntax will not be supported starting from November 1, 2021.");
107
- }
108
- else {
109
- throw new Error('Using <h4> Dependencies </h4> syntax is deprecated. Please use <h4> SAS Macros </h4> instead.');
110
- }
111
- }
112
- if (fileContent.includes('<h4> SAS Programs </h4>')) {
113
- deprecationDate = new Date(2022, 4, 2);
114
- warningDate = new Date(2022, 10, 2);
115
- today = new Date();
116
- message = "Please use <h4> SAS Includes </h4> syntax to specify programs. Specifying programs with a <h4> SAS Programs </h4> syntax will not be supported starting from April 1, 2022.";
117
- if (today < warningDate)
118
- (_c = process.logger) === null || _c === void 0 ? void 0 : _c.info(message);
119
- else if (today < deprecationDate)
120
- (_d = process.logger) === null || _d === void 0 ? void 0 : _d.warn(message);
121
- else
122
- throw new Error('Using <h4> SAS Programs </h4> syntax is deprecated. Please use <h4> SAS Includes </h4> instead.');
123
- }
124
- serviceVars = '';
125
- jobVars = '';
126
- testVars = '';
127
- if (!(type === 'service' && !compileTestFile_1.isTestFile(filePath))) return [3 /*break*/, 5];
128
- return [4 /*yield*/, exports.getVars('service', target)];
52
+ fileContent = _c.sent();
53
+ return [4 /*yield*/, config_1.getLocalOrGlobalConfig()];
129
54
  case 2:
130
- serviceVars = _l.sent();
131
- return [4 /*yield*/, config_2.getServiceInit(target)];
132
- case 3:
133
- (_e = _l.sent(), init = _e.content, initPath = _e.filePath);
134
- return [4 /*yield*/, config_2.getServiceTerm(target)];
135
- case 4:
136
- (_f = _l.sent(), term = _f.content, termPath = _f.filePath);
137
- fileContent = fileContent
138
- ? "\n* Service start;\n" + fileContent + "\n* Service end;"
139
- : '';
140
- return [3 /*break*/, 13];
141
- case 5:
142
- if (!(type === 'job' && !compileTestFile_1.isTestFile(filePath))) return [3 /*break*/, 9];
143
- return [4 /*yield*/, exports.getVars('job', target)];
144
- case 6:
145
- jobVars = _l.sent();
146
- return [4 /*yield*/, config_2.getJobInit(target)];
147
- case 7:
148
- (_g = _l.sent(), init = _g.content, initPath = _g.filePath);
149
- return [4 /*yield*/, config_2.getJobTerm(target)];
150
- case 8:
151
- (_h = _l.sent(), term = _h.content, termPath = _h.filePath);
152
- fileContent = fileContent
153
- ? "\n* Job start;\n" + fileContent + "\n* Job end;"
154
- : '';
155
- return [3 /*break*/, 13];
156
- case 9: return [4 /*yield*/, exports.getVars('test', target)];
157
- case 10:
158
- testVars = _l.sent();
159
- return [4 /*yield*/, config_2.getTestInit(target)];
160
- case 11:
161
- (_j = _l.sent(), init = _j.content, initPath = _j.filePath);
162
- return [4 /*yield*/, config_2.getTestTerm(target)];
163
- case 12:
164
- (_k = _l.sent(), term = _k.content, termPath = _k.filePath);
165
- fileContent = fileContent
166
- ? "\n* Test start;\n" + fileContent + "\n* Test end;"
167
- : '';
168
- _l.label = 13;
169
- case 13:
170
- init = init || '';
171
- initPath = initPath || '';
172
- term = term || '';
173
- termPath = termPath || '';
174
- return [4 /*yield*/, dependencies_1.getDependencyPaths(fileContent + "\n" + init + "\n" + term, macroFolders)];
175
- case 14:
176
- fileDependencyPaths = _l.sent();
177
- return [4 /*yield*/, dependencies_1.getDependencyPaths(init, macroFolders)];
178
- case 15:
179
- initDependencyPaths = _l.sent();
180
- return [4 /*yield*/, dependencies_1.getDependencyPaths(term, macroFolders)];
181
- case 16:
182
- termDependencyPaths = _l.sent();
183
- allDependencyPaths = __spreadArray(__spreadArray(__spreadArray([], __read(initDependencyPaths)), __read(fileDependencyPaths)), __read(termDependencyPaths));
184
- return [4 /*yield*/, dependencies_1.getProgramDependencies(init, programFolders, initPath)];
185
- case 17:
186
- initProgramDependencies = _l.sent();
187
- return [4 /*yield*/, dependencies_1.getProgramDependencies(term, programFolders, termPath)];
188
- case 18:
189
- termProgramDependencies = _l.sent();
190
- return [4 /*yield*/, dependencies_1.getProgramDependencies(fileContent, programFolders, filePath)];
191
- case 19:
192
- programDependencies = _l.sent();
193
- return [4 /*yield*/, getDependencies(allDependencyPaths)];
194
- case 20:
195
- dependenciesContent = _l.sent();
196
- fileContent = "* Dependencies start;\n" + initProgramDependencies + "\n" + termProgramDependencies + "\n" + dependenciesContent + "\n* Dependencies end;\n* Programs start;\n" + programDependencies + "\n*Programs end;" + init + fileContent + term;
197
- switch (type) {
198
- case 'service':
199
- fileContent = "* Service Variables start;\n" + serviceVars + "\n*Service Variables end;\n" + fileContent;
200
- break;
201
- case 'job':
202
- fileContent = "* Job Variables start;\n" + jobVars + "\n*Job Variables end;\n" + fileContent;
203
- break;
204
- case 'test':
205
- fileContent = "* Test Variables start;\n" + testVars + "\n*Test Variables end;\n" + fileContent;
206
- break;
207
- default:
208
- break;
209
- }
210
- return [2 /*return*/, fileContent];
55
+ configuration = (_c.sent()).configuration;
56
+ _b = process.sasjsConstants, buildSourceFolder = _b.buildSourceFolder, macroCorePath = _b.macroCorePath;
57
+ headerSyntaxNotices(fileContent);
58
+ return [4 /*yield*/, utils_1.loadDependenciesFile({
59
+ fileContent: fileContent,
60
+ filePath: filePath,
61
+ configuration: configuration,
62
+ target: target,
63
+ type: type,
64
+ macroFolders: macroFolders,
65
+ programFolders: programFolders,
66
+ buildSourceFolder: buildSourceFolder,
67
+ macroCorePath: macroCorePath
68
+ })];
69
+ case 3: return [2 /*return*/, _c.sent()];
211
70
  }
212
71
  });
213
72
  });
214
73
  }
215
74
  exports.loadDependencies = loadDependencies;
216
- function getDependencies(filePaths) {
217
- return __awaiter(this, void 0, void 0, function () {
218
- var dependenciesContent;
219
- var _this = this;
220
- return __generator(this, function (_a) {
221
- switch (_a.label) {
222
- case 0:
223
- dependenciesContent = [];
224
- return [4 /*yield*/, utils_1.asyncForEach(__spreadArray([], __read(new Set(filePaths))), function (filePath) { return __awaiter(_this, void 0, void 0, function () {
225
- var depFileContent;
226
- return __generator(this, function (_a) {
227
- switch (_a.label) {
228
- case 0: return [4 /*yield*/, utils_1.readFile(filePath)];
229
- case 1:
230
- depFileContent = _a.sent();
231
- dependenciesContent.push(depFileContent);
232
- return [2 /*return*/];
233
- }
234
- });
235
- }); })];
236
- case 1:
237
- _a.sent();
238
- return [2 /*return*/, dependenciesContent.join('\n')];
239
- }
240
- });
241
- });
242
- }
243
- var getVars = function (varType, target) { return __awaiter(void 0, void 0, void 0, function () {
244
- var getInternalVars, targetVars, configuration, commonServiceVars;
245
- return __generator(this, function (_a) {
246
- switch (_a.label) {
247
- case 0:
248
- getInternalVars = function (config) {
249
- var _a, _b, _c;
250
- return varType === 'service'
251
- ? (_a = config === null || config === void 0 ? void 0 : config.serviceConfig) === null || _a === void 0 ? void 0 : _a.macroVars
252
- : varType === 'job'
253
- ? (_b = config === null || config === void 0 ? void 0 : config.jobConfig) === null || _b === void 0 ? void 0 : _b.macroVars
254
- : varType === 'test'
255
- ? (_c = config === null || config === void 0 ? void 0 : config.testConfig) === null || _c === void 0 ? void 0 : _c.macroVars
256
- : {};
257
- };
258
- targetVars = getInternalVars(target);
259
- return [4 /*yield*/, config_1.getLocalOrGlobalConfig()];
260
- case 1:
261
- configuration = (_a.sent()).configuration;
262
- commonServiceVars = getInternalVars(configuration);
263
- return [2 /*return*/, convertVarsToSasFormat(__assign(__assign({}, commonServiceVars), targetVars))];
75
+ var headerSyntaxNotices = function (fileContent) {
76
+ var _a, _b, _c;
77
+ if (fileContent.includes('<h4> Dependencies </h4>')) {
78
+ var deprecationDate = new Date(2021, 10, 2);
79
+ var today = new Date();
80
+ if (today < deprecationDate) {
81
+ (_a = process.logger) === null || _a === void 0 ? void 0 : _a.warn("Please use <h4> SAS Macros </h4> syntax to specify dependencies. Specifying dependencies with a <h4> Dependencies </h4> syntax will not be supported starting from November 1, 2021.");
264
82
  }
265
- });
266
- }); };
267
- exports.getVars = getVars;
268
- var convertVarsToSasFormat = function (vars) {
269
- var e_1, _a;
270
- var entries = Object.entries(vars);
271
- var varsContent = '\n';
272
- try {
273
- for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
274
- var _b = __read(entries_1_1.value, 2), name_1 = _b[0], value = _b[1];
275
- var chunks = utils_2.chunk(value);
276
- var chunkedString = chunks.join('%trim(\n)');
277
- varsContent += "%let " + name_1 + "=" + chunkedString + ";\n";
83
+ else {
84
+ throw new Error('Using <h4> Dependencies </h4> syntax is deprecated. Please use <h4> SAS Macros </h4> instead.');
278
85
  }
279
86
  }
280
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
281
- finally {
282
- try {
283
- if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1);
87
+ if (fileContent.includes('<h4> SAS Programs </h4>')) {
88
+ var deprecationDate = new Date(2022, 4, 2);
89
+ var warningDate = new Date(2022, 10, 2);
90
+ var today = new Date();
91
+ var message = "Please use <h4> SAS Includes </h4> syntax to specify programs. Specifying programs with a <h4> SAS Programs </h4> syntax will not be supported starting from April 1, 2022.";
92
+ if (today < warningDate) {
93
+ (_b = process.logger) === null || _b === void 0 ? void 0 : _b.info(message);
94
+ }
95
+ else if (today < deprecationDate) {
96
+ (_c = process.logger) === null || _c === void 0 ? void 0 : _c.warn(message);
284
97
  }
285
- finally { if (e_1) throw e_1.error; }
98
+ else
99
+ throw new Error('Using <h4> SAS Programs </h4> syntax is deprecated. Please use <h4> SAS Includes </h4> instead.');
286
100
  }
287
- return varsContent;
288
101
  };
@@ -334,16 +334,16 @@ describe('compileTestFile', function () {
334
334
  });
335
335
  describe('isTestFile', function () {
336
336
  it('should return true if test SAS file', function () {
337
- expect(compileTestFile_1.isTestFile('random.test.sas')).toEqual(true);
338
- expect(compileTestFile_1.isTestFile('random.test.SAS')).toEqual(true);
339
- expect(compileTestFile_1.isTestFile('random.test.0.sas')).toEqual(true);
340
- expect(compileTestFile_1.isTestFile('random.test.10.sas')).toEqual(true);
337
+ expect(utils_1.isTestFile('random.test.sas')).toEqual(true);
338
+ expect(utils_1.isTestFile('random.test.SAS')).toEqual(true);
339
+ expect(utils_1.isTestFile('random.test.0.sas')).toEqual(true);
340
+ expect(utils_1.isTestFile('random.test.10.sas')).toEqual(true);
341
341
  });
342
342
  it('should return false if not a test SAS file', function () {
343
- expect(compileTestFile_1.isTestFile('random.test.txt')).toEqual(false);
344
- expect(compileTestFile_1.isTestFile('random.sas')).toEqual(false);
345
- expect(compileTestFile_1.isTestFile('random.0.sas')).toEqual(false);
346
- expect(compileTestFile_1.isTestFile('random.tests.sas')).toEqual(false);
343
+ expect(utils_1.isTestFile('random.test.txt')).toEqual(false);
344
+ expect(utils_1.isTestFile('random.sas')).toEqual(false);
345
+ expect(utils_1.isTestFile('random.0.sas')).toEqual(false);
346
+ expect(utils_1.isTestFile('random.tests.sas')).toEqual(false);
347
347
  });
348
348
  });
349
349
  var copyTestFiles = function (appName) { return __awaiter(void 0, void 0, void 0, function () {
@@ -60,7 +60,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
60
60
  Object.defineProperty(exports, "__esModule", { value: true });
61
61
  var path_1 = __importDefault(require("path"));
62
62
  var utils_1 = require("@sasjs/utils");
63
- var internalModule = __importStar(require("../internal/config"));
63
+ var internalModule = __importStar(require("@sasjs/utils/sasjsCli/getInitTerm"));
64
64
  var test_1 = require("../../../utils/test");
65
65
  var compileJobFile_1 = require("../internal/compileJobFile");
66
66
  var utils_2 = require("@sasjs/utils");
@@ -106,13 +106,13 @@ describe('compileJobFile', function () {
106
106
  return __generator(this, function (_a) {
107
107
  switch (_a.label) {
108
108
  case 0:
109
- jest.spyOn(internalModule, 'getJobInit').mockImplementation(function () {
109
+ jest.spyOn(internalModule, 'getInit').mockImplementation(function () {
110
110
  return Promise.resolve({
111
111
  content: "\n* JobInit start;\n" + fakeJobInit + "\n* JobInit end;",
112
112
  filePath: ''
113
113
  });
114
114
  });
115
- jest.spyOn(internalModule, 'getJobTerm').mockImplementation(function () {
115
+ jest.spyOn(internalModule, 'getTerm').mockImplementation(function () {
116
116
  return Promise.resolve({
117
117
  content: "\n* JobTerm start;\n" + fakeJobTerm + "\n* JobTerm end;",
118
118
  filePath: ''
@@ -60,7 +60,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
60
60
  Object.defineProperty(exports, "__esModule", { value: true });
61
61
  var path_1 = __importDefault(require("path"));
62
62
  var utils_1 = require("@sasjs/utils");
63
- var internalModule = __importStar(require("../internal/config"));
63
+ var internalModule = __importStar(require("@sasjs/utils/sasjsCli/getInitTerm"));
64
64
  var test_1 = require("../../../utils/test");
65
65
  var compileServiceFile_1 = require("../internal/compileServiceFile");
66
66
  var utils_2 = require("@sasjs/utils");
@@ -107,13 +107,13 @@ describe('compileServiceFile', function () {
107
107
  return __generator(this, function (_a) {
108
108
  switch (_a.label) {
109
109
  case 0:
110
- jest.spyOn(internalModule, 'getServiceInit').mockImplementation(function () {
110
+ jest.spyOn(internalModule, 'getInit').mockImplementation(function () {
111
111
  return Promise.resolve({
112
112
  content: "\n* ServiceInit start;\n" + fakeJobInit + "\n* ServiceInit end;",
113
113
  filePath: ''
114
114
  });
115
115
  });
116
- jest.spyOn(internalModule, 'getServiceTerm').mockImplementation(function () {
116
+ jest.spyOn(internalModule, 'getTerm').mockImplementation(function () {
117
117
  return Promise.resolve({
118
118
  content: "\n* ServiceTerm start;\n" + fakeJobTerm + "\n* ServiceTerm end;",
119
119
  filePath: ''