@sasjs/cli 4.7.0 → 4.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/commands/flow/execute.js +7 -3
- package/build/commands/flow/internal/spec/executeFlow.spec.js +2 -2
- package/build/commands/help/help.js +1 -1
- package/build/commands/job/internal/execute/sasjs.d.ts +5 -3
- package/build/commands/job/internal/execute/sasjs.js +23 -37
- package/build/commands/job/internal/execute/viya.d.ts +1 -2
- package/build/commands/job/internal/execute/viya.js +4 -5
- package/build/commands/job/jobCommand.d.ts +3 -0
- package/build/commands/job/jobCommand.js +92 -71
- package/build/commands/job/spec/execute.spec.js +16 -57
- package/build/commands/job/spec/job.spec.server.viya.js +1 -1
- package/build/commands/job/spec/jobCommand.spec.js +75 -5
- package/build/utils/config.d.ts +1 -1
- package/build/utils/config.js +47 -14
- package/package.json +3 -3
|
@@ -73,10 +73,14 @@ function execute(target, sasjs, authConfig, source, logFolder, csvFile, streamLo
|
|
|
73
73
|
_b = (0, internal_1.checkPredecessorDeadlock)(flows), predecessorDeadlock = _b.present, deadlockChain = _b.chain;
|
|
74
74
|
if (predecessorDeadlock)
|
|
75
75
|
return [2 /*return*/, reject('Circular dependency found in flows, cannot proceed\n- ' +
|
|
76
|
-
deadlockChain.join(' -> '))
|
|
76
|
+
deadlockChain.join(' -> '))
|
|
77
|
+
// job state poll options
|
|
78
|
+
// maxPollCount and pollInterval are set to 0 to use default polling options
|
|
79
|
+
// configured in @sasjs/adapter/src/api/viya/pollJobState.ts
|
|
80
|
+
];
|
|
77
81
|
pollOptions = {
|
|
78
|
-
maxPollCount:
|
|
79
|
-
pollInterval:
|
|
82
|
+
maxPollCount: 0,
|
|
83
|
+
pollInterval: 0,
|
|
80
84
|
streamLog: streamLog,
|
|
81
85
|
logFolderPath: logFolderRealPath
|
|
82
86
|
};
|
|
@@ -70,8 +70,8 @@ var saveToCsvModule = __importStar(require("../saveToCsv"));
|
|
|
70
70
|
var normalizeFilePath = __importStar(require("../normalizeFilePath"));
|
|
71
71
|
var csvColumns_1 = __importDefault(require("../csvColumns"));
|
|
72
72
|
var pollOptions = {
|
|
73
|
-
maxPollCount:
|
|
74
|
-
pollInterval:
|
|
73
|
+
maxPollCount: 0,
|
|
74
|
+
pollInterval: 0,
|
|
75
75
|
streamLog: false,
|
|
76
76
|
logFolderPath: 'fake/log/folder/path'
|
|
77
77
|
};
|
|
@@ -274,7 +274,7 @@ function printHelpText() {
|
|
|
274
274
|
"[2spaces]NOTE: Providing output flag (--output or -o) is optional. If present, CLI will immediately print out the response JSON. If value is provided, it will be treated as file path to save the response JSON.",
|
|
275
275
|
"[2spaces]NOTE: Providing log flag (--log or -l) is optional. If present, CLI will fetch and save job log to local file.",
|
|
276
276
|
"[2spaces]NOTE: Providing ignore warnings (--ignoreWarnings or -i) flag is optional. If present, CLI will return status '0', when the job state is warning.",
|
|
277
|
-
"[2spaces]NOTE: Providing verbose (--verbose or -v) flag is optional. If present, CLI will log summary of every HTTP response."
|
|
277
|
+
"[2spaces]NOTE: Providing verbose (--verbose or -v) flag is optional. If present, CLI will log summary of every HTTP response. If set to 'bleached', CLI will log summary of every HTTP response without extra colors."
|
|
278
278
|
]
|
|
279
279
|
},
|
|
280
280
|
{
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { Target } from '@sasjs/utils';
|
|
1
|
+
import { AuthConfig, Target } from '@sasjs/utils';
|
|
2
|
+
import SASjs from '@sasjs/adapter/node';
|
|
2
3
|
/**
|
|
3
4
|
* Triggers existing job for execution on SASJS server.
|
|
5
|
+
* @param {object} sasjs - configuration object of SAS adapter.
|
|
4
6
|
* @param target - SASJS server configuration.
|
|
5
7
|
* @param jobPath - location of the job.
|
|
6
8
|
* @param logFile - flag indicating if CLI should fetch and save log to provided file path. If filepath wasn't provided, {job}.log file will be created in current folder.
|
|
7
9
|
* @param output - flag indicating if CLI should save output to provided file path.
|
|
8
10
|
* @returns - promise that resolves into an object with log and output.
|
|
9
11
|
*/
|
|
10
|
-
export declare function executeJobSasjs(target: Target, jobPath: string, logFile?: string, output?: string): Promise<{
|
|
12
|
+
export declare function executeJobSasjs(sasjs: SASjs, target: Target, jobPath: string, logFile?: string, output?: string, authConfig?: AuthConfig): Promise<{
|
|
11
13
|
result: any;
|
|
12
14
|
log: any;
|
|
13
|
-
}>;
|
|
15
|
+
} | undefined>;
|
|
@@ -37,58 +37,44 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.executeJobSasjs = void 0;
|
|
40
|
-
var
|
|
41
|
-
var utils_1 = require("../../../../utils");
|
|
42
|
-
var utils_2 = require("../utils");
|
|
40
|
+
var utils_1 = require("../utils");
|
|
43
41
|
/**
|
|
44
42
|
* Triggers existing job for execution on SASJS server.
|
|
43
|
+
* @param {object} sasjs - configuration object of SAS adapter.
|
|
45
44
|
* @param target - SASJS server configuration.
|
|
46
45
|
* @param jobPath - location of the job.
|
|
47
46
|
* @param logFile - flag indicating if CLI should fetch and save log to provided file path. If filepath wasn't provided, {job}.log file will be created in current folder.
|
|
48
47
|
* @param output - flag indicating if CLI should save output to provided file path.
|
|
49
48
|
* @returns - promise that resolves into an object with log and output.
|
|
50
49
|
*/
|
|
51
|
-
function executeJobSasjs(target, jobPath, logFile, output) {
|
|
50
|
+
function executeJobSasjs(sasjs, target, jobPath, logFile, output, authConfig) {
|
|
52
51
|
var _a;
|
|
53
52
|
return __awaiter(this, void 0, void 0, function () {
|
|
54
|
-
var
|
|
55
|
-
return __generator(this, function (
|
|
56
|
-
switch (
|
|
57
|
-
case 0: return [4 /*yield*/,
|
|
53
|
+
var response;
|
|
54
|
+
return __generator(this, function (_b) {
|
|
55
|
+
switch (_b.label) {
|
|
56
|
+
case 0: return [4 /*yield*/, sasjs.executeJob({
|
|
57
|
+
_program: jobPath
|
|
58
|
+
}, target.appLoc, authConfig)];
|
|
58
59
|
case 1:
|
|
59
|
-
|
|
60
|
-
return [
|
|
61
|
-
case 2:
|
|
62
|
-
_b = _c.sent();
|
|
63
|
-
return [3 /*break*/, 4];
|
|
64
|
-
case 3:
|
|
65
|
-
_b = undefined;
|
|
66
|
-
_c.label = 4;
|
|
67
|
-
case 4:
|
|
68
|
-
authConfig = _b;
|
|
69
|
-
sasjsApiClient = new node_1.SASjsApiClient(new node_1.SasjsRequestClient(target.serverUrl, target.httpsAgentOptions));
|
|
70
|
-
return [4 /*yield*/, sasjsApiClient.executeJob({
|
|
71
|
-
_program: jobPath
|
|
72
|
-
}, target.appLoc, authConfig)];
|
|
73
|
-
case 5:
|
|
74
|
-
response = _c.sent();
|
|
75
|
-
if (!response) return [3 /*break*/, 9];
|
|
60
|
+
response = _b.sent();
|
|
61
|
+
if (!response) return [3 /*break*/, 5];
|
|
76
62
|
// handle success
|
|
77
63
|
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.success('Job executed successfully!');
|
|
78
|
-
if (!(!!logFile && response.log)) return [3 /*break*/,
|
|
79
|
-
return [4 /*yield*/, (0,
|
|
64
|
+
if (!(!!logFile && response.log)) return [3 /*break*/, 3];
|
|
65
|
+
return [4 /*yield*/, (0, utils_1.saveLog)(response.log, logFile, jobPath)
|
|
80
66
|
// save output if it is present
|
|
81
67
|
];
|
|
82
|
-
case
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
case
|
|
86
|
-
if (!(!!output && response.result)) return [3 /*break*/,
|
|
87
|
-
return [4 /*yield*/, (0,
|
|
88
|
-
case
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
case
|
|
68
|
+
case 2:
|
|
69
|
+
_b.sent();
|
|
70
|
+
_b.label = 3;
|
|
71
|
+
case 3:
|
|
72
|
+
if (!(!!output && response.result)) return [3 /*break*/, 5];
|
|
73
|
+
return [4 /*yield*/, (0, utils_1.saveOutput)(response.result, output)];
|
|
74
|
+
case 4:
|
|
75
|
+
_b.sent();
|
|
76
|
+
_b.label = 5;
|
|
77
|
+
case 5: return [2 /*return*/, response];
|
|
92
78
|
}
|
|
93
79
|
});
|
|
94
80
|
});
|
|
@@ -13,9 +13,8 @@ import { Target, AuthConfig } from '@sasjs/utils';
|
|
|
13
13
|
* @param {boolean} ignoreWarnings - flag indicating if CLI should return status '0', when the job state is warning.
|
|
14
14
|
* @param {string | undefined} source - an optional path to a JSON file containing macro variables.
|
|
15
15
|
* @param {boolean} streamLog - a flag indicating if the logs should be streamed to the supplied log path during job execution. This is useful for getting feedback on long running jobs.
|
|
16
|
-
* @param {boolean} verbose - enables verbose mode that logs summary of every HTTP response.
|
|
17
16
|
*/
|
|
18
|
-
export declare function executeJobViya(sasjs: SASjs, authConfig: AuthConfig, jobPath: string, target: Target, waitForJob: boolean, output: string | boolean, logFile: string | undefined, statusFile: string | undefined, ignoreWarnings: boolean, source: string | undefined, streamLog: boolean
|
|
17
|
+
export declare function executeJobViya(sasjs: SASjs, authConfig: AuthConfig, jobPath: string, target: Target, waitForJob: boolean, output: string | boolean, logFile: string | undefined, statusFile: string | undefined, ignoreWarnings: boolean, source: string | undefined, streamLog: boolean): Promise<any>;
|
|
19
18
|
/**
|
|
20
19
|
* Gets job execution context name.
|
|
21
20
|
* @param target - SAS server configuration.
|
|
@@ -62,9 +62,8 @@ var utils_3 = require("../utils");
|
|
|
62
62
|
* @param {boolean} ignoreWarnings - flag indicating if CLI should return status '0', when the job state is warning.
|
|
63
63
|
* @param {string | undefined} source - an optional path to a JSON file containing macro variables.
|
|
64
64
|
* @param {boolean} streamLog - a flag indicating if the logs should be streamed to the supplied log path during job execution. This is useful for getting feedback on long running jobs.
|
|
65
|
-
* @param {boolean} verbose - enables verbose mode that logs summary of every HTTP response.
|
|
66
65
|
*/
|
|
67
|
-
function executeJobViya(sasjs, authConfig, jobPath, target, waitForJob, output, logFile, statusFile, ignoreWarnings, source, streamLog
|
|
66
|
+
function executeJobViya(sasjs, authConfig, jobPath, target, waitForJob, output, logFile, statusFile, ignoreWarnings, source, streamLog) {
|
|
68
67
|
var _a, _b;
|
|
69
68
|
return __awaiter(this, void 0, void 0, function () {
|
|
70
69
|
var pollOptions, result, startTime, contextName, macroVars, submittedJob, endTime, outputJson, currentDirPath, outputPath, folderPath, parentFolderPath, logObj, logUrl, logCount, logData, error_1;
|
|
@@ -73,8 +72,8 @@ function executeJobViya(sasjs, authConfig, jobPath, target, waitForJob, output,
|
|
|
73
72
|
switch (_c.label) {
|
|
74
73
|
case 0:
|
|
75
74
|
pollOptions = {
|
|
76
|
-
maxPollCount:
|
|
77
|
-
pollInterval:
|
|
75
|
+
maxPollCount: 0,
|
|
76
|
+
pollInterval: 0,
|
|
78
77
|
streamLog: streamLog,
|
|
79
78
|
logFolderPath: logFile
|
|
80
79
|
};
|
|
@@ -106,7 +105,7 @@ function executeJobViya(sasjs, authConfig, jobPath, target, waitForJob, output,
|
|
|
106
105
|
}
|
|
107
106
|
_c.label = 5;
|
|
108
107
|
case 5: return [4 /*yield*/, sasjs
|
|
109
|
-
.startComputeJob(jobPath, null, { contextName: contextName }, authConfig, waitForJob || !!logFile, pollOptions, true, macroVars === null || macroVars === void 0 ? void 0 : macroVars.macroVars
|
|
108
|
+
.startComputeJob(jobPath, null, { contextName: contextName }, authConfig, waitForJob || !!logFile, pollOptions, true, macroVars === null || macroVars === void 0 ? void 0 : macroVars.macroVars)
|
|
110
109
|
.catch(function (err) { return __awaiter(_this, void 0, void 0, function () {
|
|
111
110
|
var logData;
|
|
112
111
|
var _a;
|
|
@@ -3,6 +3,9 @@ import { ReturnCode } from '../../types/command';
|
|
|
3
3
|
import { TargetCommand } from '../../types/command/targetCommand';
|
|
4
4
|
export declare class JobCommand extends TargetCommand {
|
|
5
5
|
private jobSubCommands;
|
|
6
|
+
private verbose;
|
|
7
|
+
private sasjs;
|
|
8
|
+
private authConfig?;
|
|
6
9
|
constructor(args: string[]);
|
|
7
10
|
/**
|
|
8
11
|
* Method responsible for command execution.
|
|
@@ -63,6 +63,7 @@ var utils_2 = require("../../utils");
|
|
|
63
63
|
var getLogFilePath_1 = require("../../utils/getLogFilePath");
|
|
64
64
|
var prefixAppLoc_1 = require("../../utils/prefixAppLoc");
|
|
65
65
|
var execute_1 = require("./internal/execute");
|
|
66
|
+
var node_1 = __importDefault(require("@sasjs/adapter/node"));
|
|
66
67
|
var JobSubCommand;
|
|
67
68
|
(function (JobSubCommand) {
|
|
68
69
|
JobSubCommand["Execute"] = "execute";
|
|
@@ -121,10 +122,10 @@ var executeParseOptions = {
|
|
|
121
122
|
description: 'Flag indicating whether the logs should be streamed to a local file as the job executes.'
|
|
122
123
|
},
|
|
123
124
|
verbose: {
|
|
124
|
-
type: '
|
|
125
|
+
type: 'string',
|
|
125
126
|
alias: 'v',
|
|
126
127
|
default: false,
|
|
127
|
-
description:
|
|
128
|
+
description: "If present, CLI will return status 0, 1 or 2 together with HTTP response summaries. If set to 'bleached', HTTP response summaries will be logged without extra colors."
|
|
128
129
|
}
|
|
129
130
|
};
|
|
130
131
|
var JobCommand = /** @class */ (function (_super) {
|
|
@@ -143,7 +144,10 @@ var JobCommand = /** @class */ (function (_super) {
|
|
|
143
144
|
examples: examples,
|
|
144
145
|
syntax: syntax
|
|
145
146
|
}) || this;
|
|
147
|
+
_this.verbose = false;
|
|
148
|
+
_this.sasjs = new node_1.default();
|
|
146
149
|
_this.jobSubCommands = jobSubCommands;
|
|
150
|
+
_this.verbose = getVerbose(args, _this.parsed.verbose);
|
|
147
151
|
return _this;
|
|
148
152
|
}
|
|
149
153
|
/**
|
|
@@ -153,58 +157,78 @@ var JobCommand = /** @class */ (function (_super) {
|
|
|
153
157
|
JobCommand.prototype.execute = function () {
|
|
154
158
|
var _a;
|
|
155
159
|
return __awaiter(this, void 0, void 0, function () {
|
|
156
|
-
var target,
|
|
160
|
+
var returnStatusOnly, target, sasjsAndAuthConfig, sasjs, authConfig, authConfigSas9, _b, _c, _d, _e;
|
|
157
161
|
return __generator(this, function (_f) {
|
|
158
162
|
switch (_f.label) {
|
|
159
|
-
case 0:
|
|
160
|
-
// returnStatusOnly flag is deprecated and is left to display warning if used
|
|
161
|
-
];
|
|
162
|
-
case 1:
|
|
163
|
-
target = (_f.sent()).target;
|
|
163
|
+
case 0:
|
|
164
164
|
returnStatusOnly = !!this.parsed.returnStatusOnly;
|
|
165
165
|
if (returnStatusOnly) {
|
|
166
166
|
process.logger.warn('--returnStatusOnly (-r) flag is deprecated.');
|
|
167
167
|
}
|
|
168
|
+
return [4 /*yield*/, this.getTargetInfo()];
|
|
169
|
+
case 1:
|
|
170
|
+
target = (_f.sent()).target;
|
|
171
|
+
return [4 /*yield*/, (0, utils_2.getSASjsAndAuthConfig)(target).catch(function (err) {
|
|
172
|
+
var _a;
|
|
173
|
+
// handle getting instance of @sasjs/adapter and auth config failure
|
|
174
|
+
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('Unable to execute job. Error fetching auth config: ', err);
|
|
175
|
+
return {
|
|
176
|
+
sasjs: (0, utils_2.getSASjs)(target),
|
|
177
|
+
authConfig: undefined,
|
|
178
|
+
authConfigSas9: undefined
|
|
179
|
+
};
|
|
180
|
+
})];
|
|
181
|
+
case 2:
|
|
182
|
+
sasjsAndAuthConfig = _f.sent();
|
|
183
|
+
sasjs = sasjsAndAuthConfig.sasjs;
|
|
184
|
+
authConfig = sasjsAndAuthConfig.authConfig;
|
|
185
|
+
authConfigSas9 = sasjsAndAuthConfig.authConfigSas9;
|
|
186
|
+
if (!sasjs || (!authConfig && !authConfigSas9)) {
|
|
187
|
+
return [2 /*return*/, command_1.ReturnCode.InternalError];
|
|
188
|
+
}
|
|
189
|
+
this.sasjs = sasjs;
|
|
190
|
+
this.sasjs.setVerboseMode(this.verbose);
|
|
191
|
+
this.authConfig = authConfig || authConfigSas9;
|
|
168
192
|
_b = target.serverType;
|
|
169
193
|
switch (_b) {
|
|
170
|
-
case utils_1.ServerType.SasViya: return [3 /*break*/,
|
|
171
|
-
case utils_1.ServerType.Sas9: return [3 /*break*/,
|
|
172
|
-
case utils_1.ServerType.Sasjs: return [3 /*break*/,
|
|
194
|
+
case utils_1.ServerType.SasViya: return [3 /*break*/, 3];
|
|
195
|
+
case utils_1.ServerType.Sas9: return [3 /*break*/, 7];
|
|
196
|
+
case utils_1.ServerType.Sasjs: return [3 /*break*/, 11];
|
|
173
197
|
}
|
|
174
|
-
return [3 /*break*/,
|
|
175
|
-
case 2:
|
|
176
|
-
if (!this.jobSubCommands.includes(this.parsed.subCommand)) return [3 /*break*/, 4];
|
|
177
|
-
return [4 /*yield*/, this.executeJobViya(target)];
|
|
198
|
+
return [3 /*break*/, 15];
|
|
178
199
|
case 3:
|
|
179
|
-
|
|
180
|
-
return [
|
|
200
|
+
if (!this.jobSubCommands.includes(this.parsed.subCommand)) return [3 /*break*/, 5];
|
|
201
|
+
return [4 /*yield*/, this.executeJobViya(target)];
|
|
181
202
|
case 4:
|
|
203
|
+
_c = _f.sent();
|
|
204
|
+
return [3 /*break*/, 6];
|
|
205
|
+
case 5:
|
|
182
206
|
_c = command_1.ReturnCode.InvalidCommand;
|
|
183
|
-
_f.label =
|
|
184
|
-
case
|
|
185
|
-
case 6:
|
|
186
|
-
if (!this.jobSubCommands.includes(this.parsed.subCommand)) return [3 /*break*/, 8];
|
|
187
|
-
return [4 /*yield*/, this.executeJobSas9(target)];
|
|
207
|
+
_f.label = 6;
|
|
208
|
+
case 6: return [2 /*return*/, _c];
|
|
188
209
|
case 7:
|
|
189
|
-
|
|
190
|
-
return [
|
|
210
|
+
if (!this.jobSubCommands.includes(this.parsed.subCommand)) return [3 /*break*/, 9];
|
|
211
|
+
return [4 /*yield*/, this.executeJobSas9(target)];
|
|
191
212
|
case 8:
|
|
213
|
+
_d = _f.sent();
|
|
214
|
+
return [3 /*break*/, 10];
|
|
215
|
+
case 9:
|
|
192
216
|
_d = command_1.ReturnCode.InvalidCommand;
|
|
193
|
-
_f.label =
|
|
194
|
-
case
|
|
195
|
-
case
|
|
217
|
+
_f.label = 10;
|
|
218
|
+
case 10: return [2 /*return*/, _d];
|
|
219
|
+
case 11:
|
|
196
220
|
if (typeof this.parsed.jobPath !== 'string')
|
|
197
221
|
return [2 /*return*/, command_1.ReturnCode.InvalidCommand];
|
|
198
|
-
if (!this.jobSubCommands.includes(this.parsed.subCommand)) return [3 /*break*/,
|
|
222
|
+
if (!this.jobSubCommands.includes(this.parsed.subCommand)) return [3 /*break*/, 13];
|
|
199
223
|
return [4 /*yield*/, this.executeJobSasjs(target)];
|
|
200
|
-
case 11:
|
|
201
|
-
_e = _f.sent();
|
|
202
|
-
return [3 /*break*/, 13];
|
|
203
224
|
case 12:
|
|
225
|
+
_e = _f.sent();
|
|
226
|
+
return [3 /*break*/, 14];
|
|
227
|
+
case 13:
|
|
204
228
|
_e = command_1.ReturnCode.InvalidCommand;
|
|
205
|
-
_f.label =
|
|
206
|
-
case
|
|
207
|
-
case
|
|
229
|
+
_f.label = 14;
|
|
230
|
+
case 14: return [2 /*return*/, _e];
|
|
231
|
+
case 15:
|
|
208
232
|
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.error("This command is not supported for specified server type.\nPlease try again with a different server type.");
|
|
209
233
|
return [2 /*return*/, command_1.ReturnCode.InternalError];
|
|
210
234
|
}
|
|
@@ -228,7 +252,7 @@ var JobCommand = /** @class */ (function (_super) {
|
|
|
228
252
|
output = ((_a = this.parsed.output) === null || _a === void 0 ? void 0 : _a.length)
|
|
229
253
|
? this.parsed.output
|
|
230
254
|
: undefined;
|
|
231
|
-
return [4 /*yield*/, (0, execute_1.executeJobSasjs)(target, jobPath, log, output)
|
|
255
|
+
return [4 /*yield*/, (0, execute_1.executeJobSasjs)(this.sasjs, target, jobPath, log, output, this.authConfig)
|
|
232
256
|
.then(function () { return command_1.ReturnCode.Success; })
|
|
233
257
|
.catch(function (err) {
|
|
234
258
|
var _a;
|
|
@@ -251,9 +275,9 @@ var JobCommand = /** @class */ (function (_super) {
|
|
|
251
275
|
JobCommand.prototype.executeJobSas9 = function (target) {
|
|
252
276
|
var _a;
|
|
253
277
|
return __awaiter(this, void 0, void 0, function () {
|
|
254
|
-
var jobPath, log, source, output,
|
|
255
|
-
return __generator(this, function (
|
|
256
|
-
switch (
|
|
278
|
+
var jobPath, log, source, output, userName, password, returnCode;
|
|
279
|
+
return __generator(this, function (_b) {
|
|
280
|
+
switch (_b.label) {
|
|
257
281
|
case 0:
|
|
258
282
|
jobPath = (0, prefixAppLoc_1.prefixAppLoc)(target.appLoc, this.parsed.jobPath);
|
|
259
283
|
log = (0, getLogFilePath_1.getLogFilePath)(this.parsed.log, jobPath);
|
|
@@ -261,19 +285,10 @@ var JobCommand = /** @class */ (function (_super) {
|
|
|
261
285
|
output = ((_a = this.parsed.output) === null || _a === void 0 ? void 0 : _a.length)
|
|
262
286
|
? this.parsed.output
|
|
263
287
|
: undefined;
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
return { sasjs: undefined, authConfigSas9: undefined };
|
|
269
|
-
})];
|
|
270
|
-
case 1:
|
|
271
|
-
_b = _c.sent(), sasjs = _b.sasjs, authConfigSas9 = _b.authConfigSas9;
|
|
272
|
-
if (!authConfigSas9 || !sasjs)
|
|
273
|
-
return [2 /*return*/, command_1.ReturnCode.InternalError];
|
|
274
|
-
userName = authConfigSas9.userName;
|
|
275
|
-
password = (0, utils_1.decodeFromBase64)(authConfigSas9.password);
|
|
276
|
-
return [4 /*yield*/, (0, execute_1.executeJobSas9)(sasjs, { userName: userName, password: password }, jobPath, log, output, source)
|
|
288
|
+
this.authConfig = this.authConfig;
|
|
289
|
+
userName = this.authConfig.userName;
|
|
290
|
+
password = (0, utils_1.decodeFromBase64)(this.authConfig.password);
|
|
291
|
+
return [4 /*yield*/, (0, execute_1.executeJobSas9)(this.sasjs, { userName: userName, password: password }, jobPath, log, output, source)
|
|
277
292
|
.then(function () { return command_1.ReturnCode.Success; })
|
|
278
293
|
.catch(function (err) {
|
|
279
294
|
var _a;
|
|
@@ -281,8 +296,8 @@ var JobCommand = /** @class */ (function (_super) {
|
|
|
281
296
|
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('Error executing job: ', err);
|
|
282
297
|
return command_1.ReturnCode.InternalError;
|
|
283
298
|
})];
|
|
284
|
-
case
|
|
285
|
-
returnCode =
|
|
299
|
+
case 1:
|
|
300
|
+
returnCode = _b.sent();
|
|
286
301
|
return [2 /*return*/, returnCode];
|
|
287
302
|
}
|
|
288
303
|
});
|
|
@@ -296,16 +311,15 @@ var JobCommand = /** @class */ (function (_super) {
|
|
|
296
311
|
JobCommand.prototype.executeJobViya = function (target) {
|
|
297
312
|
var _a, _b;
|
|
298
313
|
return __awaiter(this, void 0, void 0, function () {
|
|
299
|
-
var jobPath, statusFile, log, ignoreWarnings, streamLog,
|
|
300
|
-
return __generator(this, function (
|
|
301
|
-
switch (
|
|
314
|
+
var jobPath, statusFile, log, ignoreWarnings, streamLog, source, wait, output, returnCode;
|
|
315
|
+
return __generator(this, function (_c) {
|
|
316
|
+
switch (_c.label) {
|
|
302
317
|
case 0:
|
|
303
318
|
jobPath = (0, prefixAppLoc_1.prefixAppLoc)(target.appLoc, this.parsed.jobPath);
|
|
304
319
|
statusFile = getStatusFilePath(this.parsed.statusFile);
|
|
305
320
|
log = (0, getLogFilePath_1.getLogFilePath)(this.parsed.log, jobPath);
|
|
306
321
|
ignoreWarnings = !!this.parsed.ignoreWarnings;
|
|
307
322
|
streamLog = !!this.parsed.streamLog;
|
|
308
|
-
verbose = !!this.parsed.verbose;
|
|
309
323
|
source = this.parsed.source;
|
|
310
324
|
wait = this.parsed.wait || !!log;
|
|
311
325
|
output = ((_a = this.parsed.output) === null || _a === void 0 ? void 0 : _a.length)
|
|
@@ -313,19 +327,9 @@ var JobCommand = /** @class */ (function (_super) {
|
|
|
313
327
|
: ((_b = this.parsed.output) === null || _b === void 0 ? void 0 : _b.length) === 0
|
|
314
328
|
? true
|
|
315
329
|
: false;
|
|
316
|
-
if (verbose && !wait)
|
|
330
|
+
if (!!this.verbose && !wait)
|
|
317
331
|
wait = true;
|
|
318
|
-
return [4 /*yield*/, (0,
|
|
319
|
-
var _a;
|
|
320
|
-
// handle getting instance of @sasjs/adapter and auth config failure
|
|
321
|
-
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('Unable to execute job. Error fetching auth config: ', err);
|
|
322
|
-
return { sasjs: undefined, authConfig: undefined };
|
|
323
|
-
})];
|
|
324
|
-
case 1:
|
|
325
|
-
_c = _d.sent(), sasjs = _c.sasjs, authConfig = _c.authConfig;
|
|
326
|
-
if (!authConfig || !sasjs)
|
|
327
|
-
return [2 /*return*/, command_1.ReturnCode.InternalError];
|
|
328
|
-
return [4 /*yield*/, (0, execute_1.executeJobViya)(sasjs, authConfig, jobPath, target, wait, output, log, statusFile, ignoreWarnings, source, streamLog, verbose)
|
|
332
|
+
return [4 /*yield*/, (0, execute_1.executeJobViya)(this.sasjs, this.authConfig, jobPath, target, wait, output, log, statusFile, ignoreWarnings, source, streamLog)
|
|
329
333
|
.then(function () { return command_1.ReturnCode.Success; })
|
|
330
334
|
.catch(function (err) {
|
|
331
335
|
var _a;
|
|
@@ -333,8 +337,8 @@ var JobCommand = /** @class */ (function (_super) {
|
|
|
333
337
|
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('Error executing job: ', err);
|
|
334
338
|
return command_1.ReturnCode.InternalError;
|
|
335
339
|
})];
|
|
336
|
-
case
|
|
337
|
-
returnCode =
|
|
340
|
+
case 1:
|
|
341
|
+
returnCode = _c.sent();
|
|
338
342
|
return [2 /*return*/, returnCode];
|
|
339
343
|
}
|
|
340
344
|
});
|
|
@@ -357,3 +361,20 @@ var getStatusFilePath = function (statusFileArg) {
|
|
|
357
361
|
}
|
|
358
362
|
return undefined;
|
|
359
363
|
};
|
|
364
|
+
/**
|
|
365
|
+
* Determines verbose mode based on command arguments.
|
|
366
|
+
* @param args - command arguments.
|
|
367
|
+
* @param verboseArg - value of the verbose argument.
|
|
368
|
+
* @returns - verbose mode.
|
|
369
|
+
*/
|
|
370
|
+
var getVerbose = function (args, verboseArg) {
|
|
371
|
+
var verboseArgPresent = args.includes('-v') || args.includes('--verbose');
|
|
372
|
+
if (verboseArgPresent) {
|
|
373
|
+
// if verboseArg, use the string as verbose mode(any strings not equal to
|
|
374
|
+
// 'bleached' will be ignored)
|
|
375
|
+
if (typeof verboseArg === 'string')
|
|
376
|
+
return verboseArg;
|
|
377
|
+
return true;
|
|
378
|
+
}
|
|
379
|
+
return false;
|
|
380
|
+
};
|
|
@@ -94,17 +94,17 @@ describe('executeJobViya', function () {
|
|
|
94
94
|
it('should set streamLog to true when the flag is passed in', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
95
95
|
return __generator(this, function (_a) {
|
|
96
96
|
switch (_a.label) {
|
|
97
|
-
case 0: return [4 /*yield*/, (0, execute_1.executeJobViya)(sasjs, mocks_1.mockAuthConfig, 'test/job', target, false, false, testLogsPath, testFilePath, false, undefined, true
|
|
97
|
+
case 0: return [4 /*yield*/, (0, execute_1.executeJobViya)(sasjs, mocks_1.mockAuthConfig, 'test/job', target, false, false, testLogsPath, testFilePath, false, undefined, true)];
|
|
98
98
|
case 1:
|
|
99
99
|
_a.sent();
|
|
100
100
|
expect(sasjs.startComputeJob).toHaveBeenCalledWith('test/job', null, {
|
|
101
101
|
contextName: 'Mock Context'
|
|
102
102
|
}, mocks_1.mockAuthConfig, true, {
|
|
103
|
-
maxPollCount:
|
|
104
|
-
pollInterval:
|
|
103
|
+
maxPollCount: 0,
|
|
104
|
+
pollInterval: 0,
|
|
105
105
|
streamLog: true,
|
|
106
106
|
logFolderPath: testLogsPath
|
|
107
|
-
}, true, undefined
|
|
107
|
+
}, true, undefined);
|
|
108
108
|
return [4 /*yield*/, (0, utils_1.deleteFile)(testFilePath)];
|
|
109
109
|
case 2:
|
|
110
110
|
_a.sent();
|
|
@@ -115,62 +115,17 @@ describe('executeJobViya', function () {
|
|
|
115
115
|
it('should set streamLog to false when the flag is false', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
116
116
|
return __generator(this, function (_a) {
|
|
117
117
|
switch (_a.label) {
|
|
118
|
-
case 0: return [4 /*yield*/, (0, execute_1.executeJobViya)(sasjs, mocks_1.mockAuthConfig, 'test/job', target, false, false, testLogsPath, testFilePath, false, undefined, false
|
|
118
|
+
case 0: return [4 /*yield*/, (0, execute_1.executeJobViya)(sasjs, mocks_1.mockAuthConfig, 'test/job', target, false, false, testLogsPath, testFilePath, false, undefined, false)];
|
|
119
119
|
case 1:
|
|
120
120
|
_a.sent();
|
|
121
121
|
expect(sasjs.startComputeJob).toHaveBeenCalledWith('test/job', null, {
|
|
122
122
|
contextName: 'Mock Context'
|
|
123
123
|
}, mocks_1.mockAuthConfig, true, {
|
|
124
|
-
maxPollCount:
|
|
125
|
-
pollInterval:
|
|
124
|
+
maxPollCount: 0,
|
|
125
|
+
pollInterval: 0,
|
|
126
126
|
streamLog: false,
|
|
127
127
|
logFolderPath: testLogsPath
|
|
128
|
-
}, true, undefined
|
|
129
|
-
return [4 /*yield*/, (0, utils_1.deleteFile)(testFilePath)];
|
|
130
|
-
case 2:
|
|
131
|
-
_a.sent();
|
|
132
|
-
return [2 /*return*/];
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
}); });
|
|
136
|
-
it('should pass verbose as undefined when the flag is false', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
137
|
-
return __generator(this, function (_a) {
|
|
138
|
-
switch (_a.label) {
|
|
139
|
-
case 0: return [4 /*yield*/, (0, execute_1.executeJobViya)(sasjs, mocks_1.mockAuthConfig, 'test/job', target, false, false, testLogsPath, testFilePath, false, undefined, false, false)];
|
|
140
|
-
case 1:
|
|
141
|
-
_a.sent();
|
|
142
|
-
expect(sasjs.startComputeJob).toHaveBeenCalledWith('test/job', null, {
|
|
143
|
-
contextName: 'Mock Context'
|
|
144
|
-
}, mocks_1.mockAuthConfig, true, {
|
|
145
|
-
maxPollCount: 24 * 60 * 60,
|
|
146
|
-
pollInterval: 1000,
|
|
147
|
-
streamLog: false,
|
|
148
|
-
logFolderPath: testLogsPath
|
|
149
|
-
}, true, undefined, undefined);
|
|
150
|
-
return [4 /*yield*/, (0, utils_1.deleteFile)(testFilePath)];
|
|
151
|
-
case 2:
|
|
152
|
-
_a.sent();
|
|
153
|
-
return [2 /*return*/];
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
}); });
|
|
157
|
-
it('should pass verbose as true when the flag is true', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
158
|
-
var verbose;
|
|
159
|
-
return __generator(this, function (_a) {
|
|
160
|
-
switch (_a.label) {
|
|
161
|
-
case 0:
|
|
162
|
-
verbose = true;
|
|
163
|
-
return [4 /*yield*/, (0, execute_1.executeJobViya)(sasjs, mocks_1.mockAuthConfig, 'test/job', target, false, false, testLogsPath, testFilePath, false, undefined, false, verbose)];
|
|
164
|
-
case 1:
|
|
165
|
-
_a.sent();
|
|
166
|
-
expect(sasjs.startComputeJob).toHaveBeenCalledWith('test/job', null, {
|
|
167
|
-
contextName: 'Mock Context'
|
|
168
|
-
}, mocks_1.mockAuthConfig, true, {
|
|
169
|
-
maxPollCount: 24 * 60 * 60,
|
|
170
|
-
pollInterval: 1000,
|
|
171
|
-
streamLog: false,
|
|
172
|
-
logFolderPath: testLogsPath
|
|
173
|
-
}, true, undefined, verbose);
|
|
128
|
+
}, true, undefined);
|
|
174
129
|
return [4 /*yield*/, (0, utils_1.deleteFile)(testFilePath)];
|
|
175
130
|
case 2:
|
|
176
131
|
_a.sent();
|
|
@@ -191,11 +146,15 @@ describe('executeJobSasjs', function () {
|
|
|
191
146
|
});
|
|
192
147
|
}); });
|
|
193
148
|
it('should pass job pass as a _program parameter', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
149
|
+
var _a, sasjs, authConfig;
|
|
150
|
+
return __generator(this, function (_b) {
|
|
151
|
+
switch (_b.label) {
|
|
152
|
+
case 0: return [4 /*yield*/, (0, utils_2.getSASjsAndAuthConfig)(target)];
|
|
197
153
|
case 1:
|
|
198
|
-
_a.sent();
|
|
154
|
+
_a = _b.sent(), sasjs = _a.sasjs, authConfig = _a.authConfig;
|
|
155
|
+
return [4 /*yield*/, (0, execute_1.executeJobSasjs)(sasjs, target, 'test/job', path_1.default.join(process.projectDir, 'logs'), undefined, authConfig)];
|
|
156
|
+
case 2:
|
|
157
|
+
_b.sent();
|
|
199
158
|
expect(executeJobMock).toHaveBeenCalledWith({ _program: 'test/job' }, target.appLoc, undefined);
|
|
200
159
|
return [2 /*return*/];
|
|
201
160
|
}
|
|
@@ -599,7 +599,7 @@ var executeWrapper = function (_a) {
|
|
|
599
599
|
var _b = _a.adapter, adapter = _b === void 0 ? sasjs : _b, jobPath = _a.jobPath, _c = _a.waitForJob, waitForJob = _c === void 0 ? false : _c, _d = _a.output, output = _d === void 0 ? false : _d, _e = _a.logFile, logFile = _e === void 0 ? undefined : _e, _f = _a.statusFile, statusFile = _f === void 0 ? undefined : _f, _g = _a.ignoreWarnings, ignoreWarnings = _g === void 0 ? false : _g, _h = _a.source, source = _h === void 0 ? undefined : _h, _j = _a.streamLog, streamLog = _j === void 0 ? false : _j;
|
|
600
600
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
601
601
|
return __generator(this, function (_k) {
|
|
602
|
-
return [2 /*return*/, (0, execute_1.executeJobViya)(adapter, authConfig, jobPath, target, waitForJob, output, logFile, statusFile, ignoreWarnings, source, streamLog
|
|
602
|
+
return [2 /*return*/, (0, execute_1.executeJobViya)(adapter, authConfig, jobPath, target, waitForJob, output, logFile, statusFile, ignoreWarnings, source, streamLog)];
|
|
603
603
|
});
|
|
604
604
|
});
|
|
605
605
|
};
|
|
@@ -192,8 +192,7 @@ describe('JobCommand', function () {
|
|
|
192
192
|
_b.sent();
|
|
193
193
|
(_a = expect(viyaExecuteModule.executeJobViya)).toHaveBeenCalledWith.apply(_a, __spreadArray([], __read(executeCalledWith({
|
|
194
194
|
jobPath: jobPath,
|
|
195
|
-
waitForJob: true
|
|
196
|
-
verbose: true
|
|
195
|
+
waitForJob: true
|
|
197
196
|
})), false));
|
|
198
197
|
return [2 /*return*/];
|
|
199
198
|
}
|
|
@@ -321,6 +320,78 @@ describe('JobCommand', function () {
|
|
|
321
320
|
}
|
|
322
321
|
});
|
|
323
322
|
}); });
|
|
323
|
+
it('should set verbose to true if verbose flag present', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
324
|
+
var sasjs;
|
|
325
|
+
return __generator(this, function (_a) {
|
|
326
|
+
switch (_a.label) {
|
|
327
|
+
case 0:
|
|
328
|
+
sasjs = new node_1.default();
|
|
329
|
+
jest
|
|
330
|
+
.spyOn(configUtils, 'getSASjsAndAuthConfig')
|
|
331
|
+
.mockImplementation(function (target) {
|
|
332
|
+
sasjs = configUtils.getSASjs(target);
|
|
333
|
+
jest.spyOn(sasjs, 'setVerboseMode');
|
|
334
|
+
return Promise.resolve({
|
|
335
|
+
sasjs: sasjs,
|
|
336
|
+
authConfig: authConfig
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
return [4 /*yield*/, executeCommandWrapper([jobPath, '--verbose'])];
|
|
340
|
+
case 1:
|
|
341
|
+
_a.sent();
|
|
342
|
+
expect(sasjs.setVerboseMode).toHaveBeenCalledWith(true);
|
|
343
|
+
return [2 /*return*/];
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
}); });
|
|
347
|
+
it('should set verbose to bleached if verbose flag present and is equal to bleached', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
348
|
+
var sasjs;
|
|
349
|
+
return __generator(this, function (_a) {
|
|
350
|
+
switch (_a.label) {
|
|
351
|
+
case 0:
|
|
352
|
+
sasjs = new node_1.default();
|
|
353
|
+
jest
|
|
354
|
+
.spyOn(configUtils, 'getSASjsAndAuthConfig')
|
|
355
|
+
.mockImplementation(function (target) {
|
|
356
|
+
sasjs = configUtils.getSASjs(target);
|
|
357
|
+
jest.spyOn(sasjs, 'setVerboseMode');
|
|
358
|
+
return Promise.resolve({
|
|
359
|
+
sasjs: sasjs,
|
|
360
|
+
authConfig: authConfig
|
|
361
|
+
});
|
|
362
|
+
});
|
|
363
|
+
return [4 /*yield*/, executeCommandWrapper([jobPath, '-v', 'bleached'])];
|
|
364
|
+
case 1:
|
|
365
|
+
_a.sent();
|
|
366
|
+
expect(sasjs.setVerboseMode).toHaveBeenCalledWith('bleached');
|
|
367
|
+
return [2 /*return*/];
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
}); });
|
|
371
|
+
it('should set verbose to false if verbose flag is not present', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
372
|
+
var sasjs;
|
|
373
|
+
return __generator(this, function (_a) {
|
|
374
|
+
switch (_a.label) {
|
|
375
|
+
case 0:
|
|
376
|
+
sasjs = new node_1.default();
|
|
377
|
+
jest
|
|
378
|
+
.spyOn(configUtils, 'getSASjsAndAuthConfig')
|
|
379
|
+
.mockImplementation(function (target) {
|
|
380
|
+
sasjs = configUtils.getSASjs(target);
|
|
381
|
+
jest.spyOn(sasjs, 'setVerboseMode');
|
|
382
|
+
return Promise.resolve({
|
|
383
|
+
sasjs: sasjs,
|
|
384
|
+
authConfig: authConfig
|
|
385
|
+
});
|
|
386
|
+
});
|
|
387
|
+
return [4 /*yield*/, executeCommandWrapper([jobPath])];
|
|
388
|
+
case 1:
|
|
389
|
+
_a.sent();
|
|
390
|
+
expect(sasjs.setVerboseMode).toHaveBeenCalledWith(false);
|
|
391
|
+
return [2 /*return*/];
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
}); });
|
|
324
395
|
});
|
|
325
396
|
describe('for server type sas9', function () {
|
|
326
397
|
beforeEach(function () {
|
|
@@ -540,7 +611,7 @@ var setupMocksForSAS9 = function () {
|
|
|
540
611
|
jest.spyOn(process.logger, 'error');
|
|
541
612
|
};
|
|
542
613
|
var executeCalledWith = function (_a) {
|
|
543
|
-
var jobPath = _a.jobPath, _b = _a.waitForJob, waitForJob = _b === void 0 ? false : _b, _c = _a.output, output = _c === void 0 ? false : _c, _d = _a.logFile, logFile = _d === void 0 ? undefined : _d, _e = _a.statusFile, statusFile = _e === void 0 ? undefined : _e, _f = _a.ignoreWarnings, ignoreWarnings = _f === void 0 ? false : _f, _g = _a.source, source = _g === void 0 ? undefined : _g, _h = _a.streamLog, streamLog = _h === void 0 ? false : _h
|
|
614
|
+
var jobPath = _a.jobPath, _b = _a.waitForJob, waitForJob = _b === void 0 ? false : _b, _c = _a.output, output = _c === void 0 ? false : _c, _d = _a.logFile, logFile = _d === void 0 ? undefined : _d, _e = _a.statusFile, statusFile = _e === void 0 ? undefined : _e, _f = _a.ignoreWarnings, ignoreWarnings = _f === void 0 ? false : _f, _g = _a.source, source = _g === void 0 ? undefined : _g, _h = _a.streamLog, streamLog = _h === void 0 ? false : _h;
|
|
544
615
|
return [
|
|
545
616
|
expect.anything(),
|
|
546
617
|
authConfig,
|
|
@@ -552,8 +623,7 @@ var executeCalledWith = function (_a) {
|
|
|
552
623
|
statusFile,
|
|
553
624
|
ignoreWarnings,
|
|
554
625
|
source,
|
|
555
|
-
streamLog
|
|
556
|
-
verbose
|
|
626
|
+
streamLog
|
|
557
627
|
];
|
|
558
628
|
};
|
|
559
629
|
var executeCommandWrapper = function (additionalParams) { return __awaiter(void 0, void 0, void 0, function () {
|
package/build/utils/config.d.ts
CHANGED
package/build/utils/config.js
CHANGED
|
@@ -1150,11 +1150,19 @@ exports.getTestTearDown = getTestTearDown;
|
|
|
1150
1150
|
function getSASjs(target) {
|
|
1151
1151
|
var _a = process.env, VERBOSE = _a.VERBOSE, LOG_LEVEL = _a.LOG_LEVEL;
|
|
1152
1152
|
var verbose = false;
|
|
1153
|
-
// verbose mode should be enabled if VERBOSE environment variable present and
|
|
1153
|
+
// verbose mode should be enabled if VERBOSE environment variable present and
|
|
1154
|
+
// is equal to 'on'(case insensitive)
|
|
1154
1155
|
if (typeof VERBOSE === 'string' && /on/i.test(VERBOSE)) {
|
|
1155
1156
|
verbose = true;
|
|
1156
1157
|
}
|
|
1157
|
-
// verbose mode should be enabled
|
|
1158
|
+
// verbose mode should be enabled in 'bleached' mode(without extra colors)
|
|
1159
|
+
// if VERBOSE environment variable present and is equal to
|
|
1160
|
+
// 'bleached'(case insensitive)
|
|
1161
|
+
if (typeof VERBOSE === 'string' && /bleached/i.test(VERBOSE)) {
|
|
1162
|
+
verbose = 'bleached';
|
|
1163
|
+
}
|
|
1164
|
+
// verbose mode should be enabled if LOG_LEVEL environment variable present
|
|
1165
|
+
// and is equal to 'trace'(case insensitive)
|
|
1158
1166
|
else if (typeof LOG_LEVEL === 'string' && /trace/i.test(LOG_LEVEL)) {
|
|
1159
1167
|
verbose = true;
|
|
1160
1168
|
}
|
|
@@ -1178,23 +1186,48 @@ exports.getSASjs = getSASjs;
|
|
|
1178
1186
|
*/
|
|
1179
1187
|
function getSASjsAndAuthConfig(target) {
|
|
1180
1188
|
return __awaiter(this, void 0, void 0, function () {
|
|
1181
|
-
var sasjs;
|
|
1182
|
-
var
|
|
1183
|
-
return __generator(this, function (
|
|
1184
|
-
switch (
|
|
1189
|
+
var sasjs, _a, _b;
|
|
1190
|
+
var _c, _d;
|
|
1191
|
+
return __generator(this, function (_e) {
|
|
1192
|
+
switch (_e.label) {
|
|
1185
1193
|
case 0:
|
|
1186
1194
|
sasjs = getSASjs(target);
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1195
|
+
_a = target.serverType;
|
|
1196
|
+
switch (_a) {
|
|
1197
|
+
case utils_1.ServerType.SasViya: return [3 /*break*/, 1];
|
|
1198
|
+
case utils_1.ServerType.Sas9: return [3 /*break*/, 3];
|
|
1199
|
+
case utils_1.ServerType.Sasjs: return [3 /*break*/, 4];
|
|
1200
|
+
}
|
|
1201
|
+
return [3 /*break*/, 9];
|
|
1202
|
+
case 1:
|
|
1203
|
+
_c = {
|
|
1204
|
+
sasjs: sasjs
|
|
1205
|
+
};
|
|
1206
|
+
return [4 /*yield*/, getAuthConfig(target)];
|
|
1207
|
+
case 2: return [2 /*return*/, (_c.authConfig = _e.sent(),
|
|
1208
|
+
_c)];
|
|
1209
|
+
case 3: return [2 /*return*/, {
|
|
1210
|
+
sasjs: sasjs,
|
|
1211
|
+
authConfigSas9: getAuthConfigSAS9(target)
|
|
1212
|
+
}];
|
|
1213
|
+
case 4:
|
|
1214
|
+
_d = {
|
|
1193
1215
|
sasjs: sasjs
|
|
1194
1216
|
};
|
|
1217
|
+
return [4 /*yield*/, (0, utils_2.isSasJsServerInServerMode)(target)];
|
|
1218
|
+
case 5:
|
|
1219
|
+
if (!(_e.sent())) return [3 /*break*/, 7];
|
|
1195
1220
|
return [4 /*yield*/, getAuthConfig(target)];
|
|
1196
|
-
case
|
|
1197
|
-
|
|
1221
|
+
case 6:
|
|
1222
|
+
_b = _e.sent();
|
|
1223
|
+
return [3 /*break*/, 8];
|
|
1224
|
+
case 7:
|
|
1225
|
+
_b = undefined; // @sasjs/server doesn't have authentication in desktop mode
|
|
1226
|
+
_e.label = 8;
|
|
1227
|
+
case 8: return [2 /*return*/, (_d.authConfig = _b // @sasjs/server doesn't have authentication in desktop mode
|
|
1228
|
+
,
|
|
1229
|
+
_d)];
|
|
1230
|
+
case 9: return [2 /*return*/];
|
|
1198
1231
|
}
|
|
1199
1232
|
});
|
|
1200
1233
|
});
|
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"lint": "npx prettier --check \"{src,test}/**/*.{ts,tsx,js,jsx,html,css,sass,less,yml,md,graphql}\"",
|
|
22
22
|
"preinstall": "npm run nodeVersionMessage",
|
|
23
23
|
"prepare": "git rev-parse --git-dir && git config core.hooksPath ./.git-hooks || true",
|
|
24
|
-
"doc": "npx compodoc -p tsconfig.doc.json --coverageTest
|
|
24
|
+
"doc": "npx compodoc -p tsconfig.doc.json --coverageTest 16 --coverageTestThresholdFail"
|
|
25
25
|
},
|
|
26
26
|
"testServerTypes": "sasjs",
|
|
27
27
|
"release": {
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@sasjs/adapter": "4.
|
|
54
|
+
"@sasjs/adapter": "4.9.0",
|
|
55
55
|
"@sasjs/core": "4.46.3",
|
|
56
56
|
"@sasjs/lint": "2.3.1",
|
|
57
57
|
"@sasjs/utils": "3.4.0",
|
|
@@ -104,5 +104,5 @@
|
|
|
104
104
|
"typescript": "4.9.5",
|
|
105
105
|
"util": "0.12.4"
|
|
106
106
|
},
|
|
107
|
-
"version": "4.
|
|
107
|
+
"version": "4.8.0"
|
|
108
108
|
}
|