@sasjs/cli 3.13.3 → 3.13.6

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 (32) hide show
  1. package/build/commands/compile/compile.js +33 -26
  2. package/build/commands/compile/compileSingleFile.js +8 -5
  3. package/build/commands/compile/internal/compileFile.d.ts +15 -0
  4. package/build/commands/compile/internal/{compileServiceFile.js → compileFile.js} +27 -5
  5. package/build/commands/compile/internal/compileTestFile.js +2 -2
  6. package/build/commands/compile/spec/compile.spec.js +24 -8
  7. package/build/commands/compile/spec/{compileJobFile.spec.d.ts → compileFile.spec.d.ts} +0 -0
  8. package/build/commands/compile/spec/{compileServiceFile.spec.js → compileFile.spec.js} +75 -37
  9. package/build/commands/deploy/deploy.js +6 -2
  10. package/build/commands/help/help.js +3 -2
  11. package/build/commands/job/internal/execute/sasjs.d.ts +2 -1
  12. package/build/commands/job/internal/execute/sasjs.js +2 -2
  13. package/build/commands/job/jobCommand.d.ts +1 -1
  14. package/build/commands/job/jobCommand.js +23 -12
  15. package/build/commands/job/spec/execute.spec.js +1 -1
  16. package/build/commands/request/request.js +4 -4
  17. package/build/commands/request/requestCommand.js +21 -10
  18. package/build/commands/shared/deployToSasViyaWithServicePack.js +6 -1
  19. package/build/commands/testing/spec/testCommand.spec.js +5 -3
  20. package/build/commands/testing/spec/testing.spec.js +32 -4
  21. package/build/commands/testing/test.d.ts +1 -1
  22. package/build/commands/testing/test.js +13 -2
  23. package/build/commands/testing/testCommand.js +13 -7
  24. package/build/commands/web/internal/sasjsout.d.ts +1 -1
  25. package/build/commands/web/internal/sasjsout.js +1 -1
  26. package/build/utils/displayResult.js +5 -1
  27. package/package.json +6 -5
  28. package/build/commands/compile/internal/compileJobFile.d.ts +0 -3
  29. package/build/commands/compile/internal/compileJobFile.js +0 -60
  30. package/build/commands/compile/internal/compileServiceFile.d.ts +0 -4
  31. package/build/commands/compile/spec/compileJobFile.spec.js +0 -140
  32. package/build/commands/compile/spec/compileServiceFile.spec.d.ts +0 -1
@@ -143,7 +143,7 @@ var JobCommand = /** @class */ (function (_super) {
143
143
  JobCommand.prototype.execute = function () {
144
144
  var _a, _b;
145
145
  return __awaiter(this, void 0, void 0, function () {
146
- var target, sasjs, _c, authConfig, _d, username, password, _e, _f;
146
+ var target, sasjs, authConfig, _c, _d, username, password, _e, e_1, _f;
147
147
  return __generator(this, function (_g) {
148
148
  switch (_g.label) {
149
149
  case 0: return [4 /*yield*/, this.getTargetInfo()];
@@ -162,11 +162,11 @@ var JobCommand = /** @class */ (function (_super) {
162
162
  case utils_1.ServerType.Sas9: return [3 /*break*/, 7];
163
163
  case utils_1.ServerType.Sasjs: return [3 /*break*/, 11];
164
164
  }
165
- return [3 /*break*/, 15];
165
+ return [3 /*break*/, 19];
166
166
  case 2: return [4 /*yield*/, (0, utils_2.getAuthConfig)(target).catch(function (err) {
167
167
  var _a;
168
168
  (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('Unable to execute job. Error fetching auth config: ', err);
169
- return null;
169
+ return undefined;
170
170
  })];
171
171
  case 3:
172
172
  authConfig = _g.sent();
@@ -213,30 +213,41 @@ var JobCommand = /** @class */ (function (_super) {
213
213
  });
214
214
  if (typeof this.parsed.jobPath !== 'string')
215
215
  return [2 /*return*/, command_1.ReturnCode.InvalidCommand];
216
- if (!this.jobSubCommands.includes(this.parsed.subCommand)) return [3 /*break*/, 13];
217
- return [4 /*yield*/, this.executeJobSasjs(sasjs, target)];
216
+ _g.label = 12;
218
217
  case 12:
219
- _f = _g.sent();
220
- return [3 /*break*/, 14];
218
+ _g.trys.push([12, 14, , 15]);
219
+ return [4 /*yield*/, (0, utils_2.getAuthConfig)(target)];
221
220
  case 13:
222
- _f = command_1.ReturnCode.InvalidCommand;
223
- _g.label = 14;
224
- case 14: return [2 /*return*/, _f];
221
+ authConfig = _g.sent();
222
+ return [3 /*break*/, 15];
223
+ case 14:
224
+ e_1 = _g.sent();
225
+ return [3 /*break*/, 15];
225
226
  case 15:
227
+ if (!this.jobSubCommands.includes(this.parsed.subCommand)) return [3 /*break*/, 17];
228
+ return [4 /*yield*/, this.executeJobSasjs(sasjs, target, authConfig)];
229
+ case 16:
230
+ _f = _g.sent();
231
+ return [3 /*break*/, 18];
232
+ case 17:
233
+ _f = command_1.ReturnCode.InvalidCommand;
234
+ _g.label = 18;
235
+ case 18: return [2 /*return*/, _f];
236
+ case 19:
226
237
  (_b = process.logger) === null || _b === void 0 ? void 0 : _b.error("This command is not supported for specified server type.\nPlease try again with a different server type.");
227
238
  return [2 /*return*/, command_1.ReturnCode.InternalError];
228
239
  }
229
240
  });
230
241
  });
231
242
  };
232
- JobCommand.prototype.executeJobSasjs = function (sasjs, target) {
243
+ JobCommand.prototype.executeJobSasjs = function (sasjs, target, authConfig) {
233
244
  return __awaiter(this, void 0, void 0, function () {
234
245
  var jobPath, returnCode;
235
246
  return __generator(this, function (_a) {
236
247
  switch (_a.label) {
237
248
  case 0:
238
249
  jobPath = (0, prefixAppLoc_1.prefixAppLoc)(target.appLoc, this.parsed.jobPath);
239
- return [4 /*yield*/, (0, execute_1.executeJobSasjs)(sasjs, jobPath, this.parsed.log)
250
+ return [4 /*yield*/, (0, execute_1.executeJobSasjs)(sasjs, jobPath, this.parsed.log, authConfig)
240
251
  .then(function () { return command_1.ReturnCode.Success; })
241
252
  .catch(function (err) {
242
253
  var _a;
@@ -127,7 +127,7 @@ describe('executeJobSasjs', function () {
127
127
  case 0: return [4 /*yield*/, (0, execute_1.executeJobSasjs)(sasjs, 'test/job', path_1.default.join(process.projectDir, 'logs'))];
128
128
  case 1:
129
129
  _a.sent();
130
- expect(sasjs.executeJobSASjs).toHaveBeenCalledWith({ _program: 'test/job' });
130
+ expect(sasjs.executeJobSASjs).toHaveBeenCalledWith({ _program: 'test/job' }, undefined);
131
131
  return [2 /*return*/];
132
132
  }
133
133
  });
@@ -112,9 +112,7 @@ function runSasJob(target, isLocal, sasJobLocation, dataFilePath, configFilePath
112
112
  debug: true
113
113
  });
114
114
  return [4 /*yield*/, sasjs
115
- .request(sasJobLocation, dataJson, configJson, function () {
116
- (0, displayResult_1.displayError)(null, 'Login callback called. Request failed.');
117
- }, authConfig)
115
+ .request(sasJobLocation, dataJson, configJson, undefined, authConfig)
118
116
  .then(function (res) { return __awaiter(_this, void 0, void 0, function () {
119
117
  var output;
120
118
  return __generator(this, function (_a) {
@@ -173,7 +171,9 @@ function runSasJob(target, isLocal, sasJobLocation, dataFilePath, configFilePath
173
171
  error = {};
174
172
  if (err.message)
175
173
  error.message = err.message;
176
- (0, displayResult_1.displayError)(error, 'An error occurred while executing the request.');
174
+ if (err.error.message)
175
+ error.message = err.error.message;
176
+ (0, displayResult_1.displayError)(error, "An error occurred while executing the request.");
177
177
  }
178
178
  return [4 /*yield*/, saveLogFile(sasjs, sasJobLocation, logFile, jobPath)];
179
179
  case 1:
@@ -114,7 +114,7 @@ var RequestCommand = /** @class */ (function (_super) {
114
114
  }
115
115
  RequestCommand.prototype.execute = function () {
116
116
  return __awaiter(this, void 0, void 0, function () {
117
- var _a, target, isLocal, jobPath, log, output, authConfig, _b, _c, sasProgramPath, data, config;
117
+ var _a, target, isLocal, jobPath, log, output, authConfig, _b, e_1, _c, sasProgramPath, data, config;
118
118
  return __generator(this, function (_d) {
119
119
  switch (_d.label) {
120
120
  case 0: return [4 /*yield*/, this.getTargetInfo()];
@@ -125,16 +125,27 @@ var RequestCommand = /** @class */ (function (_super) {
125
125
  ? (0, getLogFilePath_1.getLogFilePath)(this.parsed.log || '', jobPath || '')
126
126
  : undefined;
127
127
  output = this.parsed.output || undefined;
128
- if (!(target.serverType === utils_1.ServerType.SasViya)) return [3 /*break*/, 3];
129
- return [4 /*yield*/, (0, utils_2.getAuthConfig)(target)];
130
- case 2:
131
- _b = _d.sent();
132
- return [3 /*break*/, 4];
128
+ _b = target.serverType;
129
+ switch (_b) {
130
+ case utils_1.ServerType.SasViya: return [3 /*break*/, 2];
131
+ case utils_1.ServerType.Sasjs: return [3 /*break*/, 4];
132
+ }
133
+ return [3 /*break*/, 8];
134
+ case 2: return [4 /*yield*/, (0, utils_2.getAuthConfig)(target)];
133
135
  case 3:
134
- _b = undefined;
135
- _d.label = 4;
136
+ authConfig = _d.sent();
137
+ return [3 /*break*/, 8];
136
138
  case 4:
137
- authConfig = _b;
139
+ _d.trys.push([4, 6, , 7]);
140
+ return [4 /*yield*/, (0, utils_2.getAuthConfig)(target)];
141
+ case 5:
142
+ authConfig = _d.sent();
143
+ return [3 /*break*/, 7];
144
+ case 6:
145
+ e_1 = _d.sent();
146
+ return [3 /*break*/, 7];
147
+ case 7: return [3 /*break*/, 8];
148
+ case 8:
138
149
  _c = this.parsed, sasProgramPath = _c.sasProgramPath, data = _c.data, config = _c.config;
139
150
  return [4 /*yield*/, (0, request_1.runSasJob)(target, isLocal, sasProgramPath, data, config, authConfig, log, jobPath, output)
140
151
  .then(function () {
@@ -144,7 +155,7 @@ var RequestCommand = /** @class */ (function (_super) {
144
155
  (0, utils_2.displayError)(err, 'An error has occurred when running your SAS job.');
145
156
  return command_1.ReturnCode.InternalError;
146
157
  })];
147
- case 5: return [2 /*return*/, _d.sent()];
158
+ case 9: return [2 /*return*/, _d.sent()];
148
159
  }
149
160
  });
150
161
  });
@@ -73,7 +73,12 @@ function deployToSasViyaWithServicePack(jsonFilePath, target, isLocal, isForced)
73
73
  serverUrl: target.serverUrl,
74
74
  useComputeApi: true
75
75
  });
76
- return [4 /*yield*/, sasjs.deployServicePack(jsonObject, undefined, undefined, access_token, isForced)];
76
+ return [4 /*yield*/, sasjs
77
+ .deployServicePack(jsonObject, undefined, undefined, access_token, isForced)
78
+ .catch(function (err) {
79
+ process.logger.error('deployServicePack error', err);
80
+ throw new Error('Deploy service pack error');
81
+ })];
77
82
  case 3:
78
83
  _a.sent();
79
84
  return [2 /*return*/, jsonObject];
@@ -127,7 +127,8 @@ describe('TestCommand', function () {
127
127
  '--outDirectory',
128
128
  'path-to-out',
129
129
  '--source',
130
- 'path-to-source'
130
+ 'path-to-source',
131
+ '--force'
131
132
  ], false);
132
133
  command = new testCommand_1.TestCommand(args);
133
134
  return [4 /*yield*/, command.getTargetInfo()];
@@ -155,7 +156,8 @@ describe('TestCommand', function () {
155
156
  '--out',
156
157
  'path-to-out',
157
158
  '-s',
158
- 'path-to-source'
159
+ 'path-to-source',
160
+ '-f'
159
161
  ], false);
160
162
  command = new testCommand_1.TestCommand(args);
161
163
  return [4 /*yield*/, command.getTargetInfo()];
@@ -179,7 +181,7 @@ describe('TestCommand', function () {
179
181
  return [4 /*yield*/, command.execute()];
180
182
  case 1:
181
183
  _a.sent();
182
- expect(testModule.runTest).toHaveBeenCalledWith(target, undefined, undefined, undefined);
184
+ expect(testModule.runTest).toHaveBeenCalledWith(target, undefined, undefined, undefined, false);
183
185
  return [2 /*return*/];
184
186
  }
185
187
  });
@@ -217,7 +217,7 @@ describe('sasjs test', function () {
217
217
  ]
218
218
  };
219
219
  expectedResultsCsv = "test_target,test_loc,sasjs_test_id,test_suite_result,test_description,test_url\ntestsetup,tests/testsetup.sas,sasjs_test_id,not provided,,".concat(testUrlLink('testsetup'), "\nexampleprogram,tests/jobs/jobs/exampleprogram.test.sas,sasjs_test_id,not provided,,").concat(testUrlLink('jobs/jobs/exampleprogram.test'), "\nstandalone,tests/jobs/jobs/standalone.test.sas,sasjs_test_id,not provided,,").concat(testUrlLink('jobs/jobs/standalone.test'), "\nexamplemacro,tests/macros/examplemacro.test.sas,sasjs_test_id,PASS,examplemacro test.1 description,").concat(testUrlLink('macros/examplemacro.test'), "\ndostuff,tests/services/admin/dostuff.test.0.sas,sasjs_test_id,FAIL,dostuff 0 test description,").concat(testUrlLink('services/admin/dostuff.test.0'), "\ndostuff,tests/services/admin/dostuff.test.1.sas,sasjs_test_id,PASS,dostuff 1 test description,").concat(testUrlLink('services/admin/dostuff.test.1'), "\ntestteardown,tests/testteardown.sas,sasjs_test_id,not provided,,").concat(testUrlLink('testteardown'), "\n");
220
- return [4 /*yield*/, (0, test_1.runTest)(target)];
220
+ return [4 /*yield*/, (0, test_1.runTest)(target, undefined, undefined, undefined, true)];
221
221
  case 1:
222
222
  _a.sent();
223
223
  resultsFolderPath = path_1.default.join(__dirname, target.name, 'sasjsresults');
@@ -330,7 +330,7 @@ describe('sasjs test', function () {
330
330
  return [4 /*yield*/, (0, utils_1.copy)(path_1.default.join(__dirname, target.name, 'sasjsbuild', 'testFlow.json'), path_1.default.join(__dirname, target.name, movedTestFlow))];
331
331
  case 1:
332
332
  _a.sent();
333
- return [4 /*yield*/, (0, test_1.runTest)(target, ['jobs/standalone', 'shouldFail', 'services/admin/dostuff.test.0'], outputFolder, movedTestFlow)];
333
+ return [4 /*yield*/, (0, test_1.runTest)(target, ['jobs/standalone', 'shouldFail', 'services/admin/dostuff.test.0'], outputFolder, movedTestFlow, true)];
334
334
  case 2:
335
335
  _a.sent();
336
336
  resultsFolderPath = path_1.default.join(__dirname, target.name, outputFolder);
@@ -531,7 +531,7 @@ describe('sasjs test', function () {
531
531
  ]
532
532
  };
533
533
  expectedResultsCsv = "test_target,test_loc,sasjs_test_id,test_suite_result,test_description,test_url\ntestsetup,tests/testsetup.sas,sasjs_test_id,not provided,,".concat(testUrlLink('testsetup'), "\nexampleprogram,tests/jobs/jobs/exampleprogram.test.sas,sasjs_test_id,not provided,,").concat(testUrlLink('jobs/jobs/exampleprogram.test'), "\nstandalone,tests/jobs/jobs/standalone.test.sas,sasjs_test_id,not provided,,").concat(testUrlLink('jobs/jobs/standalone.test'), "\nexamplemacro,tests/macros/examplemacro.test.sas,sasjs_test_id,PASS,examplemacro test.1 description,").concat(testUrlLink('macros/examplemacro.test'), "\nshouldFail,tests/macros/shouldFail.test.sas,sasjs_test_id,not provided,,").concat(testUrlLink('macros/shouldFail.test'), "\ndostuff,tests/services/admin/dostuff.test.0.sas,sasjs_test_id,FAIL,dostuff 0 test description,").concat(testUrlLink('services/admin/dostuff.test.0'), "\ndostuff,tests/services/admin/dostuff.test.1.sas,sasjs_test_id,PASS,dostuff 1 test description,").concat(testUrlLink('services/admin/dostuff.test.1'), "\ntestteardown,tests/testteardown.sas,sasjs_test_id,not provided,,").concat(testUrlLink('testteardown'), "\n");
534
- return [4 /*yield*/, (0, test_1.runTest)(target, undefined, undefined, undefined)];
534
+ return [4 /*yield*/, (0, test_1.runTest)(target, undefined, undefined, undefined, true)];
535
535
  case 1:
536
536
  _a.sent();
537
537
  resultsFolderPath = path_1.default.join(__dirname, target.name, 'sasjsresults');
@@ -591,7 +591,7 @@ describe('sasjs test', function () {
591
591
  jest.spyOn(fileModule, 'readFile').mockImplementation(function () {
592
592
  return Promise.resolve("{\n \"tests\": [\n \"tests/macros/".concat(testService, ".test.sas\"\n ],\n \"testSetUp\": \"\",\n \"testTearDown\": \"\"\n}"));
593
593
  });
594
- return [4 /*yield*/, (0, test_1.runTest)(target, undefined, undefined, undefined)];
594
+ return [4 /*yield*/, (0, test_1.runTest)(target, undefined, undefined, undefined, true)];
595
595
  case 1:
596
596
  _a.sent();
597
597
  expect(process.logger.table).toHaveBeenCalledWith([['uuidv4', testService, chalk_1.default.redBright(types_1.TestResultStatus.fail)]], { head: ['SASjs Test ID', 'Test Target', 'Test Suite Result'] });
@@ -599,6 +599,34 @@ describe('sasjs test', function () {
599
599
  }
600
600
  });
601
601
  }); });
602
+ it('should fail on tests failing', function () { return __awaiter(void 0, void 0, void 0, function () {
603
+ var error;
604
+ return __generator(this, function (_a) {
605
+ switch (_a.label) {
606
+ case 0: return [4 /*yield*/, (0, test_1.runTest)(target).catch(function (err) {
607
+ return err;
608
+ })];
609
+ case 1:
610
+ error = _a.sent();
611
+ expect(error).toEqual('6 tests completed with failures!');
612
+ return [2 /*return*/];
613
+ }
614
+ });
615
+ }); });
616
+ it('should not throw error on tests failing', function () { return __awaiter(void 0, void 0, void 0, function () {
617
+ var error;
618
+ return __generator(this, function (_a) {
619
+ switch (_a.label) {
620
+ case 0: return [4 /*yield*/, (0, test_1.runTest)(target, undefined, undefined, undefined, true).catch(function (err) {
621
+ return err;
622
+ })];
623
+ case 1:
624
+ error = _a.sent();
625
+ expect(error).toBeUndefined();
626
+ return [2 /*return*/];
627
+ }
628
+ });
629
+ }); });
602
630
  });
603
631
  });
604
632
  function generateTarget(serverType) {
@@ -1,3 +1,3 @@
1
1
  import { Target } from '@sasjs/utils';
2
- export declare function runTest(target: Target, testRegExps?: string[], outDirectory?: string, flowSourcePath?: string): Promise<undefined>;
2
+ export declare function runTest(target: Target, testRegExps?: string[], outDirectory?: string, flowSourcePath?: string, force?: boolean): Promise<undefined>;
3
3
  export declare const getTestUrl: (target: Target, jobLocation: string) => string;
@@ -87,11 +87,11 @@ var chalk_1 = __importDefault(require("chalk"));
87
87
  var utils_2 = require("../../utils/utils");
88
88
  var createSASjsInstance_1 = require("../../utils/createSASjsInstance");
89
89
  // interface
90
- function runTest(target, testRegExps, outDirectory, flowSourcePath) {
90
+ function runTest(target, testRegExps, outDirectory, flowSourcePath, force) {
91
91
  var _a, _b;
92
92
  if (testRegExps === void 0) { testRegExps = []; }
93
93
  return __awaiter(this, void 0, void 0, function () {
94
- var testFlowData, testFlow, flow, sasjs, authConfig, username, password, _c, sas9CredentialsError, e_1, result, isCodeExamplePrinted, printCodeExample, jsonPath, xmlPath, _d, csvData, csvPath, coverageReportPath, resultTable, testSuites, testsCount, passedTestsCount, testsWithResultsCount;
94
+ var testFlowData, testFlow, flow, sasjs, authConfig, username, password, _c, sas9CredentialsError, e_1, result, isCodeExamplePrinted, printCodeExample, jsonPath, xmlPath, _d, csvData, csvPath, coverageReportPath, resultTable, testSuites, testsCount, passedTestsCount, testsWithResultsCount, failedTestsCount, testsWithoutResultCount, errorMessage;
95
95
  var _this = this;
96
96
  return __generator(this, function (_e) {
97
97
  switch (_e.label) {
@@ -394,6 +394,17 @@ function runTest(target, testRegExps, outDirectory, flowSourcePath) {
394
394
  (_b = process.logger) === null || _b === void 0 ? void 0 : _b.info("Tests provided results: ".concat(testsWithResultsCount + '/' + testsCount, " (").concat(chalk_1.default.greenBright(Math.round((testsWithResultsCount / testsCount) * 100 || 0) + '%'), ")\n Tests that pass: ").concat(passedTestsCount + '/' + testsWithResultsCount, " (").concat(chalk_1.default.greenBright(Math.round((passedTestsCount / testsWithResultsCount) * 100 || 0) + '%'), ")\n "));
395
395
  (0, displayResult_1.displaySuccess)("Tests execution finished. The results are stored at:\n ".concat(jsonPath, "\n ").concat(csvPath, "\n ").concat(xmlPath));
396
396
  (0, displayResult_1.displaySuccess)("Tests coverage report:\n ".concat(coverageReportPath));
397
+ if (!force) {
398
+ failedTestsCount = testsWithResultsCount - passedTestsCount;
399
+ testsWithoutResultCount = testsCount - testsWithResultsCount;
400
+ errorMessage = '';
401
+ if (testsWithoutResultCount > 0)
402
+ errorMessage = "".concat(testsWithoutResultCount, " ").concat(testsWithoutResultCount === 1 ? 'test' : 'tests', " failed to complete!\n");
403
+ if (failedTestsCount > 0)
404
+ errorMessage += "".concat(failedTestsCount, " ").concat(failedTestsCount === 1 ? 'test' : 'tests', " completed with failures!");
405
+ if (errorMessage)
406
+ return [2 /*return*/, Promise.reject(errorMessage)];
407
+ }
397
408
  return [2 /*return*/];
398
409
  }
399
410
  });
@@ -57,15 +57,15 @@ var targetCommand_1 = require("../../types/command/targetCommand");
57
57
  var utils_1 = require("../../utils");
58
58
  var test_1 = require("./test");
59
59
  var syntax = 'test [filteringString..]';
60
- var usage = 'Usage: sasjs test [filtering-strings..] --source <test-flow-path> --outDirectory <folder-path> --target <target-name>';
60
+ var usage = 'Usage: sasjs test [filtering-strings..] --source <test-flow-path> --outDirectory <folder-path> --target <target-name> --force';
61
61
  var description = 'Triggers SAS unit tests.';
62
62
  var examples = [
63
63
  {
64
- command: 'sasjs test jobs/standalone1 jobs/standalone2 --source <test-flow-path> --outDirectory <folder-path> --target <target-name>',
64
+ command: 'sasjs test jobs/standalone1 jobs/standalone2 --source <test-flow-path> --outDirectory <folder-path> --target <target-name> --force',
65
65
  description: ''
66
66
  },
67
67
  {
68
- command: 'sasjs test jobs/standalone1 jobs/standalone2 -s <test-flow-path> --out <folder-path> --t <target-name>',
68
+ command: 'sasjs test jobs/standalone1 jobs/standalone2 -s <test-flow-path> --out <folder-path> -t <target-name> -f',
69
69
  description: ''
70
70
  }
71
71
  ];
@@ -77,12 +77,18 @@ var TestCommand = /** @class */ (function (_super) {
77
77
  outDirectory: {
78
78
  type: 'string',
79
79
  alias: 'out',
80
- description: 'Path to output folder for tests resuls.'
80
+ description: 'Path to output folder for tests results.'
81
81
  },
82
82
  source: {
83
83
  type: 'string',
84
84
  alias: 's',
85
85
  description: 'Test flow located at source will be executed.'
86
+ },
87
+ force: {
88
+ type: 'boolean',
89
+ default: false,
90
+ alias: 'f',
91
+ description: 'If present, CLI will force command to finish running all tests and will not return an error code even when some are failing.'
86
92
  }
87
93
  },
88
94
  syntax: syntax,
@@ -93,14 +99,14 @@ var TestCommand = /** @class */ (function (_super) {
93
99
  }
94
100
  TestCommand.prototype.execute = function () {
95
101
  return __awaiter(this, void 0, void 0, function () {
96
- var target, _a, filteringString, outDirectory, source;
102
+ var target, _a, filteringString, outDirectory, source, force;
97
103
  return __generator(this, function (_b) {
98
104
  switch (_b.label) {
99
105
  case 0: return [4 /*yield*/, this.getTargetInfo()];
100
106
  case 1:
101
107
  target = (_b.sent()).target;
102
- _a = this.parsed, filteringString = _a.filteringString, outDirectory = _a.outDirectory, source = _a.source;
103
- return [4 /*yield*/, (0, test_1.runTest)(target, filteringString, outDirectory, source)
108
+ _a = this.parsed, filteringString = _a.filteringString, outDirectory = _a.outDirectory, source = _a.source, force = _a.force;
109
+ return [4 /*yield*/, (0, test_1.runTest)(target, filteringString, outDirectory, source, force)
104
110
  .then(function () {
105
111
  return command_1.ReturnCode.Success;
106
112
  })
@@ -1 +1 @@
1
- export declare const sasjsout = "\n%macro sasjsout(type,fref=sasjs);\n%global sysprocessmode SYS_JES_JOB_URI;\n%if \"&sysprocessmode\"=\"SAS Compute Server\" %then %do;\n %if &type=HTML %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name=\"_webout.json\"\n contenttype=\"text/html\";\n %end;\n %else %if &type=JS or &type=JS64 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.js'\n contenttype='application/javascript';\n %end;\n %else %if &type=CSS or &type=CSS64 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.css'\n contenttype='text/css';\n %end;\n %else %if &type=PNG or &type=GIF or &type=JPEG or &type=JPG %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\"\n name=\"_webout.%lowcase(&type)\"\n contenttype=\"image/%lowcase(&type)\" lrecl=2000000 recfm=n;\n %end;\n %else %if &type=ICO %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.ico'\n contenttype='image/vnd.microsoft.icon' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=JSON %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.json'\n contenttype='application/json' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=MP3 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.mp3'\n contenttype='audio/mpeg' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=WAV %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.wav'\n contenttype='audio/x-wav' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=OGG %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.ogg'\n contenttype='audio/ogg' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=WOFF or &type=WOFF2 or &type=TTF %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\"\n contenttype=\"font/%lowcase(&type)\";\n %end;\n %else %if &type=MP4 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\"\n contenttype=\"video/mp4\";\n %end;\n%end;\n%else %do;\n %if &type=JS or &type=JS64 %then %do;\n %let rc=%sysfunc(stpsrv_header(\n Content-type,application/javascript%str(;)charset=UTF-8\n ));\n %end;\n %else %if &type=CSS or &type=CSS64 %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,text/css));\n %end;\n %else %if &type=PNG or &type=GIF or &type=JPEG or &type=JPG %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,image/%lowcase(&type)));\n %end;\n %else %if &type=ICO %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,image/vnd.microsoft.icon));\n %end;\n %else %if &type=JSON %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,application/json));\n %end;\n %else %if &type=MP3 %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,audio/mpeg));\n %end;\n %else %if &type=WAV %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,audio/x-wav));\n %end;\n %else %if &type=OGG %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,audio/ogg));\n %end;\n %else %if &type=WOFF or &type=WOFF2 or &type=TTF %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,font/%lowcase(&type)));\n %end;\n %else %if &type=MP4 %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,video/mp4));\n %end;\n%end;\n%if &type=HTML %then %do;\n /*\n We need to perform some substitutions -eg to get the APPLOC and SERVERTYPE.\n Therefore the developer should avoid writing lines that exceed 32k\n characters (eg base64 encoded images) as they will get truncated when passing\n through the datastep. This could of course be re-written using LUA, removing\n the length restriction. Pull requests are welcome!\n */\n filename _sjs temp;\n data _null_;\n file _sjs lrecl=32767 encoding='utf-8';\n infile &fref lrecl=32767;\n input;\n length appLoc expanded_path $1048;\n if _n_=1 then do;\n retain pgm \"&_program\" appLoc expanded_path;\n /* index is deployed in the /services/ folder under the appLoc */\n appLoc=substr(pgm,1,find(pgm,'/services/')-1);\n expanded_path=cats('?_PROGRAM=',appLoc,'/services/');\n end;\n if find(_infile_,' appLoc: ') then put ' appLoc: ' apploc:$quote1048. ',';\n else if find(_infile_,' serverType: ') then do;\n if symexist('_metaperson') then put ' serverType: \"SAS9\" ,';\n else put ' serverType: \"SASVIYA\" ,';\n end;\n else if find(_infile_,' hostUrl: ') then do;\n /* nothing - we are streaming, so remove to default as hostname */\n end;\n else do;\n length newline $32767;\n /* during SAS9 compilation, dependencies are assigned three slashes /// */\n newline=tranwrd(_infile_,'?_PROGRAM=///',cats(expanded_path));\n put newline;\n end;\n run;\n %let fref=_sjs;\n%end;\n\n/**\n * In SAS9, JS & CSS files are base64 encoded to avoid UTF8 issues in WLATIN1\n * metadata - so in this case, decode and stream byte by byte.\n * */\n%if &type=GIF or &type=PNG or &type=JPG or &type=JPEG or &type=ICO or &type=MP3\nor &type=JS64 or &type=CSS64 or &type=WAV or &type=OGG or &type=WOFF\nor &type=WOFF2 or &type=TTF or &type=MP4\n%then %do;\n data _null_;\n length filein 8 fileout 8;\n filein = fopen(\"&fref\",'I',4,'B');\n fileout = fopen(\"_webout\",'A',1,'B');\n char= '20'x;\n do while(fread(filein)=0);\n length raw $4 ;\n do i=1 to 4;\n rc=fget(filein,char,1);\n substr(raw,i,1)=char;\n end;\n rc = fput(fileout, input(raw,$base64X4.));\n rc =fwrite(fileout);\n end;\n rc = fclose(filein);\n rc = fclose(fileout);\n run;\n%end;\n%else %do;\n data _null_;\n length filein 8 fileid 8;\n filein = fopen(\"&fref\",'I',1,'B');\n fileid = fopen(\"_webout\",'A',1,'B');\n rec = '20'x;\n do while(fread(filein)=0);\n rc = fget(filein,rec,1);\n rc = fput(fileid, rec);\n rc =fwrite(fileid);\n end;\n rc = fclose(filein);\n rc = fclose(fileid);\n run;\n%end;\n%mend;";
1
+ export declare const sasjsout = "\n%macro sasjsout(type,fref=sasjs);\n%global sysprocessmode SYS_JES_JOB_URI;\n%if \"&sysprocessmode\"=\"SAS Compute Server\" %then %do;\n %if &type=HTML %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name=\"_webout.json\"\n contenttype=\"text/html\";\n %end;\n %else %if &type=JS or &type=JS64 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.js'\n contenttype='application/javascript';\n %end;\n %else %if &type=CSS or &type=CSS64 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.css'\n contenttype='text/css';\n %end;\n %else %if &type=PNG or &type=GIF or &type=JPEG or &type=JPG %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\"\n name=\"_webout.%lowcase(&type)\"\n contenttype=\"image/%lowcase(&type)\" lrecl=2000000 recfm=n;\n %end;\n %else %if &type=ICO %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.ico'\n contenttype='image/vnd.microsoft.icon' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=JSON %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.json'\n contenttype='application/json' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=MP3 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.mp3'\n contenttype='audio/mpeg' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=WAV %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.wav'\n contenttype='audio/x-wav' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=OGG %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.ogg'\n contenttype='audio/ogg' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=WOFF or &type=WOFF2 or &type=TTF %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\"\n contenttype=\"font/%lowcase(&type)\";\n %end;\n %else %if &type=MP4 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\"\n contenttype=\"video/mp4\";\n %end;\n%end;\n%else %do;\n %if &type=JS or &type=JS64 %then %do;\n %let rc=%sysfunc(stpsrv_header(\n Content-type,application/javascript%str(;)charset=UTF-8\n ));\n %end;\n %else %if &type=CSS or &type=CSS64 %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,text/css));\n %end;\n %else %if &type=PNG or &type=GIF or &type=JPEG or &type=JPG %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,image/%lowcase(&type)));\n %end;\n %else %if &type=ICO %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,image/vnd.microsoft.icon));\n %end;\n %else %if &type=JSON %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,application/json));\n %end;\n %else %if &type=MP3 %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,audio/mpeg));\n %end;\n %else %if &type=WAV %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,audio/x-wav));\n %end;\n %else %if &type=OGG %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,audio/ogg));\n %end;\n %else %if &type=WOFF or &type=WOFF2 or &type=TTF %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,font/%lowcase(&type)));\n %end;\n %else %if &type=MP4 %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,video/mp4));\n %end;\n%end;\n%if &type=HTML %then %do;\n /*\n We need to perform some substitutions -eg to get the APPLOC and SERVERTYPE.\n Therefore the developer should avoid writing lines that exceed 32k\n characters (eg base64 encoded images) as they will get truncated when passing\n through the datastep. This could of course be re-written using LUA, removing\n the length restriction. Pull requests are welcome!\n */\n filename _sjs temp;\n data _null_;\n file _sjs lrecl=32767 encoding='utf-8';\n infile &fref lrecl=32767;\n input;\n length appLoc expanded_path $1048;\n if _n_=1 then do;\n retain pgm \"&_program\" appLoc expanded_path;\n /* index is deployed in the /services/ folder under the appLoc */\n appLoc=substr(pgm,1,find(pgm,'/services/')-1);\n expanded_path=cats('?_PROGRAM=',appLoc,'/services/');\n end;\n if find(_infile_,' appLoc: ') then put ' appLoc: ' apploc:$quote1048. ',';\n else if find(_infile_,' serverType: ') then do;\n if symexist('_metaperson') then put ' serverType: \"SAS9\" ,';\n else put ' serverType: \"SASVIYA\" ,';\n end;\n else if find(_infile_,' serverUrl: ') then do;\n /* nothing - we are streaming, so remove to default as hostname */\n end;\n else do;\n /* More recently, SASjs apps avoid inline JS to allow strict CSP */\n length infile in1 in2 $32767;\n infile=cats(_infile_);\n spos1=index(upcase(infile),'APPLOC=\"');\n if spos1>0 then do;\n in1=substr(infile,1,spos1+7);\n in2=subpad(infile,spos1+8);\n in2=substr(in2,index(in2,'\"'));\n infile=cats(in1,appLoc,in2);\n putlog \"new apploc: \" infile=;\n end;\n /* find & replace serverType in HTML attributes */\n spos2=index(upcase(infile),'SERVERTYPE=\"');\n if spos2>0 then do;\n in1=substr(infile,1,spos2+11);\n in2=subpad(infile,spos2+12);\n in2=substr(in2,index(in2,'\"'));\n if symexist('sasjsprocessmode') then infile=cats(in1,\"SASJS\",in2);\n else if \"&sysprocessmode\"=\"SAS Object Server\"\n or \"&sysprocessmode\"= \"SAS Compute Server\"\n then infile=cats(in1,\"SASVIYA\",in2);\n else infile=cats(in1,\"SAS9\",in2);\n putlog \"new servertype: \" infile=;\n end;\n /* find & replace serverUrl in HTML attributes */\n spos3=index(upcase(infile),'SERVERURL=\"');\n if spos3>0 then do;\n in1=substr(infile,1,spos3+10);\n in2=subpad(infile,spos3+11);\n in2=substr(in2,index(in2,'\"'));\n infile=cats(in1,in2);\n putlog \"new serverUrl: \" infile=;\n end;\n if sum(spos1,spos2,spos3)>0 then put infile;\n else do;\n /* during SAS9 sasjs compile, dependencies get three slashes /// */\n infile=tranwrd(_infile_,'?_PROGRAM=///',cats(expanded_path));\n put infile;\n end;\n end;\n run;\n %let fref=_sjs;\n%end;\n\n/**\n * In SAS9, JS & CSS files are base64 encoded to avoid UTF8 issues in WLATIN1\n * metadata - so in this case, decode and stream byte by byte.\n * */\n%if &type=GIF or &type=PNG or &type=JPG or &type=JPEG or &type=ICO or &type=MP3\nor &type=JS64 or &type=CSS64 or &type=WAV or &type=OGG or &type=WOFF\nor &type=WOFF2 or &type=TTF or &type=MP4\n%then %do;\n data _null_;\n length filein 8 fileout 8;\n filein = fopen(\"&fref\",'I',4,'B');\n fileout = fopen(\"_webout\",'A',1,'B');\n char= '20'x;\n do while(fread(filein)=0);\n length raw $4 ;\n do i=1 to 4;\n rc=fget(filein,char,1);\n substr(raw,i,1)=char;\n end;\n rc = fput(fileout, input(raw,$base64X4.));\n rc =fwrite(fileout);\n end;\n rc = fclose(filein);\n rc = fclose(fileout);\n run;\n%end;\n%else %do;\n data _null_;\n length filein 8 fileid 8;\n filein = fopen(\"&fref\",'I',1,'B');\n fileid = fopen(\"_webout\",'A',1,'B');\n rec = '20'x;\n do while(fread(filein)=0);\n rc = fget(filein,rec,1);\n rc = fput(fileid, rec);\n rc =fwrite(fileid);\n end;\n rc = fclose(filein);\n rc = fclose(fileid);\n run;\n%end;\n%mend;";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.sasjsout = void 0;
4
- exports.sasjsout = "\n%macro sasjsout(type,fref=sasjs);\n%global sysprocessmode SYS_JES_JOB_URI;\n%if \"&sysprocessmode\"=\"SAS Compute Server\" %then %do;\n %if &type=HTML %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name=\"_webout.json\"\n contenttype=\"text/html\";\n %end;\n %else %if &type=JS or &type=JS64 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.js'\n contenttype='application/javascript';\n %end;\n %else %if &type=CSS or &type=CSS64 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.css'\n contenttype='text/css';\n %end;\n %else %if &type=PNG or &type=GIF or &type=JPEG or &type=JPG %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\"\n name=\"_webout.%lowcase(&type)\"\n contenttype=\"image/%lowcase(&type)\" lrecl=2000000 recfm=n;\n %end;\n %else %if &type=ICO %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.ico'\n contenttype='image/vnd.microsoft.icon' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=JSON %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.json'\n contenttype='application/json' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=MP3 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.mp3'\n contenttype='audio/mpeg' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=WAV %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.wav'\n contenttype='audio/x-wav' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=OGG %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.ogg'\n contenttype='audio/ogg' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=WOFF or &type=WOFF2 or &type=TTF %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\"\n contenttype=\"font/%lowcase(&type)\";\n %end;\n %else %if &type=MP4 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\"\n contenttype=\"video/mp4\";\n %end;\n%end;\n%else %do;\n %if &type=JS or &type=JS64 %then %do;\n %let rc=%sysfunc(stpsrv_header(\n Content-type,application/javascript%str(;)charset=UTF-8\n ));\n %end;\n %else %if &type=CSS or &type=CSS64 %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,text/css));\n %end;\n %else %if &type=PNG or &type=GIF or &type=JPEG or &type=JPG %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,image/%lowcase(&type)));\n %end;\n %else %if &type=ICO %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,image/vnd.microsoft.icon));\n %end;\n %else %if &type=JSON %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,application/json));\n %end;\n %else %if &type=MP3 %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,audio/mpeg));\n %end;\n %else %if &type=WAV %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,audio/x-wav));\n %end;\n %else %if &type=OGG %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,audio/ogg));\n %end;\n %else %if &type=WOFF or &type=WOFF2 or &type=TTF %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,font/%lowcase(&type)));\n %end;\n %else %if &type=MP4 %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,video/mp4));\n %end;\n%end;\n%if &type=HTML %then %do;\n /*\n We need to perform some substitutions -eg to get the APPLOC and SERVERTYPE.\n Therefore the developer should avoid writing lines that exceed 32k\n characters (eg base64 encoded images) as they will get truncated when passing\n through the datastep. This could of course be re-written using LUA, removing\n the length restriction. Pull requests are welcome!\n */\n filename _sjs temp;\n data _null_;\n file _sjs lrecl=32767 encoding='utf-8';\n infile &fref lrecl=32767;\n input;\n length appLoc expanded_path $1048;\n if _n_=1 then do;\n retain pgm \"&_program\" appLoc expanded_path;\n /* index is deployed in the /services/ folder under the appLoc */\n appLoc=substr(pgm,1,find(pgm,'/services/')-1);\n expanded_path=cats('?_PROGRAM=',appLoc,'/services/');\n end;\n if find(_infile_,' appLoc: ') then put ' appLoc: ' apploc:$quote1048. ',';\n else if find(_infile_,' serverType: ') then do;\n if symexist('_metaperson') then put ' serverType: \"SAS9\" ,';\n else put ' serverType: \"SASVIYA\" ,';\n end;\n else if find(_infile_,' hostUrl: ') then do;\n /* nothing - we are streaming, so remove to default as hostname */\n end;\n else do;\n length newline $32767;\n /* during SAS9 compilation, dependencies are assigned three slashes /// */\n newline=tranwrd(_infile_,'?_PROGRAM=///',cats(expanded_path));\n put newline;\n end;\n run;\n %let fref=_sjs;\n%end;\n\n/**\n * In SAS9, JS & CSS files are base64 encoded to avoid UTF8 issues in WLATIN1\n * metadata - so in this case, decode and stream byte by byte.\n * */\n%if &type=GIF or &type=PNG or &type=JPG or &type=JPEG or &type=ICO or &type=MP3\nor &type=JS64 or &type=CSS64 or &type=WAV or &type=OGG or &type=WOFF\nor &type=WOFF2 or &type=TTF or &type=MP4\n%then %do;\n data _null_;\n length filein 8 fileout 8;\n filein = fopen(\"&fref\",'I',4,'B');\n fileout = fopen(\"_webout\",'A',1,'B');\n char= '20'x;\n do while(fread(filein)=0);\n length raw $4 ;\n do i=1 to 4;\n rc=fget(filein,char,1);\n substr(raw,i,1)=char;\n end;\n rc = fput(fileout, input(raw,$base64X4.));\n rc =fwrite(fileout);\n end;\n rc = fclose(filein);\n rc = fclose(fileout);\n run;\n%end;\n%else %do;\n data _null_;\n length filein 8 fileid 8;\n filein = fopen(\"&fref\",'I',1,'B');\n fileid = fopen(\"_webout\",'A',1,'B');\n rec = '20'x;\n do while(fread(filein)=0);\n rc = fget(filein,rec,1);\n rc = fput(fileid, rec);\n rc =fwrite(fileid);\n end;\n rc = fclose(filein);\n rc = fclose(fileid);\n run;\n%end;\n%mend;";
4
+ exports.sasjsout = "\n%macro sasjsout(type,fref=sasjs);\n%global sysprocessmode SYS_JES_JOB_URI;\n%if \"&sysprocessmode\"=\"SAS Compute Server\" %then %do;\n %if &type=HTML %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name=\"_webout.json\"\n contenttype=\"text/html\";\n %end;\n %else %if &type=JS or &type=JS64 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.js'\n contenttype='application/javascript';\n %end;\n %else %if &type=CSS or &type=CSS64 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.css'\n contenttype='text/css';\n %end;\n %else %if &type=PNG or &type=GIF or &type=JPEG or &type=JPG %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\"\n name=\"_webout.%lowcase(&type)\"\n contenttype=\"image/%lowcase(&type)\" lrecl=2000000 recfm=n;\n %end;\n %else %if &type=ICO %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.ico'\n contenttype='image/vnd.microsoft.icon' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=JSON %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.json'\n contenttype='application/json' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=MP3 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.mp3'\n contenttype='audio/mpeg' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=WAV %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.wav'\n contenttype='audio/x-wav' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=OGG %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.ogg'\n contenttype='audio/ogg' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=WOFF or &type=WOFF2 or &type=TTF %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\"\n contenttype=\"font/%lowcase(&type)\";\n %end;\n %else %if &type=MP4 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\"\n contenttype=\"video/mp4\";\n %end;\n%end;\n%else %do;\n %if &type=JS or &type=JS64 %then %do;\n %let rc=%sysfunc(stpsrv_header(\n Content-type,application/javascript%str(;)charset=UTF-8\n ));\n %end;\n %else %if &type=CSS or &type=CSS64 %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,text/css));\n %end;\n %else %if &type=PNG or &type=GIF or &type=JPEG or &type=JPG %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,image/%lowcase(&type)));\n %end;\n %else %if &type=ICO %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,image/vnd.microsoft.icon));\n %end;\n %else %if &type=JSON %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,application/json));\n %end;\n %else %if &type=MP3 %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,audio/mpeg));\n %end;\n %else %if &type=WAV %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,audio/x-wav));\n %end;\n %else %if &type=OGG %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,audio/ogg));\n %end;\n %else %if &type=WOFF or &type=WOFF2 or &type=TTF %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,font/%lowcase(&type)));\n %end;\n %else %if &type=MP4 %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,video/mp4));\n %end;\n%end;\n%if &type=HTML %then %do;\n /*\n We need to perform some substitutions -eg to get the APPLOC and SERVERTYPE.\n Therefore the developer should avoid writing lines that exceed 32k\n characters (eg base64 encoded images) as they will get truncated when passing\n through the datastep. This could of course be re-written using LUA, removing\n the length restriction. Pull requests are welcome!\n */\n filename _sjs temp;\n data _null_;\n file _sjs lrecl=32767 encoding='utf-8';\n infile &fref lrecl=32767;\n input;\n length appLoc expanded_path $1048;\n if _n_=1 then do;\n retain pgm \"&_program\" appLoc expanded_path;\n /* index is deployed in the /services/ folder under the appLoc */\n appLoc=substr(pgm,1,find(pgm,'/services/')-1);\n expanded_path=cats('?_PROGRAM=',appLoc,'/services/');\n end;\n if find(_infile_,' appLoc: ') then put ' appLoc: ' apploc:$quote1048. ',';\n else if find(_infile_,' serverType: ') then do;\n if symexist('_metaperson') then put ' serverType: \"SAS9\" ,';\n else put ' serverType: \"SASVIYA\" ,';\n end;\n else if find(_infile_,' serverUrl: ') then do;\n /* nothing - we are streaming, so remove to default as hostname */\n end;\n else do;\n /* More recently, SASjs apps avoid inline JS to allow strict CSP */\n length infile in1 in2 $32767;\n infile=cats(_infile_);\n spos1=index(upcase(infile),'APPLOC=\"');\n if spos1>0 then do;\n in1=substr(infile,1,spos1+7);\n in2=subpad(infile,spos1+8);\n in2=substr(in2,index(in2,'\"'));\n infile=cats(in1,appLoc,in2);\n putlog \"new apploc: \" infile=;\n end;\n /* find & replace serverType in HTML attributes */\n spos2=index(upcase(infile),'SERVERTYPE=\"');\n if spos2>0 then do;\n in1=substr(infile,1,spos2+11);\n in2=subpad(infile,spos2+12);\n in2=substr(in2,index(in2,'\"'));\n if symexist('sasjsprocessmode') then infile=cats(in1,\"SASJS\",in2);\n else if \"&sysprocessmode\"=\"SAS Object Server\"\n or \"&sysprocessmode\"= \"SAS Compute Server\"\n then infile=cats(in1,\"SASVIYA\",in2);\n else infile=cats(in1,\"SAS9\",in2);\n putlog \"new servertype: \" infile=;\n end;\n /* find & replace serverUrl in HTML attributes */\n spos3=index(upcase(infile),'SERVERURL=\"');\n if spos3>0 then do;\n in1=substr(infile,1,spos3+10);\n in2=subpad(infile,spos3+11);\n in2=substr(in2,index(in2,'\"'));\n infile=cats(in1,in2);\n putlog \"new serverUrl: \" infile=;\n end;\n if sum(spos1,spos2,spos3)>0 then put infile;\n else do;\n /* during SAS9 sasjs compile, dependencies get three slashes /// */\n infile=tranwrd(_infile_,'?_PROGRAM=///',cats(expanded_path));\n put infile;\n end;\n end;\n run;\n %let fref=_sjs;\n%end;\n\n/**\n * In SAS9, JS & CSS files are base64 encoded to avoid UTF8 issues in WLATIN1\n * metadata - so in this case, decode and stream byte by byte.\n * */\n%if &type=GIF or &type=PNG or &type=JPG or &type=JPEG or &type=ICO or &type=MP3\nor &type=JS64 or &type=CSS64 or &type=WAV or &type=OGG or &type=WOFF\nor &type=WOFF2 or &type=TTF or &type=MP4\n%then %do;\n data _null_;\n length filein 8 fileout 8;\n filein = fopen(\"&fref\",'I',4,'B');\n fileout = fopen(\"_webout\",'A',1,'B');\n char= '20'x;\n do while(fread(filein)=0);\n length raw $4 ;\n do i=1 to 4;\n rc=fget(filein,char,1);\n substr(raw,i,1)=char;\n end;\n rc = fput(fileout, input(raw,$base64X4.));\n rc =fwrite(fileout);\n end;\n rc = fclose(filein);\n rc = fclose(fileout);\n run;\n%end;\n%else %do;\n data _null_;\n length filein 8 fileid 8;\n filein = fopen(\"&fref\",'I',1,'B');\n fileid = fopen(\"_webout\",'A',1,'B');\n rec = '20'x;\n do while(fread(filein)=0);\n rc = fget(filein,rec,1);\n rc = fput(fileid, rec);\n rc =fwrite(fileid);\n end;\n rc = fclose(filein);\n rc = fclose(fileid);\n run;\n%end;\n%mend;";
@@ -8,7 +8,7 @@ function displaySuccess(message) {
8
8
  }
9
9
  exports.displaySuccess = displaySuccess;
10
10
  function displayError(err, errorMessage) {
11
- var _a, _b, _c;
11
+ var _a, _b, _c, _d;
12
12
  if (errorMessage === void 0) { errorMessage = ''; }
13
13
  if (errorMessage)
14
14
  errorMessage = "".concat(errorMessage, "\n");
@@ -47,5 +47,9 @@ function displayError(err, errorMessage) {
47
47
  }
48
48
  return "".concat(errorMessage).concat(failureDetails);
49
49
  }
50
+ else {
51
+ if (errorMessage)
52
+ (_d = process.logger) === null || _d === void 0 ? void 0 : _d.error(errorMessage);
53
+ }
50
54
  }
51
55
  exports.displayError = displayError;
package/package.json CHANGED
@@ -47,10 +47,10 @@
47
47
  "access": "public"
48
48
  },
49
49
  "dependencies": {
50
- "@sasjs/adapter": "3.8.5",
51
- "@sasjs/core": "4.18.15",
50
+ "@sasjs/adapter": "3.9.4",
51
+ "@sasjs/core": "4.23.4",
52
52
  "@sasjs/lint": "1.11.2",
53
- "@sasjs/utils": "2.42.0",
53
+ "@sasjs/utils": "2.44.0",
54
54
  "chalk": "4.1.2",
55
55
  "csv-stringify": "5.6.5",
56
56
  "dotenv": "10.0.0",
@@ -65,7 +65,7 @@
65
65
  "ora": "5.4.1",
66
66
  "rimraf": "3.0.2",
67
67
  "shelljs": "0.8.5",
68
- "ssl-root-cas": "^1.3.1",
68
+ "ssl-root-cas": "1.3.1",
69
69
  "xml": "1.0.1",
70
70
  "yargs": "17.2.1"
71
71
  },
@@ -87,11 +87,12 @@
87
87
  "jest-cli": "27.4.7",
88
88
  "jest-extended": "1.1.0",
89
89
  "nodemon": "2.0.15",
90
+ "prettier": "2.6.2",
90
91
  "ts-jest": "27.1.2",
91
92
  "ts-node": "10.4.0",
92
93
  "tslib": "2.3.1",
93
94
  "typescript": "4.5.4",
94
95
  "util": "0.12.4"
95
96
  },
96
- "version": "3.13.3"
97
+ "version": "3.13.6"
97
98
  }
@@ -1,3 +0,0 @@
1
- import { Target } from '@sasjs/utils/types';
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>;
@@ -1,60 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.compileJobFile = void 0;
40
- var utils_1 = require("@sasjs/utils");
41
- var loadDependencies_1 = require("./loadDependencies");
42
- function compileJobFile(target, filePath, macroFolders, programFolders, programVar, compileTree) {
43
- if (programVar === void 0) { programVar = ''; }
44
- return __awaiter(this, void 0, void 0, function () {
45
- var dependencies;
46
- return __generator(this, function (_a) {
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, compileTree)];
49
- case 1:
50
- dependencies = _a.sent();
51
- dependencies = "".concat(programVar ? programVar + '\n' : '').concat(dependencies);
52
- return [4 /*yield*/, (0, utils_1.createFile)(filePath, dependencies)];
53
- case 2:
54
- _a.sent();
55
- return [2 /*return*/];
56
- }
57
- });
58
- });
59
- }
60
- exports.compileJobFile = compileJobFile;
@@ -1,4 +0,0 @@
1
- import { CompileTree } from '@sasjs/utils';
2
- import { Target, ServerType } from '@sasjs/utils/types';
3
- export declare function compileServiceFile(target: Target, filePath: string, macroFolders: string[], programFolders: string[], programVar: string | undefined, compileTree: CompileTree): Promise<void>;
4
- export declare function getPreCodeForServicePack(serverType: ServerType): Promise<string>;