@sasjs/cli 2.38.7 → 3.0.1
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 +2 -2
- package/build/commands/add/addCredential.js +26 -28
- package/build/commands/add/internal/input.js +15 -2
- package/build/commands/build/build.d.ts +1 -1
- package/build/commands/build/build.js +67 -56
- package/build/commands/build/internal/getLaunchPageCode.js +2 -1
- package/build/commands/compile/compile.js +18 -22
- package/build/commands/compile/internal/checkCompileStatus.js +6 -8
- package/build/commands/compile/internal/compileServiceFile.js +18 -16
- package/build/commands/compile/internal/spec/compileTestFile.spec.js +16 -4
- package/build/commands/compile/spec/loadDependencies.spec.js +3 -3
- package/build/commands/context/contextCommand.js +5 -5
- package/build/commands/deploy/deploy.d.ts +2 -1
- package/build/commands/deploy/deploy.js +92 -46
- package/build/commands/deploy/spec/cbd.spec.d.ts +1 -0
- package/build/commands/deploy/spec/cbd.spec.js +141 -0
- package/build/commands/deploy/spec/cbd.spec.server.js +6 -57
- package/build/commands/deploy/spec/utils.d.ts +6 -0
- package/build/commands/deploy/spec/utils.js +242 -0
- package/build/commands/docs/internal/getDocConfig.js +8 -3
- package/build/commands/docs/spec/generateDot.spec.js +0 -1
- package/build/commands/docs/spec/getDocConfig.spec.d.ts +1 -0
- package/build/commands/docs/spec/getDocConfig.spec.js +27 -0
- package/build/commands/flow/flowCommand.js +1 -1
- package/build/commands/flow/spec/flow.spec.server.js +1 -1
- package/build/commands/folder/folderCommand.js +2 -2
- package/build/commands/folder/spec/folder.spec.server.js +1 -1
- package/build/commands/job/internal/execute/index.d.ts +2 -0
- package/build/commands/job/internal/execute/index.js +14 -0
- package/build/commands/job/internal/execute/sasjs.d.ts +8 -0
- package/build/commands/job/internal/execute/sasjs.js +69 -0
- package/build/commands/job/{execute.d.ts → internal/execute/viya.d.ts} +1 -1
- package/build/commands/job/{execute.js → internal/execute/viya.js} +29 -68
- package/build/commands/job/internal/utils.d.ts +1 -0
- package/build/commands/job/internal/utils.js +81 -0
- package/build/commands/job/jobCommand.d.ts +2 -1
- package/build/commands/job/jobCommand.js +65 -23
- package/build/commands/job/spec/execute.spec.js +41 -21
- package/build/commands/job/spec/getContextName.spec.js +1 -1
- package/build/commands/job/spec/job.spec.server.js +4 -4
- package/build/commands/job/spec/jobCommand.spec.js +10 -10
- package/build/commands/request/request.js +1 -1
- package/build/commands/run/run.js +2 -2
- package/build/commands/servicepack/spec/servicepack.spec.server.js +0 -1
- package/build/commands/shared/dependencies.js +6 -9
- package/build/commands/shared/deployToSasViyaWithServicePack.js +1 -1
- package/build/commands/testing/test.js +1 -1
- package/build/commands/web/internal/createAssetServices.d.ts +5 -0
- package/build/commands/web/internal/createAssetServices.js +219 -0
- package/build/commands/web/internal/getTags.d.ts +4 -0
- package/build/commands/web/internal/getTags.js +21 -0
- package/build/commands/web/internal/getWebServiceContent.d.ts +2 -0
- package/build/commands/web/internal/getWebServiceContent.js +84 -0
- package/build/commands/web/{spec → internal/spec}/testFiles/script1.d.ts +0 -0
- package/build/commands/web/{spec → internal/spec}/testFiles/script1.js +0 -0
- package/build/commands/web/{spec → internal/spec}/testFiles/script2.d.ts +0 -0
- package/build/commands/web/{spec → internal/spec}/testFiles/script2.js +0 -0
- package/build/commands/web/{spec/updateTagSource.spec.d.ts → internal/spec/updateScriptTag.spec.d.ts} +0 -0
- package/build/commands/web/{spec/updateTagSource.spec.js → internal/spec/updateScriptTag.spec.js} +7 -7
- package/build/commands/web/internal/updateAllTags.d.ts +13 -0
- package/build/commands/web/internal/updateAllTags.js +94 -0
- package/build/commands/web/internal/updateLinkHref.d.ts +4 -0
- package/build/commands/web/internal/updateLinkHref.js +18 -0
- package/build/commands/web/internal/updateScriptTag.d.ts +5 -0
- package/build/commands/web/internal/updateScriptTag.js +85 -0
- package/build/commands/web/web.d.ts +0 -4
- package/build/commands/web/web.js +64 -378
- package/build/config.json +3 -1
- package/build/utils/config.d.ts +1 -1
- package/build/utils/config.js +106 -71
- package/build/utils/file.d.ts +1 -1
- package/build/utils/file.js +1 -1
- package/build/utils/spec/removeComments.spec.d.ts +1 -1
- package/build/utils/spec/removeComments.spec.js +1 -1
- package/build/utils/test.js +1 -1
- package/build/utils/utils.d.ts +1 -0
- package/build/utils/utils.js +8 -2
- package/package.json +13 -13
|
@@ -35,32 +35,11 @@ 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
|
-
};
|
|
59
38
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
60
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
61
40
|
};
|
|
62
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
63
|
-
exports.
|
|
42
|
+
exports.createWebAppServices = void 0;
|
|
64
43
|
var utils_1 = require("../../utils/utils");
|
|
65
44
|
var utils_2 = require("@sasjs/utils");
|
|
66
45
|
var config_1 = require("../../utils/config");
|
|
@@ -68,12 +47,8 @@ var path_1 = __importDefault(require("path"));
|
|
|
68
47
|
var jsdom_1 = __importDefault(require("jsdom"));
|
|
69
48
|
var sasjsout_1 = require("./internal/sasjsout");
|
|
70
49
|
var adjustIframeScript_1 = require("./internal/adjustIframeScript");
|
|
71
|
-
var
|
|
72
|
-
var
|
|
73
|
-
var permittedServerTypes = {
|
|
74
|
-
SAS9: 'SAS9',
|
|
75
|
-
SASVIYA: 'SASVIYA'
|
|
76
|
-
};
|
|
50
|
+
var createAssetServices_1 = require("./internal/createAssetServices");
|
|
51
|
+
var updateAllTags_1 = require("./internal/updateAllTags");
|
|
77
52
|
var exampleStreamConfig = {
|
|
78
53
|
streamWeb: true,
|
|
79
54
|
streamWebFolder: '/example/folder/path',
|
|
@@ -82,10 +57,9 @@ var exampleStreamConfig = {
|
|
|
82
57
|
streamServiceName: 'clickme'
|
|
83
58
|
};
|
|
84
59
|
function createWebAppServices(target) {
|
|
85
|
-
var _a
|
|
60
|
+
var _a;
|
|
86
61
|
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
-
var buildDestinationServicesFolder, streamConfig,
|
|
88
|
-
var _this = this;
|
|
62
|
+
var buildDestinationServicesFolder, streamConfig, _b, webSourcePathFull, indexHtmlPath, destinationPath, assetPathMap, indexHtml;
|
|
89
63
|
return __generator(this, function (_c) {
|
|
90
64
|
switch (_c.label) {
|
|
91
65
|
case 0:
|
|
@@ -93,328 +67,82 @@ function createWebAppServices(target) {
|
|
|
93
67
|
return [4 /*yield*/, config_1.getStreamConfig(target)];
|
|
94
68
|
case 1:
|
|
95
69
|
streamConfig = _c.sent();
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
webSourcePath = streamConfig.webSourcePath, streamWebFolder = streamConfig.streamWebFolder;
|
|
100
|
-
if (!webSourcePath) {
|
|
101
|
-
throw new Error("Invalid web sourcePath: Please specify the `streamConfig` in your target in the following format: \n " + JSON.stringify(exampleStreamConfig, null, 2));
|
|
102
|
-
}
|
|
103
|
-
if (!streamWebFolder) {
|
|
104
|
-
throw new Error("Invalid stream web folder: Please specify the `streamConfig` in your target in the following format: \n " + JSON.stringify(exampleStreamConfig, null, 2));
|
|
105
|
-
}
|
|
70
|
+
return [4 /*yield*/, validateStreamConfig(streamConfig)];
|
|
71
|
+
case 2:
|
|
72
|
+
_b = _c.sent(), webSourcePathFull = _b.webSourcePathFull, indexHtmlPath = _b.indexHtmlPath;
|
|
106
73
|
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Compiling web app services for target " + target.name + "...");
|
|
107
74
|
return [4 /*yield*/, createBuildDestinationFolder()];
|
|
108
|
-
case 2:
|
|
109
|
-
_c.sent();
|
|
110
|
-
destinationPath = path_1.default.join(buildDestinationServicesFolder, streamWebFolder);
|
|
111
|
-
return [4 /*yield*/, createTargetDestinationFolder(destinationPath)];
|
|
112
75
|
case 3:
|
|
113
76
|
_c.sent();
|
|
114
|
-
|
|
115
|
-
return [4 /*yield*/,
|
|
77
|
+
destinationPath = path_1.default.join(buildDestinationServicesFolder, streamConfig.streamWebFolder);
|
|
78
|
+
return [4 /*yield*/, createTargetDestinationFolder(destinationPath)];
|
|
116
79
|
case 4:
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
80
|
+
_c.sent();
|
|
81
|
+
return [4 /*yield*/, createAssetServices_1.createAssetServices(target, destinationPath, streamConfig).then(function (map) {
|
|
82
|
+
var indexHtmlIndex = map.findIndex(function (assetPath) { return assetPath.source === 'index.html'; });
|
|
83
|
+
map.splice(indexHtmlIndex, 1);
|
|
84
|
+
return map;
|
|
85
|
+
})];
|
|
120
86
|
case 5:
|
|
121
87
|
assetPathMap = _c.sent();
|
|
122
|
-
indexHtmlPath = path_1.default.join(webSourcePathFull, 'index.html');
|
|
123
|
-
return [4 /*yield*/, utils_2.fileExists(indexHtmlPath)];
|
|
124
|
-
case 6:
|
|
125
|
-
if (!_c.sent()) return [3 /*break*/, 14];
|
|
126
|
-
indexHtmlIndex = assetPathMap.findIndex(function (assetPath) { return assetPath.source === 'index.html'; });
|
|
127
|
-
assetPathMap.splice(indexHtmlIndex, 1);
|
|
128
88
|
return [4 /*yield*/, utils_2.readFile(indexHtmlPath).then(function (content) { return new jsdom_1.default.JSDOM(content); })];
|
|
129
|
-
case
|
|
89
|
+
case 6:
|
|
130
90
|
indexHtml = _c.sent();
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
return [2 /*return*/];
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
}); })];
|
|
142
|
-
case 8:
|
|
143
|
-
_c.sent();
|
|
144
|
-
linkTags = getLinkTags(indexHtml);
|
|
145
|
-
return [4 /*yield*/, utils_2.asyncForEach(linkTags, function (linkTag) { return __awaiter(_this, void 0, void 0, function () {
|
|
146
|
-
return __generator(this, function (_a) {
|
|
147
|
-
switch (_a.label) {
|
|
148
|
-
case 0: return [4 /*yield*/, updateLinkHref(linkTag, assetPathMap)];
|
|
149
|
-
case 1:
|
|
150
|
-
_a.sent();
|
|
151
|
-
return [2 /*return*/];
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
}); })];
|
|
155
|
-
case 9:
|
|
156
|
-
_c.sent();
|
|
157
|
-
faviconTags = getFaviconTags(indexHtml);
|
|
158
|
-
return [4 /*yield*/, utils_2.asyncForEach(faviconTags, function (faviconTag) { return __awaiter(_this, void 0, void 0, function () {
|
|
159
|
-
return __generator(this, function (_a) {
|
|
160
|
-
switch (_a.label) {
|
|
161
|
-
case 0: return [4 /*yield*/, updateLinkHref(faviconTag, assetPathMap)];
|
|
162
|
-
case 1:
|
|
163
|
-
_a.sent();
|
|
164
|
-
return [2 /*return*/];
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
}); })];
|
|
168
|
-
case 10:
|
|
91
|
+
return [4 /*yield*/, updateAllTags_1.updateAllTags(indexHtml, {
|
|
92
|
+
webSourcePathFull: webSourcePathFull,
|
|
93
|
+
destinationPath: destinationPath,
|
|
94
|
+
serverType: target.serverType,
|
|
95
|
+
assetPathMap: assetPathMap
|
|
96
|
+
})];
|
|
97
|
+
case 7:
|
|
169
98
|
_c.sent();
|
|
170
|
-
if (!(target.serverType === utils_2.ServerType.SasViya)) return [3 /*break*/,
|
|
99
|
+
if (!(target.serverType === utils_2.ServerType.SasViya)) return [3 /*break*/, 9];
|
|
171
100
|
indexHtml.window.document.body.innerHTML += adjustIframeScript_1.adjustIframeScript;
|
|
172
101
|
return [4 /*yield*/, createClickMeFile(indexHtml.serialize(), streamConfig.streamServiceName)];
|
|
173
|
-
case
|
|
102
|
+
case 8:
|
|
174
103
|
_c.sent();
|
|
175
|
-
return [3 /*break*/,
|
|
176
|
-
case
|
|
177
|
-
case
|
|
104
|
+
return [3 /*break*/, 11];
|
|
105
|
+
case 9: return [4 /*yield*/, createClickMeService(indexHtml.serialize(), streamConfig.streamServiceName)];
|
|
106
|
+
case 10:
|
|
178
107
|
_c.sent();
|
|
179
|
-
_c.label =
|
|
180
|
-
case
|
|
108
|
+
_c.label = 11;
|
|
109
|
+
case 11: return [2 /*return*/];
|
|
181
110
|
}
|
|
182
111
|
});
|
|
183
112
|
});
|
|
184
113
|
}
|
|
185
114
|
exports.createWebAppServices = createWebAppServices;
|
|
186
|
-
function
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
assetPathMapNested = _b.sent();
|
|
216
|
-
assetPathMap.push.apply(assetPathMap, __spreadArray([], __read(assetPathMapNested)));
|
|
217
|
-
return [2 /*return*/];
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
}); })];
|
|
221
|
-
case 1:
|
|
222
|
-
_a.sent();
|
|
223
|
-
return [2 /*return*/, lodash_uniqby_1.default(assetPathMap, 'source')];
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
function createAssetsServicesNested(target, streamWebFolder, fullAssetPath, destinationPath) {
|
|
229
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
230
|
-
var assetPathMap, filePaths, folderNames;
|
|
231
|
-
var _this = this;
|
|
232
|
-
return __generator(this, function (_a) {
|
|
233
|
-
switch (_a.label) {
|
|
234
|
-
case 0:
|
|
235
|
-
assetPathMap = [];
|
|
236
|
-
return [4 /*yield*/, utils_2.listFilesInFolder(fullAssetPath)];
|
|
237
|
-
case 1:
|
|
238
|
-
filePaths = _a.sent();
|
|
239
|
-
return [4 /*yield*/, utils_2.asyncForEach(filePaths, function (filePath) { return __awaiter(_this, void 0, void 0, function () {
|
|
240
|
-
var fullFileName, fileName, fileExtension, sourcePath, assetServiceUrl, fileName_1, assetServiceUrl;
|
|
241
|
-
return __generator(this, function (_a) {
|
|
242
|
-
switch (_a.label) {
|
|
243
|
-
case 0:
|
|
244
|
-
fullFileName = path_1.default.basename(filePath);
|
|
245
|
-
fileName = fullFileName.substring(0, fullFileName.lastIndexOf('.'));
|
|
246
|
-
fileExtension = path_1.default
|
|
247
|
-
.basename(filePath)
|
|
248
|
-
.substring(fullFileName.lastIndexOf('.') + 1, fullFileName.length);
|
|
249
|
-
if (!(fileName && fileExtension)) return [3 /*break*/, 4];
|
|
250
|
-
sourcePath = path_1.default.join(fullAssetPath, filePath);
|
|
251
|
-
if (!(target.serverType === utils_2.ServerType.SasViya)) return [3 /*break*/, 2];
|
|
252
|
-
return [4 /*yield*/, utils_2.copy(sourcePath, path_1.default.join(destinationPath, fullFileName))];
|
|
253
|
-
case 1:
|
|
254
|
-
_a.sent();
|
|
255
|
-
assetServiceUrl = getAssetPath(target.appLoc, target.serverType, streamWebFolder, fullFileName);
|
|
256
|
-
assetPathMap.push({
|
|
257
|
-
source: fullFileName,
|
|
258
|
-
target: assetServiceUrl
|
|
259
|
-
});
|
|
260
|
-
return [3 /*break*/, 4];
|
|
261
|
-
case 2: return [4 /*yield*/, generateAssetService(sourcePath, filePath, destinationPath, target.serverType)];
|
|
262
|
-
case 3:
|
|
263
|
-
fileName_1 = _a.sent();
|
|
264
|
-
assetServiceUrl = getAssetPath(target.appLoc, target.serverType, streamWebFolder, fileName_1.replace('.sas', ''));
|
|
265
|
-
assetPathMap.push({
|
|
266
|
-
source: fullFileName,
|
|
267
|
-
target: assetServiceUrl
|
|
268
|
-
});
|
|
269
|
-
_a.label = 4;
|
|
270
|
-
case 4: return [2 /*return*/];
|
|
271
|
-
}
|
|
272
|
-
});
|
|
273
|
-
}); })];
|
|
274
|
-
case 2:
|
|
275
|
-
_a.sent();
|
|
276
|
-
return [4 /*yield*/, utils_2.listSubFoldersInFolder(fullAssetPath)];
|
|
277
|
-
case 3:
|
|
278
|
-
folderNames = _a.sent();
|
|
279
|
-
return [4 /*yield*/, utils_2.asyncForEach(folderNames, function (folderName) { return __awaiter(_this, void 0, void 0, function () {
|
|
280
|
-
var destinationPathNested, fullAssetPathNested, assetFolderMap;
|
|
281
|
-
return __generator(this, function (_a) {
|
|
282
|
-
switch (_a.label) {
|
|
283
|
-
case 0:
|
|
284
|
-
destinationPathNested = path_1.default.join(destinationPath, folderName);
|
|
285
|
-
fullAssetPathNested = path_1.default.join(fullAssetPath, folderName);
|
|
286
|
-
return [4 /*yield*/, utils_2.createFolder(destinationPathNested)];
|
|
287
|
-
case 1:
|
|
288
|
-
_a.sent();
|
|
289
|
-
return [4 /*yield*/, createAssetsServicesNested(target, streamWebFolder + "/" + folderName, fullAssetPathNested, destinationPathNested)];
|
|
290
|
-
case 2:
|
|
291
|
-
assetFolderMap = _a.sent();
|
|
292
|
-
assetFolderMap.forEach(function (entry) {
|
|
293
|
-
assetPathMap.push({
|
|
294
|
-
source: folderName + "/" + entry.source,
|
|
295
|
-
target: entry.target
|
|
296
|
-
});
|
|
297
|
-
});
|
|
298
|
-
return [2 /*return*/];
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
}); })];
|
|
302
|
-
case 4:
|
|
303
|
-
_a.sent();
|
|
304
|
-
return [2 /*return*/, assetPathMap];
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
function generateAssetService(sourcePath, filePath, destinationPath, serverType) {
|
|
310
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
311
|
-
var fileExtension, fileType, fileName, base64string, serviceContent;
|
|
312
|
-
return __generator(this, function (_a) {
|
|
313
|
-
switch (_a.label) {
|
|
314
|
-
case 0:
|
|
315
|
-
fileExtension = path_1.default.extname(filePath);
|
|
316
|
-
fileType = fileExtension.replace('.', '').toUpperCase();
|
|
317
|
-
fileName = path_1.default
|
|
318
|
-
.basename(filePath)
|
|
319
|
-
.replace(new RegExp(fileExtension + '$'), fileExtension.replace('.', '-'));
|
|
320
|
-
return [4 /*yield*/, utils_2.base64EncodeFile(sourcePath)];
|
|
321
|
-
case 1:
|
|
322
|
-
base64string = _a.sent();
|
|
323
|
-
return [4 /*yield*/, getWebServiceContentSAS9(base64string, fileType, serverType)];
|
|
324
|
-
case 2:
|
|
325
|
-
serviceContent = _a.sent();
|
|
326
|
-
return [4 /*yield*/, utils_2.createFile(path_1.default.join(destinationPath, fileName + ".sas"), serviceContent)];
|
|
327
|
-
case 3:
|
|
328
|
-
_a.sent();
|
|
329
|
-
return [2 /*return*/, fileName + ".sas"];
|
|
330
|
-
}
|
|
331
|
-
});
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
function updateTagSource(tag, webAppSourcePath, destinationPath, target, assetPathMap) {
|
|
335
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
336
|
-
var scriptPath, isUrl, content_1, serviceContent;
|
|
337
|
-
return __generator(this, function (_a) {
|
|
338
|
-
switch (_a.label) {
|
|
339
|
-
case 0:
|
|
340
|
-
scriptPath = tag.getAttribute('src');
|
|
341
|
-
isUrl = scriptPath && (scriptPath.startsWith('http') || scriptPath.startsWith('//'));
|
|
342
|
-
if (!scriptPath) return [3 /*break*/, 7];
|
|
343
|
-
if (!!isUrl) return [3 /*break*/, 7];
|
|
344
|
-
return [4 /*yield*/, utils_2.readFile(path_1.default.join(process.projectDir, webAppSourcePath, scriptPath))];
|
|
345
|
-
case 1:
|
|
346
|
-
content_1 = _a.sent();
|
|
347
|
-
assetPathMap.forEach(function (pathEntry) {
|
|
348
|
-
content_1 = content_1.replace(new RegExp(pathEntry.source, 'g'), pathEntry.target);
|
|
349
|
-
});
|
|
350
|
-
if (!(target.serverType === utils_2.ServerType.SasViya)) return [3 /*break*/, 3];
|
|
351
|
-
return [4 /*yield*/, utils_2.createFile(path_1.default.join(destinationPath, scriptPath), content_1)];
|
|
352
|
-
case 2:
|
|
353
|
-
_a.sent();
|
|
354
|
-
return [3 /*break*/, 6];
|
|
355
|
-
case 3: return [4 /*yield*/, getWebServiceContentSAS9(js_base64_1.encode(content_1), 'JS', target.serverType)];
|
|
356
|
-
case 4:
|
|
357
|
-
serviceContent = _a.sent();
|
|
358
|
-
return [4 /*yield*/, utils_2.createFile(path_1.default.join(destinationPath, scriptPath.replace(/\.js$/, '-js') + ".sas"), serviceContent)];
|
|
359
|
-
case 5:
|
|
360
|
-
_a.sent();
|
|
361
|
-
_a.label = 6;
|
|
362
|
-
case 6:
|
|
363
|
-
tag.setAttribute('src', assetPathMap.find(function (entry) {
|
|
364
|
-
return entry.source === scriptPath || "./" + entry.source === scriptPath;
|
|
365
|
-
}).target);
|
|
366
|
-
_a.label = 7;
|
|
367
|
-
case 7: return [2 /*return*/];
|
|
368
|
-
}
|
|
369
|
-
});
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
exports.updateTagSource = updateTagSource;
|
|
373
|
-
function updateLinkHref(linkTag, assetPathMap) {
|
|
374
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
375
|
-
var linkSourcePath, isUrl;
|
|
376
|
-
return __generator(this, function (_a) {
|
|
377
|
-
linkSourcePath = linkTag.getAttribute('href') || '';
|
|
378
|
-
isUrl = linkSourcePath.startsWith('http') || linkSourcePath.startsWith('//');
|
|
379
|
-
if (!isUrl) {
|
|
380
|
-
linkTag.setAttribute('href', assetPathMap.find(function (entry) {
|
|
381
|
-
return entry.source === linkSourcePath ||
|
|
382
|
-
"./" + entry.source === linkSourcePath;
|
|
383
|
-
}).target);
|
|
384
|
-
}
|
|
385
|
-
return [2 /*return*/];
|
|
386
|
-
});
|
|
387
|
-
});
|
|
388
|
-
}
|
|
389
|
-
function getAssetPath(appLoc, serverType, streamWebFolder, fileName) {
|
|
390
|
-
if (!permittedServerTypes.hasOwnProperty(serverType.toUpperCase())) {
|
|
391
|
-
throw new Error('Unsupported server type. Supported types are SAS9 and SASVIYA');
|
|
392
|
-
}
|
|
393
|
-
var storedProcessPath =
|
|
394
|
-
// the appLoc is inserted dynamically by SAS
|
|
395
|
-
// using three forward slashes as a marker
|
|
396
|
-
// for SAS 9 fileName is a program, with replacement in sasjsout.ts
|
|
397
|
-
// for Viya, fileName is a FILE, with replacement in build.sas only
|
|
398
|
-
serverType === utils_2.ServerType.SasViya
|
|
399
|
-
? "/SASJobExecution?_FILE=" + appLoc + "/services/" + streamWebFolder
|
|
400
|
-
: "/SASStoredProcess/?_PROGRAM=///" + streamWebFolder;
|
|
401
|
-
return storedProcessPath + "/" + fileName;
|
|
402
|
-
}
|
|
403
|
-
function getScriptTags(parsedHtml) {
|
|
404
|
-
return Array.from(parsedHtml.window.document.querySelectorAll('script'));
|
|
405
|
-
}
|
|
406
|
-
function getLinkTags(parsedHtml) {
|
|
407
|
-
var linkTags = Array.from(parsedHtml.window.document.querySelectorAll('link')).filter(function (s) { return s.getAttribute('rel') === 'stylesheet'; });
|
|
408
|
-
return linkTags;
|
|
409
|
-
}
|
|
410
|
-
function getFaviconTags(parsedHtml) {
|
|
411
|
-
var linkTags = Array.from(parsedHtml.window.document.querySelectorAll('link')).filter(function (s) {
|
|
412
|
-
return s.getAttribute('rel') &&
|
|
413
|
-
s.getAttribute('rel') &&
|
|
414
|
-
s.getAttribute('rel').includes('icon');
|
|
115
|
+
var validateStreamConfig = function (streamConfig) { return __awaiter(void 0, void 0, void 0, function () {
|
|
116
|
+
var webSourcePath, streamWebFolder, webSourcePathFull, indexHtmlPath;
|
|
117
|
+
return __generator(this, function (_a) {
|
|
118
|
+
switch (_a.label) {
|
|
119
|
+
case 0:
|
|
120
|
+
if (!streamConfig) {
|
|
121
|
+
throw new Error("Invalid stream config: Please specify the `streamConfig` in your target in the following format: \n " + JSON.stringify(exampleStreamConfig, null, 2));
|
|
122
|
+
}
|
|
123
|
+
webSourcePath = streamConfig.webSourcePath, streamWebFolder = streamConfig.streamWebFolder;
|
|
124
|
+
if (!webSourcePath) {
|
|
125
|
+
throw new Error("Invalid web sourcePath: Please specify the `streamConfig` in your target in the following format: \n " + JSON.stringify(exampleStreamConfig, null, 2));
|
|
126
|
+
}
|
|
127
|
+
if (!streamWebFolder) {
|
|
128
|
+
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
|
+
}
|
|
130
|
+
webSourcePathFull = utils_1.getAbsolutePath(streamConfig.webSourcePath, process.projectDir);
|
|
131
|
+
return [4 /*yield*/, utils_2.folderExists(webSourcePathFull)];
|
|
132
|
+
case 1:
|
|
133
|
+
if (!(_a.sent())) {
|
|
134
|
+
throw new Error("webSourcePath: '" + webSourcePathFull + "' present in 'streamConfig' doesn't exist.");
|
|
135
|
+
}
|
|
136
|
+
indexHtmlPath = path_1.default.join(webSourcePathFull, 'index.html');
|
|
137
|
+
return [4 /*yield*/, utils_2.fileExists(indexHtmlPath)];
|
|
138
|
+
case 2:
|
|
139
|
+
if (!(_a.sent())) {
|
|
140
|
+
throw new Error("'index.html' doesn't exist at webSourcePath: '" + webSourcePathFull + "' present in 'streamConfig'");
|
|
141
|
+
}
|
|
142
|
+
return [2 /*return*/, { webSourcePathFull: webSourcePathFull, indexHtmlPath: indexHtmlPath }];
|
|
143
|
+
}
|
|
415
144
|
});
|
|
416
|
-
|
|
417
|
-
}
|
|
145
|
+
}); };
|
|
418
146
|
function createBuildDestinationFolder() {
|
|
419
147
|
return __awaiter(this, void 0, void 0, function () {
|
|
420
148
|
var buildDestinationFolder, pathExists;
|
|
@@ -456,48 +184,6 @@ function createTargetDestinationFolder(destinationPath) {
|
|
|
456
184
|
});
|
|
457
185
|
});
|
|
458
186
|
}
|
|
459
|
-
function getWebServiceContentSAS9(contentBase64, type, serverType) {
|
|
460
|
-
if (type === void 0) { type = 'JS'; }
|
|
461
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
462
|
-
var lines, typesToEncode, serviceContent;
|
|
463
|
-
return __generator(this, function (_a) {
|
|
464
|
-
lines = [contentBase64];
|
|
465
|
-
typesToEncode = {
|
|
466
|
-
JS: 'JS64',
|
|
467
|
-
CSS: 'CSS64'
|
|
468
|
-
};
|
|
469
|
-
serviceContent = sasjsout_1.sasjsout + "\nfilename sasjs temp lrecl=99999999;\ndata _null_;\nfile sasjs;\n";
|
|
470
|
-
lines.forEach(function (line) {
|
|
471
|
-
var chunkedLines = utils_1.chunk(line);
|
|
472
|
-
if (chunkedLines.length === 1) {
|
|
473
|
-
serviceContent += "put '" + chunkedLines[0].split("'").join("''") + "';\n";
|
|
474
|
-
}
|
|
475
|
-
else {
|
|
476
|
-
var combinedLines_1 = '';
|
|
477
|
-
chunkedLines.forEach(function (chunkedLine, index) {
|
|
478
|
-
var text = "put '" + chunkedLine.split("'").join("''") + "'";
|
|
479
|
-
if (index !== chunkedLines.length - 1) {
|
|
480
|
-
text += '@;\n';
|
|
481
|
-
}
|
|
482
|
-
else {
|
|
483
|
-
text += ';\n';
|
|
484
|
-
}
|
|
485
|
-
combinedLines_1 += text;
|
|
486
|
-
});
|
|
487
|
-
serviceContent += combinedLines_1;
|
|
488
|
-
}
|
|
489
|
-
});
|
|
490
|
-
if (serverType === permittedServerTypes.SAS9 &&
|
|
491
|
-
typesToEncode.hasOwnProperty(type)) {
|
|
492
|
-
serviceContent += "\nrun;\n%sasjsout(" + typesToEncode[type] + ")";
|
|
493
|
-
}
|
|
494
|
-
else {
|
|
495
|
-
serviceContent += "\nrun;\n%sasjsout(" + type + ")";
|
|
496
|
-
}
|
|
497
|
-
return [2 /*return*/, serviceContent];
|
|
498
|
-
});
|
|
499
|
-
});
|
|
500
|
-
}
|
|
501
187
|
function createClickMeService(indexHtmlContent, fileName) {
|
|
502
188
|
return __awaiter(this, void 0, void 0, function () {
|
|
503
189
|
var lines, clickMeServiceContent, buildDestinationServicesFolder;
|
|
@@ -516,7 +202,7 @@ function createClickMeService(indexHtmlContent, fileName) {
|
|
|
516
202
|
.join("''") + "';\n";
|
|
517
203
|
}
|
|
518
204
|
else {
|
|
519
|
-
var
|
|
205
|
+
var combinedLines_1 = '';
|
|
520
206
|
chunkedLines.forEach(function (chunkedLine, index) {
|
|
521
207
|
var text = "put '" + chunkedLine.split("'").join("''") + "'";
|
|
522
208
|
if (index !== chunkedLines.length - 1) {
|
|
@@ -525,9 +211,9 @@ function createClickMeService(indexHtmlContent, fileName) {
|
|
|
525
211
|
else {
|
|
526
212
|
text += ';\n';
|
|
527
213
|
}
|
|
528
|
-
|
|
214
|
+
combinedLines_1 += text;
|
|
529
215
|
});
|
|
530
|
-
clickMeServiceContent +=
|
|
216
|
+
clickMeServiceContent += combinedLines_1;
|
|
531
217
|
}
|
|
532
218
|
});
|
|
533
219
|
clickMeServiceContent += 'run;\n%sasjsout(HTML)';
|
package/build/config.json
CHANGED
|
@@ -241,7 +241,9 @@
|
|
|
241
241
|
"name": "viya",
|
|
242
242
|
"serverType": "SASVIYA",
|
|
243
243
|
"serverUrl": "https://sas.analytium.co.uk",
|
|
244
|
-
"
|
|
244
|
+
"httpsAgentOptions": {
|
|
245
|
+
"allowInsecureRequests": false
|
|
246
|
+
},
|
|
245
247
|
"appLoc": "/Public/app",
|
|
246
248
|
"contextName": "SAS Job Execution compute context",
|
|
247
249
|
"buildConfig": {
|
package/build/utils/config.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ export declare function getMacroFolders(target?: Target): Promise<string[]>;
|
|
|
52
52
|
* @param {Target} target- the target to check stream configuration for.
|
|
53
53
|
*/
|
|
54
54
|
export declare function getStreamConfig(target?: Target): Promise<StreamConfig>;
|
|
55
|
-
export declare function getMacroCorePath():
|
|
55
|
+
export declare function getMacroCorePath(): string;
|
|
56
56
|
/**
|
|
57
57
|
* Sanitizes app location string.
|
|
58
58
|
* @param {string} appLoc - app location
|