@sasjs/cli 3.12.5 → 3.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cli.js +3 -3
- package/build/commands/add/addCredential.js +26 -2
- package/build/commands/build/build.js +12 -10
- package/build/commands/compile/internal/compileServiceFile.js +1 -2
- package/build/commands/deploy/deployCommand.js +1 -1
- package/build/utils/config.d.ts +0 -1
- package/build/utils/config.js +35 -32
- package/build/utils/setConstants.js +14 -38
- package/build/utils/spec/setConstants.spec.js +18 -16
- package/build/utils/utils.d.ts +1 -0
- package/build/utils/utils.js +22 -1
- package/package.json +4 -5
package/build/cli.js
CHANGED
|
@@ -48,13 +48,13 @@ function cli(args) {
|
|
|
48
48
|
case 0: return [4 /*yield*/, (0, utils_1.setProjectDir)(args)];
|
|
49
49
|
case 1:
|
|
50
50
|
_a.sent();
|
|
51
|
-
return [4 /*yield*/, (
|
|
51
|
+
return [4 /*yield*/, instantiateLogger()];
|
|
52
52
|
case 2:
|
|
53
53
|
_a.sent();
|
|
54
|
-
return [4 /*yield*/, (0, utils_1.
|
|
54
|
+
return [4 /*yield*/, (0, utils_1.setConstants)()];
|
|
55
55
|
case 3:
|
|
56
56
|
_a.sent();
|
|
57
|
-
return [4 /*yield*/,
|
|
57
|
+
return [4 /*yield*/, (0, utils_1.loadProjectEnvVariables)()];
|
|
58
58
|
case 4:
|
|
59
59
|
_a.sent();
|
|
60
60
|
command = (0, parse_1.parse)(args);
|
|
@@ -10,6 +10,25 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
+
if (mod && mod.__esModule) return mod;
|
|
27
|
+
var result = {};
|
|
28
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
+
__setModuleDefault(result, mod);
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
13
32
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
33
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
34
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -54,7 +73,7 @@ exports.createEnvFileForSasjs = exports.createEnvFileForSas9 = exports.createEnv
|
|
|
54
73
|
var path_1 = __importDefault(require("path"));
|
|
55
74
|
var logger_1 = require("@sasjs/utils/logger");
|
|
56
75
|
var types_1 = require("@sasjs/utils/types");
|
|
57
|
-
var node_1 =
|
|
76
|
+
var node_1 = __importStar(require("@sasjs/adapter/node"));
|
|
58
77
|
var auth_1 = require("../../utils/auth");
|
|
59
78
|
var utils_1 = require("@sasjs/utils");
|
|
60
79
|
var input_1 = require("./internal/input");
|
|
@@ -174,7 +193,12 @@ var getTokens = function (target, client, secret, httpsAgentOptions) { return __
|
|
|
174
193
|
});
|
|
175
194
|
return [4 /*yield*/, (0, auth_1.getNewAccessToken)(adapter, client, secret, target).catch(function (e) {
|
|
176
195
|
var _a;
|
|
177
|
-
|
|
196
|
+
var errorMessage = "An error has occurred while validating your credentials: ".concat(e);
|
|
197
|
+
var checkCredentialsMessage = "Please check your Client ID ".concat(target.serverType === types_1.ServerType.Sasjs ? '' : 'and Client Secret ', "and try again.\n");
|
|
198
|
+
var errorMessageToDisplay = e instanceof node_1.CertificateError
|
|
199
|
+
? errorMessage
|
|
200
|
+
: "".concat(errorMessage, "\n").concat(checkCredentialsMessage);
|
|
201
|
+
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.error(errorMessageToDisplay);
|
|
178
202
|
throw e;
|
|
179
203
|
})];
|
|
180
204
|
case 1:
|
|
@@ -144,7 +144,7 @@ function createFinalSasFiles(target) {
|
|
|
144
144
|
return [4 /*yield*/, (0, config_2.getBuildTerm)(target)];
|
|
145
145
|
case 5:
|
|
146
146
|
buildTerm = _j.sent();
|
|
147
|
-
macroCorePath =
|
|
147
|
+
macroCorePath = process.sasjsConstants.macroCorePath;
|
|
148
148
|
return [4 /*yield*/, (0, utils_1.getDependencyPaths)("".concat(buildTerm, "\n").concat(buildInit), macroFolders, macroCorePath)];
|
|
149
149
|
case 6:
|
|
150
150
|
dependencyFilePaths = _j.sent();
|
|
@@ -205,7 +205,7 @@ function getBuildInfo(target, streamWeb) {
|
|
|
205
205
|
return [4 /*yield*/, getCreateWebServiceScript(serverType)];
|
|
206
206
|
case 2:
|
|
207
207
|
createWebServiceScript = _a.sent();
|
|
208
|
-
macroCorePath =
|
|
208
|
+
macroCorePath = process.sasjsConstants.macroCorePath;
|
|
209
209
|
buildConfig += "".concat(createWebServiceScript, "\n");
|
|
210
210
|
return [4 /*yield*/, (0, utils_1.getDependencyPaths)(buildConfig, macroFolders, macroCorePath)];
|
|
211
211
|
case 3:
|
|
@@ -222,7 +222,7 @@ function getBuildInfo(target, streamWeb) {
|
|
|
222
222
|
];
|
|
223
223
|
case 5:
|
|
224
224
|
dependencyFilePathsForCreateFile = _a.sent();
|
|
225
|
-
return [4 /*yield*/, (0, utils_1.readFile)("".concat(
|
|
225
|
+
return [4 /*yield*/, (0, utils_1.readFile)("".concat(process.sasjsConstants.macroCorePath, "/base/mp_replace.sas"))];
|
|
226
226
|
case 6:
|
|
227
227
|
gsubScript = _a.sent();
|
|
228
228
|
buildConfig += "".concat(gsubScript, "\n");
|
|
@@ -244,10 +244,11 @@ function getBuildInfo(target, streamWeb) {
|
|
|
244
244
|
}
|
|
245
245
|
function getCreateWebServiceScript(serverType) {
|
|
246
246
|
return __awaiter(this, void 0, void 0, function () {
|
|
247
|
-
var _a;
|
|
247
|
+
var macroCorePath, _a;
|
|
248
248
|
return __generator(this, function (_b) {
|
|
249
249
|
switch (_b.label) {
|
|
250
250
|
case 0:
|
|
251
|
+
macroCorePath = process.sasjsConstants.macroCorePath;
|
|
251
252
|
_a = serverType;
|
|
252
253
|
switch (_a) {
|
|
253
254
|
case utils_1.ServerType.SasViya: return [3 /*break*/, 1];
|
|
@@ -255,15 +256,15 @@ function getCreateWebServiceScript(serverType) {
|
|
|
255
256
|
case utils_1.ServerType.Sasjs: return [3 /*break*/, 5];
|
|
256
257
|
}
|
|
257
258
|
return [3 /*break*/, 7];
|
|
258
|
-
case 1: return [4 /*yield*/, (0, utils_1.readFile)("".concat(
|
|
259
|
+
case 1: return [4 /*yield*/, (0, utils_1.readFile)("".concat(macroCorePath, "/viya/mv_createwebservice.sas"))];
|
|
259
260
|
case 2: return [2 /*return*/, _b.sent()];
|
|
260
|
-
case 3: return [4 /*yield*/, (0, utils_1.readFile)("".concat(
|
|
261
|
+
case 3: return [4 /*yield*/, (0, utils_1.readFile)("".concat(macroCorePath, "/meta/mm_createwebservice.sas"))
|
|
261
262
|
// FIXME: use sasjs/mv_createwebservice.sas ones created
|
|
262
263
|
];
|
|
263
264
|
case 4: return [2 /*return*/, _b.sent()
|
|
264
265
|
// FIXME: use sasjs/mv_createwebservice.sas ones created
|
|
265
266
|
];
|
|
266
|
-
case 5: return [4 /*yield*/, (0, utils_1.readFile)("".concat(
|
|
267
|
+
case 5: return [4 /*yield*/, (0, utils_1.readFile)("".concat(macroCorePath, "/viya/mv_createwebservice.sas"))];
|
|
267
268
|
case 6: return [2 /*return*/, _b.sent()];
|
|
268
269
|
case 7: throw new error_1.ServerTypeError();
|
|
269
270
|
}
|
|
@@ -272,23 +273,24 @@ function getCreateWebServiceScript(serverType) {
|
|
|
272
273
|
}
|
|
273
274
|
function getCreateFileScript(serverType) {
|
|
274
275
|
return __awaiter(this, void 0, void 0, function () {
|
|
275
|
-
var _a;
|
|
276
|
+
var macroCorePath, _a;
|
|
276
277
|
return __generator(this, function (_b) {
|
|
277
278
|
switch (_b.label) {
|
|
278
279
|
case 0:
|
|
280
|
+
macroCorePath = process.sasjsConstants.macroCorePath;
|
|
279
281
|
_a = serverType;
|
|
280
282
|
switch (_a) {
|
|
281
283
|
case utils_1.ServerType.SasViya: return [3 /*break*/, 1];
|
|
282
284
|
case utils_1.ServerType.Sasjs: return [3 /*break*/, 3];
|
|
283
285
|
}
|
|
284
286
|
return [3 /*break*/, 5];
|
|
285
|
-
case 1: return [4 /*yield*/, (0, utils_1.readFile)("".concat(
|
|
287
|
+
case 1: return [4 /*yield*/, (0, utils_1.readFile)("".concat(macroCorePath, "/viya/mv_createfile.sas"))
|
|
286
288
|
// FIXME: use sasjs/mv_createfile.sas ones created
|
|
287
289
|
];
|
|
288
290
|
case 2: return [2 /*return*/, _b.sent()
|
|
289
291
|
// FIXME: use sasjs/mv_createfile.sas ones created
|
|
290
292
|
];
|
|
291
|
-
case 3: return [4 /*yield*/, (0, utils_1.readFile)("".concat(
|
|
293
|
+
case 3: return [4 /*yield*/, (0, utils_1.readFile)("".concat(macroCorePath, "/viya/mv_createfile.sas"))];
|
|
292
294
|
case 4: return [2 /*return*/, _b.sent()];
|
|
293
295
|
case 5: throw new error_1.ServerTypeError([utils_1.ServerType.SasViya, utils_1.ServerType.Sasjs]);
|
|
294
296
|
}
|
|
@@ -37,7 +37,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.getPreCodeForServicePack = exports.compileServiceFile = void 0;
|
|
40
|
-
var config_1 = require("../../../utils/config");
|
|
41
40
|
var utils_1 = require("@sasjs/utils");
|
|
42
41
|
var types_1 = require("@sasjs/utils/types");
|
|
43
42
|
var error_1 = require("@sasjs/utils/error");
|
|
@@ -75,7 +74,7 @@ function getPreCodeForServicePack(serverType) {
|
|
|
75
74
|
switch (_l.label) {
|
|
76
75
|
case 0:
|
|
77
76
|
content = '';
|
|
78
|
-
macroCorePath =
|
|
77
|
+
macroCorePath = process.sasjsConstants.macroCorePath;
|
|
79
78
|
_a = serverType;
|
|
80
79
|
switch (_a) {
|
|
81
80
|
case types_1.ServerType.SasViya: return [3 /*break*/, 1];
|
|
@@ -90,7 +90,7 @@ var DeployCommand = /** @class */ (function (_super) {
|
|
|
90
90
|
})
|
|
91
91
|
.catch(function (err) {
|
|
92
92
|
var _a;
|
|
93
|
-
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.error(
|
|
93
|
+
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.error("An error has occurred when deploying services: ".concat(err));
|
|
94
94
|
return command_1.ReturnCode.InternalError;
|
|
95
95
|
})];
|
|
96
96
|
case 2: return [2 /*return*/, _b.sent()];
|
package/build/utils/config.d.ts
CHANGED
|
@@ -52,7 +52,6 @@ export declare function getMacroFolders(target?: Target): Promise<string[]>;
|
|
|
52
52
|
* @param {Target} target- the target to check stream configuration for.
|
|
53
53
|
*/
|
|
54
54
|
export declare function getStreamConfig(target?: Target): Promise<StreamConfig>;
|
|
55
|
-
export declare const getMacroCorePath: () => string;
|
|
56
55
|
/**
|
|
57
56
|
* Sanitizes app location string.
|
|
58
57
|
* @param {string} appLoc - app location
|
package/build/utils/config.js
CHANGED
|
@@ -75,7 +75,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
75
75
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
76
76
|
};
|
|
77
77
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
78
|
-
exports.getTestTearDown = exports.getTestSetUp = exports.overrideEnvVariables = exports.getAccessToken = exports.getAuthConfig = exports.getProjectRoot = exports.sanitizeAppLoc = exports.
|
|
78
|
+
exports.getTestTearDown = exports.getTestSetUp = exports.overrideEnvVariables = exports.getAccessToken = exports.getAuthConfig = exports.getProjectRoot = exports.sanitizeAppLoc = exports.getStreamConfig = exports.getMacroFolders = exports.getBinaryFolders = exports.getProgramFolders = exports.getFolders = exports.saveToLocalConfig = exports.saveLocalConfigFile = exports.getLocalOrGlobalConfig = exports.getLocalConfig = exports.removeFromLocalConfig = exports.removeFromGlobalConfig = exports.saveToGlobalConfig = exports.saveGlobalRcFile = exports.getLocalRcFile = exports.getGlobalRcFile = exports.findTargetInConfiguration = exports.getConfiguration = void 0;
|
|
79
79
|
var node_1 = __importDefault(require("@sasjs/adapter/node"));
|
|
80
80
|
var utils_1 = require("@sasjs/utils");
|
|
81
81
|
var auth_1 = require("./auth");
|
|
@@ -415,16 +415,20 @@ function saveGlobalRcFile(content) {
|
|
|
415
415
|
}
|
|
416
416
|
exports.saveGlobalRcFile = saveGlobalRcFile;
|
|
417
417
|
function saveToGlobalConfig(target, isDefault, saveWithDefaultValues) {
|
|
418
|
+
var _a;
|
|
418
419
|
if (isDefault === void 0) { isDefault = false; }
|
|
419
420
|
if (saveWithDefaultValues === void 0) { saveWithDefaultValues = true; }
|
|
420
421
|
return __awaiter(this, void 0, void 0, function () {
|
|
421
422
|
var globalConfig, targetJson, existingTargetIndex;
|
|
422
|
-
return __generator(this, function (
|
|
423
|
-
switch (
|
|
423
|
+
return __generator(this, function (_b) {
|
|
424
|
+
switch (_b.label) {
|
|
424
425
|
case 0: return [4 /*yield*/, getGlobalRcFile()];
|
|
425
426
|
case 1:
|
|
426
|
-
globalConfig =
|
|
427
|
+
globalConfig = _b.sent();
|
|
427
428
|
targetJson = target.toJson(saveWithDefaultValues);
|
|
429
|
+
if ((_a = targetJson.httpsAgentOptions) === null || _a === void 0 ? void 0 : _a.ca) {
|
|
430
|
+
targetJson.httpsAgentOptions.ca = undefined;
|
|
431
|
+
}
|
|
428
432
|
if (globalConfig) {
|
|
429
433
|
if (globalConfig.targets && globalConfig.targets.length) {
|
|
430
434
|
existingTargetIndex = globalConfig.targets.findIndex(function (t) { return t.name === target.name; });
|
|
@@ -446,7 +450,7 @@ function saveToGlobalConfig(target, isDefault, saveWithDefaultValues) {
|
|
|
446
450
|
globalConfig.defaultTarget = target.name;
|
|
447
451
|
}
|
|
448
452
|
return [4 /*yield*/, saveGlobalRcFile(JSON.stringify(globalConfig, null, 2))];
|
|
449
|
-
case 2: return [2 /*return*/,
|
|
453
|
+
case 2: return [2 /*return*/, _b.sent()];
|
|
450
454
|
}
|
|
451
455
|
});
|
|
452
456
|
});
|
|
@@ -552,20 +556,23 @@ function saveLocalConfigFile(content) {
|
|
|
552
556
|
}
|
|
553
557
|
exports.saveLocalConfigFile = saveLocalConfigFile;
|
|
554
558
|
function saveToLocalConfig(target, isDefault, saveWithDefaultValues) {
|
|
555
|
-
var _a;
|
|
559
|
+
var _a, _b;
|
|
556
560
|
if (isDefault === void 0) { isDefault = false; }
|
|
557
561
|
if (saveWithDefaultValues === void 0) { saveWithDefaultValues = true; }
|
|
558
562
|
return __awaiter(this, void 0, void 0, function () {
|
|
559
563
|
var targetJson, config, existingTargetIndex, configPath;
|
|
560
|
-
return __generator(this, function (
|
|
561
|
-
switch (
|
|
564
|
+
return __generator(this, function (_c) {
|
|
565
|
+
switch (_c.label) {
|
|
562
566
|
case 0:
|
|
563
567
|
targetJson = target.toJson(saveWithDefaultValues);
|
|
568
|
+
if ((_a = targetJson.httpsAgentOptions) === null || _a === void 0 ? void 0 : _a.ca) {
|
|
569
|
+
targetJson.httpsAgentOptions.ca = undefined;
|
|
570
|
+
}
|
|
564
571
|
return [4 /*yield*/, getLocalConfig()];
|
|
565
572
|
case 1:
|
|
566
|
-
config =
|
|
573
|
+
config = _c.sent();
|
|
567
574
|
if (config) {
|
|
568
|
-
if ((
|
|
575
|
+
if ((_b = config === null || config === void 0 ? void 0 : config.targets) === null || _b === void 0 ? void 0 : _b.length) {
|
|
569
576
|
existingTargetIndex = config.targets.findIndex(function (t) { return t.name === target.name; });
|
|
570
577
|
if (existingTargetIndex > -1) {
|
|
571
578
|
config.targets[existingTargetIndex] = targetJson;
|
|
@@ -587,7 +594,7 @@ function saveToLocalConfig(target, isDefault, saveWithDefaultValues) {
|
|
|
587
594
|
configPath = path_1.default.join(process.projectDir, 'sasjs', 'sasjsconfig.json');
|
|
588
595
|
return [4 /*yield*/, (0, utils_1.createFile)(configPath, JSON.stringify(config, null, 2))];
|
|
589
596
|
case 2:
|
|
590
|
-
|
|
597
|
+
_c.sent();
|
|
591
598
|
return [2 /*return*/, configPath];
|
|
592
599
|
}
|
|
593
600
|
});
|
|
@@ -720,8 +727,6 @@ function getStreamConfig(target) {
|
|
|
720
727
|
});
|
|
721
728
|
}
|
|
722
729
|
exports.getStreamConfig = getStreamConfig;
|
|
723
|
-
var getMacroCorePath = function () { return process.sasjsConstants.macroCorePath; };
|
|
724
|
-
exports.getMacroCorePath = getMacroCorePath;
|
|
725
730
|
/**
|
|
726
731
|
* Sanitizes app location string.
|
|
727
732
|
* @param {string} appLoc - app location
|
|
@@ -988,32 +993,30 @@ var overrideEnvVariables = function (targetName) { return __awaiter(void 0, void
|
|
|
988
993
|
}); };
|
|
989
994
|
exports.overrideEnvVariables = overrideEnvVariables;
|
|
990
995
|
var getPrecedenceOfHttpsAgentOptionsAndContent = function (config, target) { return __awaiter(void 0, void 0, void 0, function () {
|
|
991
|
-
var httpsAgentOptions, _a, _b
|
|
992
|
-
return __generator(this, function (
|
|
993
|
-
switch (
|
|
996
|
+
var httpsAgentOptions, rootCas, _a, _b;
|
|
997
|
+
return __generator(this, function (_c) {
|
|
998
|
+
switch (_c.label) {
|
|
994
999
|
case 0:
|
|
995
1000
|
httpsAgentOptions = getHttpsAgentOptionsForInsecure(__assign(__assign({ allowInsecureRequests: false }, config.httpsAgentOptions), target.httpsAgentOptions));
|
|
996
|
-
if (
|
|
1001
|
+
if (httpsAgentOptions.caPath) {
|
|
1002
|
+
rootCas = require('ssl-root-cas');
|
|
1003
|
+
rootCas.addFile(path_1.default.resolve(httpsAgentOptions.caPath));
|
|
1004
|
+
httpsAgentOptions.ca = rootCas;
|
|
1005
|
+
}
|
|
1006
|
+
if (!httpsAgentOptions.keyPath) return [3 /*break*/, 2];
|
|
997
1007
|
_a = httpsAgentOptions;
|
|
998
|
-
return [4 /*yield*/, (0, utils_1.readFile)(httpsAgentOptions.
|
|
1008
|
+
return [4 /*yield*/, (0, utils_1.readFile)(httpsAgentOptions.keyPath)];
|
|
999
1009
|
case 1:
|
|
1000
|
-
_a.
|
|
1001
|
-
|
|
1010
|
+
_a.key = _c.sent();
|
|
1011
|
+
_c.label = 2;
|
|
1002
1012
|
case 2:
|
|
1003
|
-
if (!httpsAgentOptions.
|
|
1013
|
+
if (!httpsAgentOptions.certPath) return [3 /*break*/, 4];
|
|
1004
1014
|
_b = httpsAgentOptions;
|
|
1005
|
-
return [4 /*yield*/, (0, utils_1.readFile)(httpsAgentOptions.keyPath)];
|
|
1006
|
-
case 3:
|
|
1007
|
-
_b.key = _d.sent();
|
|
1008
|
-
_d.label = 4;
|
|
1009
|
-
case 4:
|
|
1010
|
-
if (!httpsAgentOptions.certPath) return [3 /*break*/, 6];
|
|
1011
|
-
_c = httpsAgentOptions;
|
|
1012
1015
|
return [4 /*yield*/, (0, utils_1.readFile)(httpsAgentOptions.certPath)];
|
|
1013
|
-
case
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
case
|
|
1016
|
+
case 3:
|
|
1017
|
+
_b.cert = _c.sent();
|
|
1018
|
+
_c.label = 4;
|
|
1019
|
+
case 4: return [2 /*return*/, httpsAgentOptions];
|
|
1017
1020
|
}
|
|
1018
1021
|
});
|
|
1019
1022
|
}); };
|
|
@@ -41,62 +41,38 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
exports.setConstants = exports.contextName = void 0;
|
|
43
43
|
var path_1 = __importDefault(require("path"));
|
|
44
|
-
var get_installed_path_1 = require("get-installed-path");
|
|
45
44
|
var config_1 = require("./config");
|
|
46
|
-
var utils_1 = require("
|
|
45
|
+
var utils_1 = require("./utils");
|
|
46
|
+
var utils_2 = 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
|
-
var _a, configuration, isLocal, buildOutputFolder, buildResultsFolder, homeDir,
|
|
50
|
-
var
|
|
51
|
-
return __generator(this, function (
|
|
52
|
-
switch (
|
|
49
|
+
var _a, configuration, isLocal, buildOutputFolder, buildResultsFolder, homeDir, buildSourceFolder, buildSourceDbFolder, buildDestinationFolder, buildDestinationServicesFolder, buildDestinationTestFolder, buildDestinationJobsFolder, buildDestinationDbFolder, buildDestinationDocsFolder, macroCorePath, buildDestinationResultsFolder, buildDestinationResultsLogsFolder, sas9CredentialsError, invalidSasError;
|
|
50
|
+
var _b, _c;
|
|
51
|
+
return __generator(this, function (_d) {
|
|
52
|
+
switch (_d.label) {
|
|
53
53
|
case 0: return [4 /*yield*/, (0, config_1.getLocalOrGlobalConfig)().catch(function () { return ({
|
|
54
54
|
configuration: null,
|
|
55
55
|
isLocal: false
|
|
56
56
|
}); })];
|
|
57
57
|
case 1:
|
|
58
|
-
_a =
|
|
59
|
-
buildOutputFolder = ((
|
|
58
|
+
_a = _d.sent(), configuration = _a.configuration, isLocal = _a.isLocal;
|
|
59
|
+
buildOutputFolder = ((_b = configuration === null || configuration === void 0 ? void 0 : configuration.buildConfig) === null || _b === void 0 ? void 0 : _b.buildOutputFolder) ||
|
|
60
60
|
(isLocal ? 'sasjsbuild' : '.sasjs/sasjsbuild');
|
|
61
|
-
buildResultsFolder = ((
|
|
61
|
+
buildResultsFolder = ((_c = configuration === null || configuration === void 0 ? void 0 : configuration.buildConfig) === null || _c === void 0 ? void 0 : _c.buildResultsFolder) ||
|
|
62
62
|
(isLocal ? 'sasjsresults' : '.sasjs/sasjsresults');
|
|
63
63
|
homeDir = require('os').homedir();
|
|
64
|
-
getMacroCoreGlobalPath = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
65
|
-
var sasjsPath, macroCoreGlobal, e_1;
|
|
66
|
-
return __generator(this, function (_a) {
|
|
67
|
-
switch (_a.label) {
|
|
68
|
-
case 0:
|
|
69
|
-
_a.trys.push([0, 2, , 3]);
|
|
70
|
-
return [4 /*yield*/, (0, get_installed_path_1.getInstalledPath)('@sasjs/cli')];
|
|
71
|
-
case 1:
|
|
72
|
-
sasjsPath = _a.sent();
|
|
73
|
-
macroCoreGlobal = path_1.default.join(sasjsPath, 'node_modules', '@sasjs', 'core');
|
|
74
|
-
return [2 /*return*/, macroCoreGlobal];
|
|
75
|
-
case 2:
|
|
76
|
-
e_1 = _a.sent();
|
|
77
|
-
throw 'Please install SASjs cli `npm i -g @sasjs/cli`';
|
|
78
|
-
case 3: return [2 /*return*/];
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
}); };
|
|
82
64
|
buildSourceFolder = path_1.default.join(isLocal ? process.projectDir : homeDir);
|
|
83
65
|
buildSourceDbFolder = path_1.default.join(isLocal ? process.projectDir : homeDir, 'sasjs', 'db');
|
|
84
|
-
buildDestinationFolder = (0,
|
|
66
|
+
buildDestinationFolder = (0, utils_2.getAbsolutePath)(buildOutputFolder, isLocal ? process.projectDir : homeDir);
|
|
85
67
|
buildDestinationServicesFolder = path_1.default.join(buildDestinationFolder, 'services');
|
|
86
68
|
buildDestinationTestFolder = path_1.default.join(buildDestinationFolder, 'tests');
|
|
87
69
|
buildDestinationJobsFolder = path_1.default.join(buildDestinationFolder, 'jobs');
|
|
88
70
|
buildDestinationDbFolder = path_1.default.join(buildDestinationFolder, 'db');
|
|
89
71
|
buildDestinationDocsFolder = path_1.default.join(buildDestinationFolder, 'docs');
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
case 3:
|
|
95
|
-
_b = _e.sent();
|
|
96
|
-
_e.label = 4;
|
|
97
|
-
case 4:
|
|
98
|
-
macroCorePath = _b;
|
|
99
|
-
buildDestinationResultsFolder = (0, utils_1.getAbsolutePath)(buildResultsFolder, isLocal ? process.projectDir : homeDir);
|
|
72
|
+
return [4 /*yield*/, (0, utils_1.getCliNodeModulePath)('@sasjs/core')];
|
|
73
|
+
case 2:
|
|
74
|
+
macroCorePath = _d.sent();
|
|
75
|
+
buildDestinationResultsFolder = (0, utils_2.getAbsolutePath)(buildResultsFolder, isLocal ? process.projectDir : homeDir);
|
|
100
76
|
buildDestinationResultsLogsFolder = path_1.default.join(buildDestinationResultsFolder, 'logs');
|
|
101
77
|
sas9CredentialsError = 'The following attributes were not found:' +
|
|
102
78
|
'\n* SAS_USERNAME' +
|
|
@@ -58,10 +58,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
58
58
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
59
59
|
};
|
|
60
60
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61
|
-
var utils_1 = require("@sasjs/utils");
|
|
62
61
|
var path_1 = __importDefault(require("path"));
|
|
63
62
|
var configUtils = __importStar(require("../config"));
|
|
64
63
|
var setConstants_1 = require("../setConstants");
|
|
64
|
+
var fileModule = __importStar(require("@sasjs/utils/file"));
|
|
65
65
|
describe('setConstants', function () {
|
|
66
66
|
var config;
|
|
67
67
|
beforeAll(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -71,17 +71,20 @@ describe('setConstants', function () {
|
|
|
71
71
|
case 0:
|
|
72
72
|
;
|
|
73
73
|
_b = (_a = JSON).parse;
|
|
74
|
-
return [4 /*yield*/,
|
|
74
|
+
return [4 /*yield*/, fileModule.readFile(path_1.default.join(__dirname, '..', '..', 'config.json'))];
|
|
75
75
|
case 1:
|
|
76
76
|
(config = _b.apply(_a, [_c.sent()]).config);
|
|
77
77
|
return [2 /*return*/];
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
80
|
}); });
|
|
81
|
-
test('should set
|
|
81
|
+
test('should set constants inside appFolder', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
82
|
+
var appFolder;
|
|
82
83
|
return __generator(this, function (_a) {
|
|
83
84
|
switch (_a.label) {
|
|
84
85
|
case 0:
|
|
86
|
+
appFolder = ['some', 'app', 'folder'].join(path_1.default.sep);
|
|
87
|
+
process.projectDir = appFolder;
|
|
85
88
|
jest
|
|
86
89
|
.spyOn(configUtils, 'getLocalOrGlobalConfig')
|
|
87
90
|
.mockImplementation(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -92,7 +95,10 @@ describe('setConstants', function () {
|
|
|
92
95
|
})];
|
|
93
96
|
});
|
|
94
97
|
}); });
|
|
95
|
-
process
|
|
98
|
+
jest.spyOn(process, 'cwd').mockImplementation(function () { return appFolder; });
|
|
99
|
+
jest
|
|
100
|
+
.spyOn(fileModule, 'folderExists')
|
|
101
|
+
.mockImplementation(function () { return Promise.resolve(true); });
|
|
96
102
|
return [4 /*yield*/, (0, setConstants_1.setConstants)()];
|
|
97
103
|
case 1:
|
|
98
104
|
_a.sent();
|
|
@@ -101,7 +107,7 @@ describe('setConstants', function () {
|
|
|
101
107
|
}
|
|
102
108
|
});
|
|
103
109
|
}); });
|
|
104
|
-
test('should set
|
|
110
|
+
test('should set constants outside appFolder', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
105
111
|
return __generator(this, function (_a) {
|
|
106
112
|
switch (_a.label) {
|
|
107
113
|
case 0:
|
|
@@ -137,15 +143,11 @@ var verifySasjsConstants = function (appFolder) {
|
|
|
137
143
|
expect(sasjsConstants.buildDestinationResultsFolder).toEqual([prefixAppFolder, 'sasjsresults'].join(path_1.default.sep));
|
|
138
144
|
expect(sasjsConstants.buildDestinationResultsLogsFolder).toEqual([prefixAppFolder, 'sasjsresults', 'logs'].join(path_1.default.sep));
|
|
139
145
|
expect(sasjsConstants.buildDestinationTestFolder).toEqual([prefixAppFolder, 'sasjsbuild', 'tests'].join(path_1.default.sep));
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
'node_modules',
|
|
148
|
-
'@sasjs',
|
|
149
|
-
'core'
|
|
150
|
-
].join(path_1.default.sep)));
|
|
146
|
+
var corePath = path_1.default.join('cli', 'node_modules', '@sasjs', 'core');
|
|
147
|
+
if (appFolder) {
|
|
148
|
+
expect(sasjsConstants.macroCorePath).toEqual(path_1.default.join(prefixAppFolder, 'node_modules', '@sasjs', corePath));
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
expect(sasjsConstants.macroCorePath).toEqual(expect.toEndWith(corePath));
|
|
152
|
+
}
|
|
151
153
|
};
|
package/build/utils/utils.d.ts
CHANGED
package/build/utils/utils.js
CHANGED
|
@@ -86,7 +86,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
86
86
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
87
87
|
};
|
|
88
88
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
89
|
-
exports.isSASjsProject = exports.terminateProcess = exports.prefixAppLoc = exports.loadEnvVariables = exports.displaySasjsRunnerError = exports.getAdapterInstance = exports.checkNodeVersion = exports.millisecondsToDdHhMmSs = exports.arrToObj = exports.parseLogLines = exports.executeShellScript = exports.getUniqServicesObj = exports.removeComments = exports.setupDoxygen = exports.setupGhooks = exports.setupGitIgnore = exports.setupNpmProject = exports.createTemplateApp = exports.createMinimalApp = exports.createAngularApp = exports.createReactApp = exports.diff = exports.inExistingProject = void 0;
|
|
89
|
+
exports.getCliNodeModulePath = exports.isSASjsProject = exports.terminateProcess = exports.prefixAppLoc = exports.loadEnvVariables = exports.displaySasjsRunnerError = exports.getAdapterInstance = exports.checkNodeVersion = exports.millisecondsToDdHhMmSs = exports.arrToObj = exports.parseLogLines = exports.executeShellScript = exports.getUniqServicesObj = exports.removeComments = exports.setupDoxygen = exports.setupGhooks = exports.setupGitIgnore = exports.setupNpmProject = exports.createTemplateApp = exports.createMinimalApp = exports.createAngularApp = exports.createReactApp = exports.diff = exports.inExistingProject = void 0;
|
|
90
90
|
var shelljs_1 = __importDefault(require("shelljs"));
|
|
91
91
|
var path_1 = __importDefault(require("path"));
|
|
92
92
|
var ora_1 = __importDefault(require("ora"));
|
|
@@ -605,3 +605,24 @@ var isSASjsProject = function () { return __awaiter(void 0, void 0, void 0, func
|
|
|
605
605
|
});
|
|
606
606
|
}); };
|
|
607
607
|
exports.isSASjsProject = isSASjsProject;
|
|
608
|
+
var getCliNodeModulePath = function (module) { return __awaiter(void 0, void 0, void 0, function () {
|
|
609
|
+
var cliDepsPath, localPath, globalPath;
|
|
610
|
+
return __generator(this, function (_a) {
|
|
611
|
+
switch (_a.label) {
|
|
612
|
+
case 0:
|
|
613
|
+
cliDepsPath = path_1.default.join('@sasjs', 'cli', 'node_modules');
|
|
614
|
+
localPath = path_1.default.join(process.cwd(), 'node_modules', cliDepsPath, module);
|
|
615
|
+
return [4 /*yield*/, (0, utils_1.folderExists)(localPath)];
|
|
616
|
+
case 1:
|
|
617
|
+
if (_a.sent())
|
|
618
|
+
return [2 /*return*/, localPath];
|
|
619
|
+
globalPath = path_1.default.join(shelljs_1.default.exec("npm root -g", { silent: true }).stdout.replace(/\n/, ''), cliDepsPath, module);
|
|
620
|
+
return [4 /*yield*/, (0, utils_1.folderExists)(globalPath)];
|
|
621
|
+
case 2:
|
|
622
|
+
if (_a.sent())
|
|
623
|
+
return [2 /*return*/, globalPath];
|
|
624
|
+
return [2 /*return*/, ''];
|
|
625
|
+
}
|
|
626
|
+
});
|
|
627
|
+
}); };
|
|
628
|
+
exports.getCliNodeModulePath = getCliNodeModulePath;
|
package/package.json
CHANGED
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@sasjs/adapter": "3.8.
|
|
51
|
-
"@sasjs/core": "4.15
|
|
50
|
+
"@sasjs/adapter": "3.8.5",
|
|
51
|
+
"@sasjs/core": "4.18.15",
|
|
52
52
|
"@sasjs/lint": "1.11.2",
|
|
53
53
|
"@sasjs/utils": "2.42.0",
|
|
54
54
|
"chalk": "4.1.2",
|
|
@@ -56,7 +56,6 @@
|
|
|
56
56
|
"dotenv": "10.0.0",
|
|
57
57
|
"esm": "3.2.25",
|
|
58
58
|
"find": "0.3.0",
|
|
59
|
-
"get-installed-path": "4.0.8",
|
|
60
59
|
"js-base64": "3.7.2",
|
|
61
60
|
"jsdom": "19.0.0",
|
|
62
61
|
"jwt-decode": "3.1.2",
|
|
@@ -66,6 +65,7 @@
|
|
|
66
65
|
"ora": "5.4.1",
|
|
67
66
|
"rimraf": "3.0.2",
|
|
68
67
|
"shelljs": "0.8.5",
|
|
68
|
+
"ssl-root-cas": "^1.3.1",
|
|
69
69
|
"xml": "1.0.1",
|
|
70
70
|
"yargs": "17.2.1"
|
|
71
71
|
},
|
|
@@ -73,7 +73,6 @@
|
|
|
73
73
|
"@babel/preset-env": "7.15.6",
|
|
74
74
|
"@babel/preset-typescript": "7.15.0",
|
|
75
75
|
"@types/find": "0.2.1",
|
|
76
|
-
"@types/get-installed-path": "4.0.1",
|
|
77
76
|
"@types/jest": "27.0.2",
|
|
78
77
|
"@types/jsdom": "16.2.13",
|
|
79
78
|
"@types/lodash.groupby": "4.6.6",
|
|
@@ -94,5 +93,5 @@
|
|
|
94
93
|
"typescript": "4.5.4",
|
|
95
94
|
"util": "0.12.4"
|
|
96
95
|
},
|
|
97
|
-
"version": "3.
|
|
96
|
+
"version": "3.13.1"
|
|
98
97
|
}
|