@sasjs/cli 4.0.7 → 4.1.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/commands/build/build.js +3 -3
- package/build/commands/compile/compile.js +26 -32
- package/build/commands/compile/compileCommand.js +4 -2
- package/build/commands/compile/compileSingleFile.d.ts +5 -0
- package/build/commands/compile/compileSingleFile.js +36 -25
- package/build/commands/compile/internal/checkCompileStatus.js +7 -9
- package/build/commands/compile/internal/compileFile.js +2 -2
- package/build/commands/compile/internal/compileTestFile.d.ts +1 -1
- package/build/commands/compile/internal/compileTestFile.js +16 -14
- package/build/commands/compile/internal/getAllFolders.d.ts +3 -2
- package/build/commands/compile/internal/getAllFolders.js +1 -0
- package/build/commands/compile/internal/identifySasFile.d.ts +2 -1
- package/build/commands/compile/internal/identifySasFile.js +20 -11
- package/build/commands/compile/internal/index.d.ts +9 -0
- package/build/commands/compile/internal/index.js +25 -0
- package/build/commands/compile/internal/spec/compileTestFile.spec.js +4 -4
- package/build/commands/compile/internal/spec/getAllFolders.spec.js +3 -3
- package/build/commands/compile/spec/compareFolders.spec.js +8 -8
- package/build/commands/compile/spec/compileFile.spec.js +5 -6
- package/build/commands/compile/spec/compileSingleFile.spec.d.ts +1 -0
- package/build/commands/compile/spec/compileSingleFile.spec.js +162 -0
- package/build/commands/compile/spec/loadDependencies.spec.js +13 -13
- package/build/commands/help/help.js +3 -2
- package/build/commands/run/run.js +2 -2
- package/build/types/command/commandBase.js +1 -1
- package/package.json +2 -2
- package/build/commands/compile/internal/getServerType.d.ts +0 -9
- package/build/commands/compile/internal/getServerType.js +0 -60
|
@@ -95,7 +95,7 @@ var compressAndSave_1 = require("../../utils/compressAndSave");
|
|
|
95
95
|
var config_1 = require("../../utils/config");
|
|
96
96
|
var file_1 = require("../../utils/file");
|
|
97
97
|
var compile_1 = require("../compile/compile");
|
|
98
|
-
var
|
|
98
|
+
var internal_1 = require("../compile/internal");
|
|
99
99
|
var config_2 = require("./internal/config");
|
|
100
100
|
var getLaunchPageCode_1 = require("./internal/getLaunchPageCode");
|
|
101
101
|
function build(target) {
|
|
@@ -550,7 +550,7 @@ var getDepsContent = function (deps, target, macroFolders) { return __awaiter(vo
|
|
|
550
550
|
switch (_a.label) {
|
|
551
551
|
case 0:
|
|
552
552
|
dependenciesContent = '';
|
|
553
|
-
compileTree = (0,
|
|
553
|
+
compileTree = (0, internal_1.getCompileTree)(target);
|
|
554
554
|
return [4 /*yield*/, (0, utils_1.asyncForEach)(deps, function (fp) { return __awaiter(void 0, void 0, void 0, function () {
|
|
555
555
|
var _a, _b;
|
|
556
556
|
return __generator(this, function (_c) {
|
|
@@ -558,7 +558,7 @@ var getDepsContent = function (deps, target, macroFolders) { return __awaiter(vo
|
|
|
558
558
|
case 0:
|
|
559
559
|
_a = dependenciesContent;
|
|
560
560
|
_b = '\n';
|
|
561
|
-
return [4 /*yield*/, (0,
|
|
561
|
+
return [4 /*yield*/, (0, internal_1.loadDependencies)(target, fp, macroFolders, [], types_1.SASJsFileType.file, compileTree)];
|
|
562
562
|
case 1:
|
|
563
563
|
dependenciesContent = _a + (_b +
|
|
564
564
|
(_c.sent()));
|
|
@@ -82,13 +82,7 @@ var config_1 = require("../../utils/config");
|
|
|
82
82
|
var file_1 = require("../../utils/file");
|
|
83
83
|
var web_1 = require("../web/web");
|
|
84
84
|
var compileModule = __importStar(require("./compile"));
|
|
85
|
-
var
|
|
86
|
-
var compileFile_1 = require("./internal/compileFile");
|
|
87
|
-
var getAllFolders_1 = require("./internal/getAllFolders");
|
|
88
|
-
var compileTestFile_1 = require("./internal/compileTestFile");
|
|
89
|
-
var copySyncFolder_1 = require("./internal/copySyncFolder");
|
|
90
|
-
var getDestinationPath_1 = require("./internal/getDestinationPath");
|
|
91
|
-
var loadDependencies_1 = require("./internal/loadDependencies");
|
|
85
|
+
var internal_1 = require("./internal");
|
|
92
86
|
function compile(target, forceCompile) {
|
|
93
87
|
var _a, _b;
|
|
94
88
|
if (forceCompile === void 0) { forceCompile = false; }
|
|
@@ -97,7 +91,7 @@ function compile(target, forceCompile) {
|
|
|
97
91
|
var _this = this;
|
|
98
92
|
return __generator(this, function (_c) {
|
|
99
93
|
switch (_c.label) {
|
|
100
|
-
case 0: return [4 /*yield*/, (0,
|
|
94
|
+
case 0: return [4 /*yield*/, (0, internal_1.checkCompileStatus)(target, ['tests'])
|
|
101
95
|
// no need to compile again
|
|
102
96
|
];
|
|
103
97
|
case 1:
|
|
@@ -115,7 +109,7 @@ function compile(target, forceCompile) {
|
|
|
115
109
|
})];
|
|
116
110
|
case 2:
|
|
117
111
|
_c.sent();
|
|
118
|
-
compileTree = (0,
|
|
112
|
+
compileTree = (0, internal_1.getCompileTree)(target);
|
|
119
113
|
return [4 /*yield*/, compileModule.compileJobsServicesTests(target, compileTree)];
|
|
120
114
|
case 3:
|
|
121
115
|
_c.sent();
|
|
@@ -128,7 +122,7 @@ function compile(target, forceCompile) {
|
|
|
128
122
|
programFolders_1 = _c.sent();
|
|
129
123
|
return [4 /*yield*/, (0, utils_1.asyncForEach)(macroFolders, function (macroFolder) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
130
124
|
switch (_a.label) {
|
|
131
|
-
case 0: return [4 /*yield*/, (0,
|
|
125
|
+
case 0: return [4 /*yield*/, (0, internal_1.copyTestMacroFiles)(macroFolder)];
|
|
132
126
|
case 1: return [2 /*return*/, _a.sent()];
|
|
133
127
|
}
|
|
134
128
|
}); }); })];
|
|
@@ -145,7 +139,7 @@ function compile(target, forceCompile) {
|
|
|
145
139
|
return [4 /*yield*/, (0, utils_1.asyncForEach)(macroTestFiles, function (macroTestFile) { return __awaiter(_this, void 0, void 0, function () {
|
|
146
140
|
return __generator(this, function (_a) {
|
|
147
141
|
switch (_a.label) {
|
|
148
|
-
case 0: return [4 /*yield*/, (0,
|
|
142
|
+
case 0: return [4 /*yield*/, (0, internal_1.compileFile)(target, path_1.default.join(buildMacroTestFolder_1, macroTestFile), macroFolders, programFolders_1, undefined, compileTree, types_1.SASJsFileType.service, '')];
|
|
149
143
|
case 1: return [2 /*return*/, _a.sent()];
|
|
150
144
|
}
|
|
151
145
|
});
|
|
@@ -156,7 +150,7 @@ function compile(target, forceCompile) {
|
|
|
156
150
|
case 11: return [4 /*yield*/, compileTree.saveTree()];
|
|
157
151
|
case 12:
|
|
158
152
|
_c.sent();
|
|
159
|
-
return [4 /*yield*/, (0,
|
|
153
|
+
return [4 /*yield*/, (0, internal_1.compileTestFlow)(target).catch(function (err) { var _a; return (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('Test flow compilation has failed.'); })];
|
|
160
154
|
case 13:
|
|
161
155
|
_c.sent();
|
|
162
156
|
return [4 /*yield*/, compileWeb(target)];
|
|
@@ -187,10 +181,10 @@ function copyFilesToBuildFolder(target) {
|
|
|
187
181
|
_c.label = 2;
|
|
188
182
|
case 2:
|
|
189
183
|
_c.trys.push([2, 7, , 8]);
|
|
190
|
-
return [4 /*yield*/, (0,
|
|
184
|
+
return [4 /*yield*/, (0, internal_1.getAllFolders)(target, internal_1.SasFileType.Service)];
|
|
191
185
|
case 3:
|
|
192
186
|
serviceFolders = _c.sent();
|
|
193
|
-
return [4 /*yield*/, (0,
|
|
187
|
+
return [4 /*yield*/, (0, internal_1.getAllFolders)(target, internal_1.SasFileType.Job)
|
|
194
188
|
// REFACTOR
|
|
195
189
|
];
|
|
196
190
|
case 4:
|
|
@@ -201,7 +195,7 @@ function copyFilesToBuildFolder(target) {
|
|
|
201
195
|
return __generator(this, function (_a) {
|
|
202
196
|
switch (_a.label) {
|
|
203
197
|
case 0:
|
|
204
|
-
destinationPath = (0,
|
|
198
|
+
destinationPath = (0, internal_1.getDestinationServicePath)(serviceFolder);
|
|
205
199
|
return [4 /*yield*/, (0, utils_1.copy)(serviceFolder, destinationPath)];
|
|
206
200
|
case 1:
|
|
207
201
|
_a.sent();
|
|
@@ -217,7 +211,7 @@ function copyFilesToBuildFolder(target) {
|
|
|
217
211
|
return __generator(this, function (_a) {
|
|
218
212
|
switch (_a.label) {
|
|
219
213
|
case 0:
|
|
220
|
-
destinationPath = (0,
|
|
214
|
+
destinationPath = (0, internal_1.getDestinationJobPath)(jobFolder);
|
|
221
215
|
return [4 /*yield*/, (0, utils_1.copy)(jobFolder, destinationPath)];
|
|
222
216
|
case 1:
|
|
223
217
|
_a.sent();
|
|
@@ -246,10 +240,10 @@ function compileJobsServicesTests(target, compileTree) {
|
|
|
246
240
|
switch (_a.label) {
|
|
247
241
|
case 0:
|
|
248
242
|
_a.trys.push([0, 13, , 14]);
|
|
249
|
-
return [4 /*yield*/, (0,
|
|
243
|
+
return [4 /*yield*/, (0, internal_1.getAllFolders)(target, internal_1.SasFileType.Service)];
|
|
250
244
|
case 1:
|
|
251
245
|
serviceFolders = _a.sent();
|
|
252
|
-
return [4 /*yield*/, (0,
|
|
246
|
+
return [4 /*yield*/, (0, internal_1.getAllFolders)(target, internal_1.SasFileType.Job)];
|
|
253
247
|
case 2:
|
|
254
248
|
jobFolders = _a.sent();
|
|
255
249
|
return [4 /*yield*/, (0, config_1.getMacroFolders)(target)];
|
|
@@ -265,7 +259,7 @@ function compileJobsServicesTests(target, compileTree) {
|
|
|
265
259
|
case 6:
|
|
266
260
|
testTearDown = _a.sent();
|
|
267
261
|
if (!testSetUp) return [3 /*break*/, 8];
|
|
268
|
-
return [4 /*yield*/, (0,
|
|
262
|
+
return [4 /*yield*/, (0, internal_1.compileTestFile)(target, testSetUp, '', true, false, compileTree).catch(function (err) {
|
|
269
263
|
throw (0, error_1.prefixMessage)(err, 'Test set up compilation has failed. ');
|
|
270
264
|
})];
|
|
271
265
|
case 7:
|
|
@@ -273,7 +267,7 @@ function compileJobsServicesTests(target, compileTree) {
|
|
|
273
267
|
_a.label = 8;
|
|
274
268
|
case 8:
|
|
275
269
|
if (!testTearDown) return [3 /*break*/, 10];
|
|
276
|
-
return [4 /*yield*/, (0,
|
|
270
|
+
return [4 /*yield*/, (0, internal_1.compileTestFile)(target, testTearDown, '', true, false, compileTree).catch(function (err) {
|
|
277
271
|
throw (0, error_1.prefixMessage)(err, 'Test tear down compilation has failed. ');
|
|
278
272
|
})];
|
|
279
273
|
case 9:
|
|
@@ -344,7 +338,7 @@ var compileServiceFolder = function (target, serviceFolder, macroFolders, progra
|
|
|
344
338
|
return __generator(this, function (_a) {
|
|
345
339
|
switch (_a.label) {
|
|
346
340
|
case 0:
|
|
347
|
-
destinationPath = (0,
|
|
341
|
+
destinationPath = (0, internal_1.getDestinationServicePath)(serviceFolder);
|
|
348
342
|
return [4 /*yield*/, (0, utils_1.listSubFoldersInFolder)(destinationPath)];
|
|
349
343
|
case 1:
|
|
350
344
|
subFolders = _a.sent();
|
|
@@ -379,11 +373,11 @@ var compileServiceFolder = function (target, serviceFolder, macroFolders, progra
|
|
|
379
373
|
case 0:
|
|
380
374
|
filePath = path_1.default.join(destinationPath, fileName);
|
|
381
375
|
if (!(0, utils_1.isTestFile)(filePath)) return [3 /*break*/, 2];
|
|
382
|
-
return [4 /*yield*/, (0,
|
|
376
|
+
return [4 /*yield*/, (0, internal_1.compileTestFile)(target, filePath, '', false, undefined, compileTree)];
|
|
383
377
|
case 1:
|
|
384
378
|
_a.sent();
|
|
385
379
|
return [3 /*break*/, 4];
|
|
386
|
-
case 2: return [4 /*yield*/, (0,
|
|
380
|
+
case 2: return [4 /*yield*/, (0, internal_1.compileFile)(target, filePath, macroFolders, programFolders, undefined, compileTree, types_1.SASJsFileType.service, serviceFolder)];
|
|
387
381
|
case 3:
|
|
388
382
|
_a.sent();
|
|
389
383
|
_a.label = 4;
|
|
@@ -409,11 +403,11 @@ var compileServiceFolder = function (target, serviceFolder, macroFolders, progra
|
|
|
409
403
|
case 0:
|
|
410
404
|
filePath = path_1.default.join(destinationPath, subFolder, fileName);
|
|
411
405
|
if (!(0, utils_1.isTestFile)(filePath)) return [3 /*break*/, 2];
|
|
412
|
-
return [4 /*yield*/, (0,
|
|
406
|
+
return [4 /*yield*/, (0, internal_1.compileTestFile)(target, filePath, '', false, undefined, compileTree)];
|
|
413
407
|
case 1:
|
|
414
408
|
_a.sent();
|
|
415
409
|
return [3 /*break*/, 4];
|
|
416
|
-
case 2: return [4 /*yield*/, (0,
|
|
410
|
+
case 2: return [4 /*yield*/, (0, internal_1.compileFile)(target, filePath, macroFolders, programFolders, undefined, compileTree, types_1.SASJsFileType.service, sourceFolder)];
|
|
417
411
|
case 3:
|
|
418
412
|
_a.sent();
|
|
419
413
|
_a.label = 4;
|
|
@@ -439,7 +433,7 @@ var compileJobFolder = function (target, jobFolder, macroFolders, programFolders
|
|
|
439
433
|
return __generator(this, function (_a) {
|
|
440
434
|
switch (_a.label) {
|
|
441
435
|
case 0:
|
|
442
|
-
destinationPath = (0,
|
|
436
|
+
destinationPath = (0, internal_1.getDestinationJobPath)(jobFolder);
|
|
443
437
|
return [4 /*yield*/, (0, utils_1.listSubFoldersInFolder)(destinationPath)];
|
|
444
438
|
case 1:
|
|
445
439
|
subFolders = _a.sent();
|
|
@@ -474,11 +468,11 @@ var compileJobFolder = function (target, jobFolder, macroFolders, programFolders
|
|
|
474
468
|
case 0:
|
|
475
469
|
filePath = path_1.default.join(destinationPath, fileName);
|
|
476
470
|
if (!(0, utils_1.isTestFile)(fileName)) return [3 /*break*/, 2];
|
|
477
|
-
return [4 /*yield*/, (0,
|
|
471
|
+
return [4 /*yield*/, (0, internal_1.compileTestFile)(target, filePath, '', false, undefined, compileTree)];
|
|
478
472
|
case 1:
|
|
479
473
|
_a.sent();
|
|
480
474
|
return [3 /*break*/, 4];
|
|
481
|
-
case 2: return [4 /*yield*/, (0,
|
|
475
|
+
case 2: return [4 /*yield*/, (0, internal_1.compileFile)(target, filePath, macroFolders, programFolders, undefined, compileTree, types_1.SASJsFileType.job, jobFolder)];
|
|
482
476
|
case 3:
|
|
483
477
|
_a.sent();
|
|
484
478
|
_a.label = 4;
|
|
@@ -504,11 +498,11 @@ var compileJobFolder = function (target, jobFolder, macroFolders, programFolders
|
|
|
504
498
|
case 0:
|
|
505
499
|
filePath = path_1.default.join(destinationPath, subFolder, fileName);
|
|
506
500
|
if (!(0, utils_1.isTestFile)(filePath)) return [3 /*break*/, 2];
|
|
507
|
-
return [4 /*yield*/, (0,
|
|
501
|
+
return [4 /*yield*/, (0, internal_1.compileTestFile)(target, filePath, '', false, undefined, compileTree)];
|
|
508
502
|
case 1:
|
|
509
503
|
_a.sent();
|
|
510
504
|
return [3 /*break*/, 4];
|
|
511
|
-
case 2: return [4 /*yield*/, (0,
|
|
505
|
+
case 2: return [4 /*yield*/, (0, internal_1.compileFile)(target, filePath, macroFolders, programFolders, undefined, compileTree, types_1.SASJsFileType.job, sourcePath)];
|
|
512
506
|
case 3:
|
|
513
507
|
_a.sent();
|
|
514
508
|
_a.label = 4;
|
|
@@ -561,13 +555,13 @@ var syncFolder = function (target) { return __awaiter(void 0, void 0, void 0, fu
|
|
|
561
555
|
case 0:
|
|
562
556
|
configuration = process.sasjsConfig;
|
|
563
557
|
if (!configuration.syncFolder) return [3 /*break*/, 2];
|
|
564
|
-
return [4 /*yield*/, (0,
|
|
558
|
+
return [4 /*yield*/, (0, internal_1.copySyncFolder)(configuration.syncFolder)];
|
|
565
559
|
case 1:
|
|
566
560
|
_a.sent();
|
|
567
561
|
_a.label = 2;
|
|
568
562
|
case 2:
|
|
569
563
|
if (!target.syncFolder) return [3 /*break*/, 4];
|
|
570
|
-
return [4 /*yield*/, (0,
|
|
564
|
+
return [4 /*yield*/, (0, internal_1.copySyncFolder)(target.syncFolder)];
|
|
571
565
|
case 3:
|
|
572
566
|
_a.sent();
|
|
573
567
|
_a.label = 4;
|
|
@@ -67,6 +67,7 @@ var CompileSubCommand;
|
|
|
67
67
|
(function (CompileSubCommand) {
|
|
68
68
|
CompileSubCommand["Job"] = "job";
|
|
69
69
|
CompileSubCommand["Service"] = "service";
|
|
70
|
+
CompileSubCommand["Test"] = "test";
|
|
70
71
|
CompileSubCommand["Identify"] = "identify";
|
|
71
72
|
})(CompileSubCommand || (CompileSubCommand = {}));
|
|
72
73
|
var syntax = 'compile [subCommand]';
|
|
@@ -94,8 +95,9 @@ var CompileCommand = /** @class */ (function (_super) {
|
|
|
94
95
|
var subCommand = args[3];
|
|
95
96
|
if ([
|
|
96
97
|
CompileSubCommand.Job,
|
|
97
|
-
CompileSubCommand.
|
|
98
|
-
CompileSubCommand.
|
|
98
|
+
CompileSubCommand.Service,
|
|
99
|
+
CompileSubCommand.Test,
|
|
100
|
+
CompileSubCommand.Identify
|
|
99
101
|
].includes(subCommand)) {
|
|
100
102
|
parseOptions = subCommandParseOptions;
|
|
101
103
|
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { Target } from '@sasjs/utils';
|
|
2
|
+
export declare enum CompileSingleFileSubCommands {
|
|
3
|
+
Job = "job",
|
|
4
|
+
Service = "service",
|
|
5
|
+
Test = "test"
|
|
6
|
+
}
|
|
2
7
|
export declare function compileSingleFile(target: Target, subCommand: string | undefined, source: string, output: string, insertProgramVar?: boolean, currentFolder?: string): Promise<{
|
|
3
8
|
destinationPath: string;
|
|
4
9
|
}>;
|
|
@@ -39,28 +39,33 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.compileSingleFile = void 0;
|
|
42
|
+
exports.compileSingleFile = exports.CompileSingleFileSubCommands = void 0;
|
|
43
43
|
var path_1 = __importDefault(require("path"));
|
|
44
44
|
var config_1 = require("../../utils/config");
|
|
45
45
|
var utils_1 = require("@sasjs/utils");
|
|
46
|
-
var
|
|
47
|
-
var
|
|
48
|
-
var
|
|
46
|
+
var error_1 = require("@sasjs/utils/error");
|
|
47
|
+
var internal_1 = require("./internal");
|
|
48
|
+
var CompileSingleFileSubCommands;
|
|
49
|
+
(function (CompileSingleFileSubCommands) {
|
|
50
|
+
CompileSingleFileSubCommands["Job"] = "job";
|
|
51
|
+
CompileSingleFileSubCommands["Service"] = "service";
|
|
52
|
+
CompileSingleFileSubCommands["Test"] = "test";
|
|
53
|
+
})(CompileSingleFileSubCommands = exports.CompileSingleFileSubCommands || (exports.CompileSingleFileSubCommands = {}));
|
|
54
|
+
var isCompileSingleFileSubCommands = function (command) {
|
|
55
|
+
return Object.values(CompileSingleFileSubCommands).includes(command);
|
|
56
|
+
};
|
|
49
57
|
function compileSingleFile(target, subCommand, source, output, insertProgramVar, currentFolder) {
|
|
50
58
|
var _a;
|
|
51
59
|
if (subCommand === void 0) { subCommand = 'identify'; }
|
|
52
60
|
if (insertProgramVar === void 0) { insertProgramVar = false; }
|
|
53
61
|
return __awaiter(this, void 0, void 0, function () {
|
|
54
|
-
var
|
|
62
|
+
var commandExample, sourcePath, outputPathParts, leafFolderName, parentOutputFolder, pathExists, sourceFileName, destinationPath, sourceFileNameWithoutExt, macroFolders, programFolders, psMaxOption, programVar, compileTree, sourceFolder, _b;
|
|
55
63
|
return __generator(this, function (_c) {
|
|
56
64
|
switch (_c.label) {
|
|
57
65
|
case 0:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
};
|
|
62
|
-
if (!subCommands.hasOwnProperty(subCommand) && subCommand !== 'identify') {
|
|
63
|
-
throw new Error("Unsupported context command. Supported commands are:\n".concat(Object.keys(subCommands).join('\n')));
|
|
66
|
+
if (!isCompileSingleFileSubCommands(subCommand) &&
|
|
67
|
+
subCommand !== 'identify') {
|
|
68
|
+
throw new Error("Unsupported context command. Supported commands are:\n".concat(Object.values(CompileSingleFileSubCommands).join('\n')));
|
|
64
69
|
}
|
|
65
70
|
commandExample = 'sasjs compile <command> --source myjob.sas --target targetName -output /some/folder';
|
|
66
71
|
if (!source) {
|
|
@@ -71,18 +76,20 @@ function compileSingleFile(target, subCommand, source, output, insertProgramVar,
|
|
|
71
76
|
return [4 /*yield*/, validateSourcePath(sourcePath)];
|
|
72
77
|
case 1:
|
|
73
78
|
if (!(_c.sent())) {
|
|
74
|
-
throw new Error("Provide a path to source file (eg '".concat(commandExample, "')"));
|
|
79
|
+
throw new Error("Provide a valid path to source file (eg '".concat(commandExample, "')"));
|
|
75
80
|
}
|
|
76
81
|
if (!(subCommand === 'identify')) return [3 /*break*/, 3];
|
|
77
|
-
return [4 /*yield*/, (0,
|
|
82
|
+
return [4 /*yield*/, (0, internal_1.identifySasFile)(target, sourcePath).catch(function (err) {
|
|
83
|
+
throw (0, error_1.prefixMessage)(err, 'Single file compilation failed. ');
|
|
84
|
+
})];
|
|
78
85
|
case 2:
|
|
79
86
|
subCommand = _c.sent();
|
|
80
87
|
_c.label = 3;
|
|
81
88
|
case 3:
|
|
82
89
|
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Compiling source file:\n- ".concat(sourcePath));
|
|
83
90
|
outputPathParts = output.split(path_1.default.sep);
|
|
84
|
-
leafFolderName = source.split(path_1.default.sep).pop();
|
|
85
91
|
outputPathParts.pop(), outputPathParts.pop();
|
|
92
|
+
leafFolderName = source.split(path_1.default.sep).pop();
|
|
86
93
|
parentOutputFolder = outputPathParts.join(path_1.default.sep);
|
|
87
94
|
return [4 /*yield*/, (0, utils_1.fileExists)(parentOutputFolder)];
|
|
88
95
|
case 4:
|
|
@@ -111,28 +118,32 @@ function compileSingleFile(target, subCommand, source, output, insertProgramVar,
|
|
|
111
118
|
programVar = insertProgramVar
|
|
112
119
|
? "%let _program=".concat(target.appLoc, "/").concat(subCommand, "s/").concat(leafFolderName, "/").concat(sourceFileNameWithoutExt, ";\n").concat(psMaxOption)
|
|
113
120
|
: "".concat(psMaxOption);
|
|
114
|
-
compileTree = (0,
|
|
121
|
+
compileTree = (0, internal_1.getCompileTree)(target);
|
|
115
122
|
sourceFolder = sourcePath
|
|
116
123
|
.split(path_1.default.sep)
|
|
117
124
|
.slice(0, sourcePath.split(path_1.default.sep).length - 1)
|
|
118
125
|
.join(path_1.default.sep);
|
|
119
126
|
_b = subCommand;
|
|
120
127
|
switch (_b) {
|
|
121
|
-
case
|
|
122
|
-
case
|
|
128
|
+
case CompileSingleFileSubCommands.Service: return [3 /*break*/, 11];
|
|
129
|
+
case CompileSingleFileSubCommands.Job: return [3 /*break*/, 13];
|
|
130
|
+
case CompileSingleFileSubCommands.Test: return [3 /*break*/, 15];
|
|
123
131
|
}
|
|
124
|
-
return [3 /*break*/,
|
|
125
|
-
case 11: return [4 /*yield*/, (0,
|
|
132
|
+
return [3 /*break*/, 17];
|
|
133
|
+
case 11: return [4 /*yield*/, (0, internal_1.compileFile)(target, destinationPath, macroFolders, programFolders, programVar, compileTree, utils_1.SASJsFileType.service, sourceFolder)];
|
|
126
134
|
case 12:
|
|
127
135
|
_c.sent();
|
|
128
|
-
return [3 /*break*/,
|
|
129
|
-
case 13: return [4 /*yield*/, (0,
|
|
136
|
+
return [3 /*break*/, 17];
|
|
137
|
+
case 13: return [4 /*yield*/, (0, internal_1.compileFile)(target, destinationPath, macroFolders, programFolders, programVar, compileTree, utils_1.SASJsFileType.job, sourceFolder)];
|
|
130
138
|
case 14:
|
|
131
139
|
_c.sent();
|
|
132
|
-
return [3 /*break*/,
|
|
133
|
-
case 15: return [
|
|
134
|
-
case 16:
|
|
135
|
-
|
|
140
|
+
return [3 /*break*/, 17];
|
|
141
|
+
case 15: return [4 /*yield*/, (0, internal_1.compileTestFile)(target, sourcePath, programVar, undefined, false, compileTree, destinationPath)];
|
|
142
|
+
case 16:
|
|
143
|
+
_c.sent();
|
|
144
|
+
return [3 /*break*/, 17];
|
|
145
|
+
case 17: return [4 /*yield*/, compileTree.saveTree()];
|
|
146
|
+
case 18:
|
|
136
147
|
_c.sent();
|
|
137
148
|
return [2 /*return*/, { destinationPath: destinationPath }];
|
|
138
149
|
}
|
|
@@ -38,9 +38,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.checkCompileStatus = void 0;
|
|
40
40
|
var utils_1 = require("@sasjs/utils");
|
|
41
|
-
var
|
|
42
|
-
var getAllFolders_1 = require("./getAllFolders");
|
|
43
|
-
var getDestinationPath_1 = require("./getDestinationPath");
|
|
41
|
+
var _1 = require("./");
|
|
44
42
|
function checkCompileStatus(target, exceptions) {
|
|
45
43
|
return __awaiter(this, void 0, void 0, function () {
|
|
46
44
|
var buildDestinationFolder, pathExists, _a, areServiceFoldersMatching, serviceReasons, _b, areJobFoldersMatching, jobReasons, compiled;
|
|
@@ -86,7 +84,7 @@ var checkServiceFolders = function (target, exceptions) { return __awaiter(void
|
|
|
86
84
|
var serviceFolders, areServiceFoldersMatching, reasons;
|
|
87
85
|
return __generator(this, function (_a) {
|
|
88
86
|
switch (_a.label) {
|
|
89
|
-
case 0: return [4 /*yield*/, (0,
|
|
87
|
+
case 0: return [4 /*yield*/, (0, _1.getAllFolders)(target, _1.SasFileType.Service)];
|
|
90
88
|
case 1:
|
|
91
89
|
serviceFolders = _a.sent();
|
|
92
90
|
areServiceFoldersMatching = true;
|
|
@@ -96,8 +94,8 @@ var checkServiceFolders = function (target, exceptions) { return __awaiter(void
|
|
|
96
94
|
return __generator(this, function (_b) {
|
|
97
95
|
switch (_b.label) {
|
|
98
96
|
case 0:
|
|
99
|
-
destinationPath = (0,
|
|
100
|
-
return [4 /*yield*/, (0,
|
|
97
|
+
destinationPath = (0, _1.getDestinationServicePath)(serviceFolder);
|
|
98
|
+
return [4 /*yield*/, (0, _1.compareFolders)(serviceFolder, destinationPath, exceptions)];
|
|
101
99
|
case 1:
|
|
102
100
|
_a = _b.sent(), equal = _a.equal, reason = _a.reason;
|
|
103
101
|
areServiceFoldersMatching = areServiceFoldersMatching && equal;
|
|
@@ -125,7 +123,7 @@ var checkJobFolders = function (target, exceptions) { return __awaiter(void 0, v
|
|
|
125
123
|
var jobFolders, areJobFoldersMatching, reasons;
|
|
126
124
|
return __generator(this, function (_a) {
|
|
127
125
|
switch (_a.label) {
|
|
128
|
-
case 0: return [4 /*yield*/, (0,
|
|
126
|
+
case 0: return [4 /*yield*/, (0, _1.getAllFolders)(target, _1.SasFileType.Job)];
|
|
129
127
|
case 1:
|
|
130
128
|
jobFolders = _a.sent();
|
|
131
129
|
areJobFoldersMatching = true;
|
|
@@ -135,8 +133,8 @@ var checkJobFolders = function (target, exceptions) { return __awaiter(void 0, v
|
|
|
135
133
|
return __generator(this, function (_b) {
|
|
136
134
|
switch (_b.label) {
|
|
137
135
|
case 0:
|
|
138
|
-
destinationPath = (0,
|
|
139
|
-
return [4 /*yield*/, (0,
|
|
136
|
+
destinationPath = (0, _1.getDestinationJobPath)(jobFolder);
|
|
137
|
+
return [4 /*yield*/, (0, _1.compareFolders)(jobFolder, destinationPath, exceptions)];
|
|
140
138
|
case 1:
|
|
141
139
|
_a = _b.sent(), equal = _a.equal, reason = _a.reason;
|
|
142
140
|
areJobFoldersMatching = areJobFoldersMatching && equal;
|
|
@@ -42,7 +42,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
42
42
|
exports.compileFile = void 0;
|
|
43
43
|
var utils_1 = require("@sasjs/utils");
|
|
44
44
|
var types_1 = require("@sasjs/utils/types");
|
|
45
|
-
var
|
|
45
|
+
var _1 = require("./");
|
|
46
46
|
var path_1 = __importDefault(require("path"));
|
|
47
47
|
/**
|
|
48
48
|
* Compiles file dependencies.
|
|
@@ -61,7 +61,7 @@ function compileFile(target, filePath, macroFolders, programFolders, programVar,
|
|
|
61
61
|
var dependencies;
|
|
62
62
|
return __generator(this, function (_a) {
|
|
63
63
|
switch (_a.label) {
|
|
64
|
-
case 0: return [4 /*yield*/, (0,
|
|
64
|
+
case 0: return [4 /*yield*/, (0, _1.loadDependencies)(target, sourceFolder
|
|
65
65
|
? path_1.default.join(sourceFolder, filePath.split(path_1.default.sep).pop())
|
|
66
66
|
: filePath, macroFolders, programFolders, (0, utils_1.isTestFile)(filePath) ? types_1.SASJsFileType.test : fileType, compileTree)];
|
|
67
67
|
case 1:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CompileTree, Configuration, Target } from '@sasjs/utils';
|
|
2
2
|
import { TestFlow } from '../../../types';
|
|
3
|
-
export declare function compileTestFile(target: Target, filePath: string, testVar: string | undefined, saveToRoot: boolean | undefined, removeOriginalFile: boolean | undefined, compileTree: CompileTree): Promise<void>;
|
|
3
|
+
export declare function compileTestFile(target: Target, filePath: string, testVar: string | undefined, saveToRoot: boolean | undefined, removeOriginalFile: boolean | undefined, compileTree: CompileTree, destinationPath?: string): 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>;
|
|
@@ -71,18 +71,18 @@ var path_1 = __importDefault(require("path"));
|
|
|
71
71
|
var types_1 = require("../../../types");
|
|
72
72
|
var config_1 = require("../../../utils/config");
|
|
73
73
|
var file_1 = require("../../../utils/file");
|
|
74
|
-
var
|
|
74
|
+
var _1 = require("./");
|
|
75
75
|
var getFileName = function (filePath) { return path_1.default.parse(filePath).base; };
|
|
76
|
-
function compileTestFile(target, filePath, testVar, saveToRoot, removeOriginalFile, compileTree) {
|
|
76
|
+
function compileTestFile(target, filePath, testVar, saveToRoot, removeOriginalFile, compileTree, destinationPath) {
|
|
77
77
|
if (testVar === void 0) { testVar = ''; }
|
|
78
78
|
if (saveToRoot === void 0) { saveToRoot = true; }
|
|
79
79
|
if (removeOriginalFile === void 0) { removeOriginalFile = true; }
|
|
80
80
|
return __awaiter(this, void 0, void 0, function () {
|
|
81
|
-
var dependencies, _a, _b, _c, buildDestinationFolder, buildDestinationTestFolder, buildDestinationFolderName
|
|
81
|
+
var dependencies, _a, _b, _c, buildDestinationFolder, buildDestinationTestFolder, buildDestinationFolderName;
|
|
82
82
|
return __generator(this, function (_d) {
|
|
83
83
|
switch (_d.label) {
|
|
84
84
|
case 0:
|
|
85
|
-
_a =
|
|
85
|
+
_a = _1.loadDependencies;
|
|
86
86
|
_b = [target,
|
|
87
87
|
(0, utils_1.getAbsolutePath)(filePath, process.projectDir)];
|
|
88
88
|
return [4 /*yield*/, (0, config_1.getMacroFolders)(target)];
|
|
@@ -98,16 +98,18 @@ function compileTestFile(target, filePath, testVar, saveToRoot, removeOriginalFi
|
|
|
98
98
|
buildDestinationFolderName = buildDestinationFolder
|
|
99
99
|
.split(path_1.default.sep)
|
|
100
100
|
.pop();
|
|
101
|
-
destinationPath =
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
101
|
+
destinationPath =
|
|
102
|
+
destinationPath ||
|
|
103
|
+
path_1.default.join(buildDestinationTestFolder, saveToRoot
|
|
104
|
+
? filePath.split(path_1.default.sep).pop() || ''
|
|
105
|
+
: filePath
|
|
106
|
+
.split(path_1.default.sep)
|
|
107
|
+
.reduce(function (acc, item, i, arr) {
|
|
108
|
+
return acc.length
|
|
109
|
+
? __spreadArray(__spreadArray([], __read(acc), false), [item], false) : arr[i - 1] === buildDestinationFolderName
|
|
110
|
+
? __spreadArray(__spreadArray([], __read(acc), false), [item], false) : acc;
|
|
111
|
+
}, [])
|
|
112
|
+
.join(path_1.default.sep));
|
|
111
113
|
return [4 /*yield*/, (0, utils_1.createFile)(destinationPath, dependencies)];
|
|
112
114
|
case 4:
|
|
113
115
|
_d.sent();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Configuration, Target } from '@sasjs/utils';
|
|
2
2
|
export declare enum SasFileType {
|
|
3
3
|
Service = "service",
|
|
4
|
-
Job = "job"
|
|
4
|
+
Job = "job",
|
|
5
|
+
Test = "test"
|
|
5
6
|
}
|
|
6
|
-
export declare const getAllFolders: (target: Target, type: SasFileType, rootConfig?: Configuration) => Promise<string[]>;
|
|
7
|
+
export declare const getAllFolders: (target: Target, type: SasFileType.Service | SasFileType.Job, rootConfig?: Configuration) => Promise<string[]>;
|
|
@@ -67,6 +67,7 @@ var SasFileType;
|
|
|
67
67
|
(function (SasFileType) {
|
|
68
68
|
SasFileType["Service"] = "service";
|
|
69
69
|
SasFileType["Job"] = "job";
|
|
70
|
+
SasFileType["Test"] = "test";
|
|
70
71
|
})(SasFileType = exports.SasFileType || (exports.SasFileType = {}));
|
|
71
72
|
var getAllFolders = function (target, type, rootConfig) { return __awaiter(void 0, void 0, void 0, function () {
|
|
72
73
|
var configuration, allFolders, config, folders, addFolders, buildSourceFolder;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { Target } from '@sasjs/utils';
|
|
2
|
-
|
|
2
|
+
import { SasFileType } from './';
|
|
3
|
+
export declare const identifySasFile: (target: Target, sourcePath: string) => Promise<SasFileType>;
|
|
@@ -35,26 +35,35 @@ 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
|
+
};
|
|
38
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
42
|
exports.identifySasFile = void 0;
|
|
40
|
-
var
|
|
43
|
+
var utils_1 = require("@sasjs/utils");
|
|
44
|
+
var _1 = require("./");
|
|
45
|
+
var path_1 = __importDefault(require("path"));
|
|
41
46
|
var identifySasFile = function (target, sourcePath) { return __awaiter(void 0, void 0, void 0, function () {
|
|
42
|
-
var serviceFolders,
|
|
47
|
+
var serviceFolders, jobFolders;
|
|
43
48
|
return __generator(this, function (_a) {
|
|
44
49
|
switch (_a.label) {
|
|
45
|
-
case 0:
|
|
50
|
+
case 0:
|
|
51
|
+
if ((0, utils_1.isTestFile)(sourcePath.split(path_1.default.sep).pop())) {
|
|
52
|
+
return [2 /*return*/, _1.SasFileType.Test];
|
|
53
|
+
}
|
|
54
|
+
return [4 /*yield*/, (0, _1.getAllFolders)(target, _1.SasFileType.Service)];
|
|
46
55
|
case 1:
|
|
47
56
|
serviceFolders = _a.sent();
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return [4 /*yield*/, (0,
|
|
57
|
+
if (serviceFolders.find(function (folder) { return sourcePath.includes(folder); })) {
|
|
58
|
+
return [2 /*return*/, _1.SasFileType.Service];
|
|
59
|
+
}
|
|
60
|
+
return [4 /*yield*/, (0, _1.getAllFolders)(target, _1.SasFileType.Job)];
|
|
52
61
|
case 2:
|
|
53
62
|
jobFolders = _a.sent();
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
throw
|
|
63
|
+
if (jobFolders.find(function (folder) { return sourcePath.includes(folder); })) {
|
|
64
|
+
return [2 /*return*/, _1.SasFileType.Job];
|
|
65
|
+
}
|
|
66
|
+
throw "Unable to identify file as ".concat(_1.SasFileType.Service, ", ").concat(_1.SasFileType.Job, " or ").concat(_1.SasFileType.Test);
|
|
58
67
|
}
|
|
59
68
|
});
|
|
60
69
|
}); };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './checkCompileStatus';
|
|
2
|
+
export * from './compareFolders';
|
|
3
|
+
export * from './compileFile';
|
|
4
|
+
export * from './compileTestFile';
|
|
5
|
+
export * from './copySyncFolder';
|
|
6
|
+
export * from './getAllFolders';
|
|
7
|
+
export * from './getDestinationPath';
|
|
8
|
+
export * from './identifySasFile';
|
|
9
|
+
export * from './loadDependencies';
|