@sasjs/cli 6.2.3 → 6.2.5
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/README.md +1 -0
- package/build/commands/build/build.js +2 -2
- package/build/commands/compile/compileCommand.d.ts +7 -1
- package/build/commands/compile/compileCommand.js +31 -40
- package/build/commands/compile/compileSingleFile.d.ts +1 -1
- package/build/commands/compile/compileSingleFile.js +204 -55
- package/build/commands/compile/internal/getAllFolders.js +6 -4
- package/build/commands/compile/internal/loadDependencies.js +1 -1
- package/build/commands/compile/spec/compile.spec.js +28 -46
- package/build/commands/compile/spec/compileCommand.spec.js +69 -15
- package/build/commands/compile/spec/compileSingleFile.spec.js +314 -0
- package/build/commands/compile/spec/loadDependencies.spec.js +20 -0
- package/build/commands/help/help.js +5 -2
- package/build/commands/run/run.js +3 -6
- package/package.json +5 -5
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
14
|
if (k2 === undefined) k2 = k;
|
|
4
15
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -68,13 +79,21 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
68
79
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
69
80
|
}
|
|
70
81
|
};
|
|
82
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
83
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
84
|
+
};
|
|
71
85
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
86
|
+
var path_1 = __importDefault(require("path"));
|
|
87
|
+
var fs_1 = __importDefault(require("fs"));
|
|
88
|
+
var os_1 = __importDefault(require("os"));
|
|
72
89
|
var compileSingleFile_1 = require("../compileSingleFile");
|
|
73
90
|
var identifySasFileModule = __importStar(require("../internal/identifySasFile"));
|
|
74
91
|
var fileModule = __importStar(require("@sasjs/utils/file"));
|
|
75
92
|
var configModule = __importStar(require("../../../utils/config"));
|
|
76
93
|
var loadDependenciesModule = __importStar(require("../internal/loadDependencies"));
|
|
77
94
|
var compileTestFileModule = __importStar(require("../internal/compileTestFile"));
|
|
95
|
+
var compileFileModule = __importStar(require("../internal/compileFile"));
|
|
96
|
+
var getAllFoldersModule = __importStar(require("../internal/getAllFolders"));
|
|
78
97
|
var internal_1 = require("../internal");
|
|
79
98
|
describe('compileSingleFile', function () {
|
|
80
99
|
it('should throw an error provided not supported subcommand', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -140,6 +159,9 @@ describe('compileSingleFile', function () {
|
|
|
140
159
|
jest
|
|
141
160
|
.spyOn(compileTestFileModule, 'compileTestFile')
|
|
142
161
|
.mockImplementation(function () { return Promise.resolve(); });
|
|
162
|
+
jest
|
|
163
|
+
.spyOn(getAllFoldersModule, 'getAllFolders')
|
|
164
|
+
.mockImplementation(function () { return Promise.resolve(['testCurrentDir']); });
|
|
143
165
|
jest.spyOn(identifySasFileModule, 'identifySasFile');
|
|
144
166
|
return [4 /*yield*/, (0, compileSingleFile_1.compileSingleFile)({}, 'identify', testFile, 'testOutput', false, 'testCurrentDir')];
|
|
145
167
|
case 1:
|
|
@@ -169,4 +191,296 @@ describe('compileSingleFile', function () {
|
|
|
169
191
|
}
|
|
170
192
|
});
|
|
171
193
|
}); });
|
|
194
|
+
describe('destination folder', function () {
|
|
195
|
+
var projectRoot = 'project';
|
|
196
|
+
var originalConstants = process.sasjsConstants;
|
|
197
|
+
var source = path_1.default.join('sasjs', 'jobs', 'daily', 'myjob.sas');
|
|
198
|
+
beforeEach(function () {
|
|
199
|
+
process.sasjsConstants = {
|
|
200
|
+
buildDestinationJobsFolder: path_1.default.join('project', 'sasjsbuild', 'jobs'),
|
|
201
|
+
buildDestinationServicesFolder: path_1.default.join('project', 'sasjsbuild', 'services')
|
|
202
|
+
};
|
|
203
|
+
jest.spyOn(fileModule, 'fileExists').mockResolvedValue(true);
|
|
204
|
+
jest.spyOn(fileModule, 'deleteFolder').mockResolvedValue(undefined);
|
|
205
|
+
jest.spyOn(fileModule, 'createFolder').mockResolvedValue(undefined);
|
|
206
|
+
jest.spyOn(fileModule, 'copy').mockResolvedValue(undefined);
|
|
207
|
+
jest
|
|
208
|
+
.spyOn(configModule, 'getMacroFolders')
|
|
209
|
+
.mockImplementation(function () { return Promise.resolve([]); });
|
|
210
|
+
jest
|
|
211
|
+
.spyOn(configModule, 'getProgramFolders')
|
|
212
|
+
.mockImplementation(function () { return Promise.resolve([]); });
|
|
213
|
+
jest
|
|
214
|
+
.spyOn(loadDependenciesModule, 'getCompileTree')
|
|
215
|
+
.mockImplementation(function () { return ({ saveTree: function () { return Promise.resolve(); } }); });
|
|
216
|
+
jest
|
|
217
|
+
.spyOn(getAllFoldersModule, 'getAllFolders')
|
|
218
|
+
.mockImplementation(function (_target, type) {
|
|
219
|
+
return Promise.resolve(type === 'job'
|
|
220
|
+
? [path_1.default.join(projectRoot, 'sasjs', 'jobs', 'daily')]
|
|
221
|
+
: [path_1.default.join(projectRoot, 'sasjs', 'services', 'example')]);
|
|
222
|
+
});
|
|
223
|
+
jest
|
|
224
|
+
.spyOn(compileFileModule, 'compileFile')
|
|
225
|
+
.mockImplementation(function () { return Promise.resolve(); });
|
|
226
|
+
jest
|
|
227
|
+
.spyOn(compileTestFileModule, 'compileTestFile')
|
|
228
|
+
.mockImplementation(function () { return Promise.resolve(); });
|
|
229
|
+
});
|
|
230
|
+
afterEach(function () {
|
|
231
|
+
process.sasjsConstants = originalConstants;
|
|
232
|
+
});
|
|
233
|
+
it('should send an identified job to the jobs folder', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
234
|
+
var destinationPath;
|
|
235
|
+
return __generator(this, function (_a) {
|
|
236
|
+
switch (_a.label) {
|
|
237
|
+
case 0:
|
|
238
|
+
jest
|
|
239
|
+
.spyOn(identifySasFileModule, 'identifySasFile')
|
|
240
|
+
.mockImplementation(function () { return Promise.resolve(internal_1.SasFileType.Job); });
|
|
241
|
+
return [4 /*yield*/, (0, compileSingleFile_1.compileSingleFile)({}, 'identify', source, undefined, false, projectRoot)];
|
|
242
|
+
case 1:
|
|
243
|
+
destinationPath = (_a.sent()).destinationPath;
|
|
244
|
+
expect(destinationPath).toEqual(path_1.default.join('project', 'sasjsbuild', 'jobs', 'daily', 'myjob.sas'));
|
|
245
|
+
return [2 /*return*/];
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
}); });
|
|
249
|
+
it('should send an identified service to the services folder', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
250
|
+
var serviceSource, destinationPath;
|
|
251
|
+
return __generator(this, function (_a) {
|
|
252
|
+
switch (_a.label) {
|
|
253
|
+
case 0:
|
|
254
|
+
jest
|
|
255
|
+
.spyOn(identifySasFileModule, 'identifySasFile')
|
|
256
|
+
.mockImplementation(function () { return Promise.resolve(internal_1.SasFileType.Service); });
|
|
257
|
+
serviceSource = path_1.default.join('sasjs', 'services', 'example', 'myService.sas');
|
|
258
|
+
return [4 /*yield*/, (0, compileSingleFile_1.compileSingleFile)({}, 'identify', serviceSource, undefined, false, projectRoot)];
|
|
259
|
+
case 1:
|
|
260
|
+
destinationPath = (_a.sent()).destinationPath;
|
|
261
|
+
expect(destinationPath).toEqual(path_1.default.join('project', 'sasjsbuild', 'services', 'example', 'myService.sas'));
|
|
262
|
+
return [2 /*return*/];
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
}); });
|
|
266
|
+
it('should point _program at the leaf folder of the source', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
267
|
+
var compileFileSpy, programVar;
|
|
268
|
+
return __generator(this, function (_a) {
|
|
269
|
+
switch (_a.label) {
|
|
270
|
+
case 0:
|
|
271
|
+
compileFileSpy = jest
|
|
272
|
+
.spyOn(compileFileModule, 'compileFile')
|
|
273
|
+
.mockImplementation(function () { return Promise.resolve(); });
|
|
274
|
+
return [4 /*yield*/, (0, compileSingleFile_1.compileSingleFile)({ appLoc: '/Public/app' }, 'job', source, undefined, true, projectRoot)];
|
|
275
|
+
case 1:
|
|
276
|
+
_a.sent();
|
|
277
|
+
programVar = compileFileSpy.mock.calls[0][4];
|
|
278
|
+
expect(programVar).toContain('%let _program=/Public/app/jobs/daily/myjob;');
|
|
279
|
+
return [2 /*return*/];
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
}); });
|
|
283
|
+
it('should file a test under tests/<where the test lives>', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
284
|
+
var serviceTest, destinationPath;
|
|
285
|
+
return __generator(this, function (_a) {
|
|
286
|
+
switch (_a.label) {
|
|
287
|
+
case 0:
|
|
288
|
+
serviceTest = path_1.default.join('sasjs', 'services', 'example', 'check.test.sas');
|
|
289
|
+
process.sasjsConstants = __assign(__assign({}, process.sasjsConstants), { buildDestinationTestFolder: path_1.default.join('project', 'sasjsbuild', 'tests') });
|
|
290
|
+
return [4 /*yield*/, (0, compileSingleFile_1.compileSingleFile)({}, 'test', serviceTest, undefined, false, projectRoot)];
|
|
291
|
+
case 1:
|
|
292
|
+
destinationPath = (_a.sent()).destinationPath;
|
|
293
|
+
expect(destinationPath).toEqual(path_1.default.join('project', 'sasjsbuild', 'tests', 'services', 'example', 'check.test.sas'));
|
|
294
|
+
return [2 /*return*/];
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
}); });
|
|
298
|
+
it('should take the test kind from a tests/<type> path', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
299
|
+
var destinationPath;
|
|
300
|
+
return __generator(this, function (_a) {
|
|
301
|
+
switch (_a.label) {
|
|
302
|
+
case 0:
|
|
303
|
+
process.sasjsConstants = __assign(__assign({}, process.sasjsConstants), { buildDestinationTestFolder: path_1.default.join('project', 'sasjsbuild', 'tests') });
|
|
304
|
+
return [4 /*yield*/, (0, compileSingleFile_1.compileSingleFile)({}, 'test', path_1.default.join('sasjs', 'tests', 'jobs', 'load.test.sas'), undefined, false, projectRoot)];
|
|
305
|
+
case 1:
|
|
306
|
+
destinationPath = (_a.sent()).destinationPath;
|
|
307
|
+
expect(destinationPath).toEqual(path_1.default.join('project', 'sasjsbuild', 'tests', 'jobs', 'load.test.sas'));
|
|
308
|
+
return [2 /*return*/];
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
}); });
|
|
312
|
+
it('should write below the output base when one is given', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
313
|
+
var destinationPath;
|
|
314
|
+
return __generator(this, function (_a) {
|
|
315
|
+
switch (_a.label) {
|
|
316
|
+
case 0: return [4 /*yield*/, (0, compileSingleFile_1.compileSingleFile)({}, 'job', source, path_1.default.join('/tmp', 'out'), false, projectRoot)];
|
|
317
|
+
case 1:
|
|
318
|
+
destinationPath = (_a.sent()).destinationPath;
|
|
319
|
+
expect(destinationPath).toEqual(path_1.default.join('/tmp', 'out', 'jobs', 'daily', 'myjob.sas'));
|
|
320
|
+
return [2 /*return*/];
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
}); });
|
|
324
|
+
it('should keep a dotted file name in _program', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
325
|
+
var compileFileSpy;
|
|
326
|
+
return __generator(this, function (_a) {
|
|
327
|
+
switch (_a.label) {
|
|
328
|
+
case 0:
|
|
329
|
+
compileFileSpy = jest
|
|
330
|
+
.spyOn(compileFileModule, 'compileFile')
|
|
331
|
+
.mockImplementation(function () { return Promise.resolve(); });
|
|
332
|
+
return [4 /*yield*/, (0, compileSingleFile_1.compileSingleFile)({ appLoc: '/Public/app' }, 'job', path_1.default.join('sasjs', 'jobs', 'daily', 'load.daily.sas'), undefined, true, projectRoot)];
|
|
333
|
+
case 1:
|
|
334
|
+
_a.sent();
|
|
335
|
+
expect(compileFileSpy.mock.calls[0][4]).toContain('%let _program=/Public/app/jobs/daily/load.daily;');
|
|
336
|
+
return [2 /*return*/];
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
}); });
|
|
340
|
+
it('should refuse a sub command it does not know', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
341
|
+
return __generator(this, function (_a) {
|
|
342
|
+
switch (_a.label) {
|
|
343
|
+
case 0:
|
|
344
|
+
jest
|
|
345
|
+
.spyOn(identifySasFileModule, 'identifySasFile')
|
|
346
|
+
.mockImplementation(function () { return Promise.resolve('nonsense'); });
|
|
347
|
+
return [4 /*yield*/, expect((0, compileSingleFile_1.compileSingleFile)({}, 'identify', source, undefined, false, projectRoot)).rejects.toThrow('Single file compilation failed. Unsupported sub command: nonsense')];
|
|
348
|
+
case 1:
|
|
349
|
+
_a.sent();
|
|
350
|
+
return [2 /*return*/];
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
}); });
|
|
354
|
+
it('should refuse a test it cannot file under any tree', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
355
|
+
return __generator(this, function (_a) {
|
|
356
|
+
switch (_a.label) {
|
|
357
|
+
case 0: return [4 /*yield*/, expect((0, compileSingleFile_1.compileSingleFile)({}, 'test', path_1.default.join('elsewhere', 'loose.test.sas'), undefined, false, projectRoot)).rejects.toThrow(/Cannot tell which test tree/)];
|
|
358
|
+
case 1:
|
|
359
|
+
_a.sent();
|
|
360
|
+
return [2 /*return*/];
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
}); });
|
|
364
|
+
it('should delete nothing, so sibling compiled files survive', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
365
|
+
var deleteFolderSpy, createFolderSpy;
|
|
366
|
+
return __generator(this, function (_a) {
|
|
367
|
+
switch (_a.label) {
|
|
368
|
+
case 0:
|
|
369
|
+
deleteFolderSpy = jest.spyOn(fileModule, 'deleteFolder');
|
|
370
|
+
createFolderSpy = jest.spyOn(fileModule, 'createFolder');
|
|
371
|
+
return [4 /*yield*/, (0, compileSingleFile_1.compileSingleFile)({}, 'job', source, undefined, false, projectRoot)];
|
|
372
|
+
case 1:
|
|
373
|
+
_a.sent();
|
|
374
|
+
expect(deleteFolderSpy).not.toHaveBeenCalled();
|
|
375
|
+
// the folder is created if missing (mkdir is recursive and idempotent)
|
|
376
|
+
expect(createFolderSpy).toHaveBeenCalledWith(path_1.default.join('project', 'sasjsbuild', 'jobs', 'daily'));
|
|
377
|
+
return [2 /*return*/];
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
}); });
|
|
381
|
+
});
|
|
382
|
+
describe('sibling files on disk', function () {
|
|
383
|
+
var originalConstants = process.sasjsConstants;
|
|
384
|
+
var root;
|
|
385
|
+
beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
386
|
+
return __generator(this, function (_a) {
|
|
387
|
+
switch (_a.label) {
|
|
388
|
+
case 0:
|
|
389
|
+
jest.restoreAllMocks();
|
|
390
|
+
return [4 /*yield*/, fs_1.default.promises.mkdtemp(path_1.default.join(os_1.default.tmpdir(), 'sasjs-single-'))];
|
|
391
|
+
case 1:
|
|
392
|
+
root = _a.sent();
|
|
393
|
+
process.sasjsConstants = {
|
|
394
|
+
buildDestinationJobsFolder: path_1.default.join(root, 'sasjsbuild', 'jobs'),
|
|
395
|
+
buildDestinationServicesFolder: path_1.default.join(root, 'sasjsbuild', 'services')
|
|
396
|
+
};
|
|
397
|
+
jest
|
|
398
|
+
.spyOn(configModule, 'getMacroFolders')
|
|
399
|
+
.mockImplementation(function () { return Promise.resolve([]); });
|
|
400
|
+
jest
|
|
401
|
+
.spyOn(configModule, 'getProgramFolders')
|
|
402
|
+
.mockImplementation(function () { return Promise.resolve([]); });
|
|
403
|
+
jest
|
|
404
|
+
.spyOn(loadDependenciesModule, 'getCompileTree')
|
|
405
|
+
.mockImplementation(function () { return ({ saveTree: function () { return Promise.resolve(); } }); });
|
|
406
|
+
jest
|
|
407
|
+
.spyOn(getAllFoldersModule, 'getAllFolders')
|
|
408
|
+
.mockImplementation(function () {
|
|
409
|
+
return Promise.resolve([path_1.default.join(root, 'sasjs', 'jobs', 'daily')]);
|
|
410
|
+
});
|
|
411
|
+
jest
|
|
412
|
+
.spyOn(compileFileModule, 'compileFile')
|
|
413
|
+
.mockImplementation(function () { return Promise.resolve(); });
|
|
414
|
+
return [2 /*return*/];
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
}); });
|
|
418
|
+
afterEach(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
419
|
+
return __generator(this, function (_a) {
|
|
420
|
+
switch (_a.label) {
|
|
421
|
+
case 0:
|
|
422
|
+
process.sasjsConstants = originalConstants;
|
|
423
|
+
return [4 /*yield*/, fs_1.default.promises.rm(root, { recursive: true, force: true })];
|
|
424
|
+
case 1:
|
|
425
|
+
_a.sent();
|
|
426
|
+
return [2 /*return*/];
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
}); });
|
|
430
|
+
it('should keep a sibling compiled file in the same leaf folder', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
431
|
+
var sourceFolder, written;
|
|
432
|
+
return __generator(this, function (_a) {
|
|
433
|
+
switch (_a.label) {
|
|
434
|
+
case 0:
|
|
435
|
+
sourceFolder = path_1.default.join(root, 'sasjs', 'jobs', 'daily');
|
|
436
|
+
return [4 /*yield*/, fs_1.default.promises.mkdir(sourceFolder, { recursive: true })];
|
|
437
|
+
case 1:
|
|
438
|
+
_a.sent();
|
|
439
|
+
return [4 /*yield*/, fs_1.default.promises.writeFile(path_1.default.join(sourceFolder, 'first.sas'), '/**\n @file first.sas\n**/\n')];
|
|
440
|
+
case 2:
|
|
441
|
+
_a.sent();
|
|
442
|
+
return [4 /*yield*/, fs_1.default.promises.writeFile(path_1.default.join(sourceFolder, 'second.sas'), '/**\n @file second.sas\n**/\n')];
|
|
443
|
+
case 3:
|
|
444
|
+
_a.sent();
|
|
445
|
+
return [4 /*yield*/, (0, compileSingleFile_1.compileSingleFile)({}, 'job', path_1.default.join(sourceFolder, 'first.sas'))];
|
|
446
|
+
case 4:
|
|
447
|
+
_a.sent();
|
|
448
|
+
return [4 /*yield*/, (0, compileSingleFile_1.compileSingleFile)({}, 'job', path_1.default.join(sourceFolder, 'second.sas'))];
|
|
449
|
+
case 5:
|
|
450
|
+
_a.sent();
|
|
451
|
+
return [4 /*yield*/, fs_1.default.promises.readdir(path_1.default.join(root, 'sasjsbuild', 'jobs', 'daily'))];
|
|
452
|
+
case 6:
|
|
453
|
+
written = _a.sent();
|
|
454
|
+
expect(written.sort()).toEqual(['first.sas', 'second.sas']);
|
|
455
|
+
return [2 /*return*/];
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
}); });
|
|
459
|
+
it('should point _program at the folder the file is written to', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
460
|
+
var compileFileSpy, sourceFile, _a;
|
|
461
|
+
return __generator(this, function (_b) {
|
|
462
|
+
switch (_b.label) {
|
|
463
|
+
case 0:
|
|
464
|
+
compileFileSpy = jest.spyOn(compileFileModule, 'compileFile');
|
|
465
|
+
sourceFile = path_1.default.join(root, 'loose.sas');
|
|
466
|
+
return [4 /*yield*/, fs_1.default.promises.writeFile(sourceFile, '/**\n @file loose.sas\n**/\n')];
|
|
467
|
+
case 1:
|
|
468
|
+
_b.sent();
|
|
469
|
+
return [4 /*yield*/, (0, compileSingleFile_1.compileSingleFile)({ appLoc: '/Public/app' }, 'job', sourceFile, undefined, true)
|
|
470
|
+
// not below a configured folder, so it lands in the type folder itself
|
|
471
|
+
];
|
|
472
|
+
case 2:
|
|
473
|
+
_b.sent();
|
|
474
|
+
// not below a configured folder, so it lands in the type folder itself
|
|
475
|
+
_a = expect;
|
|
476
|
+
return [4 /*yield*/, fs_1.default.promises.readFile(path_1.default.join(root, 'sasjsbuild', 'jobs', 'loose.sas'), 'utf8')];
|
|
477
|
+
case 3:
|
|
478
|
+
// not below a configured folder, so it lands in the type folder itself
|
|
479
|
+
_a.apply(void 0, [_b.sent()]).toBeDefined();
|
|
480
|
+
expect(compileFileSpy.mock.calls[0][4]).toContain('%let _program=/Public/app/jobs/loose;');
|
|
481
|
+
return [2 /*return*/];
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
}); });
|
|
485
|
+
});
|
|
172
486
|
});
|
|
@@ -204,6 +204,26 @@ describe('loadDependencies', function () {
|
|
|
204
204
|
}
|
|
205
205
|
});
|
|
206
206
|
}); });
|
|
207
|
+
test('it should name the file when a file header is truncated', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
208
|
+
var filePath, error;
|
|
209
|
+
return __generator(this, function (_a) {
|
|
210
|
+
switch (_a.label) {
|
|
211
|
+
case 0:
|
|
212
|
+
filePath = path_1.default.join(__dirname, './truncated-header.sas');
|
|
213
|
+
return [4 /*yield*/, (0, loadDependencies_1.loadDependencies)(target, filePath, [], [], utils_1.SASJsFileType.file, compileTree).catch(function (e) { return e; })
|
|
214
|
+
// The wording belongs to @sasjs/utils; this pins the file name the CLI adds
|
|
215
|
+
// and the shape of the diagnostic, not the library's phrasing.
|
|
216
|
+
];
|
|
217
|
+
case 1:
|
|
218
|
+
error = _a.sent();
|
|
219
|
+
// The wording belongs to @sasjs/utils; this pins the file name the CLI adds
|
|
220
|
+
// and the shape of the diagnostic, not the library's phrasing.
|
|
221
|
+
expect(error instanceof Error ? error.message : String(error)).toMatch(new RegExp("^".concat(filePath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), ": ")));
|
|
222
|
+
expect(error instanceof Error ? error.message : String(error)).toMatch(/\bline \d+/);
|
|
223
|
+
return [2 /*return*/];
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
}); });
|
|
207
227
|
test("it should load dependencies for a job ".concat(utils_1.DependencyHeader.Macro), function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
208
228
|
var dependencies;
|
|
209
229
|
return __generator(this, function (_a) {
|
|
@@ -92,9 +92,12 @@ function printHelpText() {
|
|
|
92
92
|
},
|
|
93
93
|
{
|
|
94
94
|
name: 'compile',
|
|
95
|
-
title: 'compile
|
|
95
|
+
title: 'compile [subCommand]',
|
|
96
96
|
description: [
|
|
97
|
-
"compiles the services specified in the ".concat(chalk_1.default.cyanBright('serviceFolders'), " property of the 'serviceConfig' in your target and common configuration.")
|
|
97
|
+
"compiles the services specified in the ".concat(chalk_1.default.cyanBright('serviceFolders'), " property of the 'serviceConfig' in your target and common configuration."),
|
|
98
|
+
"A single file is compiled by naming its type as a sub command - ".concat(chalk_1.default.cyanBright('job'), ", ").concat(chalk_1.default.cyanBright('service'), ", ").concat(chalk_1.default.cyanBright('test'), " or ").concat(chalk_1.default.cyanBright('identify'), ", which works the type out from the file itself - together with ").concat(chalk_1.default.cyanBright('--source'), " (or ").concat(chalk_1.default.cyanBright('-s'), ")."),
|
|
99
|
+
"The compiled file is written to the ".concat(chalk_1.default.cyanBright('jobs'), " or ").concat(chalk_1.default.cyanBright('services'), " folder of sasjsbuild for its type, or below ").concat(chalk_1.default.cyanBright('--output'), " (or ").concat(chalk_1.default.cyanBright('-o'), ") when given."),
|
|
100
|
+
"command example: sasjs compile identify --source sasjs/jobs/daily/load.sas --target myTarget"
|
|
98
101
|
]
|
|
99
102
|
},
|
|
100
103
|
{
|
|
@@ -72,7 +72,6 @@ var utils_1 = require("@sasjs/utils");
|
|
|
72
72
|
var __1 = require("../");
|
|
73
73
|
var utils_2 = require("../../utils/");
|
|
74
74
|
var axios_1 = __importDefault(require("axios"));
|
|
75
|
-
var internal_1 = require("../compile/internal");
|
|
76
75
|
var saveLog_1 = require("../../utils/saveLog");
|
|
77
76
|
var parseSourceFile_1 = require("../../utils/parseSourceFile");
|
|
78
77
|
/**
|
|
@@ -84,7 +83,7 @@ var parseSourceFile_1 = require("../../utils/parseSourceFile");
|
|
|
84
83
|
*/
|
|
85
84
|
function runSasCode(target_1, filePath_1) {
|
|
86
85
|
return __awaiter(this, arguments, void 0, function (target, filePath, compile, logFile, source) {
|
|
87
|
-
var isTempFile,
|
|
86
|
+
var isTempFile, sasFilePath, sasFileContent, linesToExecute, macroVars, macroVarStatements, _a;
|
|
88
87
|
var _b;
|
|
89
88
|
var _c;
|
|
90
89
|
if (compile === void 0) { compile = false; }
|
|
@@ -101,10 +100,8 @@ function runSasCode(target_1, filePath_1) {
|
|
|
101
100
|
case 2:
|
|
102
101
|
if (!compile) return [3 /*break*/, 5];
|
|
103
102
|
if (!/\.sas$/i.test(filePath)) return [3 /*break*/, 4];
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
sourceFolderPath = sourcefilePathParts.join(path_1.default.sep);
|
|
107
|
-
return [4 /*yield*/, (0, __1.compileSingleFile)(target, 'identify', filePath, (0, internal_1.getDestinationServicePath)(sourceFolderPath), true)];
|
|
103
|
+
;
|
|
104
|
+
return [4 /*yield*/, (0, __1.compileSingleFile)(target, 'identify', filePath, undefined, true)];
|
|
108
105
|
case 3:
|
|
109
106
|
(filePath = (_d.sent()).destinationPath);
|
|
110
107
|
(_c = process.logger) === null || _c === void 0 ? void 0 : _c.success("File Compiled and placed at: ".concat(filePath, " ."));
|
package/package.json
CHANGED
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"@sasjs/adapter": "^5.1.1",
|
|
74
|
-
"@sasjs/core": "^6.
|
|
75
|
-
"@sasjs/utils": "^4.1.
|
|
74
|
+
"@sasjs/core": "^6.1.1",
|
|
75
|
+
"@sasjs/utils": "^4.1.1",
|
|
76
76
|
"axios": "1.20.0",
|
|
77
77
|
"chalk": "4.1.2",
|
|
78
78
|
"dotenv": "18.0.8",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"@babel/preset-env": "7.29.7",
|
|
95
95
|
"@babel/preset-typescript": "7.29.7",
|
|
96
96
|
"@nogoo9/gitleaks": "8.30.1-post.2",
|
|
97
|
-
"@sasjs/lint": "^4.
|
|
97
|
+
"@sasjs/lint": "^4.4.0",
|
|
98
98
|
"@types/debug": "4.1.13",
|
|
99
99
|
"@types/find": "0.2.4",
|
|
100
100
|
"@types/jest": "30.0.0",
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
"nanoid": "3.3.18"
|
|
125
125
|
},
|
|
126
126
|
"peerDependencies": {
|
|
127
|
-
"@sasjs/lint": "^4.
|
|
127
|
+
"@sasjs/lint": "^4.4.0"
|
|
128
128
|
},
|
|
129
|
-
"version": "6.2.
|
|
129
|
+
"version": "6.2.5"
|
|
130
130
|
}
|