@sasjs/cli 3.6.4 → 3.7.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/deploy/deploy.d.ts +7 -0
- package/build/commands/deploy/deploy.js +105 -44
- package/build/commands/deploy/spec/cbd.spec.js +1 -1
- package/build/commands/help/help.js +4 -2
- package/build/commands/job/internal/execute/sasjs.d.ts +1 -0
- package/build/commands/testing/spec/testing.spec.server.js +545 -308
- package/build/commands/testing/test.d.ts +3 -1
- package/build/commands/testing/test.js +166 -113
- package/build/commands/web/internal/getTags.d.ts +2 -0
- package/build/commands/web/internal/getTags.js +9 -1
- package/build/commands/web/internal/spec/testFiles/script3.d.ts +23 -0
- package/build/commands/web/internal/spec/testFiles/script3.js +218 -0
- package/build/commands/web/internal/spec/updateLinkTag.spec.js +1 -1
- package/build/commands/web/internal/spec/updateScriptTag.spec.js +146 -1
- package/build/commands/web/internal/spec/updateStyleTag.spec.d.ts +4 -0
- package/build/commands/web/internal/spec/updateStyleTag.spec.js +131 -0
- package/build/commands/web/internal/updateAllTags.js +22 -8
- package/build/commands/web/internal/updateLinkTag.d.ts +2 -2
- package/build/commands/web/internal/updateScriptTag.d.ts +1 -1
- package/build/commands/web/internal/updateScriptTag.js +21 -10
- package/build/commands/web/internal/updateStyleTag.d.ts +5 -0
- package/build/commands/web/internal/updateStyleTag.js +96 -0
- package/build/utils/config.js +4 -1
- package/package.json +2 -2
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import SASjs from '@sasjs/adapter/node';
|
|
2
2
|
import { Target } from '@sasjs/utils';
|
|
3
|
+
/**
|
|
4
|
+
* Deploys app to serverUrl/appLoc mentioned in specified target.
|
|
5
|
+
* @param {Target} target- the target having deploy configuration.
|
|
6
|
+
* @param {boolean} isLocal- flag indicating if specified target is
|
|
7
|
+
* from local sasjsconfig or global sasjsconfig file.
|
|
8
|
+
* @param {object} sasjs - optional configuration object of SAS adapter.
|
|
9
|
+
*/
|
|
3
10
|
export declare function deploy(target: Target, isLocal: boolean, sasjs?: SASjs): Promise<void>;
|
|
@@ -49,6 +49,13 @@ var utils_2 = require("@sasjs/utils");
|
|
|
49
49
|
var file_1 = require("../../utils/file");
|
|
50
50
|
var getDeployScripts_1 = require("./internal/getDeployScripts");
|
|
51
51
|
var deployToSasViyaWithServicePack_1 = require("../shared/deployToSasViyaWithServicePack");
|
|
52
|
+
/**
|
|
53
|
+
* Deploys app to serverUrl/appLoc mentioned in specified target.
|
|
54
|
+
* @param {Target} target- the target having deploy configuration.
|
|
55
|
+
* @param {boolean} isLocal- flag indicating if specified target is
|
|
56
|
+
* from local sasjsconfig or global sasjsconfig file.
|
|
57
|
+
* @param {object} sasjs - optional configuration object of SAS adapter.
|
|
58
|
+
*/
|
|
52
59
|
function deploy(target, isLocal, sasjs) {
|
|
53
60
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
54
61
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -83,12 +90,12 @@ function deploy(target, isLocal, sasjs) {
|
|
|
83
90
|
buildDestinationFolder = process.sasjsConstants.buildDestinationFolder;
|
|
84
91
|
logFilePath = buildDestinationFolder;
|
|
85
92
|
if (!(target.serverType === utils_2.ServerType.Sasjs)) return [3 /*break*/, 5];
|
|
86
|
-
return [4 /*yield*/, deployToSasjs(target, sasjs)];
|
|
93
|
+
return [4 /*yield*/, deployToSasjs(target, isLocal, sasjs)];
|
|
87
94
|
case 4:
|
|
88
95
|
_k.sent();
|
|
89
96
|
return [3 /*break*/, 7];
|
|
90
97
|
case 5: return [4 /*yield*/, (0, utils_2.asyncForEach)(deployScripts, function (deployScript) { return __awaiter(_this, void 0, void 0, function () {
|
|
91
|
-
var deployScriptPath,
|
|
98
|
+
var deployScriptPath, deployScriptContent, linesToExecute, streamConfig, deployScriptName, logPath;
|
|
92
99
|
var _a, _b, _c;
|
|
93
100
|
return __generator(this, function (_d) {
|
|
94
101
|
switch (_d.label) {
|
|
@@ -100,19 +107,20 @@ function deploy(target, isLocal, sasjs) {
|
|
|
100
107
|
// split into lines
|
|
101
108
|
];
|
|
102
109
|
case 1:
|
|
103
|
-
|
|
104
|
-
linesToExecute =
|
|
110
|
+
deployScriptContent = _d.sent();
|
|
111
|
+
linesToExecute = deployScriptContent
|
|
105
112
|
.replace(/\r\n/g, '\n')
|
|
106
113
|
.split('\n');
|
|
107
114
|
return [4 /*yield*/, (0, config_1.getStreamConfig)(target)];
|
|
108
115
|
case 2:
|
|
109
116
|
streamConfig = _d.sent();
|
|
117
|
+
deployScriptName = path_1.default.basename(deployScript);
|
|
110
118
|
if (!(target.serverType === utils_2.ServerType.SasViya)) return [3 /*break*/, 4];
|
|
111
|
-
return [4 /*yield*/, deployToSasViya(
|
|
119
|
+
return [4 /*yield*/, deployToSasViya(deployScriptName, target, isLocal, linesToExecute, logFilePath, streamConfig)];
|
|
112
120
|
case 3:
|
|
113
121
|
_d.sent();
|
|
114
122
|
return [3 /*break*/, 6];
|
|
115
|
-
case 4: return [4 /*yield*/, deployToSas9(
|
|
123
|
+
case 4: return [4 /*yield*/, deployToSas9(deployScriptName, target, linesToExecute, logFilePath, streamConfig)];
|
|
116
124
|
case 5:
|
|
117
125
|
_d.sent();
|
|
118
126
|
_d.label = 6;
|
|
@@ -139,6 +147,14 @@ function deploy(target, isLocal, sasjs) {
|
|
|
139
147
|
});
|
|
140
148
|
}
|
|
141
149
|
exports.deploy = deploy;
|
|
150
|
+
/**
|
|
151
|
+
* Returns configuration object of SAS Adapter and authentication configuration
|
|
152
|
+
* @param {Target} target- the target to get auth configuration from.
|
|
153
|
+
* @param {boolean} isLocal- flag indicating if specified target is
|
|
154
|
+
* from local sasjsconfig or global sasjsconfig file.
|
|
155
|
+
* @returns an object containing a SAS Adapter configuration object `sasjs`
|
|
156
|
+
* and auth configuration `authConfig`.
|
|
157
|
+
*/
|
|
142
158
|
function getSASjsAndAuthConfig(target, isLocal) {
|
|
143
159
|
return __awaiter(this, void 0, void 0, function () {
|
|
144
160
|
var sasjs, authConfig, e_1;
|
|
@@ -171,14 +187,26 @@ function getSASjsAndAuthConfig(target, isLocal) {
|
|
|
171
187
|
});
|
|
172
188
|
});
|
|
173
189
|
}
|
|
174
|
-
|
|
190
|
+
/**
|
|
191
|
+
* Deploys app to `SASVIYA` server through deployScript.
|
|
192
|
+
* @param {string} deployScriptName- name of deploy script.
|
|
193
|
+
* @param {Target} target- the target having deploy configuration.
|
|
194
|
+
* @param {boolean} isLocal- flag indicating if specified target is
|
|
195
|
+
* from local sasjsconfig or global sasjsconfig file.
|
|
196
|
+
* @param {string[]} linesToExecute - array of SAS code lines of deploy script to execute.
|
|
197
|
+
* @param {string} logFolder - optional path to log folder,
|
|
198
|
+
* log file name will be <deploy-script-name>.log
|
|
199
|
+
* @param {object} streamConfig - optional configuration object of StreamConfig
|
|
200
|
+
* for printing web app url on console.
|
|
201
|
+
*/
|
|
202
|
+
function deployToSasViya(deployScriptName, target, isLocal, linesToExecute, logFolder, streamConfig) {
|
|
175
203
|
var _a, _b, _c, _d, _e;
|
|
176
204
|
return __awaiter(this, void 0, void 0, function () {
|
|
177
205
|
var contextName, _f, sasjs, authConfig, executionResult, log, appLoc, webAppStreamUrl;
|
|
178
206
|
return __generator(this, function (_g) {
|
|
179
207
|
switch (_g.label) {
|
|
180
208
|
case 0:
|
|
181
|
-
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Sending ".concat(
|
|
209
|
+
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Sending ".concat(deployScriptName, " to SAS server for execution."));
|
|
182
210
|
contextName = target.contextName;
|
|
183
211
|
if (!contextName) {
|
|
184
212
|
throw new Error('Compute Context Name is required for SAS Viya deployments.\n Please ensure that `contextName` is present in your build target configuration or in your .env file, and try again.\n');
|
|
@@ -186,7 +214,7 @@ function deployToSasViya(deployScript, target, isLocal, linesToExecute, logFileP
|
|
|
186
214
|
return [4 /*yield*/, getSASjsAndAuthConfig(target, isLocal)];
|
|
187
215
|
case 1:
|
|
188
216
|
_f = _g.sent(), sasjs = _f.sasjs, authConfig = _f.authConfig;
|
|
189
|
-
return [4 /*yield*/, sasjs.executeScriptSASViya(
|
|
217
|
+
return [4 /*yield*/, sasjs.executeScriptSASViya(deployScriptName, linesToExecute, contextName, authConfig)];
|
|
190
218
|
case 2:
|
|
191
219
|
executionResult = _g.sent();
|
|
192
220
|
try {
|
|
@@ -200,26 +228,37 @@ function deployToSasViya(deployScript, target, isLocal, linesToExecute, logFileP
|
|
|
200
228
|
(_b = process.logger) === null || _b === void 0 ? void 0 : _b.error("An error occurred when parsing the execution response: ".concat(e.message));
|
|
201
229
|
log = executionResult;
|
|
202
230
|
}
|
|
203
|
-
if (!
|
|
204
|
-
return [4 /*yield*/, (0, utils_2.createFile)(path_1.default.join(
|
|
231
|
+
if (!logFolder) return [3 /*break*/, 4];
|
|
232
|
+
return [4 /*yield*/, (0, utils_2.createFile)(path_1.default.join(logFolder, "".concat(deployScriptName.replace('.sas', ''), ".log")), log)];
|
|
205
233
|
case 3:
|
|
206
234
|
_g.sent();
|
|
207
|
-
(_c = process.logger) === null || _c === void 0 ? void 0 : _c.success("Deployment completed! Log is available at ".concat(path_1.default.join(
|
|
235
|
+
(_c = process.logger) === null || _c === void 0 ? void 0 : _c.success("Deployment completed! Log is available at ".concat(path_1.default.join(logFolder, "".concat(deployScriptName.replace('.sas', ''), ".log"))));
|
|
236
|
+
return [3 /*break*/, 5];
|
|
237
|
+
case 4:
|
|
238
|
+
(_d = process.logger) === null || _d === void 0 ? void 0 : _d.error('Unable to create log file.');
|
|
239
|
+
_g.label = 5;
|
|
240
|
+
case 5:
|
|
208
241
|
if (streamConfig === null || streamConfig === void 0 ? void 0 : streamConfig.streamWeb) {
|
|
209
242
|
appLoc = target.appLoc.replace(/\ /g, '%20');
|
|
210
243
|
webAppStreamUrl = "".concat(target.serverUrl, "/SASJobExecution?_FILE=").concat(appLoc, "/services/").concat(streamConfig.streamServiceName, ".html&_debug=2");
|
|
211
|
-
(
|
|
244
|
+
(_e = process.logger) === null || _e === void 0 ? void 0 : _e.info("Web app is available at ".concat(webAppStreamUrl));
|
|
212
245
|
}
|
|
213
|
-
return [
|
|
214
|
-
case 4:
|
|
215
|
-
(_e = process.logger) === null || _e === void 0 ? void 0 : _e.error('Unable to create log file.');
|
|
216
|
-
_g.label = 5;
|
|
217
|
-
case 5: return [2 /*return*/];
|
|
246
|
+
return [2 /*return*/];
|
|
218
247
|
}
|
|
219
248
|
});
|
|
220
249
|
});
|
|
221
250
|
}
|
|
222
|
-
|
|
251
|
+
/**
|
|
252
|
+
* Deploys app to `SAS9` server through deployScript.
|
|
253
|
+
* @param {string} deployScriptName- name of deploy script.
|
|
254
|
+
* @param {Target} target- the target having deploy configuration.
|
|
255
|
+
* @param {string[]} linesToExecute - array of SAS code lines of deploy script to execute.
|
|
256
|
+
* @param {string} logFolder - optional path to log folder,
|
|
257
|
+
* log file name will be <deploy-script-name>.log
|
|
258
|
+
* @param {object} streamConfig - optional configuration object of StreamConfig
|
|
259
|
+
* for printing web app url on console.
|
|
260
|
+
*/
|
|
261
|
+
function deployToSas9(deployScriptName, target, linesToExecute, logFolder, streamConfig) {
|
|
223
262
|
var _a, _b, _c, _d;
|
|
224
263
|
return __awaiter(this, void 0, void 0, function () {
|
|
225
264
|
var username, password, sas9CredentialsError, sasjs, executionResult, appLoc, webAppStreamUrl;
|
|
@@ -256,33 +295,42 @@ function deployToSas9(deployScript, target, linesToExecute, logFilePath, streamC
|
|
|
256
295
|
})];
|
|
257
296
|
case 1:
|
|
258
297
|
executionResult = _e.sent();
|
|
259
|
-
if (
|
|
260
|
-
(
|
|
261
|
-
return [
|
|
298
|
+
if (!executionResult) return [3 /*break*/, 5];
|
|
299
|
+
if (!logFolder) return [3 /*break*/, 3];
|
|
300
|
+
return [4 /*yield*/, (0, utils_2.createFile)(path_1.default.join(logFolder, "".concat(deployScriptName.replace('.sas', ''), ".log")), executionResult !== null && executionResult !== void 0 ? executionResult : '')];
|
|
262
301
|
case 2:
|
|
263
|
-
if (!logFilePath) return [3 /*break*/, 4];
|
|
264
|
-
return [4 /*yield*/, (0, utils_2.createFile)(path_1.default.join(logFilePath, "".concat(path_1.default.basename(deployScript).replace('.sas', ''), ".log")), executionResult !== null && executionResult !== void 0 ? executionResult : '')];
|
|
265
|
-
case 3:
|
|
266
302
|
_e.sent();
|
|
267
|
-
(
|
|
303
|
+
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.success("Deployment completed! Log is available at ".concat(path_1.default.join(logFolder, "".concat(deployScriptName.replace('.sas', ''), ".log"))));
|
|
304
|
+
return [3 /*break*/, 4];
|
|
305
|
+
case 3:
|
|
306
|
+
(_b = process.logger) === null || _b === void 0 ? void 0 : _b.error('Unable to create log file.');
|
|
307
|
+
_e.label = 4;
|
|
308
|
+
case 4:
|
|
268
309
|
if (streamConfig === null || streamConfig === void 0 ? void 0 : streamConfig.streamWeb) {
|
|
269
310
|
appLoc = target.appLoc.replace(/\ /g, '%20');
|
|
270
311
|
webAppStreamUrl = "".concat(target.serverUrl, "/SASStoredProcess/?_PROGRAM=").concat(appLoc, "/services/").concat(streamConfig.streamServiceName);
|
|
271
312
|
(_c = process.logger) === null || _c === void 0 ? void 0 : _c.info("Web app is available at ".concat(webAppStreamUrl));
|
|
272
313
|
}
|
|
273
|
-
return [3 /*break*/,
|
|
274
|
-
case
|
|
275
|
-
(_d = process.logger) === null || _d === void 0 ? void 0 : _d.error('
|
|
276
|
-
_e.label =
|
|
277
|
-
case
|
|
314
|
+
return [3 /*break*/, 6];
|
|
315
|
+
case 5:
|
|
316
|
+
(_d = process.logger) === null || _d === void 0 ? void 0 : _d.error('Error getting execution log');
|
|
317
|
+
_e.label = 6;
|
|
318
|
+
case 6: return [2 /*return*/];
|
|
278
319
|
}
|
|
279
320
|
});
|
|
280
321
|
});
|
|
281
322
|
}
|
|
282
|
-
|
|
323
|
+
/**
|
|
324
|
+
* Deploys app to `SASJS` server.
|
|
325
|
+
* @param {Target} target- the target having deploy configuration.
|
|
326
|
+
* @param {boolean} isLocal- flag indicating if specified target is
|
|
327
|
+
* from local sasjsconfig or global sasjsconfig file.
|
|
328
|
+
* @param {object} sasjs - optional configuration object of SAS adapter.
|
|
329
|
+
*/
|
|
330
|
+
function deployToSasjs(target, isLocal, sasjs) {
|
|
283
331
|
var _a, _b;
|
|
284
332
|
return __awaiter(this, void 0, void 0, function () {
|
|
285
|
-
var buildDestinationFolder, finalFilePathJSON, jsonContent, payload, result;
|
|
333
|
+
var buildDestinationFolder, finalFilePathJSON, jsonContent, payload, authConfig, e_2, result;
|
|
286
334
|
return __generator(this, function (_c) {
|
|
287
335
|
switch (_c.label) {
|
|
288
336
|
case 0:
|
|
@@ -292,18 +340,31 @@ function deployToSasjs(target, sasjs) {
|
|
|
292
340
|
case 1:
|
|
293
341
|
jsonContent = _c.sent();
|
|
294
342
|
payload = JSON.parse(jsonContent);
|
|
295
|
-
sasjs
|
|
296
|
-
|
|
297
|
-
:
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.error(err);
|
|
305
|
-
})];
|
|
343
|
+
if (!!sasjs) return [3 /*break*/, 5];
|
|
344
|
+
sasjs = new node_1.default({
|
|
345
|
+
serverUrl: target.serverUrl,
|
|
346
|
+
appLoc: target.appLoc,
|
|
347
|
+
serverType: target.serverType,
|
|
348
|
+
httpsAgentOptions: target.httpsAgentOptions,
|
|
349
|
+
debug: true
|
|
350
|
+
});
|
|
351
|
+
_c.label = 2;
|
|
306
352
|
case 2:
|
|
353
|
+
_c.trys.push([2, 4, , 5]);
|
|
354
|
+
return [4 /*yield*/, (0, config_1.getAuthConfig)(target)];
|
|
355
|
+
case 3:
|
|
356
|
+
authConfig = _c.sent();
|
|
357
|
+
return [3 /*break*/, 5];
|
|
358
|
+
case 4:
|
|
359
|
+
e_2 = _c.sent();
|
|
360
|
+
return [3 /*break*/, 5];
|
|
361
|
+
case 5: return [4 /*yield*/, sasjs
|
|
362
|
+
.deployToSASjs(payload, undefined, authConfig)
|
|
363
|
+
.catch(function (err) {
|
|
364
|
+
var _a;
|
|
365
|
+
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.error(err);
|
|
366
|
+
})];
|
|
367
|
+
case 6:
|
|
307
368
|
result = _c.sent();
|
|
308
369
|
if ((result === null || result === void 0 ? void 0 : result.status) === 'failure') {
|
|
309
370
|
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.error(result.message);
|
|
@@ -217,12 +217,14 @@ function printHelpText() {
|
|
|
217
217
|
},
|
|
218
218
|
{
|
|
219
219
|
name: 'request',
|
|
220
|
-
title: 'request <sasProgramPath> -d <path/to/datafile> -c <path/to/configfile> -t <targetName>',
|
|
220
|
+
title: 'request <sasProgramPath> -d <path/to/datafile> -c <path/to/configfile> -t <targetName> -l <path/to/log> -o <path/to/output>',
|
|
221
221
|
description: [
|
|
222
222
|
"lets",
|
|
223
223
|
"the user run a SAS job against a specified target.",
|
|
224
224
|
"The target can exist either in the local project configuration or in the global .sasjsrc file.",
|
|
225
|
-
"<sasProgramPath> - if this has a leading slash (eg /Public/app/folder/servicename) then it must be the full path. If it is a relative path (eg path/servicename) then it will be pre-pended with the appLoc - which must then be defined in the sasjs config."
|
|
225
|
+
"<sasProgramPath> - if this has a leading slash (eg /Public/app/folder/servicename) then it must be the full path. If it is a relative path (eg path/servicename) then it will be pre-pended with the appLoc - which must then be defined in the sasjs config.",
|
|
226
|
+
"<path/to/log> - Location in which to store the log file. If not provided AND an error occurs, the log will be stored in the execution path.",
|
|
227
|
+
"<path/to/output> - Location to store the output file. If not provided, a file named output.json will be saved in the execution path."
|
|
226
228
|
]
|
|
227
229
|
},
|
|
228
230
|
{
|