@sasjs/cli 3.6.2 → 3.6.3
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/cli.js +4 -4
- package/build/cli.spec.js +6 -6
- package/build/commands/add/addCommand.js +2 -2
- package/build/commands/add/addCredential.js +27 -27
- package/build/commands/add/addTarget.js +10 -10
- package/build/commands/add/internal/input.js +30 -30
- package/build/commands/add/internal/saveConfig.js +2 -2
- package/build/commands/add/spec/addCommand.spec.js +24 -20
- package/build/commands/add/spec/addCredential.spec.js +14 -14
- package/build/commands/add/spec/addTarget.spec.js +22 -22
- package/build/commands/build/build.js +81 -77
- package/build/commands/build/buildCommand.js +3 -3
- package/build/commands/build/compileBuildCommand.js +4 -4
- package/build/commands/build/internal/config.js +8 -8
- package/build/commands/build/internal/getLaunchPageCode.js +2 -2
- package/build/commands/build/spec/build.spec.js +10 -10
- package/build/commands/build/spec/buildCommand.spec.js +16 -12
- package/build/commands/build/spec/cb.spec.server.js +18 -18
- package/build/commands/build/spec/compileBuildCommand.spec.js +17 -13
- package/build/commands/compile/compile.js +61 -61
- package/build/commands/compile/compileCommand.js +10 -10
- package/build/commands/compile/compileSingleFile.js +17 -17
- package/build/commands/compile/internal/checkCompileStatus.js +11 -11
- package/build/commands/compile/internal/compareFolders.js +11 -11
- package/build/commands/compile/internal/compileJobFile.js +3 -3
- package/build/commands/compile/internal/compileServiceFile.js +14 -14
- package/build/commands/compile/internal/compileTestFile.js +41 -37
- package/build/commands/compile/internal/getAllJobFolders.js +13 -9
- package/build/commands/compile/internal/getAllServiceFolders.js +13 -9
- package/build/commands/compile/internal/getServerType.js +1 -1
- package/build/commands/compile/internal/identifySasFile.js +2 -2
- package/build/commands/compile/internal/loadDependencies.js +5 -5
- package/build/commands/compile/internal/spec/compileTestFile.spec.js +40 -40
- package/build/commands/compile/spec/compareFolders.spec.js +27 -27
- package/build/commands/compile/spec/compile.spec.js +93 -93
- package/build/commands/compile/spec/compileCommand.spec.js +37 -33
- package/build/commands/compile/spec/compileJobFile.spec.js +11 -11
- package/build/commands/compile/spec/compileServiceFile.spec.js +11 -11
- package/build/commands/compile/spec/copyFilesToBuildFolder.spec.js +7 -7
- package/build/commands/compile/spec/loadDependencies.spec.js +30 -30
- package/build/commands/context/contextCommand.js +16 -16
- package/build/commands/context/create.js +1 -1
- package/build/commands/context/delete.js +2 -2
- package/build/commands/context/edit.js +1 -1
- package/build/commands/context/export.js +5 -5
- package/build/commands/context/internal/validateConfigPath.js +1 -1
- package/build/commands/context/list.js +4 -4
- package/build/commands/context/spec/contextCommand.spec.js +80 -76
- package/build/commands/context/spec/create.spec.js +3 -3
- package/build/commands/context/spec/delete.spec.js +3 -3
- package/build/commands/context/spec/edit.spec.js +3 -3
- package/build/commands/context/spec/export.spec.js +8 -8
- package/build/commands/context/spec/list.spec.js +5 -5
- package/build/commands/create/create.js +12 -12
- package/build/commands/create/createCommand.js +2 -2
- package/build/commands/create/internal/createReadme.js +2 -2
- package/build/commands/create/spec/create.spec.js +39 -39
- package/build/commands/create/spec/createCommand.spec.js +14 -10
- package/build/commands/db/db.js +22 -22
- package/build/commands/db/dbCommand.js +1 -1
- package/build/commands/db/spec/db.spec.js +8 -8
- package/build/commands/db/spec/dbCommand.spec.js +11 -7
- package/build/commands/deploy/compileBuildDeployCommand.js +6 -6
- package/build/commands/deploy/deploy.js +39 -39
- package/build/commands/deploy/deployCommand.js +2 -2
- package/build/commands/deploy/internal/getDeployScripts.js +14 -10
- package/build/commands/deploy/spec/cbd.spec.js +14 -14
- package/build/commands/deploy/spec/cbd.spec.server.js +40 -40
- package/build/commands/deploy/spec/compileBuildDeployCommand.spec.js +18 -14
- package/build/commands/deploy/spec/deployCommand.spec.js +15 -11
- package/build/commands/deploy/spec/getDeployScripts.spec.js +8 -8
- package/build/commands/deploy/spec/utils.js +17 -17
- package/build/commands/docs/docsCommand.js +7 -7
- package/build/commands/docs/generateDocs.js +33 -29
- package/build/commands/docs/generateDot.js +12 -8
- package/build/commands/docs/initDocs.js +1 -1
- package/build/commands/docs/internal/createDotFiles.js +6 -6
- package/build/commands/docs/internal/getDotFileContent.js +17 -17
- package/build/commands/docs/internal/getFileInputs.js +1 -1
- package/build/commands/docs/internal/getFileOutputs.js +1 -1
- package/build/commands/docs/internal/getFoldersForDocs.js +4 -4
- package/build/commands/docs/internal/populateNodeDictionary.js +1 -1
- package/build/commands/docs/spec/docsCommand.spec.js +25 -21
- package/build/commands/docs/spec/generateDocs.spec.js +60 -60
- package/build/commands/docs/spec/generateDot.spec.js +23 -23
- package/build/commands/docs/spec/getDocConfig.spec.js +2 -2
- package/build/commands/docs/spec/initDocs.spec.js +7 -7
- package/build/commands/flow/execute.js +8 -8
- package/build/commands/flow/flowCommand.js +5 -5
- package/build/commands/flow/internal/checkPredecessorDeadlock.js +11 -7
- package/build/commands/flow/internal/executeFlow.js +23 -23
- package/build/commands/flow/internal/failAllSuccessors.js +1 -1
- package/build/commands/flow/internal/generateFileName.js +2 -2
- package/build/commands/flow/internal/normalizeFilePath.js +1 -1
- package/build/commands/flow/internal/parseJobDetails.js +3 -3
- package/build/commands/flow/internal/printError.js +1 -1
- package/build/commands/flow/internal/saveLog.js +8 -8
- package/build/commands/flow/internal/saveToCsv.js +2 -2
- package/build/commands/flow/internal/spec/allFlowsCompleted.spec.js +4 -4
- package/build/commands/flow/internal/spec/checkPredecessorDeadlock.spec.js +4 -4
- package/build/commands/flow/internal/spec/executeFlow.spec.js +10 -10
- package/build/commands/flow/internal/spec/failAllSuccessors.spec.js +1 -1
- package/build/commands/flow/internal/spec/saveToCsv.spec.js +16 -16
- package/build/commands/flow/internal/spec/validateParams.spec.js +33 -33
- package/build/commands/flow/internal/validateParams.js +17 -17
- package/build/commands/flow/spec/flow.spec.js +1 -1
- package/build/commands/flow/spec/flow.spec.server.js +60 -60
- package/build/commands/flow/spec/flowCommand.spec.js +16 -12
- package/build/commands/folder/create.js +2 -2
- package/build/commands/folder/delete.js +2 -2
- package/build/commands/folder/folderCommand.js +11 -11
- package/build/commands/folder/move.js +2 -2
- package/build/commands/folder/spec/folder.spec.server.js +35 -35
- package/build/commands/folder/spec/folderCommand.spec.js +23 -19
- package/build/commands/help/help.js +46 -46
- package/build/commands/help/helpCommand.js +1 -1
- package/build/commands/help/spec/help.spec.js +8 -8
- package/build/commands/help/spec/helpCommand.spec.js +11 -7
- package/build/commands/init/init.js +7 -7
- package/build/commands/init/initCommand.js +1 -1
- package/build/commands/init/spec/init.spec.server.js +17 -17
- package/build/commands/init/spec/initCommand.spec.js +11 -7
- package/build/commands/job/internal/execute/sasjs.js +1 -1
- package/build/commands/job/internal/execute/viya.js +35 -35
- package/build/commands/job/internal/utils.js +6 -6
- package/build/commands/job/jobCommand.js +6 -6
- package/build/commands/job/spec/execute.spec.js +6 -6
- package/build/commands/job/spec/getContextName.spec.js +2 -2
- package/build/commands/job/spec/job.spec.server.js +53 -53
- package/build/commands/job/spec/jobCommand.spec.js +17 -13
- package/build/commands/lint/initLint.js +2 -2
- package/build/commands/lint/lintCommand.js +10 -10
- package/build/commands/lint/processLint.js +5 -5
- package/build/commands/lint/spec/lintCommand.spec.js +19 -15
- package/build/commands/request/request.js +16 -16
- package/build/commands/request/requestCommand.js +5 -5
- package/build/commands/request/spec/request.spec.server.js +71 -71
- package/build/commands/request/spec/requestCommand.spec.js +17 -13
- package/build/commands/run/run.js +23 -23
- package/build/commands/run/runCommand.js +2 -2
- package/build/commands/run/spec/run.spec.server.js +51 -51
- package/build/commands/run/spec/runCommand.spec.js +10 -6
- package/build/commands/servicepack/deploy.js +6 -6
- package/build/commands/servicepack/servicePackCommand.js +3 -3
- package/build/commands/servicepack/spec/servicepack.spec.server.js +6 -6
- package/build/commands/servicepack/spec/servicepackCommand.spec.js +10 -6
- package/build/commands/shared/createConfigFile.js +2 -2
- package/build/commands/shared/createFileStructure.js +6 -6
- package/build/commands/shared/createLintConfigFile.js +1 -1
- package/build/commands/shared/deployToSasViyaWithServicePack.js +4 -4
- package/build/commands/shared/fetchLogFileContent.js +10 -6
- package/build/commands/testing/internal/saveOutput.js +38 -34
- package/build/commands/testing/spec/testCommand.spec.js +17 -13
- package/build/commands/testing/spec/testing.spec.server.js +38 -38
- package/build/commands/testing/test.js +45 -41
- package/build/commands/testing/testCommand.js +2 -2
- package/build/commands/version/spec/version.spec.js +1 -1
- package/build/commands/version/spec/versionCommand.spec.js +11 -7
- package/build/commands/version/version.js +3 -3
- package/build/commands/version/versionCommand.js +2 -2
- package/build/commands/web/internal/createAssetServices.js +28 -24
- package/build/commands/web/internal/getWebServiceContent.js +6 -6
- package/build/commands/web/internal/sasjsout.d.ts +1 -1
- package/build/commands/web/internal/sasjsout.js +1 -1
- package/build/commands/web/internal/spec/updateLinkTag.spec.js +2 -2
- package/build/commands/web/internal/spec/updateScriptTag.spec.js +10 -10
- package/build/commands/web/internal/updateAllTags.js +19 -15
- package/build/commands/web/internal/updateLinkTag.js +2 -2
- package/build/commands/web/internal/updateScriptTag.js +6 -6
- package/build/commands/web/spec/web.spec.js +23 -23
- package/build/commands/web/spec/webCommand.spec.js +16 -12
- package/build/commands/web/web.js +25 -25
- package/build/commands/web/webCommand.js +3 -3
- package/build/types/command/commandBase.js +19 -15
- package/build/types/command/parse.js +1 -1
- package/build/types/command/spec/commandBase.spec.js +16 -12
- package/build/types/command/targetCommand.js +4 -4
- package/build/types/command/unalias.js +9 -5
- package/build/utils/auth.js +7 -7
- package/build/utils/config.js +53 -49
- package/build/utils/displayResult.js +4 -4
- package/build/utils/file.js +11 -11
- package/build/utils/fileStructures/builtFiles.js +2 -2
- package/build/utils/fileStructures/builtFilesCustom1.js +2 -2
- package/build/utils/getLogFilePath.js +1 -1
- package/build/utils/loadEnvVariables.js +3 -3
- package/build/utils/prefixAppLoc.js +1 -1
- package/build/utils/saveLog.js +7 -7
- package/build/utils/setConstants.js +4 -4
- package/build/utils/setProjectDir.js +2 -2
- package/build/utils/spec/config.spec.js +80 -80
- package/build/utils/spec/displayResult.spec.js +7 -7
- package/build/utils/spec/file.spec.js +15 -15
- package/build/utils/spec/removeComments.spec.js +11 -11
- package/build/utils/spec/setConstants.spec.js +3 -3
- package/build/utils/spec/utils.spec.js +55 -55
- package/build/utils/test.js +59 -59
- package/build/utils/utils.js +47 -43
- package/package.json +10 -10
package/build/cli.js
CHANGED
|
@@ -45,19 +45,19 @@ function cli(args) {
|
|
|
45
45
|
var command, returnCode;
|
|
46
46
|
return __generator(this, function (_a) {
|
|
47
47
|
switch (_a.label) {
|
|
48
|
-
case 0: return [4 /*yield*/, utils_1.setProjectDir(args)];
|
|
48
|
+
case 0: return [4 /*yield*/, (0, utils_1.setProjectDir)(args)];
|
|
49
49
|
case 1:
|
|
50
50
|
_a.sent();
|
|
51
|
-
return [4 /*yield*/, utils_1.setConstants()];
|
|
51
|
+
return [4 /*yield*/, (0, utils_1.setConstants)()];
|
|
52
52
|
case 2:
|
|
53
53
|
_a.sent();
|
|
54
|
-
return [4 /*yield*/, utils_1.loadProjectEnvVariables()];
|
|
54
|
+
return [4 /*yield*/, (0, utils_1.loadProjectEnvVariables)()];
|
|
55
55
|
case 3:
|
|
56
56
|
_a.sent();
|
|
57
57
|
return [4 /*yield*/, instantiateLogger()];
|
|
58
58
|
case 4:
|
|
59
59
|
_a.sent();
|
|
60
|
-
command = parse_1.parse(args);
|
|
60
|
+
command = (0, parse_1.parse)(args);
|
|
61
61
|
return [4 /*yield*/, command.execute()];
|
|
62
62
|
case 5:
|
|
63
63
|
returnCode = _a.sent();
|
package/build/cli.spec.js
CHANGED
|
@@ -103,7 +103,7 @@ describe('CLI command parsing', function () {
|
|
|
103
103
|
it('should set up common infrastructure before parsing the command', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
104
104
|
return __generator(this, function (_a) {
|
|
105
105
|
switch (_a.label) {
|
|
106
|
-
case 0: return [4 /*yield*/, cli_1.cli(args)];
|
|
106
|
+
case 0: return [4 /*yield*/, (0, cli_1.cli)(args)];
|
|
107
107
|
case 1:
|
|
108
108
|
_a.sent();
|
|
109
109
|
expect(envVariablesModule.loadProjectEnvVariables).toHaveBeenCalledTimes(1);
|
|
@@ -117,7 +117,7 @@ describe('CLI command parsing', function () {
|
|
|
117
117
|
it('should parse the command passed in', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
118
118
|
return __generator(this, function (_a) {
|
|
119
119
|
switch (_a.label) {
|
|
120
|
-
case 0: return [4 /*yield*/, cli_1.cli(args)];
|
|
120
|
+
case 0: return [4 /*yield*/, (0, cli_1.cli)(args)];
|
|
121
121
|
case 1:
|
|
122
122
|
_a.sent();
|
|
123
123
|
expect(parseModule.parse).toHaveBeenCalledTimes(1);
|
|
@@ -129,7 +129,7 @@ describe('CLI command parsing', function () {
|
|
|
129
129
|
it('should execute the command when successfully parsed', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
130
130
|
return __generator(this, function (_a) {
|
|
131
131
|
switch (_a.label) {
|
|
132
|
-
case 0: return [4 /*yield*/, cli_1.cli(args)];
|
|
132
|
+
case 0: return [4 /*yield*/, (0, cli_1.cli)(args)];
|
|
133
133
|
case 1:
|
|
134
134
|
_a.sent();
|
|
135
135
|
expect(process.logger).toBeInstanceOf(utils_1.Logger);
|
|
@@ -141,7 +141,7 @@ describe('CLI command parsing', function () {
|
|
|
141
141
|
it('should return with the correct exit code after successful execution', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
142
142
|
return __generator(this, function (_a) {
|
|
143
143
|
switch (_a.label) {
|
|
144
|
-
case 0: return [4 /*yield*/, cli_1.cli(args)];
|
|
144
|
+
case 0: return [4 /*yield*/, (0, cli_1.cli)(args)];
|
|
145
145
|
case 1:
|
|
146
146
|
_a.sent();
|
|
147
147
|
expect(process.exit).toHaveBeenCalledWith(0);
|
|
@@ -156,7 +156,7 @@ describe('CLI command parsing', function () {
|
|
|
156
156
|
jest
|
|
157
157
|
.spyOn(mockCommand, 'execute')
|
|
158
158
|
.mockImplementation(function () { return Promise.resolve(command_1.ReturnCode.InternalError); });
|
|
159
|
-
return [4 /*yield*/, cli_1.cli(args)];
|
|
159
|
+
return [4 /*yield*/, (0, cli_1.cli)(args)];
|
|
160
160
|
case 1:
|
|
161
161
|
_a.sent();
|
|
162
162
|
expect(process.exit).toHaveBeenCalledWith(2);
|
|
@@ -167,7 +167,7 @@ describe('CLI command parsing', function () {
|
|
|
167
167
|
});
|
|
168
168
|
var setupMocks = function () {
|
|
169
169
|
jest.resetAllMocks();
|
|
170
|
-
test_1.mockProcessExit();
|
|
170
|
+
(0, test_1.mockProcessExit)();
|
|
171
171
|
jest.mock('./utils');
|
|
172
172
|
jest.mock('./types/command');
|
|
173
173
|
jest
|
|
@@ -150,7 +150,7 @@ var AddCommand = /** @class */ (function (_super) {
|
|
|
150
150
|
case 1:
|
|
151
151
|
_a = _b.sent(), target = _a.target, isLocal = _a.isLocal;
|
|
152
152
|
scope = isLocal ? types_1.TargetScope.Local : types_1.TargetScope.Global;
|
|
153
|
-
return [4 /*yield*/, addCredential_1.addCredential(target, this.insecure, scope)
|
|
153
|
+
return [4 /*yield*/, (0, addCredential_1.addCredential)(target, this.insecure, scope)
|
|
154
154
|
.then(function () {
|
|
155
155
|
var _a;
|
|
156
156
|
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.success('Credentials successfully added!');
|
|
@@ -170,7 +170,7 @@ var AddCommand = /** @class */ (function (_super) {
|
|
|
170
170
|
return __awaiter(this, void 0, void 0, function () {
|
|
171
171
|
return __generator(this, function (_a) {
|
|
172
172
|
switch (_a.label) {
|
|
173
|
-
case 0: return [4 /*yield*/, addTarget_1.addTarget(this.insecure)
|
|
173
|
+
case 0: return [4 /*yield*/, (0, addTarget_1.addTarget)(this.insecure)
|
|
174
174
|
.then(function () {
|
|
175
175
|
var _a;
|
|
176
176
|
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.success('Target has been successfully added!');
|
|
@@ -79,14 +79,14 @@ var addCredential = function (target, insecure, targetScope) { return __awaiter(
|
|
|
79
79
|
if (insecure)
|
|
80
80
|
(_f = process.logger) === null || _f === void 0 ? void 0 : _f.warn('Executing with insecure connection.');
|
|
81
81
|
if (!!target.serverUrl) return [3 /*break*/, 3];
|
|
82
|
-
return [4 /*yield*/, input_1.getAndValidateServerUrl(target)];
|
|
82
|
+
return [4 /*yield*/, (0, input_1.getAndValidateServerUrl)(target)];
|
|
83
83
|
case 1:
|
|
84
84
|
serverUrl = _j.sent();
|
|
85
85
|
target = new types_1.Target(__assign(__assign({}, target.toJson(false)), { serverUrl: serverUrl }));
|
|
86
|
-
return [4 /*yield*/, saveConfig_1.saveConfig(targetScope, target, false, false)];
|
|
86
|
+
return [4 /*yield*/, (0, saveConfig_1.saveConfig)(targetScope, target, false, false)];
|
|
87
87
|
case 2:
|
|
88
88
|
filePath_1 = _j.sent();
|
|
89
|
-
(_g = process.logger) === null || _g === void 0 ? void 0 : _g.info("Target configuration has been saved to "
|
|
89
|
+
(_g = process.logger) === null || _g === void 0 ? void 0 : _g.info("Target configuration has been saved to ".concat(filePath_1, " ."));
|
|
90
90
|
_j.label = 3;
|
|
91
91
|
case 3:
|
|
92
92
|
_a = target.serverType;
|
|
@@ -96,14 +96,14 @@ var addCredential = function (target, insecure, targetScope) { return __awaiter(
|
|
|
96
96
|
case types_1.ServerType.Sasjs: return [3 /*break*/, 15];
|
|
97
97
|
}
|
|
98
98
|
return [3 /*break*/, 21];
|
|
99
|
-
case 4: return [4 /*yield*/, input_1.getCredentialsInputForViya(target.name)];
|
|
99
|
+
case 4: return [4 /*yield*/, (0, input_1.getCredentialsInputForViya)(target.name)];
|
|
100
100
|
case 5:
|
|
101
101
|
_b = _j.sent(), client = _b.client, secret = _b.secret;
|
|
102
|
-
return [4 /*yield*/, exports.getTokens(target, client, secret, httpsAgentOptions)];
|
|
102
|
+
return [4 /*yield*/, (0, exports.getTokens)(target, client, secret, httpsAgentOptions)];
|
|
103
103
|
case 6:
|
|
104
104
|
_c = _j.sent(), access_token = _c.access_token, refresh_token = _c.refresh_token;
|
|
105
105
|
if (!(targetScope === targetScope_1.TargetScope.Local)) return [3 /*break*/, 8];
|
|
106
|
-
return [4 /*yield*/, exports.createEnvFileForViya(target.name, client, secret, access_token, refresh_token)];
|
|
106
|
+
return [4 /*yield*/, (0, exports.createEnvFileForViya)(target.name, client, secret, access_token, refresh_token)];
|
|
107
107
|
case 7:
|
|
108
108
|
_j.sent();
|
|
109
109
|
return [3 /*break*/, 9];
|
|
@@ -111,11 +111,11 @@ var addCredential = function (target, insecure, targetScope) { return __awaiter(
|
|
|
111
111
|
target = new types_1.Target(__assign(__assign({}, target.toJson(false)), { authConfig: { client: client, secret: secret, access_token: access_token, refresh_token: refresh_token } }));
|
|
112
112
|
_j.label = 9;
|
|
113
113
|
case 9: return [3 /*break*/, 22];
|
|
114
|
-
case 10: return [4 /*yield*/, input_1.getCredentialsInputSas9(target, targetScope)];
|
|
114
|
+
case 10: return [4 /*yield*/, (0, input_1.getCredentialsInputSas9)(target, targetScope)];
|
|
115
115
|
case 11:
|
|
116
116
|
_d = _j.sent(), userName = _d.userName, password = _d.password;
|
|
117
117
|
if (!(targetScope === targetScope_1.TargetScope.Local)) return [3 /*break*/, 13];
|
|
118
|
-
return [4 /*yield*/, exports.createEnvFileForSas9(target.name, userName, password)];
|
|
118
|
+
return [4 /*yield*/, (0, exports.createEnvFileForSas9)(target.name, userName, password)];
|
|
119
119
|
case 12:
|
|
120
120
|
_j.sent();
|
|
121
121
|
return [3 /*break*/, 14];
|
|
@@ -123,14 +123,14 @@ var addCredential = function (target, insecure, targetScope) { return __awaiter(
|
|
|
123
123
|
target = new types_1.Target(__assign(__assign({}, target.toJson(false)), { authConfigSas9: { userName: userName, password: password } }));
|
|
124
124
|
_j.label = 14;
|
|
125
125
|
case 14: return [3 /*break*/, 22];
|
|
126
|
-
case 15: return [4 /*yield*/, input_1.getCredentialsInputSasjs(target)];
|
|
126
|
+
case 15: return [4 /*yield*/, (0, input_1.getCredentialsInputSasjs)(target)];
|
|
127
127
|
case 16:
|
|
128
128
|
client = (_j.sent()).client;
|
|
129
|
-
return [4 /*yield*/, exports.getTokens(target, client, '', httpsAgentOptions)];
|
|
129
|
+
return [4 /*yield*/, (0, exports.getTokens)(target, client, '', httpsAgentOptions)];
|
|
130
130
|
case 17:
|
|
131
131
|
_e = _j.sent(), access_token = _e.access_token, refresh_token = _e.refresh_token;
|
|
132
132
|
if (!(targetScope === targetScope_1.TargetScope.Local)) return [3 /*break*/, 19];
|
|
133
|
-
return [4 /*yield*/, exports.createEnvFileForSasjs(target.name, client, access_token, refresh_token)];
|
|
133
|
+
return [4 /*yield*/, (0, exports.createEnvFileForSasjs)(target.name, client, access_token, refresh_token)];
|
|
134
134
|
case 18:
|
|
135
135
|
_j.sent();
|
|
136
136
|
return [3 /*break*/, 20];
|
|
@@ -139,10 +139,10 @@ var addCredential = function (target, insecure, targetScope) { return __awaiter(
|
|
|
139
139
|
_j.label = 20;
|
|
140
140
|
case 20: return [3 /*break*/, 22];
|
|
141
141
|
case 21: throw new Error('Target contains invalid serverType. Possible types could be SASVIYA, SAS9 and SASJS');
|
|
142
|
-
case 22: return [4 /*yield*/, saveConfig_1.saveConfig(targetScope, target, false, false)];
|
|
142
|
+
case 22: return [4 /*yield*/, (0, saveConfig_1.saveConfig)(targetScope, target, false, false)];
|
|
143
143
|
case 23:
|
|
144
144
|
filePath = _j.sent();
|
|
145
|
-
(_h = process.logger) === null || _h === void 0 ? void 0 : _h.info("Target configuration has been saved to "
|
|
145
|
+
(_h = process.logger) === null || _h === void 0 ? void 0 : _h.info("Target configuration has been saved to ".concat(filePath, " ."));
|
|
146
146
|
return [2 /*return*/, target];
|
|
147
147
|
}
|
|
148
148
|
});
|
|
@@ -172,9 +172,9 @@ var getTokens = function (target, client, secret, httpsAgentOptions) { return __
|
|
|
172
172
|
httpsAgentOptions: httpsAgentOptions,
|
|
173
173
|
debug: ((_b = process.logger) === null || _b === void 0 ? void 0 : _b.logLevel) === logger_1.LogLevel.Debug
|
|
174
174
|
});
|
|
175
|
-
return [4 /*yield*/, auth_1.getNewAccessToken(adapter, client, secret, target).catch(function (e) {
|
|
175
|
+
return [4 /*yield*/, (0, auth_1.getNewAccessToken)(adapter, client, secret, target).catch(function (e) {
|
|
176
176
|
var _a;
|
|
177
|
-
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.error("An error has occurred while validating your credentials: "
|
|
177
|
+
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.error("An error has occurred while validating your credentials: ".concat(e, "\nPlease check your Client ID ").concat(target.serverType === types_1.ServerType.Sasjs ? '' : 'and Client Secret ', "and try again.\n"));
|
|
178
178
|
throw e;
|
|
179
179
|
})];
|
|
180
180
|
case 1:
|
|
@@ -190,12 +190,12 @@ var createEnvFileForViya = function (targetName, client, secret, accessToken, re
|
|
|
190
190
|
return __generator(this, function (_b) {
|
|
191
191
|
switch (_b.label) {
|
|
192
192
|
case 0:
|
|
193
|
-
envFileContent = "CLIENT="
|
|
194
|
-
envFilePath = path_1.default.join(process.projectDir, ".env."
|
|
195
|
-
return [4 /*yield*/, utils_1.createFile(envFilePath, envFileContent)];
|
|
193
|
+
envFileContent = "CLIENT=".concat(client, "\nSECRET=").concat(secret, "\nACCESS_TOKEN=").concat(accessToken, "\nREFRESH_TOKEN=").concat(refreshToken, "\n");
|
|
194
|
+
envFilePath = path_1.default.join(process.projectDir, ".env.".concat(targetName));
|
|
195
|
+
return [4 /*yield*/, (0, utils_1.createFile)(envFilePath, envFileContent)];
|
|
196
196
|
case 1:
|
|
197
197
|
_b.sent();
|
|
198
|
-
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.success("Environment file saved at "
|
|
198
|
+
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.success("Environment file saved at ".concat(envFilePath));
|
|
199
199
|
return [2 /*return*/];
|
|
200
200
|
}
|
|
201
201
|
});
|
|
@@ -207,12 +207,12 @@ var createEnvFileForSas9 = function (targetName, userName, password) { return __
|
|
|
207
207
|
return __generator(this, function (_b) {
|
|
208
208
|
switch (_b.label) {
|
|
209
209
|
case 0:
|
|
210
|
-
envFileContent = "SAS_USERNAME="
|
|
211
|
-
envFilePath = path_1.default.join(process.projectDir, ".env."
|
|
212
|
-
return [4 /*yield*/, utils_1.createFile(envFilePath, envFileContent)];
|
|
210
|
+
envFileContent = "SAS_USERNAME=".concat(userName, "\nSAS_PASSWORD=").concat(password, "\n");
|
|
211
|
+
envFilePath = path_1.default.join(process.projectDir, ".env.".concat(targetName));
|
|
212
|
+
return [4 /*yield*/, (0, utils_1.createFile)(envFilePath, envFileContent)];
|
|
213
213
|
case 1:
|
|
214
214
|
_b.sent();
|
|
215
|
-
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.success("Environment file saved at "
|
|
215
|
+
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.success("Environment file saved at ".concat(envFilePath));
|
|
216
216
|
return [2 /*return*/];
|
|
217
217
|
}
|
|
218
218
|
});
|
|
@@ -224,12 +224,12 @@ var createEnvFileForSasjs = function (targetName, client, accessToken, refreshTo
|
|
|
224
224
|
return __generator(this, function (_b) {
|
|
225
225
|
switch (_b.label) {
|
|
226
226
|
case 0:
|
|
227
|
-
envFileContent = "CLIENT="
|
|
228
|
-
envFilePath = path_1.default.join(process.projectDir, ".env."
|
|
229
|
-
return [4 /*yield*/, utils_1.createFile(envFilePath, envFileContent)];
|
|
227
|
+
envFileContent = "CLIENT=".concat(client, "\nACCESS_TOKEN=").concat(accessToken, "\nREFRESH_TOKEN=").concat(refreshToken, "\n");
|
|
228
|
+
envFilePath = path_1.default.join(process.projectDir, ".env.".concat(targetName));
|
|
229
|
+
return [4 /*yield*/, (0, utils_1.createFile)(envFilePath, envFileContent)];
|
|
230
230
|
case 1:
|
|
231
231
|
_b.sent();
|
|
232
|
-
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.success("Environment file saved at "
|
|
232
|
+
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.success("Environment file saved at ".concat(envFilePath));
|
|
233
233
|
return [2 /*return*/];
|
|
234
234
|
}
|
|
235
235
|
});
|
|
@@ -66,16 +66,16 @@ function addTarget(insecure) {
|
|
|
66
66
|
case 0:
|
|
67
67
|
if (insecure)
|
|
68
68
|
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.warn('Executing with insecure connection.');
|
|
69
|
-
return [4 /*yield*/, input_1.getCommonFields()];
|
|
69
|
+
return [4 /*yield*/, (0, input_1.getCommonFields)()];
|
|
70
70
|
case 1:
|
|
71
71
|
_d = _h.sent(), scope = _d.scope, serverType = _d.serverType, name = _d.name, appLoc = _d.appLoc, serverUrl = _d.serverUrl, existingTarget = _d.existingTarget;
|
|
72
72
|
saveWithDefaultValues = !existingTarget;
|
|
73
73
|
targetJson = __assign(__assign({}, existingTarget), { name: name, serverType: serverType, serverUrl: serverUrl, appLoc: appLoc });
|
|
74
74
|
target = new types_1.Target(targetJson);
|
|
75
|
-
return [4 /*yield*/, saveConfig_1.saveConfig(scope, target, false, saveWithDefaultValues)];
|
|
75
|
+
return [4 /*yield*/, (0, saveConfig_1.saveConfig)(scope, target, false, saveWithDefaultValues)];
|
|
76
76
|
case 2:
|
|
77
77
|
filePath = _h.sent();
|
|
78
|
-
(_b = process.logger) === null || _b === void 0 ? void 0 : _b.info("Target configuration has been saved to "
|
|
78
|
+
(_b = process.logger) === null || _b === void 0 ? void 0 : _b.info("Target configuration has been saved to ".concat(filePath, " ."));
|
|
79
79
|
_e = serverType;
|
|
80
80
|
switch (_e) {
|
|
81
81
|
case types_1.ServerType.Sas9: return [3 /*break*/, 3];
|
|
@@ -83,18 +83,18 @@ function addTarget(insecure) {
|
|
|
83
83
|
case types_1.ServerType.Sasjs: return [3 /*break*/, 7];
|
|
84
84
|
}
|
|
85
85
|
return [3 /*break*/, 9];
|
|
86
|
-
case 3: return [4 /*yield*/, input_1.getAndValidateSas9Fields(target, scope)];
|
|
86
|
+
case 3: return [4 /*yield*/, (0, input_1.getAndValidateSas9Fields)(target, scope)];
|
|
87
87
|
case 4:
|
|
88
88
|
_f = _h.sent(), serverName = _f.serverName, repositoryName = _f.repositoryName, userName = _f.userName, password = _f.password;
|
|
89
89
|
targetJson = __assign(__assign({}, targetJson), { serverName: serverName, repositoryName: repositoryName });
|
|
90
90
|
if (scope === targetScope_1.TargetScope.Local) {
|
|
91
|
-
addCredential_1.createEnvFileForSas9(name, userName, password);
|
|
91
|
+
(0, addCredential_1.createEnvFileForSas9)(name, userName, password);
|
|
92
92
|
}
|
|
93
93
|
else {
|
|
94
94
|
targetJson = __assign(__assign({}, targetJson), { authConfigSas9: { userName: userName, password: password } });
|
|
95
95
|
}
|
|
96
96
|
return [3 /*break*/, 10];
|
|
97
|
-
case 5: return [4 /*yield*/, input_1.getAndValidateSasViyaFields(target, scope, serverUrl, insecure, addCredential_1.addCredential)];
|
|
97
|
+
case 5: return [4 /*yield*/, (0, input_1.getAndValidateSasViyaFields)(target, scope, serverUrl, insecure, addCredential_1.addCredential)];
|
|
98
98
|
case 6:
|
|
99
99
|
_g = _h.sent(), contextName = _g.contextName, updatedViyaTarget = _g.target;
|
|
100
100
|
targetJson = {
|
|
@@ -106,19 +106,19 @@ function addTarget(insecure) {
|
|
|
106
106
|
};
|
|
107
107
|
targetJson = __assign(__assign({}, updatedViyaTarget.toJson(false)), targetJson);
|
|
108
108
|
return [3 /*break*/, 10];
|
|
109
|
-
case 7: return [4 /*yield*/, input_1.getAndValidateSasjsFields(target, scope, insecure, addCredential_1.addCredential)];
|
|
109
|
+
case 7: return [4 /*yield*/, (0, input_1.getAndValidateSasjsFields)(target, scope, insecure, addCredential_1.addCredential)];
|
|
110
110
|
case 8:
|
|
111
111
|
updatedSasjsTarget = (_h.sent()).target;
|
|
112
112
|
targetJson = updatedSasjsTarget.toJson(false);
|
|
113
113
|
return [3 /*break*/, 10];
|
|
114
114
|
case 9: throw new Error('Target contains invalid serverType. Possible types could be SASVIYA, SAS9 and SASJS');
|
|
115
|
-
case 10: return [4 /*yield*/, input_1.getIsDefault()];
|
|
115
|
+
case 10: return [4 /*yield*/, (0, input_1.getIsDefault)()];
|
|
116
116
|
case 11:
|
|
117
117
|
isDefault = _h.sent();
|
|
118
|
-
return [4 /*yield*/, saveConfig_1.saveConfig(scope, new types_1.Target(targetJson), isDefault, saveWithDefaultValues)];
|
|
118
|
+
return [4 /*yield*/, (0, saveConfig_1.saveConfig)(scope, new types_1.Target(targetJson), isDefault, saveWithDefaultValues)];
|
|
119
119
|
case 12:
|
|
120
120
|
filePath = _h.sent();
|
|
121
|
-
(_c = process.logger) === null || _c === void 0 ? void 0 : _c.info("Target configuration has been saved to "
|
|
121
|
+
(_c = process.logger) === null || _c === void 0 ? void 0 : _c.info("Target configuration has been saved to ".concat(filePath));
|
|
122
122
|
return [2 /*return*/, true];
|
|
123
123
|
}
|
|
124
124
|
});
|
|
@@ -83,7 +83,7 @@ function getCommonFields() {
|
|
|
83
83
|
case 5: return [2 /*return*/, _c.sent()];
|
|
84
84
|
case 6:
|
|
85
85
|
if (existingTarget) {
|
|
86
|
-
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Updating current target '"
|
|
86
|
+
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Updating current target '".concat(name, "'"));
|
|
87
87
|
}
|
|
88
88
|
return [4 /*yield*/, getAndValidateAppLoc(name, existingTarget)];
|
|
89
89
|
case 7:
|
|
@@ -111,7 +111,7 @@ function getAndValidateScope() {
|
|
|
111
111
|
switch (_a.label) {
|
|
112
112
|
case 0:
|
|
113
113
|
errorMessage = 'Target scope must be either 1 or 2.';
|
|
114
|
-
return [4 /*yield*/, input_1.getChoice('Please pick a scope for the new target: ', 'Please choose either option 1 or 2.', [
|
|
114
|
+
return [4 /*yield*/, (0, input_1.getChoice)('Please pick a scope for the new target: ', 'Please choose either option 1 or 2.', [
|
|
115
115
|
{ title: '1. Local project config file', value: 1 },
|
|
116
116
|
{ title: '2. Global config file', value: 2 }
|
|
117
117
|
]).catch(function () {
|
|
@@ -132,7 +132,7 @@ function getAndValidateServerType() {
|
|
|
132
132
|
var serverType;
|
|
133
133
|
return __generator(this, function (_a) {
|
|
134
134
|
switch (_a.label) {
|
|
135
|
-
case 0: return [4 /*yield*/, input_1.getChoice('Please pick a server type: ', 'Please choose either option 1 or 2.', [
|
|
135
|
+
case 0: return [4 /*yield*/, (0, input_1.getChoice)('Please pick a server type: ', 'Please choose either option 1 or 2.', [
|
|
136
136
|
{ title: '1. SAS Viya', value: 1 },
|
|
137
137
|
{ title: '2. SAS 9', value: 2 },
|
|
138
138
|
{ title: '3. SAS JS', value: 3 }
|
|
@@ -157,7 +157,7 @@ function getAndValidateServerUrl(target) {
|
|
|
157
157
|
var serverUrl;
|
|
158
158
|
return __generator(this, function (_a) {
|
|
159
159
|
switch (_a.label) {
|
|
160
|
-
case 0: return [4 /*yield*/, input_1.getUrl('Please enter a target server URL (including port, if relevant): ', 'Server URL is required.', target === null || target === void 0 ? void 0 : target.serverUrl)];
|
|
160
|
+
case 0: return [4 /*yield*/, (0, input_1.getUrl)('Please enter a target server URL (including port, if relevant): ', 'Server URL is required.', target === null || target === void 0 ? void 0 : target.serverUrl)];
|
|
161
161
|
case 1:
|
|
162
162
|
serverUrl = _a.sent();
|
|
163
163
|
return [2 /*return*/, serverUrl];
|
|
@@ -191,7 +191,7 @@ function getAndValidateTargetName(serverType) {
|
|
|
191
191
|
: serverType === types_1.ServerType.Sas9
|
|
192
192
|
? 'sas9'
|
|
193
193
|
: 'server';
|
|
194
|
-
return [4 /*yield*/, input_1.getString('Please enter a target name: ', validator, defaultName)];
|
|
194
|
+
return [4 /*yield*/, (0, input_1.getString)('Please enter a target name: ', validator, defaultName)];
|
|
195
195
|
case 1:
|
|
196
196
|
targetName = _a.sent();
|
|
197
197
|
return [2 /*return*/, targetName];
|
|
@@ -205,15 +205,15 @@ function getAndValidateUpdateExisting(targetScope, targetName) {
|
|
|
205
205
|
var targetJson, errorMessage_1, choice;
|
|
206
206
|
return __generator(this, function (_b) {
|
|
207
207
|
switch (_b.label) {
|
|
208
|
-
case 0: return [4 /*yield*/, config_1.findTargetInConfiguration(targetName, targetScope)
|
|
208
|
+
case 0: return [4 /*yield*/, (0, config_1.findTargetInConfiguration)(targetName, targetScope)
|
|
209
209
|
.then(function (res) { return res.target.toJson(); })
|
|
210
210
|
.catch(function (_) { return undefined; })];
|
|
211
211
|
case 1:
|
|
212
212
|
targetJson = _b.sent();
|
|
213
213
|
if (!targetJson) return [3 /*break*/, 3];
|
|
214
|
-
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Found target with same name: '"
|
|
214
|
+
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Found target with same name: '".concat(targetName, "'"));
|
|
215
215
|
errorMessage_1 = 'Target update choice must be either 1 or 2.';
|
|
216
|
-
return [4 /*yield*/, input_1.getChoice('Please pick an option for the current target: ', 'Please choose either option 1 or 2.', [
|
|
216
|
+
return [4 /*yield*/, (0, input_1.getChoice)('Please pick an option for the current target: ', 'Please choose either option 1 or 2.', [
|
|
217
217
|
{ title: '1. Update this target', value: 1 },
|
|
218
218
|
{ title: '2. Go back and create a new target', value: 2 }
|
|
219
219
|
]).catch(function () {
|
|
@@ -235,13 +235,13 @@ function getAndValidateSas9Fields(target, scope) {
|
|
|
235
235
|
var serverName, repositoryName, _a, userName, password;
|
|
236
236
|
return __generator(this, function (_b) {
|
|
237
237
|
switch (_b.label) {
|
|
238
|
-
case 0: return [4 /*yield*/, input_1.getString('Please enter a server name (default is SASApp): ', function (v) { return !!v || 'Server name is required.'; }, 'SASApp')];
|
|
238
|
+
case 0: return [4 /*yield*/, (0, input_1.getString)('Please enter a server name (default is SASApp): ', function (v) { return !!v || 'Server name is required.'; }, 'SASApp')];
|
|
239
239
|
case 1:
|
|
240
240
|
serverName = _b.sent();
|
|
241
|
-
return [4 /*yield*/, input_1.getString('Please enter a repository name (default is Foundation): ', function (v) { return !!v || 'Repository name is required.'; }, 'Foundation')];
|
|
241
|
+
return [4 /*yield*/, (0, input_1.getString)('Please enter a repository name (default is Foundation): ', function (v) { return !!v || 'Repository name is required.'; }, 'Foundation')];
|
|
242
242
|
case 2:
|
|
243
243
|
repositoryName = _b.sent();
|
|
244
|
-
return [4 /*yield*/, exports.getCredentialsInputSas9(target, scope)];
|
|
244
|
+
return [4 /*yield*/, (0, exports.getCredentialsInputSas9)(target, scope)];
|
|
245
245
|
case 3:
|
|
246
246
|
_a = _b.sent(), userName = _a.userName, password = _a.password;
|
|
247
247
|
return [2 /*return*/, { serverName: serverName, repositoryName: repositoryName, userName: userName, password: password }];
|
|
@@ -251,7 +251,7 @@ function getAndValidateSas9Fields(target, scope) {
|
|
|
251
251
|
}
|
|
252
252
|
exports.getAndValidateSas9Fields = getAndValidateSas9Fields;
|
|
253
253
|
var shouldAuthenticate = function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
254
|
-
return [2 /*return*/, input_1.getConfirmation('Would you like to authenticate against this target?', true)];
|
|
254
|
+
return [2 /*return*/, (0, input_1.getConfirmation)('Would you like to authenticate against this target?', true)];
|
|
255
255
|
}); }); };
|
|
256
256
|
exports.shouldAuthenticate = shouldAuthenticate;
|
|
257
257
|
function getAndValidateSasViyaFields(target, scope, serverUrl, insecure, authenticateCallback) {
|
|
@@ -262,7 +262,7 @@ function getAndValidateSasViyaFields(target, scope, serverUrl, insecure, authent
|
|
|
262
262
|
switch (_b.label) {
|
|
263
263
|
case 0:
|
|
264
264
|
contextName = 'SAS Job Execution compute context';
|
|
265
|
-
return [4 /*yield*/, exports.shouldAuthenticate()];
|
|
265
|
+
return [4 /*yield*/, (0, exports.shouldAuthenticate)()];
|
|
266
266
|
case 1:
|
|
267
267
|
if (!_b.sent()) return [3 /*break*/, 8];
|
|
268
268
|
return [4 /*yield*/, authenticateCallback(target, insecure, scope)];
|
|
@@ -279,7 +279,7 @@ function getAndValidateSasViyaFields(target, scope, serverUrl, insecure, authent
|
|
|
279
279
|
contexts = [];
|
|
280
280
|
if (!(scope === targetScope_1.TargetScope.Local)) return [3 /*break*/, 4];
|
|
281
281
|
dotenv_1.default.config({
|
|
282
|
-
path: path_1.default.join(process.projectDir, ".env."
|
|
282
|
+
path: path_1.default.join(process.projectDir, ".env.".concat(target.name))
|
|
283
283
|
});
|
|
284
284
|
return [4 /*yield*/, sasjs.getComputeContexts(process.env.ACCESS_TOKEN)];
|
|
285
285
|
case 3:
|
|
@@ -287,15 +287,15 @@ function getAndValidateSasViyaFields(target, scope, serverUrl, insecure, authent
|
|
|
287
287
|
return [3 /*break*/, 6];
|
|
288
288
|
case 4:
|
|
289
289
|
if (!target.authConfig || !target.authConfig.access_token) {
|
|
290
|
-
throw new Error("No access token available for target "
|
|
290
|
+
throw new Error("No access token available for target ".concat(target.name, ". Please run `sasjs add cred -t ").concat(target.name, "` to authenticate."));
|
|
291
291
|
}
|
|
292
292
|
return [4 /*yield*/, sasjs.getComputeContexts(target.authConfig.access_token)];
|
|
293
293
|
case 5:
|
|
294
294
|
contexts = _b.sent();
|
|
295
295
|
_b.label = 6;
|
|
296
296
|
case 6:
|
|
297
|
-
contextNumberErrorMessage = "Context number must be between 1 and "
|
|
298
|
-
return [4 /*yield*/, input_1.getChoice('Please pick your SAS Viya execution context: ', contextNumberErrorMessage, contexts.map(function (c, i) { return ({ title: c.name, value: i }); }))];
|
|
297
|
+
contextNumberErrorMessage = "Context number must be between 1 and ".concat(contexts.length);
|
|
298
|
+
return [4 /*yield*/, (0, input_1.getChoice)('Please pick your SAS Viya execution context: ', contextNumberErrorMessage, contexts.map(function (c, i) { return ({ title: c.name, value: i }); }))];
|
|
299
299
|
case 7:
|
|
300
300
|
contextNumber = _b.sent();
|
|
301
301
|
contextName = contexts[contextNumber].name;
|
|
@@ -313,7 +313,7 @@ function getAndValidateSasjsFields(target, scope, insecure, authenticateCallback
|
|
|
313
313
|
return __awaiter(this, void 0, void 0, function () {
|
|
314
314
|
return __generator(this, function (_a) {
|
|
315
315
|
switch (_a.label) {
|
|
316
|
-
case 0: return [4 /*yield*/, exports.shouldAuthenticate()];
|
|
316
|
+
case 0: return [4 /*yield*/, (0, exports.shouldAuthenticate)()];
|
|
317
317
|
case 1:
|
|
318
318
|
if (!_a.sent()) return [3 /*break*/, 3];
|
|
319
319
|
return [4 /*yield*/, authenticateCallback(target, insecure, scope)];
|
|
@@ -334,7 +334,7 @@ function getAndValidateAppLoc(targetName, target) {
|
|
|
334
334
|
switch (_b.label) {
|
|
335
335
|
case 0:
|
|
336
336
|
errorMessage = 'App location is required.';
|
|
337
|
-
return [4 /*yield*/, input_1.getString('Please provide an app location: ', function (v) { return !!v || errorMessage; }, (_a = target === null || target === void 0 ? void 0 : target.appLoc) !== null && _a !== void 0 ? _a : "/Public/app/"
|
|
337
|
+
return [4 /*yield*/, (0, input_1.getString)('Please provide an app location: ', function (v) { return !!v || errorMessage; }, (_a = target === null || target === void 0 ? void 0 : target.appLoc) !== null && _a !== void 0 ? _a : "/Public/app/".concat(targetName))];
|
|
338
338
|
case 1:
|
|
339
339
|
appLoc = _b.sent();
|
|
340
340
|
return [2 /*return*/, appLoc];
|
|
@@ -347,11 +347,11 @@ var getCredentialsInputForViya = function (targetName) { return __awaiter(void 0
|
|
|
347
347
|
return __generator(this, function (_a) {
|
|
348
348
|
switch (_a.label) {
|
|
349
349
|
case 0:
|
|
350
|
-
defaultValues = exports.getDefaultValues(targetName);
|
|
351
|
-
return [4 /*yield*/, input_1.getString('Please enter your Client ID: ', function (v) { return !!v || 'Client ID is required.'; }, defaultValues.client)];
|
|
350
|
+
defaultValues = (0, exports.getDefaultValues)(targetName);
|
|
351
|
+
return [4 /*yield*/, (0, input_1.getString)('Please enter your Client ID: ', function (v) { return !!v || 'Client ID is required.'; }, defaultValues.client)];
|
|
352
352
|
case 1:
|
|
353
353
|
client = _a.sent();
|
|
354
|
-
return [4 /*yield*/, input_1.getString('Please enter your Client Secret: ', function (v) { return !!v || 'Client Secret is required.'; }, defaultValues.secret)];
|
|
354
|
+
return [4 /*yield*/, (0, input_1.getString)('Please enter your Client Secret: ', function (v) { return !!v || 'Client Secret is required.'; }, defaultValues.secret)];
|
|
355
355
|
case 2:
|
|
356
356
|
secret = _a.sent();
|
|
357
357
|
return [2 /*return*/, { client: client, secret: secret }];
|
|
@@ -363,7 +363,7 @@ var getCredentialsInputSasjs = function (target) { return __awaiter(void 0, void
|
|
|
363
363
|
var client;
|
|
364
364
|
return __generator(this, function (_a) {
|
|
365
365
|
switch (_a.label) {
|
|
366
|
-
case 0: return [4 /*yield*/, input_1.getString('Please enter your Client ID: ', function (v) { return !!v || 'Client ID is required.'; }, exports.getDefaultValues(target.name).client)];
|
|
366
|
+
case 0: return [4 /*yield*/, (0, input_1.getString)('Please enter your Client ID: ', function (v) { return !!v || 'Client ID is required.'; }, (0, exports.getDefaultValues)(target.name).client)];
|
|
367
367
|
case 1:
|
|
368
368
|
client = _a.sent();
|
|
369
369
|
return [2 /*return*/, { client: client }];
|
|
@@ -381,10 +381,10 @@ var getCredentialsInputSas9 = function (target, scope) { return __awaiter(void 0
|
|
|
381
381
|
name = '';
|
|
382
382
|
if (scope === targetScope_1.TargetScope.Local) {
|
|
383
383
|
result = dotenv_1.default.config({
|
|
384
|
-
path: path_1.default.join(process.projectDir, ".env."
|
|
384
|
+
path: path_1.default.join(process.projectDir, ".env.".concat(targetName))
|
|
385
385
|
});
|
|
386
386
|
if (result.error) {
|
|
387
|
-
process.logger.info("A .env."
|
|
387
|
+
process.logger.info("A .env.".concat(targetName, " file does not exist. It will be created."));
|
|
388
388
|
}
|
|
389
389
|
else {
|
|
390
390
|
name = process.env.SAS_USERNAME;
|
|
@@ -393,10 +393,10 @@ var getCredentialsInputSas9 = function (target, scope) { return __awaiter(void 0
|
|
|
393
393
|
else {
|
|
394
394
|
name = (_b = (_a = target.authConfigSas9) === null || _a === void 0 ? void 0 : _a.userName) !== null && _b !== void 0 ? _b : '';
|
|
395
395
|
}
|
|
396
|
-
return [4 /*yield*/, input_1.getString('Please enter your SAS username', function (v) { return !!v || 'username is required.'; }, name)];
|
|
396
|
+
return [4 /*yield*/, (0, input_1.getString)('Please enter your SAS username', function (v) { return !!v || 'username is required.'; }, name)];
|
|
397
397
|
case 1:
|
|
398
398
|
userName = _e.sent();
|
|
399
|
-
return [4 /*yield*/, input_1.getString('Please enter your SAS password', function (v) { return !!v || 'password is required.'; })];
|
|
399
|
+
return [4 /*yield*/, (0, input_1.getString)('Please enter your SAS password', function (v) { return !!v || 'password is required.'; })];
|
|
400
400
|
case 2:
|
|
401
401
|
password = _e.sent();
|
|
402
402
|
if (!/{sas00/i.test(password)) {
|
|
@@ -405,14 +405,14 @@ var getCredentialsInputSas9 = function (target, scope) { return __awaiter(void 0
|
|
|
405
405
|
else if (!/^({sas00)[3-9]/i.test(password)) {
|
|
406
406
|
(_d = process.logger) === null || _d === void 0 ? void 0 : _d.warn('This password type can be easily decrypted. Please consider {sas003} or above.');
|
|
407
407
|
}
|
|
408
|
-
password = utils_1.encodeToBase64(password);
|
|
408
|
+
password = (0, utils_1.encodeToBase64)(password);
|
|
409
409
|
return [2 /*return*/, { userName: userName, password: password }];
|
|
410
410
|
}
|
|
411
411
|
});
|
|
412
412
|
}); };
|
|
413
413
|
exports.getCredentialsInputSas9 = getCredentialsInputSas9;
|
|
414
414
|
var getDefaultValues = function (targetName) {
|
|
415
|
-
dotenv_1.default.config({ path: path_1.default.join(process.projectDir, ".env."
|
|
415
|
+
dotenv_1.default.config({ path: path_1.default.join(process.projectDir, ".env.".concat(targetName)) });
|
|
416
416
|
var defaultClient = process.env.CLIENT === 'undefined' ||
|
|
417
417
|
process.env.CLIENT === 'null' ||
|
|
418
418
|
!process.env.CLIENT
|
|
@@ -429,7 +429,7 @@ exports.getDefaultValues = getDefaultValues;
|
|
|
429
429
|
var getIsDefault = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
430
430
|
return __generator(this, function (_a) {
|
|
431
431
|
switch (_a.label) {
|
|
432
|
-
case 0: return [4 /*yield*/, input_1.getConfirmation('Would you like to set this as your default target?', false)];
|
|
432
|
+
case 0: return [4 /*yield*/, (0, input_1.getConfirmation)('Would you like to set this as your default target?', false)];
|
|
433
433
|
case 1: return [2 /*return*/, _a.sent()];
|
|
434
434
|
}
|
|
435
435
|
});
|
|
@@ -47,13 +47,13 @@ function saveConfig(scope, target, isDefault, saveWithDefaultValues) {
|
|
|
47
47
|
case 0:
|
|
48
48
|
filePath = '';
|
|
49
49
|
if (!(scope === types_1.TargetScope.Local)) return [3 /*break*/, 2];
|
|
50
|
-
return [4 /*yield*/, utils_1.saveToLocalConfig(target, isDefault, saveWithDefaultValues)];
|
|
50
|
+
return [4 /*yield*/, (0, utils_1.saveToLocalConfig)(target, isDefault, saveWithDefaultValues)];
|
|
51
51
|
case 1:
|
|
52
52
|
filePath = _a.sent();
|
|
53
53
|
return [3 /*break*/, 4];
|
|
54
54
|
case 2:
|
|
55
55
|
if (!(scope === types_1.TargetScope.Global)) return [3 /*break*/, 4];
|
|
56
|
-
return [4 /*yield*/, utils_1.saveToGlobalConfig(target, isDefault, saveWithDefaultValues)];
|
|
56
|
+
return [4 /*yield*/, (0, utils_1.saveToGlobalConfig)(target, isDefault, saveWithDefaultValues)];
|
|
57
57
|
case 3:
|
|
58
58
|
filePath = _a.sent();
|
|
59
59
|
_a.label = 4;
|