@sasjs/cli 3.17.0 → 3.18.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 +42 -40
- package/build/commands/build/spec/build.spec.js +51 -0
- package/build/commands/build/spec/{cb.spec.server.d.ts → cb.spec.server.viya.d.ts} +0 -0
- package/build/commands/build/spec/{cb.spec.server.js → cb.spec.server.viya.js} +1 -1
- package/build/commands/compile/internal/compileFile.js +6 -3
- package/build/commands/compile/internal/loadDependencies.js +29 -21
- package/build/commands/compile/internal/spec/compileTestFile.spec.js +1 -1
- package/build/commands/deploy/spec/cbd.spec.js +24 -19
- package/build/commands/deploy/spec/{cbd.spec.server.d.ts → cbd.spec.server.viya.d.ts} +0 -0
- package/build/commands/deploy/spec/cbd.spec.server.viya.js +334 -0
- package/build/commands/flow/spec/{flow.spec.server.d.ts → flow.spec.server.viya.d.ts} +0 -0
- package/build/commands/flow/spec/{flow.spec.server.js → flow.spec.server.viya.js} +39 -55
- package/build/commands/folder/spec/{folder.spec.server.d.ts → folder.spec.server.viya.d.ts} +0 -0
- package/build/commands/folder/spec/{folder.spec.server.js → folder.spec.server.viya.js} +17 -23
- package/build/commands/init/spec/{init.spec.server.d.ts → init.spec.d.ts} +0 -0
- package/build/commands/init/spec/{init.spec.server.js → init.spec.js} +0 -0
- package/build/commands/job/spec/{job.spec.server.d.ts → job.spec.server.viya.d.ts} +0 -0
- package/build/commands/job/spec/{job.spec.server.js → job.spec.server.viya.js} +45 -56
- package/build/commands/request/request.js +3 -2
- package/build/commands/request/spec/{request.spec.server.d.ts → request.spec.server.sas9.d.ts} +0 -0
- package/build/commands/request/spec/request.spec.server.sas9.js +283 -0
- package/build/commands/{run/spec/run.spec.server.d.ts → request/spec/request.spec.server.viya.d.ts} +0 -0
- package/build/commands/request/spec/request.spec.server.viya.js +460 -0
- package/build/commands/request/spec/utils.d.ts +23 -0
- package/build/commands/request/spec/utils.js +87 -0
- package/build/commands/{servicepack/spec/servicepack.spec.server.d.ts → run/spec/run.spec.server.sas9.d.ts} +0 -0
- package/build/commands/run/spec/run.spec.server.sas9.js +115 -0
- package/build/commands/run/spec/run.spec.server.viya.d.ts +1 -0
- package/build/commands/run/spec/{run.spec.server.js → run.spec.server.viya.js} +32 -101
- package/build/commands/servicepack/spec/servicepack.spec.server.viya.d.ts +1 -0
- package/build/commands/servicepack/spec/{servicepack.spec.server.js → servicepack.spec.server.viya.js} +1 -1
- package/build/utils/test.js +4 -2
- package/build/utils/utils.d.ts +0 -6
- package/build/utils/utils.js +2 -35
- package/package.json +6 -5
- package/build/commands/deploy/spec/cbd.spec.server.js +0 -331
- package/build/commands/request/spec/request.spec.server.js +0 -709
- package/build/utils/spec/removeComments.spec.d.ts +0 -1
- package/build/utils/spec/removeComments.spec.js +0 -47
|
@@ -90,7 +90,6 @@ exports.getBuildVars = exports.build = void 0;
|
|
|
90
90
|
var path_1 = __importDefault(require("path"));
|
|
91
91
|
var utils_1 = require("@sasjs/utils");
|
|
92
92
|
var error_1 = require("@sasjs/utils/error");
|
|
93
|
-
var utils_2 = require("../../utils/utils");
|
|
94
93
|
var file_1 = require("../../utils/file");
|
|
95
94
|
var config_1 = require("../../utils/config");
|
|
96
95
|
var compile_1 = require("../compile/compile");
|
|
@@ -98,6 +97,7 @@ var config_2 = require("./internal/config");
|
|
|
98
97
|
var getLaunchPageCode_1 = require("./internal/getLaunchPageCode");
|
|
99
98
|
var types_1 = require("@sasjs/utils/types");
|
|
100
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
|
return __generator(this, function (_a) {
|
|
@@ -150,7 +150,7 @@ function createFinalSasFiles(target) {
|
|
|
150
150
|
return [4 /*yield*/, (0, utils_1.getDependencyPaths)("".concat(buildTerm, "\n").concat(buildInit), macroFolders, macroCorePath)];
|
|
151
151
|
case 6:
|
|
152
152
|
dependencyFilePaths = _l.sent();
|
|
153
|
-
return [4 /*yield*/,
|
|
153
|
+
return [4 /*yield*/, getDepsContent(dependencyFilePaths, target, macroFolders)];
|
|
154
154
|
case 7:
|
|
155
155
|
dependenciesContent = _l.sent();
|
|
156
156
|
finalSasFileContent += "\n".concat(dependenciesContent, "\n\n").concat(buildInit, "\n");
|
|
@@ -174,7 +174,7 @@ function createFinalSasFiles(target) {
|
|
|
174
174
|
servicePackSASjs.streamWebFolder = streamConfig.streamWebFolder;
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
|
-
finalSasFileContent = (0,
|
|
177
|
+
finalSasFileContent = (0, utils_1.removeHeader)(finalSasFileContent);
|
|
178
178
|
(_d = process.logger) === null || _d === void 0 ? void 0 : _d.debug("Creating file ".concat(finalFilePath, " ."));
|
|
179
179
|
return [4 /*yield*/, (0, utils_1.createFile)(finalFilePath, finalSasFileContent)];
|
|
180
180
|
case 9:
|
|
@@ -238,13 +238,13 @@ function getBuildInfo(target, streamWeb) {
|
|
|
238
238
|
dependencyFilePathsForGsubScript = _a.sent();
|
|
239
239
|
dependencyFilePaths = __spreadArray([], __read(new Set(__spreadArray(__spreadArray(__spreadArray([], __read(dependencyFilePaths), false), __read(dependencyFilePathsForCreateFile), false), __read(dependencyFilePathsForGsubScript), false))), false);
|
|
240
240
|
_a.label = 8;
|
|
241
|
-
case 8: return [4 /*yield*/,
|
|
241
|
+
case 8: return [4 /*yield*/, getDepsContent(dependencyFilePaths, target, macroFolders)];
|
|
242
242
|
case 9:
|
|
243
243
|
dependenciesContent = _a.sent();
|
|
244
244
|
return [4 /*yield*/, getBuildVars(target)];
|
|
245
245
|
case 10:
|
|
246
246
|
buildVars = _a.sent();
|
|
247
|
-
return [2 /*return*/, "\n/**\n * The appLoc represents the metadata or SAS Drive location of the app you\n * are about to deploy\n *\n * To set an alternative appLoc, simply populate the appLoc variable prior\n * to running this program, eg:\n *\n * %let apploc=/my/apploc;\n * %inc thisfile;\n *\n */\n\n%global appLoc serverName;\n%let compiled_apploc=".concat(appLoc, ";\n\n").concat(serverType === utils_1.ServerType.Sas9 ? "%let serverName=".concat(serverName, ";") : '', "\n\n%let appLoc=%sysfunc(coalescec(&appLoc,&compiled_apploc));\n\n%let sasjs_clickmeservice=clickme;\n%let syscc=0;\noptions ps=max nonotes nosgen nomprint nomlogic nosource2 nosource noquotelenmax;\n/* user supplied build vars */\n").concat(buildVars, "\n/* user supplied build vars end */\n/* system macro dependencies for build process */\n").concat(dependenciesContent, "\n/* system macro dependencies for build process end*/\n/* system macros for build process */\n").concat(buildConfig, "\n/* system macros for build process end */\n")];
|
|
247
|
+
return [2 /*return*/, "\n/**\n * The appLoc represents the metadata or SAS Drive location of the app you\n * are about to deploy\n *\n * To set an alternative appLoc, simply populate the appLoc variable prior\n * to running this program, eg:\n *\n * %let apploc=/my/apploc;\n * %inc thisfile;\n *\n */\n\n%global appLoc serverName;\n%let compiled_apploc=".concat(appLoc, ";\n\n").concat(serverType === utils_1.ServerType.Sas9 ? "%let serverName=".concat(serverName, ";") : '', "\n\n%let appLoc=%sysfunc(coalescec(&appLoc,&compiled_apploc));\n\n%let sasjs_clickmeservice=clickme;\n%let syscc=0;\noptions ps=max nonotes nosgen nomprint nomlogic nosource2 nosource noquotelenmax;\n/* user supplied build vars */\n").concat(buildVars, "\n/* user supplied build vars end */\n/* system macro dependencies for build process */\n").concat(dependenciesContent, "\n/* system macro dependencies for build process end*/\n/* system macros for build process */\n").concat((0, utils_1.removeHeader)(buildConfig), "\n/* system macros for build process end */\n")];
|
|
248
248
|
}
|
|
249
249
|
});
|
|
250
250
|
});
|
|
@@ -364,33 +364,6 @@ function getFolderContent(serverType) {
|
|
|
364
364
|
});
|
|
365
365
|
});
|
|
366
366
|
}
|
|
367
|
-
function getDependencies(filePaths) {
|
|
368
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
369
|
-
var dependenciesContent;
|
|
370
|
-
var _this = this;
|
|
371
|
-
return __generator(this, function (_a) {
|
|
372
|
-
switch (_a.label) {
|
|
373
|
-
case 0:
|
|
374
|
-
dependenciesContent = [];
|
|
375
|
-
return [4 /*yield*/, (0, utils_1.asyncForEach)(__spreadArray([], __read(new Set(filePaths)), false), function (filePath) { return __awaiter(_this, void 0, void 0, function () {
|
|
376
|
-
var depFileContent;
|
|
377
|
-
return __generator(this, function (_a) {
|
|
378
|
-
switch (_a.label) {
|
|
379
|
-
case 0: return [4 /*yield*/, (0, utils_1.readFile)(filePath)];
|
|
380
|
-
case 1:
|
|
381
|
-
depFileContent = _a.sent();
|
|
382
|
-
dependenciesContent.push(depFileContent);
|
|
383
|
-
return [2 /*return*/];
|
|
384
|
-
}
|
|
385
|
-
});
|
|
386
|
-
}); })];
|
|
387
|
-
case 1:
|
|
388
|
-
_a.sent();
|
|
389
|
-
return [2 /*return*/, dependenciesContent.join('\n')];
|
|
390
|
-
}
|
|
391
|
-
});
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
367
|
function getContentFor(rootDirectory, folderPath, serverType) {
|
|
395
368
|
return __awaiter(this, void 0, void 0, function () {
|
|
396
369
|
var folderName, content, contentJSON, files, subFolders;
|
|
@@ -413,26 +386,27 @@ function getContentFor(rootDirectory, folderPath, serverType) {
|
|
|
413
386
|
case 1:
|
|
414
387
|
files = _a.sent();
|
|
415
388
|
return [4 /*yield*/, (0, utils_1.asyncForEach)(files, function (file) { return __awaiter(_this, void 0, void 0, function () {
|
|
416
|
-
var filePath, fileContent, transformedContent, fileContentEncoded, transformedContent;
|
|
417
|
-
return __generator(this, function (
|
|
418
|
-
switch (
|
|
389
|
+
var filePath, fileContent, _a, transformedContent, fileContentEncoded, transformedContent;
|
|
390
|
+
return __generator(this, function (_b) {
|
|
391
|
+
switch (_b.label) {
|
|
419
392
|
case 0:
|
|
420
393
|
filePath = path_1.default.join(folderPath, file);
|
|
421
394
|
if (!(0, file_1.isSasFile)(file)) return [3 /*break*/, 2];
|
|
395
|
+
_a = utils_1.removeHeader;
|
|
422
396
|
return [4 /*yield*/, (0, utils_1.readFile)(filePath)];
|
|
423
397
|
case 1:
|
|
424
|
-
fileContent = _a.sent();
|
|
398
|
+
fileContent = _a.apply(void 0, [_b.sent()]);
|
|
425
399
|
transformedContent = getServiceText(file, fileContent, serverType);
|
|
426
400
|
content += "\n".concat(transformedContent, "\n");
|
|
427
401
|
contentJSON.members.push({
|
|
428
402
|
name: file.replace(/.sas$/, ''),
|
|
429
403
|
type: types_1.MemberType.service,
|
|
430
|
-
code: (0,
|
|
404
|
+
code: (0, utils_1.removeHeader)(fileContent)
|
|
431
405
|
});
|
|
432
406
|
return [3 /*break*/, 4];
|
|
433
407
|
case 2: return [4 /*yield*/, (0, utils_1.base64EncodeFile)(filePath)];
|
|
434
408
|
case 3:
|
|
435
|
-
fileContentEncoded =
|
|
409
|
+
fileContentEncoded = _b.sent();
|
|
436
410
|
transformedContent = getFileText(file, fileContentEncoded, serverType);
|
|
437
411
|
content += "\n".concat(transformedContent, "\n");
|
|
438
412
|
contentJSON.members.push({
|
|
@@ -440,7 +414,7 @@ function getContentFor(rootDirectory, folderPath, serverType) {
|
|
|
440
414
|
type: types_1.MemberType.file,
|
|
441
415
|
code: fileContentEncoded
|
|
442
416
|
});
|
|
443
|
-
|
|
417
|
+
_b.label = 4;
|
|
444
418
|
case 4: return [2 /*return*/];
|
|
445
419
|
}
|
|
446
420
|
});
|
|
@@ -472,7 +446,7 @@ function getContentFor(rootDirectory, folderPath, serverType) {
|
|
|
472
446
|
}
|
|
473
447
|
function getServiceText(serviceFileName, fileContent, serverType) {
|
|
474
448
|
var serviceName = serviceFileName.replace(/.sas$/, '');
|
|
475
|
-
var sourceCodeLines = getLines(
|
|
449
|
+
var sourceCodeLines = getLines(fileContent);
|
|
476
450
|
var content = "";
|
|
477
451
|
sourceCodeLines.forEach(function (line) {
|
|
478
452
|
var escapedLine = line.split("'").join("''");
|
|
@@ -561,3 +535,31 @@ var convertVarsToSasFormat = function (vars) {
|
|
|
561
535
|
}
|
|
562
536
|
return varsContent;
|
|
563
537
|
};
|
|
538
|
+
var getDepsContent = function (deps, target, macroFolders) { return __awaiter(void 0, void 0, void 0, function () {
|
|
539
|
+
var dependenciesContent, compileTree;
|
|
540
|
+
return __generator(this, function (_a) {
|
|
541
|
+
switch (_a.label) {
|
|
542
|
+
case 0:
|
|
543
|
+
dependenciesContent = '';
|
|
544
|
+
compileTree = (0, loadDependencies_1.getCompileTree)(target);
|
|
545
|
+
return [4 /*yield*/, (0, utils_1.asyncForEach)(deps, function (fp) { return __awaiter(void 0, void 0, void 0, function () {
|
|
546
|
+
var _a, _b;
|
|
547
|
+
return __generator(this, function (_c) {
|
|
548
|
+
switch (_c.label) {
|
|
549
|
+
case 0:
|
|
550
|
+
_a = dependenciesContent;
|
|
551
|
+
_b = '\n';
|
|
552
|
+
return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, fp, macroFolders, [], types_1.SASJsFileType.file, compileTree)];
|
|
553
|
+
case 1:
|
|
554
|
+
dependenciesContent = _a + (_b +
|
|
555
|
+
(_c.sent()));
|
|
556
|
+
return [2 /*return*/];
|
|
557
|
+
}
|
|
558
|
+
});
|
|
559
|
+
}); })];
|
|
560
|
+
case 1:
|
|
561
|
+
_a.sent();
|
|
562
|
+
return [2 /*return*/, dependenciesContent];
|
|
563
|
+
}
|
|
564
|
+
});
|
|
565
|
+
}); };
|
|
@@ -35,12 +35,16 @@ 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
|
var test_1 = require("../../../utils/test");
|
|
40
43
|
var utils_1 = require("@sasjs/utils");
|
|
41
44
|
var utils_2 = require("../../../utils");
|
|
42
45
|
var build_1 = require("../build");
|
|
43
46
|
var __1 = require("../..");
|
|
47
|
+
var path_1 = __importDefault(require("path"));
|
|
44
48
|
describe('sasjs build', function () {
|
|
45
49
|
var appName;
|
|
46
50
|
beforeAll(function () {
|
|
@@ -97,4 +101,51 @@ describe('sasjs build', function () {
|
|
|
97
101
|
}
|
|
98
102
|
});
|
|
99
103
|
}); }, 2 * 60 * 1000);
|
|
104
|
+
it("should compile and build remaining multiline comments", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
105
|
+
var beforeComment, afterComment, commentLine1, commentLine2, testContent, macroPath, _a, _b, target, finalSasFilePath, finalSasFile;
|
|
106
|
+
return __generator(this, function (_c) {
|
|
107
|
+
switch (_c.label) {
|
|
108
|
+
case 0:
|
|
109
|
+
beforeComment = 'before comment;';
|
|
110
|
+
afterComment = 'after comment;';
|
|
111
|
+
commentLine1 = "/*Name_corrected2=translate(trim(Name_corrected),'_','~!@#$%^&*()+-=[]{}|;:\",./<>?\u00C2\u00B0\u00B2\u00B3\u00B5 ');";
|
|
112
|
+
commentLine2 = "/* Name_corrected2=translate(trim(Name_corrected),'_','/','(',')','?','\u00C2\u00B2','#','\u00B0C','\u00B5','\u00B3'); */";
|
|
113
|
+
testContent = [
|
|
114
|
+
beforeComment,
|
|
115
|
+
commentLine1,
|
|
116
|
+
commentLine2,
|
|
117
|
+
afterComment
|
|
118
|
+
].join('\n');
|
|
119
|
+
appName = "test-app-build-".concat((0, utils_1.generateTimestamp)());
|
|
120
|
+
return [4 /*yield*/, (0, test_1.createTestApp)(__dirname, appName)];
|
|
121
|
+
case 1:
|
|
122
|
+
_c.sent();
|
|
123
|
+
macroPath = path_1.default.join(__dirname, appName, 'sasjs', 'macros', 'examplemacro.sas');
|
|
124
|
+
_a = utils_1.createFile;
|
|
125
|
+
_b = [macroPath];
|
|
126
|
+
return [4 /*yield*/, (0, utils_1.readFile)(macroPath)];
|
|
127
|
+
case 2: return [4 /*yield*/, _a.apply(void 0, _b.concat([(_c.sent()) + testContent]))];
|
|
128
|
+
case 3:
|
|
129
|
+
_c.sent();
|
|
130
|
+
return [4 /*yield*/, (0, utils_2.findTargetInConfiguration)('viya')];
|
|
131
|
+
case 4:
|
|
132
|
+
target = (_c.sent()).target;
|
|
133
|
+
return [4 /*yield*/, (0, __1.compile)(target)];
|
|
134
|
+
case 5:
|
|
135
|
+
_c.sent();
|
|
136
|
+
return [4 /*yield*/, (0, build_1.build)(target)];
|
|
137
|
+
case 6:
|
|
138
|
+
_c.sent();
|
|
139
|
+
finalSasFilePath = path_1.default.join(__dirname, appName, 'sasjsbuild', target.buildConfig.buildOutputFileName);
|
|
140
|
+
return [4 /*yield*/, (0, utils_1.readFile)(finalSasFilePath)];
|
|
141
|
+
case 7:
|
|
142
|
+
finalSasFile = _c.sent();
|
|
143
|
+
expect(finalSasFile.includes(beforeComment)).toBeTruthy();
|
|
144
|
+
expect(finalSasFile.includes(commentLine1.split("'").join("'".repeat(2)))).toBeTruthy();
|
|
145
|
+
expect(commentLine2.split("'").join("'".repeat(2))).toBeTruthy();
|
|
146
|
+
expect(finalSasFile.includes(afterComment)).toBeTruthy();
|
|
147
|
+
return [2 /*return*/];
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}); });
|
|
100
151
|
});
|
|
File without changes
|
|
@@ -44,7 +44,7 @@ var test_1 = require("../../../utils/test");
|
|
|
44
44
|
var utils_1 = require("@sasjs/utils");
|
|
45
45
|
var compile_1 = require("../../compile/compile");
|
|
46
46
|
var build_1 = require("../build");
|
|
47
|
-
describe('sasjs compile', function () {
|
|
47
|
+
describe('sasjs compile with Viya', function () {
|
|
48
48
|
var target;
|
|
49
49
|
beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
50
50
|
var appName;
|
|
@@ -122,10 +122,11 @@ function getPreCodeForServicePack(serverType) {
|
|
|
122
122
|
'/* so we provide instead as __program */\n' +
|
|
123
123
|
'%global __program _program;\n' +
|
|
124
124
|
'%let _program=%sysfunc(coalescec(&__program,&_program));\n' +
|
|
125
|
-
'%macro webout(action,ds,dslabel=,fmt=,missing=NULL,showmeta=NO);\n' +
|
|
125
|
+
'%macro webout(action,ds,dslabel=,fmt=,missing=NULL,showmeta=NO,maxobs=MAX);\n' +
|
|
126
126
|
' %mv_webout(&action,ds=&ds,dslabel=&dslabel,fmt=&fmt\n' +
|
|
127
127
|
' ,missing=&missing\n' +
|
|
128
128
|
' ,showmeta=&showmeta\n' +
|
|
129
|
+
' ,maxobs=&maxobs\n' +
|
|
129
130
|
' )' +
|
|
130
131
|
'%mend;\n';
|
|
131
132
|
return [3 /*break*/, 14];
|
|
@@ -143,10 +144,11 @@ function getPreCodeForServicePack(serverType) {
|
|
|
143
144
|
case 8:
|
|
144
145
|
content = _g + _l.sent();
|
|
145
146
|
content +=
|
|
146
|
-
' %macro webout(action,ds,dslabel=,fmt=,missing=NULL,showmeta=NO);\n' +
|
|
147
|
+
' %macro webout(action,ds,dslabel=,fmt=,missing=NULL,showmeta=NO,maxobs=MAX);\n' +
|
|
147
148
|
' %mm_webout(&action,ds=&ds,dslabel=&dslabel,fmt=&fmt\n' +
|
|
148
149
|
' ,missing=&missing\n' +
|
|
149
150
|
' ,showmeta=&showmeta\n' +
|
|
151
|
+
' ,maxobs=&maxobs\n' +
|
|
150
152
|
' )' +
|
|
151
153
|
' %mend;\n';
|
|
152
154
|
return [3 /*break*/, 14];
|
|
@@ -164,10 +166,11 @@ function getPreCodeForServicePack(serverType) {
|
|
|
164
166
|
case 12:
|
|
165
167
|
content = _k + _l.sent();
|
|
166
168
|
content +=
|
|
167
|
-
' %macro webout(action,ds,dslabel=,fmt=,missing=NULL,showmeta=NO);\n' +
|
|
169
|
+
' %macro webout(action,ds,dslabel=,fmt=,missing=NULL,showmeta=NO,maxobs=MAX);\n' +
|
|
168
170
|
' %ms_webout(&action,ds=&ds,dslabel=&dslabel,fmt=&fmt\n' +
|
|
169
171
|
' ,missing=&missing\n' +
|
|
170
172
|
' ,showmeta=&showmeta\n' +
|
|
173
|
+
' ,maxobs=&maxobs\n' +
|
|
171
174
|
' )' +
|
|
172
175
|
' %mend;\n';
|
|
173
176
|
return [3 /*break*/, 14];
|
|
@@ -46,33 +46,41 @@ var path_1 = __importDefault(require("path"));
|
|
|
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, leaf, configuration,
|
|
50
|
-
return __generator(this, function (
|
|
51
|
-
switch (
|
|
49
|
+
var fileContent, _b, leaf, configuration, _c, buildSourceFolder, macroCorePath, binaryFolders;
|
|
50
|
+
return __generator(this, function (_d) {
|
|
51
|
+
switch (_d.label) {
|
|
52
52
|
case 0:
|
|
53
53
|
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Loading dependencies for ".concat(filePath));
|
|
54
54
|
fileContent = '';
|
|
55
|
-
if (!(compileTree && Object.keys(compileTree).length)) return [3 /*break*/,
|
|
55
|
+
if (!(compileTree && Object.keys(compileTree).length)) return [3 /*break*/, 6];
|
|
56
|
+
if (!(type === utils_1.SASJsFileType.file)) return [3 /*break*/, 2];
|
|
57
|
+
_b = utils_1.removeHeader;
|
|
58
|
+
return [4 /*yield*/, (0, utils_1.readFile)(filePath)];
|
|
59
|
+
case 1:
|
|
60
|
+
// If file is of a generic type SASJsFileType.file, then just read the file content without header
|
|
61
|
+
fileContent = _b.apply(void 0, [_d.sent()]);
|
|
62
|
+
return [3 /*break*/, 5];
|
|
63
|
+
case 2:
|
|
56
64
|
leaf = compileTree.getLeaf(filePath);
|
|
57
|
-
if (!leaf) return [3 /*break*/,
|
|
65
|
+
if (!leaf) return [3 /*break*/, 3];
|
|
58
66
|
fileContent = leaf.content;
|
|
59
|
-
return [3 /*break*/,
|
|
60
|
-
case
|
|
61
|
-
case
|
|
62
|
-
fileContent =
|
|
63
|
-
|
|
64
|
-
case
|
|
65
|
-
case
|
|
66
|
-
case 5:
|
|
67
|
-
fileContent = _c.sent();
|
|
68
|
-
_c.label = 6;
|
|
69
|
-
case 6: return [4 /*yield*/, (0, config_1.getLocalOrGlobalConfig)()];
|
|
67
|
+
return [3 /*break*/, 5];
|
|
68
|
+
case 3: return [4 /*yield*/, (0, utils_1.readFile)(filePath)];
|
|
69
|
+
case 4:
|
|
70
|
+
fileContent = _d.sent();
|
|
71
|
+
_d.label = 5;
|
|
72
|
+
case 5: return [3 /*break*/, 8];
|
|
73
|
+
case 6: return [4 /*yield*/, (0, utils_1.readFile)(filePath)];
|
|
70
74
|
case 7:
|
|
71
|
-
|
|
72
|
-
|
|
75
|
+
fileContent = _d.sent();
|
|
76
|
+
_d.label = 8;
|
|
77
|
+
case 8: return [4 /*yield*/, (0, config_1.getLocalOrGlobalConfig)()];
|
|
78
|
+
case 9:
|
|
79
|
+
configuration = (_d.sent()).configuration;
|
|
80
|
+
_c = process.sasjsConstants, buildSourceFolder = _c.buildSourceFolder, macroCorePath = _c.macroCorePath;
|
|
73
81
|
return [4 /*yield*/, (0, config_1.getBinaryFolders)(target)];
|
|
74
|
-
case
|
|
75
|
-
binaryFolders =
|
|
82
|
+
case 10:
|
|
83
|
+
binaryFolders = _d.sent();
|
|
76
84
|
headerSyntaxNotices(fileContent);
|
|
77
85
|
return [4 /*yield*/, (0, utils_1.loadDependenciesFile)({
|
|
78
86
|
fileContent: fileContent,
|
|
@@ -87,7 +95,7 @@ function loadDependencies(target, filePath, macroFolders, programFolders, type,
|
|
|
87
95
|
binaryFolders: binaryFolders,
|
|
88
96
|
compileTree: compileTree
|
|
89
97
|
})];
|
|
90
|
-
case
|
|
98
|
+
case 11: return [2 /*return*/, _d.sent()];
|
|
91
99
|
}
|
|
92
100
|
});
|
|
93
101
|
});
|
|
@@ -131,7 +131,7 @@ describe('compileTestFile', function () {
|
|
|
131
131
|
testVar = replaceLineBreaks("* Test Variables start;\n\n%let ".concat(Object.keys(target.testConfig.macroVars)[0], "=").concat(Object.values(target.testConfig.macroVars)[0], ";\n\n* Test Variables end;"));
|
|
132
132
|
testInit = replaceLineBreaks("* TestInit start;\n\n\n%put testing, init;\n* TestInit end;");
|
|
133
133
|
testTerm = replaceLineBreaks("* TestTerm start;\n\n\n%put testing, termed;\n* TestTerm end;");
|
|
134
|
-
mvWebout = "%macro mv_webout(action,ds,fref=_mvwtemp,dslabel=,fmt=
|
|
134
|
+
mvWebout = "%macro mv_webout(action,ds,fref=_mvwtemp,dslabel=,fmt=N,stream=Y,missing=NULL";
|
|
135
135
|
expect(testFileContent.indexOf(testVar)).toBeGreaterThan(-1);
|
|
136
136
|
expect(testFileContent.indexOf(testInit)).toBeGreaterThan(-1);
|
|
137
137
|
expect(testFileContent.indexOf(testTerm)).toBeGreaterThan(-1);
|
|
@@ -49,7 +49,6 @@ var build_1 = require("../../build/build");
|
|
|
49
49
|
var deploy_1 = require("../deploy");
|
|
50
50
|
var utils_2 = require("./utils");
|
|
51
51
|
var config_1 = require("../../../utils/config");
|
|
52
|
-
var utils_3 = require("../../../utils");
|
|
53
52
|
describe('sasjs cbd with server type SASJS', function () {
|
|
54
53
|
var target;
|
|
55
54
|
var appName;
|
|
@@ -80,9 +79,9 @@ describe('sasjs cbd with server type SASJS', function () {
|
|
|
80
79
|
});
|
|
81
80
|
}); });
|
|
82
81
|
it("should deploy compile and build to sasjs/server", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
83
|
-
var sasjs, customTarget, macroCorePath, mf_getuser, mp_jsonout, ms_webout, webout, mocksPath, appinitJSPath, getdataJSPath, appinitJSContents, getdataJSContents;
|
|
84
|
-
return __generator(this, function (
|
|
85
|
-
switch (
|
|
82
|
+
var sasjs, customTarget, macroCorePath, mf_getuser, _a, mp_jsonout, ms_webout, webout, mocksPath, appinitJSPath, getdataJSPath, appinitJSContents, getdataJSContents, depsInserts, appinit, getdata, getCode;
|
|
83
|
+
return __generator(this, function (_b) {
|
|
84
|
+
switch (_b.label) {
|
|
86
85
|
case 0:
|
|
87
86
|
sasjs = new node_1.default();
|
|
88
87
|
jest.mock('@sasjs/adapter');
|
|
@@ -98,7 +97,7 @@ describe('sasjs cbd with server type SASJS', function () {
|
|
|
98
97
|
}
|
|
99
98
|
})];
|
|
100
99
|
case 1:
|
|
101
|
-
|
|
100
|
+
_b.sent();
|
|
102
101
|
return [4 /*yield*/, (0, utils_2.updateLocalTarget)(target.name, {
|
|
103
102
|
jobConfig: undefined,
|
|
104
103
|
serviceConfig: undefined,
|
|
@@ -108,30 +107,32 @@ describe('sasjs cbd with server type SASJS', function () {
|
|
|
108
107
|
}
|
|
109
108
|
})];
|
|
110
109
|
case 2:
|
|
111
|
-
|
|
110
|
+
_b.sent();
|
|
112
111
|
return [4 /*yield*/, (0, config_1.findTargetInConfiguration)(target.name, types_1.TargetScope.Local)];
|
|
113
112
|
case 3:
|
|
114
|
-
customTarget = (
|
|
113
|
+
customTarget = (_b.sent()).target;
|
|
115
114
|
return [4 /*yield*/, expect((0, build_1.build)(customTarget)).toResolve()];
|
|
116
115
|
case 4:
|
|
117
|
-
|
|
116
|
+
_b.sent();
|
|
118
117
|
return [4 /*yield*/, (0, deploy_1.deploy)(customTarget, true, sasjs)];
|
|
119
118
|
case 5:
|
|
120
|
-
|
|
119
|
+
_b.sent();
|
|
121
120
|
macroCorePath = process.sasjsConstants.macroCorePath;
|
|
121
|
+
_a = utils_1.removeHeader;
|
|
122
122
|
return [4 /*yield*/, (0, utils_1.readFile)("".concat(macroCorePath, "/base/mf_getuser.sas"))];
|
|
123
123
|
case 6:
|
|
124
|
-
mf_getuser = _a.sent();
|
|
124
|
+
mf_getuser = _a.apply(void 0, [_b.sent()]);
|
|
125
125
|
return [4 /*yield*/, (0, utils_1.readFile)("".concat(macroCorePath, "/base/mp_jsonout.sas"))];
|
|
126
126
|
case 7:
|
|
127
|
-
mp_jsonout =
|
|
127
|
+
mp_jsonout = _b.sent();
|
|
128
128
|
return [4 /*yield*/, (0, utils_1.readFile)("".concat(macroCorePath, "/server/ms_webout.sas"))];
|
|
129
129
|
case 8:
|
|
130
|
-
ms_webout =
|
|
131
|
-
webout = ' %macro webout(action,ds,dslabel=,fmt=,missing=NULL,showmeta=NO);\n' +
|
|
130
|
+
ms_webout = _b.sent();
|
|
131
|
+
webout = ' %macro webout(action,ds,dslabel=,fmt=,missing=NULL,showmeta=NO,maxobs=MAX);\n' +
|
|
132
132
|
' %ms_webout(&action,ds=&ds,dslabel=&dslabel,fmt=&fmt\n' +
|
|
133
133
|
' ,missing=&missing\n' +
|
|
134
134
|
' ,showmeta=&showmeta\n' +
|
|
135
|
+
' ,maxobs=&maxobs\n' +
|
|
135
136
|
' )' +
|
|
136
137
|
' %mend;\n';
|
|
137
138
|
mocksPath = path_1.default.join(__dirname, appName, 'sasjs', 'mocks');
|
|
@@ -139,10 +140,16 @@ describe('sasjs cbd with server type SASJS', function () {
|
|
|
139
140
|
getdataJSPath = path_1.default.join(mocksPath, 'services', 'common', 'getdata.js');
|
|
140
141
|
return [4 /*yield*/, (0, utils_1.readFile)(appinitJSPath)];
|
|
141
142
|
case 9:
|
|
142
|
-
appinitJSContents =
|
|
143
|
+
appinitJSContents = _b.sent();
|
|
143
144
|
return [4 /*yield*/, (0, utils_1.readFile)(getdataJSPath)];
|
|
144
145
|
case 10:
|
|
145
|
-
getdataJSContents =
|
|
146
|
+
getdataJSContents = _b.sent();
|
|
147
|
+
depsInserts = "\n\n* Service Variables start;\n\n\n* Service Variables end;\n* SAS Macros start;\n\n\n\n* SAS Macros end;\n* SAS Includes start;\n\n* SAS Includes end;\n* Binary Files start;\n\n* Binary Files end;\n\n \n* Service start;\n";
|
|
148
|
+
appinit = "/**\n @file appinit.sas\n @brief Initialisation service - runs on app startup\n @details This is always the first service called when the app is opened.\n\n <h4> SAS Macros </h4>\n\n**/\n\nproc sql;\ncreate table areas as select distinct area\n from mydb.springs;\n\n%webout(OPEN)\n%webout(OBJ,areas)\n%webout(CLOSE)\n\n";
|
|
149
|
+
getdata = "/**\n @file getdata.sas\n @brief Get Data service - runs on app startup\n @details This is always the first service called when the app is opened.\n\n <h4> SAS Macros </h4>\n\n**/\n\n%webout(FETCH)\n\nproc sql;\ncreate table springs as select * from mydb.springs\n where area in (select area from work.areas);\n\n%webout(OPEN)\n%webout(OBJ,springs)\n%webout(CLOSE)\n\n";
|
|
150
|
+
getCode = function (file) {
|
|
151
|
+
return "".concat(mf_getuser).concat(mp_jsonout).concat(ms_webout).concat(webout, "/* provide additional debug info */\n%global _program;\n%put &=syscc;\n%put user=%mf_getuser();\n%put pgm=&_program;\n%put timestamp=%sysfunc(datetime(),datetime19.);").concat(depsInserts).concat(file, "* Service end;");
|
|
152
|
+
};
|
|
146
153
|
expect(sasjs.deployToSASjs).toHaveBeenCalledWith({
|
|
147
154
|
appLoc: target.appLoc,
|
|
148
155
|
fileTree: {
|
|
@@ -163,8 +170,7 @@ describe('sasjs cbd with server type SASJS', function () {
|
|
|
163
170
|
{
|
|
164
171
|
name: 'appinit',
|
|
165
172
|
type: 'service',
|
|
166
|
-
code: (
|
|
167
|
-
'/* provide additional debug info */\n%global _program;\n%put &=syscc;\n%put user=%mf_getuser();\n%put pgm=&_program;\n%put timestamp=%sysfunc(datetime(),datetime19.);\n* Service Variables start;\n* Service Variables end;\n* SAS Macros start;\n* SAS Macros end;\n* SAS Includes start;\n* SAS Includes end;\n* Binary Files start;\n* Binary Files end;\n* Service start;\nproc sql;\ncreate table areas as select distinct area\n from mydb.springs;\n%webout(OPEN)\n%webout(OBJ,areas)\n%webout(CLOSE)\n* Service end;')
|
|
173
|
+
code: getCode(appinit)
|
|
168
174
|
},
|
|
169
175
|
{
|
|
170
176
|
name: 'getdata.js',
|
|
@@ -174,8 +180,7 @@ describe('sasjs cbd with server type SASJS', function () {
|
|
|
174
180
|
{
|
|
175
181
|
name: 'getdata',
|
|
176
182
|
type: 'service',
|
|
177
|
-
code: (
|
|
178
|
-
'/* provide additional debug info */\n%global _program;\n%put &=syscc;\n%put user=%mf_getuser();\n%put pgm=&_program;\n%put timestamp=%sysfunc(datetime(),datetime19.);\n* Service Variables start;\n* Service Variables end;\n* SAS Macros start;\n* SAS Macros end;\n* SAS Includes start;\n* SAS Includes end;\n* Binary Files start;\n* Binary Files end;\n* Service start;\n%webout(FETCH)\nproc sql;\ncreate table springs as select * from mydb.springs\n where area in (select area from work.areas);\n%webout(OPEN)\n%webout(OBJ,springs)\n%webout(CLOSE)\n* Service end;')
|
|
183
|
+
code: getCode(getdata)
|
|
179
184
|
}
|
|
180
185
|
]
|
|
181
186
|
}
|
|
File without changes
|