@sasjs/cli 3.0.2 → 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/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 -2
- package/build/commands/compile/internal/compileTestFile.d.ts +0 -2
- package/build/commands/compile/internal/compileTestFile.js +10 -14
- 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 +8 -8
- 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/deploy/deploy.js +1 -1
- 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/request/request.js +2 -2
- package/build/commands/run/run.js +1 -1
- package/build/commands/servicepack/deploy.js +1 -1
- package/build/commands/web/internal/getWebServiceContent.js +1 -2
- package/build/commands/web/web.js +12 -13
- package/build/utils/config.d.ts +1 -2
- package/build/utils/config.js +2 -2
- 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/utils.d.ts +0 -2
- package/build/utils/utils.js +1 -16
- package/package.json +2 -2
- 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
|
@@ -92,8 +92,6 @@ var config_1 = require("../../utils/config");
|
|
|
92
92
|
var compile_1 = require("../compile/compile");
|
|
93
93
|
var config_2 = require("./internal/config");
|
|
94
94
|
var getLaunchPageCode_1 = require("./internal/getLaunchPageCode");
|
|
95
|
-
var dependencies_1 = require("../shared/dependencies");
|
|
96
|
-
var compileTestFile_1 = require("../compile/internal/compileTestFile");
|
|
97
95
|
function build(target) {
|
|
98
96
|
return __awaiter(this, void 0, void 0, function () {
|
|
99
97
|
return __generator(this, function (_a) {
|
|
@@ -132,7 +130,7 @@ function createFinalSasFiles(target) {
|
|
|
132
130
|
function createFinalSasFile(target, streamConfig) {
|
|
133
131
|
var _a, _b, _c, _d, _e, _f;
|
|
134
132
|
return __awaiter(this, void 0, void 0, function () {
|
|
135
|
-
var streamWeb, buildConfig, serverType, name, macroFolders, buildOutputFileName, buildDestinationFolder, finalSasFileContent, finalFilePath, finalFilePathJSON, buildInfo, buildInit, buildTerm, dependencyFilePaths, dependenciesContent, _g, folderContent, folderContentJSON;
|
|
133
|
+
var streamWeb, buildConfig, serverType, name, macroFolders, buildOutputFileName, buildDestinationFolder, finalSasFileContent, finalFilePath, finalFilePathJSON, buildInfo, buildInit, buildTerm, macroCorePath, dependencyFilePaths, dependenciesContent, _g, folderContent, folderContentJSON;
|
|
136
134
|
return __generator(this, function (_h) {
|
|
137
135
|
switch (_h.label) {
|
|
138
136
|
case 0:
|
|
@@ -156,7 +154,8 @@ function createFinalSasFile(target, streamConfig) {
|
|
|
156
154
|
return [4 /*yield*/, config_2.getBuildTerm(target)];
|
|
157
155
|
case 4:
|
|
158
156
|
buildTerm = _h.sent();
|
|
159
|
-
|
|
157
|
+
macroCorePath = config_1.getMacroCorePath();
|
|
158
|
+
return [4 /*yield*/, utils_1.getDependencyPaths(buildTerm + "\n" + buildInit, macroFolders, macroCorePath)];
|
|
160
159
|
case 5:
|
|
161
160
|
dependencyFilePaths = _h.sent();
|
|
162
161
|
return [4 /*yield*/, getDependencies(dependencyFilePaths)];
|
|
@@ -189,7 +188,7 @@ function createFinalSasFile(target, streamConfig) {
|
|
|
189
188
|
}
|
|
190
189
|
function getBuildInfo(target, streamWeb) {
|
|
191
190
|
return __awaiter(this, void 0, void 0, function () {
|
|
192
|
-
var buildConfig, serverType, appLoc, macroFolders, createWebServiceScript, dependencyFilePaths, createFileScript, dependencyFilePathsForCreateFile, gsubScript, dependencyFilePathsForGsubScript, dependenciesContent, buildVars;
|
|
191
|
+
var buildConfig, serverType, appLoc, macroFolders, createWebServiceScript, macroCorePath, dependencyFilePaths, createFileScript, dependencyFilePathsForCreateFile, gsubScript, dependencyFilePathsForGsubScript, dependenciesContent, buildVars;
|
|
193
192
|
return __generator(this, function (_a) {
|
|
194
193
|
switch (_a.label) {
|
|
195
194
|
case 0:
|
|
@@ -201,8 +200,9 @@ function getBuildInfo(target, streamWeb) {
|
|
|
201
200
|
return [4 /*yield*/, getCreateWebServiceScript(serverType)];
|
|
202
201
|
case 2:
|
|
203
202
|
createWebServiceScript = _a.sent();
|
|
203
|
+
macroCorePath = config_1.getMacroCorePath();
|
|
204
204
|
buildConfig += createWebServiceScript + "\n";
|
|
205
|
-
return [4 /*yield*/,
|
|
205
|
+
return [4 /*yield*/, utils_1.getDependencyPaths(buildConfig, macroFolders, macroCorePath)];
|
|
206
206
|
case 3:
|
|
207
207
|
dependencyFilePaths = _a.sent();
|
|
208
208
|
if (!(target.serverType === utils_1.ServerType.SasViya && streamWeb)) return [3 /*break*/, 8];
|
|
@@ -210,7 +210,7 @@ function getBuildInfo(target, streamWeb) {
|
|
|
210
210
|
case 4:
|
|
211
211
|
createFileScript = _a.sent();
|
|
212
212
|
buildConfig += createFileScript + "\n";
|
|
213
|
-
return [4 /*yield*/,
|
|
213
|
+
return [4 /*yield*/, utils_1.getDependencyPaths(createFileScript, macroFolders, macroCorePath)
|
|
214
214
|
// The gsubScript is used to perform the replacement of the appLoc within
|
|
215
215
|
// the deployed index.html file. This only happens when deploying using the
|
|
216
216
|
// SAS Program (build.sas) approach.
|
|
@@ -221,7 +221,7 @@ function getBuildInfo(target, streamWeb) {
|
|
|
221
221
|
case 6:
|
|
222
222
|
gsubScript = _a.sent();
|
|
223
223
|
buildConfig += gsubScript + "\n";
|
|
224
|
-
return [4 /*yield*/,
|
|
224
|
+
return [4 /*yield*/, utils_1.getDependencyPaths(gsubScript, macroFolders, macroCorePath)];
|
|
225
225
|
case 7:
|
|
226
226
|
dependencyFilePathsForGsubScript = _a.sent();
|
|
227
227
|
dependencyFilePaths = __spreadArray([], __read(new Set(__spreadArray(__spreadArray(__spreadArray([], __read(dependencyFilePaths)), __read(dependencyFilePathsForCreateFile)), __read(dependencyFilePathsForGsubScript)))));
|
|
@@ -482,7 +482,7 @@ function getServiceText(serviceFileName, fileContent, serverType, testPath) {
|
|
|
482
482
|
}
|
|
483
483
|
});
|
|
484
484
|
return "%let service=" + serviceName + ";\nfilename sascode temp lrecl=32767;\ndata _null_;\nfile sascode;\n" + content + "\n\nrun;\n" + (serverType !== utils_1.ServerType.Sasjs
|
|
485
|
-
? getWebServiceScriptInvocation(serverType,
|
|
485
|
+
? getWebServiceScriptInvocation(serverType, utils_1.isTestFile(serviceFileName) && testPath ? "" + testPath : '')
|
|
486
486
|
: '') + "\nfilename sascode clear;\n";
|
|
487
487
|
}
|
|
488
488
|
function getFileText(fileName, fileContent, serverType) {
|
|
@@ -494,7 +494,7 @@ function getFileText(fileName, fileContent, serverType) {
|
|
|
494
494
|
}
|
|
495
495
|
function getWebFileContent(filecontent, type) {
|
|
496
496
|
var parsedContent = '';
|
|
497
|
-
var chunkedLines =
|
|
497
|
+
var chunkedLines = utils_1.chunk(filecontent);
|
|
498
498
|
if (chunkedLines.length === 1) {
|
|
499
499
|
parsedContent = " put '" + chunkedLines[0].split("'").join("''") + "';\n";
|
|
500
500
|
}
|
|
@@ -548,7 +548,7 @@ var convertVarsToSasFormat = function (vars) {
|
|
|
548
548
|
try {
|
|
549
549
|
for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
|
|
550
550
|
var _b = __read(entries_1_1.value, 2), name_1 = _b[0], value = _b[1];
|
|
551
|
-
var chunks =
|
|
551
|
+
var chunks = utils_1.chunk(value);
|
|
552
552
|
var chunkedString = chunks.join('%trim(\n)');
|
|
553
553
|
varsContent += "%let " + name_1 + "=" + chunkedString + ";\n";
|
|
554
554
|
}
|
|
@@ -41,9 +41,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
exports.getBuildTerm = exports.getBuildInit = void 0;
|
|
43
43
|
var path_1 = __importDefault(require("path"));
|
|
44
|
+
var utils_1 = require("@sasjs/utils");
|
|
44
45
|
var config_1 = require("../../../utils/config");
|
|
45
|
-
var utils_1 = require("../../../utils/utils");
|
|
46
|
-
var utils_2 = require("@sasjs/utils");
|
|
47
46
|
var getBuildInit = function (target) { return __awaiter(void 0, void 0, void 0, function () {
|
|
48
47
|
var buildSourceFolder, buildInitContent, configuration;
|
|
49
48
|
var _a, _b;
|
|
@@ -53,7 +52,7 @@ var getBuildInit = function (target) { return __awaiter(void 0, void 0, void 0,
|
|
|
53
52
|
buildSourceFolder = process.sasjsConstants.buildSourceFolder;
|
|
54
53
|
buildInitContent = '';
|
|
55
54
|
if (!((_a = target === null || target === void 0 ? void 0 : target.buildConfig) === null || _a === void 0 ? void 0 : _a.initProgram)) return [3 /*break*/, 2];
|
|
56
|
-
return [4 /*yield*/,
|
|
55
|
+
return [4 /*yield*/, utils_1.readFile(utils_1.getAbsolutePath(target.buildConfig.initProgram, buildSourceFolder))];
|
|
57
56
|
case 1:
|
|
58
57
|
buildInitContent = _c.sent();
|
|
59
58
|
return [3 /*break*/, 5];
|
|
@@ -61,7 +60,7 @@ var getBuildInit = function (target) { return __awaiter(void 0, void 0, void 0,
|
|
|
61
60
|
case 3:
|
|
62
61
|
configuration = _c.sent();
|
|
63
62
|
if (!((_b = configuration === null || configuration === void 0 ? void 0 : configuration.buildConfig) === null || _b === void 0 ? void 0 : _b.initProgram)) return [3 /*break*/, 5];
|
|
64
|
-
return [4 /*yield*/,
|
|
63
|
+
return [4 /*yield*/, utils_1.readFile(utils_1.getAbsolutePath(configuration.buildConfig.initProgram, buildSourceFolder))];
|
|
65
64
|
case 4:
|
|
66
65
|
buildInitContent = _c.sent();
|
|
67
66
|
_c.label = 5;
|
|
@@ -81,7 +80,7 @@ var getBuildTerm = function (target) { return __awaiter(void 0, void 0, void 0,
|
|
|
81
80
|
buildSourceFolder = process.sasjsConstants.buildSourceFolder;
|
|
82
81
|
buildTermContent = '';
|
|
83
82
|
if (!((_a = target === null || target === void 0 ? void 0 : target.buildConfig) === null || _a === void 0 ? void 0 : _a.termProgram)) return [3 /*break*/, 2];
|
|
84
|
-
return [4 /*yield*/,
|
|
83
|
+
return [4 /*yield*/, utils_1.readFile(utils_1.getAbsolutePath(target.buildConfig.termProgram, buildSourceFolder))];
|
|
85
84
|
case 1:
|
|
86
85
|
buildTermContent = _c.sent();
|
|
87
86
|
return [3 /*break*/, 5];
|
|
@@ -89,7 +88,7 @@ var getBuildTerm = function (target) { return __awaiter(void 0, void 0, void 0,
|
|
|
89
88
|
case 3:
|
|
90
89
|
configuration = _c.sent();
|
|
91
90
|
if (!((_b = configuration === null || configuration === void 0 ? void 0 : configuration.buildConfig) === null || _b === void 0 ? void 0 : _b.termProgram)) return [3 /*break*/, 5];
|
|
92
|
-
return [4 /*yield*/,
|
|
91
|
+
return [4 /*yield*/, utils_1.readFile(utils_1.getAbsolutePath(configuration.buildConfig.termProgram, buildSourceFolder))];
|
|
93
92
|
case 4:
|
|
94
93
|
buildTermContent = _c.sent();
|
|
95
94
|
_c.label = 5;
|
|
@@ -338,7 +338,7 @@ var compileServiceFolder = function (target, serviceFolder, macroFolders, progra
|
|
|
338
338
|
switch (_a.label) {
|
|
339
339
|
case 0:
|
|
340
340
|
filePath = path_1.default.join(destinationPath, fileName);
|
|
341
|
-
if (!
|
|
341
|
+
if (!utils_1.isTestFile(filePath)) return [3 /*break*/, 2];
|
|
342
342
|
return [4 /*yield*/, compileTestFile_1.compileTestFile(target, filePath, '', false)];
|
|
343
343
|
case 1:
|
|
344
344
|
_a.sent();
|
|
@@ -366,7 +366,7 @@ var compileServiceFolder = function (target, serviceFolder, macroFolders, progra
|
|
|
366
366
|
switch (_a.label) {
|
|
367
367
|
case 0:
|
|
368
368
|
filePath = path_1.default.join(destinationPath, subFolder, fileName);
|
|
369
|
-
if (!
|
|
369
|
+
if (!utils_1.isTestFile(filePath)) return [3 /*break*/, 2];
|
|
370
370
|
return [4 /*yield*/, compileTestFile_1.compileTestFile(target, filePath, '', false)];
|
|
371
371
|
case 1:
|
|
372
372
|
_a.sent();
|
|
@@ -409,7 +409,7 @@ var compileJobFolder = function (target, jobFolder, macroFolders, programFolders
|
|
|
409
409
|
switch (_a.label) {
|
|
410
410
|
case 0:
|
|
411
411
|
filePath = path_1.default.join(destinationPath, fileName);
|
|
412
|
-
if (!
|
|
412
|
+
if (!utils_1.isTestFile(fileName)) return [3 /*break*/, 2];
|
|
413
413
|
return [4 /*yield*/, compileTestFile_1.compileTestFile(target, filePath, '', false)];
|
|
414
414
|
case 1:
|
|
415
415
|
_a.sent();
|
|
@@ -437,7 +437,7 @@ var compileJobFolder = function (target, jobFolder, macroFolders, programFolders
|
|
|
437
437
|
switch (_a.label) {
|
|
438
438
|
case 0:
|
|
439
439
|
filePath = path_1.default.join(destinationPath, subFolder, fileName);
|
|
440
|
-
if (!
|
|
440
|
+
if (!utils_1.isTestFile(filePath)) return [3 /*break*/, 2];
|
|
441
441
|
return [4 /*yield*/, compileTestFile_1.compileTestFile(target, filePath, '', false)];
|
|
442
442
|
case 1:
|
|
443
443
|
_a.sent();
|
|
@@ -62,6 +62,7 @@ var compile_1 = require("./compile");
|
|
|
62
62
|
var path_1 = __importDefault(require("path"));
|
|
63
63
|
var getDestinationPath_1 = require("./internal/getDestinationPath");
|
|
64
64
|
var compileSingleFile_1 = require("./compileSingleFile");
|
|
65
|
+
var utils_2 = require("@sasjs/utils");
|
|
65
66
|
var CompileSubCommand;
|
|
66
67
|
(function (CompileSubCommand) {
|
|
67
68
|
CompileSubCommand["Job"] = "job";
|
|
@@ -121,7 +122,7 @@ var CompileCommand = /** @class */ (function (_super) {
|
|
|
121
122
|
var internal = [value, this.subCommand + "s"];
|
|
122
123
|
if (leafFolderName)
|
|
123
124
|
internal.push(leafFolderName);
|
|
124
|
-
outputPath =
|
|
125
|
+
outputPath = utils_2.getAbsolutePath(internal.join(path_1.default.sep), process.currentDir);
|
|
125
126
|
}
|
|
126
127
|
else {
|
|
127
128
|
outputPath =
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Target } from '@sasjs/utils
|
|
1
|
+
import { Target } from '@sasjs/utils';
|
|
2
2
|
export declare function compileSingleFile(target: Target, subCommand: string | undefined, source: string, output: string, insertProgramVar?: boolean): Promise<{
|
|
3
3
|
destinationPath: string;
|
|
4
4
|
}>;
|
|
@@ -42,8 +42,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
42
42
|
exports.compileSingleFile = void 0;
|
|
43
43
|
var path_1 = __importDefault(require("path"));
|
|
44
44
|
var config_1 = require("../../utils/config");
|
|
45
|
-
var utils_1 = require("
|
|
46
|
-
var utils_2 = require("@sasjs/utils");
|
|
45
|
+
var utils_1 = require("@sasjs/utils");
|
|
47
46
|
var compileServiceFile_1 = require("./internal/compileServiceFile");
|
|
48
47
|
var compileJobFile_1 = require("./internal/compileJobFile");
|
|
49
48
|
var identifySasFile_1 = require("./internal/identifySasFile");
|
|
@@ -85,20 +84,20 @@ function compileSingleFile(target, subCommand, source, output, insertProgramVar)
|
|
|
85
84
|
leafFolderName = source.split(path_1.default.sep).pop();
|
|
86
85
|
outputPathParts.pop(), outputPathParts.pop();
|
|
87
86
|
parentOutputFolder = outputPathParts.join(path_1.default.sep);
|
|
88
|
-
return [4 /*yield*/,
|
|
87
|
+
return [4 /*yield*/, utils_1.fileExists(parentOutputFolder)];
|
|
89
88
|
case 4:
|
|
90
89
|
pathExists = _c.sent();
|
|
91
90
|
if (!pathExists) return [3 /*break*/, 6];
|
|
92
|
-
return [4 /*yield*/,
|
|
91
|
+
return [4 /*yield*/, utils_1.deleteFolder(parentOutputFolder)];
|
|
93
92
|
case 5:
|
|
94
93
|
_c.sent();
|
|
95
94
|
_c.label = 6;
|
|
96
|
-
case 6: return [4 /*yield*/,
|
|
95
|
+
case 6: return [4 /*yield*/, utils_1.createFolder(output)];
|
|
97
96
|
case 7:
|
|
98
97
|
_c.sent();
|
|
99
98
|
sourceFileName = sourcePath.split(path_1.default.sep).pop();
|
|
100
99
|
destinationPath = path_1.default.join(output, sourceFileName);
|
|
101
|
-
return [4 /*yield*/,
|
|
100
|
+
return [4 /*yield*/, utils_1.copy(sourcePath, destinationPath)];
|
|
102
101
|
case 8:
|
|
103
102
|
_c.sent();
|
|
104
103
|
sourceFileNameWithoutExt = sourceFileName.split('.')[0];
|
|
@@ -144,7 +143,7 @@ function validateSourcePath(path) {
|
|
|
144
143
|
isSourceFile = /\.sas$/i.test(path);
|
|
145
144
|
if (!isSourceFile)
|
|
146
145
|
return [2 /*return*/, false];
|
|
147
|
-
return [4 /*yield*/,
|
|
146
|
+
return [4 /*yield*/, utils_1.fileExists(path)];
|
|
148
147
|
case 1: return [2 /*return*/, _a.sent()];
|
|
149
148
|
}
|
|
150
149
|
});
|
|
@@ -38,7 +38,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.compareFolders = void 0;
|
|
40
40
|
var utils_1 = require("@sasjs/utils");
|
|
41
|
-
var compileTestFile_1 = require("./compileTestFile");
|
|
42
41
|
var compareFolders = function (sourcePath, destinationPath, exceptions) { return __awaiter(void 0, void 0, void 0, function () {
|
|
43
42
|
var sourcePathExists, destinationPathExists, sourceSubFolders, destinationSubFolders, sourceFiles, destinationFiles, areSubFoldersMatching, missingSubFolders, areFilesMatching, missingFiles;
|
|
44
43
|
return __generator(this, function (_a) {
|
|
@@ -65,7 +64,7 @@ var compareFolders = function (sourcePath, destinationPath, exceptions) { return
|
|
|
65
64
|
case 4:
|
|
66
65
|
destinationSubFolders = (_a.sent());
|
|
67
66
|
return [4 /*yield*/, utils_1.listFilesInFolder(sourcePath).then(function (files) {
|
|
68
|
-
return files.filter(function (file) { return !
|
|
67
|
+
return files.filter(function (file) { return !utils_1.isTestFile(file); });
|
|
69
68
|
})];
|
|
70
69
|
case 5:
|
|
71
70
|
sourceFiles = (_a.sent());
|
|
@@ -45,7 +45,7 @@ function compileJobFile(target, filePath, macroFolders, programFolders, programV
|
|
|
45
45
|
var dependencies;
|
|
46
46
|
return __generator(this, function (_a) {
|
|
47
47
|
switch (_a.label) {
|
|
48
|
-
case 0: return [4 /*yield*/, loadDependencies_1.loadDependencies(target, filePath, macroFolders, programFolders,
|
|
48
|
+
case 0: return [4 /*yield*/, loadDependencies_1.loadDependencies(target, filePath, macroFolders, programFolders, utils_1.isTestFile(filePath) ? utils_1.SASJsFileType.test : utils_1.SASJsFileType.job)];
|
|
49
49
|
case 1:
|
|
50
50
|
dependencies = _a.sent();
|
|
51
51
|
dependencies = "" + (programVar ? programVar + '\n' : '') + dependencies;
|
|
@@ -43,14 +43,13 @@ var types_1 = require("@sasjs/utils/types");
|
|
|
43
43
|
var error_1 = require("@sasjs/utils/error");
|
|
44
44
|
var loadDependencies_1 = require("./loadDependencies");
|
|
45
45
|
var getServerType_1 = require("./getServerType");
|
|
46
|
-
var compileTestFile_1 = require("./compileTestFile");
|
|
47
46
|
function compileServiceFile(target, filePath, macroFolders, programFolders, programVar) {
|
|
48
47
|
if (programVar === void 0) { programVar = ''; }
|
|
49
48
|
return __awaiter(this, void 0, void 0, function () {
|
|
50
49
|
var dependencies, serverType, preCode;
|
|
51
50
|
return __generator(this, function (_a) {
|
|
52
51
|
switch (_a.label) {
|
|
53
|
-
case 0: return [4 /*yield*/, loadDependencies_1.loadDependencies(target, filePath, macroFolders, programFolders,
|
|
52
|
+
case 0: return [4 /*yield*/, loadDependencies_1.loadDependencies(target, filePath, macroFolders, programFolders, utils_1.isTestFile(filePath) ? types_1.SASJsFileType.test : types_1.SASJsFileType.service)];
|
|
54
53
|
case 1:
|
|
55
54
|
dependencies = _a.sent();
|
|
56
55
|
return [4 /*yield*/, getServerType_1.getServerType(target)];
|
|
@@ -2,6 +2,4 @@ import { Target } from '@sasjs/utils';
|
|
|
2
2
|
export declare function compileTestFile(target: Target, filePath: string, testVar?: string, saveToRoot?: boolean, removeOriginalFile?: boolean): Promise<void>;
|
|
3
3
|
export declare function moveTestFile(filePath: string): Promise<void>;
|
|
4
4
|
export declare function copyTestMacroFiles(folderAbsolutePath: string): Promise<void>;
|
|
5
|
-
export declare const testFileRegExp: RegExp;
|
|
6
|
-
export declare const isTestFile: (fileName: string) => boolean;
|
|
7
5
|
export declare const compileTestFlow: (target: Target) => Promise<void>;
|
|
@@ -60,7 +60,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
60
60
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
61
61
|
};
|
|
62
62
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
63
|
-
exports.compileTestFlow = exports.
|
|
63
|
+
exports.compileTestFlow = exports.copyTestMacroFiles = exports.moveTestFile = exports.compileTestFile = void 0;
|
|
64
64
|
var types_1 = require("../../../types");
|
|
65
65
|
var path_1 = __importDefault(require("path"));
|
|
66
66
|
var utils_1 = require("@sasjs/utils");
|
|
@@ -69,7 +69,6 @@ var file_1 = require("../../../utils/file");
|
|
|
69
69
|
var chalk_1 = __importDefault(require("chalk"));
|
|
70
70
|
var config_1 = require("../../../utils/config");
|
|
71
71
|
var compileServiceFile_1 = require("./compileServiceFile");
|
|
72
|
-
var utils_2 = require("../../../utils/utils");
|
|
73
72
|
var testsBuildFolder = function () {
|
|
74
73
|
return path_1.default.join(process.projectDir, 'sasjsbuild', 'tests');
|
|
75
74
|
};
|
|
@@ -85,12 +84,12 @@ function compileTestFile(target, filePath, testVar, saveToRoot, removeOriginalFi
|
|
|
85
84
|
case 0:
|
|
86
85
|
_a = loadDependencies_1.loadDependencies;
|
|
87
86
|
_b = [target,
|
|
88
|
-
|
|
87
|
+
utils_1.getAbsolutePath(filePath, process.projectDir)];
|
|
89
88
|
return [4 /*yield*/, config_1.getMacroFolders(target)];
|
|
90
89
|
case 1:
|
|
91
90
|
_b = _b.concat([_c.sent()]);
|
|
92
91
|
return [4 /*yield*/, config_1.getProgramFolders(target)];
|
|
93
|
-
case 2: return [4 /*yield*/, _a.apply(void 0, _b.concat([_c.sent(),
|
|
92
|
+
case 2: return [4 /*yield*/, _a.apply(void 0, _b.concat([_c.sent(), utils_1.SASJsFileType.test]))];
|
|
94
93
|
case 3:
|
|
95
94
|
dependencies = _c.sent();
|
|
96
95
|
return [4 /*yield*/, compileServiceFile_1.getPreCodeForServicePack(target.serverType)];
|
|
@@ -128,7 +127,7 @@ function moveTestFile(filePath) {
|
|
|
128
127
|
switch (_a.label) {
|
|
129
128
|
case 0:
|
|
130
129
|
fileName = filePath.split(path_1.default.sep).pop();
|
|
131
|
-
if (!
|
|
130
|
+
if (!utils_1.isTestFile(fileName))
|
|
132
131
|
return [2 /*return*/];
|
|
133
132
|
destinationPath = filePath.replace('sasjsbuild', 'sasjsbuild/tests');
|
|
134
133
|
testDestinationFolder = destinationPath
|
|
@@ -171,7 +170,7 @@ function copyTestMacroFiles(folderAbsolutePath) {
|
|
|
171
170
|
case 0: return [4 /*yield*/, utils_1.listFilesAndSubFoldersInFolder(folderAbsolutePath)];
|
|
172
171
|
case 1:
|
|
173
172
|
macroFiles = _a.sent();
|
|
174
|
-
macroTestFiles = macroFiles.filter(function (item) { return
|
|
173
|
+
macroTestFiles = macroFiles.filter(function (item) { return utils_1.testFileRegExp.test(item); });
|
|
175
174
|
return [4 /*yield*/, utils_1.asyncForEach(macroTestFiles, function (file) { return __awaiter(_this, void 0, void 0, function () {
|
|
176
175
|
var destinationFile;
|
|
177
176
|
return __generator(this, function (_a) {
|
|
@@ -197,9 +196,6 @@ function copyTestMacroFiles(folderAbsolutePath) {
|
|
|
197
196
|
});
|
|
198
197
|
}
|
|
199
198
|
exports.copyTestMacroFiles = copyTestMacroFiles;
|
|
200
|
-
exports.testFileRegExp = /\.test\.(\d+\.)?sas$/i;
|
|
201
|
-
var isTestFile = function (fileName) { return exports.testFileRegExp.test(fileName); };
|
|
202
|
-
exports.isTestFile = isTestFile;
|
|
203
199
|
var compileTestFlow = function (target) { return __awaiter(void 0, void 0, void 0, function () {
|
|
204
200
|
var _a, buildDestinationFolder, buildDestinationTestFolder, testFiles, testFlow, testSetUp, testTearDown, testSetUpFileName_1, testTearDownFileName_1;
|
|
205
201
|
var _b, _c;
|
|
@@ -278,14 +274,14 @@ var printTestCoverage = function (testFlow, buildDestinationFolder, target) { re
|
|
|
278
274
|
shouldBeCovered = shouldBeCovered.split(path_1.default.sep).pop() || '';
|
|
279
275
|
}
|
|
280
276
|
if (testFlow.tests.find(function (testFile) {
|
|
281
|
-
var testCovering = testFile.replace(
|
|
277
|
+
var testCovering = testFile.replace(utils_1.testFileRegExp, '');
|
|
282
278
|
if (type === 'macros') {
|
|
283
279
|
testCovering = testCovering.split(path_1.default.sep).pop() || '';
|
|
284
280
|
}
|
|
285
281
|
if (testCovering === shouldBeCovered) {
|
|
286
282
|
extraTests = extraTests.filter(function (test) {
|
|
287
|
-
return test.replace(
|
|
288
|
-
testFile.replace(
|
|
283
|
+
return test.replace(utils_1.testFileRegExp, '') !==
|
|
284
|
+
testFile.replace(utils_1.testFileRegExp, '');
|
|
289
285
|
});
|
|
290
286
|
}
|
|
291
287
|
return testCovering === shouldBeCovered;
|
|
@@ -312,7 +308,7 @@ var printTestCoverage = function (testFlow, buildDestinationFolder, target) { re
|
|
|
312
308
|
return [4 /*yield*/, utils_1.asyncForEach(macroFolders, function (macroFolder) { return __awaiter(void 0, void 0, void 0, function () {
|
|
313
309
|
return __generator(this, function (_a) {
|
|
314
310
|
switch (_a.label) {
|
|
315
|
-
case 0: return [4 /*yield*/, collectCoverage(macroFolder, 'macros', function (file) { return !
|
|
311
|
+
case 0: return [4 /*yield*/, collectCoverage(macroFolder, 'macros', function (file) { return !utils_1.testFileRegExp.test(file); })];
|
|
316
312
|
case 1:
|
|
317
313
|
_a.sent();
|
|
318
314
|
return [2 /*return*/];
|
|
@@ -353,7 +349,7 @@ var printTestCoverage = function (testFlow, buildDestinationFolder, target) { re
|
|
|
353
349
|
return __generator(this, function (_a) {
|
|
354
350
|
switch (_a.label) {
|
|
355
351
|
case 0: return [4 /*yield*/, utils_1.listFilesAndSubFoldersInFolder(macroFolder)];
|
|
356
|
-
case 1: return [4 /*yield*/, (_a.sent()).filter(function (file) { return !
|
|
352
|
+
case 1: return [4 /*yield*/, (_a.sent()).filter(function (file) { return !utils_1.isTestFile(file); })];
|
|
357
353
|
case 2:
|
|
358
354
|
macros = _a.sent();
|
|
359
355
|
macroTypeRegExp = new RegExp("^macros" + utils_1.pathSepEscaped);
|
|
@@ -58,8 +58,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
|
58
58
|
};
|
|
59
59
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
60
|
exports.getAllJobFolders = void 0;
|
|
61
|
+
var utils_1 = require("@sasjs/utils");
|
|
61
62
|
var config_1 = require("../../../utils/config");
|
|
62
|
-
var utils_1 = require("../../../utils/utils");
|
|
63
63
|
function getAllJobFolders(target) {
|
|
64
64
|
var _a, _b;
|
|
65
65
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -58,8 +58,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
|
58
58
|
};
|
|
59
59
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
60
|
exports.getAllServiceFolders = void 0;
|
|
61
|
+
var utils_1 = require("@sasjs/utils");
|
|
61
62
|
var config_1 = require("../../../utils/config");
|
|
62
|
-
var utils_1 = require("../../../utils/utils");
|
|
63
63
|
function getAllServiceFolders(target) {
|
|
64
64
|
var _a, _b;
|
|
65
65
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { Target } from '@sasjs/utils';
|
|
2
|
-
export declare function loadDependencies(target: Target, filePath: string, macroFolders: string[], programFolders: string[], type
|
|
3
|
-
export declare const getVars: (varType: 'service' | 'job' | 'test', target: Target) => Promise<string>;
|
|
1
|
+
import { Target, SASJsFileType } from '@sasjs/utils';
|
|
2
|
+
export declare function loadDependencies(target: Target, filePath: string, macroFolders: string[], programFolders: string[], type: SASJsFileType): Promise<string>;
|