@sap-ux/project-access 1.11.0 → 1.11.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.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/project/dependencies.d.ts +10 -0
- package/dist/project/dependencies.js +34 -1
- package/dist/project/index.d.ts +1 -0
- package/dist/project/index.js +3 -1
- package/dist/project/module-loader.d.ts +7 -1
- package/dist/project/module-loader.js +12 -2
- package/dist/project/mta.d.ts +3 -3
- package/dist/project/mta.js +3 -3
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { FileName } from './constants';
|
|
2
|
-
export { findAllApps, findFioriArtifacts, findProjectRoot, getAppRootFromWebappPath, getAppProgrammingLanguage, getCapCustomPaths, getCapEnvironment, getCapModelAndServices, getCapProjectType, getMtaPath, getWebappPath, isCapJavaProject, isCapNodeJsProject, loadModuleFromProject, readCapServiceMetadataEdmx, readUi5Yaml } from './project';
|
|
2
|
+
export { findAllApps, findFioriArtifacts, findProjectRoot, getAppRootFromWebappPath, getAppProgrammingLanguage, getCapCustomPaths, getCapEnvironment, getCapModelAndServices, getCapProjectType, getMtaPath, getNodeModulesPath, getWebappPath, isCapJavaProject, isCapNodeJsProject, loadModuleFromProject, readCapServiceMetadataEdmx, readUi5Yaml } from './project';
|
|
3
3
|
export { getFilePaths } from './file';
|
|
4
4
|
export * from './types';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.getFilePaths = exports.readUi5Yaml = exports.readCapServiceMetadataEdmx = exports.loadModuleFromProject = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.getWebappPath = exports.getMtaPath = exports.getCapProjectType = exports.getCapModelAndServices = exports.getCapEnvironment = exports.getCapCustomPaths = exports.getAppProgrammingLanguage = exports.getAppRootFromWebappPath = exports.findProjectRoot = exports.findFioriArtifacts = exports.findAllApps = exports.FileName = void 0;
|
|
17
|
+
exports.getFilePaths = exports.readUi5Yaml = exports.readCapServiceMetadataEdmx = exports.loadModuleFromProject = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.getWebappPath = exports.getNodeModulesPath = exports.getMtaPath = exports.getCapProjectType = exports.getCapModelAndServices = exports.getCapEnvironment = exports.getCapCustomPaths = exports.getAppProgrammingLanguage = exports.getAppRootFromWebappPath = exports.findProjectRoot = exports.findFioriArtifacts = exports.findAllApps = exports.FileName = void 0;
|
|
18
18
|
var constants_1 = require("./constants");
|
|
19
19
|
Object.defineProperty(exports, "FileName", { enumerable: true, get: function () { return constants_1.FileName; } });
|
|
20
20
|
var project_1 = require("./project");
|
|
@@ -28,6 +28,7 @@ Object.defineProperty(exports, "getCapEnvironment", { enumerable: true, get: fun
|
|
|
28
28
|
Object.defineProperty(exports, "getCapModelAndServices", { enumerable: true, get: function () { return project_1.getCapModelAndServices; } });
|
|
29
29
|
Object.defineProperty(exports, "getCapProjectType", { enumerable: true, get: function () { return project_1.getCapProjectType; } });
|
|
30
30
|
Object.defineProperty(exports, "getMtaPath", { enumerable: true, get: function () { return project_1.getMtaPath; } });
|
|
31
|
+
Object.defineProperty(exports, "getNodeModulesPath", { enumerable: true, get: function () { return project_1.getNodeModulesPath; } });
|
|
31
32
|
Object.defineProperty(exports, "getWebappPath", { enumerable: true, get: function () { return project_1.getWebappPath; } });
|
|
32
33
|
Object.defineProperty(exports, "isCapJavaProject", { enumerable: true, get: function () { return project_1.isCapJavaProject; } });
|
|
33
34
|
Object.defineProperty(exports, "isCapNodeJsProject", { enumerable: true, get: function () { return project_1.isCapNodeJsProject; } });
|
|
@@ -7,4 +7,14 @@ import type { Package } from '../types';
|
|
|
7
7
|
* @returns - true: has dependency; false: no dependency
|
|
8
8
|
*/
|
|
9
9
|
export declare const hasDependency: (packageJson: Package, dependency: string) => boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Returns path to folder that hosts 'node_modules' used by project.
|
|
12
|
+
* Optionally, a module name can be passed to check for. This is
|
|
13
|
+
* useful to check if a module is hoisted in a mono repository.
|
|
14
|
+
*
|
|
15
|
+
* @param projectRoot - absolute path to root of the project/app.
|
|
16
|
+
* @param [module] - optional module name to find in node_modules
|
|
17
|
+
* @returns - parent path of node_modules used by project or undefined if node module path was not found
|
|
18
|
+
*/
|
|
19
|
+
export declare function getNodeModulesPath(projectRoot: string, module?: string): string | undefined;
|
|
10
20
|
//# sourceMappingURL=dependencies.d.ts.map
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasDependency = void 0;
|
|
3
|
+
exports.getNodeModulesPath = exports.hasDependency = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const constants_1 = require("../constants");
|
|
4
7
|
/**
|
|
5
8
|
* Helper to check for dependency/devDependency.
|
|
6
9
|
*
|
|
@@ -10,4 +13,34 @@ exports.hasDependency = void 0;
|
|
|
10
13
|
*/
|
|
11
14
|
const hasDependency = (packageJson, dependency) => { var _a, _b; return !!(((_a = packageJson.dependencies) === null || _a === void 0 ? void 0 : _a[dependency]) || ((_b = packageJson.devDependencies) === null || _b === void 0 ? void 0 : _b[dependency])); };
|
|
12
15
|
exports.hasDependency = hasDependency;
|
|
16
|
+
/**
|
|
17
|
+
* Returns path to folder that hosts 'node_modules' used by project.
|
|
18
|
+
* Optionally, a module name can be passed to check for. This is
|
|
19
|
+
* useful to check if a module is hoisted in a mono repository.
|
|
20
|
+
*
|
|
21
|
+
* @param projectRoot - absolute path to root of the project/app.
|
|
22
|
+
* @param [module] - optional module name to find in node_modules
|
|
23
|
+
* @returns - parent path of node_modules used by project or undefined if node module path was not found
|
|
24
|
+
*/
|
|
25
|
+
function getNodeModulesPath(projectRoot, module) {
|
|
26
|
+
if (!(0, path_1.isAbsolute)(projectRoot)) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
const { root } = (0, path_1.parse)(projectRoot);
|
|
30
|
+
let currentDir = projectRoot;
|
|
31
|
+
let modulesPath;
|
|
32
|
+
while (currentDir !== root) {
|
|
33
|
+
let checkPath = (0, path_1.join)(currentDir, 'node_modules');
|
|
34
|
+
if (module) {
|
|
35
|
+
checkPath = (0, path_1.join)(checkPath, module, constants_1.FileName.Package);
|
|
36
|
+
}
|
|
37
|
+
if ((0, fs_1.existsSync)(checkPath)) {
|
|
38
|
+
modulesPath = currentDir;
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
currentDir = (0, path_1.dirname)(currentDir);
|
|
42
|
+
}
|
|
43
|
+
return modulesPath;
|
|
44
|
+
}
|
|
45
|
+
exports.getNodeModulesPath = getNodeModulesPath;
|
|
13
46
|
//# sourceMappingURL=dependencies.js.map
|
package/dist/project/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { getCapCustomPaths, getCapModelAndServices, getCapProjectType, isCapJavaProject, isCapNodeJsProject, getCapEnvironment, readCapServiceMetadataEdmx } from './cap';
|
|
2
|
+
export { getNodeModulesPath } from './dependencies';
|
|
2
3
|
export { getAppProgrammingLanguage } from './info';
|
|
3
4
|
export { loadModuleFromProject } from './module-loader';
|
|
4
5
|
export { findAllApps, findFioriArtifacts, findProjectRoot, getAppRootFromWebappPath } from './search';
|
package/dist/project/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getMtaPath = exports.readUi5Yaml = exports.getWebappPath = exports.getAppRootFromWebappPath = exports.findProjectRoot = exports.findFioriArtifacts = exports.findAllApps = exports.loadModuleFromProject = exports.getAppProgrammingLanguage = exports.readCapServiceMetadataEdmx = exports.getCapEnvironment = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.getCapProjectType = exports.getCapModelAndServices = exports.getCapCustomPaths = void 0;
|
|
3
|
+
exports.getMtaPath = exports.readUi5Yaml = exports.getWebappPath = exports.getAppRootFromWebappPath = exports.findProjectRoot = exports.findFioriArtifacts = exports.findAllApps = exports.loadModuleFromProject = exports.getAppProgrammingLanguage = exports.getNodeModulesPath = exports.readCapServiceMetadataEdmx = exports.getCapEnvironment = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.getCapProjectType = exports.getCapModelAndServices = exports.getCapCustomPaths = void 0;
|
|
4
4
|
var cap_1 = require("./cap");
|
|
5
5
|
Object.defineProperty(exports, "getCapCustomPaths", { enumerable: true, get: function () { return cap_1.getCapCustomPaths; } });
|
|
6
6
|
Object.defineProperty(exports, "getCapModelAndServices", { enumerable: true, get: function () { return cap_1.getCapModelAndServices; } });
|
|
@@ -9,6 +9,8 @@ Object.defineProperty(exports, "isCapJavaProject", { enumerable: true, get: func
|
|
|
9
9
|
Object.defineProperty(exports, "isCapNodeJsProject", { enumerable: true, get: function () { return cap_1.isCapNodeJsProject; } });
|
|
10
10
|
Object.defineProperty(exports, "getCapEnvironment", { enumerable: true, get: function () { return cap_1.getCapEnvironment; } });
|
|
11
11
|
Object.defineProperty(exports, "readCapServiceMetadataEdmx", { enumerable: true, get: function () { return cap_1.readCapServiceMetadataEdmx; } });
|
|
12
|
+
var dependencies_1 = require("./dependencies");
|
|
13
|
+
Object.defineProperty(exports, "getNodeModulesPath", { enumerable: true, get: function () { return dependencies_1.getNodeModulesPath; } });
|
|
12
14
|
var info_1 = require("./info");
|
|
13
15
|
Object.defineProperty(exports, "getAppProgrammingLanguage", { enumerable: true, get: function () { return info_1.getAppProgrammingLanguage; } });
|
|
14
16
|
var module_loader_1 = require("./module-loader");
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Load module from project or app. Throws error if module is not installed.
|
|
3
3
|
*
|
|
4
|
+
* Note: Node's require.resolve() caches file access results in internal statCache, see:
|
|
5
|
+
* (https://github.com/nodejs/node/blob/d150316a8ecad1a9c20615ae62fcaf4f8d060dcc/lib/internal/modules/cjs/loader.js#L155)
|
|
6
|
+
* This means, if a module is not installed and require.resolve() is executed, it will never resolve, even after the
|
|
7
|
+
* module is installed later on. To prevent filling cjs loader's statCache with entries for non existing files,
|
|
8
|
+
* we check if the module exists using getNodeModulesPath() before require.resolve().
|
|
9
|
+
*
|
|
4
10
|
* @param projectRoot - root path of the project/app.
|
|
5
|
-
* @param moduleName - name of the
|
|
11
|
+
* @param moduleName - name of the node module.
|
|
6
12
|
* @returns - loaded module.
|
|
7
13
|
*/
|
|
8
14
|
export declare function loadModuleFromProject<T>(projectRoot: string, moduleName: string): Promise<T>;
|
|
@@ -33,11 +33,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
33
33
|
};
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
35
|
exports.loadModuleFromProject = void 0;
|
|
36
|
+
const dependencies_1 = require("./dependencies");
|
|
36
37
|
/**
|
|
37
38
|
* Load module from project or app. Throws error if module is not installed.
|
|
38
39
|
*
|
|
40
|
+
* Note: Node's require.resolve() caches file access results in internal statCache, see:
|
|
41
|
+
* (https://github.com/nodejs/node/blob/d150316a8ecad1a9c20615ae62fcaf4f8d060dcc/lib/internal/modules/cjs/loader.js#L155)
|
|
42
|
+
* This means, if a module is not installed and require.resolve() is executed, it will never resolve, even after the
|
|
43
|
+
* module is installed later on. To prevent filling cjs loader's statCache with entries for non existing files,
|
|
44
|
+
* we check if the module exists using getNodeModulesPath() before require.resolve().
|
|
45
|
+
*
|
|
39
46
|
* @param projectRoot - root path of the project/app.
|
|
40
|
-
* @param moduleName - name of the
|
|
47
|
+
* @param moduleName - name of the node module.
|
|
41
48
|
* @returns - loaded module.
|
|
42
49
|
*/
|
|
43
50
|
function loadModuleFromProject(projectRoot, moduleName) {
|
|
@@ -45,11 +52,14 @@ function loadModuleFromProject(projectRoot, moduleName) {
|
|
|
45
52
|
var _a;
|
|
46
53
|
let module;
|
|
47
54
|
try {
|
|
55
|
+
if (!(0, dependencies_1.getNodeModulesPath)(projectRoot, moduleName)) {
|
|
56
|
+
throw Error('Path to module not found.');
|
|
57
|
+
}
|
|
48
58
|
const modulePath = require.resolve(moduleName, { paths: [projectRoot] });
|
|
49
59
|
module = (yield (_a = modulePath, Promise.resolve().then(() => __importStar(require(_a)))));
|
|
50
60
|
}
|
|
51
61
|
catch (error) {
|
|
52
|
-
throw Error(`Module '${moduleName}' not installed in project '${projectRoot}'`);
|
|
62
|
+
throw Error(`Module '${moduleName}' not installed in project '${projectRoot}'.\n${error.toString()}`);
|
|
53
63
|
}
|
|
54
64
|
return module;
|
|
55
65
|
});
|
package/dist/project/mta.d.ts
CHANGED
|
@@ -7,9 +7,9 @@ import type { MtaPath } from '../types/mta';
|
|
|
7
7
|
* a parent root folder for MTA project, and this project itself is configured
|
|
8
8
|
* to have deploy target CF and user answered yes to "add to Managed App Router" question.
|
|
9
9
|
*
|
|
10
|
-
* @param projectPath Fiori app root folder
|
|
11
|
-
* @param fs
|
|
12
|
-
* @returns MtaPath
|
|
10
|
+
* @param projectPath - Fiori app root folder
|
|
11
|
+
* @param fs - optional mem-fs-editor instance
|
|
12
|
+
* @returns - MtaPath
|
|
13
13
|
*/
|
|
14
14
|
export declare function getMtaPath(projectPath: string, fs?: Editor): Promise<MtaPath | undefined>;
|
|
15
15
|
//# sourceMappingURL=mta.d.ts.map
|
package/dist/project/mta.js
CHANGED
|
@@ -20,9 +20,9 @@ const path_1 = require("path");
|
|
|
20
20
|
* a parent root folder for MTA project, and this project itself is configured
|
|
21
21
|
* to have deploy target CF and user answered yes to "add to Managed App Router" question.
|
|
22
22
|
*
|
|
23
|
-
* @param projectPath Fiori app root folder
|
|
24
|
-
* @param fs
|
|
25
|
-
* @returns MtaPath
|
|
23
|
+
* @param projectPath - Fiori app root folder
|
|
24
|
+
* @param fs - optional mem-fs-editor instance
|
|
25
|
+
* @returns - MtaPath
|
|
26
26
|
*/
|
|
27
27
|
function getMtaPath(projectPath, fs) {
|
|
28
28
|
return __awaiter(this, void 0, void 0, function* () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/project-access",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.2",
|
|
4
4
|
"description": "Library to access SAP Fiori tools projects",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"findit2": "2.2.3",
|
|
28
28
|
"mem-fs": "2.1.0",
|
|
29
29
|
"mem-fs-editor": "9.4.0",
|
|
30
|
-
"@sap-ux/ui5-config": "0.
|
|
30
|
+
"@sap-ux/ui5-config": "0.19.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/mem-fs": "1.1.2",
|