@sasjs/cli 2.39.0 → 3.0.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/commands/add/addCredential.d.ts +2 -2
- package/build/commands/add/addCredential.js +26 -28
- package/build/commands/add/internal/input.js +15 -2
- package/build/commands/build/build.js +11 -11
- package/build/commands/build/internal/config.d.ts +1 -1
- package/build/commands/build/internal/config.js +5 -6
- package/build/commands/compile/compile.js +4 -4
- package/build/commands/compile/compileCommand.js +2 -1
- package/build/commands/compile/compileSingleFile.d.ts +1 -1
- package/build/commands/compile/compileSingleFile.js +6 -7
- package/build/commands/compile/internal/compareFolders.js +1 -2
- package/build/commands/compile/internal/compileJobFile.js +1 -1
- package/build/commands/compile/internal/compileServiceFile.js +1 -1
- package/build/commands/compile/internal/compileTestFile.d.ts +0 -2
- package/build/commands/compile/internal/compileTestFile.js +11 -15
- package/build/commands/compile/internal/getAllJobFolders.js +1 -1
- package/build/commands/compile/internal/getAllServiceFolders.js +1 -1
- package/build/commands/compile/internal/loadDependencies.d.ts +2 -3
- package/build/commands/compile/internal/loadDependencies.js +43 -230
- package/build/commands/compile/internal/spec/compileTestFile.spec.js +24 -12
- package/build/commands/compile/spec/compile.spec.js +30 -0
- package/build/commands/compile/spec/compileJobFile.spec.js +3 -3
- package/build/commands/compile/spec/compileServiceFile.spec.js +3 -3
- package/build/commands/compile/spec/loadDependencies.spec.js +37 -37
- package/build/commands/context/contextCommand.js +5 -5
- package/build/commands/deploy/deploy.js +3 -3
- package/build/commands/docs/generateDocs.js +4 -5
- package/build/commands/docs/internal/getFileInputs.d.ts +1 -1
- package/build/commands/docs/internal/getFileInputs.js +2 -2
- package/build/commands/docs/internal/getFileOutputs.d.ts +1 -1
- package/build/commands/docs/internal/getFileOutputs.js +2 -2
- package/build/commands/docs/internal/getFoldersForDocs.d.ts +1 -1
- package/build/commands/docs/internal/getFoldersForDocs.js +1 -1
- package/build/commands/flow/flowCommand.js +1 -1
- package/build/commands/flow/spec/flow.spec.server.js +1 -1
- package/build/commands/folder/folderCommand.js +2 -2
- package/build/commands/folder/spec/folder.spec.server.js +1 -1
- package/build/commands/job/jobCommand.js +1 -1
- package/build/commands/job/spec/job.spec.server.js +2 -2
- package/build/commands/request/request.js +3 -3
- package/build/commands/run/run.js +3 -3
- package/build/commands/servicepack/deploy.js +1 -1
- package/build/commands/servicepack/spec/servicepack.spec.server.js +0 -1
- package/build/commands/shared/deployToSasViyaWithServicePack.js +1 -1
- package/build/commands/testing/test.js +1 -1
- package/build/commands/web/internal/getWebServiceContent.js +1 -2
- package/build/commands/web/web.js +12 -13
- package/build/config.json +3 -1
- package/build/utils/config.d.ts +1 -2
- package/build/utils/config.js +106 -66
- package/build/utils/file.d.ts +0 -6
- package/build/utils/file.js +1 -43
- package/build/utils/setConstants.js +1 -1
- package/build/utils/spec/utils.spec.js +31 -5
- package/build/utils/test.js +1 -1
- package/build/utils/utils.d.ts +0 -2
- package/build/utils/utils.js +2 -17
- package/package.json +5 -5
- package/CHANGELOG.md +0 -30
- package/build/commands/compile/internal/config.d.ts +0 -25
- package/build/commands/compile/internal/config.js +0 -259
- package/build/commands/compile/spec/getDependencyPaths.spec.d.ts +0 -1
- package/build/commands/compile/spec/getDependencyPaths.spec.js +0 -263
- package/build/commands/compile/spec/getProgramDependencies.spec.d.ts +0 -1
- package/build/commands/compile/spec/getProgramDependencies.spec.js +0 -403
- package/build/commands/shared/dependencies.d.ts +0 -12
- package/build/commands/shared/dependencies.js +0 -332
- package/build/utils/spec/utils.spec.server.d.ts +0 -1
- package/build/utils/spec/utils.spec.server.js +0 -72
|
@@ -67,7 +67,7 @@ function deployToSasViyaWithServicePack(jsonFilePath, target, isLocal, isForced)
|
|
|
67
67
|
throw new Error("Deployment failed. Request is not authenticated.\nPlease add the following variables to your .env" + (isLocal ? "." + target.name : '') + " file:\nCLIENT, SECRET, ACCESS_TOKEN, REFRESH_TOKEN");
|
|
68
68
|
}
|
|
69
69
|
sasjs = new node_1.default({
|
|
70
|
-
|
|
70
|
+
httpsAgentOptions: target.httpsAgentOptions,
|
|
71
71
|
appLoc: target.appLoc,
|
|
72
72
|
serverType: target.serverType,
|
|
73
73
|
serverUrl: target.serverUrl,
|
|
@@ -144,7 +144,7 @@ function runTest(target, testRegExps, outDirectory, flowSourcePath) {
|
|
|
144
144
|
flow.push(testFlow.testTearDown);
|
|
145
145
|
sasjs = new node_1.default({
|
|
146
146
|
serverUrl: target.serverUrl,
|
|
147
|
-
|
|
147
|
+
httpsAgentOptions: target.httpsAgentOptions,
|
|
148
148
|
appLoc: target.appLoc,
|
|
149
149
|
serverType: target.serverType,
|
|
150
150
|
debug: true,
|
|
@@ -38,7 +38,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.getWebServiceContent = void 0;
|
|
40
40
|
var utils_1 = require("@sasjs/utils");
|
|
41
|
-
var utils_2 = require("../../../utils");
|
|
42
41
|
var sasjsout_1 = require("./sasjsout");
|
|
43
42
|
var getWebServiceContent = function (contentBase64, type, serverType) {
|
|
44
43
|
if (type === void 0) { type = 'JS'; }
|
|
@@ -52,7 +51,7 @@ var getWebServiceContent = function (contentBase64, type, serverType) {
|
|
|
52
51
|
};
|
|
53
52
|
serviceContent = sasjsout_1.sasjsout + "\nfilename sasjs temp lrecl=99999999;\ndata _null_;\nfile sasjs;\n";
|
|
54
53
|
lines.forEach(function (line) {
|
|
55
|
-
var chunkedLines =
|
|
54
|
+
var chunkedLines = utils_1.chunk(line);
|
|
56
55
|
if (chunkedLines.length === 1) {
|
|
57
56
|
serviceContent += "put '" + chunkedLines[0].split("'").join("''") + "';\n";
|
|
58
57
|
}
|
|
@@ -40,8 +40,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
exports.createWebAppServices = void 0;
|
|
43
|
-
var utils_1 = require("
|
|
44
|
-
var utils_2 = require("@sasjs/utils");
|
|
43
|
+
var utils_1 = require("@sasjs/utils");
|
|
45
44
|
var config_1 = require("../../utils/config");
|
|
46
45
|
var path_1 = __importDefault(require("path"));
|
|
47
46
|
var jsdom_1 = __importDefault(require("jsdom"));
|
|
@@ -85,7 +84,7 @@ function createWebAppServices(target) {
|
|
|
85
84
|
})];
|
|
86
85
|
case 5:
|
|
87
86
|
assetPathMap = _c.sent();
|
|
88
|
-
return [4 /*yield*/,
|
|
87
|
+
return [4 /*yield*/, utils_1.readFile(indexHtmlPath).then(function (content) { return new jsdom_1.default.JSDOM(content); })];
|
|
89
88
|
case 6:
|
|
90
89
|
indexHtml = _c.sent();
|
|
91
90
|
return [4 /*yield*/, updateAllTags_1.updateAllTags(indexHtml, {
|
|
@@ -96,7 +95,7 @@ function createWebAppServices(target) {
|
|
|
96
95
|
})];
|
|
97
96
|
case 7:
|
|
98
97
|
_c.sent();
|
|
99
|
-
if (!(target.serverType ===
|
|
98
|
+
if (!(target.serverType === utils_1.ServerType.SasViya)) return [3 /*break*/, 9];
|
|
100
99
|
indexHtml.window.document.body.innerHTML += adjustIframeScript_1.adjustIframeScript;
|
|
101
100
|
return [4 /*yield*/, createClickMeFile(indexHtml.serialize(), streamConfig.streamServiceName)];
|
|
102
101
|
case 8:
|
|
@@ -128,13 +127,13 @@ var validateStreamConfig = function (streamConfig) { return __awaiter(void 0, vo
|
|
|
128
127
|
throw new Error("Invalid stream web folder: Please specify the `streamConfig` in your target in the following format: \n " + JSON.stringify(exampleStreamConfig, null, 2));
|
|
129
128
|
}
|
|
130
129
|
webSourcePathFull = utils_1.getAbsolutePath(streamConfig.webSourcePath, process.projectDir);
|
|
131
|
-
return [4 /*yield*/,
|
|
130
|
+
return [4 /*yield*/, utils_1.folderExists(webSourcePathFull)];
|
|
132
131
|
case 1:
|
|
133
132
|
if (!(_a.sent())) {
|
|
134
133
|
throw new Error("webSourcePath: '" + webSourcePathFull + "' present in 'streamConfig' doesn't exist.");
|
|
135
134
|
}
|
|
136
135
|
indexHtmlPath = path_1.default.join(webSourcePathFull, 'index.html');
|
|
137
|
-
return [4 /*yield*/,
|
|
136
|
+
return [4 /*yield*/, utils_1.fileExists(indexHtmlPath)];
|
|
138
137
|
case 2:
|
|
139
138
|
if (!(_a.sent())) {
|
|
140
139
|
throw new Error("'index.html' doesn't exist at webSourcePath: '" + webSourcePathFull + "' present in 'streamConfig'");
|
|
@@ -150,11 +149,11 @@ function createBuildDestinationFolder() {
|
|
|
150
149
|
switch (_a.label) {
|
|
151
150
|
case 0:
|
|
152
151
|
buildDestinationFolder = process.sasjsConstants.buildDestinationFolder;
|
|
153
|
-
return [4 /*yield*/,
|
|
152
|
+
return [4 /*yield*/, utils_1.fileExists(buildDestinationFolder)];
|
|
154
153
|
case 1:
|
|
155
154
|
pathExists = _a.sent();
|
|
156
155
|
if (!!pathExists) return [3 /*break*/, 3];
|
|
157
|
-
return [4 /*yield*/,
|
|
156
|
+
return [4 /*yield*/, utils_1.createFolder(buildDestinationFolder)];
|
|
158
157
|
case 2:
|
|
159
158
|
_a.sent();
|
|
160
159
|
_a.label = 3;
|
|
@@ -168,15 +167,15 @@ function createTargetDestinationFolder(destinationPath) {
|
|
|
168
167
|
var pathExists;
|
|
169
168
|
return __generator(this, function (_a) {
|
|
170
169
|
switch (_a.label) {
|
|
171
|
-
case 0: return [4 /*yield*/,
|
|
170
|
+
case 0: return [4 /*yield*/, utils_1.fileExists(destinationPath)];
|
|
172
171
|
case 1:
|
|
173
172
|
pathExists = _a.sent();
|
|
174
173
|
if (!pathExists) return [3 /*break*/, 3];
|
|
175
|
-
return [4 /*yield*/,
|
|
174
|
+
return [4 /*yield*/, utils_1.deleteFolder(destinationPath)];
|
|
176
175
|
case 2:
|
|
177
176
|
_a.sent();
|
|
178
177
|
_a.label = 3;
|
|
179
|
-
case 3: return [4 /*yield*/,
|
|
178
|
+
case 3: return [4 /*yield*/, utils_1.createFolder(destinationPath)];
|
|
180
179
|
case 4:
|
|
181
180
|
_a.sent();
|
|
182
181
|
return [2 /*return*/];
|
|
@@ -218,7 +217,7 @@ function createClickMeService(indexHtmlContent, fileName) {
|
|
|
218
217
|
});
|
|
219
218
|
clickMeServiceContent += 'run;\n%sasjsout(HTML)';
|
|
220
219
|
buildDestinationServicesFolder = process.sasjsConstants.buildDestinationServicesFolder;
|
|
221
|
-
return [4 /*yield*/,
|
|
220
|
+
return [4 /*yield*/, utils_1.createFile(path_1.default.join(buildDestinationServicesFolder, fileName + ".sas"), clickMeServiceContent)];
|
|
222
221
|
case 1:
|
|
223
222
|
_a.sent();
|
|
224
223
|
return [2 /*return*/];
|
|
@@ -233,7 +232,7 @@ function createClickMeFile(indexHtmlContent, fileName) {
|
|
|
233
232
|
switch (_a.label) {
|
|
234
233
|
case 0:
|
|
235
234
|
buildDestinationServicesFolder = process.sasjsConstants.buildDestinationServicesFolder;
|
|
236
|
-
return [4 /*yield*/,
|
|
235
|
+
return [4 /*yield*/, utils_1.createFile(path_1.default.join(buildDestinationServicesFolder, fileName + ".html"), indexHtmlContent)];
|
|
237
236
|
case 1:
|
|
238
237
|
_a.sent();
|
|
239
238
|
return [2 /*return*/];
|
package/build/config.json
CHANGED
|
@@ -241,7 +241,9 @@
|
|
|
241
241
|
"name": "viya",
|
|
242
242
|
"serverType": "SASVIYA",
|
|
243
243
|
"serverUrl": "https://sas.analytium.co.uk",
|
|
244
|
-
"
|
|
244
|
+
"httpsAgentOptions": {
|
|
245
|
+
"allowInsecureRequests": false
|
|
246
|
+
},
|
|
245
247
|
"appLoc": "/Public/app",
|
|
246
248
|
"contextName": "SAS Job Execution compute context",
|
|
247
249
|
"buildConfig": {
|
package/build/utils/config.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Configuration, Target, AuthConfig } from '@sasjs/utils';
|
|
2
|
-
import { StreamConfig } from '@sasjs/utils/types/config';
|
|
1
|
+
import { Configuration, Target, AuthConfig, StreamConfig } from '@sasjs/utils';
|
|
3
2
|
import { TargetScope } from '../types/targetScope';
|
|
4
3
|
/**
|
|
5
4
|
* Returns an object that represents the SASjs CLI configuration in a given file.
|
package/build/utils/config.js
CHANGED
|
@@ -234,26 +234,28 @@ exports.findTargetInConfiguration = findTargetInConfiguration;
|
|
|
234
234
|
function getLocalTarget(targetName) {
|
|
235
235
|
var _a;
|
|
236
236
|
return __awaiter(this, void 0, void 0, function () {
|
|
237
|
-
var localConfig, targetJson;
|
|
238
|
-
return __generator(this, function (
|
|
239
|
-
switch (
|
|
237
|
+
var localConfig, targetJson, _b;
|
|
238
|
+
return __generator(this, function (_c) {
|
|
239
|
+
switch (_c.label) {
|
|
240
240
|
case 0: return [4 /*yield*/, getConfiguration(path_1.default.join(process.projectDir, 'sasjs', 'sasjsconfig.json')).catch(function () { return null; })];
|
|
241
241
|
case 1:
|
|
242
|
-
localConfig =
|
|
243
|
-
if (localConfig === null || localConfig === void 0 ? void 0 : localConfig.targets)
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
251
|
-
targetJson.serverUrl = utils_1.urlOrigin(targetJson.serverUrl);
|
|
252
|
-
targetJson.allowInsecureRequests = getPrecedenceOfInsecureRequests(localConfig, targetJson);
|
|
253
|
-
return [2 /*return*/, new utils_1.Target(targetJson)];
|
|
254
|
-
}
|
|
242
|
+
localConfig = _c.sent();
|
|
243
|
+
if (!(localConfig === null || localConfig === void 0 ? void 0 : localConfig.targets)) return [3 /*break*/, 3];
|
|
244
|
+
targetJson = localConfig.targets.find(function (t) { return t.name === targetName; });
|
|
245
|
+
if (!targetJson) return [3 /*break*/, 3];
|
|
246
|
+
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Target " + targetName + " was found in your local sasjsconfig.json file.");
|
|
247
|
+
targetJson.appLoc = sanitizeAppLoc(targetJson.appLoc);
|
|
248
|
+
if (!targetJson.hasOwnProperty('serverUrl')) {
|
|
249
|
+
targetJson.serverUrl = '';
|
|
255
250
|
}
|
|
256
|
-
|
|
251
|
+
targetJson.serverUrl = utils_1.urlOrigin(targetJson.serverUrl);
|
|
252
|
+
_b = targetJson;
|
|
253
|
+
return [4 /*yield*/, getPrecedenceOfHttpsAgentOptionsAndContent(localConfig, targetJson)];
|
|
254
|
+
case 2:
|
|
255
|
+
_b.httpsAgentOptions =
|
|
256
|
+
_c.sent();
|
|
257
|
+
return [2 /*return*/, new utils_1.Target(targetJson)];
|
|
258
|
+
case 3: throw new Error(ERROR_MESSAGE(targetName).NOT_FOUND_TARGET_NAME);
|
|
257
259
|
}
|
|
258
260
|
});
|
|
259
261
|
});
|
|
@@ -261,31 +263,34 @@ function getLocalTarget(targetName) {
|
|
|
261
263
|
function getLocalFallbackTarget() {
|
|
262
264
|
var _a, _b;
|
|
263
265
|
return __awaiter(this, void 0, void 0, function () {
|
|
264
|
-
var localConfig, fallBackTargetJson, defaultTargetName_1;
|
|
265
|
-
return __generator(this, function (
|
|
266
|
-
switch (
|
|
266
|
+
var localConfig, fallBackTargetJson, defaultTargetName_1, _c;
|
|
267
|
+
return __generator(this, function (_d) {
|
|
268
|
+
switch (_d.label) {
|
|
267
269
|
case 0: return [4 /*yield*/, getConfiguration(path_1.default.join(process.projectDir, 'sasjs', 'sasjsconfig.json')).catch(function () { return null; })];
|
|
268
270
|
case 1:
|
|
269
|
-
localConfig =
|
|
270
|
-
if (!(localConfig === null || localConfig === void 0 ? void 0 : localConfig.targets)) return [3 /*break*/,
|
|
271
|
+
localConfig = _d.sent();
|
|
272
|
+
if (!(localConfig === null || localConfig === void 0 ? void 0 : localConfig.targets)) return [3 /*break*/, 4];
|
|
271
273
|
defaultTargetName_1 = localConfig === null || localConfig === void 0 ? void 0 : localConfig.defaultTarget;
|
|
272
274
|
if (defaultTargetName_1) {
|
|
273
275
|
fallBackTargetJson = (_a = localConfig === null || localConfig === void 0 ? void 0 : localConfig.targets) === null || _a === void 0 ? void 0 : _a.find(function (t) { return t.name === defaultTargetName_1; });
|
|
274
276
|
}
|
|
275
|
-
if (!fallBackTargetJson) return [3 /*break*/,
|
|
277
|
+
if (!fallBackTargetJson) return [3 /*break*/, 4];
|
|
276
278
|
(_b = process.logger) === null || _b === void 0 ? void 0 : _b.info("No target was specified. Falling back to default target '" + fallBackTargetJson.name + "' from your local sasjsconfig.json file.");
|
|
277
279
|
fallBackTargetJson.appLoc = sanitizeAppLoc(fallBackTargetJson.appLoc);
|
|
278
280
|
if (!fallBackTargetJson.hasOwnProperty('serverUrl')) {
|
|
279
281
|
fallBackTargetJson.serverUrl = '';
|
|
280
282
|
}
|
|
281
283
|
fallBackTargetJson.serverUrl = utils_1.urlOrigin(fallBackTargetJson.serverUrl);
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
return [4 /*yield*/, utils_2.loadEnvVariables(".env." + fallBackTargetJson.name)];
|
|
284
|
+
_c = fallBackTargetJson;
|
|
285
|
+
return [4 /*yield*/, getPrecedenceOfHttpsAgentOptionsAndContent(localConfig, fallBackTargetJson)];
|
|
285
286
|
case 2:
|
|
286
|
-
_c.
|
|
287
|
+
_c.httpsAgentOptions =
|
|
288
|
+
_d.sent();
|
|
289
|
+
return [4 /*yield*/, utils_2.loadEnvVariables(".env." + fallBackTargetJson.name)];
|
|
290
|
+
case 3:
|
|
291
|
+
_d.sent();
|
|
287
292
|
return [2 /*return*/, new utils_1.Target(fallBackTargetJson)];
|
|
288
|
-
case
|
|
293
|
+
case 4: throw new Error(ERROR_MESSAGE().NOT_FOUND_FALLBACK);
|
|
289
294
|
}
|
|
290
295
|
});
|
|
291
296
|
});
|
|
@@ -293,26 +298,28 @@ function getLocalFallbackTarget() {
|
|
|
293
298
|
function getGlobalTarget(targetName) {
|
|
294
299
|
var _a;
|
|
295
300
|
return __awaiter(this, void 0, void 0, function () {
|
|
296
|
-
var globalConfig, targetJson;
|
|
297
|
-
return __generator(this, function (
|
|
298
|
-
switch (
|
|
301
|
+
var globalConfig, targetJson, _b;
|
|
302
|
+
return __generator(this, function (_c) {
|
|
303
|
+
switch (_c.label) {
|
|
299
304
|
case 0: return [4 /*yield*/, getGlobalRcFile()];
|
|
300
305
|
case 1:
|
|
301
|
-
globalConfig =
|
|
302
|
-
if (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.targets)
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
}
|
|
310
|
-
targetJson.serverUrl = utils_1.urlOrigin(targetJson.serverUrl);
|
|
311
|
-
targetJson.allowInsecureRequests = getPrecedenceOfInsecureRequests(globalConfig, targetJson);
|
|
312
|
-
return [2 /*return*/, new utils_1.Target(targetJson)];
|
|
313
|
-
}
|
|
306
|
+
globalConfig = _c.sent();
|
|
307
|
+
if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.targets)) return [3 /*break*/, 3];
|
|
308
|
+
targetJson = globalConfig.targets.find(function (t) { return t.name === targetName; });
|
|
309
|
+
if (!targetJson) return [3 /*break*/, 3];
|
|
310
|
+
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Target " + targetName + " was found in your global .sasjsrc file.");
|
|
311
|
+
targetJson.appLoc = sanitizeAppLoc(targetJson.appLoc);
|
|
312
|
+
if (!targetJson.hasOwnProperty('serverUrl')) {
|
|
313
|
+
targetJson.serverUrl = '';
|
|
314
314
|
}
|
|
315
|
-
|
|
315
|
+
targetJson.serverUrl = utils_1.urlOrigin(targetJson.serverUrl);
|
|
316
|
+
_b = targetJson;
|
|
317
|
+
return [4 /*yield*/, getPrecedenceOfHttpsAgentOptionsAndContent(globalConfig, targetJson)];
|
|
318
|
+
case 2:
|
|
319
|
+
_b.httpsAgentOptions =
|
|
320
|
+
_c.sent();
|
|
321
|
+
return [2 /*return*/, new utils_1.Target(targetJson)];
|
|
322
|
+
case 3: throw new Error(ERROR_MESSAGE(targetName).NOT_FOUND_TARGET_NAME);
|
|
316
323
|
}
|
|
317
324
|
});
|
|
318
325
|
});
|
|
@@ -320,27 +327,30 @@ function getGlobalTarget(targetName) {
|
|
|
320
327
|
function getGlobalFallbackTarget() {
|
|
321
328
|
var _a, _b;
|
|
322
329
|
return __awaiter(this, void 0, void 0, function () {
|
|
323
|
-
var globalConfig, fallBackTargetJson, defaultTargetName;
|
|
324
|
-
return __generator(this, function (
|
|
325
|
-
switch (
|
|
330
|
+
var globalConfig, fallBackTargetJson, defaultTargetName, _c;
|
|
331
|
+
return __generator(this, function (_d) {
|
|
332
|
+
switch (_d.label) {
|
|
326
333
|
case 0: return [4 /*yield*/, getGlobalRcFile()];
|
|
327
334
|
case 1:
|
|
328
|
-
globalConfig = (
|
|
335
|
+
globalConfig = (_d.sent());
|
|
329
336
|
defaultTargetName = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.defaultTarget;
|
|
330
337
|
if (defaultTargetName) {
|
|
331
338
|
fallBackTargetJson = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.targets) === null || _a === void 0 ? void 0 : _a.find(function (t) { return t.name === defaultTargetName; });
|
|
332
339
|
}
|
|
333
|
-
if (fallBackTargetJson)
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
}
|
|
339
|
-
fallBackTargetJson.serverUrl = utils_1.urlOrigin(fallBackTargetJson.serverUrl);
|
|
340
|
-
fallBackTargetJson.allowInsecureRequests = getPrecedenceOfInsecureRequests(globalConfig, fallBackTargetJson);
|
|
341
|
-
return [2 /*return*/, new utils_1.Target(fallBackTargetJson)];
|
|
340
|
+
if (!fallBackTargetJson) return [3 /*break*/, 3];
|
|
341
|
+
(_b = process.logger) === null || _b === void 0 ? void 0 : _b.info("No target was specified. Falling back to default target '" + fallBackTargetJson.name + "' from your global .sasjsrc file.");
|
|
342
|
+
fallBackTargetJson.appLoc = sanitizeAppLoc(fallBackTargetJson.appLoc);
|
|
343
|
+
if (!fallBackTargetJson.hasOwnProperty('serverUrl')) {
|
|
344
|
+
fallBackTargetJson.serverUrl = '';
|
|
342
345
|
}
|
|
343
|
-
|
|
346
|
+
fallBackTargetJson.serverUrl = utils_1.urlOrigin(fallBackTargetJson.serverUrl);
|
|
347
|
+
_c = fallBackTargetJson;
|
|
348
|
+
return [4 /*yield*/, getPrecedenceOfHttpsAgentOptionsAndContent(globalConfig, fallBackTargetJson)];
|
|
349
|
+
case 2:
|
|
350
|
+
_c.httpsAgentOptions =
|
|
351
|
+
_d.sent();
|
|
352
|
+
return [2 /*return*/, new utils_1.Target(fallBackTargetJson)];
|
|
353
|
+
case 3: throw new Error(ERROR_MESSAGE().NOT_FOUND_FALLBACK);
|
|
344
354
|
}
|
|
345
355
|
});
|
|
346
356
|
});
|
|
@@ -623,7 +633,7 @@ function getProgramFolders(target) {
|
|
|
623
633
|
}
|
|
624
634
|
buildSourceFolder = process.sasjsConstants.buildSourceFolder;
|
|
625
635
|
programFolders = programFolders.map(function (programFolder) {
|
|
626
|
-
return
|
|
636
|
+
return utils_1.getAbsolutePath(programFolder, buildSourceFolder);
|
|
627
637
|
});
|
|
628
638
|
return [2 /*return*/, __spreadArray([], __read(new Set(programFolders)))];
|
|
629
639
|
}
|
|
@@ -654,7 +664,7 @@ function getMacroFolders(target) {
|
|
|
654
664
|
}
|
|
655
665
|
buildSourceFolder = process.sasjsConstants.buildSourceFolder;
|
|
656
666
|
macroFolders = macroFolders.map(function (macroFolder) {
|
|
657
|
-
return
|
|
667
|
+
return utils_1.getAbsolutePath(macroFolder, buildSourceFolder);
|
|
658
668
|
});
|
|
659
669
|
return [2 /*return*/, __spreadArray([], __read(new Set(macroFolders)))];
|
|
660
670
|
}
|
|
@@ -798,7 +808,7 @@ function getAuthConfig(target) {
|
|
|
798
808
|
if (!auth_1.isAccessTokenExpiring(access_token)) return [3 /*break*/, 7];
|
|
799
809
|
sasjs = new node_1.default({
|
|
800
810
|
serverUrl: target.serverUrl,
|
|
801
|
-
|
|
811
|
+
httpsAgentOptions: target.httpsAgentOptions,
|
|
802
812
|
serverType: target.serverType
|
|
803
813
|
});
|
|
804
814
|
if (!auth_1.isRefreshTokenExpiring(refresh_token)) return [3 /*break*/, 4];
|
|
@@ -866,7 +876,7 @@ function getAccessToken(target, checkIfExpiring) {
|
|
|
866
876
|
if (!(checkIfExpiring && auth_1.isAccessTokenExpiring(accessToken))) return [3 /*break*/, 7];
|
|
867
877
|
sasjs = new node_1.default({
|
|
868
878
|
serverUrl: target.serverUrl,
|
|
869
|
-
|
|
879
|
+
httpsAgentOptions: target.httpsAgentOptions,
|
|
870
880
|
serverType: target.serverType
|
|
871
881
|
});
|
|
872
882
|
client = target.authConfig && target.authConfig.client
|
|
@@ -947,9 +957,39 @@ var overrideEnvVariables = function (targetName) { return __awaiter(void 0, void
|
|
|
947
957
|
});
|
|
948
958
|
}); };
|
|
949
959
|
exports.overrideEnvVariables = overrideEnvVariables;
|
|
950
|
-
var
|
|
951
|
-
var _a;
|
|
952
|
-
return (
|
|
960
|
+
var getPrecedenceOfHttpsAgentOptionsAndContent = function (config, target) { return __awaiter(void 0, void 0, void 0, function () {
|
|
961
|
+
var httpsAgentOptions, _a, _b, _c;
|
|
962
|
+
return __generator(this, function (_d) {
|
|
963
|
+
switch (_d.label) {
|
|
964
|
+
case 0:
|
|
965
|
+
httpsAgentOptions = getHttpsAgentOptionsForInsecure(__assign(__assign({ allowInsecureRequests: false }, config.httpsAgentOptions), target.httpsAgentOptions));
|
|
966
|
+
if (!httpsAgentOptions.caPath) return [3 /*break*/, 2];
|
|
967
|
+
_a = httpsAgentOptions;
|
|
968
|
+
return [4 /*yield*/, utils_1.readFile(httpsAgentOptions.caPath)];
|
|
969
|
+
case 1:
|
|
970
|
+
_a.ca = _d.sent();
|
|
971
|
+
_d.label = 2;
|
|
972
|
+
case 2:
|
|
973
|
+
if (!httpsAgentOptions.keyPath) return [3 /*break*/, 4];
|
|
974
|
+
_b = httpsAgentOptions;
|
|
975
|
+
return [4 /*yield*/, utils_1.readFile(httpsAgentOptions.keyPath)];
|
|
976
|
+
case 3:
|
|
977
|
+
_b.key = _d.sent();
|
|
978
|
+
_d.label = 4;
|
|
979
|
+
case 4:
|
|
980
|
+
if (!httpsAgentOptions.certPath) return [3 /*break*/, 6];
|
|
981
|
+
_c = httpsAgentOptions;
|
|
982
|
+
return [4 /*yield*/, utils_1.readFile(httpsAgentOptions.certPath)];
|
|
983
|
+
case 5:
|
|
984
|
+
_c.cert = _d.sent();
|
|
985
|
+
_d.label = 6;
|
|
986
|
+
case 6: return [2 /*return*/, httpsAgentOptions];
|
|
987
|
+
}
|
|
988
|
+
});
|
|
989
|
+
}); };
|
|
990
|
+
var getHttpsAgentOptionsForInsecure = function (options) {
|
|
991
|
+
return options.allowInsecureRequests
|
|
992
|
+
? __assign({ rejectUnauthorized: false }, options) : options;
|
|
953
993
|
};
|
|
954
994
|
var getTestSetUp = function (target) { return __awaiter(void 0, void 0, void 0, function () {
|
|
955
995
|
var projectRoot, localConfig;
|
package/build/utils/file.d.ts
CHANGED
|
@@ -4,12 +4,6 @@ export function isSasFile(filePath: any): boolean;
|
|
|
4
4
|
export function isJsonFile(filePath: any): boolean;
|
|
5
5
|
export function isCsvFile(filePath: any): boolean;
|
|
6
6
|
export function isShellScript(filePath: any): boolean;
|
|
7
|
-
/**
|
|
8
|
-
* Gets a list of @li items from the supplied file content with the specified header.
|
|
9
|
-
* @param {string} listHeader - the header of the section to look for - e.g. <h4> SAS Macros </h4>.
|
|
10
|
-
* @param {string} fileContent - the text content of the file.
|
|
11
|
-
*/
|
|
12
|
-
export function getList(listHeader: string, fileContent: string): any[];
|
|
13
7
|
export function getBrief(fileContent: any): any;
|
|
14
8
|
export function getRelativePath(from: any, to: any): any[];
|
|
15
9
|
export function saveToDefaultLocation(filePath: any, data: any): Promise<{
|
package/build/utils/file.js
CHANGED
|
@@ -39,7 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.sasFileRegExp = exports.saveToDefaultLocation = exports.getRelativePath = exports.getBrief = exports.
|
|
42
|
+
exports.sasFileRegExp = exports.saveToDefaultLocation = exports.getRelativePath = exports.getBrief = exports.sanitizeFileName = exports.isShellScript = exports.isCsvFile = exports.isJsonFile = exports.isSasFile = exports.unifyFilePath = exports.createFolderStructure = void 0;
|
|
43
43
|
var path_1 = __importDefault(require("path"));
|
|
44
44
|
var utils_1 = require("@sasjs/utils");
|
|
45
45
|
var config_1 = require("./config");
|
|
@@ -129,48 +129,6 @@ var sanitizeFileName = function (fileName) {
|
|
|
129
129
|
return fileName.replace(/[^a-z0-9]/gi, '_');
|
|
130
130
|
};
|
|
131
131
|
exports.sanitizeFileName = sanitizeFileName;
|
|
132
|
-
/**
|
|
133
|
-
* Gets a list of @li items from the supplied file content with the specified header.
|
|
134
|
-
* @param {string} listHeader - the header of the section to look for - e.g. <h4> SAS Macros </h4>.
|
|
135
|
-
* @param {string} fileContent - the text content of the file.
|
|
136
|
-
*/
|
|
137
|
-
function getList(listHeader, fileContent) {
|
|
138
|
-
var _a;
|
|
139
|
-
var fileHeader;
|
|
140
|
-
try {
|
|
141
|
-
var hasFileHeader = fileContent.split('/**')[0] !== fileContent;
|
|
142
|
-
if (!hasFileHeader)
|
|
143
|
-
return [];
|
|
144
|
-
fileHeader = fileContent.split('/**')[1].split('**/')[0];
|
|
145
|
-
}
|
|
146
|
-
catch (e) {
|
|
147
|
-
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('File header parse error.\nPlease make sure your file header is in the correct format.');
|
|
148
|
-
}
|
|
149
|
-
var list = [];
|
|
150
|
-
var lines = fileHeader.split('\n').map(function (s) { return (s ? s.trim() : s); });
|
|
151
|
-
var startIndex = null;
|
|
152
|
-
var endIndex = null;
|
|
153
|
-
for (var i = 0; i < lines.length; i++) {
|
|
154
|
-
if (new RegExp(listHeader, 'i').test(lines[i])) {
|
|
155
|
-
startIndex = i + 1;
|
|
156
|
-
break;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
for (var i = startIndex; i < lines.length; i++) {
|
|
160
|
-
if (!lines[i]) {
|
|
161
|
-
endIndex = i;
|
|
162
|
-
break;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
for (var i = startIndex; i < endIndex; i++) {
|
|
166
|
-
list.push(lines[i]);
|
|
167
|
-
}
|
|
168
|
-
return list
|
|
169
|
-
.filter(function (l) { return l.startsWith('@li'); })
|
|
170
|
-
.map(function (d) { return d.replace(/\@li/g, ''); })
|
|
171
|
-
.map(function (d) { return d.trim(); });
|
|
172
|
-
}
|
|
173
|
-
exports.getList = getList;
|
|
174
132
|
function getBrief(fileContent) {
|
|
175
133
|
var fileHeader;
|
|
176
134
|
try {
|
|
@@ -43,7 +43,7 @@ exports.setConstants = exports.contextName = void 0;
|
|
|
43
43
|
var path_1 = __importDefault(require("path"));
|
|
44
44
|
var get_installed_path_1 = require("get-installed-path");
|
|
45
45
|
var config_1 = require("./config");
|
|
46
|
-
var utils_1 = require("
|
|
46
|
+
var utils_1 = require("@sasjs/utils");
|
|
47
47
|
exports.contextName = 'sasjs cli compute context';
|
|
48
48
|
var setConstants = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
49
49
|
var _a, configuration, isLocal, buildOutputFolder, buildResultsFolder, homeDir, getMacroCoreGlobalPath, buildSourceFolder, buildSourceDbFolder, buildDestinationFolder, buildDestinationServicesFolder, buildDestinationTestFolder, buildDestinationJobsFolder, buildDestinationDbFolder, buildDestinationDocsFolder, macroCorePath, _b, buildDestinationResultsFolder, buildDestinationResultsLogsFolder, sas9CredentialsError, invalidSasError;
|
|
@@ -235,11 +235,11 @@ describe('utils', function () {
|
|
|
235
235
|
describe('chunk', function () {
|
|
236
236
|
it('should return an array with only one element that is equal to text itself if text size is less than max length', function () {
|
|
237
237
|
var txt = '0B0pFTOzHXyRuikRydwnd8uQdwvITllwNOX20vQLsT0JgkXa1W';
|
|
238
|
-
expect(
|
|
238
|
+
expect(utils_2.chunk(txt)[0]).toBe(txt);
|
|
239
239
|
});
|
|
240
240
|
it('should return an array with 3 elements', function () {
|
|
241
241
|
var txt = 'SGmqg3pnHCJn0iPQC4Rd9AnFS3k5V7dDc81GlF6lCCurmsEJq7VS\nig42yjxerV7OAjE1HIOgJZXqID30\nkaVJsCwWrtFEIL8mQepjp4zLGeCaWk7ymu9BqolSnqA3udaiWuHcm6m80E36mWYWU0lITAgdp1QzVwIczpopXRaUWtJamiPnHyflksdNEXkboKlAT5RuR795ShUOc6KajQZ1qH2ZGJPV2DxjEqtXA9uvNbpisOVY6MpRdEzWNgdDsXlfuXkrBk5RqA7PkdtjBtNHA7JtEklTnYKrOdge03qFXKjh';
|
|
242
|
-
expect(
|
|
242
|
+
expect(utils_2.chunk(txt)).toBeArrayOfSize(3);
|
|
243
243
|
});
|
|
244
244
|
});
|
|
245
245
|
describe('arrToObj', function () {
|
|
@@ -307,18 +307,18 @@ describe('utils', function () {
|
|
|
307
307
|
var relativePath = './my-path/xyz';
|
|
308
308
|
var pathRelativeTo = '/home/abc';
|
|
309
309
|
var expectedAbsolutePath = ['', 'home', 'abc', 'my-path', 'xyz'].join(path_1.default.sep);
|
|
310
|
-
expect(
|
|
310
|
+
expect(utils_2.getAbsolutePath(relativePath, pathRelativeTo)).toEqual(expectedAbsolutePath);
|
|
311
311
|
});
|
|
312
312
|
it('should convert tilde from absolute path', function () {
|
|
313
313
|
var relativePath = '~/my-path/xyz';
|
|
314
314
|
var expectedAbsolutePath = homedir + ['', 'my-path', 'xyz'].join(path_1.default.sep);
|
|
315
|
-
expect(
|
|
315
|
+
expect(utils_2.getAbsolutePath(relativePath, '')).toEqual(expectedAbsolutePath);
|
|
316
316
|
});
|
|
317
317
|
it('should return same path if path is absolute', function () {
|
|
318
318
|
var absolutePath = '/my-path/xyz';
|
|
319
319
|
var pathRelativeTo = '/home/abc';
|
|
320
320
|
var expectedAbsolutePath = ['', 'my-path', 'xyz'].join(path_1.default.sep);
|
|
321
|
-
expect(
|
|
321
|
+
expect(utils_2.getAbsolutePath(absolutePath, pathRelativeTo)).toEqual(expectedAbsolutePath);
|
|
322
322
|
});
|
|
323
323
|
});
|
|
324
324
|
describe('loadEnvVariables', function () {
|
|
@@ -359,4 +359,30 @@ describe('utils', function () {
|
|
|
359
359
|
});
|
|
360
360
|
}); });
|
|
361
361
|
});
|
|
362
|
+
describe('createReactApp', function () {
|
|
363
|
+
it('should create React app', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
364
|
+
var reactFolder, reactFolderPath, sasjsFolderPath;
|
|
365
|
+
return __generator(this, function (_a) {
|
|
366
|
+
switch (_a.label) {
|
|
367
|
+
case 0:
|
|
368
|
+
reactFolder = 'react-seed-app';
|
|
369
|
+
reactFolderPath = path_1.default.join(__dirname, reactFolder);
|
|
370
|
+
sasjsFolderPath = path_1.default.join(reactFolderPath, 'sasjs');
|
|
371
|
+
return [4 /*yield*/, utils_2.createFolder(reactFolderPath)];
|
|
372
|
+
case 1:
|
|
373
|
+
_a.sent();
|
|
374
|
+
return [4 /*yield*/, expect(utils_1.createReactApp(reactFolderPath)).toResolve()];
|
|
375
|
+
case 2:
|
|
376
|
+
_a.sent();
|
|
377
|
+
return [4 /*yield*/, expect(utils_2.folderExists(sasjsFolderPath)).resolves.toEqual(true)];
|
|
378
|
+
case 3:
|
|
379
|
+
_a.sent();
|
|
380
|
+
return [4 /*yield*/, utils_2.deleteFolder(reactFolderPath)];
|
|
381
|
+
case 4:
|
|
382
|
+
_a.sent();
|
|
383
|
+
return [2 /*return*/];
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
}); }, 600000);
|
|
387
|
+
});
|
|
362
388
|
});
|
package/build/utils/test.js
CHANGED
|
@@ -147,7 +147,7 @@ var removeTestServerFolder = function (folderPath, target) { return __awaiter(vo
|
|
|
147
147
|
}
|
|
148
148
|
sasjs = new node_1.default({
|
|
149
149
|
serverUrl: target.serverUrl,
|
|
150
|
-
|
|
150
|
+
httpsAgentOptions: target.httpsAgentOptions,
|
|
151
151
|
appLoc: target.appLoc,
|
|
152
152
|
serverType: target.serverType
|
|
153
153
|
});
|
package/build/utils/utils.d.ts
CHANGED
|
@@ -18,7 +18,6 @@ export declare function setupDoxygen(folderPath: string): Promise<void>;
|
|
|
18
18
|
export declare function removeComments(text: string): string;
|
|
19
19
|
export declare function getUniqServicesObj(services: string[]): any;
|
|
20
20
|
export declare function executeShellScript(filePath: string, logFilePath: string): Promise<unknown>;
|
|
21
|
-
export declare function chunk(text: string, maxLength?: number): string[];
|
|
22
21
|
/**
|
|
23
22
|
* Extracts plain text job log from fetched json log
|
|
24
23
|
* @param {object} logJson
|
|
@@ -33,7 +32,6 @@ export declare const millisecondsToDdHhMmSs: (milliseconds: number) => string;
|
|
|
33
32
|
export declare function checkNodeVersion(): void;
|
|
34
33
|
export declare function getAdapterInstance(target: Target): SASjs;
|
|
35
34
|
export declare function displaySasjsRunnerError(username: string): void;
|
|
36
|
-
export declare const getAbsolutePath: (providedPath: string, relativePath: string) => string;
|
|
37
35
|
export declare const loadEnvVariables: (fileName: string) => Promise<void>;
|
|
38
36
|
export declare function prefixAppLoc(appLoc?: string, path?: string): string | null;
|
|
39
37
|
export declare const isWindows: () => boolean;
|