@sasjs/cli 3.13.3 → 3.13.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/commands/compile/compile.js +33 -26
- package/build/commands/compile/compileSingleFile.js +8 -5
- package/build/commands/compile/internal/compileFile.d.ts +15 -0
- package/build/commands/compile/internal/{compileServiceFile.js → compileFile.js} +27 -5
- package/build/commands/compile/internal/compileTestFile.js +2 -2
- package/build/commands/compile/spec/compile.spec.js +24 -8
- package/build/commands/compile/spec/{compileJobFile.spec.d.ts → compileFile.spec.d.ts} +0 -0
- package/build/commands/compile/spec/{compileServiceFile.spec.js → compileFile.spec.js} +75 -37
- package/build/commands/deploy/deploy.js +6 -2
- package/build/commands/help/help.js +3 -2
- package/build/commands/job/internal/execute/sasjs.d.ts +2 -1
- package/build/commands/job/internal/execute/sasjs.js +2 -2
- package/build/commands/job/jobCommand.d.ts +1 -1
- package/build/commands/job/jobCommand.js +23 -12
- package/build/commands/job/spec/execute.spec.js +1 -1
- package/build/commands/request/request.js +4 -4
- package/build/commands/request/requestCommand.js +21 -10
- package/build/commands/shared/deployToSasViyaWithServicePack.js +6 -1
- package/build/commands/testing/spec/testCommand.spec.js +5 -3
- package/build/commands/testing/spec/testing.spec.js +32 -4
- package/build/commands/testing/test.d.ts +1 -1
- package/build/commands/testing/test.js +13 -2
- package/build/commands/testing/testCommand.js +13 -7
- package/build/commands/web/internal/sasjsout.d.ts +1 -1
- package/build/commands/web/internal/sasjsout.js +1 -1
- package/build/utils/displayResult.js +5 -1
- package/package.json +6 -5
- package/build/commands/compile/internal/compileJobFile.d.ts +0 -3
- package/build/commands/compile/internal/compileJobFile.js +0 -60
- package/build/commands/compile/internal/compileServiceFile.d.ts +0 -4
- package/build/commands/compile/spec/compileJobFile.spec.js +0 -140
- package/build/commands/compile/spec/compileServiceFile.spec.d.ts +0 -1
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
31
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
32
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
33
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
34
|
-
function step(op) {
|
|
35
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
36
|
-
while (_) try {
|
|
37
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
38
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
39
|
-
switch (op[0]) {
|
|
40
|
-
case 0: case 1: t = op; break;
|
|
41
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
42
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
43
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
44
|
-
default:
|
|
45
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
46
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
47
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
48
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
49
|
-
if (t[2]) _.ops.pop();
|
|
50
|
-
_.trys.pop(); continue;
|
|
51
|
-
}
|
|
52
|
-
op = body.call(thisArg, _);
|
|
53
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
54
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
58
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
59
|
-
};
|
|
60
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61
|
-
var path_1 = __importDefault(require("path"));
|
|
62
|
-
var utils_1 = require("@sasjs/utils");
|
|
63
|
-
var internalModule = __importStar(require("@sasjs/utils/sasjsCli/getInitTerm"));
|
|
64
|
-
var getInitTerm_1 = require("@sasjs/utils/sasjsCli/getInitTerm");
|
|
65
|
-
var test_1 = require("../../../utils/test");
|
|
66
|
-
var compileJobFile_1 = require("../internal/compileJobFile");
|
|
67
|
-
var utils_2 = require("@sasjs/utils");
|
|
68
|
-
var loadDependencies_1 = require("../internal/loadDependencies");
|
|
69
|
-
var fakeJobInit = "/**\n @file\n @brief This code is inserted into the beginning of each Viya Job.\n @details Inserted during the `sasjs compile` step. Add any code here that\n should go at the beginning of every deployed job.\n\n The path to this file should be listed in the `jobInit` property of the\n sasjsconfig file.\n\n ".concat(utils_1.DependencyHeader.DeprecatedInclude, "\n @li test.sas TEST\n\n ").concat(utils_1.DependencyHeader.Macro, "\n @li examplemacro.sas\n\n**/\n\n%example(Job Init is executing!)\n\n%let mylib=WORK;");
|
|
70
|
-
var fakeJobTerm = "/**\n @file serviceterm.sas\n @brief this file is called at the end of every service\n @details This file is included at the *end* of every service.\n\n ".concat(utils_1.DependencyHeader.Macro, "\n @li mf_abort.sas\n @li mf_existds.sas\n\n**/\n\n%put service is finishing. Thanks, SASjs!;");
|
|
71
|
-
var fakeProgramLines = [
|
|
72
|
-
'filename TEST temp;',
|
|
73
|
-
'data _null_;',
|
|
74
|
-
'file TEST lrecl=32767;',
|
|
75
|
-
"put '%put ''Hello, world!'';';",
|
|
76
|
-
'run;'
|
|
77
|
-
];
|
|
78
|
-
describe('compileJobFile', function () {
|
|
79
|
-
var appName = "cli-tests-compile-job-file-".concat((0, utils_1.generateTimestamp)());
|
|
80
|
-
var target = (0, test_1.generateTestTarget)(appName, '/Public/app', {
|
|
81
|
-
serviceFolders: [path_1.default.join('sasjs', 'services')],
|
|
82
|
-
initProgram: '',
|
|
83
|
-
termProgram: '',
|
|
84
|
-
macroVars: {}
|
|
85
|
-
}, utils_1.ServerType.SasViya);
|
|
86
|
-
beforeAll(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
87
|
-
return __generator(this, function (_a) {
|
|
88
|
-
switch (_a.label) {
|
|
89
|
-
case 0: return [4 /*yield*/, (0, test_1.createTestMinimalApp)(__dirname, target.name)];
|
|
90
|
-
case 1:
|
|
91
|
-
_a.sent();
|
|
92
|
-
return [2 /*return*/];
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}); });
|
|
96
|
-
afterAll(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
97
|
-
return __generator(this, function (_a) {
|
|
98
|
-
switch (_a.label) {
|
|
99
|
-
case 0: return [4 /*yield*/, (0, test_1.removeTestApp)(__dirname, target.name)];
|
|
100
|
-
case 1:
|
|
101
|
-
_a.sent();
|
|
102
|
-
return [2 /*return*/];
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
}); });
|
|
106
|
-
test('it should compile and create file', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
107
|
-
var filePath, buildPath, destinationPath, compileTree, compiledContent, macrosToTest;
|
|
108
|
-
return __generator(this, function (_a) {
|
|
109
|
-
switch (_a.label) {
|
|
110
|
-
case 0:
|
|
111
|
-
(0, getInitTerm_1.mockGetProgram)(internalModule, fakeJobInit, fakeJobTerm);
|
|
112
|
-
filePath = path_1.default.join(__dirname, './service.sas');
|
|
113
|
-
buildPath = path_1.default.join(process.projectDir, 'sasjsbuild');
|
|
114
|
-
destinationPath = path_1.default.join(buildPath, 'service.sas');
|
|
115
|
-
compileTree = (0, loadDependencies_1.getCompileTree)(target);
|
|
116
|
-
return [4 /*yield*/, (0, utils_2.createFolder)(buildPath)];
|
|
117
|
-
case 1:
|
|
118
|
-
_a.sent();
|
|
119
|
-
return [4 /*yield*/, (0, utils_2.copy)(filePath, destinationPath)];
|
|
120
|
-
case 2:
|
|
121
|
-
_a.sent();
|
|
122
|
-
return [4 /*yield*/, expect((0, compileJobFile_1.compileJobFile)(target, destinationPath, [path_1.default.join(__dirname, './macros')], [path_1.default.join(__dirname, './'), path_1.default.join(__dirname, './services')], undefined, compileTree)).toResolve()];
|
|
123
|
-
case 3:
|
|
124
|
-
_a.sent();
|
|
125
|
-
return [4 /*yield*/, expect((0, utils_2.fileExists)(destinationPath)).resolves.toEqual(true)];
|
|
126
|
-
case 4:
|
|
127
|
-
_a.sent();
|
|
128
|
-
return [4 /*yield*/, (0, utils_2.readFile)(destinationPath)];
|
|
129
|
-
case 5:
|
|
130
|
-
compiledContent = _a.sent();
|
|
131
|
-
macrosToTest = ['mf_abort', 'mf_existds'];
|
|
132
|
-
return [4 /*yield*/, (0, test_1.verifyCompiledJob)(compiledContent, macrosToTest)];
|
|
133
|
-
case 6:
|
|
134
|
-
_a.sent();
|
|
135
|
-
expect(compiledContent).toEqual(expect.stringContaining(fakeProgramLines.join('\n')));
|
|
136
|
-
return [2 /*return*/];
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
}); });
|
|
140
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|