@sasjs/cli 3.19.6 → 3.20.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/compile/spec/compile.spec.js +2 -1
- package/build/commands/deploy/deploy.js +54 -108
- package/build/commands/deploy/spec/cbd.spec.js +31 -8
- package/build/commands/fs/fsCommand.d.ts +11 -0
- package/build/commands/fs/fsCommand.js +335 -0
- package/build/commands/fs/internal/executeCode.d.ts +4 -0
- package/build/commands/fs/internal/executeCode.js +126 -0
- package/build/commands/fs/internal/extractHashArray.d.ts +1 -0
- package/build/commands/fs/internal/extractHashArray.js +20 -0
- package/build/commands/fs/spec/executeCode.spec.d.ts +1 -0
- package/build/commands/fs/spec/executeCode.spec.js +197 -0
- package/build/commands/fs/spec/extractHashArray.spec.d.ts +1 -0
- package/build/commands/fs/spec/extractHashArray.spec.js +14 -0
- package/build/commands/fs/spec/fsCommand.spec.d.ts +1 -0
- package/build/commands/fs/spec/fsCommand.spec.js +297 -0
- package/build/commands/help/help.js +14 -0
- package/build/commands/job/internal/execute/sas9.d.ts +1 -1
- package/build/commands/job/internal/execute/sasjs.d.ts +3 -4
- package/build/commands/job/internal/execute/sasjs.js +36 -20
- package/build/commands/job/jobCommand.d.ts +4 -8
- package/build/commands/job/jobCommand.js +71 -97
- package/build/commands/job/spec/execute.spec.js +52 -7
- package/build/commands/job/spec/jobCommand.spec.js +8 -3
- package/build/commands/request/spec/request.spec.server.sas9.js +2 -0
- package/build/commands/run/run.js +70 -107
- package/build/types/command/commandFactory.js +2 -0
- package/build/utils/config.d.ts +28 -1
- package/build/utils/config.js +71 -1
- package/build/utils/index.d.ts +1 -0
- package/build/utils/index.js +1 -0
- package/package.json +8 -7
|
@@ -66,8 +66,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
66
66
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
67
67
|
exports.runSasCode = void 0;
|
|
68
68
|
var path_1 = __importDefault(require("path"));
|
|
69
|
-
var node_1 =
|
|
70
|
-
var node_2 = require("@sasjs/adapter/node");
|
|
69
|
+
var node_1 = require("@sasjs/adapter/node");
|
|
71
70
|
var config_1 = require("../../utils/config");
|
|
72
71
|
var utils_1 = require("@sasjs/utils");
|
|
73
72
|
var __1 = require("../");
|
|
@@ -87,7 +86,7 @@ function runSasCode(target, filePath, compile, logFile, source) {
|
|
|
87
86
|
var _a;
|
|
88
87
|
if (compile === void 0) { compile = false; }
|
|
89
88
|
return __awaiter(this, void 0, void 0, function () {
|
|
90
|
-
var isTempFile, sourcefilePathParts, sourceFolderPath, sasFilePath, sasFileContent, linesToExecute, macroVars, macroVarStatements
|
|
89
|
+
var isTempFile, sourcefilePathParts, sourceFolderPath, sasFilePath, sasFileContent, linesToExecute, macroVars, macroVarStatements;
|
|
91
90
|
var _b;
|
|
92
91
|
return __generator(this, function (_c) {
|
|
93
92
|
switch (_c.label) {
|
|
@@ -127,59 +126,46 @@ function runSasCode(target, filePath, compile, logFile, source) {
|
|
|
127
126
|
linesToExecute = __spreadArray(__spreadArray([], __read(macroVarStatements), false), __read(linesToExecute), false);
|
|
128
127
|
_c.label = 8;
|
|
129
128
|
case 8:
|
|
130
|
-
if (!
|
|
131
|
-
return [4 /*yield*/,
|
|
129
|
+
if (!isTempFile) return [3 /*break*/, 10];
|
|
130
|
+
return [4 /*yield*/, (0, utils_1.deleteFile)(filePath)];
|
|
132
131
|
case 9:
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
_c.sent();
|
|
133
|
+
_c.label = 10;
|
|
135
134
|
case 10:
|
|
136
|
-
if (!(target.serverType === utils_1.ServerType.
|
|
135
|
+
if (!(target.serverType === utils_1.ServerType.SasViya)) return [3 /*break*/, 12];
|
|
136
|
+
return [4 /*yield*/, executeOnSasViya(filePath, target, linesToExecute, logFile)];
|
|
137
|
+
case 11: return [2 /*return*/, _c.sent()];
|
|
138
|
+
case 12:
|
|
139
|
+
if (!(target.serverType === utils_1.ServerType.Sas9)) return [3 /*break*/, 14];
|
|
137
140
|
return [4 /*yield*/, executeOnSas9(target, linesToExecute, logFile)];
|
|
138
|
-
case
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
case 12: return [4 /*yield*/, executeOnSasJS(filePath, target, linesToExecute, logFile)];
|
|
142
|
-
case 13:
|
|
143
|
-
result = _c.sent();
|
|
144
|
-
_c.label = 14;
|
|
145
|
-
case 14:
|
|
146
|
-
if (!isTempFile) return [3 /*break*/, 16];
|
|
147
|
-
return [4 /*yield*/, (0, utils_1.deleteFile)(filePath)];
|
|
148
|
-
case 15:
|
|
149
|
-
_c.sent();
|
|
150
|
-
_c.label = 16;
|
|
151
|
-
case 16: return [2 /*return*/, result];
|
|
141
|
+
case 13: return [2 /*return*/, _c.sent()];
|
|
142
|
+
case 14: return [4 /*yield*/, executeOnSasJS(filePath, target, linesToExecute, logFile)];
|
|
143
|
+
case 15: return [2 /*return*/, _c.sent()];
|
|
152
144
|
}
|
|
153
145
|
});
|
|
154
146
|
});
|
|
155
147
|
}
|
|
156
148
|
exports.runSasCode = runSasCode;
|
|
157
149
|
function executeOnSasViya(filePath, target, linesToExecute, logFile) {
|
|
158
|
-
var _a, _b, _c, _d
|
|
150
|
+
var _a, _b, _c, _d;
|
|
159
151
|
return __awaiter(this, void 0, void 0, function () {
|
|
160
|
-
var
|
|
152
|
+
var _e, sasjs, authConfig, contextName, log, buildDestinationResultsFolder, createdFilePath;
|
|
161
153
|
var _this = this;
|
|
162
154
|
return __generator(this, function (_f) {
|
|
163
155
|
switch (_f.label) {
|
|
164
156
|
case 0:
|
|
165
157
|
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Sending ".concat(path_1.default.basename(filePath), " to SAS server for execution."));
|
|
166
|
-
|
|
167
|
-
serverUrl: target.serverUrl,
|
|
168
|
-
httpsAgentOptions: target.httpsAgentOptions,
|
|
169
|
-
appLoc: target.appLoc,
|
|
170
|
-
serverType: target.serverType,
|
|
171
|
-
debug: true,
|
|
172
|
-
useComputeApi: true
|
|
173
|
-
});
|
|
174
|
-
contextName = target.contextName;
|
|
175
|
-
if (!contextName) {
|
|
176
|
-
contextName = sasjs.getSasjsConfig().contextName;
|
|
177
|
-
}
|
|
178
|
-
return [4 /*yield*/, (0, config_1.getAuthConfig)(target)];
|
|
158
|
+
return [4 /*yield*/, (0, config_1.getSASjsAndAuthConfig)(target)];
|
|
179
159
|
case 1:
|
|
180
|
-
|
|
160
|
+
_e = _f.sent(), sasjs = _e.sasjs, authConfig = _e.authConfig;
|
|
161
|
+
contextName = target.contextName || sasjs.getSasjsConfig().contextName;
|
|
181
162
|
return [4 /*yield*/, sasjs
|
|
182
|
-
.
|
|
163
|
+
.executeScript({
|
|
164
|
+
fileName: path_1.default.basename(filePath),
|
|
165
|
+
linesOfCode: linesToExecute,
|
|
166
|
+
contextName: contextName,
|
|
167
|
+
authConfig: authConfig
|
|
168
|
+
})
|
|
183
169
|
.catch(function (err) { return __awaiter(_this, void 0, void 0, function () {
|
|
184
170
|
var log;
|
|
185
171
|
return __generator(this, function (_a) {
|
|
@@ -187,35 +173,23 @@ function executeOnSasViya(filePath, target, linesToExecute, logFile) {
|
|
|
187
173
|
case 0:
|
|
188
174
|
log = err.log;
|
|
189
175
|
if (!log)
|
|
190
|
-
throw new
|
|
176
|
+
throw new node_1.ErrorResponse('We were not able to fetch the log this time.');
|
|
191
177
|
return [4 /*yield*/, createOutputFile(log, logFile)];
|
|
192
178
|
case 1:
|
|
193
179
|
_a.sent();
|
|
194
|
-
throw new
|
|
180
|
+
throw new node_1.ErrorResponse('Find more error details in the log file.');
|
|
195
181
|
}
|
|
196
182
|
});
|
|
197
183
|
}); })];
|
|
198
184
|
case 2:
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
try {
|
|
202
|
-
log = executionResult.log.items
|
|
203
|
-
? executionResult.log.items.map(function (i) { return i.line; })
|
|
204
|
-
: executionResult.log;
|
|
205
|
-
}
|
|
206
|
-
catch (e) {
|
|
207
|
-
(0, utils_2.displayError)(e, 'An error occurred when parsing the execution log');
|
|
208
|
-
(_b = process.logger) === null || _b === void 0 ? void 0 : _b.info('The execution output will be saved to the log file.');
|
|
209
|
-
log = JSON.stringify(executionResult);
|
|
210
|
-
isOutput = true;
|
|
211
|
-
}
|
|
212
|
-
(_c = process.logger) === null || _c === void 0 ? void 0 : _c.success('Job execution completed!');
|
|
185
|
+
log = (_f.sent()).log;
|
|
186
|
+
(_b = process.logger) === null || _b === void 0 ? void 0 : _b.success('Job execution completed!');
|
|
213
187
|
buildDestinationResultsFolder = process.sasjsConstants.buildDestinationResultsFolder;
|
|
214
|
-
(
|
|
215
|
-
return [4 /*yield*/, createOutputFile(log,
|
|
188
|
+
(_c = process.logger) === null || _c === void 0 ? void 0 : _c.info("Creating log file in ".concat(buildDestinationResultsFolder, " ."));
|
|
189
|
+
return [4 /*yield*/, createOutputFile(log, logFile)];
|
|
216
190
|
case 3:
|
|
217
191
|
createdFilePath = _f.sent();
|
|
218
|
-
(
|
|
192
|
+
(_d = process.logger) === null || _d === void 0 ? void 0 : _d.success("Log file has been created at ".concat(createdFilePath, " ."));
|
|
219
193
|
return [2 /*return*/, { log: log }];
|
|
220
194
|
}
|
|
221
195
|
});
|
|
@@ -224,33 +198,20 @@ function executeOnSasViya(filePath, target, linesToExecute, logFile) {
|
|
|
224
198
|
function executeOnSas9(target, linesToExecute, logFile) {
|
|
225
199
|
var _a;
|
|
226
200
|
return __awaiter(this, void 0, void 0, function () {
|
|
227
|
-
var
|
|
201
|
+
var _b, sasjs, authConfigSas9, userName, password, executionResult;
|
|
228
202
|
var _this = this;
|
|
229
|
-
return __generator(this, function (
|
|
230
|
-
switch (
|
|
231
|
-
case 0:
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
else {
|
|
237
|
-
username = process.env.SAS_USERNAME;
|
|
238
|
-
password = process.env.SAS_PASSWORD;
|
|
239
|
-
}
|
|
240
|
-
if (!username || !password) {
|
|
241
|
-
sas9CredentialsError = process.sasjsConstants.sas9CredentialsError;
|
|
242
|
-
throw new Error(sas9CredentialsError);
|
|
243
|
-
}
|
|
244
|
-
password = (0, utils_1.decodeFromBase64)(password);
|
|
245
|
-
sasjs = new node_1.default({
|
|
246
|
-
serverUrl: target.serverUrl,
|
|
247
|
-
httpsAgentOptions: target.httpsAgentOptions,
|
|
248
|
-
appLoc: target.appLoc,
|
|
249
|
-
serverType: target.serverType,
|
|
250
|
-
debug: true
|
|
251
|
-
});
|
|
203
|
+
return __generator(this, function (_c) {
|
|
204
|
+
switch (_c.label) {
|
|
205
|
+
case 0: return [4 /*yield*/, (0, config_1.getSASjsAndAuthConfig)(target)];
|
|
206
|
+
case 1:
|
|
207
|
+
_b = _c.sent(), sasjs = _b.sasjs, authConfigSas9 = _b.authConfigSas9;
|
|
208
|
+
userName = authConfigSas9.userName;
|
|
209
|
+
password = (0, utils_1.decodeFromBase64)(authConfigSas9.password);
|
|
252
210
|
return [4 /*yield*/, sasjs
|
|
253
|
-
.
|
|
211
|
+
.executeScript({
|
|
212
|
+
linesOfCode: linesToExecute,
|
|
213
|
+
authConfigSas9: { userName: userName, password: password }
|
|
214
|
+
})
|
|
254
215
|
.catch(function (err) { return __awaiter(_this, void 0, void 0, function () {
|
|
255
216
|
var log;
|
|
256
217
|
return __generator(this, function (_a) {
|
|
@@ -261,21 +222,21 @@ function executeOnSas9(target, linesToExecute, logFile) {
|
|
|
261
222
|
return [4 /*yield*/, createOutputFile(log, logFile)];
|
|
262
223
|
case 1:
|
|
263
224
|
_a.sent();
|
|
264
|
-
throw new
|
|
225
|
+
throw new node_1.ErrorResponse('Find more error details in the log file.');
|
|
265
226
|
case 2:
|
|
266
227
|
if (err && err.errorCode === 404) {
|
|
267
|
-
(0, utils_2.displaySasjsRunnerError)(
|
|
228
|
+
(0, utils_2.displaySasjsRunnerError)(userName);
|
|
268
229
|
}
|
|
269
230
|
throw err;
|
|
270
231
|
}
|
|
271
232
|
});
|
|
272
233
|
}); })];
|
|
273
|
-
case
|
|
274
|
-
executionResult =
|
|
234
|
+
case 2:
|
|
235
|
+
executionResult = _c.sent();
|
|
275
236
|
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.success('Job execution completed!');
|
|
276
237
|
return [4 /*yield*/, createOutputFile(executionResult || '', logFile)];
|
|
277
|
-
case
|
|
278
|
-
|
|
238
|
+
case 3:
|
|
239
|
+
_c.sent();
|
|
279
240
|
return [2 /*return*/, { log: executionResult }];
|
|
280
241
|
}
|
|
281
242
|
});
|
|
@@ -284,32 +245,34 @@ function executeOnSas9(target, linesToExecute, logFile) {
|
|
|
284
245
|
function executeOnSasJS(filePath, target, linesToExecute, logFile) {
|
|
285
246
|
var _a;
|
|
286
247
|
return __awaiter(this, void 0, void 0, function () {
|
|
287
|
-
var authConfig, sasjs, fileExtension, executionResult;
|
|
288
|
-
return __generator(this, function (
|
|
289
|
-
switch (
|
|
248
|
+
var authConfig, _b, sasjs, fileExtension, executionResult;
|
|
249
|
+
return __generator(this, function (_c) {
|
|
250
|
+
switch (_c.label) {
|
|
290
251
|
case 0: return [4 /*yield*/, (0, utils_2.isSasJsServerInServerMode)(target)];
|
|
291
252
|
case 1:
|
|
292
|
-
if (!
|
|
253
|
+
if (!(_c.sent())) return [3 /*break*/, 3];
|
|
293
254
|
return [4 /*yield*/, (0, config_1.getAuthConfig)(target)];
|
|
294
255
|
case 2:
|
|
295
|
-
|
|
296
|
-
|
|
256
|
+
_b = _c.sent();
|
|
257
|
+
return [3 /*break*/, 4];
|
|
297
258
|
case 3:
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
httpsAgentOptions: target.httpsAgentOptions,
|
|
301
|
-
appLoc: target.appLoc,
|
|
302
|
-
serverType: target.serverType,
|
|
303
|
-
debug: true
|
|
304
|
-
});
|
|
305
|
-
fileExtension = path_1.default.extname(filePath).slice(1);
|
|
306
|
-
return [4 /*yield*/, sasjs.executeScriptSASjs(linesToExecute.join('\n'), fileExtension, authConfig)];
|
|
259
|
+
_b = undefined;
|
|
260
|
+
_c.label = 4;
|
|
307
261
|
case 4:
|
|
308
|
-
|
|
262
|
+
authConfig = _b;
|
|
263
|
+
sasjs = (0, config_1.getSASjs)(target);
|
|
264
|
+
fileExtension = path_1.default.extname(filePath).slice(1);
|
|
265
|
+
return [4 /*yield*/, sasjs.executeScript({
|
|
266
|
+
linesOfCode: linesToExecute,
|
|
267
|
+
runTime: fileExtension,
|
|
268
|
+
authConfig: authConfig
|
|
269
|
+
})];
|
|
270
|
+
case 5:
|
|
271
|
+
executionResult = _c.sent();
|
|
309
272
|
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.success('Job execution completed!');
|
|
310
273
|
return [4 /*yield*/, createOutputFile(executionResult || '', logFile)];
|
|
311
|
-
case
|
|
312
|
-
|
|
274
|
+
case 6:
|
|
275
|
+
_c.sent();
|
|
313
276
|
return [2 /*return*/, { log: executionResult }];
|
|
314
277
|
}
|
|
315
278
|
});
|
|
@@ -23,6 +23,7 @@ var helpCommand_1 = require("../../commands/help/helpCommand");
|
|
|
23
23
|
var jobCommand_1 = require("../../commands/job/jobCommand");
|
|
24
24
|
var lintCommand_1 = require("../../commands/lint/lintCommand");
|
|
25
25
|
var flowCommand_1 = require("../../commands/flow/flowCommand");
|
|
26
|
+
var fsCommand_1 = require("../../commands/fs/fsCommand");
|
|
26
27
|
exports.commandFactory = new Map([
|
|
27
28
|
['add', function (args) { return new addCommand_1.AddCommand(args); }],
|
|
28
29
|
['build', function (args) { return new buildCommand_1.BuildCommand(args); }],
|
|
@@ -38,6 +39,7 @@ exports.commandFactory = new Map([
|
|
|
38
39
|
['deploy', function (args) { return new deployCommand_1.DeployCommand(args); }],
|
|
39
40
|
['doc', function (args) { return new docsCommand_1.DocsCommand(args); }],
|
|
40
41
|
['folder', function (args) { return new folderCommand_1.FolderCommand(args); }],
|
|
42
|
+
['fs', function (args) { return new fsCommand_1.FSCommand(args); }],
|
|
41
43
|
['help', function (args) { return new helpCommand_1.HelpCommand(args); }],
|
|
42
44
|
['init', function (args) { return new initCommand_1.InitCommand(args); }],
|
|
43
45
|
['job', function (args) { return new jobCommand_1.JobCommand(args); }],
|
package/build/utils/config.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import SASjs from '@sasjs/adapter/node';
|
|
2
|
+
import { Configuration, Target, AuthConfig, StreamConfig, AuthConfigSas9 } from '@sasjs/utils';
|
|
2
3
|
import { TargetScope } from '../types/targetScope';
|
|
3
4
|
/**
|
|
4
5
|
* Returns an object that represents the SASjs CLI configuration in a given file.
|
|
@@ -64,6 +65,12 @@ export declare function getProjectRoot(): Promise<string>;
|
|
|
64
65
|
* @returns {AuthConfig} - an object containing an access token, refresh token, client ID and secret.
|
|
65
66
|
*/
|
|
66
67
|
export declare function getAuthConfig(target: Target): Promise<AuthConfig>;
|
|
68
|
+
/**
|
|
69
|
+
* Gets the auth config for the specified SAS9 target.
|
|
70
|
+
* @param {Target} target - the target to get an access token for.
|
|
71
|
+
* @returns {AuthConfigSas9} - an object containing an userName and password.
|
|
72
|
+
*/
|
|
73
|
+
export declare function getAuthConfigSAS9(target: Target): AuthConfigSas9;
|
|
67
74
|
/**
|
|
68
75
|
* Gets an access token for the specified target.
|
|
69
76
|
* If the target is from the global `.sasjsrc` file,
|
|
@@ -87,3 +94,23 @@ export declare function getAccessToken(target: Target, checkIfExpiring?: boolean
|
|
|
87
94
|
export declare const overrideEnvVariables: (targetName: string) => Promise<void>;
|
|
88
95
|
export declare const getTestSetUp: (target: Target) => Promise<string | undefined>;
|
|
89
96
|
export declare const getTestTearDown: (target: Target) => Promise<string | undefined>;
|
|
97
|
+
/**
|
|
98
|
+
* Returns configuration object of SAS Adapter and authentication configuration
|
|
99
|
+
* @param {Target} target - the target to get auth configuration from.
|
|
100
|
+
*/
|
|
101
|
+
export declare function getSASjs(target: Target): SASjs;
|
|
102
|
+
/**
|
|
103
|
+
* Returns configuration object of SAS Adapter and authentication configuration
|
|
104
|
+
* @param {Target} target - the target to get auth configuration from.
|
|
105
|
+
* @returns an object containing a SAS Adapter configuration object `sasjs`
|
|
106
|
+
* and auth configuration `authConfig` or `authConfigSas9`.
|
|
107
|
+
*/
|
|
108
|
+
export declare function getSASjsAndAuthConfig(target: Target): Promise<{
|
|
109
|
+
sasjs: SASjs;
|
|
110
|
+
authConfigSas9: AuthConfigSas9;
|
|
111
|
+
authConfig?: undefined;
|
|
112
|
+
} | {
|
|
113
|
+
sasjs: SASjs;
|
|
114
|
+
authConfig: AuthConfig;
|
|
115
|
+
authConfigSas9?: undefined;
|
|
116
|
+
}>;
|
package/build/utils/config.js
CHANGED
|
@@ -75,7 +75,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
75
75
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
76
76
|
};
|
|
77
77
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
78
|
-
exports.getTestTearDown = exports.getTestSetUp = exports.overrideEnvVariables = exports.getAccessToken = exports.getAuthConfig = exports.getProjectRoot = exports.sanitizeAppLoc = exports.getStreamConfig = exports.getMacroFolders = exports.getBinaryFolders = exports.getProgramFolders = exports.getFolders = exports.saveToLocalConfig = exports.saveLocalConfigFile = exports.getLocalOrGlobalConfig = exports.getLocalConfig = exports.removeFromLocalConfig = exports.removeFromGlobalConfig = exports.saveToGlobalConfig = exports.saveGlobalRcFile = exports.getLocalRcFile = exports.getGlobalRcFile = exports.findTargetInConfiguration = exports.getConfiguration = void 0;
|
|
78
|
+
exports.getSASjsAndAuthConfig = exports.getSASjs = exports.getTestTearDown = exports.getTestSetUp = exports.overrideEnvVariables = exports.getAccessToken = exports.getAuthConfigSAS9 = exports.getAuthConfig = exports.getProjectRoot = exports.sanitizeAppLoc = exports.getStreamConfig = exports.getMacroFolders = exports.getBinaryFolders = exports.getProgramFolders = exports.getFolders = exports.saveToLocalConfig = exports.saveLocalConfigFile = exports.getLocalOrGlobalConfig = exports.getLocalConfig = exports.removeFromLocalConfig = exports.removeFromGlobalConfig = exports.saveToGlobalConfig = exports.saveGlobalRcFile = exports.getLocalRcFile = exports.getGlobalRcFile = exports.findTargetInConfiguration = exports.getConfiguration = void 0;
|
|
79
79
|
var node_1 = __importDefault(require("@sasjs/adapter/node"));
|
|
80
80
|
var utils_1 = require("@sasjs/utils");
|
|
81
81
|
var auth_1 = require("./auth");
|
|
@@ -870,6 +870,31 @@ function getAuthConfig(target) {
|
|
|
870
870
|
});
|
|
871
871
|
}
|
|
872
872
|
exports.getAuthConfig = getAuthConfig;
|
|
873
|
+
/**
|
|
874
|
+
* Gets the auth config for the specified SAS9 target.
|
|
875
|
+
* @param {Target} target - the target to get an access token for.
|
|
876
|
+
* @returns {AuthConfigSas9} - an object containing an userName and password.
|
|
877
|
+
*/
|
|
878
|
+
function getAuthConfigSAS9(target) {
|
|
879
|
+
var _a = target.authConfigSas9
|
|
880
|
+
? {
|
|
881
|
+
userName: target.authConfigSas9.userName,
|
|
882
|
+
password: target.authConfigSas9.password
|
|
883
|
+
}
|
|
884
|
+
: {
|
|
885
|
+
userName: process.env.SAS_USERNAME,
|
|
886
|
+
password: process.env.SAS_PASSWORD
|
|
887
|
+
}, userName = _a.userName, password = _a.password;
|
|
888
|
+
if (!userName || !password) {
|
|
889
|
+
var sas9CredentialsError = process.sasjsConstants.sas9CredentialsError;
|
|
890
|
+
throw new Error(sas9CredentialsError);
|
|
891
|
+
}
|
|
892
|
+
return {
|
|
893
|
+
userName: userName,
|
|
894
|
+
password: password
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
exports.getAuthConfigSAS9 = getAuthConfigSAS9;
|
|
873
898
|
/**
|
|
874
899
|
* Gets an access token for the specified target.
|
|
875
900
|
* If the target is from the global `.sasjsrc` file,
|
|
@@ -1068,3 +1093,48 @@ var getTestTearDown = function (target) { return __awaiter(void 0, void 0, void
|
|
|
1068
1093
|
});
|
|
1069
1094
|
}); };
|
|
1070
1095
|
exports.getTestTearDown = getTestTearDown;
|
|
1096
|
+
/**
|
|
1097
|
+
* Returns configuration object of SAS Adapter and authentication configuration
|
|
1098
|
+
* @param {Target} target - the target to get auth configuration from.
|
|
1099
|
+
*/
|
|
1100
|
+
function getSASjs(target) {
|
|
1101
|
+
return new node_1.default({
|
|
1102
|
+
serverUrl: target.serverUrl,
|
|
1103
|
+
appLoc: target.appLoc,
|
|
1104
|
+
serverType: target.serverType,
|
|
1105
|
+
httpsAgentOptions: target.httpsAgentOptions,
|
|
1106
|
+
debug: true,
|
|
1107
|
+
useComputeApi: target.serverType === utils_1.ServerType.SasViya
|
|
1108
|
+
});
|
|
1109
|
+
}
|
|
1110
|
+
exports.getSASjs = getSASjs;
|
|
1111
|
+
/**
|
|
1112
|
+
* Returns configuration object of SAS Adapter and authentication configuration
|
|
1113
|
+
* @param {Target} target - the target to get auth configuration from.
|
|
1114
|
+
* @returns an object containing a SAS Adapter configuration object `sasjs`
|
|
1115
|
+
* and auth configuration `authConfig` or `authConfigSas9`.
|
|
1116
|
+
*/
|
|
1117
|
+
function getSASjsAndAuthConfig(target) {
|
|
1118
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1119
|
+
var sasjs;
|
|
1120
|
+
var _a;
|
|
1121
|
+
return __generator(this, function (_b) {
|
|
1122
|
+
switch (_b.label) {
|
|
1123
|
+
case 0:
|
|
1124
|
+
sasjs = getSASjs(target);
|
|
1125
|
+
if (target.serverType === utils_1.ServerType.Sas9)
|
|
1126
|
+
return [2 /*return*/, {
|
|
1127
|
+
sasjs: sasjs,
|
|
1128
|
+
authConfigSas9: getAuthConfigSAS9(target)
|
|
1129
|
+
}];
|
|
1130
|
+
_a = {
|
|
1131
|
+
sasjs: sasjs
|
|
1132
|
+
};
|
|
1133
|
+
return [4 /*yield*/, getAuthConfig(target)];
|
|
1134
|
+
case 1: return [2 /*return*/, (_a.authConfig = _b.sent(),
|
|
1135
|
+
_a)];
|
|
1136
|
+
}
|
|
1137
|
+
});
|
|
1138
|
+
});
|
|
1139
|
+
}
|
|
1140
|
+
exports.getSASjsAndAuthConfig = getSASjsAndAuthConfig;
|
package/build/utils/index.d.ts
CHANGED
package/build/utils/index.js
CHANGED
|
@@ -15,6 +15,7 @@ __exportStar(require("./config"), exports);
|
|
|
15
15
|
__exportStar(require("./displayResult"), exports);
|
|
16
16
|
__exportStar(require("./file"), exports);
|
|
17
17
|
__exportStar(require("./loadEnvVariables"), exports);
|
|
18
|
+
__exportStar(require("./saveLog"), exports);
|
|
18
19
|
__exportStar(require("./setConstants"), exports);
|
|
19
20
|
__exportStar(require("./setProjectDir"), exports);
|
|
20
21
|
__exportStar(require("./utils"), exports);
|
package/package.json
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"nodeVersionMessage": "echo \u001b[33m make sure you are running node lts version \u001b[0m",
|
|
10
10
|
"checkNodeVersion": "node -e \"console.log('\u001b[36m', 'Checking your Node.js version...'); if (!process.versions || !process.versions.node) { console.log('\u001b[31m', 'Error determining Node.js version. Exiting...') } if (parseInt(process.versions.node) < 14) { console.log('\u001b[31m', '❌ You must be running at least Node.js 14 to install SASjs CLI.\\nYour current version is ' + process.versions.node + '.\\nPlease install a more recent version and try again.'); process.exit(1); } else { console.log('\u001b[32m', '✅ Node.js version check passed. Continuing...'); } console.log('\u001b[0m', '');\"",
|
|
11
|
+
"start:ci": "npm run build && npm run set:permissions",
|
|
11
12
|
"start": "nodemon --watch \"src/**/*\" --exec \"npm run build && npm run set:permissions\"",
|
|
12
13
|
"set:permissions": "node -e \"require('fs').chmodSync('build/index.js', '755')\"",
|
|
13
14
|
"build": "rimraf build && tsc -p . && npm run copy:files",
|
|
@@ -21,7 +22,7 @@
|
|
|
21
22
|
"preinstall": "npm run nodeVersionMessage",
|
|
22
23
|
"prepare": "git rev-parse --git-dir && git config core.hooksPath ./.git-hooks || true"
|
|
23
24
|
},
|
|
24
|
-
"testServerTypes": "
|
|
25
|
+
"testServerTypes": "sasjs,sas9",
|
|
25
26
|
"release": {
|
|
26
27
|
"branches": [
|
|
27
28
|
"main"
|
|
@@ -49,10 +50,10 @@
|
|
|
49
50
|
"access": "public"
|
|
50
51
|
},
|
|
51
52
|
"dependencies": {
|
|
52
|
-
"@sasjs/adapter": "
|
|
53
|
-
"@sasjs/core": "4.
|
|
54
|
-
"@sasjs/lint": "1.
|
|
55
|
-
"@sasjs/utils": "2.
|
|
53
|
+
"@sasjs/adapter": "4.0.1",
|
|
54
|
+
"@sasjs/core": "4.43.1",
|
|
55
|
+
"@sasjs/lint": "1.13.0",
|
|
56
|
+
"@sasjs/utils": "2.49.2",
|
|
56
57
|
"adm-zip": "0.5.9",
|
|
57
58
|
"chalk": "4.1.2",
|
|
58
59
|
"csv-stringify": "5.6.5",
|
|
@@ -78,7 +79,7 @@
|
|
|
78
79
|
"@types/adm-zip": "0.5.0",
|
|
79
80
|
"@types/find": "0.2.1",
|
|
80
81
|
"@types/jest": "27.0.2",
|
|
81
|
-
"@types/jsdom": "16.2.
|
|
82
|
+
"@types/jsdom": "16.2.15",
|
|
82
83
|
"@types/lodash.groupby": "4.6.6",
|
|
83
84
|
"@types/lodash.uniqby": "4.7.6",
|
|
84
85
|
"@types/node": "17.0.8",
|
|
@@ -98,5 +99,5 @@
|
|
|
98
99
|
"typescript": "4.5.4",
|
|
99
100
|
"util": "0.12.4"
|
|
100
101
|
},
|
|
101
|
-
"version": "3.
|
|
102
|
+
"version": "3.20.1"
|
|
102
103
|
}
|