@sasjs/cli 3.21.0 → 3.21.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/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 +4 -2
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
+
if (mod && mod.__esModule) return mod;
|
|
27
|
+
var result = {};
|
|
28
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
+
__setModuleDefault(result, mod);
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
33
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
34
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
35
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
36
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
37
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
38
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
42
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
43
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
44
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
45
|
+
function step(op) {
|
|
46
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
47
|
+
while (_) try {
|
|
48
|
+
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;
|
|
49
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
50
|
+
switch (op[0]) {
|
|
51
|
+
case 0: case 1: t = op; break;
|
|
52
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
53
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
54
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
55
|
+
default:
|
|
56
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
57
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
58
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
59
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
60
|
+
if (t[2]) _.ops.pop();
|
|
61
|
+
_.trys.pop(); continue;
|
|
62
|
+
}
|
|
63
|
+
op = body.call(thisArg, _);
|
|
64
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
65
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
69
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
70
|
+
};
|
|
71
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
72
|
+
var path_1 = __importDefault(require("path"));
|
|
73
|
+
var utils_1 = require("@sasjs/utils");
|
|
74
|
+
var deploy_1 = require("../deploy");
|
|
75
|
+
var test_1 = require("../../../utils/test");
|
|
76
|
+
var deployToSasViyaWithServicePackModule = __importStar(require("../../shared/deployToSasViyaWithServicePack"));
|
|
77
|
+
var deployToSASJSWithServicePackModule = __importStar(require("../internal/deployToSASJSWithServicePack"));
|
|
78
|
+
var executeSasScriptModule = __importStar(require("../internal/executeSasScript"));
|
|
79
|
+
var utilsModule = __importStar(require("../../../utils/utils"));
|
|
80
|
+
var commonTargetFields = {
|
|
81
|
+
name: 'test',
|
|
82
|
+
serverUrl: 'http://test.sasjs',
|
|
83
|
+
appLoc: '/Public/test/'
|
|
84
|
+
};
|
|
85
|
+
describe('deploy', function () {
|
|
86
|
+
var appName = '';
|
|
87
|
+
beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
88
|
+
return __generator(this, function (_a) {
|
|
89
|
+
switch (_a.label) {
|
|
90
|
+
case 0:
|
|
91
|
+
appName = "cli-tests-".concat((0, utils_1.generateTimestamp)());
|
|
92
|
+
return [4 /*yield*/, (0, test_1.createTestApp)(__dirname, appName)];
|
|
93
|
+
case 1:
|
|
94
|
+
_a.sent();
|
|
95
|
+
process.logger = new utils_1.Logger();
|
|
96
|
+
jest.spyOn(process.logger, 'success');
|
|
97
|
+
jest.spyOn(process.logger, 'error');
|
|
98
|
+
jest.spyOn(process.logger, 'info');
|
|
99
|
+
return [2 /*return*/];
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}); });
|
|
103
|
+
afterEach(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
104
|
+
return __generator(this, function (_a) {
|
|
105
|
+
switch (_a.label) {
|
|
106
|
+
case 0: return [4 /*yield*/, (0, test_1.removeTestApp)(__dirname, appName)];
|
|
107
|
+
case 1:
|
|
108
|
+
_a.sent();
|
|
109
|
+
return [2 /*return*/];
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}); });
|
|
113
|
+
describe('deployServicePack', function () {
|
|
114
|
+
it('should deploy services to SAS Viya as a service pack', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
115
|
+
var target, fileTree;
|
|
116
|
+
return __generator(this, function (_a) {
|
|
117
|
+
switch (_a.label) {
|
|
118
|
+
case 0:
|
|
119
|
+
target = new utils_1.Target(__assign(__assign({}, commonTargetFields), { serverType: utils_1.ServerType.SasViya, deployConfig: {
|
|
120
|
+
deployServicePack: true
|
|
121
|
+
} }));
|
|
122
|
+
fileTree = {
|
|
123
|
+
members: [
|
|
124
|
+
{
|
|
125
|
+
name: 'mockedFile',
|
|
126
|
+
type: utils_1.MemberType.file,
|
|
127
|
+
code: 'mocked code'
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
};
|
|
131
|
+
jest
|
|
132
|
+
.spyOn(deployToSasViyaWithServicePackModule, 'deployToSasViyaWithServicePack')
|
|
133
|
+
.mockImplementation(function () { return Promise.resolve(fileTree); });
|
|
134
|
+
return [4 /*yield*/, (0, deploy_1.deploy)(target, true)];
|
|
135
|
+
case 1:
|
|
136
|
+
_a.sent();
|
|
137
|
+
expect(process.logger.info).toHaveBeenCalledWith("Deploying service pack to ".concat(target.serverUrl, " at location ").concat(target.appLoc, " ."));
|
|
138
|
+
expect(deployToSasViyaWithServicePackModule.deployToSasViyaWithServicePack).toHaveBeenCalledWith(path_1.default.join(process.sasjsConstants.buildDestinationFolder, "".concat(target.name, ".json")), target, true, true);
|
|
139
|
+
return [2 /*return*/];
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}); });
|
|
143
|
+
it('should deploy services to SASJS as a service pack', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
144
|
+
var target;
|
|
145
|
+
return __generator(this, function (_a) {
|
|
146
|
+
switch (_a.label) {
|
|
147
|
+
case 0:
|
|
148
|
+
target = new utils_1.Target(__assign(__assign({}, commonTargetFields), { serverType: utils_1.ServerType.Sasjs, deployConfig: {
|
|
149
|
+
deployServicePack: true
|
|
150
|
+
} }));
|
|
151
|
+
jest
|
|
152
|
+
.spyOn(deployToSASJSWithServicePackModule, 'deployToSasjsWithServicePack')
|
|
153
|
+
.mockImplementation(function () { return Promise.resolve(); });
|
|
154
|
+
return [4 /*yield*/, (0, deploy_1.deploy)(target, true)];
|
|
155
|
+
case 1:
|
|
156
|
+
_a.sent();
|
|
157
|
+
expect(process.logger.info).toHaveBeenCalledWith("Deploying service pack to ".concat(target.serverUrl, " at location ").concat(target.appLoc, " ."));
|
|
158
|
+
expect(deployToSASJSWithServicePackModule.deployToSasjsWithServicePack).toHaveBeenCalledWith(path_1.default.join(process.sasjsConstants.buildDestinationFolder, "".concat(target.name, ".json")), target, { streamServiceName: 'clickme' });
|
|
159
|
+
return [2 /*return*/];
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}); });
|
|
163
|
+
it('should deploy services to SAS9 by executing sas script which is created in the result of build process', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
164
|
+
var target;
|
|
165
|
+
return __generator(this, function (_a) {
|
|
166
|
+
switch (_a.label) {
|
|
167
|
+
case 0:
|
|
168
|
+
target = new utils_1.Target(__assign(__assign({}, commonTargetFields), { serverType: utils_1.ServerType.Sas9, deployConfig: {
|
|
169
|
+
deployServicePack: true
|
|
170
|
+
} }));
|
|
171
|
+
jest
|
|
172
|
+
.spyOn(executeSasScriptModule, 'executeSasScript')
|
|
173
|
+
.mockImplementation(function () { return Promise.resolve(); });
|
|
174
|
+
return [4 /*yield*/, (0, deploy_1.deploy)(target, true)];
|
|
175
|
+
case 1:
|
|
176
|
+
_a.sent();
|
|
177
|
+
expect(executeSasScriptModule.executeSasScript).toHaveBeenCalledWith(path_1.default.join(process.sasjsConstants.buildDestinationFolder, "".concat(target.name, ".sas")), target, { streamServiceName: 'clickme' });
|
|
178
|
+
return [2 /*return*/];
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}); });
|
|
182
|
+
});
|
|
183
|
+
describe('deployScripts', function () {
|
|
184
|
+
describe('SAS', function () {
|
|
185
|
+
it('should execute all scripts on SASVIYA', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
186
|
+
return __generator(this, function (_a) {
|
|
187
|
+
switch (_a.label) {
|
|
188
|
+
case 0: return [4 /*yield*/, testSasDeployScripts(utils_1.ServerType.SasViya)];
|
|
189
|
+
case 1:
|
|
190
|
+
_a.sent();
|
|
191
|
+
return [2 /*return*/];
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
}); });
|
|
195
|
+
it('should execute all scripts on SAS9', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
196
|
+
return __generator(this, function (_a) {
|
|
197
|
+
switch (_a.label) {
|
|
198
|
+
case 0: return [4 /*yield*/, testSasDeployScripts(utils_1.ServerType.Sas9)];
|
|
199
|
+
case 1:
|
|
200
|
+
_a.sent();
|
|
201
|
+
return [2 /*return*/];
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}); });
|
|
205
|
+
it('should execute all scripts on SASJS', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
206
|
+
return __generator(this, function (_a) {
|
|
207
|
+
switch (_a.label) {
|
|
208
|
+
case 0: return [4 /*yield*/, testSasDeployScripts(utils_1.ServerType.Sasjs)];
|
|
209
|
+
case 1:
|
|
210
|
+
_a.sent();
|
|
211
|
+
return [2 /*return*/];
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}); });
|
|
215
|
+
});
|
|
216
|
+
describe('Non SAS', function () {
|
|
217
|
+
it('should execute shell script', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
218
|
+
var target;
|
|
219
|
+
return __generator(this, function (_a) {
|
|
220
|
+
switch (_a.label) {
|
|
221
|
+
case 0:
|
|
222
|
+
target = new utils_1.Target(__assign(__assign({}, commonTargetFields), { serverType: utils_1.ServerType.Sasjs, deployConfig: {
|
|
223
|
+
deployScripts: ['script.sh']
|
|
224
|
+
} }));
|
|
225
|
+
jest
|
|
226
|
+
.spyOn(utilsModule, 'executeShellScript')
|
|
227
|
+
.mockImplementation(function () { return Promise.resolve(); });
|
|
228
|
+
return [4 /*yield*/, (0, deploy_1.deploy)(target, true)];
|
|
229
|
+
case 1:
|
|
230
|
+
_a.sent();
|
|
231
|
+
expect(process.logger.info).toHaveBeenCalledWith("Executing shell script ".concat(path_1.default.join(process.projectDir, "script.sh"), " ..."));
|
|
232
|
+
expect(process.logger.success).toHaveBeenCalledWith("Shell script execution completed! Log is here: ".concat(path_1.default.join(process.sasjsConstants.buildDestinationFolder, 'script.log')));
|
|
233
|
+
return [2 /*return*/];
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
}); });
|
|
237
|
+
it('should execute batch script', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
238
|
+
var target;
|
|
239
|
+
return __generator(this, function (_a) {
|
|
240
|
+
switch (_a.label) {
|
|
241
|
+
case 0:
|
|
242
|
+
target = new utils_1.Target(__assign(__assign({}, commonTargetFields), { serverType: utils_1.ServerType.Sasjs, deployConfig: {
|
|
243
|
+
deployScripts: ['script.bat']
|
|
244
|
+
} }));
|
|
245
|
+
jest
|
|
246
|
+
.spyOn(utilsModule, 'executeShellScript')
|
|
247
|
+
.mockImplementation(function () { return Promise.resolve(); });
|
|
248
|
+
return [4 /*yield*/, (0, deploy_1.deploy)(target, true)];
|
|
249
|
+
case 1:
|
|
250
|
+
_a.sent();
|
|
251
|
+
expect(process.logger.info).toHaveBeenCalledWith("Executing shell script ".concat(path_1.default.join(process.projectDir, "script.bat"), " ..."));
|
|
252
|
+
expect(process.logger.success).toHaveBeenCalledWith("Shell script execution completed! Log is here: ".concat(path_1.default.join(process.sasjsConstants.buildDestinationFolder, 'script.log')));
|
|
253
|
+
return [2 /*return*/];
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
}); });
|
|
257
|
+
it('should execute powershell script', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
258
|
+
var target;
|
|
259
|
+
return __generator(this, function (_a) {
|
|
260
|
+
switch (_a.label) {
|
|
261
|
+
case 0:
|
|
262
|
+
target = new utils_1.Target(__assign(__assign({}, commonTargetFields), { serverType: utils_1.ServerType.Sasjs, deployConfig: {
|
|
263
|
+
deployScripts: ['script.ps1']
|
|
264
|
+
} }));
|
|
265
|
+
jest
|
|
266
|
+
.spyOn(utilsModule, 'executePowerShellScript')
|
|
267
|
+
.mockImplementation(function () { return Promise.resolve(); });
|
|
268
|
+
return [4 /*yield*/, (0, deploy_1.deploy)(target, true)];
|
|
269
|
+
case 1:
|
|
270
|
+
_a.sent();
|
|
271
|
+
expect(process.logger.info).toHaveBeenCalledWith("Executing powershell script ".concat(path_1.default.join(process.projectDir, "script.ps1"), " ..."));
|
|
272
|
+
expect(process.logger.success).toHaveBeenCalledWith("PowerShell script execution completed! Log is here: ".concat(path_1.default.join(process.sasjsConstants.buildDestinationFolder, 'script.log')));
|
|
273
|
+
return [2 /*return*/];
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
}); });
|
|
277
|
+
it('should show error message when script type is not supported', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
278
|
+
var target;
|
|
279
|
+
return __generator(this, function (_a) {
|
|
280
|
+
switch (_a.label) {
|
|
281
|
+
case 0:
|
|
282
|
+
target = new utils_1.Target(__assign(__assign({}, commonTargetFields), { serverType: utils_1.ServerType.Sasjs, deployConfig: {
|
|
283
|
+
deployScripts: ['script.invalid']
|
|
284
|
+
} }));
|
|
285
|
+
return [4 /*yield*/, (0, deploy_1.deploy)(target, true)];
|
|
286
|
+
case 1:
|
|
287
|
+
_a.sent();
|
|
288
|
+
expect(process.logger.error).toHaveBeenCalledWith("Unable to process script located at ".concat(path_1.default.join(process.projectDir, "script.invalid")));
|
|
289
|
+
return [2 /*return*/];
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
}); });
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
function testSasDeployScripts(serverType) {
|
|
297
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
298
|
+
var target;
|
|
299
|
+
return __generator(this, function (_a) {
|
|
300
|
+
switch (_a.label) {
|
|
301
|
+
case 0:
|
|
302
|
+
target = new utils_1.Target(__assign(__assign({}, commonTargetFields), { serverType: serverType, deployConfig: {
|
|
303
|
+
deployScripts: ['script1.sas', 'script2.sas']
|
|
304
|
+
} }));
|
|
305
|
+
jest
|
|
306
|
+
.spyOn(executeSasScriptModule, 'executeSasScript')
|
|
307
|
+
.mockImplementation(function () { return Promise.resolve(); });
|
|
308
|
+
return [4 /*yield*/, (0, deploy_1.deploy)(target, true)];
|
|
309
|
+
case 1:
|
|
310
|
+
_a.sent();
|
|
311
|
+
expect(executeSasScriptModule.executeSasScript).toHaveBeenNthCalledWith(1, path_1.default.join(process.projectDir, "script1.sas"), target, { streamServiceName: 'clickme' });
|
|
312
|
+
expect(executeSasScriptModule.executeSasScript).toHaveBeenNthCalledWith(2, path_1.default.join(process.projectDir, "script2.sas"), target, { streamServiceName: 'clickme' });
|
|
313
|
+
return [2 /*return*/];
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
}
|
|
@@ -35,6 +35,31 @@ 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, pack) {
|
|
55
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
56
|
+
if (ar || !(i in from)) {
|
|
57
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
58
|
+
ar[i] = from[i];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
62
|
+
};
|
|
38
63
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
64
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
65
|
};
|
|
@@ -78,36 +103,19 @@ describe('getDeployScripts', function () {
|
|
|
78
103
|
}
|
|
79
104
|
});
|
|
80
105
|
}); });
|
|
81
|
-
it('should
|
|
82
|
-
var
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return [4 /*yield*/, (0, getDeployScripts_1.getDeployScripts)(target)];
|
|
88
|
-
case 1:
|
|
89
|
-
deployScripts = _a.sent();
|
|
90
|
-
buildDestinationFolder = process.sasjsConstants.buildDestinationFolder;
|
|
91
|
-
expect(deployScripts).toIncludeAllMembers([
|
|
92
|
-
path_1.default.join(buildDestinationFolder, 'output-test.sas')
|
|
93
|
-
]);
|
|
94
|
-
return [2 /*return*/];
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
}); });
|
|
98
|
-
it('should should fallback to target name for the build output file name for SAS9', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
99
|
-
var deployScripts, buildDestinationFolder;
|
|
100
|
-
return __generator(this, function (_a) {
|
|
101
|
-
switch (_a.label) {
|
|
106
|
+
it('should return all deployScripts present at root level of configuration and in target', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
107
|
+
var scripts, deployScripts;
|
|
108
|
+
var _a;
|
|
109
|
+
var _b;
|
|
110
|
+
return __generator(this, function (_c) {
|
|
111
|
+
switch (_c.label) {
|
|
102
112
|
case 0:
|
|
103
|
-
|
|
113
|
+
scripts = ['script1.sh', 'script2.bat', 'script3.ps1'];
|
|
114
|
+
(_b = target.deployConfig) === null || _b === void 0 ? void 0 : (_a = _b.deployScripts).push.apply(_a, __spreadArray([], __read(scripts), false));
|
|
104
115
|
return [4 /*yield*/, (0, getDeployScripts_1.getDeployScripts)(target)];
|
|
105
116
|
case 1:
|
|
106
|
-
deployScripts =
|
|
107
|
-
|
|
108
|
-
expect(deployScripts).toIncludeAllMembers([
|
|
109
|
-
path_1.default.join(buildDestinationFolder, "".concat(target.name, ".sas"))
|
|
110
|
-
]);
|
|
117
|
+
deployScripts = _c.sent();
|
|
118
|
+
expect(deployScripts).toEqual(__spreadArray(['sasjs/build/deployscript.sh'], __read(scripts), false));
|
|
111
119
|
return [2 /*return*/];
|
|
112
120
|
}
|
|
113
121
|
});
|
package/build/utils/file.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export function isSasFile(filePath: any): boolean;
|
|
|
4
4
|
export function isJsonFile(filePath: any): boolean;
|
|
5
5
|
export function isCsvFile(filePath: any): boolean;
|
|
6
6
|
export function isShellScript(filePath: any): boolean;
|
|
7
|
+
export function isPowerShellScript(filePath: any): boolean;
|
|
7
8
|
export function getBrief(fileContent: any): any;
|
|
8
9
|
export function getRelativePath(from: any, to: any): any[];
|
|
9
10
|
export function saveToDefaultLocation(filePath: any, data: any): Promise<{
|
package/build/utils/file.js
CHANGED
|
@@ -39,7 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.sasFileRegExp = exports.saveToDefaultLocation = exports.getRelativePath = exports.getBrief = exports.sanitizeFileName = exports.isShellScript = exports.isCsvFile = exports.isJsonFile = exports.isSasFile = exports.unifyFilePath = exports.createFolderStructure = void 0;
|
|
42
|
+
exports.sasFileRegExp = exports.saveToDefaultLocation = exports.getRelativePath = exports.getBrief = exports.sanitizeFileName = exports.isPowerShellScript = exports.isShellScript = exports.isCsvFile = exports.isJsonFile = exports.isSasFile = exports.unifyFilePath = exports.createFolderStructure = void 0;
|
|
43
43
|
var path_1 = __importDefault(require("path"));
|
|
44
44
|
var utils_1 = require("@sasjs/utils");
|
|
45
45
|
var config_1 = require("./config");
|
|
@@ -122,9 +122,13 @@ function isCsvFile(filePath) {
|
|
|
122
122
|
}
|
|
123
123
|
exports.isCsvFile = isCsvFile;
|
|
124
124
|
function isShellScript(filePath) {
|
|
125
|
-
return path_1.default.extname(filePath) === '.sh';
|
|
125
|
+
return path_1.default.extname(filePath) === '.sh' || path_1.default.extname(filePath) === '.bat';
|
|
126
126
|
}
|
|
127
127
|
exports.isShellScript = isShellScript;
|
|
128
|
+
function isPowerShellScript(filePath) {
|
|
129
|
+
return path_1.default.extname(filePath) === '.ps1';
|
|
130
|
+
}
|
|
131
|
+
exports.isPowerShellScript = isPowerShellScript;
|
|
128
132
|
var sanitizeFileName = function (fileName) {
|
|
129
133
|
return fileName.replace(/[^a-z0-9]/gi, '_');
|
|
130
134
|
};
|
package/build/utils/utils.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare function setupGitIgnore(folderName: string): Promise<void>;
|
|
|
11
11
|
export declare function setupDoxygen(folderPath: string): Promise<void>;
|
|
12
12
|
export declare function getUniqServicesObj(services: string[]): any;
|
|
13
13
|
export declare function executeShellScript(filePath: string, logFilePath: string): Promise<unknown>;
|
|
14
|
+
export declare function executePowerShellScript(filePath: string, logFilePath: string): Promise<void>;
|
|
14
15
|
/**
|
|
15
16
|
* Extracts plain text job log from fetched json log
|
|
16
17
|
* @param {object} logJson
|
package/build/utils/utils.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
+
return cooked;
|
|
5
|
+
};
|
|
2
6
|
var __assign = (this && this.__assign) || function () {
|
|
3
7
|
__assign = Object.assign || function(t) {
|
|
4
8
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -86,8 +90,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
86
90
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
87
91
|
};
|
|
88
92
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
89
|
-
exports.isSasJsServerInServerMode = exports.getNodeModulePath = exports.isSASjsProject = exports.terminateProcess = exports.prefixAppLoc = exports.loadEnvVariables = exports.displaySasjsRunnerError = exports.getAdapterInstance = exports.checkNodeVersion = exports.millisecondsToDdHhMmSs = exports.arrToObj = exports.convertToSASStatements = exports.parseLogLines = exports.executeShellScript = exports.getUniqServicesObj = exports.setupDoxygen = exports.setupGitIgnore = exports.setupNpmProject = exports.createTemplateApp = exports.createMinimalApp = exports.createAngularApp = exports.createReactApp = exports.diff = exports.inExistingProject = void 0;
|
|
93
|
+
exports.isSasJsServerInServerMode = exports.getNodeModulePath = exports.isSASjsProject = exports.terminateProcess = exports.prefixAppLoc = exports.loadEnvVariables = exports.displaySasjsRunnerError = exports.getAdapterInstance = exports.checkNodeVersion = exports.millisecondsToDdHhMmSs = exports.arrToObj = exports.convertToSASStatements = exports.parseLogLines = exports.executePowerShellScript = exports.executeShellScript = exports.getUniqServicesObj = exports.setupDoxygen = exports.setupGitIgnore = exports.setupNpmProject = exports.createTemplateApp = exports.createMinimalApp = exports.createAngularApp = exports.createReactApp = exports.diff = exports.inExistingProject = void 0;
|
|
90
94
|
var shelljs_1 = __importDefault(require("shelljs"));
|
|
95
|
+
var node_powershell_1 = require("node-powershell");
|
|
91
96
|
var path_1 = __importDefault(require("path"));
|
|
92
97
|
var ora_1 = __importDefault(require("ora"));
|
|
93
98
|
var axios_1 = __importDefault(require("axios"));
|
|
@@ -420,6 +425,65 @@ function executeShellScript(filePath, logFilePath) {
|
|
|
420
425
|
});
|
|
421
426
|
}
|
|
422
427
|
exports.executeShellScript = executeShellScript;
|
|
428
|
+
function executePowerShellScript(filePath, logFilePath) {
|
|
429
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
430
|
+
var ps, scriptCommand;
|
|
431
|
+
var _this = this;
|
|
432
|
+
return __generator(this, function (_a) {
|
|
433
|
+
switch (_a.label) {
|
|
434
|
+
case 0:
|
|
435
|
+
ps = new node_powershell_1.PowerShell({
|
|
436
|
+
executableOptions: {
|
|
437
|
+
'-ExecutionPolicy': 'Bypass',
|
|
438
|
+
'-NoProfile': true
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
scriptCommand = node_powershell_1.PowerShell.command(templateObject_1 || (templateObject_1 = __makeTemplateObject([". ", ""], [". ", ""])), filePath);
|
|
442
|
+
return [4 /*yield*/, ps
|
|
443
|
+
.invoke(scriptCommand)
|
|
444
|
+
.then(function (result) { return __awaiter(_this, void 0, void 0, function () {
|
|
445
|
+
var content;
|
|
446
|
+
var _a, _b;
|
|
447
|
+
return __generator(this, function (_c) {
|
|
448
|
+
switch (_c.label) {
|
|
449
|
+
case 0:
|
|
450
|
+
if (result.hadErrors) {
|
|
451
|
+
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.error("Error: ".concat(result.stderr));
|
|
452
|
+
throw new Error('Error executing shell script:' + result.stderr);
|
|
453
|
+
}
|
|
454
|
+
if (!logFilePath) return [3 /*break*/, 2];
|
|
455
|
+
content = (_b = result.stdout) === null || _b === void 0 ? void 0 : _b.toString().replace(/\u001b\[\?1h\u001b\[\?1l/g, '');
|
|
456
|
+
return [4 /*yield*/, (0, utils_1.createFile)(logFilePath, content !== null && content !== void 0 ? content : '')];
|
|
457
|
+
case 1:
|
|
458
|
+
_c.sent();
|
|
459
|
+
_c.label = 2;
|
|
460
|
+
case 2: return [2 /*return*/];
|
|
461
|
+
}
|
|
462
|
+
});
|
|
463
|
+
}); })
|
|
464
|
+
.catch(function (error) {
|
|
465
|
+
var _a;
|
|
466
|
+
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.error("Error: ".concat(error));
|
|
467
|
+
throw new Error('Error executing shell script: ' + error);
|
|
468
|
+
})
|
|
469
|
+
.finally(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
470
|
+
return __generator(this, function (_a) {
|
|
471
|
+
switch (_a.label) {
|
|
472
|
+
case 0: return [4 /*yield*/, ps.dispose()];
|
|
473
|
+
case 1:
|
|
474
|
+
_a.sent();
|
|
475
|
+
return [2 /*return*/];
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
}); })];
|
|
479
|
+
case 1:
|
|
480
|
+
_a.sent();
|
|
481
|
+
return [2 /*return*/];
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
exports.executePowerShellScript = executePowerShellScript;
|
|
423
487
|
/**
|
|
424
488
|
* Extracts plain text job log from fetched json log
|
|
425
489
|
* @param {object} logJson
|
|
@@ -666,3 +730,4 @@ var isSasJsServerInServerMode = function (target) { return __awaiter(void 0, voi
|
|
|
666
730
|
});
|
|
667
731
|
}); };
|
|
668
732
|
exports.isSasJsServerInServerMode = isSasJsServerInServerMode;
|
|
733
|
+
var templateObject_1;
|
package/package.json
CHANGED
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@sasjs/adapter": "4.0.1",
|
|
54
54
|
"@sasjs/core": "4.43.1",
|
|
55
|
-
"@sasjs/lint": "1.
|
|
55
|
+
"@sasjs/lint": "1.15.0",
|
|
56
56
|
"@sasjs/utils": "2.51.0",
|
|
57
57
|
"adm-zip": "0.5.9",
|
|
58
58
|
"chalk": "4.1.2",
|
|
@@ -66,6 +66,7 @@
|
|
|
66
66
|
"lodash.groupby": "4.6.0",
|
|
67
67
|
"lodash.uniqby": "4.7.0",
|
|
68
68
|
"node-graphviz": "0.1.1",
|
|
69
|
+
"node-powershell": "5.0.1",
|
|
69
70
|
"ora": "5.4.1",
|
|
70
71
|
"rimraf": "3.0.2",
|
|
71
72
|
"shelljs": "0.8.5",
|
|
@@ -77,6 +78,7 @@
|
|
|
77
78
|
"@babel/preset-env": "7.15.6",
|
|
78
79
|
"@babel/preset-typescript": "7.15.0",
|
|
79
80
|
"@types/adm-zip": "0.5.0",
|
|
81
|
+
"@types/debug": "4.1.7",
|
|
80
82
|
"@types/find": "0.2.1",
|
|
81
83
|
"@types/jest": "27.0.2",
|
|
82
84
|
"@types/jsdom": "16.2.15",
|
|
@@ -99,5 +101,5 @@
|
|
|
99
101
|
"typescript": "4.5.4",
|
|
100
102
|
"util": "0.12.4"
|
|
101
103
|
},
|
|
102
|
-
"version": "3.21.
|
|
104
|
+
"version": "3.21.2"
|
|
103
105
|
}
|