@sasjs/cli 3.13.1 → 3.13.2
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.
|
@@ -69,7 +69,7 @@ var setConstants = function () { return __awaiter(void 0, void 0, void 0, functi
|
|
|
69
69
|
buildDestinationJobsFolder = path_1.default.join(buildDestinationFolder, 'jobs');
|
|
70
70
|
buildDestinationDbFolder = path_1.default.join(buildDestinationFolder, 'db');
|
|
71
71
|
buildDestinationDocsFolder = path_1.default.join(buildDestinationFolder, 'docs');
|
|
72
|
-
return [4 /*yield*/, (0, utils_1.
|
|
72
|
+
return [4 /*yield*/, (0, utils_1.getNodeModulePath)('@sasjs/core')];
|
|
73
73
|
case 2:
|
|
74
74
|
macroCorePath = _d.sent();
|
|
75
75
|
buildDestinationResultsFolder = (0, utils_2.getAbsolutePath)(buildResultsFolder, isLocal ? process.projectDir : homeDir);
|
|
@@ -78,7 +78,37 @@ describe('setConstants', function () {
|
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
80
|
}); });
|
|
81
|
-
test('should set constants inside appFolder', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
81
|
+
test('should set constants inside appFolder when @sasjs/core dependency is present', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
82
|
+
var appFolder, hasSasjsCore;
|
|
83
|
+
return __generator(this, function (_a) {
|
|
84
|
+
switch (_a.label) {
|
|
85
|
+
case 0:
|
|
86
|
+
appFolder = ['some', 'app', 'folder'].join(path_1.default.sep);
|
|
87
|
+
process.projectDir = appFolder;
|
|
88
|
+
jest
|
|
89
|
+
.spyOn(configUtils, 'getLocalOrGlobalConfig')
|
|
90
|
+
.mockImplementation(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
91
|
+
return __generator(this, function (_a) {
|
|
92
|
+
return [2 /*return*/, Promise.resolve({
|
|
93
|
+
configuration: config,
|
|
94
|
+
isLocal: true
|
|
95
|
+
})];
|
|
96
|
+
});
|
|
97
|
+
}); });
|
|
98
|
+
jest.spyOn(process, 'cwd').mockImplementation(function () { return appFolder; });
|
|
99
|
+
hasSasjsCore = true;
|
|
100
|
+
jest
|
|
101
|
+
.spyOn(fileModule, 'folderExists')
|
|
102
|
+
.mockImplementation(function (path) { return Promise.resolve(hasSasjsCore); });
|
|
103
|
+
return [4 /*yield*/, (0, setConstants_1.setConstants)()];
|
|
104
|
+
case 1:
|
|
105
|
+
_a.sent();
|
|
106
|
+
verifySasjsConstants(process.projectDir, hasSasjsCore);
|
|
107
|
+
return [2 /*return*/];
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}); });
|
|
111
|
+
test('should set constants inside appFolder when @sasjs/core dependency is not present', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
82
112
|
var appFolder;
|
|
83
113
|
return __generator(this, function (_a) {
|
|
84
114
|
switch (_a.label) {
|
|
@@ -98,7 +128,9 @@ describe('setConstants', function () {
|
|
|
98
128
|
jest.spyOn(process, 'cwd').mockImplementation(function () { return appFolder; });
|
|
99
129
|
jest
|
|
100
130
|
.spyOn(fileModule, 'folderExists')
|
|
101
|
-
.mockImplementation(function () {
|
|
131
|
+
.mockImplementation(function (folderPath) {
|
|
132
|
+
return Promise.resolve(folderPath !== path_1.default.join(appFolder, 'node_modules', '@sasjs', 'core'));
|
|
133
|
+
});
|
|
102
134
|
return [4 /*yield*/, (0, setConstants_1.setConstants)()];
|
|
103
135
|
case 1:
|
|
104
136
|
_a.sent();
|
|
@@ -130,7 +162,8 @@ describe('setConstants', function () {
|
|
|
130
162
|
});
|
|
131
163
|
}); });
|
|
132
164
|
});
|
|
133
|
-
var verifySasjsConstants = function (appFolder) {
|
|
165
|
+
var verifySasjsConstants = function (appFolder, hasSasjsCore) {
|
|
166
|
+
if (hasSasjsCore === void 0) { hasSasjsCore = false; }
|
|
134
167
|
var prefixAppFolder = appFolder !== null && appFolder !== void 0 ? appFolder : require('os').homedir();
|
|
135
168
|
var sasjsConstants = process.sasjsConstants;
|
|
136
169
|
expect(sasjsConstants.buildSourceFolder).toEqual(prefixAppFolder);
|
|
@@ -143,7 +176,9 @@ var verifySasjsConstants = function (appFolder) {
|
|
|
143
176
|
expect(sasjsConstants.buildDestinationResultsFolder).toEqual([prefixAppFolder, 'sasjsresults'].join(path_1.default.sep));
|
|
144
177
|
expect(sasjsConstants.buildDestinationResultsLogsFolder).toEqual([prefixAppFolder, 'sasjsresults', 'logs'].join(path_1.default.sep));
|
|
145
178
|
expect(sasjsConstants.buildDestinationTestFolder).toEqual([prefixAppFolder, 'sasjsbuild', 'tests'].join(path_1.default.sep));
|
|
146
|
-
var corePath =
|
|
179
|
+
var corePath = hasSasjsCore
|
|
180
|
+
? 'core'
|
|
181
|
+
: path_1.default.join('cli', 'node_modules', '@sasjs', 'core');
|
|
147
182
|
if (appFolder) {
|
|
148
183
|
expect(sasjsConstants.macroCorePath).toEqual(path_1.default.join(prefixAppFolder, 'node_modules', '@sasjs', corePath));
|
|
149
184
|
}
|
package/build/utils/utils.d.ts
CHANGED
|
@@ -43,4 +43,4 @@ export declare const terminateProcess: (status: number) => never;
|
|
|
43
43
|
* @returns boolean
|
|
44
44
|
*/
|
|
45
45
|
export declare const isSASjsProject: () => Promise<boolean>;
|
|
46
|
-
export declare const
|
|
46
|
+
export declare const getNodeModulePath: (module: string) => Promise<string>;
|
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.
|
|
89
|
+
exports.getNodeModulePath = 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"));
|
|
@@ -605,24 +605,36 @@ var isSASjsProject = function () { return __awaiter(void 0, void 0, void 0, func
|
|
|
605
605
|
});
|
|
606
606
|
}); };
|
|
607
607
|
exports.isSASjsProject = isSASjsProject;
|
|
608
|
-
var
|
|
609
|
-
var cliDepsPath,
|
|
608
|
+
var getNodeModulePath = function (module) { return __awaiter(void 0, void 0, void 0, function () {
|
|
609
|
+
var projectPath, cliDepsPath, cliLocalPath, cliGlobalPath;
|
|
610
610
|
return __generator(this, function (_a) {
|
|
611
611
|
switch (_a.label) {
|
|
612
612
|
case 0:
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
return [4 /*yield*/, (0, utils_1.folderExists)(localPath)];
|
|
613
|
+
projectPath = path_1.default.join(process.cwd(), 'node_modules', module);
|
|
614
|
+
return [4 /*yield*/, (0, utils_1.folderExists)(projectPath)];
|
|
616
615
|
case 1:
|
|
617
616
|
if (_a.sent())
|
|
618
|
-
return [2 /*return*/,
|
|
619
|
-
|
|
620
|
-
|
|
617
|
+
return [2 /*return*/, projectPath
|
|
618
|
+
// Check if module is present in @sasjs/cli located in project's dependencies
|
|
619
|
+
];
|
|
620
|
+
cliDepsPath = path_1.default.join('@sasjs', 'cli', 'node_modules');
|
|
621
|
+
cliLocalPath = path_1.default.join(process.cwd(), 'node_modules', cliDepsPath, module);
|
|
622
|
+
return [4 /*yield*/, (0, utils_1.folderExists)(cliLocalPath)];
|
|
621
623
|
case 2:
|
|
622
624
|
if (_a.sent())
|
|
623
|
-
return [2 /*return*/,
|
|
625
|
+
return [2 /*return*/, cliLocalPath
|
|
626
|
+
// Check if module is present in global @sasjs/cli
|
|
627
|
+
];
|
|
628
|
+
cliGlobalPath = path_1.default.join(shelljs_1.default.exec("npm root -g", { silent: true }).stdout.replace(/\n/, ''), cliDepsPath, module);
|
|
629
|
+
return [4 /*yield*/, (0, utils_1.folderExists)(cliGlobalPath)];
|
|
630
|
+
case 3:
|
|
631
|
+
if (_a.sent())
|
|
632
|
+
return [2 /*return*/, cliGlobalPath
|
|
633
|
+
// Return default value
|
|
634
|
+
];
|
|
635
|
+
// Return default value
|
|
624
636
|
return [2 /*return*/, ''];
|
|
625
637
|
}
|
|
626
638
|
});
|
|
627
639
|
}); };
|
|
628
|
-
exports.
|
|
640
|
+
exports.getNodeModulePath = getNodeModulePath;
|
package/package.json
CHANGED