@sasjs/cli 3.8.9 → 3.10.1

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 (27) hide show
  1. package/build/commands/build/build.js +33 -45
  2. package/build/commands/compile/compile.d.ts +2 -1
  3. package/build/commands/compile/compile.js +26 -20
  4. package/build/commands/compile/compileSingleFile.js +9 -4
  5. package/build/commands/compile/internal/compileJobFile.d.ts +2 -1
  6. package/build/commands/compile/internal/compileJobFile.js +2 -2
  7. package/build/commands/compile/internal/compileServiceFile.d.ts +2 -1
  8. package/build/commands/compile/internal/compileServiceFile.js +2 -2
  9. package/build/commands/compile/internal/compileTestFile.d.ts +2 -2
  10. package/build/commands/compile/internal/compileTestFile.js +3 -2
  11. package/build/commands/compile/internal/loadDependencies.d.ts +3 -2
  12. package/build/commands/compile/internal/loadDependencies.js +37 -16
  13. package/build/commands/compile/internal/spec/compileTestFile.spec.js +2 -2
  14. package/build/commands/compile/spec/compileJobFile.spec.js +6 -4
  15. package/build/commands/compile/spec/compileServiceFile.spec.js +6 -4
  16. package/build/commands/compile/spec/loadDependencies.spec.js +38 -32
  17. package/build/commands/deploy/deploy.js +44 -39
  18. package/build/commands/docs/generateDocs.js +3 -7
  19. package/build/commands/docs/internal/getFileInputs.js +1 -1
  20. package/build/commands/docs/internal/getFileOutputs.js +1 -1
  21. package/build/commands/web/web.js +34 -24
  22. package/build/utils/displayResult.js +1 -1
  23. package/build/utils/spec/removeComments.spec.d.ts +1 -1
  24. package/build/utils/spec/removeComments.spec.js +2 -1
  25. package/build/utils/utils.d.ts +0 -1
  26. package/build/utils/utils.js +2 -4
  27. package/package.json +2 -2
@@ -113,78 +113,66 @@ function build(target) {
113
113
  }
114
114
  exports.build = build;
115
115
  function createFinalSasFiles(target) {
116
- var _a;
116
+ var _a, _b, _c, _d, _e, _f, _g;
117
117
  return __awaiter(this, void 0, void 0, function () {
118
- var streamConfig;
119
- return __generator(this, function (_b) {
120
- switch (_b.label) {
118
+ var streamConfig, streamWeb, buildConfig, serverType, name, macroFolders, buildOutputFileName, buildDestinationFolder, finalSasFileContent, finalFilePath, finalFilePathJSON, buildInfo, buildInit, buildTerm, macroCorePath, dependencyFilePaths, dependenciesContent, _h, folderContent, folderContentJSON;
119
+ return __generator(this, function (_j) {
120
+ switch (_j.label) {
121
121
  case 0:
122
122
  (_a = process.logger) === null || _a === void 0 ? void 0 : _a.info('Creating output SAS and JSON files.');
123
123
  return [4 /*yield*/, (0, config_1.getStreamConfig)(target)];
124
124
  case 1:
125
- streamConfig = _b.sent();
126
- return [4 /*yield*/, createFinalSasFile(target, streamConfig)];
127
- case 2:
128
- _b.sent();
129
- return [2 /*return*/];
130
- }
131
- });
132
- });
133
- }
134
- function createFinalSasFile(target, streamConfig) {
135
- var _a, _b, _c, _d, _e, _f;
136
- return __awaiter(this, void 0, void 0, function () {
137
- var streamWeb, buildConfig, serverType, name, macroFolders, buildOutputFileName, buildDestinationFolder, finalSasFileContent, finalFilePath, finalFilePathJSON, buildInfo, buildInit, buildTerm, macroCorePath, dependencyFilePaths, dependenciesContent, _g, folderContent, folderContentJSON;
138
- return __generator(this, function (_h) {
139
- switch (_h.label) {
140
- case 0:
141
- streamWeb = (_a = streamConfig.streamWeb) !== null && _a !== void 0 ? _a : false;
125
+ streamConfig = _j.sent();
126
+ streamWeb = (_b = streamConfig.streamWeb) !== null && _b !== void 0 ? _b : false;
142
127
  buildConfig = target.buildConfig, serverType = target.serverType, name = target.name;
143
128
  return [4 /*yield*/, (0, config_1.getMacroFolders)(target)];
144
- case 1:
145
- macroFolders = _h.sent();
146
- buildOutputFileName = (_b = buildConfig === null || buildConfig === void 0 ? void 0 : buildConfig.buildOutputFileName) !== null && _b !== void 0 ? _b : "".concat(name, ".sas");
129
+ case 2:
130
+ macroFolders = _j.sent();
131
+ buildOutputFileName = (_c = buildConfig === null || buildConfig === void 0 ? void 0 : buildConfig.buildOutputFileName) !== null && _c !== void 0 ? _c : "".concat(name, ".sas");
147
132
  buildDestinationFolder = process.sasjsConstants.buildDestinationFolder;
148
133
  finalSasFileContent = '';
149
134
  finalFilePath = path_1.default.join(buildDestinationFolder, buildOutputFileName);
150
135
  finalFilePathJSON = path_1.default.join(buildDestinationFolder, "".concat(name, ".json"));
151
136
  return [4 /*yield*/, getBuildInfo(target, streamWeb)];
152
- case 2:
153
- buildInfo = _h.sent();
137
+ case 3:
138
+ buildInfo = _j.sent();
154
139
  finalSasFileContent += "\n".concat(buildInfo);
155
140
  return [4 /*yield*/, (0, config_2.getBuildInit)(target)];
156
- case 3:
157
- buildInit = _h.sent();
158
- return [4 /*yield*/, (0, config_2.getBuildTerm)(target)];
159
141
  case 4:
160
- buildTerm = _h.sent();
142
+ buildInit = _j.sent();
143
+ return [4 /*yield*/, (0, config_2.getBuildTerm)(target)];
144
+ case 5:
145
+ buildTerm = _j.sent();
161
146
  macroCorePath = (0, config_1.getMacroCorePath)();
162
147
  return [4 /*yield*/, (0, utils_1.getDependencyPaths)("".concat(buildTerm, "\n").concat(buildInit), macroFolders, macroCorePath)];
163
- case 5:
164
- dependencyFilePaths = _h.sent();
165
- return [4 /*yield*/, getDependencies(dependencyFilePaths)];
166
148
  case 6:
167
- dependenciesContent = _h.sent();
149
+ dependencyFilePaths = _j.sent();
150
+ return [4 /*yield*/, getDependencies(dependencyFilePaths)];
151
+ case 7:
152
+ dependenciesContent = _j.sent();
168
153
  finalSasFileContent += "\n".concat(dependenciesContent, "\n\n").concat(buildInit, "\n");
169
154
  return [4 /*yield*/, getFolderContent(serverType)];
170
- case 7:
171
- _g = _h.sent(), folderContent = _g.folderContent, folderContentJSON = _g.folderContentJSON;
155
+ case 8:
156
+ _h = _j.sent(), folderContent = _h.folderContent, folderContentJSON = _h.folderContentJSON;
172
157
  finalSasFileContent += "\n".concat(folderContent);
173
158
  finalSasFileContent += "\n".concat(buildTerm);
174
159
  if (streamWeb) {
175
- finalSasFileContent += (0, getLaunchPageCode_1.getLaunchPageCode)(target.serverType, streamConfig.streamServiceName);
160
+ if (target.serverType === utils_1.ServerType.SasViya ||
161
+ target.serverType === utils_1.ServerType.Sas9) {
162
+ finalSasFileContent += (0, getLaunchPageCode_1.getLaunchPageCode)(target.serverType, streamConfig.streamServiceName);
163
+ }
176
164
  }
177
165
  finalSasFileContent = (0, utils_2.removeComments)(finalSasFileContent);
178
- (_c = process.logger) === null || _c === void 0 ? void 0 : _c.debug("Creating file ".concat(finalFilePath, " ."));
166
+ (_d = process.logger) === null || _d === void 0 ? void 0 : _d.debug("Creating file ".concat(finalFilePath, " ."));
179
167
  return [4 /*yield*/, (0, utils_1.createFile)(finalFilePath, finalSasFileContent)];
180
- case 8:
181
- _h.sent();
182
- (_d = process.logger) === null || _d === void 0 ? void 0 : _d.success("File ".concat(finalFilePath, " has been created."));
183
- (_e = process.logger) === null || _e === void 0 ? void 0 : _e.debug("Creating file ".concat(finalFilePathJSON, " ."));
184
- return [4 /*yield*/, (0, utils_1.createFile)(finalFilePathJSON, JSON.stringify(folderContentJSON, null, 1))];
185
168
  case 9:
186
- _h.sent();
187
- (_f = process.logger) === null || _f === void 0 ? void 0 : _f.success("File ".concat(finalFilePathJSON, " has been created."));
169
+ _j.sent();
170
+ (_e = process.logger) === null || _e === void 0 ? void 0 : _e.success("File ".concat(finalFilePath, " has been created."));
171
+ (_f = process.logger) === null || _f === void 0 ? void 0 : _f.debug("Creating file ".concat(finalFilePathJSON, " ."));
172
+ return [4 /*yield*/, (0, utils_1.createFile)(finalFilePathJSON, JSON.stringify(folderContentJSON, null, 1))];
173
+ case 10:
174
+ _j.sent();
175
+ (_g = process.logger) === null || _g === void 0 ? void 0 : _g.success("File ".concat(finalFilePathJSON, " has been created."));
188
176
  return [2 /*return*/];
189
177
  }
190
178
  });
@@ -1,4 +1,5 @@
1
+ import { CompileTree } from '@sasjs/utils';
1
2
  import { Target } from '@sasjs/utils/types';
2
3
  export declare function compile(target: Target, forceCompile?: boolean): Promise<void>;
3
4
  export declare function copyFilesToBuildFolder(target: Target): Promise<void>;
4
- export declare function compileJobsServicesTests(target: Target): Promise<void>;
5
+ export declare function compileJobsServicesTests(target: Target, compileTree: CompileTree): Promise<void>;
@@ -82,11 +82,12 @@ var compileServiceFile_1 = require("./internal/compileServiceFile");
82
82
  var compileJobFile_1 = require("./internal/compileJobFile");
83
83
  var compileTestFile_1 = require("./internal/compileTestFile");
84
84
  var getDestinationPath_1 = require("./internal/getDestinationPath");
85
+ var loadDependencies_1 = require("./internal/loadDependencies");
85
86
  function compile(target, forceCompile) {
86
87
  var _a, _b;
87
88
  if (forceCompile === void 0) { forceCompile = false; }
88
89
  return __awaiter(this, void 0, void 0, function () {
89
- var result, macroFolders, programFolders_1, buildMacroTestFolder_1, macroTestFiles;
90
+ var result, compileTree, macroFolders, programFolders_1, buildMacroTestFolder_1, macroTestFiles;
90
91
  var _this = this;
91
92
  return __generator(this, function (_c) {
92
93
  switch (_c.label) {
@@ -108,7 +109,8 @@ function compile(target, forceCompile) {
108
109
  })];
109
110
  case 2:
110
111
  _c.sent();
111
- return [4 /*yield*/, compileModule.compileJobsServicesTests(target)];
112
+ compileTree = (0, loadDependencies_1.getCompileTree)(target);
113
+ return [4 /*yield*/, compileModule.compileJobsServicesTests(target, compileTree)];
112
114
  case 3:
113
115
  _c.sent();
114
116
  return [4 /*yield*/, (0, config_1.getMacroFolders)(target)];
@@ -136,17 +138,20 @@ function compile(target, forceCompile) {
136
138
  macroTestFiles = _c.sent();
137
139
  return [4 /*yield*/, (0, utils_1.asyncForEach)(macroTestFiles, function (macroTestFile) { return __awaiter(_this, void 0, void 0, function () {
138
140
  return __generator(this, function (_a) {
139
- return [2 /*return*/, (0, compileServiceFile_1.compileServiceFile)(target, path_1.default.join(buildMacroTestFolder_1, macroTestFile), macroFolders, programFolders_1)];
141
+ return [2 /*return*/, (0, compileServiceFile_1.compileServiceFile)(target, path_1.default.join(buildMacroTestFolder_1, macroTestFile), macroFolders, programFolders_1, undefined, compileTree)];
140
142
  });
141
143
  }); })];
142
144
  case 10:
143
145
  _c.sent();
144
146
  _c.label = 11;
145
- case 11: return [4 /*yield*/, (0, compileTestFile_1.compileTestFlow)(target).catch(function (err) { var _a; return (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('Test flow compilation has failed.'); })];
147
+ case 11: return [4 /*yield*/, compileTree.saveTree()];
146
148
  case 12:
147
149
  _c.sent();
148
- return [4 /*yield*/, compileWeb(target)];
150
+ return [4 /*yield*/, (0, compileTestFile_1.compileTestFlow)(target).catch(function (err) { var _a; return (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('Test flow compilation has failed.'); })];
149
151
  case 13:
152
+ _c.sent();
153
+ return [4 /*yield*/, compileWeb(target)];
154
+ case 14:
150
155
  _c.sent();
151
156
  return [2 /*return*/];
152
157
  }
@@ -221,7 +226,7 @@ function copyFilesToBuildFolder(target) {
221
226
  });
222
227
  }
223
228
  exports.copyFilesToBuildFolder = copyFilesToBuildFolder;
224
- function compileJobsServicesTests(target) {
229
+ function compileJobsServicesTests(target, compileTree) {
225
230
  var _a;
226
231
  return __awaiter(this, void 0, void 0, function () {
227
232
  var serviceFolders, jobFolders, macroFolders_1, programFolders_2, testSetUp, testTearDown, error_2;
@@ -249,20 +254,20 @@ function compileJobsServicesTests(target) {
249
254
  case 6:
250
255
  testTearDown = _b.sent();
251
256
  if (!testSetUp) return [3 /*break*/, 8];
252
- return [4 /*yield*/, (0, compileTestFile_1.compileTestFile)(target, testSetUp, '', true, false).catch(function (err) { var _a; return (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('Test set up compilation has failed.'); })];
257
+ return [4 /*yield*/, (0, compileTestFile_1.compileTestFile)(target, testSetUp, '', true, false, compileTree).catch(function (err) { var _a; return (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('Test set up compilation has failed.'); })];
253
258
  case 7:
254
259
  _b.sent();
255
260
  _b.label = 8;
256
261
  case 8:
257
262
  if (!testTearDown) return [3 /*break*/, 10];
258
- return [4 /*yield*/, (0, compileTestFile_1.compileTestFile)(target, testTearDown, '', true, false).catch(function (err) { var _a; return (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('Test tear down compilation has failed.'); })];
263
+ return [4 /*yield*/, (0, compileTestFile_1.compileTestFile)(target, testTearDown, '', true, false, compileTree).catch(function (err) { var _a; return (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('Test tear down compilation has failed.'); })];
259
264
  case 9:
260
265
  _b.sent();
261
266
  _b.label = 10;
262
267
  case 10: return [4 /*yield*/, (0, utils_1.asyncForEach)(serviceFolders, function (serviceFolder) { return __awaiter(_this, void 0, void 0, function () {
263
268
  return __generator(this, function (_a) {
264
269
  switch (_a.label) {
265
- case 0: return [4 /*yield*/, compileServiceFolder(target, serviceFolder, macroFolders_1, programFolders_2)];
270
+ case 0: return [4 /*yield*/, compileServiceFolder(target, serviceFolder, macroFolders_1, programFolders_2, compileTree)];
266
271
  case 1:
267
272
  _a.sent();
268
273
  return [2 /*return*/];
@@ -274,7 +279,7 @@ function compileJobsServicesTests(target) {
274
279
  return [4 /*yield*/, (0, utils_1.asyncForEach)(jobFolders, function (jobFolder) { return __awaiter(_this, void 0, void 0, function () {
275
280
  return __generator(this, function (_a) {
276
281
  switch (_a.label) {
277
- case 0: return [4 /*yield*/, compileJobFolder(target, jobFolder, macroFolders_1, programFolders_2)];
282
+ case 0: return [4 /*yield*/, compileJobFolder(target, jobFolder, macroFolders_1, programFolders_2, compileTree)];
278
283
  case 1:
279
284
  _a.sent();
280
285
  return [2 /*return*/];
@@ -319,7 +324,7 @@ function recreateBuildFolder() {
319
324
  });
320
325
  });
321
326
  }
322
- var compileServiceFolder = function (target, serviceFolder, macroFolders, programFolders) { return __awaiter(void 0, void 0, void 0, function () {
327
+ var compileServiceFolder = function (target, serviceFolder, macroFolders, programFolders, compileTree) { return __awaiter(void 0, void 0, void 0, function () {
323
328
  var destinationPath, subFolders, filesNamesInPath;
324
329
  return __generator(this, function (_a) {
325
330
  switch (_a.label) {
@@ -338,11 +343,11 @@ var compileServiceFolder = function (target, serviceFolder, macroFolders, progra
338
343
  case 0:
339
344
  filePath = path_1.default.join(destinationPath, fileName);
340
345
  if (!(0, utils_1.isTestFile)(filePath)) return [3 /*break*/, 2];
341
- return [4 /*yield*/, (0, compileTestFile_1.compileTestFile)(target, filePath, '', false)];
346
+ return [4 /*yield*/, (0, compileTestFile_1.compileTestFile)(target, filePath, '', false, undefined, compileTree)];
342
347
  case 1:
343
348
  _a.sent();
344
349
  return [3 /*break*/, 4];
345
- case 2: return [4 /*yield*/, (0, compileServiceFile_1.compileServiceFile)(target, filePath, macroFolders, programFolders)];
350
+ case 2: return [4 /*yield*/, (0, compileServiceFile_1.compileServiceFile)(target, filePath, macroFolders, programFolders, undefined, compileTree)];
346
351
  case 3:
347
352
  _a.sent();
348
353
  _a.label = 4;
@@ -366,11 +371,11 @@ var compileServiceFolder = function (target, serviceFolder, macroFolders, progra
366
371
  case 0:
367
372
  filePath = path_1.default.join(destinationPath, subFolder, fileName);
368
373
  if (!(0, utils_1.isTestFile)(filePath)) return [3 /*break*/, 2];
369
- return [4 /*yield*/, (0, compileTestFile_1.compileTestFile)(target, filePath, '', false)];
374
+ return [4 /*yield*/, (0, compileTestFile_1.compileTestFile)(target, filePath, '', false, undefined, compileTree)];
370
375
  case 1:
371
376
  _a.sent();
372
377
  return [3 /*break*/, 4];
373
- case 2: return [4 /*yield*/, (0, compileServiceFile_1.compileServiceFile)(target, filePath, macroFolders, programFolders)];
378
+ case 2: return [4 /*yield*/, (0, compileServiceFile_1.compileServiceFile)(target, filePath, macroFolders, programFolders, undefined, compileTree)];
374
379
  case 3:
375
380
  _a.sent();
376
381
  _a.label = 4;
@@ -386,11 +391,12 @@ var compileServiceFolder = function (target, serviceFolder, macroFolders, progra
386
391
  }); })];
387
392
  case 4:
388
393
  _a.sent();
394
+ compileTree.saveTree();
389
395
  return [2 /*return*/];
390
396
  }
391
397
  });
392
398
  }); };
393
- var compileJobFolder = function (target, jobFolder, macroFolders, programFolders) { return __awaiter(void 0, void 0, void 0, function () {
399
+ var compileJobFolder = function (target, jobFolder, macroFolders, programFolders, compileTree) { return __awaiter(void 0, void 0, void 0, function () {
394
400
  var destinationPath, subFolders, filesNamesInPath;
395
401
  return __generator(this, function (_a) {
396
402
  switch (_a.label) {
@@ -409,11 +415,11 @@ var compileJobFolder = function (target, jobFolder, macroFolders, programFolders
409
415
  case 0:
410
416
  filePath = path_1.default.join(destinationPath, fileName);
411
417
  if (!(0, utils_1.isTestFile)(fileName)) return [3 /*break*/, 2];
412
- return [4 /*yield*/, (0, compileTestFile_1.compileTestFile)(target, filePath, '', false)];
418
+ return [4 /*yield*/, (0, compileTestFile_1.compileTestFile)(target, filePath, '', false, undefined, compileTree)];
413
419
  case 1:
414
420
  _a.sent();
415
421
  return [3 /*break*/, 4];
416
- case 2: return [4 /*yield*/, (0, compileJobFile_1.compileJobFile)(target, filePath, macroFolders, programFolders)];
422
+ case 2: return [4 /*yield*/, (0, compileJobFile_1.compileJobFile)(target, filePath, macroFolders, programFolders, undefined, compileTree)];
417
423
  case 3:
418
424
  _a.sent();
419
425
  _a.label = 4;
@@ -437,11 +443,11 @@ var compileJobFolder = function (target, jobFolder, macroFolders, programFolders
437
443
  case 0:
438
444
  filePath = path_1.default.join(destinationPath, subFolder, fileName);
439
445
  if (!(0, utils_1.isTestFile)(filePath)) return [3 /*break*/, 2];
440
- return [4 /*yield*/, (0, compileTestFile_1.compileTestFile)(target, filePath, '', false)];
446
+ return [4 /*yield*/, (0, compileTestFile_1.compileTestFile)(target, filePath, '', false, undefined, compileTree)];
441
447
  case 1:
442
448
  _a.sent();
443
449
  return [3 /*break*/, 4];
444
- case 2: return [4 /*yield*/, (0, compileJobFile_1.compileJobFile)(target, filePath, macroFolders, programFolders)];
450
+ case 2: return [4 /*yield*/, (0, compileJobFile_1.compileJobFile)(target, filePath, macroFolders, programFolders, undefined, compileTree)];
445
451
  case 3:
446
452
  _a.sent();
447
453
  _a.label = 4;
@@ -46,12 +46,13 @@ var utils_1 = require("@sasjs/utils");
46
46
  var compileServiceFile_1 = require("./internal/compileServiceFile");
47
47
  var compileJobFile_1 = require("./internal/compileJobFile");
48
48
  var identifySasFile_1 = require("./internal/identifySasFile");
49
+ var loadDependencies_1 = require("./internal/loadDependencies");
49
50
  function compileSingleFile(target, subCommand, source, output, insertProgramVar) {
50
51
  var _a;
51
52
  if (subCommand === void 0) { subCommand = 'identify'; }
52
53
  if (insertProgramVar === void 0) { insertProgramVar = false; }
53
54
  return __awaiter(this, void 0, void 0, function () {
54
- var subCommands, commandExample, sourcePath, outputPathParts, leafFolderName, parentOutputFolder, pathExists, sourceFileName, destinationPath, sourceFileNameWithoutExt, macroFolders, programFolders, psMaxOption, programVar, _b;
55
+ var subCommands, commandExample, sourcePath, outputPathParts, leafFolderName, parentOutputFolder, pathExists, sourceFileName, destinationPath, sourceFileNameWithoutExt, macroFolders, programFolders, psMaxOption, programVar, compileTree, _b;
55
56
  return __generator(this, function (_c) {
56
57
  switch (_c.label) {
57
58
  case 0:
@@ -111,22 +112,26 @@ function compileSingleFile(target, subCommand, source, output, insertProgramVar)
111
112
  programVar = insertProgramVar
112
113
  ? "%let _program=".concat(target.appLoc, "/").concat(subCommand, "s/").concat(leafFolderName, "/").concat(sourceFileNameWithoutExt, ";\n").concat(psMaxOption)
113
114
  : "".concat(psMaxOption);
115
+ compileTree = (0, loadDependencies_1.getCompileTree)(target);
114
116
  _b = subCommand;
115
117
  switch (_b) {
116
118
  case subCommands.service: return [3 /*break*/, 11];
117
119
  case subCommands.job: return [3 /*break*/, 13];
118
120
  }
119
121
  return [3 /*break*/, 15];
120
- case 11: return [4 /*yield*/, (0, compileServiceFile_1.compileServiceFile)(target, destinationPath, macroFolders, programFolders, programVar)];
122
+ case 11: return [4 /*yield*/, (0, compileServiceFile_1.compileServiceFile)(target, destinationPath, macroFolders, programFolders, programVar, compileTree)];
121
123
  case 12:
122
124
  _c.sent();
123
125
  return [3 /*break*/, 16];
124
- case 13: return [4 /*yield*/, (0, compileJobFile_1.compileJobFile)(target, destinationPath, macroFolders, programFolders, programVar)];
126
+ case 13: return [4 /*yield*/, (0, compileJobFile_1.compileJobFile)(target, destinationPath, macroFolders, programFolders, programVar, compileTree)];
125
127
  case 14:
126
128
  _c.sent();
127
129
  return [3 /*break*/, 16];
128
130
  case 15: return [3 /*break*/, 16];
129
- case 16: return [2 /*return*/, { destinationPath: destinationPath }];
131
+ case 16: return [4 /*yield*/, compileTree.saveTree()];
132
+ case 17:
133
+ _c.sent();
134
+ return [2 /*return*/, { destinationPath: destinationPath }];
130
135
  }
131
136
  });
132
137
  });
@@ -1,2 +1,3 @@
1
1
  import { Target } from '@sasjs/utils/types';
2
- export declare function compileJobFile(target: Target, filePath: string, macroFolders: string[], programFolders: string[], programVar?: string): Promise<void>;
2
+ import { CompileTree } from '@sasjs/utils';
3
+ export declare function compileJobFile(target: Target, filePath: string, macroFolders: string[], programFolders: string[], programVar: string | undefined, compileTree: CompileTree): Promise<void>;
@@ -39,13 +39,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.compileJobFile = void 0;
40
40
  var utils_1 = require("@sasjs/utils");
41
41
  var loadDependencies_1 = require("./loadDependencies");
42
- function compileJobFile(target, filePath, macroFolders, programFolders, programVar) {
42
+ function compileJobFile(target, filePath, macroFolders, programFolders, programVar, compileTree) {
43
43
  if (programVar === void 0) { programVar = ''; }
44
44
  return __awaiter(this, void 0, void 0, function () {
45
45
  var dependencies;
46
46
  return __generator(this, function (_a) {
47
47
  switch (_a.label) {
48
- case 0: return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, filePath, macroFolders, programFolders, (0, utils_1.isTestFile)(filePath) ? utils_1.SASJsFileType.test : utils_1.SASJsFileType.job)];
48
+ case 0: return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, filePath, macroFolders, programFolders, (0, utils_1.isTestFile)(filePath) ? utils_1.SASJsFileType.test : utils_1.SASJsFileType.job, compileTree)];
49
49
  case 1:
50
50
  dependencies = _a.sent();
51
51
  dependencies = "".concat(programVar ? programVar + '\n' : '').concat(dependencies);
@@ -1,3 +1,4 @@
1
+ import { CompileTree } from '@sasjs/utils';
1
2
  import { Target, ServerType } from '@sasjs/utils/types';
2
- export declare function compileServiceFile(target: Target, filePath: string, macroFolders: string[], programFolders: string[], programVar?: string): Promise<void>;
3
+ export declare function compileServiceFile(target: Target, filePath: string, macroFolders: string[], programFolders: string[], programVar: string | undefined, compileTree: CompileTree): Promise<void>;
3
4
  export declare function getPreCodeForServicePack(serverType: ServerType): Promise<string>;
@@ -43,13 +43,13 @@ var types_1 = require("@sasjs/utils/types");
43
43
  var error_1 = require("@sasjs/utils/error");
44
44
  var loadDependencies_1 = require("./loadDependencies");
45
45
  var getServerType_1 = require("./getServerType");
46
- function compileServiceFile(target, filePath, macroFolders, programFolders, programVar) {
46
+ function compileServiceFile(target, filePath, macroFolders, programFolders, programVar, compileTree) {
47
47
  if (programVar === void 0) { programVar = ''; }
48
48
  return __awaiter(this, void 0, void 0, function () {
49
49
  var dependencies, serverType, preCode;
50
50
  return __generator(this, function (_a) {
51
51
  switch (_a.label) {
52
- case 0: return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, filePath, macroFolders, programFolders, (0, utils_1.isTestFile)(filePath) ? types_1.SASJsFileType.test : types_1.SASJsFileType.service)];
52
+ case 0: return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, filePath, macroFolders, programFolders, (0, utils_1.isTestFile)(filePath) ? types_1.SASJsFileType.test : types_1.SASJsFileType.service, compileTree)];
53
53
  case 1:
54
54
  dependencies = _a.sent();
55
55
  return [4 /*yield*/, (0, getServerType_1.getServerType)(target)];
@@ -1,6 +1,6 @@
1
1
  import { TestFlow } from '../../../types';
2
- import { Target, Configuration } from '@sasjs/utils';
3
- export declare function compileTestFile(target: Target, filePath: string, testVar?: string, saveToRoot?: boolean, removeOriginalFile?: boolean): Promise<void>;
2
+ import { Target, Configuration, CompileTree } from '@sasjs/utils';
3
+ export declare function compileTestFile(target: Target, filePath: string, testVar: string | undefined, saveToRoot: boolean | undefined, removeOriginalFile: boolean | undefined, compileTree: CompileTree): Promise<void>;
4
4
  export declare function moveTestFile(filePath: string): Promise<void>;
5
5
  export declare function copyTestMacroFiles(folderAbsolutePath: string): Promise<void>;
6
6
  export declare const compileTestFlow: (target: Target, config?: Configuration | undefined) => Promise<TestFlow | undefined>;
@@ -77,7 +77,7 @@ var testsBuildFolder = function () {
77
77
  return path_1.default.join(process.projectDir, 'sasjsbuild', 'tests');
78
78
  };
79
79
  var getFileName = function (filePath) { return path_1.default.parse(filePath).base; };
80
- function compileTestFile(target, filePath, testVar, saveToRoot, removeOriginalFile) {
80
+ function compileTestFile(target, filePath, testVar, saveToRoot, removeOriginalFile, compileTree) {
81
81
  if (testVar === void 0) { testVar = ''; }
82
82
  if (saveToRoot === void 0) { saveToRoot = true; }
83
83
  if (removeOriginalFile === void 0) { removeOriginalFile = true; }
@@ -93,7 +93,8 @@ function compileTestFile(target, filePath, testVar, saveToRoot, removeOriginalFi
93
93
  case 1:
94
94
  _b = _b.concat([_c.sent()]);
95
95
  return [4 /*yield*/, (0, config_1.getProgramFolders)(target)];
96
- case 2: return [4 /*yield*/, _a.apply(void 0, _b.concat([_c.sent(), utils_1.SASJsFileType.test]))];
96
+ case 2: return [4 /*yield*/, _a.apply(void 0, _b.concat([_c.sent(), utils_1.SASJsFileType.test,
97
+ compileTree]))];
97
98
  case 3:
98
99
  dependencies = _c.sent();
99
100
  return [4 /*yield*/, (0, compileServiceFile_1.getPreCodeForServicePack)(target.serverType)];
@@ -1,2 +1,3 @@
1
- import { Target, SASJsFileType } from '@sasjs/utils';
2
- export declare function loadDependencies(target: Target, filePath: string, macroFolders: string[], programFolders: string[], type: SASJsFileType): Promise<string>;
1
+ import { Target, SASJsFileType, CompileTree } from '@sasjs/utils';
2
+ export declare function loadDependencies(target: Target, filePath: string, macroFolders: string[], programFolders: string[], type: SASJsFileType, compileTree: CompileTree): Promise<string>;
3
+ export declare const getCompileTree: (target: Target) => CompileTree;
@@ -35,27 +35,43 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
36
  }
37
37
  };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
38
41
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.loadDependencies = void 0;
42
+ exports.getCompileTree = exports.loadDependencies = void 0;
40
43
  var utils_1 = require("@sasjs/utils");
41
44
  var config_1 = require("../../../utils/config");
42
- function loadDependencies(target, filePath, macroFolders, programFolders, type) {
45
+ var path_1 = __importDefault(require("path"));
46
+ function loadDependencies(target, filePath, macroFolders, programFolders, type, compileTree) {
43
47
  var _a;
44
48
  return __awaiter(this, void 0, void 0, function () {
45
- var fileContent, configuration, _b, buildSourceFolder, macroCorePath, binaryFolders;
49
+ var fileContent, leaf, configuration, _b, buildSourceFolder, macroCorePath, binaryFolders;
46
50
  return __generator(this, function (_c) {
47
51
  switch (_c.label) {
48
52
  case 0:
49
53
  (_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Loading dependencies for ".concat(filePath));
50
- return [4 /*yield*/, (0, utils_1.readFile)(filePath)];
51
- case 1:
52
- fileContent = _c.sent();
53
- return [4 /*yield*/, (0, config_1.getLocalOrGlobalConfig)()];
54
+ fileContent = '';
55
+ if (!(compileTree && Object.keys(compileTree).length)) return [3 /*break*/, 4];
56
+ leaf = compileTree.getLeaf(filePath);
57
+ if (!leaf) return [3 /*break*/, 1];
58
+ fileContent = leaf.content;
59
+ return [3 /*break*/, 3];
60
+ case 1: return [4 /*yield*/, (0, utils_1.readFile)(filePath)];
54
61
  case 2:
62
+ fileContent = _c.sent();
63
+ _c.label = 3;
64
+ case 3: return [3 /*break*/, 6];
65
+ case 4: return [4 /*yield*/, (0, utils_1.readFile)(filePath)];
66
+ case 5:
67
+ fileContent = _c.sent();
68
+ _c.label = 6;
69
+ case 6: return [4 /*yield*/, (0, config_1.getLocalOrGlobalConfig)()];
70
+ case 7:
55
71
  configuration = (_c.sent()).configuration;
56
72
  _b = process.sasjsConstants, buildSourceFolder = _b.buildSourceFolder, macroCorePath = _b.macroCorePath;
57
73
  return [4 /*yield*/, (0, config_1.getBinaryFolders)(target)];
58
- case 3:
74
+ case 8:
59
75
  binaryFolders = _c.sent();
60
76
  headerSyntaxNotices(fileContent);
61
77
  return [4 /*yield*/, (0, utils_1.loadDependenciesFile)({
@@ -68,9 +84,10 @@ function loadDependencies(target, filePath, macroFolders, programFolders, type)
68
84
  programFolders: programFolders,
69
85
  buildSourceFolder: buildSourceFolder,
70
86
  macroCorePath: macroCorePath,
71
- binaryFolders: binaryFolders
87
+ binaryFolders: binaryFolders,
88
+ compileTree: compileTree
72
89
  })];
73
- case 4: return [2 /*return*/, _c.sent()];
90
+ case 9: return [2 /*return*/, _c.sent()];
74
91
  }
75
92
  });
76
93
  });
@@ -78,21 +95,21 @@ function loadDependencies(target, filePath, macroFolders, programFolders, type)
78
95
  exports.loadDependencies = loadDependencies;
79
96
  var headerSyntaxNotices = function (fileContent) {
80
97
  var _a, _b, _c;
81
- if (fileContent.includes('<h4> Dependencies </h4>')) {
98
+ if (fileContent.includes(utils_1.DependencyHeader.DeprecatedMacro)) {
82
99
  var deprecationDate = new Date(2021, 10, 2);
83
100
  var today = new Date();
84
101
  if (today < deprecationDate) {
85
- (_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.");
102
+ (_a = process.logger) === null || _a === void 0 ? void 0 : _a.warn("Please use ".concat(utils_1.DependencyHeader.Macro, " syntax to specify dependencies. Specifying dependencies with a ").concat(utils_1.DependencyHeader.DeprecatedMacro, " syntax will not be supported starting from November 1, 2021."));
86
103
  }
87
104
  else {
88
- throw new Error('Using <h4> Dependencies </h4> syntax is deprecated. Please use <h4> SAS Macros </h4> instead.');
105
+ throw new Error("Using ".concat(utils_1.DependencyHeader.DeprecatedMacro, " syntax is deprecated. Please use ").concat(utils_1.DependencyHeader.Macro, " instead."));
89
106
  }
90
107
  }
91
- if (fileContent.includes('<h4> SAS Programs </h4>')) {
108
+ if (fileContent.includes(utils_1.DependencyHeader.DeprecatedInclude)) {
92
109
  var deprecationDate = new Date(2022, 4, 2);
93
110
  var warningDate = new Date(2022, 10, 2);
94
111
  var today = new Date();
95
- 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.";
112
+ var message = "Please use ".concat(utils_1.DependencyHeader.Include, " syntax to specify programs. Specifying programs with a ").concat(utils_1.DependencyHeader.DeprecatedInclude, " syntax will not be supported starting from April 1, 2022.");
96
113
  if (today < warningDate) {
97
114
  (_b = process.logger) === null || _b === void 0 ? void 0 : _b.info(message);
98
115
  }
@@ -100,6 +117,10 @@ var headerSyntaxNotices = function (fileContent) {
100
117
  (_c = process.logger) === null || _c === void 0 ? void 0 : _c.warn(message);
101
118
  }
102
119
  else
103
- throw new Error('Using <h4> SAS Programs </h4> syntax is deprecated. Please use <h4> SAS Includes </h4> instead.');
120
+ throw new Error("Using ".concat(utils_1.DependencyHeader.DeprecatedInclude, " syntax is deprecated. Please use ").concat(utils_1.DependencyHeader.Include, " instead."));
104
121
  }
105
122
  };
123
+ var getCompileTree = function (target) {
124
+ return new utils_1.CompileTree(path_1.default.join(process.sasjsConstants.buildDestinationFolder, "".concat(target === null || target === void 0 ? void 0 : target.name, "_compileTree.json")));
125
+ };
126
+ exports.getCompileTree = getCompileTree;
@@ -129,8 +129,8 @@ describe('compileTestFile', function () {
129
129
  case 2:
130
130
  testFileContent = _a.apply(void 0, [_b.sent()]);
131
131
  testVar = replaceLineBreaks("* Test Variables start;\n\n%let ".concat(Object.keys(target.testConfig.macroVars)[0], "=").concat(Object.values(target.testConfig.macroVars)[0], ";\n\n* Test Variables end;"));
132
- testInit = replaceLineBreaks("* TestInit start;\n/**\n @file\n @brief setting up the test\n\n <h4> SAS Macros </h4>\n**/\n\n%put testing, init;\n* TestInit end;");
133
- testTerm = replaceLineBreaks("* TestTerm start;\n/**\n @file\n @brief ending the test\n\n <h4> SAS Macros </h4>\n**/\n\n%put testing, termed;\n* TestTerm end;");
132
+ testInit = replaceLineBreaks("* TestInit start;\n\n\n%put testing, init;\n* TestInit end;");
133
+ testTerm = replaceLineBreaks("* TestTerm start;\n\n\n%put testing, termed;\n* TestTerm end;");
134
134
  mvWebout = "%macro mv_webout(action,ds,fref=_mvwtemp,dslabel=,fmt=Y,stream=Y,missing=NULL<br> ,showmeta=NO<br>);";
135
135
  expect(testFileContent.indexOf(testVar)).toBeGreaterThan(-1);
136
136
  expect(testFileContent.indexOf(testInit)).toBeGreaterThan(-1);
@@ -65,8 +65,9 @@ var getInitTerm_1 = require("@sasjs/utils/sasjsCli/getInitTerm");
65
65
  var test_1 = require("../../../utils/test");
66
66
  var compileJobFile_1 = require("../internal/compileJobFile");
67
67
  var utils_2 = require("@sasjs/utils");
68
- var fakeJobInit = "/**\n @file\n @brief This code is inserted into the beginning of each Viya Job.\n @details Inserted during the `sasjs compile` step. Add any code here that\n should go at the beginning of every deployed job.\n\n The path to this file should be listed in the `jobInit` property of the\n sasjsconfig file.\n\n <h4> SAS Programs </h4>\n @li test.sas TEST\n\n <h4> SAS Macros </h4>\n @li examplemacro.sas\n\n**/\n\n%example(Job Init is executing!)\n\n%let mylib=WORK;";
69
- var fakeJobTerm = "/**\n @file serviceterm.sas\n @brief this file is called at the end of every service\n @details This file is included at the *end* of every service.\n\n <h4> SAS Macros </h4>\n @li mf_abort.sas\n @li mf_existds.sas\n\n**/\n\n%put service is finishing. Thanks, SASjs!;";
68
+ var loadDependencies_1 = require("../internal/loadDependencies");
69
+ var fakeJobInit = "/**\n @file\n @brief This code is inserted into the beginning of each Viya Job.\n @details Inserted during the `sasjs compile` step. Add any code here that\n should go at the beginning of every deployed job.\n\n The path to this file should be listed in the `jobInit` property of the\n sasjsconfig file.\n\n ".concat(utils_1.DependencyHeader.DeprecatedInclude, "\n @li test.sas TEST\n\n ").concat(utils_1.DependencyHeader.Macro, "\n @li examplemacro.sas\n\n**/\n\n%example(Job Init is executing!)\n\n%let mylib=WORK;");
70
+ var fakeJobTerm = "/**\n @file serviceterm.sas\n @brief this file is called at the end of every service\n @details This file is included at the *end* of every service.\n\n ".concat(utils_1.DependencyHeader.Macro, "\n @li mf_abort.sas\n @li mf_existds.sas\n\n**/\n\n%put service is finishing. Thanks, SASjs!;");
70
71
  var fakeProgramLines = [
71
72
  'filename TEST temp;',
72
73
  'data _null_;',
@@ -103,7 +104,7 @@ describe('compileJobFile', function () {
103
104
  });
104
105
  }); });
105
106
  test('it should compile and create file', function () { return __awaiter(void 0, void 0, void 0, function () {
106
- var filePath, buildPath, destinationPath, compiledContent, macrosToTest;
107
+ var filePath, buildPath, destinationPath, compileTree, compiledContent, macrosToTest;
107
108
  return __generator(this, function (_a) {
108
109
  switch (_a.label) {
109
110
  case 0:
@@ -111,13 +112,14 @@ describe('compileJobFile', function () {
111
112
  filePath = path_1.default.join(__dirname, './service.sas');
112
113
  buildPath = path_1.default.join(process.projectDir, 'sasjsbuild');
113
114
  destinationPath = path_1.default.join(buildPath, 'service.sas');
115
+ compileTree = (0, loadDependencies_1.getCompileTree)(target);
114
116
  return [4 /*yield*/, (0, utils_2.createFolder)(buildPath)];
115
117
  case 1:
116
118
  _a.sent();
117
119
  return [4 /*yield*/, (0, utils_2.copy)(filePath, destinationPath)];
118
120
  case 2:
119
121
  _a.sent();
120
- return [4 /*yield*/, expect((0, compileJobFile_1.compileJobFile)(target, destinationPath, [path_1.default.join(__dirname, './macros')], [path_1.default.join(__dirname, './'), path_1.default.join(__dirname, './services')])).toResolve()];
122
+ return [4 /*yield*/, expect((0, compileJobFile_1.compileJobFile)(target, destinationPath, [path_1.default.join(__dirname, './macros')], [path_1.default.join(__dirname, './'), path_1.default.join(__dirname, './services')], undefined, compileTree)).toResolve()];
121
123
  case 3:
122
124
  _a.sent();
123
125
  return [4 /*yield*/, expect((0, utils_2.fileExists)(destinationPath)).resolves.toEqual(true)];