@sasjs/cli 3.15.2 → 3.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/build/commands/add/addCredential.js +25 -18
- package/build/commands/add/addTarget.js +14 -9
- package/build/commands/add/spec/addTarget.spec.js +7 -0
- package/build/commands/build/build.js +4 -4
- package/build/commands/compile/internal/spec/compileTestFile.spec.js +5 -3
- package/build/commands/deploy/spec/cbd.spec.js +38 -17
- package/build/commands/testing/spec/testing.spec.js +5 -0
- package/build/commands/web/internal/createAssetServices.d.ts +11 -2
- package/build/commands/web/internal/createAssetServices.js +83 -92
- package/build/commands/web/internal/getAssetPath.d.ts +2 -0
- package/build/commands/web/internal/getAssetPath.js +17 -0
- package/build/commands/web/internal/modifyLinksInContent.d.ts +2 -0
- package/build/commands/web/internal/modifyLinksInContent.js +11 -0
- package/build/commands/web/internal/sas9/createClickMeService.d.ts +6 -0
- package/build/commands/web/internal/sas9/createClickMeService.js +91 -0
- package/build/commands/web/internal/sas9/generateAssetService.d.ts +7 -0
- package/build/commands/web/internal/sas9/generateAssetService.js +75 -0
- package/build/commands/web/internal/sas9/getWebServiceContent.d.ts +7 -0
- package/build/commands/web/internal/{getWebServiceContent.js → sas9/getWebServiceContent.js} +12 -8
- package/build/commands/web/internal/sas9/index.d.ts +3 -0
- package/build/commands/web/internal/sas9/index.js +15 -0
- package/build/commands/web/internal/sasViya/createClickMeFile.d.ts +6 -0
- package/build/commands/web/internal/sasViya/createClickMeFile.js +63 -0
- package/build/commands/web/internal/sasViya/index.d.ts +1 -0
- package/build/commands/web/internal/sasViya/index.js +13 -0
- package/build/commands/web/internal/sasjsout.d.ts +1 -1
- package/build/commands/web/internal/sasjsout.js +2 -1
- package/build/commands/web/internal/updateAllTags.d.ts +7 -4
- package/build/commands/web/internal/updateAllTags.js +5 -0
- package/build/commands/web/internal/updateLinkTag.d.ts +2 -4
- package/build/commands/web/internal/updateScriptTag.d.ts +2 -4
- package/build/commands/web/internal/updateScriptTag.js +32 -32
- package/build/commands/web/internal/updateStyleTag.d.ts +2 -4
- package/build/commands/web/internal/updateStyleTag.js +32 -32
- package/build/commands/web/web.js +30 -79
- package/build/constants.d.ts +1 -0
- package/build/utils/setConstants.js +4 -2
- package/build/utils/utils.d.ts +1 -0
- package/build/utils/utils.js +22 -1
- package/package.json +1 -1
- package/build/commands/web/internal/getWebServiceContent.d.ts +0 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sasjsout = void 0;
|
|
4
|
-
|
|
4
|
+
var sasjsout = function () { return "\n/* this macro is derived from: https://core.sasjs.io/mp__replace_8sas.html */\noptions mprint;\n%macro mp_replace(infile,\n findvar=,\n replacevar=,\n outfile=0\n)/*/STORE SOURCE*/;\n\n%local inref outref dttm ds1 rc;\n/* create filerefs */\n%let rc=%sysfunc(filename(inref,,temp,lrecl=200));\n%let rc=%sysfunc(filename(outref,,temp,lrecl=200));\n\n%if &outfile=0 %then %let outfile=&infile;\n\n/* uniquely named 32 char datasets */\n%let ds1=all%substr(%sysfunc(compress(%sysfunc(uuidgen()),-)),1,29);\n%let ds2=start%substr(%sysfunc(compress(%sysfunc(uuidgen()),-)),1,27);\n\n/* START */\n%let dttm=%sysfunc(datetime());\n\nfilename &inref &infile lrecl=1 recfm=n;\n\ndata &ds1;\n infile &inref;\n input sourcechar $char1. @@;\n format sourcechar hex2.;\nrun;\n\ndata &ds2;\n /* set find string to length in bytes to cover trailing spaces */\n length string $ %length(%superq(&findvar));\n string =symget(\"&findvar\");\n drop string;\n\n firstchar=char(string,1);\n findlen=lengthm(string); /* <- for trailing bytes */\n\n do _N_=1 to nobs;\n set &ds1 nobs=nobs point=_N_;\n if sourcechar=firstchar then do;\n pos=1;\n s=0;\n do point=_N_ to min(_N_ + findlen -1,nobs);\n set &ds1 point=point;\n if sourcechar=char(string, pos) then s + 1;\n else goto _leave_;\n pos+1;\n end;\n _leave_:\n if s=findlen then do;\n START =_N_;\n _N_ =_N_+ s - 1;\n STOP =_N_;\n output;\n end;\n end;\n end;\n stop;\n keep START STOP;\nrun;\n\ndata &ds1;\n declare hash HS(dataset:\"&ds2(keep=start)\");\n HS.defineKey(\"start\");\n HS.defineDone();\n declare hash HE(dataset:\"&ds2(keep=stop)\");\n HE.defineKey(\"stop\");\n HE.defineDone();\n do until(eof);\n set &ds1 end=eof curobs =n;\n start = ^HS.check(key:n);\n stop = ^HE.check(key:n);\n length strt $ 1;\n strt =put(start,best. -L);\n retain out 1;\n if out then output;\n if start then out=0;\n if stop then out=1;\n end;\n stop;\n keep sourcechar strt;\nrun;\n\nfilename &outref &outfile recfm=n;\n\ndata _null_;\n length replace $ %length(%superq(&replacevar));\n replace=symget(\"&replacevar\");\n file &outref;\n do until(eof);\n set &ds1 end=eof;\n if strt =\"1\" then put replace char.;\n else put sourcechar char1.;\n end;\n stop;\nrun;\n\n/* END */\n%put &sysmacroname took %sysevalf(%sysfunc(datetime())-&dttm) seconds to run;\n\n%mend mp_replace;\n\n%macro sasjsout(type,fref=sasjs);\n%global sysprocessmode SYS_JES_JOB_URI;\n\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=SVG or &type=SVG64 %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,image/svg+xml));\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\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 _sjsout temp;\n data _null_;\n file _sjsout 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 put ' serverType: \"SAS9\" ,';\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 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 static GUID */\n infile=tranwrd(_infile_,'?_PROGRAM=".concat(process.sasjsConstants.sas9GUID, "',cats(expanded_path));\n put infile;\n end;\n end;\n run;\n %let fref=_sjsout;\n%end;\n%else %if &type=JS64 or &type=CSS64 %then %do;\n options nobomfile;\n %let fvar=").concat(process.sasjsConstants.sas9GUID, ";\n %let stgfile=\"%sysfunc(pathname(work))/stgfile.txt\";\n %let newfile=\"%sysfunc(pathname(work))/newfile.txt\";\n\n /* convert from base64 */\n filename _out64 &stgfile encoding='utf-8';\n data _null_;\n length filein 8 fileout 8;\n filein = fopen(\"&fref\",'I',4,'B');\n fileout = fopen(\"_out64\",'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\n /* get appLoc from _program */\n data _null_;\n pgm=\"&_program\";\n appLoc=substr(pgm,1,find(pgm,'/services/')-1);\n call symputx('apploc',cats(appLoc,'/services/'));\n run;\n %put &=fvar;\n %put &=apploc;\n /* replace the GUID with appLoc */\n %mp_replace(&stgfile,\n findvar=fvar,\n replacevar=apploc,\n outfile=&newfile\n )\n filename &fref &newfile encoding='utf-8';\n%end;\n\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=WAV or &type=OGG or &type=WOFF or &type=WOFF2 or &type=TTF or &type=MP4\nor &type=SVG64\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 %put streaming to _webout;\n data _null_;\n infile &fref lrecl=1 recfm=n;\n file _webout mod lrecl=1 recfm=n;\n input sourcechar $char1. @@;\n format sourcechar hex2.;\n put sourcechar char1. @@;\n run;\n%end;\n%mend sasjsout;"); };
|
|
5
|
+
exports.sasjsout = sasjsout;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { JSDOM } from 'jsdom';
|
|
2
2
|
import { ServerType } from '@sasjs/utils';
|
|
3
|
+
import { AssetPathMap } from './createAssetServices';
|
|
3
4
|
interface paramsType {
|
|
4
5
|
webSourcePathFull: string;
|
|
5
6
|
destinationPath: string;
|
|
6
7
|
serverType: ServerType;
|
|
7
|
-
assetPathMap:
|
|
8
|
-
source: string;
|
|
9
|
-
target: string;
|
|
10
|
-
}[];
|
|
8
|
+
assetPathMap: AssetPathMap[];
|
|
11
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Updates HTML Tags with correct link.
|
|
12
|
+
* Also updates contents to update included asset references
|
|
13
|
+
* @param {JSDOM} parsedHtml- DOMWindow for index.html
|
|
14
|
+
*/
|
|
12
15
|
export declare const updateAllTags: (parsedHtml: JSDOM, { webSourcePathFull, destinationPath, serverType, assetPathMap }: paramsType) => Promise<void>;
|
|
13
16
|
export {};
|
|
@@ -67,6 +67,11 @@ var getTags_1 = require("./getTags");
|
|
|
67
67
|
var updateScriptTag_1 = require("./updateScriptTag");
|
|
68
68
|
var updateLinkTag_1 = require("./updateLinkTag");
|
|
69
69
|
var updateStyleTag_1 = require("./updateStyleTag");
|
|
70
|
+
/**
|
|
71
|
+
* Updates HTML Tags with correct link.
|
|
72
|
+
* Also updates contents to update included asset references
|
|
73
|
+
* @param {JSDOM} parsedHtml- DOMWindow for index.html
|
|
74
|
+
*/
|
|
70
75
|
var updateAllTags = function (parsedHtml, _a) {
|
|
71
76
|
var webSourcePathFull = _a.webSourcePathFull, destinationPath = _a.destinationPath, serverType = _a.serverType, assetPathMap = _a.assetPathMap;
|
|
72
77
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
target: string;
|
|
4
|
-
}[], tagType?: 'link' | 'src') => void;
|
|
1
|
+
import { AssetPathMap } from './createAssetServices';
|
|
2
|
+
export declare const updateLinkTag: (linkTag: HTMLLinkElement | HTMLSourceElement | HTMLImageElement, assetPathMap: AssetPathMap[], tagType?: 'link' | 'src') => void;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { ServerType } from '@sasjs/utils';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
target: string;
|
|
5
|
-
}[]) => Promise<void>;
|
|
2
|
+
import { AssetPathMap } from './createAssetServices';
|
|
3
|
+
export declare const updateScriptTag: (tag: HTMLScriptElement, webSourcePathFull: string, destinationPath: string, serverType: ServerType, assetPathMap: AssetPathMap[]) => Promise<void>;
|
|
@@ -43,54 +43,54 @@ exports.updateScriptTag = void 0;
|
|
|
43
43
|
var path_1 = __importDefault(require("path"));
|
|
44
44
|
var utils_1 = require("@sasjs/utils");
|
|
45
45
|
var js_base64_1 = require("js-base64");
|
|
46
|
-
var
|
|
46
|
+
var sas9_1 = require("./sas9");
|
|
47
|
+
var modifyLinksInContent_1 = require("./modifyLinksInContent");
|
|
47
48
|
var updateScriptTag = function (tag, webSourcePathFull, destinationPath, serverType, assetPathMap) { return __awaiter(void 0, void 0, void 0, function () {
|
|
48
|
-
var scriptPath, isUrl, _content, content, serviceContent, _content, content;
|
|
49
|
-
return __generator(this, function (
|
|
50
|
-
switch (
|
|
49
|
+
var scriptPath, isUrl, _content, content, _a, serviceContent, _content, content;
|
|
50
|
+
return __generator(this, function (_b) {
|
|
51
|
+
switch (_b.label) {
|
|
51
52
|
case 0:
|
|
52
53
|
scriptPath = tag.getAttribute('src');
|
|
53
|
-
if (!scriptPath) return [3 /*break*/,
|
|
54
|
+
if (!scriptPath) return [3 /*break*/, 10];
|
|
54
55
|
isUrl = scriptPath.startsWith('http') || scriptPath.startsWith('//');
|
|
55
|
-
if (!!isUrl) return [3 /*break*/,
|
|
56
|
+
if (!!isUrl) return [3 /*break*/, 9];
|
|
56
57
|
return [4 /*yield*/, (0, utils_1.readFile)(path_1.default.join(webSourcePathFull, scriptPath)).catch(function (_) {
|
|
57
58
|
throw new Error("Unable to find file: ".concat(scriptPath));
|
|
58
59
|
})];
|
|
59
60
|
case 1:
|
|
60
|
-
_content =
|
|
61
|
-
content = modifyLinksInContent(_content, assetPathMap);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
case 4
|
|
69
|
-
|
|
70
|
-
|
|
61
|
+
_content = _b.sent();
|
|
62
|
+
content = (0, modifyLinksInContent_1.modifyLinksInContent)(_content, assetPathMap);
|
|
63
|
+
_a = serverType;
|
|
64
|
+
switch (_a) {
|
|
65
|
+
case utils_1.ServerType.SasViya: return [3 /*break*/, 2];
|
|
66
|
+
case utils_1.ServerType.Sas9: return [3 /*break*/, 4];
|
|
67
|
+
}
|
|
68
|
+
return [3 /*break*/, 7];
|
|
69
|
+
case 2: return [4 /*yield*/, (0, utils_1.createFile)(path_1.default.join(destinationPath, scriptPath), content)];
|
|
70
|
+
case 3:
|
|
71
|
+
_b.sent();
|
|
72
|
+
return [3 /*break*/, 8];
|
|
73
|
+
case 4: return [4 /*yield*/, (0, sas9_1.getWebServiceContent)((0, js_base64_1.encode)(content), 'JS')];
|
|
71
74
|
case 5:
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
serviceContent = _b.sent();
|
|
76
|
+
return [4 /*yield*/, (0, utils_1.createFile)(path_1.default.join(destinationPath, "".concat(scriptPath.replace(/\.js$/, '-js'), ".sas")), serviceContent)];
|
|
74
77
|
case 6:
|
|
78
|
+
_b.sent();
|
|
79
|
+
return [3 /*break*/, 8];
|
|
80
|
+
case 7: throw new Error("Server Type: ".concat(serverType, " is not supported for updating script tag."));
|
|
81
|
+
case 8:
|
|
75
82
|
tag.setAttribute('src', assetPathMap.find(function (entry) {
|
|
76
83
|
return entry.source === scriptPath || "./".concat(entry.source) === scriptPath;
|
|
77
84
|
}).target);
|
|
78
|
-
|
|
79
|
-
case
|
|
80
|
-
case
|
|
85
|
+
_b.label = 9;
|
|
86
|
+
case 9: return [3 /*break*/, 11];
|
|
87
|
+
case 10:
|
|
81
88
|
_content = tag.innerHTML;
|
|
82
|
-
content = modifyLinksInContent(_content, assetPathMap);
|
|
89
|
+
content = (0, modifyLinksInContent_1.modifyLinksInContent)(_content, assetPathMap);
|
|
83
90
|
tag.innerHTML = content;
|
|
84
|
-
|
|
85
|
-
case
|
|
91
|
+
_b.label = 11;
|
|
92
|
+
case 11: return [2 /*return*/];
|
|
86
93
|
}
|
|
87
94
|
});
|
|
88
95
|
}); };
|
|
89
96
|
exports.updateScriptTag = updateScriptTag;
|
|
90
|
-
var modifyLinksInContent = function (_content, assetPathMap) {
|
|
91
|
-
var content = _content;
|
|
92
|
-
assetPathMap.forEach(function (pathEntry) {
|
|
93
|
-
content = content.replace(new RegExp(pathEntry.source, 'g'), pathEntry.target);
|
|
94
|
-
});
|
|
95
|
-
return content;
|
|
96
|
-
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { ServerType } from '@sasjs/utils';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
target: string;
|
|
5
|
-
}[]) => Promise<void>;
|
|
2
|
+
import { AssetPathMap } from './createAssetServices';
|
|
3
|
+
export declare const updateStyleTag: (tag: HTMLStyleElement | HTMLLinkElement, webSourcePathFull: string, destinationPath: string, serverType: ServerType, assetPathMap: AssetPathMap[]) => Promise<void>;
|
|
@@ -43,54 +43,54 @@ exports.updateStyleTag = void 0;
|
|
|
43
43
|
var path_1 = __importDefault(require("path"));
|
|
44
44
|
var utils_1 = require("@sasjs/utils");
|
|
45
45
|
var js_base64_1 = require("js-base64");
|
|
46
|
-
var
|
|
46
|
+
var sas9_1 = require("./sas9");
|
|
47
|
+
var modifyLinksInContent_1 = require("./modifyLinksInContent");
|
|
47
48
|
var updateStyleTag = function (tag, webSourcePathFull, destinationPath, serverType, assetPathMap) { return __awaiter(void 0, void 0, void 0, function () {
|
|
48
|
-
var scriptPath, isUrl, _content, content, serviceContent, _content, content;
|
|
49
|
-
return __generator(this, function (
|
|
50
|
-
switch (
|
|
49
|
+
var scriptPath, isUrl, _content, content, _a, serviceContent, _content, content;
|
|
50
|
+
return __generator(this, function (_b) {
|
|
51
|
+
switch (_b.label) {
|
|
51
52
|
case 0:
|
|
52
53
|
scriptPath = tag.getAttribute('href');
|
|
53
|
-
if (!scriptPath) return [3 /*break*/,
|
|
54
|
+
if (!scriptPath) return [3 /*break*/, 10];
|
|
54
55
|
isUrl = scriptPath.startsWith('http') || scriptPath.startsWith('//');
|
|
55
|
-
if (!!isUrl) return [3 /*break*/,
|
|
56
|
+
if (!!isUrl) return [3 /*break*/, 9];
|
|
56
57
|
return [4 /*yield*/, (0, utils_1.readFile)(path_1.default.join(webSourcePathFull, scriptPath)).catch(function (_) {
|
|
57
58
|
throw new Error("Unable to find file: ".concat(scriptPath));
|
|
58
59
|
})];
|
|
59
60
|
case 1:
|
|
60
|
-
_content =
|
|
61
|
-
content = modifyLinksInContent(_content, assetPathMap);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
case 4
|
|
69
|
-
|
|
70
|
-
|
|
61
|
+
_content = _b.sent();
|
|
62
|
+
content = (0, modifyLinksInContent_1.modifyLinksInContent)(_content, assetPathMap);
|
|
63
|
+
_a = serverType;
|
|
64
|
+
switch (_a) {
|
|
65
|
+
case utils_1.ServerType.SasViya: return [3 /*break*/, 2];
|
|
66
|
+
case utils_1.ServerType.Sas9: return [3 /*break*/, 4];
|
|
67
|
+
}
|
|
68
|
+
return [3 /*break*/, 7];
|
|
69
|
+
case 2: return [4 /*yield*/, (0, utils_1.createFile)(path_1.default.join(destinationPath, scriptPath), content)];
|
|
70
|
+
case 3:
|
|
71
|
+
_b.sent();
|
|
72
|
+
return [3 /*break*/, 8];
|
|
73
|
+
case 4: return [4 /*yield*/, (0, sas9_1.getWebServiceContent)((0, js_base64_1.encode)(content), 'CSS')];
|
|
71
74
|
case 5:
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
serviceContent = _b.sent();
|
|
76
|
+
return [4 /*yield*/, (0, utils_1.createFile)(path_1.default.join(destinationPath, "".concat(scriptPath.replace(/\.css$/, '-css'), ".sas")), serviceContent)];
|
|
74
77
|
case 6:
|
|
78
|
+
_b.sent();
|
|
79
|
+
return [3 /*break*/, 8];
|
|
80
|
+
case 7: throw new Error("Server Type: ".concat(serverType, " is not supported for updating style tag."));
|
|
81
|
+
case 8:
|
|
75
82
|
tag.setAttribute('href', assetPathMap.find(function (entry) {
|
|
76
83
|
return entry.source === scriptPath || "./".concat(entry.source) === scriptPath;
|
|
77
84
|
}).target);
|
|
78
|
-
|
|
79
|
-
case
|
|
80
|
-
case
|
|
85
|
+
_b.label = 9;
|
|
86
|
+
case 9: return [3 /*break*/, 11];
|
|
87
|
+
case 10:
|
|
81
88
|
_content = tag.innerHTML;
|
|
82
|
-
content = modifyLinksInContent(_content, assetPathMap);
|
|
89
|
+
content = (0, modifyLinksInContent_1.modifyLinksInContent)(_content, assetPathMap);
|
|
83
90
|
tag.innerHTML = content;
|
|
84
|
-
|
|
85
|
-
case
|
|
91
|
+
_b.label = 11;
|
|
92
|
+
case 11: return [2 /*return*/];
|
|
86
93
|
}
|
|
87
94
|
});
|
|
88
95
|
}); };
|
|
89
96
|
exports.updateStyleTag = updateStyleTag;
|
|
90
|
-
var modifyLinksInContent = function (_content, assetPathMap) {
|
|
91
|
-
var content = _content;
|
|
92
|
-
assetPathMap.forEach(function (pathEntry) {
|
|
93
|
-
content = content.replace(new RegExp(pathEntry.source, 'g'), pathEntry.target);
|
|
94
|
-
});
|
|
95
|
-
return content;
|
|
96
|
-
};
|
|
@@ -44,10 +44,11 @@ var utils_1 = require("@sasjs/utils");
|
|
|
44
44
|
var config_1 = require("../../utils/config");
|
|
45
45
|
var path_1 = __importDefault(require("path"));
|
|
46
46
|
var jsdom_1 = __importDefault(require("jsdom"));
|
|
47
|
-
var sasjsout_1 = require("./internal/sasjsout");
|
|
48
47
|
var adjustIframeScript_1 = require("./internal/adjustIframeScript");
|
|
49
48
|
var createAssetServices_1 = require("./internal/createAssetServices");
|
|
50
49
|
var updateAllTags_1 = require("./internal/updateAllTags");
|
|
50
|
+
var sas9_1 = require("./internal/sas9");
|
|
51
|
+
var sasViya_1 = require("./internal/sasViya");
|
|
51
52
|
var exampleStreamConfig = {
|
|
52
53
|
streamWeb: true,
|
|
53
54
|
streamWebFolder: '/example/folder/path',
|
|
@@ -58,32 +59,32 @@ var exampleStreamConfig = {
|
|
|
58
59
|
function createWebAppServices(target) {
|
|
59
60
|
var _a, _b;
|
|
60
61
|
return __awaiter(this, void 0, void 0, function () {
|
|
61
|
-
var buildDestinationServicesFolder, streamConfig, _c, webSourcePathFull, indexHtmlPath, destinationPath, assetPathMap, indexHtml;
|
|
62
|
-
return __generator(this, function (
|
|
63
|
-
switch (
|
|
62
|
+
var buildDestinationServicesFolder, streamConfig, _c, webSourcePathFull, indexHtmlPath, destinationPath, assetPathMap, indexHtml, _d;
|
|
63
|
+
return __generator(this, function (_e) {
|
|
64
|
+
switch (_e.label) {
|
|
64
65
|
case 0:
|
|
65
66
|
buildDestinationServicesFolder = process.sasjsConstants.buildDestinationServicesFolder;
|
|
66
67
|
return [4 /*yield*/, (0, config_1.getStreamConfig)(target)];
|
|
67
68
|
case 1:
|
|
68
|
-
streamConfig =
|
|
69
|
+
streamConfig = _e.sent();
|
|
69
70
|
return [4 /*yield*/, validateStreamConfig(streamConfig)];
|
|
70
71
|
case 2:
|
|
71
|
-
_c =
|
|
72
|
+
_c = _e.sent(), webSourcePathFull = _c.webSourcePathFull, indexHtmlPath = _c.indexHtmlPath;
|
|
72
73
|
return [4 /*yield*/, createBuildDestinationFolder()];
|
|
73
74
|
case 3:
|
|
74
|
-
|
|
75
|
+
_e.sent();
|
|
75
76
|
destinationPath = path_1.default.join(buildDestinationServicesFolder, streamConfig.streamWebFolder);
|
|
76
77
|
return [4 /*yield*/, createTargetDestinationFolder(destinationPath)
|
|
77
78
|
// For server type SASjs, just need to copy webSourcePath
|
|
78
79
|
// to streamWebFolder, no need to create service files.
|
|
79
80
|
];
|
|
80
81
|
case 4:
|
|
81
|
-
|
|
82
|
+
_e.sent();
|
|
82
83
|
if (!(target.serverType === utils_1.ServerType.Sasjs)) return [3 /*break*/, 6];
|
|
83
84
|
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Copying web app files for target ".concat(target.name, "..."));
|
|
84
85
|
return [4 /*yield*/, (0, utils_1.copy)(webSourcePathFull, destinationPath)];
|
|
85
86
|
case 5:
|
|
86
|
-
|
|
87
|
+
_e.sent();
|
|
87
88
|
return [2 /*return*/];
|
|
88
89
|
case 6:
|
|
89
90
|
(_b = process.logger) === null || _b === void 0 ? void 0 : _b.info("Compiling web app services for target ".concat(target.name, "..."));
|
|
@@ -93,10 +94,10 @@ function createWebAppServices(target) {
|
|
|
93
94
|
return map;
|
|
94
95
|
})];
|
|
95
96
|
case 7:
|
|
96
|
-
assetPathMap =
|
|
97
|
+
assetPathMap = _e.sent();
|
|
97
98
|
return [4 /*yield*/, (0, utils_1.readFile)(indexHtmlPath).then(function (content) { return new jsdom_1.default.JSDOM(content); })];
|
|
98
99
|
case 8:
|
|
99
|
-
indexHtml =
|
|
100
|
+
indexHtml = _e.sent();
|
|
100
101
|
return [4 /*yield*/, (0, updateAllTags_1.updateAllTags)(indexHtml, {
|
|
101
102
|
webSourcePathFull: webSourcePathFull,
|
|
102
103
|
destinationPath: destinationPath,
|
|
@@ -104,18 +105,25 @@ function createWebAppServices(target) {
|
|
|
104
105
|
assetPathMap: assetPathMap
|
|
105
106
|
})];
|
|
106
107
|
case 9:
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
_e.sent();
|
|
109
|
+
_d = target.serverType;
|
|
110
|
+
switch (_d) {
|
|
111
|
+
case utils_1.ServerType.SasViya: return [3 /*break*/, 10];
|
|
112
|
+
case utils_1.ServerType.Sas9: return [3 /*break*/, 12];
|
|
113
|
+
}
|
|
114
|
+
return [3 /*break*/, 14];
|
|
111
115
|
case 10:
|
|
112
|
-
|
|
113
|
-
return [
|
|
114
|
-
case 11:
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
case 13:
|
|
116
|
+
indexHtml.window.document.body.innerHTML += adjustIframeScript_1.adjustIframeScript;
|
|
117
|
+
return [4 /*yield*/, (0, sasViya_1.createClickMeFile)(indexHtml.serialize(), streamConfig.streamServiceName)];
|
|
118
|
+
case 11:
|
|
119
|
+
_e.sent();
|
|
120
|
+
return [3 /*break*/, 15];
|
|
121
|
+
case 12: return [4 /*yield*/, (0, sas9_1.createClickMeService)(indexHtml.serialize(), streamConfig.streamServiceName)];
|
|
122
|
+
case 13:
|
|
123
|
+
_e.sent();
|
|
124
|
+
return [3 /*break*/, 15];
|
|
125
|
+
case 14: throw new Error("Server Type: ".concat(target.serverType, " is not supported for processing streaming index file."));
|
|
126
|
+
case 15: return [2 /*return*/];
|
|
119
127
|
}
|
|
120
128
|
});
|
|
121
129
|
});
|
|
@@ -193,60 +201,3 @@ function createTargetDestinationFolder(destinationPath) {
|
|
|
193
201
|
});
|
|
194
202
|
});
|
|
195
203
|
}
|
|
196
|
-
function createClickMeService(indexHtmlContent, fileName) {
|
|
197
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
198
|
-
var lines, clickMeServiceContent, buildDestinationServicesFolder;
|
|
199
|
-
return __generator(this, function (_a) {
|
|
200
|
-
switch (_a.label) {
|
|
201
|
-
case 0:
|
|
202
|
-
lines = indexHtmlContent.replace(/\r\n/g, '\n').split('\n');
|
|
203
|
-
clickMeServiceContent = "".concat(sasjsout_1.sasjsout, "\nfilename sasjs temp lrecl=99999999;\ndata _null_;\nfile sasjs;\n");
|
|
204
|
-
lines.forEach(function (line) {
|
|
205
|
-
var chunkedLines = (0, utils_1.chunk)(line);
|
|
206
|
-
if (chunkedLines.length === 1) {
|
|
207
|
-
if (chunkedLines[0].length == 0)
|
|
208
|
-
chunkedLines[0] = ' ';
|
|
209
|
-
clickMeServiceContent += "put '".concat(chunkedLines[0]
|
|
210
|
-
.split("'")
|
|
211
|
-
.join("''"), "';\n");
|
|
212
|
-
}
|
|
213
|
-
else {
|
|
214
|
-
var combinedLines_1 = '';
|
|
215
|
-
chunkedLines.forEach(function (chunkedLine, index) {
|
|
216
|
-
var text = "put '".concat(chunkedLine.split("'").join("''"), "'");
|
|
217
|
-
if (index !== chunkedLines.length - 1) {
|
|
218
|
-
text += '@;\n';
|
|
219
|
-
}
|
|
220
|
-
else {
|
|
221
|
-
text += ';\n';
|
|
222
|
-
}
|
|
223
|
-
combinedLines_1 += text;
|
|
224
|
-
});
|
|
225
|
-
clickMeServiceContent += combinedLines_1;
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
clickMeServiceContent += 'run;\n%sasjsout(HTML)';
|
|
229
|
-
buildDestinationServicesFolder = process.sasjsConstants.buildDestinationServicesFolder;
|
|
230
|
-
return [4 /*yield*/, (0, utils_1.createFile)(path_1.default.join(buildDestinationServicesFolder, "".concat(fileName, ".sas")), clickMeServiceContent)];
|
|
231
|
-
case 1:
|
|
232
|
-
_a.sent();
|
|
233
|
-
return [2 /*return*/];
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
function createClickMeFile(indexHtmlContent, fileName) {
|
|
239
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
240
|
-
var buildDestinationServicesFolder;
|
|
241
|
-
return __generator(this, function (_a) {
|
|
242
|
-
switch (_a.label) {
|
|
243
|
-
case 0:
|
|
244
|
-
buildDestinationServicesFolder = process.sasjsConstants.buildDestinationServicesFolder;
|
|
245
|
-
return [4 /*yield*/, (0, utils_1.createFile)(path_1.default.join(buildDestinationServicesFolder, "".concat(fileName, ".html")), indexHtmlContent)];
|
|
246
|
-
case 1:
|
|
247
|
-
_a.sent();
|
|
248
|
-
return [2 /*return*/];
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
});
|
|
252
|
-
}
|
package/build/constants.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ var utils_1 = require("./utils");
|
|
|
46
46
|
var utils_2 = require("@sasjs/utils");
|
|
47
47
|
exports.contextName = 'sasjs cli compute context';
|
|
48
48
|
var setConstants = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
49
|
-
var _a, configuration, isLocal, buildOutputFolder, buildResultsFolder, homeDir, buildSourceFolder, buildSourceDbFolder, buildDestinationFolder, buildDestinationServicesFolder, buildDestinationTestFolder, buildDestinationJobsFolder, buildDestinationDbFolder, buildDestinationDocsFolder, macroCorePath, buildDestinationResultsFolder, buildDestinationResultsLogsFolder, sas9CredentialsError, invalidSasError;
|
|
49
|
+
var _a, configuration, isLocal, buildOutputFolder, buildResultsFolder, homeDir, buildSourceFolder, buildSourceDbFolder, buildDestinationFolder, buildDestinationServicesFolder, buildDestinationTestFolder, buildDestinationJobsFolder, buildDestinationDbFolder, buildDestinationDocsFolder, macroCorePath, buildDestinationResultsFolder, buildDestinationResultsLogsFolder, sas9CredentialsError, invalidSasError, sas9GUID;
|
|
50
50
|
var _b, _c;
|
|
51
51
|
return __generator(this, function (_d) {
|
|
52
52
|
switch (_d.label) {
|
|
@@ -79,6 +79,7 @@ var setConstants = function () { return __awaiter(void 0, void 0, void 0, functi
|
|
|
79
79
|
'\n* SAS_PASSWORD' +
|
|
80
80
|
'\nPlease run "sasjs auth" for your specified target to apply the correct credentials.';
|
|
81
81
|
invalidSasError = 'Url specified does not contain a valid sas program. Please provide valid url.';
|
|
82
|
+
sas9GUID = 'pZKd6F95jECvRQlN0LCfdA==';
|
|
82
83
|
process.sasjsConstants = {
|
|
83
84
|
buildSourceFolder: buildSourceFolder,
|
|
84
85
|
buildSourceDbFolder: buildSourceDbFolder,
|
|
@@ -93,7 +94,8 @@ var setConstants = function () { return __awaiter(void 0, void 0, void 0, functi
|
|
|
93
94
|
macroCorePath: macroCorePath,
|
|
94
95
|
contextName: exports.contextName,
|
|
95
96
|
sas9CredentialsError: sas9CredentialsError,
|
|
96
|
-
invalidSasError: invalidSasError
|
|
97
|
+
invalidSasError: invalidSasError,
|
|
98
|
+
sas9GUID: sas9GUID
|
|
97
99
|
};
|
|
98
100
|
return [2 /*return*/];
|
|
99
101
|
}
|
package/build/utils/utils.d.ts
CHANGED
|
@@ -44,3 +44,4 @@ export declare const terminateProcess: (status: number) => never;
|
|
|
44
44
|
*/
|
|
45
45
|
export declare const isSASjsProject: () => Promise<boolean>;
|
|
46
46
|
export declare const getNodeModulePath: (module: string) => Promise<string>;
|
|
47
|
+
export declare const isSasJsServerInServerMode: (target: Target) => Promise<boolean>;
|
package/build/utils/utils.js
CHANGED
|
@@ -86,10 +86,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
86
86
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
87
87
|
};
|
|
88
88
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
89
|
-
exports.getNodeModulePath = exports.isSASjsProject = exports.terminateProcess = exports.prefixAppLoc = exports.loadEnvVariables = exports.displaySasjsRunnerError = exports.getAdapterInstance = exports.checkNodeVersion = exports.millisecondsToDdHhMmSs = exports.arrToObj = exports.parseLogLines = exports.executeShellScript = exports.getUniqServicesObj = exports.removeComments = exports.setupDoxygen = exports.setupGhooks = exports.setupGitIgnore = exports.setupNpmProject = exports.createTemplateApp = exports.createMinimalApp = exports.createAngularApp = exports.createReactApp = exports.diff = exports.inExistingProject = void 0;
|
|
89
|
+
exports.isSasJsServerInServerMode = exports.getNodeModulePath = exports.isSASjsProject = exports.terminateProcess = exports.prefixAppLoc = exports.loadEnvVariables = exports.displaySasjsRunnerError = exports.getAdapterInstance = exports.checkNodeVersion = exports.millisecondsToDdHhMmSs = exports.arrToObj = exports.parseLogLines = exports.executeShellScript = exports.getUniqServicesObj = exports.removeComments = exports.setupDoxygen = exports.setupGhooks = exports.setupGitIgnore = exports.setupNpmProject = exports.createTemplateApp = exports.createMinimalApp = exports.createAngularApp = exports.createReactApp = exports.diff = exports.inExistingProject = void 0;
|
|
90
90
|
var shelljs_1 = __importDefault(require("shelljs"));
|
|
91
91
|
var path_1 = __importDefault(require("path"));
|
|
92
92
|
var ora_1 = __importDefault(require("ora"));
|
|
93
|
+
var axios_1 = __importDefault(require("axios"));
|
|
93
94
|
var utils_1 = require("@sasjs/utils");
|
|
94
95
|
var node_1 = __importDefault(require("@sasjs/adapter/node"));
|
|
95
96
|
var displayResult_1 = require("./displayResult");
|
|
@@ -638,3 +639,23 @@ var getNodeModulePath = function (module) { return __awaiter(void 0, void 0, voi
|
|
|
638
639
|
});
|
|
639
640
|
}); };
|
|
640
641
|
exports.getNodeModulePath = getNodeModulePath;
|
|
642
|
+
var isSasJsServerInServerMode = function (target) { return __awaiter(void 0, void 0, void 0, function () {
|
|
643
|
+
var res, error_1, message;
|
|
644
|
+
return __generator(this, function (_a) {
|
|
645
|
+
switch (_a.label) {
|
|
646
|
+
case 0:
|
|
647
|
+
_a.trys.push([0, 2, , 3]);
|
|
648
|
+
return [4 /*yield*/, axios_1.default.get("".concat(target.serverUrl, "/SASjsApi/info"))];
|
|
649
|
+
case 1:
|
|
650
|
+
res = _a.sent();
|
|
651
|
+
return [2 /*return*/, res.data.mode === 'server'];
|
|
652
|
+
case 2:
|
|
653
|
+
error_1 = _a.sent();
|
|
654
|
+
message = "An error occurred while fetching server info from ".concat(target.serverUrl, "/SASjsApi/info");
|
|
655
|
+
(0, displayResult_1.displayError)(error_1, message);
|
|
656
|
+
throw new Error(message);
|
|
657
|
+
case 3: return [2 /*return*/];
|
|
658
|
+
}
|
|
659
|
+
});
|
|
660
|
+
}); };
|
|
661
|
+
exports.isSasJsServerInServerMode = isSasJsServerInServerMode;
|
package/package.json
CHANGED