@sasjs/cli 3.10.0 → 3.11.0
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/compile/compile.js +11 -8
- package/build/commands/compile/compileSingleFile.js +4 -1
- package/build/commands/compile/internal/compileTestFile.d.ts +2 -2
- package/build/commands/compile/internal/compileTestFile.js +2 -3
- package/build/commands/compile/internal/spec/compileTestFile.spec.js +2 -2
- package/build/commands/deploy/deploy.js +5 -5
- package/build/commands/deploy/spec/cbd.spec.js +9 -2
- package/build/commands/help/help.js +2 -2
- package/build/commands/request/request.js +38 -26
- package/build/commands/request/spec/request.spec.server.js +155 -68
- package/build/commands/testing/test.js +4 -2
- package/build/utils/config.js +3 -4
- package/build/utils/displayResult.js +1 -1
- package/build/utils/utils.d.ts +8 -0
- package/build/utils/utils.js +41 -1
- package/package.json +3 -3
|
@@ -144,11 +144,14 @@ function compile(target, forceCompile) {
|
|
|
144
144
|
case 10:
|
|
145
145
|
_c.sent();
|
|
146
146
|
_c.label = 11;
|
|
147
|
-
case 11: return [4 /*yield*/,
|
|
147
|
+
case 11: return [4 /*yield*/, compileTree.saveTree()];
|
|
148
148
|
case 12:
|
|
149
149
|
_c.sent();
|
|
150
|
-
return [4 /*yield*/,
|
|
150
|
+
return [4 /*yield*/, (0, compileTestFile_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.'); })];
|
|
151
151
|
case 13:
|
|
152
|
+
_c.sent();
|
|
153
|
+
return [4 /*yield*/, compileWeb(target)];
|
|
154
|
+
case 14:
|
|
152
155
|
_c.sent();
|
|
153
156
|
return [2 /*return*/];
|
|
154
157
|
}
|
|
@@ -251,13 +254,13 @@ function compileJobsServicesTests(target, compileTree) {
|
|
|
251
254
|
case 6:
|
|
252
255
|
testTearDown = _b.sent();
|
|
253
256
|
if (!testSetUp) return [3 /*break*/, 8];
|
|
254
|
-
return [4 /*yield*/, (0, compileTestFile_1.compileTestFile)(target, testSetUp, '', true, false).catch(function (err) { var _a; return (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('Test set up compilation has failed.'); })];
|
|
257
|
+
return [4 /*yield*/, (0, compileTestFile_1.compileTestFile)(target, testSetUp, '', true, false, compileTree).catch(function (err) { var _a; return (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('Test set up compilation has failed.'); })];
|
|
255
258
|
case 7:
|
|
256
259
|
_b.sent();
|
|
257
260
|
_b.label = 8;
|
|
258
261
|
case 8:
|
|
259
262
|
if (!testTearDown) return [3 /*break*/, 10];
|
|
260
|
-
return [4 /*yield*/, (0, compileTestFile_1.compileTestFile)(target, testTearDown, '', true, false).catch(function (err) { var _a; return (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('Test tear down compilation has failed.'); })];
|
|
263
|
+
return [4 /*yield*/, (0, compileTestFile_1.compileTestFile)(target, testTearDown, '', true, false, compileTree).catch(function (err) { var _a; return (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('Test tear down compilation has failed.'); })];
|
|
261
264
|
case 9:
|
|
262
265
|
_b.sent();
|
|
263
266
|
_b.label = 10;
|
|
@@ -340,7 +343,7 @@ var compileServiceFolder = function (target, serviceFolder, macroFolders, progra
|
|
|
340
343
|
case 0:
|
|
341
344
|
filePath = path_1.default.join(destinationPath, fileName);
|
|
342
345
|
if (!(0, utils_1.isTestFile)(filePath)) return [3 /*break*/, 2];
|
|
343
|
-
return [4 /*yield*/, (0, compileTestFile_1.compileTestFile)(target, filePath, '', false)];
|
|
346
|
+
return [4 /*yield*/, (0, compileTestFile_1.compileTestFile)(target, filePath, '', false, undefined, compileTree)];
|
|
344
347
|
case 1:
|
|
345
348
|
_a.sent();
|
|
346
349
|
return [3 /*break*/, 4];
|
|
@@ -368,7 +371,7 @@ var compileServiceFolder = function (target, serviceFolder, macroFolders, progra
|
|
|
368
371
|
case 0:
|
|
369
372
|
filePath = path_1.default.join(destinationPath, subFolder, fileName);
|
|
370
373
|
if (!(0, utils_1.isTestFile)(filePath)) return [3 /*break*/, 2];
|
|
371
|
-
return [4 /*yield*/, (0, compileTestFile_1.compileTestFile)(target, filePath, '', false)];
|
|
374
|
+
return [4 /*yield*/, (0, compileTestFile_1.compileTestFile)(target, filePath, '', false, undefined, compileTree)];
|
|
372
375
|
case 1:
|
|
373
376
|
_a.sent();
|
|
374
377
|
return [3 /*break*/, 4];
|
|
@@ -412,7 +415,7 @@ var compileJobFolder = function (target, jobFolder, macroFolders, programFolders
|
|
|
412
415
|
case 0:
|
|
413
416
|
filePath = path_1.default.join(destinationPath, fileName);
|
|
414
417
|
if (!(0, utils_1.isTestFile)(fileName)) return [3 /*break*/, 2];
|
|
415
|
-
return [4 /*yield*/, (0, compileTestFile_1.compileTestFile)(target, filePath, '', false)];
|
|
418
|
+
return [4 /*yield*/, (0, compileTestFile_1.compileTestFile)(target, filePath, '', false, undefined, compileTree)];
|
|
416
419
|
case 1:
|
|
417
420
|
_a.sent();
|
|
418
421
|
return [3 /*break*/, 4];
|
|
@@ -440,7 +443,7 @@ var compileJobFolder = function (target, jobFolder, macroFolders, programFolders
|
|
|
440
443
|
case 0:
|
|
441
444
|
filePath = path_1.default.join(destinationPath, subFolder, fileName);
|
|
442
445
|
if (!(0, utils_1.isTestFile)(filePath)) return [3 /*break*/, 2];
|
|
443
|
-
return [4 /*yield*/, (0, compileTestFile_1.compileTestFile)(target, filePath, '', false)];
|
|
446
|
+
return [4 /*yield*/, (0, compileTestFile_1.compileTestFile)(target, filePath, '', false, undefined, compileTree)];
|
|
444
447
|
case 1:
|
|
445
448
|
_a.sent();
|
|
446
449
|
return [3 /*break*/, 4];
|
|
@@ -128,7 +128,10 @@ function compileSingleFile(target, subCommand, source, output, insertProgramVar)
|
|
|
128
128
|
_c.sent();
|
|
129
129
|
return [3 /*break*/, 16];
|
|
130
130
|
case 15: return [3 /*break*/, 16];
|
|
131
|
-
case 16: return [
|
|
131
|
+
case 16: return [4 /*yield*/, compileTree.saveTree()];
|
|
132
|
+
case 17:
|
|
133
|
+
_c.sent();
|
|
134
|
+
return [2 /*return*/, { destinationPath: destinationPath }];
|
|
132
135
|
}
|
|
133
136
|
});
|
|
134
137
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TestFlow } from '../../../types';
|
|
2
|
-
import { Target, Configuration } from '@sasjs/utils';
|
|
3
|
-
export declare function compileTestFile(target: Target, filePath: string, testVar
|
|
2
|
+
import { Target, Configuration, CompileTree } from '@sasjs/utils';
|
|
3
|
+
export declare function compileTestFile(target: Target, filePath: string, testVar: string | undefined, saveToRoot: boolean | undefined, removeOriginalFile: boolean | undefined, compileTree: CompileTree): Promise<void>;
|
|
4
4
|
export declare function moveTestFile(filePath: string): Promise<void>;
|
|
5
5
|
export declare function copyTestMacroFiles(folderAbsolutePath: string): Promise<void>;
|
|
6
6
|
export declare const compileTestFlow: (target: Target, config?: Configuration | undefined) => Promise<TestFlow | undefined>;
|
|
@@ -77,16 +77,15 @@ var testsBuildFolder = function () {
|
|
|
77
77
|
return path_1.default.join(process.projectDir, 'sasjsbuild', 'tests');
|
|
78
78
|
};
|
|
79
79
|
var getFileName = function (filePath) { return path_1.default.parse(filePath).base; };
|
|
80
|
-
function compileTestFile(target, filePath, testVar, saveToRoot, removeOriginalFile) {
|
|
80
|
+
function compileTestFile(target, filePath, testVar, saveToRoot, removeOriginalFile, compileTree) {
|
|
81
81
|
if (testVar === void 0) { testVar = ''; }
|
|
82
82
|
if (saveToRoot === void 0) { saveToRoot = true; }
|
|
83
83
|
if (removeOriginalFile === void 0) { removeOriginalFile = true; }
|
|
84
84
|
return __awaiter(this, void 0, void 0, function () {
|
|
85
|
-
var
|
|
85
|
+
var dependencies, _a, _b, preCode, destinationPath;
|
|
86
86
|
return __generator(this, function (_c) {
|
|
87
87
|
switch (_c.label) {
|
|
88
88
|
case 0:
|
|
89
|
-
compileTree = (0, loadDependencies_1.getCompileTree)(target);
|
|
90
89
|
_a = loadDependencies_1.loadDependencies;
|
|
91
90
|
_b = [target,
|
|
92
91
|
(0, utils_1.getAbsolutePath)(filePath, process.projectDir)];
|
|
@@ -129,8 +129,8 @@ describe('compileTestFile', function () {
|
|
|
129
129
|
case 2:
|
|
130
130
|
testFileContent = _a.apply(void 0, [_b.sent()]);
|
|
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
|
-
testInit = replaceLineBreaks("* TestInit start;\n%put testing, init;\n* TestInit end;");
|
|
133
|
-
testTerm = replaceLineBreaks("* TestTerm start;\n%put testing, termed;\n* TestTerm end;");
|
|
132
|
+
testInit = replaceLineBreaks("* TestInit start;\n\n\n%put testing, init;\n* TestInit end;");
|
|
133
|
+
testTerm = replaceLineBreaks("* TestTerm start;\n\n\n%put testing, termed;\n* TestTerm end;");
|
|
134
134
|
mvWebout = "%macro mv_webout(action,ds,fref=_mvwtemp,dslabel=,fmt=Y,stream=Y,missing=NULL<br> ,showmeta=NO<br>);";
|
|
135
135
|
expect(testFileContent.indexOf(testVar)).toBeGreaterThan(-1);
|
|
136
136
|
expect(testFileContent.indexOf(testInit)).toBeGreaterThan(-1);
|
|
@@ -330,11 +330,12 @@ function deployToSas9(deployScriptName, target, linesToExecute, logFolder, strea
|
|
|
330
330
|
* Deploys app to `SASJS` server.
|
|
331
331
|
* @param {Target} target- the target having deploy configuration.
|
|
332
332
|
* @param {object} sasjs - optional configuration object of SAS adapter.
|
|
333
|
+
* @param {object} streamConfig - optional config for deploying streaming app.
|
|
333
334
|
*/
|
|
334
335
|
function deployToSasjs(target, sasjs, streamConfig) {
|
|
335
336
|
var _a, _b, _c;
|
|
336
337
|
return __awaiter(this, void 0, void 0, function () {
|
|
337
|
-
var buildDestinationFolder, finalFilePathJSON, jsonContent, payload, authConfig, e_2, result,
|
|
338
|
+
var buildDestinationFolder, finalFilePathJSON, jsonContent, payload, authConfig, e_2, result, webAppStreamUrl;
|
|
338
339
|
return __generator(this, function (_d) {
|
|
339
340
|
switch (_d.label) {
|
|
340
341
|
case 0:
|
|
@@ -363,7 +364,7 @@ function deployToSasjs(target, sasjs, streamConfig) {
|
|
|
363
364
|
e_2 = _d.sent();
|
|
364
365
|
return [3 /*break*/, 5];
|
|
365
366
|
case 5: return [4 /*yield*/, sasjs
|
|
366
|
-
.deployToSASjs(payload, undefined, authConfig)
|
|
367
|
+
.deployToSASjs(payload, undefined, streamConfig, authConfig)
|
|
367
368
|
.catch(function (err) {
|
|
368
369
|
var _a;
|
|
369
370
|
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.error(err);
|
|
@@ -376,9 +377,8 @@ function deployToSasjs(target, sasjs, streamConfig) {
|
|
|
376
377
|
(_b = process.logger) === null || _b === void 0 ? void 0 : _b.info("Payload example:\n".concat(JSON.stringify(result.example, null, 2)));
|
|
377
378
|
}
|
|
378
379
|
}
|
|
379
|
-
if (streamConfig === null || streamConfig === void 0 ? void 0 : streamConfig.streamWeb) {
|
|
380
|
-
|
|
381
|
-
webAppStreamUrl = "".concat(target.serverUrl, "/AppStream").concat(appLoc);
|
|
380
|
+
if ((streamConfig === null || streamConfig === void 0 ? void 0 : streamConfig.streamWeb) && (result === null || result === void 0 ? void 0 : result.streamServiceName)) {
|
|
381
|
+
webAppStreamUrl = "".concat(target.serverUrl, "/AppStream/").concat(result.streamServiceName);
|
|
382
382
|
(_c = process.logger) === null || _c === void 0 ? void 0 : _c.info("Web app is available at ".concat(webAppStreamUrl));
|
|
383
383
|
}
|
|
384
384
|
return [2 /*return*/];
|
|
@@ -78,7 +78,7 @@ describe('sasjs cbd with server type SASJS', function () {
|
|
|
78
78
|
});
|
|
79
79
|
}); });
|
|
80
80
|
it("should deploy compile and build to sasjs/server", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
81
|
-
var sasjs, customTarget, macroCorePath, mf_getuser, mp_jsonout, ms_webout, webout;
|
|
81
|
+
var sasjs, customTarget, macroCorePath, mf_getuser, mp_jsonout, ms_webout, webout, streamConfig;
|
|
82
82
|
return __generator(this, function (_a) {
|
|
83
83
|
switch (_a.label) {
|
|
84
84
|
case 0:
|
|
@@ -125,6 +125,13 @@ describe('sasjs cbd with server type SASJS', function () {
|
|
|
125
125
|
' ,showmeta=&showmeta\n' +
|
|
126
126
|
' )' +
|
|
127
127
|
' %mend;\n';
|
|
128
|
+
streamConfig = {
|
|
129
|
+
assetPaths: [],
|
|
130
|
+
streamServiceName: 'clickme',
|
|
131
|
+
streamWeb: false,
|
|
132
|
+
streamWebFolder: '',
|
|
133
|
+
webSourcePath: ''
|
|
134
|
+
};
|
|
128
135
|
expect(sasjs.deployToSASjs).toHaveBeenCalledWith({
|
|
129
136
|
members: [
|
|
130
137
|
{
|
|
@@ -152,7 +159,7 @@ describe('sasjs cbd with server type SASJS', function () {
|
|
|
152
159
|
]
|
|
153
160
|
}
|
|
154
161
|
]
|
|
155
|
-
}, undefined, undefined);
|
|
162
|
+
}, undefined, streamConfig, undefined);
|
|
156
163
|
return [2 /*return*/];
|
|
157
164
|
}
|
|
158
165
|
});
|
|
@@ -223,8 +223,8 @@ function printHelpText() {
|
|
|
223
223
|
"the user run a SAS job against a specified target.",
|
|
224
224
|
"The target can exist either in the local project configuration or in the global .sasjsrc file.",
|
|
225
225
|
"<sasProgramPath> - if this has a leading slash (eg /Public/app/folder/servicename) then it must be the full path. If it is a relative path (eg path/servicename) then it will be pre-pended with the appLoc - which must then be defined in the sasjs config.",
|
|
226
|
-
"<path/to/log> - Location in which to store the log file. If not provided AND
|
|
227
|
-
"<path/to/output> - Location to store the output file. If not provided
|
|
226
|
+
"<path/to/log> - Location in which to store the log file. If not provided AND current directory is a sasjs project, it will be saved in sasjsresults else in the current directory",
|
|
227
|
+
"<path/to/output> - Location to store the output file. If not provided AND current directory is a sasjs project, an output file will be saved in the sasjsresults folder else in current directory."
|
|
228
228
|
]
|
|
229
229
|
},
|
|
230
230
|
{
|
|
@@ -47,7 +47,6 @@ var displayResult_1 = require("../../utils/displayResult");
|
|
|
47
47
|
var types_1 = require("@sasjs/utils/types");
|
|
48
48
|
var utils_2 = require("../../utils/utils");
|
|
49
49
|
var saveLog_1 = require("../../utils/saveLog");
|
|
50
|
-
var getLogFilePath_1 = require("../../utils/getLogFilePath");
|
|
51
50
|
function runSasJob(target, isLocal, sasJobLocation, dataFilePath, configFilePath, authConfig, logFile, jobPath, outputPathParam) {
|
|
52
51
|
return __awaiter(this, void 0, void 0, function () {
|
|
53
52
|
var dataJson, configJson, dataFile, configFile, sas9CredentialsError, sasjs, result;
|
|
@@ -150,7 +149,7 @@ function runSasJob(target, isLocal, sasJobLocation, dataFilePath, configFilePath
|
|
|
150
149
|
output = res;
|
|
151
150
|
}
|
|
152
151
|
if (!!!output) return [3 /*break*/, 4];
|
|
153
|
-
return [4 /*yield*/, writeOutput(outputPathParam, output,
|
|
152
|
+
return [4 /*yield*/, writeOutput(outputPathParam, output, sasJobLocation)];
|
|
154
153
|
case 3:
|
|
155
154
|
_a.sent();
|
|
156
155
|
_a.label = 4;
|
|
@@ -193,20 +192,28 @@ function runSasJob(target, isLocal, sasJobLocation, dataFilePath, configFilePath
|
|
|
193
192
|
}
|
|
194
193
|
exports.runSasJob = runSasJob;
|
|
195
194
|
var saveLogFile = function (sasjs, sasJobLocation, logFile, jobPath) { return __awaiter(void 0, void 0, void 0, function () {
|
|
196
|
-
var sasRequests, currentRequestLog;
|
|
195
|
+
var sasRequests, currentRequestLog, logPath, timestamp, filename;
|
|
197
196
|
return __generator(this, function (_a) {
|
|
198
197
|
switch (_a.label) {
|
|
199
198
|
case 0:
|
|
200
199
|
sasRequests = sasjs.getSasRequests();
|
|
201
200
|
currentRequestLog = sasRequests.find(function (x) { return x.serviceLink === sasJobLocation; });
|
|
202
|
-
if (!(currentRequestLog && jobPath)) return [3 /*break*/,
|
|
203
|
-
if (
|
|
204
|
-
|
|
205
|
-
return [4 /*yield*/, (0, saveLog_1.saveLog)(currentRequestLog.logFile, logFile, jobPath || '', false)];
|
|
201
|
+
if (!(currentRequestLog && jobPath)) return [3 /*break*/, 4];
|
|
202
|
+
if (!!logFile) return [3 /*break*/, 2];
|
|
203
|
+
return [4 /*yield*/, (0, utils_2.isSASjsProject)()];
|
|
206
204
|
case 1:
|
|
207
|
-
_a.sent()
|
|
205
|
+
logPath = (_a.sent())
|
|
206
|
+
? path_1.default.join(process.sasjsConstants.buildDestinationResultsFolder, 'requests')
|
|
207
|
+
: process.projectDir;
|
|
208
|
+
timestamp = (0, utils_1.generateTimestamp)();
|
|
209
|
+
filename = sasJobLocation.split(path_1.default.sep).pop();
|
|
210
|
+
logFile = path_1.default.join(logPath, "".concat(filename, "-").concat(timestamp, ".log"));
|
|
208
211
|
_a.label = 2;
|
|
209
|
-
case 2: return [
|
|
212
|
+
case 2: return [4 /*yield*/, (0, saveLog_1.saveLog)(currentRequestLog.logFile, logFile, jobPath || '', false)];
|
|
213
|
+
case 3:
|
|
214
|
+
_a.sent();
|
|
215
|
+
_a.label = 4;
|
|
216
|
+
case 4: return [2 /*return*/];
|
|
210
217
|
}
|
|
211
218
|
});
|
|
212
219
|
}); };
|
|
@@ -214,15 +221,18 @@ var saveLogFile = function (sasjs, sasJobLocation, logFile, jobPath) { return __
|
|
|
214
221
|
* Writes output to the file
|
|
215
222
|
* @param outputPathParam path to output file
|
|
216
223
|
* @param output data to be written to output file
|
|
217
|
-
* @param
|
|
224
|
+
* @param sasJobLocation is used for output file name when outputPathParam is undefined
|
|
218
225
|
* @returns output path for the file created
|
|
219
226
|
*/
|
|
220
|
-
var writeOutput = function (outputPathParam, output,
|
|
221
|
-
var outputPath, outputFilename, outputPathArr, outputString;
|
|
227
|
+
var writeOutput = function (outputPathParam, output, sasJobLocation) { return __awaiter(void 0, void 0, void 0, function () {
|
|
228
|
+
var outputPath, outputFilename, outputPathArr, timestamp, filename, outputString;
|
|
222
229
|
return __generator(this, function (_a) {
|
|
223
230
|
switch (_a.label) {
|
|
224
|
-
case 0:
|
|
225
|
-
|
|
231
|
+
case 0: return [4 /*yield*/, (0, utils_2.isSASjsProject)()];
|
|
232
|
+
case 1:
|
|
233
|
+
outputPath = (_a.sent())
|
|
234
|
+
? path_1.default.join(process.sasjsConstants.buildDestinationResultsFolder, 'requests')
|
|
235
|
+
: process.projectDir;
|
|
226
236
|
if (outputPathParam && typeof outputPathParam === 'string') {
|
|
227
237
|
outputPathParam = path_1.default.join(process.projectDir, outputPathParam || '');
|
|
228
238
|
outputPathArr = outputPathParam.split(path_1.default.sep);
|
|
@@ -230,18 +240,20 @@ var writeOutput = function (outputPathParam, output, isLocal) { return __awaiter
|
|
|
230
240
|
outputPath = outputPathArr.join(path_1.default.sep);
|
|
231
241
|
}
|
|
232
242
|
return [4 /*yield*/, (0, utils_1.folderExists)(outputPath)];
|
|
233
|
-
case 1:
|
|
234
|
-
if (!!(_a.sent())) return [3 /*break*/, 3];
|
|
235
|
-
return [4 /*yield*/, (0, utils_1.createFolder)(outputPath)];
|
|
236
243
|
case 2:
|
|
237
|
-
_a.sent();
|
|
238
|
-
|
|
244
|
+
if (!!(_a.sent())) return [3 /*break*/, 4];
|
|
245
|
+
return [4 /*yield*/, (0, utils_1.createFolder)(outputPath)];
|
|
239
246
|
case 3:
|
|
247
|
+
_a.sent();
|
|
248
|
+
_a.label = 4;
|
|
249
|
+
case 4:
|
|
240
250
|
if (outputFilename) {
|
|
241
251
|
outputPath += "".concat(path_1.default.sep).concat(outputFilename);
|
|
242
252
|
}
|
|
243
253
|
else {
|
|
244
|
-
|
|
254
|
+
timestamp = (0, utils_1.generateTimestamp)();
|
|
255
|
+
filename = sasJobLocation.split(path_1.default.sep).pop();
|
|
256
|
+
outputPath += "".concat(path_1.default.sep).concat(filename, "-").concat(timestamp, ".json");
|
|
245
257
|
}
|
|
246
258
|
outputString = '';
|
|
247
259
|
if (typeof output === 'object') {
|
|
@@ -256,16 +268,16 @@ var writeOutput = function (outputPathParam, output, isLocal) { return __awaiter
|
|
|
256
268
|
else {
|
|
257
269
|
outputString = output;
|
|
258
270
|
}
|
|
259
|
-
if (!outputString) return [3 /*break*/,
|
|
271
|
+
if (!outputString) return [3 /*break*/, 6];
|
|
260
272
|
return [4 /*yield*/, (0, utils_1.createFile)(outputPath, outputString)];
|
|
261
|
-
case
|
|
273
|
+
case 5:
|
|
262
274
|
_a.sent();
|
|
263
275
|
(0, displayResult_1.displaySuccess)("Request finished. Output is stored at '".concat(outputPath, "'"));
|
|
264
|
-
return [3 /*break*/,
|
|
265
|
-
case
|
|
276
|
+
return [3 /*break*/, 7];
|
|
277
|
+
case 6:
|
|
266
278
|
(0, displayResult_1.displayError)("There was a problem with writing output file. Data not present.");
|
|
267
|
-
_a.label =
|
|
268
|
-
case
|
|
279
|
+
_a.label = 7;
|
|
280
|
+
case 7: return [2 /*return*/];
|
|
269
281
|
}
|
|
270
282
|
});
|
|
271
283
|
}); };
|
|
@@ -10,6 +10,25 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
+
if (mod && mod.__esModule) return mod;
|
|
27
|
+
var result = {};
|
|
28
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
+
__setModuleDefault(result, mod);
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
13
32
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
33
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
34
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -54,6 +73,7 @@ var path_1 = __importDefault(require("path"));
|
|
|
54
73
|
var utils_1 = require("@sasjs/utils");
|
|
55
74
|
var utils_2 = require("@sasjs/utils");
|
|
56
75
|
var test_1 = require("../../../utils/test");
|
|
76
|
+
var timeStampUtils = __importStar(require("@sasjs/utils/time"));
|
|
57
77
|
var config_1 = require("../../../utils/config");
|
|
58
78
|
var request_1 = require("../request");
|
|
59
79
|
var build_1 = require("../../build/build");
|
|
@@ -92,14 +112,17 @@ var expectedDataObj = {
|
|
|
92
112
|
}
|
|
93
113
|
]
|
|
94
114
|
};
|
|
95
|
-
var getOutputJson = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
115
|
+
var getOutputJson = function (fileName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
116
|
+
var _a, _b;
|
|
117
|
+
return __generator(this, function (_c) {
|
|
118
|
+
switch (_c.label) {
|
|
119
|
+
case 0:
|
|
120
|
+
_b = (_a = JSON).parse;
|
|
121
|
+
return [4 /*yield*/, (0, utils_1.readFile)(path_1.default.join(process.sasjsConstants.buildDestinationResultsFolder, 'requests', fileName))];
|
|
122
|
+
case 1: return [2 /*return*/, _b.apply(_a, [_c.sent()])];
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}); };
|
|
103
126
|
describe('sasjs request without compute API', function () {
|
|
104
127
|
var appName = 'cli-tests-request-' + (0, utils_2.generateTimestamp)();
|
|
105
128
|
var target = (0, test_1.generateTestTarget)(appName, "/Public/app/cli-tests/".concat(appName), {
|
|
@@ -165,18 +188,24 @@ describe('sasjs request without compute API', function () {
|
|
|
165
188
|
});
|
|
166
189
|
}); });
|
|
167
190
|
it("should execute service 'sendArr' with absolute path", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
168
|
-
var _a, _b;
|
|
191
|
+
var timestamp, outputFilename, _a, _b;
|
|
169
192
|
return __generator(this, function (_c) {
|
|
170
193
|
switch (_c.label) {
|
|
171
|
-
case 0:
|
|
194
|
+
case 0:
|
|
195
|
+
timestamp = (0, utils_2.generateTimestamp)();
|
|
196
|
+
jest
|
|
197
|
+
.spyOn(timeStampUtils, 'generateTimestamp')
|
|
198
|
+
.mockImplementationOnce(function () { return timestamp; });
|
|
199
|
+
outputFilename = "sendArr-".concat(timestamp, ".json");
|
|
200
|
+
return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, "/Public/app/cli-tests/".concat(target.name, "/services/runRequest/sendArr"), dataPathRel, undefined, authConfig)).toResolve()];
|
|
172
201
|
case 1:
|
|
173
202
|
_c.sent();
|
|
174
203
|
_a = expect;
|
|
175
|
-
return [4 /*yield*/, getOutputJson()];
|
|
204
|
+
return [4 /*yield*/, getOutputJson(outputFilename)];
|
|
176
205
|
case 2:
|
|
177
206
|
_a.apply(void 0, [(_c.sent()).table1]).toEqual(expectedDataArr.table1);
|
|
178
207
|
_b = expect;
|
|
179
|
-
return [4 /*yield*/, getOutputJson()];
|
|
208
|
+
return [4 /*yield*/, getOutputJson(outputFilename)];
|
|
180
209
|
case 3:
|
|
181
210
|
_b.apply(void 0, [(_c.sent()).table2]).toEqual(expectedDataArr.table2);
|
|
182
211
|
return [2 /*return*/];
|
|
@@ -184,18 +213,24 @@ describe('sasjs request without compute API', function () {
|
|
|
184
213
|
});
|
|
185
214
|
}); });
|
|
186
215
|
it("should execute service 'sendObj' with absolute path", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
187
|
-
var _a, _b;
|
|
216
|
+
var timestamp, outputFilename, _a, _b;
|
|
188
217
|
return __generator(this, function (_c) {
|
|
189
218
|
switch (_c.label) {
|
|
190
|
-
case 0:
|
|
219
|
+
case 0:
|
|
220
|
+
timestamp = (0, utils_2.generateTimestamp)();
|
|
221
|
+
jest
|
|
222
|
+
.spyOn(timeStampUtils, 'generateTimestamp')
|
|
223
|
+
.mockImplementationOnce(function () { return timestamp; });
|
|
224
|
+
outputFilename = "sendObj-".concat(timestamp, ".json");
|
|
225
|
+
return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, "/Public/app/cli-tests/".concat(target.name, "/services/runRequest/sendObj"), dataPathRel, undefined, authConfig)).toResolve()];
|
|
191
226
|
case 1:
|
|
192
227
|
_c.sent();
|
|
193
228
|
_a = expect;
|
|
194
|
-
return [4 /*yield*/, getOutputJson()];
|
|
229
|
+
return [4 /*yield*/, getOutputJson(outputFilename)];
|
|
195
230
|
case 2:
|
|
196
231
|
_a.apply(void 0, [(_c.sent()).table1]).toEqual(expectedDataObj.table1);
|
|
197
232
|
_b = expect;
|
|
198
|
-
return [4 /*yield*/, getOutputJson()];
|
|
233
|
+
return [4 /*yield*/, getOutputJson(outputFilename)];
|
|
199
234
|
case 3:
|
|
200
235
|
_b.apply(void 0, [(_c.sent()).table2]).toEqual(expectedDataObj.table2);
|
|
201
236
|
return [2 /*return*/];
|
|
@@ -203,18 +238,24 @@ describe('sasjs request without compute API', function () {
|
|
|
203
238
|
});
|
|
204
239
|
}); });
|
|
205
240
|
it("should execute service 'sendArr' with relative path", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
206
|
-
var _a, _b;
|
|
241
|
+
var timestamp, outputFilename, _a, _b;
|
|
207
242
|
return __generator(this, function (_c) {
|
|
208
243
|
switch (_c.label) {
|
|
209
|
-
case 0:
|
|
244
|
+
case 0:
|
|
245
|
+
timestamp = (0, utils_2.generateTimestamp)();
|
|
246
|
+
jest
|
|
247
|
+
.spyOn(timeStampUtils, 'generateTimestamp')
|
|
248
|
+
.mockImplementationOnce(function () { return timestamp; });
|
|
249
|
+
outputFilename = "sendArr-".concat(timestamp, ".json");
|
|
250
|
+
return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, 'services/runRequest/sendArr', dataPathRel, undefined, authConfig)).toResolve()];
|
|
210
251
|
case 1:
|
|
211
252
|
_c.sent();
|
|
212
253
|
_a = expect;
|
|
213
|
-
return [4 /*yield*/, getOutputJson()];
|
|
254
|
+
return [4 /*yield*/, getOutputJson(outputFilename)];
|
|
214
255
|
case 2:
|
|
215
256
|
_a.apply(void 0, [(_c.sent()).table1]).toEqual(expectedDataArr.table1);
|
|
216
257
|
_b = expect;
|
|
217
|
-
return [4 /*yield*/, getOutputJson()];
|
|
258
|
+
return [4 /*yield*/, getOutputJson(outputFilename)];
|
|
218
259
|
case 3:
|
|
219
260
|
_b.apply(void 0, [(_c.sent()).table2]).toEqual(expectedDataArr.table2);
|
|
220
261
|
return [2 /*return*/];
|
|
@@ -222,18 +263,24 @@ describe('sasjs request without compute API', function () {
|
|
|
222
263
|
});
|
|
223
264
|
}); });
|
|
224
265
|
it("should execute service 'sendObj' with relative path", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
225
|
-
var _a, _b;
|
|
266
|
+
var timestamp, outputFilename, _a, _b;
|
|
226
267
|
return __generator(this, function (_c) {
|
|
227
268
|
switch (_c.label) {
|
|
228
|
-
case 0:
|
|
269
|
+
case 0:
|
|
270
|
+
timestamp = (0, utils_2.generateTimestamp)();
|
|
271
|
+
jest
|
|
272
|
+
.spyOn(timeStampUtils, 'generateTimestamp')
|
|
273
|
+
.mockImplementationOnce(function () { return timestamp; });
|
|
274
|
+
outputFilename = "sendObj-".concat(timestamp, ".json");
|
|
275
|
+
return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, 'services/runRequest/sendObj', dataPathRel, undefined, authConfig)).toResolve()];
|
|
229
276
|
case 1:
|
|
230
277
|
_c.sent();
|
|
231
278
|
_a = expect;
|
|
232
|
-
return [4 /*yield*/, getOutputJson()];
|
|
279
|
+
return [4 /*yield*/, getOutputJson(outputFilename)];
|
|
233
280
|
case 2:
|
|
234
281
|
_a.apply(void 0, [(_c.sent()).table1]).toEqual(expectedDataObj.table1);
|
|
235
282
|
_b = expect;
|
|
236
|
-
return [4 /*yield*/, getOutputJson()];
|
|
283
|
+
return [4 /*yield*/, getOutputJson(outputFilename)];
|
|
237
284
|
case 3:
|
|
238
285
|
_b.apply(void 0, [(_c.sent()).table2]).toEqual(expectedDataObj.table2);
|
|
239
286
|
return [2 /*return*/];
|
|
@@ -258,7 +305,7 @@ describe('sasjs request without compute API', function () {
|
|
|
258
305
|
});
|
|
259
306
|
}); });
|
|
260
307
|
it("should execute service 'err' with absolute path with log path", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
261
|
-
var jobPath, log, rawLogDataStats
|
|
308
|
+
var jobPath, log, rawLogDataStats;
|
|
262
309
|
return __generator(this, function (_a) {
|
|
263
310
|
switch (_a.label) {
|
|
264
311
|
case 0:
|
|
@@ -268,15 +315,13 @@ describe('sasjs request without compute API', function () {
|
|
|
268
315
|
case 1:
|
|
269
316
|
_a.sent();
|
|
270
317
|
rawLogDataStats = (0, fs_1.statSync)(log);
|
|
271
|
-
rawDataStats = (0, fs_1.statSync)(path_1.default.join(process.projectDir, 'output.json'));
|
|
272
318
|
expect(rawLogDataStats.size).toBeGreaterThan(10);
|
|
273
|
-
expect(rawDataStats.size).toBeGreaterThan(10);
|
|
274
319
|
return [2 /*return*/];
|
|
275
320
|
}
|
|
276
321
|
});
|
|
277
322
|
}); });
|
|
278
323
|
it("should execute service 'err' with absolute path with default log path", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
279
|
-
var jobPath, log, rawLogDataStats
|
|
324
|
+
var jobPath, log, rawLogDataStats;
|
|
280
325
|
return __generator(this, function (_a) {
|
|
281
326
|
switch (_a.label) {
|
|
282
327
|
case 0:
|
|
@@ -286,9 +331,7 @@ describe('sasjs request without compute API', function () {
|
|
|
286
331
|
case 1:
|
|
287
332
|
_a.sent();
|
|
288
333
|
rawLogDataStats = (0, fs_1.statSync)(log);
|
|
289
|
-
rawDataStats = (0, fs_1.statSync)(path_1.default.join(process.projectDir, 'output.json'));
|
|
290
334
|
expect(rawLogDataStats.size).toBeGreaterThan(10);
|
|
291
|
-
expect(rawDataStats.size).toBeGreaterThan(10);
|
|
292
335
|
return [2 /*return*/];
|
|
293
336
|
}
|
|
294
337
|
});
|
|
@@ -355,18 +398,24 @@ describe('sasjs request with SAS9', function () {
|
|
|
355
398
|
});
|
|
356
399
|
}); });
|
|
357
400
|
it("should execute service 'sendArr' with absolute path", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
358
|
-
var _a, _b;
|
|
401
|
+
var timestamp, outputFilename, _a, _b;
|
|
359
402
|
return __generator(this, function (_c) {
|
|
360
403
|
switch (_c.label) {
|
|
361
|
-
case 0:
|
|
404
|
+
case 0:
|
|
405
|
+
timestamp = (0, utils_2.generateTimestamp)();
|
|
406
|
+
jest
|
|
407
|
+
.spyOn(timeStampUtils, 'generateTimestamp')
|
|
408
|
+
.mockImplementationOnce(function () { return timestamp; });
|
|
409
|
+
outputFilename = "sendArr-".concat(timestamp, ".json");
|
|
410
|
+
return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, "/Public/app/cli-tests/".concat(target.name, "/services/runRequest/sendArr"), dataPathRel)).toResolve()];
|
|
362
411
|
case 1:
|
|
363
412
|
_c.sent();
|
|
364
413
|
_a = expect;
|
|
365
|
-
return [4 /*yield*/, getOutputJson()];
|
|
414
|
+
return [4 /*yield*/, getOutputJson(outputFilename)];
|
|
366
415
|
case 2:
|
|
367
416
|
_a.apply(void 0, [(_c.sent()).table1]).toEqual(expectedDataArr.table1);
|
|
368
417
|
_b = expect;
|
|
369
|
-
return [4 /*yield*/, getOutputJson()];
|
|
418
|
+
return [4 /*yield*/, getOutputJson(outputFilename)];
|
|
370
419
|
case 3:
|
|
371
420
|
_b.apply(void 0, [(_c.sent()).table2]).toEqual(expectedDataArr.table2);
|
|
372
421
|
return [2 /*return*/];
|
|
@@ -374,18 +423,24 @@ describe('sasjs request with SAS9', function () {
|
|
|
374
423
|
});
|
|
375
424
|
}); });
|
|
376
425
|
it("should execute service 'sendObj' with absolute path", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
377
|
-
var _a, _b;
|
|
426
|
+
var timestamp, outputFilename, _a, _b;
|
|
378
427
|
return __generator(this, function (_c) {
|
|
379
428
|
switch (_c.label) {
|
|
380
|
-
case 0:
|
|
429
|
+
case 0:
|
|
430
|
+
timestamp = (0, utils_2.generateTimestamp)();
|
|
431
|
+
jest
|
|
432
|
+
.spyOn(timeStampUtils, 'generateTimestamp')
|
|
433
|
+
.mockImplementationOnce(function () { return timestamp; });
|
|
434
|
+
outputFilename = "sendObj-".concat(timestamp, ".json");
|
|
435
|
+
return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, "/Public/app/cli-tests/".concat(target.name, "/services/runRequest/sendObj"), dataPathRel)).toResolve()];
|
|
381
436
|
case 1:
|
|
382
437
|
_c.sent();
|
|
383
438
|
_a = expect;
|
|
384
|
-
return [4 /*yield*/, getOutputJson()];
|
|
439
|
+
return [4 /*yield*/, getOutputJson(outputFilename)];
|
|
385
440
|
case 2:
|
|
386
441
|
_a.apply(void 0, [(_c.sent()).table1]).toEqual(expectedDataObj.table1);
|
|
387
442
|
_b = expect;
|
|
388
|
-
return [4 /*yield*/, getOutputJson()];
|
|
443
|
+
return [4 /*yield*/, getOutputJson(outputFilename)];
|
|
389
444
|
case 3:
|
|
390
445
|
_b.apply(void 0, [(_c.sent()).table2]).toEqual(expectedDataObj.table2);
|
|
391
446
|
return [2 /*return*/];
|
|
@@ -393,18 +448,24 @@ describe('sasjs request with SAS9', function () {
|
|
|
393
448
|
});
|
|
394
449
|
}); });
|
|
395
450
|
it("should execute service 'sendArr' with relative path", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
396
|
-
var _a, _b;
|
|
451
|
+
var timestamp, outputFilename, _a, _b;
|
|
397
452
|
return __generator(this, function (_c) {
|
|
398
453
|
switch (_c.label) {
|
|
399
|
-
case 0:
|
|
454
|
+
case 0:
|
|
455
|
+
timestamp = (0, utils_2.generateTimestamp)();
|
|
456
|
+
jest
|
|
457
|
+
.spyOn(timeStampUtils, 'generateTimestamp')
|
|
458
|
+
.mockImplementationOnce(function () { return timestamp; });
|
|
459
|
+
outputFilename = "sendArr-".concat(timestamp, ".json");
|
|
460
|
+
return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, 'services/runRequest/sendArr', dataPathRel)).toResolve()];
|
|
400
461
|
case 1:
|
|
401
462
|
_c.sent();
|
|
402
463
|
_a = expect;
|
|
403
|
-
return [4 /*yield*/, getOutputJson()];
|
|
464
|
+
return [4 /*yield*/, getOutputJson(outputFilename)];
|
|
404
465
|
case 2:
|
|
405
466
|
_a.apply(void 0, [(_c.sent()).table1]).toEqual(expectedDataArr.table1);
|
|
406
467
|
_b = expect;
|
|
407
|
-
return [4 /*yield*/, getOutputJson()];
|
|
468
|
+
return [4 /*yield*/, getOutputJson(outputFilename)];
|
|
408
469
|
case 3:
|
|
409
470
|
_b.apply(void 0, [(_c.sent()).table2]).toEqual(expectedDataArr.table2);
|
|
410
471
|
return [2 /*return*/];
|
|
@@ -412,18 +473,24 @@ describe('sasjs request with SAS9', function () {
|
|
|
412
473
|
});
|
|
413
474
|
}); });
|
|
414
475
|
it("should execute service 'sendObj' with relative path", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
415
|
-
var _a, _b;
|
|
476
|
+
var timestamp, outputFilename, _a, _b;
|
|
416
477
|
return __generator(this, function (_c) {
|
|
417
478
|
switch (_c.label) {
|
|
418
|
-
case 0:
|
|
479
|
+
case 0:
|
|
480
|
+
timestamp = (0, utils_2.generateTimestamp)();
|
|
481
|
+
jest
|
|
482
|
+
.spyOn(timeStampUtils, 'generateTimestamp')
|
|
483
|
+
.mockImplementationOnce(function () { return timestamp; });
|
|
484
|
+
outputFilename = "sendObj-".concat(timestamp, ".json");
|
|
485
|
+
return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, 'services/runRequest/sendObj', dataPathRel)).toResolve()];
|
|
419
486
|
case 1:
|
|
420
487
|
_c.sent();
|
|
421
488
|
_a = expect;
|
|
422
|
-
return [4 /*yield*/, getOutputJson()];
|
|
489
|
+
return [4 /*yield*/, getOutputJson(outputFilename)];
|
|
423
490
|
case 2:
|
|
424
491
|
_a.apply(void 0, [(_c.sent()).table1]).toEqual(expectedDataObj.table1);
|
|
425
492
|
_b = expect;
|
|
426
|
-
return [4 /*yield*/, getOutputJson()];
|
|
493
|
+
return [4 /*yield*/, getOutputJson(outputFilename)];
|
|
427
494
|
case 3:
|
|
428
495
|
_b.apply(void 0, [(_c.sent()).table2]).toEqual(expectedDataObj.table2);
|
|
429
496
|
return [2 /*return*/];
|
|
@@ -448,7 +515,7 @@ describe('sasjs request with SAS9', function () {
|
|
|
448
515
|
});
|
|
449
516
|
}); });
|
|
450
517
|
it("should execute service 'err' with absolute path with log path", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
451
|
-
var jobPath, log, rawLogDataStats
|
|
518
|
+
var jobPath, log, rawLogDataStats;
|
|
452
519
|
return __generator(this, function (_a) {
|
|
453
520
|
switch (_a.label) {
|
|
454
521
|
case 0:
|
|
@@ -458,15 +525,13 @@ describe('sasjs request with SAS9', function () {
|
|
|
458
525
|
case 1:
|
|
459
526
|
_a.sent();
|
|
460
527
|
rawLogDataStats = (0, fs_1.statSync)(log);
|
|
461
|
-
rawDataStats = (0, fs_1.statSync)(path_1.default.join(process.projectDir, 'output.json'));
|
|
462
528
|
expect(rawLogDataStats.size).toBeGreaterThan(10);
|
|
463
|
-
expect(rawDataStats.size).toBeGreaterThan(10);
|
|
464
529
|
return [2 /*return*/];
|
|
465
530
|
}
|
|
466
531
|
});
|
|
467
532
|
}); });
|
|
468
533
|
it("should execute service 'err' with absolute path with default log path", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
469
|
-
var jobPath, log, rawLogDataStats
|
|
534
|
+
var jobPath, log, rawLogDataStats;
|
|
470
535
|
return __generator(this, function (_a) {
|
|
471
536
|
switch (_a.label) {
|
|
472
537
|
case 0:
|
|
@@ -476,9 +541,7 @@ describe('sasjs request with SAS9', function () {
|
|
|
476
541
|
case 1:
|
|
477
542
|
_a.sent();
|
|
478
543
|
rawLogDataStats = (0, fs_1.statSync)(log);
|
|
479
|
-
rawDataStats = (0, fs_1.statSync)(path_1.default.join(process.projectDir, 'output.json'));
|
|
480
544
|
expect(rawLogDataStats.size).toBeGreaterThan(10);
|
|
481
|
-
expect(rawDataStats.size).toBeGreaterThan(10);
|
|
482
545
|
return [2 /*return*/];
|
|
483
546
|
}
|
|
484
547
|
});
|
|
@@ -544,18 +607,24 @@ describe("sasjs request with compute API", function () {
|
|
|
544
607
|
});
|
|
545
608
|
}); });
|
|
546
609
|
it("should execute service 'sendArr' with absolute path", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
547
|
-
var _a, _b;
|
|
610
|
+
var timestamp, outputFilename, _a, _b;
|
|
548
611
|
return __generator(this, function (_c) {
|
|
549
612
|
switch (_c.label) {
|
|
550
|
-
case 0:
|
|
613
|
+
case 0:
|
|
614
|
+
timestamp = (0, utils_2.generateTimestamp)();
|
|
615
|
+
jest
|
|
616
|
+
.spyOn(timeStampUtils, 'generateTimestamp')
|
|
617
|
+
.mockImplementationOnce(function () { return timestamp; });
|
|
618
|
+
outputFilename = "sendArr-".concat(timestamp, ".json");
|
|
619
|
+
return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, "/Public/app/cli-tests/".concat(target.name, "/services/runRequest/sendArr"), dataPathRel, configPathRel, authConfig)).toResolve()];
|
|
551
620
|
case 1:
|
|
552
621
|
_c.sent();
|
|
553
622
|
_a = expect;
|
|
554
|
-
return [4 /*yield*/, getOutputJson()];
|
|
623
|
+
return [4 /*yield*/, getOutputJson(outputFilename)];
|
|
555
624
|
case 2:
|
|
556
625
|
_a.apply(void 0, [(_c.sent()).table1]).toEqual(expectedDataArr.table1);
|
|
557
626
|
_b = expect;
|
|
558
|
-
return [4 /*yield*/, getOutputJson()];
|
|
627
|
+
return [4 /*yield*/, getOutputJson(outputFilename)];
|
|
559
628
|
case 3:
|
|
560
629
|
_b.apply(void 0, [(_c.sent()).table2]).toEqual(expectedDataArr.table2);
|
|
561
630
|
return [2 /*return*/];
|
|
@@ -563,18 +632,24 @@ describe("sasjs request with compute API", function () {
|
|
|
563
632
|
});
|
|
564
633
|
}); });
|
|
565
634
|
it("should execute service 'sendObj' with absolute path", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
566
|
-
var _a, _b;
|
|
635
|
+
var timestamp, outputFilename, _a, _b;
|
|
567
636
|
return __generator(this, function (_c) {
|
|
568
637
|
switch (_c.label) {
|
|
569
|
-
case 0:
|
|
638
|
+
case 0:
|
|
639
|
+
timestamp = (0, utils_2.generateTimestamp)();
|
|
640
|
+
jest
|
|
641
|
+
.spyOn(timeStampUtils, 'generateTimestamp')
|
|
642
|
+
.mockImplementationOnce(function () { return timestamp; });
|
|
643
|
+
outputFilename = "sendObj-".concat(timestamp, ".json");
|
|
644
|
+
return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, "/Public/app/cli-tests/".concat(target.name, "/services/runRequest/sendObj"), dataPathRel, configPathRel, authConfig)).toResolve()];
|
|
570
645
|
case 1:
|
|
571
646
|
_c.sent();
|
|
572
647
|
_a = expect;
|
|
573
|
-
return [4 /*yield*/, getOutputJson()];
|
|
648
|
+
return [4 /*yield*/, getOutputJson(outputFilename)];
|
|
574
649
|
case 2:
|
|
575
650
|
_a.apply(void 0, [(_c.sent()).table1]).toEqual(expectedDataObj.table1);
|
|
576
651
|
_b = expect;
|
|
577
|
-
return [4 /*yield*/, getOutputJson()];
|
|
652
|
+
return [4 /*yield*/, getOutputJson(outputFilename)];
|
|
578
653
|
case 3:
|
|
579
654
|
_b.apply(void 0, [(_c.sent()).table2]).toEqual(expectedDataObj.table2);
|
|
580
655
|
return [2 /*return*/];
|
|
@@ -582,18 +657,24 @@ describe("sasjs request with compute API", function () {
|
|
|
582
657
|
});
|
|
583
658
|
}); });
|
|
584
659
|
it("should execute service 'sendArr' with relative path", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
585
|
-
var _a, _b;
|
|
660
|
+
var timestamp, outputFilename, _a, _b;
|
|
586
661
|
return __generator(this, function (_c) {
|
|
587
662
|
switch (_c.label) {
|
|
588
|
-
case 0:
|
|
663
|
+
case 0:
|
|
664
|
+
timestamp = (0, utils_2.generateTimestamp)();
|
|
665
|
+
jest
|
|
666
|
+
.spyOn(timeStampUtils, 'generateTimestamp')
|
|
667
|
+
.mockImplementationOnce(function () { return timestamp; });
|
|
668
|
+
outputFilename = "sendArr-".concat(timestamp, ".json");
|
|
669
|
+
return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, 'services/runRequest/sendArr', dataPathRel, undefined, authConfig)).toResolve()];
|
|
589
670
|
case 1:
|
|
590
671
|
_c.sent();
|
|
591
672
|
_a = expect;
|
|
592
|
-
return [4 /*yield*/, getOutputJson()];
|
|
673
|
+
return [4 /*yield*/, getOutputJson(outputFilename)];
|
|
593
674
|
case 2:
|
|
594
675
|
_a.apply(void 0, [(_c.sent()).table1]).toEqual(expectedDataArr.table1);
|
|
595
676
|
_b = expect;
|
|
596
|
-
return [4 /*yield*/, getOutputJson()];
|
|
677
|
+
return [4 /*yield*/, getOutputJson(outputFilename)];
|
|
597
678
|
case 3:
|
|
598
679
|
_b.apply(void 0, [(_c.sent()).table2]).toEqual(expectedDataArr.table2);
|
|
599
680
|
return [2 /*return*/];
|
|
@@ -601,18 +682,24 @@ describe("sasjs request with compute API", function () {
|
|
|
601
682
|
});
|
|
602
683
|
}); });
|
|
603
684
|
it("should execute service 'sendObj' with relative path", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
604
|
-
var _a, _b;
|
|
685
|
+
var timestamp, outputFilename, _a, _b;
|
|
605
686
|
return __generator(this, function (_c) {
|
|
606
687
|
switch (_c.label) {
|
|
607
|
-
case 0:
|
|
688
|
+
case 0:
|
|
689
|
+
timestamp = (0, utils_2.generateTimestamp)();
|
|
690
|
+
jest
|
|
691
|
+
.spyOn(timeStampUtils, 'generateTimestamp')
|
|
692
|
+
.mockImplementationOnce(function () { return timestamp; });
|
|
693
|
+
outputFilename = "sendObj-".concat(timestamp, ".json");
|
|
694
|
+
return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, 'services/runRequest/sendObj', dataPathRel, undefined, authConfig)).toResolve()];
|
|
608
695
|
case 1:
|
|
609
696
|
_c.sent();
|
|
610
697
|
_a = expect;
|
|
611
|
-
return [4 /*yield*/, getOutputJson()];
|
|
698
|
+
return [4 /*yield*/, getOutputJson(outputFilename)];
|
|
612
699
|
case 2:
|
|
613
700
|
_a.apply(void 0, [(_c.sent()).table1]).toEqual(expectedDataObj.table1);
|
|
614
701
|
_b = expect;
|
|
615
|
-
return [4 /*yield*/, getOutputJson()];
|
|
702
|
+
return [4 /*yield*/, getOutputJson(outputFilename)];
|
|
616
703
|
case 3:
|
|
617
704
|
_b.apply(void 0, [(_c.sent()).table2]).toEqual(expectedDataObj.table2);
|
|
618
705
|
return [2 /*return*/];
|
|
@@ -122,7 +122,7 @@ function runTest(target, testRegExps, outDirectory, flowSourcePath) {
|
|
|
122
122
|
flow = [];
|
|
123
123
|
if (testFlow.testSetUp)
|
|
124
124
|
flow.push(testFlow.testSetUp);
|
|
125
|
-
if (testFlow.tests)
|
|
125
|
+
if (testFlow.tests) {
|
|
126
126
|
flow = __spreadArray(__spreadArray([], __read(flow), false), __read(testFlow.tests.filter(function (test) {
|
|
127
127
|
var e_2, _a;
|
|
128
128
|
if (!testRegExps.length)
|
|
@@ -144,6 +144,7 @@ function runTest(target, testRegExps, outDirectory, flowSourcePath) {
|
|
|
144
144
|
}
|
|
145
145
|
return match;
|
|
146
146
|
})), false);
|
|
147
|
+
}
|
|
147
148
|
if (testFlow.testTearDown)
|
|
148
149
|
flow.push(testFlow.testTearDown);
|
|
149
150
|
sasjs = (0, createSASjsInstance_1.createSASjsInstance)({
|
|
@@ -190,7 +191,8 @@ function runTest(target, testRegExps, outDirectory, flowSourcePath) {
|
|
|
190
191
|
case 7:
|
|
191
192
|
e_1 = _e.sent();
|
|
192
193
|
return [3 /*break*/, 8];
|
|
193
|
-
case 8:
|
|
194
|
+
case 8: // FIXME: handle error properly
|
|
195
|
+
return [3 /*break*/, 9];
|
|
194
196
|
case 9:
|
|
195
197
|
result = {
|
|
196
198
|
sasjs_test_meta: []
|
package/build/utils/config.js
CHANGED
|
@@ -686,11 +686,10 @@ function getMacroFolders(target) {
|
|
|
686
686
|
return [4 /*yield*/, getLocalOrGlobalConfig()];
|
|
687
687
|
case 1:
|
|
688
688
|
localConfig = (_a.sent()).configuration;
|
|
689
|
+
if (target === null || target === void 0 ? void 0 : target.macroFolders)
|
|
690
|
+
macroFolders = target.macroFolders;
|
|
689
691
|
if (localConfig === null || localConfig === void 0 ? void 0 : localConfig.macroFolders) {
|
|
690
|
-
macroFolders = localConfig.macroFolders;
|
|
691
|
-
}
|
|
692
|
-
if (target === null || target === void 0 ? void 0 : target.macroFolders) {
|
|
693
|
-
macroFolders = target.macroFolders.concat(macroFolders);
|
|
692
|
+
macroFolders = localConfig.macroFolders.concat(macroFolders);
|
|
694
693
|
}
|
|
695
694
|
buildSourceFolder = process.sasjsConstants.buildSourceFolder;
|
|
696
695
|
macroFolders = macroFolders.map(function (macroFolder) {
|
|
@@ -12,7 +12,7 @@ function displayError(err, errorMessage) {
|
|
|
12
12
|
if (errorMessage === void 0) { errorMessage = ''; }
|
|
13
13
|
if (errorMessage)
|
|
14
14
|
errorMessage = "".concat(errorMessage, "\n");
|
|
15
|
-
if (err
|
|
15
|
+
if (err) {
|
|
16
16
|
var failureDetails = '';
|
|
17
17
|
if (err.hasOwnProperty('error')) {
|
|
18
18
|
var body = err.error || null;
|
package/build/utils/utils.d.ts
CHANGED
|
@@ -35,3 +35,11 @@ export declare function displaySasjsRunnerError(username: string): void;
|
|
|
35
35
|
export declare const loadEnvVariables: (fileName: string) => Promise<void>;
|
|
36
36
|
export declare function prefixAppLoc(appLoc?: string, path?: string): string | null;
|
|
37
37
|
export declare const terminateProcess: (status: number) => never;
|
|
38
|
+
/**
|
|
39
|
+
* This function checks whether the current directory, or any of the parent
|
|
40
|
+
* directories, are part of a SASjs project. This is done by testing for
|
|
41
|
+
* the existence of a ./sasjs/sasjsconfig.json file.
|
|
42
|
+
*
|
|
43
|
+
* @returns boolean
|
|
44
|
+
*/
|
|
45
|
+
export declare const isSASjsProject: () => Promise<boolean>;
|
package/build/utils/utils.js
CHANGED
|
@@ -86,7 +86,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
86
86
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
87
87
|
};
|
|
88
88
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
89
|
-
exports.terminateProcess = exports.prefixAppLoc = exports.loadEnvVariables = exports.displaySasjsRunnerError = exports.getAdapterInstance = exports.checkNodeVersion = exports.millisecondsToDdHhMmSs = exports.arrToObj = exports.parseLogLines = exports.executeShellScript = exports.getUniqServicesObj = exports.removeComments = exports.setupDoxygen = exports.setupGhooks = exports.setupGitIgnore = exports.setupNpmProject = exports.createTemplateApp = exports.createMinimalApp = exports.createAngularApp = exports.createReactApp = exports.diff = exports.inExistingProject = void 0;
|
|
89
|
+
exports.isSASjsProject = exports.terminateProcess = exports.prefixAppLoc = exports.loadEnvVariables = exports.displaySasjsRunnerError = exports.getAdapterInstance = exports.checkNodeVersion = exports.millisecondsToDdHhMmSs = exports.arrToObj = exports.parseLogLines = exports.executeShellScript = exports.getUniqServicesObj = exports.removeComments = exports.setupDoxygen = exports.setupGhooks = exports.setupGitIgnore = exports.setupNpmProject = exports.createTemplateApp = exports.createMinimalApp = exports.createAngularApp = exports.createReactApp = exports.diff = exports.inExistingProject = void 0;
|
|
90
90
|
var shelljs_1 = __importDefault(require("shelljs"));
|
|
91
91
|
var path_1 = __importDefault(require("path"));
|
|
92
92
|
var ora_1 = __importDefault(require("ora"));
|
|
@@ -561,3 +561,43 @@ var terminateProcess = function (status) {
|
|
|
561
561
|
process.exit(status);
|
|
562
562
|
};
|
|
563
563
|
exports.terminateProcess = terminateProcess;
|
|
564
|
+
/**
|
|
565
|
+
* This function checks whether the current directory, or any of the parent
|
|
566
|
+
* directories, are part of a SASjs project. This is done by testing for
|
|
567
|
+
* the existence of a ./sasjs/sasjsconfig.json file.
|
|
568
|
+
*
|
|
569
|
+
* @returns boolean
|
|
570
|
+
*/
|
|
571
|
+
var isSASjsProject = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
572
|
+
var i, currentLocation, maxLevels, _a;
|
|
573
|
+
return __generator(this, function (_b) {
|
|
574
|
+
switch (_b.label) {
|
|
575
|
+
case 0:
|
|
576
|
+
i = 1;
|
|
577
|
+
currentLocation = process.projectDir;
|
|
578
|
+
maxLevels = currentLocation.split(path_1.default.sep).length;
|
|
579
|
+
_b.label = 1;
|
|
580
|
+
case 1:
|
|
581
|
+
if (!(i <= maxLevels)) return [3 /*break*/, 5];
|
|
582
|
+
return [4 /*yield*/, (0, utils_1.folderExists)(path_1.default.join(currentLocation, 'sasjs'))];
|
|
583
|
+
case 2:
|
|
584
|
+
_a = (_b.sent());
|
|
585
|
+
if (!_a) return [3 /*break*/, 4];
|
|
586
|
+
return [4 /*yield*/, (0, utils_1.fileExists)(path_1.default.join(currentLocation, 'sasjs', 'sasjsconfig.json'))];
|
|
587
|
+
case 3:
|
|
588
|
+
_a = (_b.sent());
|
|
589
|
+
_b.label = 4;
|
|
590
|
+
case 4:
|
|
591
|
+
if (_a) {
|
|
592
|
+
return [2 /*return*/, true];
|
|
593
|
+
}
|
|
594
|
+
else {
|
|
595
|
+
currentLocation = path_1.default.join(currentLocation, '..');
|
|
596
|
+
i++;
|
|
597
|
+
}
|
|
598
|
+
return [3 /*break*/, 1];
|
|
599
|
+
case 5: return [2 /*return*/, false];
|
|
600
|
+
}
|
|
601
|
+
});
|
|
602
|
+
}); };
|
|
603
|
+
exports.isSASjsProject = isSASjsProject;
|
package/package.json
CHANGED
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@sasjs/adapter": "
|
|
50
|
+
"@sasjs/adapter": "3.8.0",
|
|
51
51
|
"@sasjs/core": "4.15.3",
|
|
52
52
|
"@sasjs/lint": "1.11.2",
|
|
53
|
-
"@sasjs/utils": "2.
|
|
53
|
+
"@sasjs/utils": "2.40.0",
|
|
54
54
|
"chalk": "4.1.2",
|
|
55
55
|
"csv-stringify": "5.6.5",
|
|
56
56
|
"dotenv": "10.0.0",
|
|
@@ -94,5 +94,5 @@
|
|
|
94
94
|
"typescript": "4.5.4",
|
|
95
95
|
"util": "0.12.4"
|
|
96
96
|
},
|
|
97
|
-
"version": "3.
|
|
97
|
+
"version": "3.11.0"
|
|
98
98
|
}
|