@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
|
@@ -376,11 +376,9 @@ describe('sasjs compile single file', function () {
|
|
|
376
376
|
'-s',
|
|
377
377
|
'./jobs/extract/makedata1.sas'
|
|
378
378
|
]);
|
|
379
|
-
|
|
380
|
-
case 1:
|
|
381
|
-
output = _a.sent();
|
|
379
|
+
output = command.getOutputPath();
|
|
382
380
|
return [4 /*yield*/, expect((0, compileSingleFile_1.compileSingleFile)(target, 'job', command.source, output)).toResolve()];
|
|
383
|
-
case
|
|
381
|
+
case 1:
|
|
384
382
|
_a.sent();
|
|
385
383
|
expect(compileFile.compileFile).toHaveBeenCalled();
|
|
386
384
|
return [2 /*return*/];
|
|
@@ -400,11 +398,9 @@ describe('sasjs compile single file', function () {
|
|
|
400
398
|
'-s',
|
|
401
399
|
'./jobs/extract/makedata1.sas'
|
|
402
400
|
]);
|
|
403
|
-
|
|
404
|
-
case 1:
|
|
405
|
-
output = _a.sent();
|
|
401
|
+
output = command.getOutputPath();
|
|
406
402
|
return [4 /*yield*/, expect((0, compileSingleFile_1.compileSingleFile)(target, 'job', command.source, output)).toResolve()];
|
|
407
|
-
case
|
|
403
|
+
case 1:
|
|
408
404
|
_a.sent();
|
|
409
405
|
expect(compileFile.compileFile).toHaveBeenCalled();
|
|
410
406
|
return [2 /*return*/];
|
|
@@ -442,11 +438,9 @@ describe('sasjs compile single file', function () {
|
|
|
442
438
|
'-s',
|
|
443
439
|
'sasjs/services/common/example.sas'
|
|
444
440
|
]);
|
|
445
|
-
|
|
446
|
-
case 1:
|
|
447
|
-
output = _a.sent();
|
|
441
|
+
output = command.getOutputPath();
|
|
448
442
|
return [4 /*yield*/, expect((0, compileSingleFile_1.compileSingleFile)(target, 'service', command.source, output)).toResolve()];
|
|
449
|
-
case
|
|
443
|
+
case 1:
|
|
450
444
|
_a.sent();
|
|
451
445
|
expect(compileFile.compileFile).toHaveBeenCalled();
|
|
452
446
|
return [2 /*return*/];
|
|
@@ -466,11 +460,9 @@ describe('sasjs compile single file', function () {
|
|
|
466
460
|
'-s',
|
|
467
461
|
"".concat(process.projectDir, "/sasjs/services/common/example.sas")
|
|
468
462
|
]);
|
|
469
|
-
|
|
470
|
-
case 1:
|
|
471
|
-
output = _a.sent();
|
|
463
|
+
output = command.getOutputPath();
|
|
472
464
|
return [4 /*yield*/, expect((0, compileSingleFile_1.compileSingleFile)(target, 'service', command.source, output)).toResolve()];
|
|
473
|
-
case
|
|
465
|
+
case 1:
|
|
474
466
|
_a.sent();
|
|
475
467
|
expect(compileFile.compileFile).toHaveBeenCalled();
|
|
476
468
|
return [2 /*return*/];
|
|
@@ -598,7 +590,7 @@ describe('sasjs compile outside project', function () {
|
|
|
598
590
|
'-s',
|
|
599
591
|
'../services/example1.sas'
|
|
600
592
|
]);
|
|
601
|
-
output = command.
|
|
593
|
+
output = command.getOutputPath();
|
|
602
594
|
return [4 /*yield*/, expect((0, compileSingleFile_1.compileSingleFile)(undefined, 'service', command.source, output)).resolves.toEqual({
|
|
603
595
|
destinationPath: destinationPath
|
|
604
596
|
})];
|
|
@@ -647,19 +639,17 @@ describe('sasjs compile outside project', function () {
|
|
|
647
639
|
'-s',
|
|
648
640
|
'../services/example1.sas'
|
|
649
641
|
]);
|
|
650
|
-
|
|
651
|
-
case 2:
|
|
652
|
-
output = _a.sent();
|
|
642
|
+
output = command.getOutputPath();
|
|
653
643
|
return [4 /*yield*/, expect((0, compileSingleFile_1.compileSingleFile)(undefined, 'service', command.source, output)).resolves.toEqual({
|
|
654
644
|
destinationPath: destinationPath
|
|
655
645
|
})];
|
|
656
|
-
case
|
|
646
|
+
case 2:
|
|
657
647
|
_a.sent();
|
|
658
648
|
return [4 /*yield*/, expect((0, utils_1.fileExists)(destinationPath)).resolves.toEqual(true)];
|
|
659
|
-
case
|
|
649
|
+
case 3:
|
|
660
650
|
_a.sent();
|
|
661
651
|
return [4 /*yield*/, (0, utils_1.readFile)(destinationPath)];
|
|
662
|
-
case
|
|
652
|
+
case 4:
|
|
663
653
|
compiledContent = _a.sent();
|
|
664
654
|
macrosToTest = [
|
|
665
655
|
'mf_nobs',
|
|
@@ -667,7 +657,7 @@ describe('sasjs compile outside project', function () {
|
|
|
667
657
|
'yetanothermacro'
|
|
668
658
|
];
|
|
669
659
|
return [4 /*yield*/, (0, test_1.verifyCompiledService)(compiledContent, macrosToTest, false, false)];
|
|
670
|
-
case
|
|
660
|
+
case 5:
|
|
671
661
|
_a.sent();
|
|
672
662
|
return [2 /*return*/];
|
|
673
663
|
}
|
|
@@ -698,11 +688,9 @@ describe('sasjs compile outside project', function () {
|
|
|
698
688
|
'-s',
|
|
699
689
|
'../services/example1.sas'
|
|
700
690
|
]);
|
|
701
|
-
|
|
702
|
-
case 3:
|
|
703
|
-
output = _a.sent();
|
|
691
|
+
output = command.getOutputPath();
|
|
704
692
|
return [4 /*yield*/, expect((0, compileSingleFile_1.compileSingleFile)(undefined, 'service', command.source, output)).rejects.toEqual("Unable to locate dependencies: ".concat(dependencies.join(', ')))];
|
|
705
|
-
case
|
|
693
|
+
case 3:
|
|
706
694
|
_a.sent();
|
|
707
695
|
return [2 /*return*/];
|
|
708
696
|
}
|
|
@@ -736,19 +724,17 @@ describe('sasjs compile outside project', function () {
|
|
|
736
724
|
'-s',
|
|
737
725
|
'../services/example1.sas'
|
|
738
726
|
]);
|
|
739
|
-
|
|
740
|
-
case 4:
|
|
741
|
-
output = _a.sent();
|
|
727
|
+
output = command.getOutputPath();
|
|
742
728
|
return [4 /*yield*/, expect((0, compileSingleFile_1.compileSingleFile)(undefined, 'service', command.source, output)).resolves.toEqual({
|
|
743
729
|
destinationPath: destinationPath
|
|
744
730
|
})];
|
|
745
|
-
case
|
|
731
|
+
case 4:
|
|
746
732
|
_a.sent();
|
|
747
733
|
return [4 /*yield*/, expect((0, utils_1.fileExists)(destinationPath)).resolves.toEqual(true)];
|
|
748
|
-
case
|
|
734
|
+
case 5:
|
|
749
735
|
_a.sent();
|
|
750
736
|
return [4 /*yield*/, (0, utils_1.readFile)(destinationPath)];
|
|
751
|
-
case
|
|
737
|
+
case 6:
|
|
752
738
|
compiledContent = _a.sent();
|
|
753
739
|
macrosToTest = [
|
|
754
740
|
'mf_nobs',
|
|
@@ -756,7 +742,7 @@ describe('sasjs compile outside project', function () {
|
|
|
756
742
|
'yetanothermacro'
|
|
757
743
|
];
|
|
758
744
|
return [4 /*yield*/, (0, test_1.verifyCompiledService)(compiledContent, macrosToTest, false, false)];
|
|
759
|
-
case
|
|
745
|
+
case 7:
|
|
760
746
|
_a.sent();
|
|
761
747
|
return [2 /*return*/];
|
|
762
748
|
}
|
|
@@ -790,19 +776,17 @@ describe('sasjs compile outside project', function () {
|
|
|
790
776
|
'-s',
|
|
791
777
|
'../services/example1.sas'
|
|
792
778
|
]);
|
|
793
|
-
|
|
794
|
-
case 4:
|
|
795
|
-
output = _a.sent();
|
|
779
|
+
output = command.getOutputPath();
|
|
796
780
|
return [4 /*yield*/, expect((0, compileSingleFile_1.compileSingleFile)(undefined, 'service', command.source, output)).resolves.toEqual({
|
|
797
781
|
destinationPath: destinationPath
|
|
798
782
|
})];
|
|
799
|
-
case
|
|
783
|
+
case 4:
|
|
800
784
|
_a.sent();
|
|
801
785
|
return [4 /*yield*/, expect((0, utils_1.fileExists)(destinationPath)).resolves.toEqual(true)];
|
|
802
|
-
case
|
|
786
|
+
case 5:
|
|
803
787
|
_a.sent();
|
|
804
788
|
return [4 /*yield*/, (0, utils_1.readFile)(destinationPath)];
|
|
805
|
-
case
|
|
789
|
+
case 6:
|
|
806
790
|
compiledContent = _a.sent();
|
|
807
791
|
macrosToTest = [
|
|
808
792
|
'mf_nobs',
|
|
@@ -810,7 +794,7 @@ describe('sasjs compile outside project', function () {
|
|
|
810
794
|
'yetanothermacro'
|
|
811
795
|
];
|
|
812
796
|
return [4 /*yield*/, (0, test_1.verifyCompiledService)(compiledContent, macrosToTest, false, false)];
|
|
813
|
-
case
|
|
797
|
+
case 7:
|
|
814
798
|
_a.sent();
|
|
815
799
|
return [2 /*return*/];
|
|
816
800
|
}
|
|
@@ -863,11 +847,9 @@ describe('sasjs compile outside project', function () {
|
|
|
863
847
|
'-s',
|
|
864
848
|
'../services/example1.sas'
|
|
865
849
|
]);
|
|
866
|
-
|
|
867
|
-
case 1:
|
|
868
|
-
output = _a.sent();
|
|
850
|
+
output = command.getOutputPath();
|
|
869
851
|
return [4 /*yield*/, expect((0, compileSingleFile_1.compileSingleFile)(undefined, 'service', command.source, output)).rejects.toEqual("Unable to locate dependencies: ".concat(dependencies.join(', ')))];
|
|
870
|
-
case
|
|
852
|
+
case 1:
|
|
871
853
|
_a.sent();
|
|
872
854
|
return [2 /*return*/];
|
|
873
855
|
}
|
|
@@ -101,6 +101,8 @@ var path_1 = __importDefault(require("path"));
|
|
|
101
101
|
var os_1 = __importDefault(require("os"));
|
|
102
102
|
var compileModule = __importStar(require("../compile"));
|
|
103
103
|
var compileSingleFileModule = __importStar(require("../compileSingleFile"));
|
|
104
|
+
var identifySasFileModule = __importStar(require("../internal/identifySasFile"));
|
|
105
|
+
var internal_1 = require("../internal");
|
|
104
106
|
var compileCommand_1 = require("../compileCommand");
|
|
105
107
|
var utils_1 = require("@sasjs/utils");
|
|
106
108
|
var utils_2 = require("../../../utils");
|
|
@@ -334,7 +336,7 @@ describe('CompileCommand', function () {
|
|
|
334
336
|
expectedTarget[key] = target[key];
|
|
335
337
|
});
|
|
336
338
|
delete expectedTarget.getConfig;
|
|
337
|
-
expect(compileSingleFileModule.compileSingleFile).toHaveBeenCalledWith(expect.objectContaining(expectedTarget), 'job', path_1.default.join(os_1.default.homedir(), 'test.sas'),
|
|
339
|
+
expect(compileSingleFileModule.compileSingleFile).toHaveBeenCalledWith(expect.objectContaining(expectedTarget), 'job', path_1.default.join(os_1.default.homedir(), 'test.sas'), undefined);
|
|
338
340
|
return [2 /*return*/];
|
|
339
341
|
}
|
|
340
342
|
});
|
|
@@ -388,7 +390,7 @@ describe('CompileCommand', function () {
|
|
|
388
390
|
}
|
|
389
391
|
});
|
|
390
392
|
}); });
|
|
391
|
-
it('should return the output
|
|
393
|
+
it('should return the output base for a job when specified', function () {
|
|
392
394
|
var args = __spreadArray(__spreadArray([], __read(defaultArgs), false), [
|
|
393
395
|
'compile',
|
|
394
396
|
'job',
|
|
@@ -400,10 +402,11 @@ describe('CompileCommand', function () {
|
|
|
400
402
|
os_1.default.homedir()
|
|
401
403
|
], false);
|
|
402
404
|
var command = new compileCommand_1.CompileCommand(args);
|
|
403
|
-
|
|
404
|
-
|
|
405
|
+
// the base only - the type folder and the file's own path are added by
|
|
406
|
+
// compileSingleFile
|
|
407
|
+
expect(command.getOutputPath()).toEqual(os_1.default.homedir());
|
|
405
408
|
});
|
|
406
|
-
it('should return the output
|
|
409
|
+
it('should return the output base for a service when specified', function () {
|
|
407
410
|
var args = __spreadArray(__spreadArray([], __read(defaultArgs), false), [
|
|
408
411
|
'compile',
|
|
409
412
|
'service',
|
|
@@ -415,10 +418,9 @@ describe('CompileCommand', function () {
|
|
|
415
418
|
os_1.default.homedir()
|
|
416
419
|
], false);
|
|
417
420
|
var command = new compileCommand_1.CompileCommand(args);
|
|
418
|
-
|
|
419
|
-
expect(output).toEqual(path_1.default.join(os_1.default.homedir(), 'services'));
|
|
421
|
+
expect(command.getOutputPath()).toEqual(os_1.default.homedir());
|
|
420
422
|
});
|
|
421
|
-
it('should
|
|
423
|
+
it('should leave the destination to the compile when not specified', function () {
|
|
422
424
|
var args = __spreadArray(__spreadArray([], __read(defaultArgs), false), [
|
|
423
425
|
'compile',
|
|
424
426
|
'job',
|
|
@@ -427,12 +429,11 @@ describe('CompileCommand', function () {
|
|
|
427
429
|
'-s',
|
|
428
430
|
'/dev/test.sas'
|
|
429
431
|
], false);
|
|
430
|
-
var buildDestinationJobsFolder = process.sasjsConstants.buildDestinationJobsFolder;
|
|
431
432
|
var command = new compileCommand_1.CompileCommand(args);
|
|
432
|
-
|
|
433
|
-
expect(
|
|
433
|
+
// the default for the type lives in compileSingleFile, not here
|
|
434
|
+
expect(command.getOutputPath()).toBeUndefined();
|
|
434
435
|
});
|
|
435
|
-
it('should
|
|
436
|
+
it('should leave the destination to the compile for a service too', function () {
|
|
436
437
|
var args = __spreadArray(__spreadArray([], __read(defaultArgs), false), [
|
|
437
438
|
'compile',
|
|
438
439
|
'service',
|
|
@@ -441,11 +442,64 @@ describe('CompileCommand', function () {
|
|
|
441
442
|
'-s',
|
|
442
443
|
'/dev/test.sas'
|
|
443
444
|
], false);
|
|
444
|
-
var buildDestinationServicesFolder = process.sasjsConstants.buildDestinationServicesFolder;
|
|
445
445
|
var command = new compileCommand_1.CompileCommand(args);
|
|
446
|
-
|
|
447
|
-
expect(output).toEqual(path_1.default.join(buildDestinationServicesFolder, 'dev'));
|
|
446
|
+
expect(command.getOutputPath()).toBeUndefined();
|
|
448
447
|
});
|
|
448
|
+
it('should pass identify through for a job source', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
449
|
+
var args, command;
|
|
450
|
+
return __generator(this, function (_a) {
|
|
451
|
+
switch (_a.label) {
|
|
452
|
+
case 0:
|
|
453
|
+
jest
|
|
454
|
+
.spyOn(identifySasFileModule, 'identifySasFile')
|
|
455
|
+
.mockImplementation(function () { return Promise.resolve(internal_1.SasFileType.Job); });
|
|
456
|
+
args = __spreadArray(__spreadArray([], __read(defaultArgs), false), [
|
|
457
|
+
'compile',
|
|
458
|
+
'identify',
|
|
459
|
+
'-t',
|
|
460
|
+
'test',
|
|
461
|
+
'-s',
|
|
462
|
+
'/dev/test.sas'
|
|
463
|
+
], false);
|
|
464
|
+
command = new compileCommand_1.CompileCommand(args);
|
|
465
|
+
return [4 /*yield*/, command.execute()
|
|
466
|
+
// the type is left to compileSingleFile, which is the only place that
|
|
467
|
+
// resolves 'identify'
|
|
468
|
+
];
|
|
469
|
+
case 1:
|
|
470
|
+
_a.sent();
|
|
471
|
+
// the type is left to compileSingleFile, which is the only place that
|
|
472
|
+
// resolves 'identify'
|
|
473
|
+
expect(compileSingleFileModule.compileSingleFile).toHaveBeenCalledWith(expect.anything(), 'identify', '/dev/test.sas', undefined);
|
|
474
|
+
return [2 /*return*/];
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
}); });
|
|
478
|
+
it('should pass identify through for a service source', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
479
|
+
var args, command;
|
|
480
|
+
return __generator(this, function (_a) {
|
|
481
|
+
switch (_a.label) {
|
|
482
|
+
case 0:
|
|
483
|
+
jest
|
|
484
|
+
.spyOn(identifySasFileModule, 'identifySasFile')
|
|
485
|
+
.mockImplementation(function () { return Promise.resolve(internal_1.SasFileType.Service); });
|
|
486
|
+
args = __spreadArray(__spreadArray([], __read(defaultArgs), false), [
|
|
487
|
+
'compile',
|
|
488
|
+
'identify',
|
|
489
|
+
'-t',
|
|
490
|
+
'test',
|
|
491
|
+
'-s',
|
|
492
|
+
'/dev/test.sas'
|
|
493
|
+
], false);
|
|
494
|
+
command = new compileCommand_1.CompileCommand(args);
|
|
495
|
+
return [4 /*yield*/, command.execute()];
|
|
496
|
+
case 1:
|
|
497
|
+
_a.sent();
|
|
498
|
+
expect(compileSingleFileModule.compileSingleFile).toHaveBeenCalledWith(expect.anything(), 'identify', '/dev/test.sas', undefined);
|
|
499
|
+
return [2 /*return*/];
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
}); });
|
|
449
503
|
});
|
|
450
504
|
var setupMocks = function () {
|
|
451
505
|
jest.resetAllMocks();
|