@sasjs/cli 3.21.0 → 3.21.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/deploy/deploy.d.ts +3 -5
- package/build/commands/deploy/deploy.js +54 -300
- package/build/commands/deploy/internal/deployToSASJSWithServicePack.d.ts +7 -0
- package/build/commands/deploy/internal/deployToSASJSWithServicePack.js +95 -0
- package/build/commands/deploy/internal/executeDeployScript.d.ts +2 -0
- package/build/commands/deploy/internal/executeDeployScript.js +55 -0
- package/build/commands/deploy/internal/executeDeployScriptSas9.d.ts +12 -0
- package/build/commands/deploy/internal/executeDeployScriptSas9.js +106 -0
- package/build/commands/deploy/internal/executeDeployScriptSasViya.d.ts +12 -0
- package/build/commands/deploy/internal/executeDeployScriptSasViya.js +108 -0
- package/build/commands/deploy/internal/executeDeployScriptSasjs.d.ts +12 -0
- package/build/commands/deploy/internal/executeDeployScriptSasjs.js +109 -0
- package/build/commands/deploy/internal/executeNonSasScript.d.ts +1 -0
- package/build/commands/deploy/internal/executeNonSasScript.js +77 -0
- package/build/commands/deploy/internal/executeSasScript.d.ts +8 -0
- package/build/commands/deploy/internal/executeSasScript.js +109 -0
- package/build/commands/deploy/internal/getDeployScripts.js +8 -17
- package/build/commands/deploy/internal/index.d.ts +8 -0
- package/build/commands/deploy/internal/index.js +20 -0
- package/build/commands/deploy/spec/cbd.spec.js +2 -2
- package/build/commands/deploy/spec/deploy.spec.d.ts +1 -0
- package/build/commands/deploy/spec/deploy.spec.js +317 -0
- package/build/commands/deploy/spec/getDeployScripts.spec.js +35 -27
- package/build/utils/file.d.ts +1 -0
- package/build/utils/file.js +6 -2
- package/build/utils/utils.d.ts +1 -0
- package/build/utils/utils.js +66 -1
- package/package.json +3 -1
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import SASjs from '@sasjs/adapter/node';
|
|
2
1
|
import { Target } from '@sasjs/utils';
|
|
3
2
|
/**
|
|
4
3
|
* 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
|
|
4
|
+
* @param {Target} target - the target having deploy configuration.
|
|
5
|
+
* @param {boolean} isLocal - flag indicating if specified target is
|
|
7
6
|
* from local sasjsconfig or global sasjsconfig file.
|
|
8
|
-
* @param {object} sasjs - optional configuration object of SAS adapter.
|
|
9
7
|
*/
|
|
10
|
-
export declare function deploy(target: Target, isLocal: boolean
|
|
8
|
+
export declare function deploy(target: Target, isLocal: boolean): Promise<void>;
|
|
@@ -41,329 +41,83 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
exports.deploy = void 0;
|
|
43
43
|
var path_1 = __importDefault(require("path"));
|
|
44
|
-
var os_1 = __importDefault(require("os"));
|
|
45
|
-
var node_1 = require("@sasjs/adapter/node");
|
|
46
44
|
var config_1 = require("../../utils/config");
|
|
47
|
-
var utils_1 = require("
|
|
48
|
-
var utils_2 = require("@sasjs/utils");
|
|
49
|
-
var file_1 = require("../../utils/file");
|
|
50
|
-
var getDeployScripts_1 = require("./internal/getDeployScripts");
|
|
45
|
+
var utils_1 = require("@sasjs/utils");
|
|
51
46
|
var deployToSasViyaWithServicePack_1 = require("../shared/deployToSasViyaWithServicePack");
|
|
47
|
+
var internal_1 = require("./internal");
|
|
52
48
|
/**
|
|
53
49
|
* 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
|
|
50
|
+
* @param {Target} target - the target having deploy configuration.
|
|
51
|
+
* @param {boolean} isLocal - flag indicating if specified target is
|
|
56
52
|
* from local sasjsconfig or global sasjsconfig file.
|
|
57
|
-
* @param {object} sasjs - optional configuration object of SAS adapter.
|
|
58
53
|
*/
|
|
59
|
-
function deploy(target, isLocal
|
|
60
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
54
|
+
function deploy(target, isLocal) {
|
|
55
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
61
56
|
return __awaiter(this, void 0, void 0, function () {
|
|
62
|
-
var
|
|
57
|
+
var streamConfig, buildDestinationFolder, finalFilePathJSON, appLoc, jsonObject, servicesFolder, webIndexFileName, buildOutputFileName, deployScriptPath, deployScripts;
|
|
63
58
|
var _this = this;
|
|
64
|
-
return __generator(this, function (
|
|
65
|
-
switch (
|
|
66
|
-
case 0:
|
|
67
|
-
|
|
68
|
-
|
|
59
|
+
return __generator(this, function (_l) {
|
|
60
|
+
switch (_l.label) {
|
|
61
|
+
case 0: return [4 /*yield*/, (0, config_1.getStreamConfig)(target)];
|
|
62
|
+
case 1:
|
|
63
|
+
streamConfig = _l.sent();
|
|
64
|
+
if (!((_a = target.deployConfig) === null || _a === void 0 ? void 0 : _a.deployServicePack)) return [3 /*break*/, 7];
|
|
65
|
+
buildDestinationFolder = process.sasjsConstants.buildDestinationFolder;
|
|
66
|
+
finalFilePathJSON = path_1.default.join(buildDestinationFolder, "".concat(target.name, ".json"));
|
|
67
|
+
if (!(target.serverType === utils_1.ServerType.SasViya)) return [3 /*break*/, 3];
|
|
69
68
|
appLoc = encodeURI(target.appLoc);
|
|
70
69
|
(_b = process.logger) === null || _b === void 0 ? void 0 : _b.info("Deploying service pack to ".concat(target.serverUrl, " at location ").concat(appLoc, " ."));
|
|
71
|
-
buildDestinationFolder_1 = process.sasjsConstants.buildDestinationFolder;
|
|
72
|
-
finalFilePathJSON = path_1.default.join(buildDestinationFolder_1, "".concat(target.name, ".json"));
|
|
73
70
|
return [4 /*yield*/, (0, deployToSasViyaWithServicePack_1.deployToSasViyaWithServicePack)(finalFilePathJSON, target, isLocal, true)];
|
|
74
|
-
case
|
|
75
|
-
jsonObject =
|
|
71
|
+
case 2:
|
|
72
|
+
jsonObject = _l.sent();
|
|
76
73
|
servicesFolder = jsonObject === null || jsonObject === void 0 ? void 0 : jsonObject.members.find(function (member) {
|
|
77
|
-
return (member === null || member === void 0 ? void 0 : member.name) === 'services' && (member === null || member === void 0 ? void 0 : member.type) ===
|
|
74
|
+
return (member === null || member === void 0 ? void 0 : member.name) === 'services' && (member === null || member === void 0 ? void 0 : member.type) === utils_1.MemberType.folder;
|
|
78
75
|
});
|
|
79
|
-
webIndexFileName = (_e = (_d = (_c = servicesFolder === null || servicesFolder === void 0 ? void 0 : servicesFolder.members) === null || _c === void 0 ? void 0 : _c.find(function (member) { return (member === null || member === void 0 ? void 0 : member.type) ===
|
|
76
|
+
webIndexFileName = (_e = (_d = (_c = servicesFolder === null || servicesFolder === void 0 ? void 0 : servicesFolder.members) === null || _c === void 0 ? void 0 : _c.find(function (member) { return (member === null || member === void 0 ? void 0 : member.type) === utils_1.MemberType.file; })) === null || _d === void 0 ? void 0 : _d.name) !== null && _e !== void 0 ? _e : '';
|
|
80
77
|
(_f = process.logger) === null || _f === void 0 ? void 0 : _f.success('Build pack has been successfully deployed.');
|
|
81
|
-
(_g = process.logger) === null || _g === void 0 ? void 0 : _g.success(target.serverType ===
|
|
78
|
+
(_g = process.logger) === null || _g === void 0 ? void 0 : _g.success(target.serverType === utils_1.ServerType.SasViya && webIndexFileName
|
|
82
79
|
? "".concat(target.serverUrl, "/SASJobExecution?_file=").concat(appLoc, "/services/").concat(webIndexFileName, "&_debug=2")
|
|
83
80
|
: "".concat(target.serverUrl, "/SASJobExecution?_folder=").concat(appLoc));
|
|
84
|
-
|
|
85
|
-
case 2: return [4 /*yield*/, (0, getDeployScripts_1.getDeployScripts)(target)];
|
|
81
|
+
return [3 /*break*/, 7];
|
|
86
82
|
case 3:
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
buildDestinationFolder = process.sasjsConstants.buildDestinationFolder;
|
|
92
|
-
logFilePath = buildDestinationFolder;
|
|
93
|
-
return [4 /*yield*/, (0, config_1.getStreamConfig)(target)];
|
|
83
|
+
if (!(target.serverType === utils_1.ServerType.Sasjs)) return [3 /*break*/, 5];
|
|
84
|
+
(_h = process.logger) === null || _h === void 0 ? void 0 : _h.info("Deploying service pack to ".concat(target.serverUrl, " at location ").concat(target.appLoc, " ."));
|
|
85
|
+
return [4 /*yield*/, (0, internal_1.deployToSasjsWithServicePack)(finalFilePathJSON, target, streamConfig)];
|
|
94
86
|
case 4:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return [4 /*yield*/, deployToSasjs(target, streamConfig)];
|
|
87
|
+
_l.sent();
|
|
88
|
+
return [3 /*break*/, 7];
|
|
98
89
|
case 5:
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
var _a, _b, _c, _d;
|
|
104
|
-
return __generator(this, function (_e) {
|
|
105
|
-
switch (_e.label) {
|
|
106
|
-
case 0:
|
|
107
|
-
deployScriptPath = (0, utils_2.getAbsolutePath)(deployScript, process.projectDir);
|
|
108
|
-
if (!(0, file_1.isSasFile)(deployScript)) return [3 /*break*/, 6];
|
|
109
|
-
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Processing SAS file ".concat(path_1.default.basename(deployScript), " ..."));
|
|
110
|
-
return [4 /*yield*/, (0, utils_2.readFile)(deployScriptPath)
|
|
111
|
-
// split into lines
|
|
112
|
-
];
|
|
113
|
-
case 1:
|
|
114
|
-
deployScriptContent = _e.sent();
|
|
115
|
-
linesToExecute = deployScriptContent
|
|
116
|
-
.replace(/\r\n/g, '\n')
|
|
117
|
-
.split('\n');
|
|
118
|
-
deployScriptName = path_1.default.basename(deployScript);
|
|
119
|
-
if (!(target.serverType === utils_2.ServerType.SasViya)) return [3 /*break*/, 3];
|
|
120
|
-
return [4 /*yield*/, deployToSasViya(deployScriptName, target, linesToExecute, logFilePath, streamConfig)];
|
|
121
|
-
case 2:
|
|
122
|
-
_e.sent();
|
|
123
|
-
return [3 /*break*/, 5];
|
|
124
|
-
case 3: return [4 /*yield*/, deployToSas9(deployScriptName, target, linesToExecute, logFilePath, streamConfig)];
|
|
125
|
-
case 4:
|
|
126
|
-
_e.sent();
|
|
127
|
-
_e.label = 5;
|
|
128
|
-
case 5: return [3 /*break*/, 9];
|
|
129
|
-
case 6:
|
|
130
|
-
if (!(0, file_1.isShellScript)(deployScript)) return [3 /*break*/, 8];
|
|
131
|
-
(_b = process.logger) === null || _b === void 0 ? void 0 : _b.info("Executing shell script ".concat(deployScript, " ..."));
|
|
132
|
-
logPath = path_1.default.join(process.projectDir, 'sasjsbuild', "".concat(path_1.default.basename(deployScript).replace('.sh', ''), ".log"));
|
|
133
|
-
return [4 /*yield*/, (0, utils_1.executeShellScript)(deployScriptPath, logPath)];
|
|
134
|
-
case 7:
|
|
135
|
-
_e.sent();
|
|
136
|
-
(_c = process.logger) === null || _c === void 0 ? void 0 : _c.success("Shell script execution completed! Log is here: ".concat(logPath));
|
|
137
|
-
return [3 /*break*/, 9];
|
|
138
|
-
case 8:
|
|
139
|
-
(_d = process.logger) === null || _d === void 0 ? void 0 : _d.error("Unable to process script located at ".concat(deployScriptPath));
|
|
140
|
-
_e.label = 9;
|
|
141
|
-
case 9: return [2 /*return*/];
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
}); })];
|
|
145
|
-
case 7:
|
|
146
|
-
_j.sent();
|
|
147
|
-
_j.label = 8;
|
|
148
|
-
case 8: return [2 /*return*/];
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
exports.deploy = deploy;
|
|
154
|
-
/**
|
|
155
|
-
* Deploys app to `SASVIYA` server through deployScript.
|
|
156
|
-
* @param {string} deployScriptName - name of deploy script.
|
|
157
|
-
* @param {Target} target - the target having deploy configuration.
|
|
158
|
-
* @param {string[]} linesToExecute - array of SAS code lines of deploy script to execute.
|
|
159
|
-
* @param {string} logFolder - optional path to log folder,
|
|
160
|
-
* log file name will be <deploy-script-name>.log
|
|
161
|
-
* @param {object} streamConfig - optional configuration object of StreamConfig
|
|
162
|
-
* for printing web app url on console.
|
|
163
|
-
*/
|
|
164
|
-
function deployToSasViya(deployScriptName, target, linesToExecute, logFolder, streamConfig) {
|
|
165
|
-
var _a, _b, _c, _d, _e;
|
|
166
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
167
|
-
var contextName, _f, sasjs, authConfig, executionResult, log, appLoc, webAppStreamUrl;
|
|
168
|
-
return __generator(this, function (_g) {
|
|
169
|
-
switch (_g.label) {
|
|
170
|
-
case 0:
|
|
171
|
-
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Sending ".concat(deployScriptName, " to SAS server for execution."));
|
|
172
|
-
contextName = target.contextName;
|
|
173
|
-
if (!contextName) {
|
|
174
|
-
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');
|
|
175
|
-
}
|
|
176
|
-
return [4 /*yield*/, (0, config_1.getSASjsAndAuthConfig)(target)];
|
|
177
|
-
case 1:
|
|
178
|
-
_f = _g.sent(), sasjs = _f.sasjs, authConfig = _f.authConfig;
|
|
179
|
-
return [4 /*yield*/, sasjs
|
|
180
|
-
.executeScript({
|
|
181
|
-
fileName: deployScriptName,
|
|
182
|
-
linesOfCode: linesToExecute,
|
|
183
|
-
contextName: contextName,
|
|
184
|
-
authConfig: authConfig
|
|
185
|
-
})
|
|
186
|
-
.catch(function (err) {
|
|
187
|
-
process.logger.error('executeScriptSASViya Error', err);
|
|
188
|
-
})];
|
|
189
|
-
case 2:
|
|
190
|
-
executionResult = _g.sent();
|
|
191
|
-
try {
|
|
192
|
-
log = executionResult.log.items
|
|
193
|
-
? executionResult.log.items
|
|
194
|
-
.map(function (i) { return i.line; })
|
|
195
|
-
.join(os_1.default.EOL)
|
|
196
|
-
: JSON.stringify(executionResult.log).replace(/\\n/g, os_1.default.EOL);
|
|
197
|
-
}
|
|
198
|
-
catch (e) {
|
|
199
|
-
(_b = process.logger) === null || _b === void 0 ? void 0 : _b.error("An error occurred when parsing the execution response: ".concat(e.message));
|
|
200
|
-
log = executionResult;
|
|
201
|
-
}
|
|
202
|
-
if (!logFolder) return [3 /*break*/, 4];
|
|
203
|
-
return [4 /*yield*/, (0, utils_2.createFile)(path_1.default.join(logFolder, "".concat(deployScriptName.replace('.sas', ''), ".log")), log)];
|
|
204
|
-
case 3:
|
|
205
|
-
_g.sent();
|
|
206
|
-
(_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"))));
|
|
207
|
-
return [3 /*break*/, 5];
|
|
208
|
-
case 4:
|
|
209
|
-
(_d = process.logger) === null || _d === void 0 ? void 0 : _d.error('Unable to create log file.');
|
|
210
|
-
_g.label = 5;
|
|
211
|
-
case 5:
|
|
212
|
-
if (streamConfig === null || streamConfig === void 0 ? void 0 : streamConfig.streamWeb) {
|
|
213
|
-
appLoc = encodeURI(target.appLoc);
|
|
214
|
-
webAppStreamUrl = "".concat(target.serverUrl, "/SASJobExecution?_FILE=").concat(appLoc, "/services/").concat(streamConfig.streamServiceName, ".html&_debug=2");
|
|
215
|
-
(_e = process.logger) === null || _e === void 0 ? void 0 : _e.info("Web app is available at ".concat(webAppStreamUrl));
|
|
216
|
-
}
|
|
217
|
-
return [2 /*return*/];
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Deploys app to `SAS9` server through deployScript.
|
|
224
|
-
* @param {string} deployScriptName - name of deploy script.
|
|
225
|
-
* @param {Target} target - the target having deploy configuration.
|
|
226
|
-
* @param {string[]} linesToExecute - array of SAS code lines of deploy script to execute.
|
|
227
|
-
* @param {string} logFolder - optional path to log folder,
|
|
228
|
-
* log file name will be <deploy-script-name>.log
|
|
229
|
-
* @param {object} streamConfig - optional configuration object of StreamConfig
|
|
230
|
-
* for printing web app url on console.
|
|
231
|
-
*/
|
|
232
|
-
function deployToSas9(deployScriptName, target, linesToExecute, logFolder, streamConfig) {
|
|
233
|
-
var _a, _b, _c, _d, _e;
|
|
234
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
235
|
-
var _f, sasjs, authConfigSas9, userName, password, completedWithError, executionResult, logContent, logFilePath, appLoc, webAppStreamUrl;
|
|
236
|
-
return __generator(this, function (_g) {
|
|
237
|
-
switch (_g.label) {
|
|
238
|
-
case 0: return [4 /*yield*/, (0, config_1.getSASjsAndAuthConfig)(target)];
|
|
239
|
-
case 1:
|
|
240
|
-
_f = _g.sent(), sasjs = _f.sasjs, authConfigSas9 = _f.authConfigSas9;
|
|
241
|
-
userName = authConfigSas9.userName;
|
|
242
|
-
password = (0, utils_2.decodeFromBase64)(authConfigSas9.userName);
|
|
243
|
-
completedWithError = false;
|
|
244
|
-
return [4 /*yield*/, sasjs
|
|
245
|
-
.executeScript({
|
|
246
|
-
linesOfCode: linesToExecute,
|
|
247
|
-
authConfigSas9: { userName: userName, password: password }
|
|
248
|
-
})
|
|
249
|
-
.catch(function (err) {
|
|
250
|
-
var _a;
|
|
251
|
-
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.log(formatErrorString(err));
|
|
252
|
-
if (err && err.errorCode === 404) {
|
|
253
|
-
(0, utils_1.displaySasjsRunnerError)(userName);
|
|
254
|
-
}
|
|
255
|
-
completedWithError = true;
|
|
256
|
-
return err;
|
|
257
|
-
})];
|
|
258
|
-
case 2:
|
|
259
|
-
executionResult = _g.sent();
|
|
260
|
-
if (!executionResult) {
|
|
261
|
-
return [2 /*return*/, (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('Error getting execution log')];
|
|
262
|
-
}
|
|
263
|
-
if (!logFolder) {
|
|
264
|
-
return [2 /*return*/, (_b = process.logger) === null || _b === void 0 ? void 0 : _b.error('Unable to create log file.')];
|
|
265
|
-
}
|
|
266
|
-
logContent = completedWithError
|
|
267
|
-
? executionResult.result
|
|
268
|
-
: executionResult;
|
|
269
|
-
logFilePath = path_1.default.join(logFolder, "".concat(deployScriptName.replace('.sas', ''), ".log"));
|
|
270
|
-
return [4 /*yield*/, (0, utils_2.createFile)(logFilePath, logContent !== null && logContent !== void 0 ? logContent : '')];
|
|
271
|
-
case 3:
|
|
272
|
-
_g.sent();
|
|
273
|
-
if (completedWithError) {
|
|
274
|
-
(_c = process.logger) === null || _c === void 0 ? void 0 : _c.error("Deployment failed with errors! Log is available at ".concat(logFilePath));
|
|
275
|
-
throw new Error("Deployment failed.");
|
|
276
|
-
}
|
|
277
|
-
(_d = process.logger) === null || _d === void 0 ? void 0 : _d.success("Deployment completed! Log is available at ".concat(logFilePath));
|
|
278
|
-
if (streamConfig === null || streamConfig === void 0 ? void 0 : streamConfig.streamWeb) {
|
|
279
|
-
appLoc = encodeURI(target.appLoc);
|
|
280
|
-
webAppStreamUrl = "".concat(target.serverUrl, "/SASStoredProcess/?_PROGRAM=").concat(appLoc, "/services/").concat(streamConfig.streamServiceName);
|
|
281
|
-
(_e = process.logger) === null || _e === void 0 ? void 0 : _e.info("Web app is available at ".concat(webAppStreamUrl));
|
|
282
|
-
}
|
|
283
|
-
return [2 /*return*/];
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* Deploys app to `SASJS` server.
|
|
290
|
-
* @param {Target} target - the target having deploy configuration.
|
|
291
|
-
* @param {object} streamConfig - optional config for deploying streaming app.
|
|
292
|
-
*/
|
|
293
|
-
function deployToSasjs(target, streamConfig) {
|
|
294
|
-
var _a, _b, _c;
|
|
295
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
296
|
-
var buildDestinationFolder, finalFilePathJSON, jsonContent, payload, authConfig, _d, sasjsApiClient, result, webAppStreamUrl;
|
|
297
|
-
return __generator(this, function (_e) {
|
|
298
|
-
switch (_e.label) {
|
|
299
|
-
case 0:
|
|
300
|
-
buildDestinationFolder = process.sasjsConstants.buildDestinationFolder;
|
|
301
|
-
finalFilePathJSON = path_1.default.join(buildDestinationFolder, "".concat(target.name, ".json"));
|
|
302
|
-
return [4 /*yield*/, (0, utils_2.readFile)(finalFilePathJSON)];
|
|
303
|
-
case 1:
|
|
304
|
-
jsonContent = _e.sent();
|
|
305
|
-
payload = JSON.parse(jsonContent);
|
|
306
|
-
return [4 /*yield*/, (0, utils_1.isSasJsServerInServerMode)(target)];
|
|
307
|
-
case 2:
|
|
308
|
-
if (!(_e.sent())) return [3 /*break*/, 4];
|
|
309
|
-
return [4 /*yield*/, (0, config_1.getAuthConfig)(target)];
|
|
310
|
-
case 3:
|
|
311
|
-
_d = _e.sent();
|
|
312
|
-
return [3 /*break*/, 5];
|
|
313
|
-
case 4:
|
|
314
|
-
_d = undefined;
|
|
315
|
-
_e.label = 5;
|
|
316
|
-
case 5:
|
|
317
|
-
authConfig = _d;
|
|
318
|
-
console.log(326);
|
|
319
|
-
sasjsApiClient = new node_1.SASjsApiClient(new node_1.SasjsRequestClient(target.serverUrl, target.httpsAgentOptions));
|
|
320
|
-
return [4 /*yield*/, sasjsApiClient
|
|
321
|
-
.deploy(payload, target.appLoc, authConfig)
|
|
322
|
-
.catch(function (err) {
|
|
323
|
-
var _a;
|
|
324
|
-
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('deployToSASjs Error', err);
|
|
325
|
-
})];
|
|
90
|
+
if (!(target.serverType === utils_1.ServerType.Sas9)) return [3 /*break*/, 7];
|
|
91
|
+
buildOutputFileName = ((_j = target.buildConfig) === null || _j === void 0 ? void 0 : _j.buildOutputFileName) || "".concat(target.name, ".sas");
|
|
92
|
+
deployScriptPath = path_1.default.join(buildDestinationFolder, buildOutputFileName);
|
|
93
|
+
return [4 /*yield*/, (0, internal_1.executeSasScript)(deployScriptPath, target, streamConfig)];
|
|
326
94
|
case 6:
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
if ((streamConfig === null || streamConfig === void 0 ? void 0 : streamConfig.streamWeb) && (result === null || result === void 0 ? void 0 : result.streamServiceName)) {
|
|
335
|
-
webAppStreamUrl = "".concat(target.serverUrl, "/AppStream/").concat(result.streamServiceName);
|
|
336
|
-
(_c = process.logger) === null || _c === void 0 ? void 0 : _c.info("Web app is available at ".concat(webAppStreamUrl));
|
|
95
|
+
_l.sent();
|
|
96
|
+
_l.label = 7;
|
|
97
|
+
case 7: return [4 /*yield*/, (0, internal_1.getDeployScripts)(target)];
|
|
98
|
+
case 8:
|
|
99
|
+
deployScripts = _l.sent();
|
|
100
|
+
if (deployScripts.length === 0 && !((_k = target.deployConfig) === null || _k === void 0 ? void 0 : _k.deployServicePack)) {
|
|
101
|
+
throw new Error("Deployment failed.\nPlease either enable the 'deployServicePack' option or add deployment script paths to 'deployScripts' in your target's 'deployConfig'.");
|
|
337
102
|
}
|
|
103
|
+
return [4 /*yield*/, (0, utils_1.asyncForEach)(deployScripts, function (deployScript) { return __awaiter(_this, void 0, void 0, function () {
|
|
104
|
+
var deployScriptPath;
|
|
105
|
+
return __generator(this, function (_a) {
|
|
106
|
+
switch (_a.label) {
|
|
107
|
+
case 0:
|
|
108
|
+
deployScriptPath = (0, utils_1.getAbsolutePath)(deployScript, process.projectDir);
|
|
109
|
+
return [4 /*yield*/, (0, internal_1.executeDeployScript)(deployScriptPath, target, streamConfig)];
|
|
110
|
+
case 1:
|
|
111
|
+
_a.sent();
|
|
112
|
+
return [2 /*return*/];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}); })];
|
|
116
|
+
case 9:
|
|
117
|
+
_l.sent();
|
|
338
118
|
return [2 /*return*/];
|
|
339
119
|
}
|
|
340
120
|
});
|
|
341
121
|
});
|
|
342
122
|
}
|
|
343
|
-
|
|
344
|
-
* this function formats the error string to dump error log on console
|
|
345
|
-
* @param error
|
|
346
|
-
* @returns returns a string
|
|
347
|
-
*/
|
|
348
|
-
function formatErrorString(error) {
|
|
349
|
-
var _a, _b, _c, _d;
|
|
350
|
-
var err = '';
|
|
351
|
-
err += "".concat(error.stack, "\n");
|
|
352
|
-
err += "url: ".concat(((_a = error.config) === null || _a === void 0 ? void 0 : _a.url) ? removePasswordFromUrl(error.config.url) : '', "\n");
|
|
353
|
-
err += "method: ".concat(((_b = error.config) === null || _b === void 0 ? void 0 : _b.method) ? error.config.method : '', "\n");
|
|
354
|
-
err += "headers: ".concat(((_c = error.config) === null || _c === void 0 ? void 0 : _c.headers) ? error.config.headers : '', "\n");
|
|
355
|
-
err += "data: ".concat(((_d = error.response) === null || _d === void 0 ? void 0 : _d.data) ? error.response.data : '');
|
|
356
|
-
return err;
|
|
357
|
-
}
|
|
358
|
-
/**
|
|
359
|
-
* removes password from url
|
|
360
|
-
* @param str parameter of type string
|
|
361
|
-
* @returns returns a string
|
|
362
|
-
*/
|
|
363
|
-
function removePasswordFromUrl(str) {
|
|
364
|
-
var startingIndex = str.indexOf('_password');
|
|
365
|
-
if (startingIndex !== -1) {
|
|
366
|
-
return str.slice(0, startingIndex) + 'PASSWORD-REMOVED';
|
|
367
|
-
}
|
|
368
|
-
return str;
|
|
369
|
-
}
|
|
123
|
+
exports.deploy = deploy;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Target, StreamConfig } from '@sasjs/utils';
|
|
2
|
+
/**
|
|
3
|
+
* Deploys app to `SASJS` server.
|
|
4
|
+
* @param {Target} target - the target having deploy configuration.
|
|
5
|
+
* @param {object} streamConfig - optional config for deploying streaming app.
|
|
6
|
+
*/
|
|
7
|
+
export declare function deployToSasjsWithServicePack(jsonFilePath: string, target: Target, streamConfig?: StreamConfig): Promise<void>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.deployToSasjsWithServicePack = void 0;
|
|
40
|
+
var node_1 = require("@sasjs/adapter/node");
|
|
41
|
+
var config_1 = require("../../../utils/config");
|
|
42
|
+
var utils_1 = require("../../../utils/utils");
|
|
43
|
+
var utils_2 = require("@sasjs/utils");
|
|
44
|
+
/**
|
|
45
|
+
* Deploys app to `SASJS` server.
|
|
46
|
+
* @param {Target} target - the target having deploy configuration.
|
|
47
|
+
* @param {object} streamConfig - optional config for deploying streaming app.
|
|
48
|
+
*/
|
|
49
|
+
function deployToSasjsWithServicePack(jsonFilePath, target, streamConfig) {
|
|
50
|
+
var _a, _b, _c;
|
|
51
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
52
|
+
var jsonContent, payload, authConfig, _d, sasjsApiClient, result, webAppStreamUrl;
|
|
53
|
+
return __generator(this, function (_e) {
|
|
54
|
+
switch (_e.label) {
|
|
55
|
+
case 0: return [4 /*yield*/, (0, utils_2.readFile)(jsonFilePath)];
|
|
56
|
+
case 1:
|
|
57
|
+
jsonContent = _e.sent();
|
|
58
|
+
payload = JSON.parse(jsonContent);
|
|
59
|
+
return [4 /*yield*/, (0, utils_1.isSasJsServerInServerMode)(target)];
|
|
60
|
+
case 2:
|
|
61
|
+
if (!(_e.sent())) return [3 /*break*/, 4];
|
|
62
|
+
return [4 /*yield*/, (0, config_1.getAuthConfig)(target)];
|
|
63
|
+
case 3:
|
|
64
|
+
_d = _e.sent();
|
|
65
|
+
return [3 /*break*/, 5];
|
|
66
|
+
case 4:
|
|
67
|
+
_d = undefined;
|
|
68
|
+
_e.label = 5;
|
|
69
|
+
case 5:
|
|
70
|
+
authConfig = _d;
|
|
71
|
+
sasjsApiClient = new node_1.SASjsApiClient(new node_1.SasjsRequestClient(target.serverUrl, target.httpsAgentOptions));
|
|
72
|
+
return [4 /*yield*/, sasjsApiClient
|
|
73
|
+
.deploy(payload, target.appLoc, authConfig)
|
|
74
|
+
.catch(function (err) {
|
|
75
|
+
var _a;
|
|
76
|
+
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('deployToSASjs Error', err);
|
|
77
|
+
})];
|
|
78
|
+
case 6:
|
|
79
|
+
result = _e.sent();
|
|
80
|
+
if ((result === null || result === void 0 ? void 0 : result.status) === 'failure') {
|
|
81
|
+
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.error(result.message);
|
|
82
|
+
if (result.example) {
|
|
83
|
+
(_b = process.logger) === null || _b === void 0 ? void 0 : _b.info("Payload example:\n".concat(JSON.stringify(result.example, null, 2)));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if ((streamConfig === null || streamConfig === void 0 ? void 0 : streamConfig.streamWeb) && (result === null || result === void 0 ? void 0 : result.streamServiceName)) {
|
|
87
|
+
webAppStreamUrl = "".concat(target.serverUrl, "/AppStream/").concat(result.streamServiceName);
|
|
88
|
+
(_c = process.logger) === null || _c === void 0 ? void 0 : _c.info("Web app is available at ".concat(webAppStreamUrl));
|
|
89
|
+
}
|
|
90
|
+
return [2 /*return*/];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
exports.deployToSasjsWithServicePack = deployToSasjsWithServicePack;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.executeDeployScript = void 0;
|
|
40
|
+
var file_1 = require("../../../utils/file");
|
|
41
|
+
var _1 = require("./");
|
|
42
|
+
function executeDeployScript(scriptPath, target, streamConfig) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
44
|
+
return __generator(this, function (_a) {
|
|
45
|
+
switch (_a.label) {
|
|
46
|
+
case 0:
|
|
47
|
+
if (!(0, file_1.isSasFile)(scriptPath)) return [3 /*break*/, 2];
|
|
48
|
+
return [4 /*yield*/, (0, _1.executeSasScript)(scriptPath, target, streamConfig)];
|
|
49
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
50
|
+
case 2: return [2 /*return*/, (0, _1.executeNonSasScript)(scriptPath)];
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
exports.executeDeployScript = executeDeployScript;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Target, StreamConfig } from '@sasjs/utils';
|
|
2
|
+
/**
|
|
3
|
+
* Execute deployScript on `SAS9` server.
|
|
4
|
+
* @param {string} deployScriptName - name of deploy script.
|
|
5
|
+
* @param {Target} target - the target having deploy configuration.
|
|
6
|
+
* @param {string[]} linesToExecute - array of SAS code lines of deploy script to execute.
|
|
7
|
+
* @param {string} logFolder - optional path to log folder,
|
|
8
|
+
* log file name will be <deploy-script-name>.log
|
|
9
|
+
* @param {object} streamConfig - optional configuration object of StreamConfig
|
|
10
|
+
* for printing web app url on console.
|
|
11
|
+
*/
|
|
12
|
+
export declare function executeDeployScriptSas9(deployScriptName: string, target: Target, linesToExecute: string[], logFilePath: string, streamConfig?: StreamConfig): Promise<void>;
|