@sasjs/cli 3.0.1 → 3.1.0
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/add/addCredential.d.ts +6 -2
- package/build/commands/add/addCredential.js +79 -47
- package/build/commands/add/addTarget.js +32 -20
- package/build/commands/add/internal/input.d.ts +7 -0
- package/build/commands/add/internal/input.js +53 -8
- package/build/commands/add/spec/addTarget.spec.js +78 -0
- package/build/commands/build/build.js +11 -11
- package/build/commands/build/internal/config.d.ts +1 -1
- package/build/commands/build/internal/config.js +5 -6
- package/build/commands/compile/compile.js +4 -4
- package/build/commands/compile/compileCommand.js +2 -1
- package/build/commands/compile/compileSingleFile.d.ts +1 -1
- package/build/commands/compile/compileSingleFile.js +6 -7
- package/build/commands/compile/internal/compareFolders.js +1 -2
- package/build/commands/compile/internal/compileJobFile.js +1 -1
- package/build/commands/compile/internal/compileServiceFile.js +32 -16
- package/build/commands/compile/internal/compileTestFile.d.ts +0 -2
- package/build/commands/compile/internal/compileTestFile.js +11 -15
- package/build/commands/compile/internal/getAllJobFolders.js +1 -1
- package/build/commands/compile/internal/getAllServiceFolders.js +1 -1
- package/build/commands/compile/internal/loadDependencies.d.ts +2 -3
- package/build/commands/compile/internal/loadDependencies.js +43 -230
- package/build/commands/compile/internal/spec/compileTestFile.spec.js +8 -8
- package/build/commands/compile/spec/compile.spec.js +30 -0
- package/build/commands/compile/spec/compileJobFile.spec.js +3 -3
- package/build/commands/compile/spec/compileServiceFile.spec.js +3 -3
- package/build/commands/compile/spec/loadDependencies.spec.js +37 -37
- package/build/commands/create/spec/reactAppFiles.js +5 -5
- package/build/commands/deploy/deploy.js +1 -1
- package/build/commands/deploy/spec/cbd.spec.js +19 -3
- package/build/commands/docs/generateDocs.js +4 -5
- package/build/commands/docs/internal/getFileInputs.d.ts +1 -1
- package/build/commands/docs/internal/getFileInputs.js +2 -2
- package/build/commands/docs/internal/getFileOutputs.d.ts +1 -1
- package/build/commands/docs/internal/getFileOutputs.js +2 -2
- package/build/commands/docs/internal/getFoldersForDocs.d.ts +1 -1
- package/build/commands/docs/internal/getFoldersForDocs.js +1 -1
- package/build/commands/job/internal/execute/viya.js +0 -6
- package/build/commands/job/internal/utils.js +6 -8
- package/build/commands/request/request.js +2 -2
- package/build/commands/run/run.js +1 -1
- package/build/commands/servicepack/deploy.js +1 -1
- package/build/commands/shared/fetchLogFileContent.js +6 -8
- package/build/commands/testing/test.js +1 -1
- package/build/commands/web/internal/getTags.d.ts +2 -1
- package/build/commands/web/internal/getTags.js +10 -12
- package/build/commands/web/internal/getWebServiceContent.js +1 -2
- package/build/commands/web/internal/sasjsout.d.ts +1 -1
- package/build/commands/web/internal/sasjsout.js +1 -1
- package/build/commands/web/internal/spec/updateLinkTag.spec.d.ts +4 -0
- package/build/commands/web/internal/spec/updateLinkTag.spec.js +32 -0
- package/build/commands/web/internal/updateAllTags.js +33 -8
- package/build/commands/web/internal/updateLinkTag.d.ts +4 -0
- package/build/commands/web/internal/updateLinkTag.js +24 -0
- package/build/commands/web/web.js +12 -13
- package/build/utils/auth.d.ts +10 -4
- package/build/utils/auth.js +17 -15
- package/build/utils/config.d.ts +2 -3
- package/build/utils/config.js +14 -16
- package/build/utils/file.d.ts +0 -6
- package/build/utils/file.js +1 -43
- package/build/utils/setConstants.js +1 -1
- package/build/utils/spec/utils.spec.js +31 -5
- package/build/utils/utils.d.ts +0 -2
- package/build/utils/utils.js +2 -21
- package/package.json +8 -14
- package/CHANGELOG.md +0 -30
- package/build/commands/compile/internal/config.d.ts +0 -25
- package/build/commands/compile/internal/config.js +0 -259
- package/build/commands/compile/spec/getDependencyPaths.spec.d.ts +0 -1
- package/build/commands/compile/spec/getDependencyPaths.spec.js +0 -263
- package/build/commands/compile/spec/getProgramDependencies.spec.d.ts +0 -1
- package/build/commands/compile/spec/getProgramDependencies.spec.js +0 -403
- package/build/commands/shared/dependencies.d.ts +0 -12
- package/build/commands/shared/dependencies.js +0 -332
- package/build/commands/web/internal/updateLinkHref.d.ts +0 -4
- package/build/commands/web/internal/updateLinkHref.js +0 -18
- package/build/utils/spec/utils.spec.server.d.ts +0 -1
- package/build/utils/spec/utils.spec.server.js +0 -72
|
@@ -205,6 +205,7 @@ function runTest(target, testRegExps, outDirectory, flowSourcePath) {
|
|
|
205
205
|
testUrl = testUrl + "&_contextName=" + encodeURIComponent(target.contextName);
|
|
206
206
|
}
|
|
207
207
|
printTestUrl = function () { return process.logger.info("Test URL: " + testUrl); };
|
|
208
|
+
printTestUrl();
|
|
208
209
|
return [4 /*yield*/, sasjs
|
|
209
210
|
.request(sasJobLocation, {}, { username: username, password: password }, function () {
|
|
210
211
|
displayResult_1.displayError(null, 'Login callback called. Request failed.');
|
|
@@ -247,7 +248,6 @@ function runTest(target, testRegExps, outDirectory, flowSourcePath) {
|
|
|
247
248
|
}
|
|
248
249
|
if (!((_a = res.result) === null || _a === void 0 ? void 0 : _a.test_results))
|
|
249
250
|
lineBreak = false;
|
|
250
|
-
printTestUrl();
|
|
251
251
|
if (!res.log) return [3 /*break*/, 2];
|
|
252
252
|
return [4 /*yield*/, saveOutput_1.saveLog(outDirectory, test, res.log, lineBreak)];
|
|
253
253
|
case 1:
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { JSDOM } from 'jsdom';
|
|
2
2
|
export declare const getScriptTags: (parsedHtml: JSDOM) => HTMLScriptElement[];
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const getStyleTags: (parsedHtml: JSDOM) => HTMLLinkElement[];
|
|
4
4
|
export declare const getFaviconTags: (parsedHtml: JSDOM) => HTMLLinkElement[];
|
|
5
|
+
export declare const getImgTags: (parsedHtml: JSDOM) => HTMLImageElement[];
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getFaviconTags = exports.
|
|
3
|
+
exports.getImgTags = exports.getFaviconTags = exports.getStyleTags = exports.getScriptTags = void 0;
|
|
4
4
|
var getScriptTags = function (parsedHtml) {
|
|
5
|
-
return Array.from(parsedHtml.window.document.
|
|
5
|
+
return Array.from(parsedHtml.window.document.getElementsByTagName('script'));
|
|
6
6
|
};
|
|
7
7
|
exports.getScriptTags = getScriptTags;
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
return linkTags;
|
|
8
|
+
var getStyleTags = function (parsedHtml) {
|
|
9
|
+
return Array.from(parsedHtml.window.document.getElementsByTagName('link')).filter(function (s) { return s.getAttribute('rel') === 'stylesheet'; });
|
|
11
10
|
};
|
|
12
|
-
exports.
|
|
11
|
+
exports.getStyleTags = getStyleTags;
|
|
13
12
|
var getFaviconTags = function (parsedHtml) {
|
|
14
|
-
|
|
15
|
-
return s.getAttribute('rel') &&
|
|
16
|
-
s.getAttribute('rel') &&
|
|
17
|
-
s.getAttribute('rel').includes('icon');
|
|
18
|
-
});
|
|
19
|
-
return linkTags;
|
|
13
|
+
return Array.from(parsedHtml.window.document.getElementsByTagName('link')).filter(function (s) { var _a; return (_a = s.getAttribute('rel')) === null || _a === void 0 ? void 0 : _a.includes('icon'); });
|
|
20
14
|
};
|
|
21
15
|
exports.getFaviconTags = getFaviconTags;
|
|
16
|
+
var getImgTags = function (parsedHtml) {
|
|
17
|
+
return Array.from(parsedHtml.window.document.getElementsByTagName('img')).filter(function (s) { return s.getAttribute('src'); });
|
|
18
|
+
};
|
|
19
|
+
exports.getImgTags = getImgTags;
|
|
@@ -38,7 +38,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.getWebServiceContent = void 0;
|
|
40
40
|
var utils_1 = require("@sasjs/utils");
|
|
41
|
-
var utils_2 = require("../../../utils");
|
|
42
41
|
var sasjsout_1 = require("./sasjsout");
|
|
43
42
|
var getWebServiceContent = function (contentBase64, type, serverType) {
|
|
44
43
|
if (type === void 0) { type = 'JS'; }
|
|
@@ -52,7 +51,7 @@ var getWebServiceContent = function (contentBase64, type, serverType) {
|
|
|
52
51
|
};
|
|
53
52
|
serviceContent = sasjsout_1.sasjsout + "\nfilename sasjs temp lrecl=99999999;\ndata _null_;\nfile sasjs;\n";
|
|
54
53
|
lines.forEach(function (line) {
|
|
55
|
-
var chunkedLines =
|
|
54
|
+
var chunkedLines = utils_1.chunk(line);
|
|
56
55
|
if (chunkedLines.length === 1) {
|
|
57
56
|
serviceContent += "put '" + chunkedLines[0].split("'").join("''") + "';\n";
|
|
58
57
|
}
|
|
@@ -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 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.png'\n contenttype='image/png' 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%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 %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,image/png));\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%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/* stream byte by byte */\n/* in SAS9, JS & CSS files are base64 encoded to avoid UTF8 issues in WLATIN1 metadata */\n%if &type=PNG or &type=ICO or &type=MP3 or &type=JS64 or &type=CSS64 or &type=WAV or &type=OGG\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 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.png'\n contenttype='image/png' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=JPG %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.jpg'\n contenttype='image/jpg' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=JPEG %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.jpeg'\n contenttype='image/jpeg' 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%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 %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,image/png));\n %end;\n %else %if &type=JPG %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,image/jpg));\n %end;\n %else %if &type=JPEG %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,image/jpeg));\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%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/* stream byte by byte */\n/* in SAS9, JS & CSS files are base64 encoded to avoid UTF8 issues in WLATIN1 metadata */\n%if &type=PNG or &type=JPG or &type=JPEG or &type=ICO or &type=MP3 or &type=JS64 or &type=CSS64 or &type=WAV or &type=OGG\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 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.png'\n contenttype='image/png' 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%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 %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,image/png));\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%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/* stream byte by byte */\n/* in SAS9, JS & CSS files are base64 encoded to avoid UTF8 issues in WLATIN1 metadata */\n%if &type=PNG or &type=ICO or &type=MP3 or &type=JS64 or &type=CSS64 or &type=WAV or &type=OGG\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 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.png'\n contenttype='image/png' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=JPG %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.jpg'\n contenttype='image/jpg' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=JPEG %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.jpeg'\n contenttype='image/jpeg' 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%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 %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,image/png));\n %end;\n %else %if &type=JPG %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,image/jpg));\n %end;\n %else %if &type=JPEG %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,image/jpeg));\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%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/* stream byte by byte */\n/* in SAS9, JS & CSS files are base64 encoded to avoid UTF8 issues in WLATIN1 metadata */\n%if &type=PNG or &type=JPG or &type=JPEG or &type=ICO or &type=MP3 or &type=JS64 or &type=CSS64 or &type=WAV or &type=OGG\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;";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @jest-environment jsdom
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var updateLinkTag_1 = require("../updateLinkTag");
|
|
7
|
+
describe('updateLinkTag', function () {
|
|
8
|
+
it("should update href of link tag", function () {
|
|
9
|
+
var linkTag = document.createElement('link');
|
|
10
|
+
linkTag.setAttribute('href', './style.css');
|
|
11
|
+
var assetPathMap = [];
|
|
12
|
+
var sasProgramPath = '/SASJobExecution?_FILE=appLoc/services/streamWebFolder/style.css';
|
|
13
|
+
assetPathMap.push({
|
|
14
|
+
source: 'style.css',
|
|
15
|
+
target: sasProgramPath
|
|
16
|
+
});
|
|
17
|
+
updateLinkTag_1.updateLinkTag(linkTag, assetPathMap);
|
|
18
|
+
expect(linkTag.getAttribute('href')).toEqual(sasProgramPath);
|
|
19
|
+
});
|
|
20
|
+
it("should update src of image tag", function () {
|
|
21
|
+
var imgTag = document.createElement('img');
|
|
22
|
+
imgTag.setAttribute('src', './image.jpeg');
|
|
23
|
+
var assetPathMap = [];
|
|
24
|
+
var sasProgramPath = '/SASJobExecution?_FILE=appLoc/services/streamWebFolder/image.jpeg';
|
|
25
|
+
assetPathMap.push({
|
|
26
|
+
source: 'image.jpeg',
|
|
27
|
+
target: sasProgramPath
|
|
28
|
+
});
|
|
29
|
+
updateLinkTag_1.updateLinkTag(imgTag, assetPathMap, 'image');
|
|
30
|
+
expect(imgTag.getAttribute('src')).toEqual(sasProgramPath);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -35,16 +35,37 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
39
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
40
|
+
if (!m) return o;
|
|
41
|
+
var i = m.call(o), r, ar = [], e;
|
|
42
|
+
try {
|
|
43
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
44
|
+
}
|
|
45
|
+
catch (error) { e = { error: error }; }
|
|
46
|
+
finally {
|
|
47
|
+
try {
|
|
48
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
49
|
+
}
|
|
50
|
+
finally { if (e) throw e.error; }
|
|
51
|
+
}
|
|
52
|
+
return ar;
|
|
53
|
+
};
|
|
54
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
55
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
56
|
+
to[j] = from[i];
|
|
57
|
+
return to;
|
|
58
|
+
};
|
|
38
59
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
60
|
exports.updateAllTags = void 0;
|
|
40
61
|
var utils_1 = require("@sasjs/utils");
|
|
41
62
|
var getTags_1 = require("./getTags");
|
|
42
63
|
var updateScriptTag_1 = require("./updateScriptTag");
|
|
43
|
-
var
|
|
64
|
+
var updateLinkTag_1 = require("./updateLinkTag");
|
|
44
65
|
var updateAllTags = function (parsedHtml, _a) {
|
|
45
66
|
var webSourcePathFull = _a.webSourcePathFull, destinationPath = _a.destinationPath, serverType = _a.serverType, assetPathMap = _a.assetPathMap;
|
|
46
67
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
47
|
-
var assetsNotFound, scriptTags,
|
|
68
|
+
var assetsNotFound, scriptTags, styleTags, faviconTags, linkTags, imgTags, notFoundErrors;
|
|
48
69
|
return __generator(this, function (_b) {
|
|
49
70
|
switch (_b.label) {
|
|
50
71
|
case 0:
|
|
@@ -62,21 +83,25 @@ var updateAllTags = function (parsedHtml, _a) {
|
|
|
62
83
|
}); })];
|
|
63
84
|
case 1:
|
|
64
85
|
_b.sent();
|
|
65
|
-
|
|
66
|
-
|
|
86
|
+
styleTags = getTags_1.getStyleTags(parsedHtml);
|
|
87
|
+
faviconTags = getTags_1.getFaviconTags(parsedHtml);
|
|
88
|
+
linkTags = __spreadArray(__spreadArray([], __read(styleTags)), __read(faviconTags));
|
|
89
|
+
linkTags.forEach(function (tag) {
|
|
67
90
|
try {
|
|
68
|
-
|
|
91
|
+
updateLinkTag_1.updateLinkTag(tag, assetPathMap);
|
|
69
92
|
}
|
|
70
93
|
catch (error) {
|
|
94
|
+
console.log(tag, error);
|
|
71
95
|
assetsNotFound.push(error);
|
|
72
96
|
}
|
|
73
97
|
});
|
|
74
|
-
|
|
75
|
-
|
|
98
|
+
imgTags = getTags_1.getImgTags(parsedHtml);
|
|
99
|
+
imgTags.forEach(function (tag) {
|
|
76
100
|
try {
|
|
77
|
-
|
|
101
|
+
updateLinkTag_1.updateLinkTag(tag, assetPathMap, 'image');
|
|
78
102
|
}
|
|
79
103
|
catch (error) {
|
|
104
|
+
console.log(tag, error);
|
|
80
105
|
assetsNotFound.push(error);
|
|
81
106
|
}
|
|
82
107
|
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateLinkTag = void 0;
|
|
4
|
+
var updateLinkTag = function (linkTag, assetPathMap, tagType) {
|
|
5
|
+
if (tagType === void 0) { tagType = 'link'; }
|
|
6
|
+
var linkSourcePath = tagType === 'link'
|
|
7
|
+
? linkTag.getAttribute('href')
|
|
8
|
+
: linkTag.getAttribute('src');
|
|
9
|
+
if (!linkSourcePath)
|
|
10
|
+
return;
|
|
11
|
+
var isUrl = linkSourcePath.startsWith('http') || linkSourcePath.startsWith('//');
|
|
12
|
+
if (isUrl)
|
|
13
|
+
return;
|
|
14
|
+
var assetPath = assetPathMap.find(function (entry) {
|
|
15
|
+
return entry.source === linkSourcePath || "./" + entry.source === linkSourcePath;
|
|
16
|
+
});
|
|
17
|
+
if (!(assetPath === null || assetPath === void 0 ? void 0 : assetPath.target)) {
|
|
18
|
+
throw new Error("Unable to find file: " + linkSourcePath);
|
|
19
|
+
}
|
|
20
|
+
tagType === 'link'
|
|
21
|
+
? linkTag.setAttribute('href', assetPath.target)
|
|
22
|
+
: linkTag.setAttribute('src', assetPath.target);
|
|
23
|
+
};
|
|
24
|
+
exports.updateLinkTag = updateLinkTag;
|
|
@@ -40,8 +40,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
exports.createWebAppServices = void 0;
|
|
43
|
-
var utils_1 = require("
|
|
44
|
-
var utils_2 = require("@sasjs/utils");
|
|
43
|
+
var utils_1 = require("@sasjs/utils");
|
|
45
44
|
var config_1 = require("../../utils/config");
|
|
46
45
|
var path_1 = __importDefault(require("path"));
|
|
47
46
|
var jsdom_1 = __importDefault(require("jsdom"));
|
|
@@ -85,7 +84,7 @@ function createWebAppServices(target) {
|
|
|
85
84
|
})];
|
|
86
85
|
case 5:
|
|
87
86
|
assetPathMap = _c.sent();
|
|
88
|
-
return [4 /*yield*/,
|
|
87
|
+
return [4 /*yield*/, utils_1.readFile(indexHtmlPath).then(function (content) { return new jsdom_1.default.JSDOM(content); })];
|
|
89
88
|
case 6:
|
|
90
89
|
indexHtml = _c.sent();
|
|
91
90
|
return [4 /*yield*/, updateAllTags_1.updateAllTags(indexHtml, {
|
|
@@ -96,7 +95,7 @@ function createWebAppServices(target) {
|
|
|
96
95
|
})];
|
|
97
96
|
case 7:
|
|
98
97
|
_c.sent();
|
|
99
|
-
if (!(target.serverType ===
|
|
98
|
+
if (!(target.serverType === utils_1.ServerType.SasViya)) return [3 /*break*/, 9];
|
|
100
99
|
indexHtml.window.document.body.innerHTML += adjustIframeScript_1.adjustIframeScript;
|
|
101
100
|
return [4 /*yield*/, createClickMeFile(indexHtml.serialize(), streamConfig.streamServiceName)];
|
|
102
101
|
case 8:
|
|
@@ -128,13 +127,13 @@ var validateStreamConfig = function (streamConfig) { return __awaiter(void 0, vo
|
|
|
128
127
|
throw new Error("Invalid stream web folder: Please specify the `streamConfig` in your target in the following format: \n " + JSON.stringify(exampleStreamConfig, null, 2));
|
|
129
128
|
}
|
|
130
129
|
webSourcePathFull = utils_1.getAbsolutePath(streamConfig.webSourcePath, process.projectDir);
|
|
131
|
-
return [4 /*yield*/,
|
|
130
|
+
return [4 /*yield*/, utils_1.folderExists(webSourcePathFull)];
|
|
132
131
|
case 1:
|
|
133
132
|
if (!(_a.sent())) {
|
|
134
133
|
throw new Error("webSourcePath: '" + webSourcePathFull + "' present in 'streamConfig' doesn't exist.");
|
|
135
134
|
}
|
|
136
135
|
indexHtmlPath = path_1.default.join(webSourcePathFull, 'index.html');
|
|
137
|
-
return [4 /*yield*/,
|
|
136
|
+
return [4 /*yield*/, utils_1.fileExists(indexHtmlPath)];
|
|
138
137
|
case 2:
|
|
139
138
|
if (!(_a.sent())) {
|
|
140
139
|
throw new Error("'index.html' doesn't exist at webSourcePath: '" + webSourcePathFull + "' present in 'streamConfig'");
|
|
@@ -150,11 +149,11 @@ function createBuildDestinationFolder() {
|
|
|
150
149
|
switch (_a.label) {
|
|
151
150
|
case 0:
|
|
152
151
|
buildDestinationFolder = process.sasjsConstants.buildDestinationFolder;
|
|
153
|
-
return [4 /*yield*/,
|
|
152
|
+
return [4 /*yield*/, utils_1.fileExists(buildDestinationFolder)];
|
|
154
153
|
case 1:
|
|
155
154
|
pathExists = _a.sent();
|
|
156
155
|
if (!!pathExists) return [3 /*break*/, 3];
|
|
157
|
-
return [4 /*yield*/,
|
|
156
|
+
return [4 /*yield*/, utils_1.createFolder(buildDestinationFolder)];
|
|
158
157
|
case 2:
|
|
159
158
|
_a.sent();
|
|
160
159
|
_a.label = 3;
|
|
@@ -168,15 +167,15 @@ function createTargetDestinationFolder(destinationPath) {
|
|
|
168
167
|
var pathExists;
|
|
169
168
|
return __generator(this, function (_a) {
|
|
170
169
|
switch (_a.label) {
|
|
171
|
-
case 0: return [4 /*yield*/,
|
|
170
|
+
case 0: return [4 /*yield*/, utils_1.fileExists(destinationPath)];
|
|
172
171
|
case 1:
|
|
173
172
|
pathExists = _a.sent();
|
|
174
173
|
if (!pathExists) return [3 /*break*/, 3];
|
|
175
|
-
return [4 /*yield*/,
|
|
174
|
+
return [4 /*yield*/, utils_1.deleteFolder(destinationPath)];
|
|
176
175
|
case 2:
|
|
177
176
|
_a.sent();
|
|
178
177
|
_a.label = 3;
|
|
179
|
-
case 3: return [4 /*yield*/,
|
|
178
|
+
case 3: return [4 /*yield*/, utils_1.createFolder(destinationPath)];
|
|
180
179
|
case 4:
|
|
181
180
|
_a.sent();
|
|
182
181
|
return [2 /*return*/];
|
|
@@ -218,7 +217,7 @@ function createClickMeService(indexHtmlContent, fileName) {
|
|
|
218
217
|
});
|
|
219
218
|
clickMeServiceContent += 'run;\n%sasjsout(HTML)';
|
|
220
219
|
buildDestinationServicesFolder = process.sasjsConstants.buildDestinationServicesFolder;
|
|
221
|
-
return [4 /*yield*/,
|
|
220
|
+
return [4 /*yield*/, utils_1.createFile(path_1.default.join(buildDestinationServicesFolder, fileName + ".sas"), clickMeServiceContent)];
|
|
222
221
|
case 1:
|
|
223
222
|
_a.sent();
|
|
224
223
|
return [2 /*return*/];
|
|
@@ -233,7 +232,7 @@ function createClickMeFile(indexHtmlContent, fileName) {
|
|
|
233
232
|
switch (_a.label) {
|
|
234
233
|
case 0:
|
|
235
234
|
buildDestinationServicesFolder = process.sasjsConstants.buildDestinationServicesFolder;
|
|
236
|
-
return [4 /*yield*/,
|
|
235
|
+
return [4 /*yield*/, utils_1.createFile(path_1.default.join(buildDestinationServicesFolder, fileName + ".html"), indexHtmlContent)];
|
|
237
236
|
case 1:
|
|
238
237
|
_a.sent();
|
|
239
238
|
return [2 /*return*/];
|
package/build/utils/auth.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ServerType, Target } from '@sasjs/utils';
|
|
2
2
|
import SASjs from '@sasjs/adapter/node';
|
|
3
|
-
export declare
|
|
3
|
+
export declare const getAuthUrl: (serverType: ServerType, serverUrl: string, clientId: string) => string;
|
|
4
4
|
export declare function getAuthCode(authUrl: string): Promise<string>;
|
|
5
5
|
/**
|
|
6
6
|
* Checks if the Access Token is expired or is expiring in 1 hour. A default Access Token
|
|
@@ -18,5 +18,11 @@ export declare function isAccessTokenExpiring(token: string): boolean;
|
|
|
18
18
|
* @param {string} token- token string that will be evaluated
|
|
19
19
|
*/
|
|
20
20
|
export declare function isRefreshTokenExpiring(token?: string): boolean;
|
|
21
|
-
export declare function refreshTokens(sasjsInstance: SASjs, clientId: string, clientSecret: string, refreshToken: string): Promise<
|
|
22
|
-
|
|
21
|
+
export declare function refreshTokens(sasjsInstance: SASjs, clientId: string, clientSecret: string, refreshToken: string): Promise<{
|
|
22
|
+
access_token: string;
|
|
23
|
+
refresh_token: string;
|
|
24
|
+
}>;
|
|
25
|
+
export declare function getNewAccessToken(sasjsInstance: SASjs, clientId: string, clientSecret: string, target: Target): Promise<{
|
|
26
|
+
access_token: string;
|
|
27
|
+
refresh_token: string;
|
|
28
|
+
}>;
|
package/build/utils/auth.js
CHANGED
|
@@ -42,9 +42,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
42
42
|
exports.getNewAccessToken = exports.refreshTokens = exports.isRefreshTokenExpiring = exports.isAccessTokenExpiring = exports.getAuthCode = exports.getAuthUrl = void 0;
|
|
43
43
|
var utils_1 = require("@sasjs/utils");
|
|
44
44
|
var jwt_decode_1 = __importDefault(require("jwt-decode"));
|
|
45
|
-
function
|
|
46
|
-
return
|
|
47
|
-
|
|
45
|
+
var getAuthUrl = function (serverType, serverUrl, clientId) {
|
|
46
|
+
return serverType === utils_1.ServerType.Sasjs
|
|
47
|
+
? serverUrl + "/#/SASjsLogon?client_id=" + clientId + "&response_type=code"
|
|
48
|
+
: serverUrl + "/SASLogon/oauth/authorize?client_id=" + clientId + "&response_type=code";
|
|
49
|
+
};
|
|
48
50
|
exports.getAuthUrl = getAuthUrl;
|
|
49
51
|
function getAuthCode(authUrl) {
|
|
50
52
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -100,13 +102,13 @@ function isRefreshTokenExpiring(token) {
|
|
|
100
102
|
exports.isRefreshTokenExpiring = isRefreshTokenExpiring;
|
|
101
103
|
function refreshTokens(sasjsInstance, clientId, clientSecret, refreshToken) {
|
|
102
104
|
return __awaiter(this, void 0, void 0, function () {
|
|
103
|
-
var
|
|
104
|
-
return __generator(this, function (
|
|
105
|
-
switch (
|
|
105
|
+
var _a, access_token, refresh_token;
|
|
106
|
+
return __generator(this, function (_b) {
|
|
107
|
+
switch (_b.label) {
|
|
106
108
|
case 0: return [4 /*yield*/, sasjsInstance.refreshTokens(clientId, clientSecret, refreshToken)];
|
|
107
109
|
case 1:
|
|
108
|
-
|
|
109
|
-
return [2 /*return*/,
|
|
110
|
+
_a = _b.sent(), access_token = _a.access_token, refresh_token = _a.refresh_token;
|
|
111
|
+
return [2 /*return*/, { access_token: access_token, refresh_token: refresh_token }];
|
|
110
112
|
}
|
|
111
113
|
});
|
|
112
114
|
});
|
|
@@ -114,18 +116,18 @@ function refreshTokens(sasjsInstance, clientId, clientSecret, refreshToken) {
|
|
|
114
116
|
exports.refreshTokens = refreshTokens;
|
|
115
117
|
function getNewAccessToken(sasjsInstance, clientId, clientSecret, target) {
|
|
116
118
|
return __awaiter(this, void 0, void 0, function () {
|
|
117
|
-
var authUrl, authCode,
|
|
118
|
-
return __generator(this, function (
|
|
119
|
-
switch (
|
|
119
|
+
var authUrl, authCode, _a, access_token, refresh_token;
|
|
120
|
+
return __generator(this, function (_b) {
|
|
121
|
+
switch (_b.label) {
|
|
120
122
|
case 0:
|
|
121
|
-
authUrl = getAuthUrl(target.serverUrl, clientId);
|
|
123
|
+
authUrl = exports.getAuthUrl(target.serverType, target.serverUrl, clientId);
|
|
122
124
|
return [4 /*yield*/, getAuthCode(authUrl)];
|
|
123
125
|
case 1:
|
|
124
|
-
authCode =
|
|
126
|
+
authCode = _b.sent();
|
|
125
127
|
return [4 /*yield*/, sasjsInstance.getAccessToken(clientId, clientSecret, authCode)];
|
|
126
128
|
case 2:
|
|
127
|
-
|
|
128
|
-
return [2 /*return*/,
|
|
129
|
+
_a = _b.sent(), access_token = _a.access_token, refresh_token = _a.refresh_token;
|
|
130
|
+
return [2 /*return*/, { access_token: access_token, refresh_token: refresh_token }];
|
|
129
131
|
}
|
|
130
132
|
});
|
|
131
133
|
});
|
package/build/utils/config.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Configuration, Target, AuthConfig } from '@sasjs/utils';
|
|
2
|
-
import { StreamConfig } from '@sasjs/utils/types/config';
|
|
1
|
+
import { Configuration, Target, AuthConfig, StreamConfig } from '@sasjs/utils';
|
|
3
2
|
import { TargetScope } from '../types/targetScope';
|
|
4
3
|
/**
|
|
5
4
|
* Returns an object that represents the SASjs CLI configuration in a given file.
|
|
@@ -52,7 +51,7 @@ export declare function getMacroFolders(target?: Target): Promise<string[]>;
|
|
|
52
51
|
* @param {Target} target- the target to check stream configuration for.
|
|
53
52
|
*/
|
|
54
53
|
export declare function getStreamConfig(target?: Target): Promise<StreamConfig>;
|
|
55
|
-
export declare
|
|
54
|
+
export declare const getMacroCorePath: () => string;
|
|
56
55
|
/**
|
|
57
56
|
* Sanitizes app location string.
|
|
58
57
|
* @param {string} appLoc - app location
|
package/build/utils/config.js
CHANGED
|
@@ -633,7 +633,7 @@ function getProgramFolders(target) {
|
|
|
633
633
|
}
|
|
634
634
|
buildSourceFolder = process.sasjsConstants.buildSourceFolder;
|
|
635
635
|
programFolders = programFolders.map(function (programFolder) {
|
|
636
|
-
return
|
|
636
|
+
return utils_1.getAbsolutePath(programFolder, buildSourceFolder);
|
|
637
637
|
});
|
|
638
638
|
return [2 /*return*/, __spreadArray([], __read(new Set(programFolders)))];
|
|
639
639
|
}
|
|
@@ -664,7 +664,7 @@ function getMacroFolders(target) {
|
|
|
664
664
|
}
|
|
665
665
|
buildSourceFolder = process.sasjsConstants.buildSourceFolder;
|
|
666
666
|
macroFolders = macroFolders.map(function (macroFolder) {
|
|
667
|
-
return
|
|
667
|
+
return utils_1.getAbsolutePath(macroFolder, buildSourceFolder);
|
|
668
668
|
});
|
|
669
669
|
return [2 /*return*/, __spreadArray([], __read(new Set(macroFolders)))];
|
|
670
670
|
}
|
|
@@ -691,10 +691,7 @@ function getStreamConfig(target) {
|
|
|
691
691
|
});
|
|
692
692
|
}
|
|
693
693
|
exports.getStreamConfig = getStreamConfig;
|
|
694
|
-
function
|
|
695
|
-
var macroCorePath = process.sasjsConstants.macroCorePath;
|
|
696
|
-
return macroCorePath;
|
|
697
|
-
}
|
|
694
|
+
var getMacroCorePath = function () { return process.sasjsConstants.macroCorePath; };
|
|
698
695
|
exports.getMacroCorePath = getMacroCorePath;
|
|
699
696
|
/**
|
|
700
697
|
* Sanitizes app location string.
|
|
@@ -761,7 +758,7 @@ exports.getProjectRoot = getProjectRoot;
|
|
|
761
758
|
function getAuthConfig(target) {
|
|
762
759
|
var _a, _b, _c, _d;
|
|
763
760
|
return __awaiter(this, void 0, void 0, function () {
|
|
764
|
-
var access_token, refresh_token, client, secret,
|
|
761
|
+
var access_token, refresh_token, client, secret, sasjs, tokens;
|
|
765
762
|
return __generator(this, function (_e) {
|
|
766
763
|
switch (_e.label) {
|
|
767
764
|
case 0:
|
|
@@ -811,18 +808,19 @@ function getAuthConfig(target) {
|
|
|
811
808
|
httpsAgentOptions: target.httpsAgentOptions,
|
|
812
809
|
serverType: target.serverType
|
|
813
810
|
});
|
|
811
|
+
tokens = void 0;
|
|
814
812
|
if (!auth_1.isRefreshTokenExpiring(refresh_token)) return [3 /*break*/, 4];
|
|
815
813
|
return [4 /*yield*/, auth_1.getNewAccessToken(sasjs, client, secret, target)];
|
|
816
814
|
case 3:
|
|
817
|
-
|
|
815
|
+
tokens = _e.sent();
|
|
818
816
|
return [3 /*break*/, 6];
|
|
819
817
|
case 4: return [4 /*yield*/, auth_1.refreshTokens(sasjs, client, secret, refresh_token)];
|
|
820
818
|
case 5:
|
|
821
|
-
|
|
819
|
+
tokens = _e.sent();
|
|
822
820
|
_e.label = 6;
|
|
823
821
|
case 6:
|
|
824
|
-
access_token = (
|
|
825
|
-
refresh_token = (
|
|
822
|
+
access_token = (tokens === null || tokens === void 0 ? void 0 : tokens.access_token) || access_token;
|
|
823
|
+
refresh_token = (tokens === null || tokens === void 0 ? void 0 : tokens.refresh_token) || refresh_token;
|
|
826
824
|
_e.label = 7;
|
|
827
825
|
case 7: return [2 /*return*/, {
|
|
828
826
|
access_token: access_token,
|
|
@@ -852,7 +850,7 @@ exports.getAuthConfig = getAuthConfig;
|
|
|
852
850
|
function getAccessToken(target, checkIfExpiring) {
|
|
853
851
|
if (checkIfExpiring === void 0) { checkIfExpiring = true; }
|
|
854
852
|
return __awaiter(this, void 0, void 0, function () {
|
|
855
|
-
var accessToken, sasjs, client, secret, refreshToken,
|
|
853
|
+
var accessToken, sasjs, client, secret, refreshToken, tokens;
|
|
856
854
|
return __generator(this, function (_a) {
|
|
857
855
|
switch (_a.label) {
|
|
858
856
|
case 0:
|
|
@@ -907,18 +905,18 @@ function getAccessToken(target, checkIfExpiring) {
|
|
|
907
905
|
(refreshToken.trim() === 'null' || refreshToken.trim() === 'undefined')
|
|
908
906
|
? undefined
|
|
909
907
|
: refreshToken;
|
|
910
|
-
|
|
908
|
+
tokens = void 0;
|
|
911
909
|
if (!auth_1.isRefreshTokenExpiring(refreshToken)) return [3 /*break*/, 4];
|
|
912
910
|
return [4 /*yield*/, auth_1.getNewAccessToken(sasjs, client, secret, target)];
|
|
913
911
|
case 3:
|
|
914
|
-
|
|
912
|
+
tokens = _a.sent();
|
|
915
913
|
return [3 /*break*/, 6];
|
|
916
914
|
case 4: return [4 /*yield*/, auth_1.refreshTokens(sasjs, client, secret, refreshToken)];
|
|
917
915
|
case 5:
|
|
918
|
-
|
|
916
|
+
tokens = _a.sent();
|
|
919
917
|
_a.label = 6;
|
|
920
918
|
case 6:
|
|
921
|
-
accessToken =
|
|
919
|
+
accessToken = tokens === null || tokens === void 0 ? void 0 : tokens.access_token;
|
|
922
920
|
_a.label = 7;
|
|
923
921
|
case 7: return [2 /*return*/, accessToken];
|
|
924
922
|
}
|
package/build/utils/file.d.ts
CHANGED
|
@@ -4,12 +4,6 @@ export function isSasFile(filePath: any): boolean;
|
|
|
4
4
|
export function isJsonFile(filePath: any): boolean;
|
|
5
5
|
export function isCsvFile(filePath: any): boolean;
|
|
6
6
|
export function isShellScript(filePath: any): boolean;
|
|
7
|
-
/**
|
|
8
|
-
* Gets a list of @li items from the supplied file content with the specified header.
|
|
9
|
-
* @param {string} listHeader - the header of the section to look for - e.g. <h4> SAS Macros </h4>.
|
|
10
|
-
* @param {string} fileContent - the text content of the file.
|
|
11
|
-
*/
|
|
12
|
-
export function getList(listHeader: string, fileContent: string): any[];
|
|
13
7
|
export function getBrief(fileContent: any): any;
|
|
14
8
|
export function getRelativePath(from: any, to: any): any[];
|
|
15
9
|
export function saveToDefaultLocation(filePath: any, data: any): Promise<{
|