@sasjs/cli 3.9.0 → 3.10.2

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 (29) hide show
  1. package/build/commands/compile/compile.d.ts +2 -1
  2. package/build/commands/compile/compile.js +26 -20
  3. package/build/commands/compile/compileSingleFile.js +9 -4
  4. package/build/commands/compile/internal/compileJobFile.d.ts +2 -1
  5. package/build/commands/compile/internal/compileJobFile.js +2 -2
  6. package/build/commands/compile/internal/compileServiceFile.d.ts +2 -1
  7. package/build/commands/compile/internal/compileServiceFile.js +2 -2
  8. package/build/commands/compile/internal/compileTestFile.d.ts +2 -2
  9. package/build/commands/compile/internal/compileTestFile.js +3 -2
  10. package/build/commands/compile/internal/loadDependencies.d.ts +3 -2
  11. package/build/commands/compile/internal/loadDependencies.js +37 -16
  12. package/build/commands/compile/internal/spec/compileTestFile.spec.js +2 -2
  13. package/build/commands/compile/spec/compileJobFile.spec.js +6 -4
  14. package/build/commands/compile/spec/compileServiceFile.spec.js +6 -4
  15. package/build/commands/compile/spec/loadDependencies.spec.js +38 -32
  16. package/build/commands/docs/generateDocs.js +3 -7
  17. package/build/commands/docs/internal/getFileInputs.js +1 -1
  18. package/build/commands/docs/internal/getFileOutputs.js +1 -1
  19. package/build/commands/help/help.js +2 -2
  20. package/build/commands/request/request.js +38 -26
  21. package/build/commands/request/spec/request.spec.server.js +155 -68
  22. package/build/commands/testing/test.js +4 -2
  23. package/build/utils/config.js +3 -4
  24. package/build/utils/displayResult.js +1 -1
  25. package/build/utils/spec/removeComments.spec.d.ts +1 -1
  26. package/build/utils/spec/removeComments.spec.js +2 -1
  27. package/build/utils/utils.d.ts +8 -1
  28. package/build/utils/utils.js +42 -4
  29. package/package.json +2 -2
@@ -74,13 +74,14 @@ var utils_1 = require("@sasjs/utils");
74
74
  var internalModule = __importStar(require("@sasjs/utils/sasjsCli/getInitTerm"));
75
75
  var getInitTerm_1 = require("@sasjs/utils/sasjsCli/getInitTerm");
76
76
  var test_1 = require("../../../utils/test");
77
+ var utils_2 = require("../../../utils");
77
78
  var loadDependencies_1 = require("../internal/loadDependencies");
78
- var fakeInit = "/**\n @file serviceinit.sas\n @brief this file is called with every service\n @details This file is included in *every* service, *after* the macros and *before* the service code.\n\n <h4> SAS Macros </h4>\n @li mf_abort.sas\n\n**/\n\noptions\n DATASTMTCHK=ALLKEYWORDS /* some sites have this enabled */\n PS=MAX /* reduce log size slightly */\n;\n%put service is starting!!;";
79
- var fakeTerm = "/**\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!;";
80
- var fakeInit2 = "/**\n @file serviceinit.sas\n @brief this file is called with every service\n @details This file is included in *every* service, *after* the macros and *before* the service code.\n\n <h4> SAS Macros </h4>\n @li mf_abort.sas\n\n**/\n\noptions\n DATASTMTCHK=ALLKEYWORDS /* some sites have this enabled */\n PS=MAX /* reduce log size slightly */\n;\n%put service is starting!!;";
81
- var fakeTerm2 = "/**\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!;";
82
- 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;";
83
- var fakeJobInit2 = "/**\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 Includes </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;";
79
+ var fakeInit = "/**\n @file serviceinit.sas\n @brief this file is called with every service\n @details This file is included in *every* service, *after* the macros and *before* the service code.\n\n ".concat(utils_1.DependencyHeader.Macro, "\n @li mf_abort.sas\n\n**/\n\noptions\n DATASTMTCHK=ALLKEYWORDS /* some sites have this enabled */\n PS=MAX /* reduce log size slightly */\n;\n%put service is starting!!;");
80
+ var fakeTerm = "/**\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!;");
81
+ var fakeInit2 = "/**\n @file serviceinit.sas\n @brief this file is called with every service\n @details This file is included in *every* service, *after* the macros and *before* the service code.\n\n ".concat(utils_1.DependencyHeader.Macro, "\n @li mf_abort.sas\n\n**/\n\noptions\n DATASTMTCHK=ALLKEYWORDS /* some sites have this enabled */\n PS=MAX /* reduce log size slightly */\n;\n%put service is starting!!;");
82
+ var fakeTerm2 = "/**\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!;");
83
+ 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;");
84
+ var fakeJobInit2 = "/**\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.Include, "\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;");
84
85
  var fakeProgramLines = [
85
86
  'filename TEST temp;',
86
87
  'data _null_;',
@@ -132,17 +133,22 @@ describe('loadDependencies', function () {
132
133
  macroVars: {}
133
134
  }, utils_1.ServerType.SasViya);
134
135
  var target = new utils_1.Target(__assign(__assign({}, temp.toJson()), { jobConfig: jobConfig(false), serviceConfig: serviceConfig(false) }));
136
+ var compileTree;
135
137
  beforeAll(function () { return __awaiter(void 0, void 0, void 0, function () {
136
138
  return __generator(this, function (_a) {
137
139
  switch (_a.label) {
138
- case 0: return [4 /*yield*/, (0, test_1.createTestMinimalApp)(__dirname, target.name)];
140
+ case 0: return [4 /*yield*/, (0, utils_2.setConstants)()];
139
141
  case 1:
142
+ _a.sent();
143
+ compileTree = (0, loadDependencies_1.getCompileTree)(target);
144
+ return [4 /*yield*/, (0, test_1.createTestMinimalApp)(__dirname, target.name)];
145
+ case 2:
140
146
  _a.sent();
141
147
  return [4 /*yield*/, (0, test_1.updateConfig)({
142
148
  jobConfig: jobConfig(),
143
149
  serviceConfig: serviceConfig()
144
150
  })];
145
- case 2:
151
+ case 3:
146
152
  _a.sent();
147
153
  return [2 /*return*/];
148
154
  }
@@ -158,13 +164,13 @@ describe('loadDependencies', function () {
158
164
  }
159
165
  });
160
166
  }); });
161
- test('it should load dependencies for a service with <h4> Dependencies </h4>', function () { return __awaiter(void 0, void 0, void 0, function () {
167
+ test("it should load dependencies for a service with ".concat(utils_1.DependencyHeader.DeprecatedMacro), function () { return __awaiter(void 0, void 0, void 0, function () {
162
168
  var dependencies;
163
169
  return __generator(this, function (_a) {
164
170
  switch (_a.label) {
165
171
  case 0:
166
172
  (0, getInitTerm_1.mockGetProgram)(internalModule, fakeInit, fakeTerm);
167
- return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, path_1.default.join(__dirname, './service.sas'), [], [], utils_1.SASJsFileType.service)];
173
+ return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, path_1.default.join(__dirname, './service.sas'), [], [], utils_1.SASJsFileType.service, compileTree)];
168
174
  case 1:
169
175
  dependencies = _a.sent();
170
176
  expect(dependencies).toStartWith(compiledVars('Service'));
@@ -178,13 +184,13 @@ describe('loadDependencies', function () {
178
184
  }
179
185
  });
180
186
  }); });
181
- test('it should load dependencies for a job <h4> SAS Macros </h4>', function () { return __awaiter(void 0, void 0, void 0, function () {
187
+ test("it should load dependencies for a job ".concat(utils_1.DependencyHeader.Macro), function () { return __awaiter(void 0, void 0, void 0, function () {
182
188
  var dependencies;
183
189
  return __generator(this, function (_a) {
184
190
  switch (_a.label) {
185
191
  case 0:
186
192
  (0, getInitTerm_1.mockGetProgram)(internalModule, fakeInit, fakeTerm);
187
- return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, path_1.default.join(__dirname, './service.sas'), [], [], utils_1.SASJsFileType.job)];
193
+ return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, path_1.default.join(__dirname, './service.sas'), [], [], utils_1.SASJsFileType.job, compileTree)];
188
194
  case 1:
189
195
  dependencies = _a.sent();
190
196
  expect(dependencies).toStartWith(compiledVars('Job'));
@@ -198,13 +204,13 @@ describe('loadDependencies', function () {
198
204
  }
199
205
  });
200
206
  }); });
201
- test('it should load dependencies for a service with <h4> SAS MAcros </h4>', function () { return __awaiter(void 0, void 0, void 0, function () {
207
+ test("it should load dependencies for a service with ".concat(utils_1.DependencyHeader.Macro), function () { return __awaiter(void 0, void 0, void 0, function () {
202
208
  var dependencies;
203
209
  return __generator(this, function (_a) {
204
210
  switch (_a.label) {
205
211
  case 0:
206
212
  (0, getInitTerm_1.mockGetProgram)(internalModule, fakeInit2, fakeTerm2);
207
- return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, path_1.default.join(__dirname, './service.sas'), [], [], utils_1.SASJsFileType.service)];
213
+ return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, path_1.default.join(__dirname, './service.sas'), [], [], utils_1.SASJsFileType.service, compileTree)];
208
214
  case 1:
209
215
  dependencies = _a.sent();
210
216
  expect(dependencies).toStartWith(compiledVars('Service'));
@@ -218,13 +224,13 @@ describe('loadDependencies', function () {
218
224
  }
219
225
  });
220
226
  }); });
221
- test('it should load dependencies for a job <h4> SAS MAcros </h4>', function () { return __awaiter(void 0, void 0, void 0, function () {
227
+ test("it should load dependencies for a job ".concat(utils_1.DependencyHeader.Macro), function () { return __awaiter(void 0, void 0, void 0, function () {
222
228
  var dependencies;
223
229
  return __generator(this, function (_a) {
224
230
  switch (_a.label) {
225
231
  case 0:
226
232
  (0, getInitTerm_1.mockGetProgram)(internalModule, fakeInit2, fakeTerm2);
227
- return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, path_1.default.join(__dirname, './service.sas'), [], [], utils_1.SASJsFileType.job)];
233
+ return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, path_1.default.join(__dirname, './service.sas'), [], [], utils_1.SASJsFileType.job, compileTree)];
228
234
  case 1:
229
235
  dependencies = _a.sent();
230
236
  expect(dependencies).toStartWith(compiledVars('Job'));
@@ -238,13 +244,13 @@ describe('loadDependencies', function () {
238
244
  }
239
245
  });
240
246
  }); });
241
- test('it should load programs for a service with <h4> SAS Programs </h4>', function () { return __awaiter(void 0, void 0, void 0, function () {
247
+ test("it should load programs for a service with ".concat(utils_1.DependencyHeader.DeprecatedInclude), function () { return __awaiter(void 0, void 0, void 0, function () {
242
248
  var dependencies;
243
249
  return __generator(this, function (_a) {
244
250
  switch (_a.label) {
245
251
  case 0:
246
252
  (0, getInitTerm_1.mockGetProgram)(internalModule, fakeJobInit, fakeTerm);
247
- return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, path_1.default.join(__dirname, './service.sas'), [path_1.default.join(__dirname, './macros')], [path_1.default.join(__dirname, './'), path_1.default.join(__dirname, './services')], utils_1.SASJsFileType.service)];
253
+ return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, path_1.default.join(__dirname, './service.sas'), [path_1.default.join(__dirname, './macros')], [path_1.default.join(__dirname, './'), path_1.default.join(__dirname, './services')], utils_1.SASJsFileType.service, compileTree)];
248
254
  case 1:
249
255
  dependencies = _a.sent();
250
256
  expect(dependencies).toStartWith(compiledVars('Service'));
@@ -258,13 +264,13 @@ describe('loadDependencies', function () {
258
264
  }
259
265
  });
260
266
  }); });
261
- test('it should load programs for a job <h4> SAS Programs </h4>', function () { return __awaiter(void 0, void 0, void 0, function () {
267
+ test("it should load programs for a job ".concat(utils_1.DependencyHeader.DeprecatedInclude), function () { return __awaiter(void 0, void 0, void 0, function () {
262
268
  var dependencies;
263
269
  return __generator(this, function (_a) {
264
270
  switch (_a.label) {
265
271
  case 0:
266
272
  (0, getInitTerm_1.mockGetProgram)(internalModule, fakeJobInit, fakeTerm);
267
- return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, path_1.default.join(__dirname, './service.sas'), [path_1.default.join(__dirname, './macros')], [path_1.default.join(__dirname, './'), path_1.default.join(__dirname, './services')], utils_1.SASJsFileType.job)];
273
+ return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, path_1.default.join(__dirname, './service.sas'), [path_1.default.join(__dirname, './macros')], [path_1.default.join(__dirname, './'), path_1.default.join(__dirname, './services')], utils_1.SASJsFileType.job, compileTree)];
268
274
  case 1:
269
275
  dependencies = _a.sent();
270
276
  expect(dependencies).toStartWith(compiledVars('Job'));
@@ -278,13 +284,13 @@ describe('loadDependencies', function () {
278
284
  }
279
285
  });
280
286
  }); });
281
- test('it should load programs for a service with <h4> SAS Includes </h4>', function () { return __awaiter(void 0, void 0, void 0, function () {
287
+ test("it should load programs for a service with ".concat(utils_1.DependencyHeader.Include), function () { return __awaiter(void 0, void 0, void 0, function () {
282
288
  var dependencies;
283
289
  return __generator(this, function (_a) {
284
290
  switch (_a.label) {
285
291
  case 0:
286
292
  (0, getInitTerm_1.mockGetProgram)(internalModule, fakeJobInit2, fakeTerm2);
287
- return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, path_1.default.join(__dirname, './service.sas'), [path_1.default.join(__dirname, './macros')], [path_1.default.join(__dirname, './'), path_1.default.join(__dirname, './services')], utils_1.SASJsFileType.service)];
293
+ return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, path_1.default.join(__dirname, './service.sas'), [path_1.default.join(__dirname, './macros')], [path_1.default.join(__dirname, './'), path_1.default.join(__dirname, './services')], utils_1.SASJsFileType.service, compileTree)];
288
294
  case 1:
289
295
  dependencies = _a.sent();
290
296
  expect(dependencies).toStartWith(compiledVars('Service'));
@@ -298,13 +304,13 @@ describe('loadDependencies', function () {
298
304
  }
299
305
  });
300
306
  }); });
301
- test('it should load programs for a job <h4> SAS Includes </h4>', function () { return __awaiter(void 0, void 0, void 0, function () {
307
+ test("it should load programs for a job ".concat(utils_1.DependencyHeader.Include), function () { return __awaiter(void 0, void 0, void 0, function () {
302
308
  var dependencies;
303
309
  return __generator(this, function (_a) {
304
310
  switch (_a.label) {
305
311
  case 0:
306
312
  (0, getInitTerm_1.mockGetProgram)(internalModule, fakeJobInit2, fakeTerm2);
307
- return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, path_1.default.join(__dirname, './service.sas'), [path_1.default.join(__dirname, './macros')], [path_1.default.join(__dirname, './'), path_1.default.join(__dirname, './services')], utils_1.SASJsFileType.job)];
313
+ return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, path_1.default.join(__dirname, './service.sas'), [path_1.default.join(__dirname, './macros')], [path_1.default.join(__dirname, './'), path_1.default.join(__dirname, './services')], utils_1.SASJsFileType.job, compileTree)];
308
314
  case 1:
309
315
  dependencies = _a.sent();
310
316
  expect(dependencies).toStartWith(compiledVars('Job'));
@@ -318,13 +324,13 @@ describe('loadDependencies', function () {
318
324
  }
319
325
  });
320
326
  }); });
321
- test("it should load dependencies for a job having jobInit's <h4> SAS Programs </h4>", function () { return __awaiter(void 0, void 0, void 0, function () {
327
+ test("it should load dependencies for a job having jobInit's ".concat(utils_1.DependencyHeader.DeprecatedInclude), function () { return __awaiter(void 0, void 0, void 0, function () {
322
328
  var dependencies;
323
329
  return __generator(this, function (_a) {
324
330
  switch (_a.label) {
325
331
  case 0:
326
332
  (0, getInitTerm_1.mockGetProgram)(internalModule, fakeJobInit, fakeTerm2);
327
- return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, path_1.default.join(__dirname, './service.sas'), [path_1.default.join(__dirname, './macros')], [path_1.default.join(__dirname, './'), path_1.default.join(__dirname, './services')], utils_1.SASJsFileType.job)];
333
+ return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, path_1.default.join(__dirname, './service.sas'), [path_1.default.join(__dirname, './macros')], [path_1.default.join(__dirname, './'), path_1.default.join(__dirname, './services')], utils_1.SASJsFileType.job, compileTree)];
328
334
  case 1:
329
335
  dependencies = _a.sent();
330
336
  expect(dependencies).toStartWith(compiledVars('Job'));
@@ -341,13 +347,13 @@ describe('loadDependencies', function () {
341
347
  }
342
348
  });
343
349
  }); });
344
- test("it should load dependencies for a job having jobTerm's <h4> SAS Programs </h4>", function () { return __awaiter(void 0, void 0, void 0, function () {
350
+ test("it should load dependencies for a job having jobTerm's ".concat(utils_1.DependencyHeader.DeprecatedInclude), function () { return __awaiter(void 0, void 0, void 0, function () {
345
351
  var dependencies;
346
352
  return __generator(this, function (_a) {
347
353
  switch (_a.label) {
348
354
  case 0:
349
355
  (0, getInitTerm_1.mockGetProgram)(internalModule, fakeInit2, fakeJobInit);
350
- return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, path_1.default.join(__dirname, './service.sas'), [path_1.default.join(__dirname, './macros')], [path_1.default.join(__dirname, './'), path_1.default.join(__dirname, './services')], utils_1.SASJsFileType.job)];
356
+ return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, path_1.default.join(__dirname, './service.sas'), [path_1.default.join(__dirname, './macros')], [path_1.default.join(__dirname, './'), path_1.default.join(__dirname, './services')], utils_1.SASJsFileType.job, compileTree)];
351
357
  case 1:
352
358
  dependencies = _a.sent();
353
359
  expect(dependencies).toStartWith(compiledVars('Job'));
@@ -363,13 +369,13 @@ describe('loadDependencies', function () {
363
369
  }
364
370
  });
365
371
  }); });
366
- test("it should load dependencies for a service having serviceInit's <h4> SAS Programs </h4>", function () { return __awaiter(void 0, void 0, void 0, function () {
372
+ test("it should load dependencies for a service having serviceInit's ".concat(utils_1.DependencyHeader.DeprecatedInclude), function () { return __awaiter(void 0, void 0, void 0, function () {
367
373
  var dependencies;
368
374
  return __generator(this, function (_a) {
369
375
  switch (_a.label) {
370
376
  case 0:
371
377
  (0, getInitTerm_1.mockGetProgram)(internalModule, fakeJobInit, fakeTerm2);
372
- return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, path_1.default.join(__dirname, './service.sas'), [path_1.default.join(__dirname, './macros')], [path_1.default.join(__dirname, './'), path_1.default.join(__dirname, './services')], utils_1.SASJsFileType.service)];
378
+ return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, path_1.default.join(__dirname, './service.sas'), [path_1.default.join(__dirname, './macros')], [path_1.default.join(__dirname, './'), path_1.default.join(__dirname, './services')], utils_1.SASJsFileType.service, compileTree)];
373
379
  case 1:
374
380
  dependencies = _a.sent();
375
381
  expect(dependencies).toStartWith(compiledVars('Service'));
@@ -386,13 +392,13 @@ describe('loadDependencies', function () {
386
392
  }
387
393
  });
388
394
  }); });
389
- test("it should load dependencies for a service having serviceTerm's <h4> SAS Programs </h4>", function () { return __awaiter(void 0, void 0, void 0, function () {
395
+ test("it should load dependencies for a service having serviceTerm's ".concat(utils_1.DependencyHeader.DeprecatedInclude), function () { return __awaiter(void 0, void 0, void 0, function () {
390
396
  var dependencies;
391
397
  return __generator(this, function (_a) {
392
398
  switch (_a.label) {
393
399
  case 0:
394
400
  (0, getInitTerm_1.mockGetProgram)(internalModule, fakeInit2, fakeJobInit);
395
- return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, path_1.default.join(__dirname, './service.sas'), [path_1.default.join(__dirname, './macros')], [path_1.default.join(__dirname, './'), path_1.default.join(__dirname, './services')], utils_1.SASJsFileType.service)];
401
+ return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, path_1.default.join(__dirname, './service.sas'), [path_1.default.join(__dirname, './macros')], [path_1.default.join(__dirname, './'), path_1.default.join(__dirname, './services')], utils_1.SASJsFileType.service, compileTree)];
396
402
  case 1:
397
403
  dependencies = _a.sent();
398
404
  expect(dependencies).toStartWith(compiledVars('Service'));
@@ -84,7 +84,6 @@ var utils_1 = require("@sasjs/utils");
84
84
  var getFoldersForDocs_1 = require("./internal/getFoldersForDocs");
85
85
  var createDotFiles_1 = require("./internal/createDotFiles");
86
86
  var getDocConfig_1 = require("./internal/getDocConfig");
87
- var utils_2 = require("../../utils");
88
87
  /**
89
88
  * Generates documentation(Doxygen)
90
89
  * By default the docs will be at 'sasjsbuild/docs' folder
@@ -188,16 +187,13 @@ function generateDocs(target, config, outDirectory) {
188
187
  exports.generateDocs = generateDocs;
189
188
  function setVariableCmd(params) {
190
189
  var command = '';
191
- var isWin = (0, utils_2.isWindows)();
192
- if (isWin) {
193
- for (var param in params) {
190
+ if ((0, utils_1.isWindows)()) {
191
+ for (var param in params)
194
192
  command += "set ".concat(param, "=").concat(params[param], " && ");
195
- }
196
193
  }
197
194
  else {
198
- for (var param in params) {
195
+ for (var param in params)
199
196
  command += "".concat(param, "='").concat(params[param], "' ");
200
- }
201
197
  }
202
198
  return command;
203
199
  }
@@ -9,7 +9,7 @@ var utils_1 = require("@sasjs/utils");
9
9
  * @param {Map} paramNodes- Map for params(Inputs/Outputs)
10
10
  */
11
11
  function getFileInputs(fileName, fileContent, paramNodes) {
12
- var fileInputs = (0, utils_1.getList)('<h4> Data Inputs </h4>', fileContent)
12
+ var fileInputs = (0, utils_1.getList)(utils_1.DependencyHeader.DataInput, fileContent)
13
13
  .map(function (input) { return input.toUpperCase(); })
14
14
  .filter(function (input) { return !input.endsWith('.DLL'); });
15
15
  fileInputs.forEach(function (inputParam) {
@@ -8,7 +8,7 @@ var utils_1 = require("@sasjs/utils");
8
8
  * @param {Map} paramNodes- Map for params(Inputs/Outputs)
9
9
  */
10
10
  function getFileOutputs(fileContent, paramNodes) {
11
- var fileOutputs = (0, utils_1.getList)('<h4> Data Outputs </h4>', fileContent)
11
+ var fileOutputs = (0, utils_1.getList)(utils_1.DependencyHeader.DataOutput, fileContent)
12
12
  .map(function (output) { return output.toUpperCase(); })
13
13
  .filter(function (output) { return !output.endsWith('.DLL'); });
14
14
  fileOutputs.forEach(function (outputParam) {
@@ -223,8 +223,8 @@ function printHelpText() {
223
223
  "the user run a SAS job against a specified target.",
224
224
  "The target can exist either in the local project configuration or in the global .sasjsrc file.",
225
225
  "<sasProgramPath> - if this has a leading slash (eg /Public/app/folder/servicename) then it must be the full path. If it is a relative path (eg path/servicename) then it will be pre-pended with the appLoc - which must then be defined in the sasjs config.",
226
- "<path/to/log> - Location in which to store the log file. If not provided AND an error occurs, the log will be stored in the execution path.",
227
- "<path/to/output> - Location to store the output file. If not provided, a file named output.json will be saved in the execution path."
226
+ "<path/to/log> - Location in which to store the log file. If not provided AND current directory is a sasjs project, it will be saved in sasjsresults else in the current directory",
227
+ "<path/to/output> - Location to store the output file. If not provided AND current directory is a sasjs project, an output file will be saved in the sasjsresults folder else in current directory."
228
228
  ]
229
229
  },
230
230
  {
@@ -47,7 +47,6 @@ var displayResult_1 = require("../../utils/displayResult");
47
47
  var types_1 = require("@sasjs/utils/types");
48
48
  var utils_2 = require("../../utils/utils");
49
49
  var saveLog_1 = require("../../utils/saveLog");
50
- var getLogFilePath_1 = require("../../utils/getLogFilePath");
51
50
  function runSasJob(target, isLocal, sasJobLocation, dataFilePath, configFilePath, authConfig, logFile, jobPath, outputPathParam) {
52
51
  return __awaiter(this, void 0, void 0, function () {
53
52
  var dataJson, configJson, dataFile, configFile, sas9CredentialsError, sasjs, result;
@@ -150,7 +149,7 @@ function runSasJob(target, isLocal, sasJobLocation, dataFilePath, configFilePath
150
149
  output = res;
151
150
  }
152
151
  if (!!!output) return [3 /*break*/, 4];
153
- return [4 /*yield*/, writeOutput(outputPathParam, output, isLocal)];
152
+ return [4 /*yield*/, writeOutput(outputPathParam, output, sasJobLocation)];
154
153
  case 3:
155
154
  _a.sent();
156
155
  _a.label = 4;
@@ -193,20 +192,28 @@ function runSasJob(target, isLocal, sasJobLocation, dataFilePath, configFilePath
193
192
  }
194
193
  exports.runSasJob = runSasJob;
195
194
  var saveLogFile = function (sasjs, sasJobLocation, logFile, jobPath) { return __awaiter(void 0, void 0, void 0, function () {
196
- var sasRequests, currentRequestLog;
195
+ var sasRequests, currentRequestLog, logPath, timestamp, filename;
197
196
  return __generator(this, function (_a) {
198
197
  switch (_a.label) {
199
198
  case 0:
200
199
  sasRequests = sasjs.getSasRequests();
201
200
  currentRequestLog = sasRequests.find(function (x) { return x.serviceLink === sasJobLocation; });
202
- if (!(currentRequestLog && jobPath)) return [3 /*break*/, 2];
203
- if (!logFile)
204
- logFile = (0, getLogFilePath_1.getLogFilePath)('', jobPath || '');
205
- return [4 /*yield*/, (0, saveLog_1.saveLog)(currentRequestLog.logFile, logFile, jobPath || '', false)];
201
+ if (!(currentRequestLog && jobPath)) return [3 /*break*/, 4];
202
+ if (!!logFile) return [3 /*break*/, 2];
203
+ return [4 /*yield*/, (0, utils_2.isSASjsProject)()];
206
204
  case 1:
207
- _a.sent();
205
+ logPath = (_a.sent())
206
+ ? path_1.default.join(process.sasjsConstants.buildDestinationResultsFolder, 'requests')
207
+ : process.projectDir;
208
+ timestamp = (0, utils_1.generateTimestamp)();
209
+ filename = sasJobLocation.split(path_1.default.sep).pop();
210
+ logFile = path_1.default.join(logPath, "".concat(filename, "-").concat(timestamp, ".log"));
208
211
  _a.label = 2;
209
- case 2: return [2 /*return*/];
212
+ case 2: return [4 /*yield*/, (0, saveLog_1.saveLog)(currentRequestLog.logFile, logFile, jobPath || '', false)];
213
+ case 3:
214
+ _a.sent();
215
+ _a.label = 4;
216
+ case 4: return [2 /*return*/];
210
217
  }
211
218
  });
212
219
  }); };
@@ -214,15 +221,18 @@ var saveLogFile = function (sasjs, sasJobLocation, logFile, jobPath) { return __
214
221
  * Writes output to the file
215
222
  * @param outputPathParam path to output file
216
223
  * @param output data to be written to output file
217
- * @param isLocal is local target, othervise it is global
224
+ * @param sasJobLocation is used for output file name when outputPathParam is undefined
218
225
  * @returns output path for the file created
219
226
  */
220
- var writeOutput = function (outputPathParam, output, isLocal) { return __awaiter(void 0, void 0, void 0, function () {
221
- var outputPath, outputFilename, outputPathArr, outputString;
227
+ var writeOutput = function (outputPathParam, output, sasJobLocation) { return __awaiter(void 0, void 0, void 0, function () {
228
+ var outputPath, outputFilename, outputPathArr, timestamp, filename, outputString;
222
229
  return __generator(this, function (_a) {
223
230
  switch (_a.label) {
224
- case 0:
225
- outputPath = path_1.default.join(process.projectDir, isLocal ? '' : '');
231
+ case 0: return [4 /*yield*/, (0, utils_2.isSASjsProject)()];
232
+ case 1:
233
+ outputPath = (_a.sent())
234
+ ? path_1.default.join(process.sasjsConstants.buildDestinationResultsFolder, 'requests')
235
+ : process.projectDir;
226
236
  if (outputPathParam && typeof outputPathParam === 'string') {
227
237
  outputPathParam = path_1.default.join(process.projectDir, outputPathParam || '');
228
238
  outputPathArr = outputPathParam.split(path_1.default.sep);
@@ -230,18 +240,20 @@ var writeOutput = function (outputPathParam, output, isLocal) { return __awaiter
230
240
  outputPath = outputPathArr.join(path_1.default.sep);
231
241
  }
232
242
  return [4 /*yield*/, (0, utils_1.folderExists)(outputPath)];
233
- case 1:
234
- if (!!(_a.sent())) return [3 /*break*/, 3];
235
- return [4 /*yield*/, (0, utils_1.createFolder)(outputPath)];
236
243
  case 2:
237
- _a.sent();
238
- _a.label = 3;
244
+ if (!!(_a.sent())) return [3 /*break*/, 4];
245
+ return [4 /*yield*/, (0, utils_1.createFolder)(outputPath)];
239
246
  case 3:
247
+ _a.sent();
248
+ _a.label = 4;
249
+ case 4:
240
250
  if (outputFilename) {
241
251
  outputPath += "".concat(path_1.default.sep).concat(outputFilename);
242
252
  }
243
253
  else {
244
- outputPath += "".concat(path_1.default.sep, "output.json");
254
+ timestamp = (0, utils_1.generateTimestamp)();
255
+ filename = sasJobLocation.split(path_1.default.sep).pop();
256
+ outputPath += "".concat(path_1.default.sep).concat(filename, "-").concat(timestamp, ".json");
245
257
  }
246
258
  outputString = '';
247
259
  if (typeof output === 'object') {
@@ -256,16 +268,16 @@ var writeOutput = function (outputPathParam, output, isLocal) { return __awaiter
256
268
  else {
257
269
  outputString = output;
258
270
  }
259
- if (!outputString) return [3 /*break*/, 5];
271
+ if (!outputString) return [3 /*break*/, 6];
260
272
  return [4 /*yield*/, (0, utils_1.createFile)(outputPath, outputString)];
261
- case 4:
273
+ case 5:
262
274
  _a.sent();
263
275
  (0, displayResult_1.displaySuccess)("Request finished. Output is stored at '".concat(outputPath, "'"));
264
- return [3 /*break*/, 6];
265
- case 5:
276
+ return [3 /*break*/, 7];
277
+ case 6:
266
278
  (0, displayResult_1.displayError)("There was a problem with writing output file. Data not present.");
267
- _a.label = 6;
268
- case 6: return [2 /*return*/];
279
+ _a.label = 7;
280
+ case 7: return [2 /*return*/];
269
281
  }
270
282
  });
271
283
  }); };