@sasjs/cli 4.0.4 → 4.0.6
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 +2 -5
- package/build/commands/add/spec/addCommand.spec.js +7 -0
- package/build/commands/build/build.d.ts +1 -1
- package/build/commands/build/build.js +9 -14
- package/build/commands/build/internal/config.js +14 -21
- package/build/commands/build/spec/buildCommand.spec.js +8 -1
- package/build/commands/build/spec/compileBuildCommand.spec.js +8 -1
- package/build/commands/compile/compile.js +22 -24
- package/build/commands/compile/internal/compileTestFile.d.ts +1 -1
- package/build/commands/compile/internal/compileTestFile.js +16 -24
- package/build/commands/compile/internal/getAllFolders.d.ts +1 -1
- package/build/commands/compile/internal/getAllFolders.js +28 -40
- package/build/commands/compile/internal/getServerType.js +6 -12
- package/build/commands/compile/internal/loadDependencies.d.ts +1 -1
- package/build/commands/compile/internal/loadDependencies.js +6 -7
- package/build/commands/compile/internal/spec/getAllFolders.spec.js +1 -1
- package/build/commands/compile/spec/compile.spec.js +43 -29
- package/build/commands/compile/spec/compileCommand.spec.js +11 -3
- package/build/commands/compile/spec/loadDependencies.spec.js +11 -6
- package/build/commands/context/spec/contextCommand.spec.js +8 -0
- package/build/commands/deploy/internal/getDeployScripts.js +4 -15
- package/build/commands/deploy/spec/cbd.spec.js +26 -22
- package/build/commands/deploy/spec/compileBuildDeployCommand.spec.js +9 -2
- package/build/commands/deploy/spec/deployCommand.spec.js +7 -0
- package/build/commands/docs/docsCommand.js +4 -9
- package/build/commands/docs/spec/docsCommand.spec.js +4 -0
- package/build/commands/flow/spec/flowCommand.spec.js +7 -11
- package/build/commands/folder/spec/folderCommand.spec.js +7 -0
- package/build/commands/fs/spec/fsCommand.spec.js +19 -22
- package/build/commands/job/spec/jobCommand.spec.js +6 -0
- package/build/commands/request/spec/requestCommand.spec.js +7 -11
- package/build/commands/run/spec/runCommand.spec.js +7 -11
- package/build/commands/servicepack/spec/servicepackCommand.spec.js +7 -11
- package/build/commands/testing/spec/testCommand.spec.js +7 -11
- package/build/commands/web/spec/web.spec.js +12 -7
- package/build/commands/web/spec/webCommand.spec.js +8 -1
- package/build/types/command/targetCommand.js +25 -5
- package/build/utils/config.js +60 -74
- package/build/utils/setConstants.d.ts +2 -3
- package/build/utils/setConstants.js +55 -77
- package/build/utils/spec/setConstants.spec.js +1 -1
- package/build/utils/test.js +32 -17
- package/package.json +1 -1
package/build/cli.js
CHANGED
|
@@ -50,16 +50,13 @@ function cli(args) {
|
|
|
50
50
|
_a.sent();
|
|
51
51
|
return [4 /*yield*/, instantiateLogger()];
|
|
52
52
|
case 2:
|
|
53
|
-
_a.sent();
|
|
54
|
-
return [4 /*yield*/, (0, utils_1.setConstants)()];
|
|
55
|
-
case 3:
|
|
56
53
|
_a.sent();
|
|
57
54
|
return [4 /*yield*/, (0, utils_1.loadProjectEnvVariables)()];
|
|
58
|
-
case
|
|
55
|
+
case 3:
|
|
59
56
|
_a.sent();
|
|
60
57
|
command = (0, parse_1.parse)(args);
|
|
61
58
|
return [4 /*yield*/, command.execute()];
|
|
62
|
-
case
|
|
59
|
+
case 4:
|
|
63
60
|
returnCode = _a.sent();
|
|
64
61
|
process.exit(returnCode);
|
|
65
62
|
return [2 /*return*/];
|
|
@@ -88,6 +88,7 @@ var addCommand_1 = require("../addCommand");
|
|
|
88
88
|
var addTargetModule = __importStar(require("../addTarget"));
|
|
89
89
|
var addCredentialModule = __importStar(require("../addCredential"));
|
|
90
90
|
var configUtils = __importStar(require("../../../utils/config"));
|
|
91
|
+
var setConstantsUtils = __importStar(require("../../../utils/setConstants"));
|
|
91
92
|
var utils_1 = require("@sasjs/utils");
|
|
92
93
|
var types_1 = require("../../../types");
|
|
93
94
|
var command_1 = require("../../../types/command");
|
|
@@ -168,6 +169,12 @@ describe('AddCommand - cred', function () {
|
|
|
168
169
|
jest
|
|
169
170
|
.spyOn(configUtils, 'findTargetInConfiguration')
|
|
170
171
|
.mockImplementation(function () { return Promise.resolve({ target: target, isLocal: true }); });
|
|
172
|
+
jest
|
|
173
|
+
.spyOn(configUtils, 'getLocalConfig')
|
|
174
|
+
.mockImplementation(function () { return Promise.resolve({}); });
|
|
175
|
+
jest
|
|
176
|
+
.spyOn(setConstantsUtils, 'setConstants')
|
|
177
|
+
.mockImplementation(function () { return Promise.resolve(); });
|
|
171
178
|
jest.spyOn(process.logger, 'success');
|
|
172
179
|
jest.spyOn(process.logger, 'error');
|
|
173
180
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ServerType, Target } from '@sasjs/utils';
|
|
2
2
|
export declare function build(target: Target): Promise<void>;
|
|
3
3
|
export declare function getWebServiceScriptInvocation(serverType: ServerType, isSASFile?: boolean, encoded?: boolean): string;
|
|
4
4
|
export declare function getBuildVars(target: Target): Promise<string>;
|
|
@@ -87,17 +87,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
87
87
|
};
|
|
88
88
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
89
89
|
exports.getBuildVars = exports.getWebServiceScriptInvocation = exports.build = void 0;
|
|
90
|
-
var path_1 = __importDefault(require("path"));
|
|
91
90
|
var utils_1 = require("@sasjs/utils");
|
|
92
91
|
var error_1 = require("@sasjs/utils/error");
|
|
93
|
-
var
|
|
92
|
+
var path_1 = __importDefault(require("path"));
|
|
93
|
+
var types_1 = require("@sasjs/utils/types");
|
|
94
|
+
var compressAndSave_1 = require("../../utils/compressAndSave");
|
|
94
95
|
var config_1 = require("../../utils/config");
|
|
96
|
+
var file_1 = require("../../utils/file");
|
|
95
97
|
var compile_1 = require("../compile/compile");
|
|
98
|
+
var loadDependencies_1 = require("../compile/internal/loadDependencies");
|
|
96
99
|
var config_2 = require("./internal/config");
|
|
97
100
|
var getLaunchPageCode_1 = require("./internal/getLaunchPageCode");
|
|
98
|
-
var types_1 = require("@sasjs/utils/types");
|
|
99
|
-
var compressAndSave_1 = require("../../utils/compressAndSave");
|
|
100
|
-
var loadDependencies_1 = require("../compile/internal/loadDependencies");
|
|
101
101
|
function build(target) {
|
|
102
102
|
return __awaiter(this, void 0, void 0, function () {
|
|
103
103
|
var _a;
|
|
@@ -515,15 +515,10 @@ function getBuildVars(target) {
|
|
|
515
515
|
return __awaiter(this, void 0, void 0, function () {
|
|
516
516
|
var targetBuildVars, configuration, commonBuildVars;
|
|
517
517
|
return __generator(this, function (_e) {
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
case 1:
|
|
523
|
-
configuration = _e.sent();
|
|
524
|
-
commonBuildVars = (_d = (_c = configuration === null || configuration === void 0 ? void 0 : configuration.buildConfig) === null || _c === void 0 ? void 0 : _c.macroVars) !== null && _d !== void 0 ? _d : {};
|
|
525
|
-
return [2 /*return*/, convertVarsToSasFormat(__assign(__assign({}, commonBuildVars), targetBuildVars))];
|
|
526
|
-
}
|
|
518
|
+
targetBuildVars = (_b = (_a = target === null || target === void 0 ? void 0 : target.buildConfig) === null || _a === void 0 ? void 0 : _a.macroVars) !== null && _b !== void 0 ? _b : {};
|
|
519
|
+
configuration = process.sasjsConfig;
|
|
520
|
+
commonBuildVars = (_d = (_c = configuration === null || configuration === void 0 ? void 0 : configuration.buildConfig) === null || _c === void 0 ? void 0 : _c.macroVars) !== null && _d !== void 0 ? _d : {};
|
|
521
|
+
return [2 /*return*/, convertVarsToSasFormat(__assign(__assign({}, commonBuildVars), targetBuildVars))];
|
|
527
522
|
});
|
|
528
523
|
});
|
|
529
524
|
}
|
|
@@ -35,14 +35,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
39
|
exports.getBuildTerm = exports.getBuildInit = void 0;
|
|
43
|
-
var path_1 = __importDefault(require("path"));
|
|
44
40
|
var utils_1 = require("@sasjs/utils");
|
|
45
|
-
var config_1 = require("../../../utils/config");
|
|
46
41
|
var getBuildInit = function (target) { return __awaiter(void 0, void 0, void 0, function () {
|
|
47
42
|
var buildSourceFolder, buildInitContent, configuration;
|
|
48
43
|
var _a, _b;
|
|
@@ -55,16 +50,15 @@ var getBuildInit = function (target) { return __awaiter(void 0, void 0, void 0,
|
|
|
55
50
|
return [4 /*yield*/, (0, utils_1.readFile)((0, utils_1.getAbsolutePath)(target.buildConfig.initProgram, buildSourceFolder))];
|
|
56
51
|
case 1:
|
|
57
52
|
buildInitContent = _c.sent();
|
|
58
|
-
return [3 /*break*/,
|
|
59
|
-
case 2:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (!((_b = configuration === null || configuration === void 0 ? void 0 : configuration.buildConfig) === null || _b === void 0 ? void 0 : _b.initProgram)) return [3 /*break*/, 5];
|
|
53
|
+
return [3 /*break*/, 4];
|
|
54
|
+
case 2:
|
|
55
|
+
configuration = process.sasjsConfig;
|
|
56
|
+
if (!((_b = configuration === null || configuration === void 0 ? void 0 : configuration.buildConfig) === null || _b === void 0 ? void 0 : _b.initProgram)) return [3 /*break*/, 4];
|
|
63
57
|
return [4 /*yield*/, (0, utils_1.readFile)((0, utils_1.getAbsolutePath)(configuration.buildConfig.initProgram, buildSourceFolder))];
|
|
64
|
-
case
|
|
58
|
+
case 3:
|
|
65
59
|
buildInitContent = _c.sent();
|
|
66
|
-
_c.label =
|
|
67
|
-
case
|
|
60
|
+
_c.label = 4;
|
|
61
|
+
case 4: return [2 /*return*/, buildInitContent
|
|
68
62
|
? "\n* BuildInit start;\n".concat(buildInitContent, "\n* BuildInit end;")
|
|
69
63
|
: ''];
|
|
70
64
|
}
|
|
@@ -83,16 +77,15 @@ var getBuildTerm = function (target) { return __awaiter(void 0, void 0, void 0,
|
|
|
83
77
|
return [4 /*yield*/, (0, utils_1.readFile)((0, utils_1.getAbsolutePath)(target.buildConfig.termProgram, buildSourceFolder))];
|
|
84
78
|
case 1:
|
|
85
79
|
buildTermContent = _c.sent();
|
|
86
|
-
return [3 /*break*/,
|
|
87
|
-
case 2:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (!((_b = configuration === null || configuration === void 0 ? void 0 : configuration.buildConfig) === null || _b === void 0 ? void 0 : _b.termProgram)) return [3 /*break*/, 5];
|
|
80
|
+
return [3 /*break*/, 4];
|
|
81
|
+
case 2:
|
|
82
|
+
configuration = process.sasjsConfig;
|
|
83
|
+
if (!((_b = configuration === null || configuration === void 0 ? void 0 : configuration.buildConfig) === null || _b === void 0 ? void 0 : _b.termProgram)) return [3 /*break*/, 4];
|
|
91
84
|
return [4 /*yield*/, (0, utils_1.readFile)((0, utils_1.getAbsolutePath)(configuration.buildConfig.termProgram, buildSourceFolder))];
|
|
92
|
-
case
|
|
85
|
+
case 3:
|
|
93
86
|
buildTermContent = _c.sent();
|
|
94
|
-
_c.label =
|
|
95
|
-
case
|
|
87
|
+
_c.label = 4;
|
|
88
|
+
case 4: return [2 /*return*/, buildTermContent
|
|
96
89
|
? "\n* BuildTerm start;\n".concat(buildTermContent, "\n* BuildTerm end;")
|
|
97
90
|
: ''];
|
|
98
91
|
}
|
|
@@ -88,6 +88,7 @@ var buildModule = __importStar(require("../build"));
|
|
|
88
88
|
var buildCommand_1 = require("../buildCommand");
|
|
89
89
|
var utils_1 = require("@sasjs/utils");
|
|
90
90
|
var configUtils = __importStar(require("../../../utils/config"));
|
|
91
|
+
var setConstantsUtils = __importStar(require("../../../utils/setConstants"));
|
|
91
92
|
var command_1 = require("../../../types/command");
|
|
92
93
|
var utils_2 = require("../../../utils");
|
|
93
94
|
var defaultArgs = ['node', 'sasjs'];
|
|
@@ -101,7 +102,7 @@ describe('BuildCommand', function () {
|
|
|
101
102
|
beforeAll(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
102
103
|
return __generator(this, function (_a) {
|
|
103
104
|
switch (_a.label) {
|
|
104
|
-
case 0: return [4 /*yield*/, (0, utils_2.setConstants)()];
|
|
105
|
+
case 0: return [4 /*yield*/, (0, utils_2.setConstants)(false)];
|
|
105
106
|
case 1:
|
|
106
107
|
_a.sent();
|
|
107
108
|
return [2 /*return*/];
|
|
@@ -194,6 +195,12 @@ var setupMocks = function () {
|
|
|
194
195
|
jest
|
|
195
196
|
.spyOn(configUtils, 'findTargetInConfiguration')
|
|
196
197
|
.mockImplementation(function () { return Promise.resolve({ target: target, isLocal: true }); });
|
|
198
|
+
jest
|
|
199
|
+
.spyOn(configUtils, 'getLocalConfig')
|
|
200
|
+
.mockImplementation(function () { return Promise.resolve({}); });
|
|
201
|
+
jest
|
|
202
|
+
.spyOn(setConstantsUtils, 'setConstants')
|
|
203
|
+
.mockImplementation(function () { return Promise.resolve(); });
|
|
197
204
|
process.logger = new utils_1.Logger(utils_1.LogLevel.Off);
|
|
198
205
|
jest.spyOn(process.logger, 'success');
|
|
199
206
|
jest.spyOn(process.logger, 'error');
|
|
@@ -89,6 +89,7 @@ var compileModule = __importStar(require("../../compile/compile"));
|
|
|
89
89
|
var compileBuildCommand_1 = require("../compileBuildCommand");
|
|
90
90
|
var utils_1 = require("@sasjs/utils");
|
|
91
91
|
var configUtils = __importStar(require("../../../utils/config"));
|
|
92
|
+
var setConstantsUtils = __importStar(require("../../../utils/setConstants"));
|
|
92
93
|
var command_1 = require("../../../types/command");
|
|
93
94
|
var utils_2 = require("../../../utils");
|
|
94
95
|
describe('CompileBuildCommand', function () {
|
|
@@ -102,7 +103,7 @@ describe('CompileBuildCommand', function () {
|
|
|
102
103
|
beforeAll(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
103
104
|
return __generator(this, function (_a) {
|
|
104
105
|
switch (_a.label) {
|
|
105
|
-
case 0: return [4 /*yield*/, (0, utils_2.setConstants)()];
|
|
106
|
+
case 0: return [4 /*yield*/, (0, utils_2.setConstants)(false)];
|
|
106
107
|
case 1:
|
|
107
108
|
_a.sent();
|
|
108
109
|
return [2 /*return*/];
|
|
@@ -121,6 +122,12 @@ describe('CompileBuildCommand', function () {
|
|
|
121
122
|
jest
|
|
122
123
|
.spyOn(configUtils, 'findTargetInConfiguration')
|
|
123
124
|
.mockImplementation(function () { return Promise.resolve({ target: target, isLocal: true }); });
|
|
125
|
+
jest
|
|
126
|
+
.spyOn(configUtils, 'getLocalConfig')
|
|
127
|
+
.mockImplementation(function () { return Promise.resolve({}); });
|
|
128
|
+
jest
|
|
129
|
+
.spyOn(setConstantsUtils, 'setConstants')
|
|
130
|
+
.mockImplementation(function () { return Promise.resolve(); });
|
|
124
131
|
process.logger = new utils_1.Logger(utils_1.LogLevel.Off);
|
|
125
132
|
jest.spyOn(process.logger, 'success');
|
|
126
133
|
jest.spyOn(process.logger, 'error');
|
|
@@ -74,20 +74,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
74
74
|
};
|
|
75
75
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
76
76
|
exports.compileJobsServicesTests = exports.copyFilesToBuildFolder = exports.compile = void 0;
|
|
77
|
+
var utils_1 = require("@sasjs/utils");
|
|
78
|
+
var types_1 = require("@sasjs/utils/types");
|
|
77
79
|
var path_1 = __importDefault(require("path"));
|
|
78
80
|
var config_1 = require("../../utils/config");
|
|
79
|
-
var utils_1 = require("@sasjs/utils");
|
|
80
|
-
var web_1 = require("../web/web");
|
|
81
81
|
var file_1 = require("../../utils/file");
|
|
82
|
-
var
|
|
83
|
-
var checkCompileStatus_1 = require("./internal/checkCompileStatus");
|
|
82
|
+
var web_1 = require("../web/web");
|
|
84
83
|
var compileModule = __importStar(require("./compile"));
|
|
85
|
-
var
|
|
84
|
+
var checkCompileStatus_1 = require("./internal/checkCompileStatus");
|
|
86
85
|
var compileFile_1 = require("./internal/compileFile");
|
|
86
|
+
var getAllFolders_1 = require("./internal/getAllFolders");
|
|
87
87
|
var compileTestFile_1 = require("./internal/compileTestFile");
|
|
88
|
+
var copySyncFolder_1 = require("./internal/copySyncFolder");
|
|
88
89
|
var getDestinationPath_1 = require("./internal/getDestinationPath");
|
|
89
90
|
var loadDependencies_1 = require("./internal/loadDependencies");
|
|
90
|
-
var copySyncFolder_1 = require("./internal/copySyncFolder");
|
|
91
91
|
function compile(target, forceCompile) {
|
|
92
92
|
var _a, _b;
|
|
93
93
|
if (forceCompile === void 0) { forceCompile = false; }
|
|
@@ -531,12 +531,11 @@ function compileWeb(target) {
|
|
|
531
531
|
var configuration, streamConfig, streamWeb;
|
|
532
532
|
return __generator(this, function (_c) {
|
|
533
533
|
switch (_c.label) {
|
|
534
|
-
case 0:
|
|
535
|
-
|
|
536
|
-
configuration = (_c.sent()).configuration;
|
|
534
|
+
case 0:
|
|
535
|
+
configuration = process.sasjsConfig;
|
|
537
536
|
streamConfig = __assign(__assign({}, configuration === null || configuration === void 0 ? void 0 : configuration.streamConfig), target.streamConfig);
|
|
538
537
|
streamWeb = (_a = streamConfig.streamWeb) !== null && _a !== void 0 ? _a : false;
|
|
539
|
-
if (!streamWeb) return [3 /*break*/,
|
|
538
|
+
if (!streamWeb) return [3 /*break*/, 2];
|
|
540
539
|
(_b = process.logger) === null || _b === void 0 ? void 0 : _b.info('Compiling web app services since `streamWeb` is enabled.');
|
|
541
540
|
return [4 /*yield*/, (0, web_1.createWebAppServices)(target)
|
|
542
541
|
.then(function () { var _a; return (_a = process.logger) === null || _a === void 0 ? void 0 : _a.success("Web app services have been compiled."); })
|
|
@@ -544,10 +543,10 @@ function compileWeb(target) {
|
|
|
544
543
|
var _a;
|
|
545
544
|
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('An error has occurred when compiling web app services.', err.toString());
|
|
546
545
|
})];
|
|
547
|
-
case
|
|
546
|
+
case 1:
|
|
548
547
|
_c.sent();
|
|
549
|
-
_c.label =
|
|
550
|
-
case
|
|
548
|
+
_c.label = 2;
|
|
549
|
+
case 2: return [2 /*return*/];
|
|
551
550
|
}
|
|
552
551
|
});
|
|
553
552
|
});
|
|
@@ -556,21 +555,20 @@ var syncFolder = function (target) { return __awaiter(void 0, void 0, void 0, fu
|
|
|
556
555
|
var configuration;
|
|
557
556
|
return __generator(this, function (_a) {
|
|
558
557
|
switch (_a.label) {
|
|
559
|
-
case 0:
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
if (!configuration.syncFolder) return [3 /*break*/, 3];
|
|
558
|
+
case 0:
|
|
559
|
+
configuration = process.sasjsConfig;
|
|
560
|
+
if (!configuration.syncFolder) return [3 /*break*/, 2];
|
|
563
561
|
return [4 /*yield*/, (0, copySyncFolder_1.copySyncFolder)(configuration.syncFolder)];
|
|
564
|
-
case
|
|
562
|
+
case 1:
|
|
565
563
|
_a.sent();
|
|
566
|
-
_a.label =
|
|
567
|
-
case
|
|
568
|
-
if (!target.syncFolder) return [3 /*break*/,
|
|
564
|
+
_a.label = 2;
|
|
565
|
+
case 2:
|
|
566
|
+
if (!target.syncFolder) return [3 /*break*/, 4];
|
|
569
567
|
return [4 /*yield*/, (0, copySyncFolder_1.copySyncFolder)(target.syncFolder)];
|
|
570
|
-
case
|
|
568
|
+
case 3:
|
|
571
569
|
_a.sent();
|
|
572
|
-
_a.label =
|
|
573
|
-
case
|
|
570
|
+
_a.label = 4;
|
|
571
|
+
case 4: return [2 /*return*/];
|
|
574
572
|
}
|
|
575
573
|
});
|
|
576
574
|
}); };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { CompileTree, Configuration, Target } from '@sasjs/utils';
|
|
1
2
|
import { TestFlow } from '../../../types';
|
|
2
|
-
import { Target, Configuration, CompileTree } from '@sasjs/utils';
|
|
3
3
|
export declare function compileTestFile(target: Target, filePath: string, testVar: string | undefined, saveToRoot: boolean | undefined, removeOriginalFile: boolean | undefined, compileTree: CompileTree): Promise<void>;
|
|
4
4
|
export declare function copyTestMacroFiles(folderAbsolutePath: string): Promise<void>;
|
|
5
5
|
export declare const compileTestFlow: (target: Target, config?: Configuration) => Promise<TestFlow | undefined>;
|
|
@@ -65,13 +65,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
65
65
|
};
|
|
66
66
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
67
67
|
exports.compileTestFlow = exports.copyTestMacroFiles = exports.compileTestFile = void 0;
|
|
68
|
-
var types_1 = require("../../../types");
|
|
69
|
-
var path_1 = __importDefault(require("path"));
|
|
70
68
|
var utils_1 = require("@sasjs/utils");
|
|
71
|
-
var loadDependencies_1 = require("./loadDependencies");
|
|
72
|
-
var file_1 = require("../../../utils/file");
|
|
73
69
|
var chalk_1 = __importDefault(require("chalk"));
|
|
70
|
+
var path_1 = __importDefault(require("path"));
|
|
71
|
+
var types_1 = require("../../../types");
|
|
74
72
|
var config_1 = require("../../../utils/config");
|
|
73
|
+
var file_1 = require("../../../utils/file");
|
|
74
|
+
var loadDependencies_1 = require("./loadDependencies");
|
|
75
75
|
var getFileName = function (filePath) { return path_1.default.parse(filePath).base; };
|
|
76
76
|
function compileTestFile(target, filePath, testVar, saveToRoot, removeOriginalFile, compileTree) {
|
|
77
77
|
if (testVar === void 0) { testVar = ''; }
|
|
@@ -159,10 +159,10 @@ function copyTestMacroFiles(folderAbsolutePath) {
|
|
|
159
159
|
}
|
|
160
160
|
exports.copyTestMacroFiles = copyTestMacroFiles;
|
|
161
161
|
var compileTestFlow = function (target, config) { return __awaiter(void 0, void 0, void 0, function () {
|
|
162
|
-
var _a, buildDestinationFolder, buildDestinationTestFolder, testFiles,
|
|
163
|
-
var _c, _d, _e
|
|
164
|
-
return __generator(this, function (
|
|
165
|
-
switch (
|
|
162
|
+
var _a, buildDestinationFolder, buildDestinationTestFolder, testFiles, config_2, testFlow, testSetUp, testTearDown, testSetUpFileName_1, testTearDownFileName_1;
|
|
163
|
+
var _b, _c, _d, _e;
|
|
164
|
+
return __generator(this, function (_f) {
|
|
165
|
+
switch (_f.label) {
|
|
166
166
|
case 0:
|
|
167
167
|
if (target.testConfig &&
|
|
168
168
|
Object.keys(target.testConfig).includes('testFolders')) {
|
|
@@ -171,22 +171,14 @@ var compileTestFlow = function (target, config) { return __awaiter(void 0, void
|
|
|
171
171
|
_a = process.sasjsConstants, buildDestinationFolder = _a.buildDestinationFolder, buildDestinationTestFolder = _a.buildDestinationTestFolder;
|
|
172
172
|
return [4 /*yield*/, (0, utils_1.folderExists)(buildDestinationTestFolder)];
|
|
173
173
|
case 1:
|
|
174
|
-
if (!
|
|
174
|
+
if (!_f.sent()) return [3 /*break*/, 4];
|
|
175
175
|
return [4 /*yield*/, (0, utils_1.listFilesAndSubFoldersInFolder)(buildDestinationTestFolder)];
|
|
176
176
|
case 2:
|
|
177
|
-
testFiles = (
|
|
178
|
-
|
|
179
|
-
if (_b) return [3 /*break*/, 5];
|
|
180
|
-
return [4 /*yield*/, (0, config_1.getLocalOrGlobalConfig)()];
|
|
181
|
-
case 3: return [4 /*yield*/, (_g.sent()).configuration];
|
|
182
|
-
case 4:
|
|
183
|
-
_b = (_g.sent());
|
|
184
|
-
_g.label = 5;
|
|
185
|
-
case 5:
|
|
186
|
-
config = _b;
|
|
177
|
+
testFiles = (_f.sent()).map(function (file) { return path_1.default.join('tests', file); });
|
|
178
|
+
config_2 = process.sasjsConfig;
|
|
187
179
|
testFlow = { tests: [] };
|
|
188
|
-
testSetUp = ((
|
|
189
|
-
testTearDown = ((
|
|
180
|
+
testSetUp = ((_b = target.testConfig) === null || _b === void 0 ? void 0 : _b.testSetUp) || ((_c = config_2.testConfig) === null || _c === void 0 ? void 0 : _c.testSetUp);
|
|
181
|
+
testTearDown = ((_d = target.testConfig) === null || _d === void 0 ? void 0 : _d.testTearDown) || ((_e = config_2.testConfig) === null || _e === void 0 ? void 0 : _e.testTearDown);
|
|
190
182
|
if (testFiles.length) {
|
|
191
183
|
if (testSetUp) {
|
|
192
184
|
testSetUpFileName_1 = getFileName(testSetUp);
|
|
@@ -207,10 +199,10 @@ var compileTestFlow = function (target, config) { return __awaiter(void 0, void
|
|
|
207
199
|
return file.split(path_1.default.sep).join('/');
|
|
208
200
|
});
|
|
209
201
|
return [4 /*yield*/, printTestCoverage(testFlow, buildDestinationFolder, target)];
|
|
210
|
-
case
|
|
211
|
-
|
|
202
|
+
case 3:
|
|
203
|
+
_f.sent();
|
|
212
204
|
return [2 /*return*/, Promise.resolve(testFlow)];
|
|
213
|
-
case
|
|
205
|
+
case 4: return [2 /*return*/];
|
|
214
206
|
}
|
|
215
207
|
});
|
|
216
208
|
}); };
|
|
@@ -63,53 +63,41 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
63
63
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
64
64
|
exports.getAllFolders = exports.SasFileType = void 0;
|
|
65
65
|
var utils_1 = require("@sasjs/utils");
|
|
66
|
-
var config_1 = require("../../../utils/config");
|
|
67
66
|
var SasFileType;
|
|
68
67
|
(function (SasFileType) {
|
|
69
68
|
SasFileType["Service"] = "service";
|
|
70
69
|
SasFileType["Job"] = "job";
|
|
71
70
|
})(SasFileType = exports.SasFileType || (exports.SasFileType = {}));
|
|
72
71
|
var getAllFolders = function (target, type, rootConfig) { return __awaiter(void 0, void 0, void 0, function () {
|
|
73
|
-
var configuration,
|
|
74
|
-
return __generator(this, function (
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
configuration = _a;
|
|
86
|
-
addFolders = function (folders) {
|
|
87
|
-
allFolders = __spreadArray(__spreadArray([], __read((allFolders || [])), false), __read((folders || [])), false);
|
|
88
|
-
};
|
|
89
|
-
if (type === SasFileType.Service) {
|
|
90
|
-
config = configuration.serviceConfig;
|
|
91
|
-
folders = config === null || config === void 0 ? void 0 : config.serviceFolders;
|
|
92
|
-
addFolders(folders);
|
|
93
|
-
config = target.serviceConfig;
|
|
94
|
-
folders = config === null || config === void 0 ? void 0 : config.serviceFolders;
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
config = configuration.jobConfig;
|
|
98
|
-
folders = config === null || config === void 0 ? void 0 : config.jobFolders;
|
|
99
|
-
addFolders(folders);
|
|
100
|
-
config = target.jobConfig;
|
|
101
|
-
folders = config === null || config === void 0 ? void 0 : config.jobFolders;
|
|
102
|
-
}
|
|
103
|
-
addFolders(folders);
|
|
104
|
-
if (!allFolders)
|
|
105
|
-
return [2 /*return*/, []];
|
|
106
|
-
allFolders = allFolders.filter(function (p) { return !!p; });
|
|
107
|
-
buildSourceFolder = process.sasjsConstants.buildSourceFolder;
|
|
108
|
-
allFolders = allFolders.map(function (sasFile) {
|
|
109
|
-
return (0, utils_1.getAbsolutePath)(sasFile, buildSourceFolder);
|
|
110
|
-
});
|
|
111
|
-
return [2 /*return*/, __spreadArray([], __read(new Set(allFolders)), false)];
|
|
72
|
+
var configuration, allFolders, config, folders, addFolders, buildSourceFolder;
|
|
73
|
+
return __generator(this, function (_a) {
|
|
74
|
+
configuration = rootConfig || process.sasjsConfig;
|
|
75
|
+
addFolders = function (folders) {
|
|
76
|
+
allFolders = __spreadArray(__spreadArray([], __read((allFolders || [])), false), __read((folders || [])), false);
|
|
77
|
+
};
|
|
78
|
+
if (type === SasFileType.Service) {
|
|
79
|
+
config = configuration.serviceConfig;
|
|
80
|
+
folders = config === null || config === void 0 ? void 0 : config.serviceFolders;
|
|
81
|
+
addFolders(folders);
|
|
82
|
+
config = target.serviceConfig;
|
|
83
|
+
folders = config === null || config === void 0 ? void 0 : config.serviceFolders;
|
|
112
84
|
}
|
|
85
|
+
else {
|
|
86
|
+
config = configuration.jobConfig;
|
|
87
|
+
folders = config === null || config === void 0 ? void 0 : config.jobFolders;
|
|
88
|
+
addFolders(folders);
|
|
89
|
+
config = target.jobConfig;
|
|
90
|
+
folders = config === null || config === void 0 ? void 0 : config.jobFolders;
|
|
91
|
+
}
|
|
92
|
+
addFolders(folders);
|
|
93
|
+
if (!allFolders)
|
|
94
|
+
return [2 /*return*/, []];
|
|
95
|
+
allFolders = allFolders.filter(function (p) { return !!p; });
|
|
96
|
+
buildSourceFolder = process.sasjsConstants.buildSourceFolder;
|
|
97
|
+
allFolders = allFolders.map(function (sasFile) {
|
|
98
|
+
return (0, utils_1.getAbsolutePath)(sasFile, buildSourceFolder);
|
|
99
|
+
});
|
|
100
|
+
return [2 /*return*/, __spreadArray([], __read(new Set(allFolders)), false)];
|
|
113
101
|
});
|
|
114
102
|
}); };
|
|
115
103
|
exports.getAllFolders = getAllFolders;
|
|
@@ -38,7 +38,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.getServerType = void 0;
|
|
40
40
|
var types_1 = require("@sasjs/utils/types");
|
|
41
|
-
var config_1 = require("../../../utils/config");
|
|
42
41
|
/**
|
|
43
42
|
* Returns server type for 'compile' step.
|
|
44
43
|
* If target is not present, it looks for serverType at root level
|
|
@@ -49,17 +48,12 @@ function getServerType(target) {
|
|
|
49
48
|
return __awaiter(this, void 0, void 0, function () {
|
|
50
49
|
var configuration;
|
|
51
50
|
return __generator(this, function (_a) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
configuration = (_a.sent()).configuration;
|
|
59
|
-
return [2 /*return*/, (configuration === null || configuration === void 0 ? void 0 : configuration.serverType)
|
|
60
|
-
? configuration.serverType
|
|
61
|
-
: types_1.ServerType.SasViya];
|
|
62
|
-
}
|
|
51
|
+
if (target === null || target === void 0 ? void 0 : target.serverType)
|
|
52
|
+
return [2 /*return*/, target.serverType];
|
|
53
|
+
configuration = process.sasjsConfig;
|
|
54
|
+
return [2 /*return*/, (configuration === null || configuration === void 0 ? void 0 : configuration.serverType)
|
|
55
|
+
? configuration.serverType
|
|
56
|
+
: types_1.ServerType.SasViya];
|
|
63
57
|
});
|
|
64
58
|
});
|
|
65
59
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CompileTree, SASJsFileType, Target } from '@sasjs/utils';
|
|
2
2
|
export declare function loadDependencies(target: Target, filePath: string, macroFolders: string[], programFolders: string[], type: SASJsFileType, compileTree: CompileTree): Promise<string>;
|
|
3
3
|
export declare const getCompileTree: (target: Target) => CompileTree;
|
|
@@ -41,12 +41,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
exports.getCompileTree = exports.loadDependencies = void 0;
|
|
43
43
|
var utils_1 = require("@sasjs/utils");
|
|
44
|
-
var config_1 = require("../../../utils/config");
|
|
45
44
|
var path_1 = __importDefault(require("path"));
|
|
45
|
+
var config_1 = require("../../../utils/config");
|
|
46
46
|
function loadDependencies(target, filePath, macroFolders, programFolders, type, compileTree) {
|
|
47
47
|
var _a;
|
|
48
48
|
return __awaiter(this, void 0, void 0, function () {
|
|
49
|
-
var fileContent, _b, leaf,
|
|
49
|
+
var fileContent, _b, leaf, _c, buildSourceFolder, macroCorePath, binaryFolders, configuration;
|
|
50
50
|
return __generator(this, function (_d) {
|
|
51
51
|
switch (_d.label) {
|
|
52
52
|
case 0:
|
|
@@ -74,13 +74,12 @@ function loadDependencies(target, filePath, macroFolders, programFolders, type,
|
|
|
74
74
|
case 7:
|
|
75
75
|
fileContent = _d.sent();
|
|
76
76
|
_d.label = 8;
|
|
77
|
-
case 8:
|
|
78
|
-
case 9:
|
|
79
|
-
configuration = (_d.sent()).configuration;
|
|
77
|
+
case 8:
|
|
80
78
|
_c = process.sasjsConstants, buildSourceFolder = _c.buildSourceFolder, macroCorePath = _c.macroCorePath;
|
|
81
79
|
return [4 /*yield*/, (0, config_1.getBinaryFolders)(target)];
|
|
82
|
-
case
|
|
80
|
+
case 9:
|
|
83
81
|
binaryFolders = _d.sent();
|
|
82
|
+
configuration = process.sasjsConfig;
|
|
84
83
|
headerSyntaxNotices(fileContent);
|
|
85
84
|
return [4 /*yield*/, (0, utils_1.loadDependenciesFile)({
|
|
86
85
|
fileContent: fileContent,
|
|
@@ -95,7 +94,7 @@ function loadDependencies(target, filePath, macroFolders, programFolders, type,
|
|
|
95
94
|
binaryFolders: binaryFolders,
|
|
96
95
|
compileTree: compileTree
|
|
97
96
|
})];
|
|
98
|
-
case
|
|
97
|
+
case 10: return [2 /*return*/, _d.sent()];
|
|
99
98
|
}
|
|
100
99
|
});
|
|
101
100
|
});
|
|
@@ -112,7 +112,7 @@ describe('getAllFolders', function () {
|
|
|
112
112
|
var _c, _d;
|
|
113
113
|
return __generator(this, function (_e) {
|
|
114
114
|
switch (_e.label) {
|
|
115
|
-
case 0: return [4 /*yield*/, (0, utils_2.setConstants)()];
|
|
115
|
+
case 0: return [4 /*yield*/, (0, utils_2.setConstants)(false)];
|
|
116
116
|
case 1:
|
|
117
117
|
_e.sent();
|
|
118
118
|
_b = (_a = JSON).parse;
|