@sasjs/cli 3.13.5 → 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.
- package/build/commands/help/help.js +3 -2
- package/build/commands/testing/spec/testCommand.spec.js +5 -3
- package/build/commands/testing/spec/testing.spec.js +32 -4
- package/build/commands/testing/test.d.ts +1 -1
- package/build/commands/testing/test.js +13 -2
- package/build/commands/testing/testCommand.js +13 -7
- package/build/commands/web/internal/sasjsout.d.ts +1 -1
- package/build/commands/web/internal/sasjsout.js +1 -1
- package/package.json +1 -1
|
@@ -298,11 +298,12 @@ function printHelpText() {
|
|
|
298
298
|
title: 'test',
|
|
299
299
|
description: [
|
|
300
300
|
"Triggers SAS unit tests.",
|
|
301
|
-
"[2spaces]command example: sasjs test <filteringString> --source <testFlowPath> --outDirectory <folderPath> -t <targetName>",
|
|
301
|
+
"[2spaces]command example: sasjs test <filteringString> --source <testFlowPath> --outDirectory <folderPath> -t <targetName> --force",
|
|
302
302
|
"",
|
|
303
303
|
"[2spaces]NOTE: Providing <filteringString> is optional. If not present, all tests mentioned in test flow file will be executed.",
|
|
304
304
|
"[2spaces]NOTE: Providing source flag is optional. If not present, CLI will use test flow located at sasjsbuild/testFlow.json.",
|
|
305
|
-
"[2spaces]NOTE: Providing outDirectory flag is optional. If not present, CLI will use save outputs into sasjsresults folder."
|
|
305
|
+
"[2spaces]NOTE: Providing outDirectory flag is optional. If not present, CLI will use save outputs into sasjsresults folder.",
|
|
306
|
+
"[2spaces]NOTE: Providing force (--force or -f) flag is optional. If present, CLI will force command to finish running all tests and will not return an error code even when some are failing. Useful when the requirement is not to make CI Pipeline fail."
|
|
306
307
|
]
|
|
307
308
|
}
|
|
308
309
|
];
|
|
@@ -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>
|
|
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
|
|
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_,'
|
|
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_,'
|
|
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;";
|
package/package.json
CHANGED