@sap-ux/project-access 1.15.4 → 1.16.0

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  export { FileName } from './constants';
2
- export { findAllApps, findCapProjects, findFioriArtifacts, findProjectRoot, getAppRootFromWebappPath, getAppProgrammingLanguage, getCapCustomPaths, getCapEnvironment, getCapModelAndServices, getCapProjectType, getCdsFiles, getCdsRoots, getCdsServices, getMtaPath, getNodeModulesPath, getWebappPath, isCapJavaProject, isCapNodeJsProject, loadModuleFromProject, readCapServiceMetadataEdmx, readUi5Yaml } from './project';
2
+ export { findAllApps, findCapProjects, findFioriArtifacts, findProjectRoot, getAppRootFromWebappPath, getAppProgrammingLanguage, getAppType, getCapCustomPaths, getCapEnvironment, getCapModelAndServices, getCapProjectType, getCdsFiles, getCdsRoots, getCdsServices, getMtaPath, getNodeModulesPath, getProjectType, 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.getNodeModulesPath = exports.getMtaPath = exports.getCdsServices = exports.getCdsRoots = exports.getCdsFiles = exports.getCapProjectType = exports.getCapModelAndServices = exports.getCapEnvironment = exports.getCapCustomPaths = exports.getAppProgrammingLanguage = exports.getAppRootFromWebappPath = exports.findProjectRoot = exports.findFioriArtifacts = exports.findCapProjects = exports.findAllApps = exports.FileName = void 0;
17
+ exports.getFilePaths = exports.readUi5Yaml = exports.readCapServiceMetadataEdmx = exports.loadModuleFromProject = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.getWebappPath = exports.getProjectType = exports.getNodeModulesPath = exports.getMtaPath = exports.getCdsServices = exports.getCdsRoots = exports.getCdsFiles = exports.getCapProjectType = exports.getCapModelAndServices = exports.getCapEnvironment = exports.getCapCustomPaths = exports.getAppType = exports.getAppProgrammingLanguage = exports.getAppRootFromWebappPath = exports.findProjectRoot = exports.findFioriArtifacts = exports.findCapProjects = 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");
@@ -24,6 +24,7 @@ Object.defineProperty(exports, "findFioriArtifacts", { enumerable: true, get: fu
24
24
  Object.defineProperty(exports, "findProjectRoot", { enumerable: true, get: function () { return project_1.findProjectRoot; } });
25
25
  Object.defineProperty(exports, "getAppRootFromWebappPath", { enumerable: true, get: function () { return project_1.getAppRootFromWebappPath; } });
26
26
  Object.defineProperty(exports, "getAppProgrammingLanguage", { enumerable: true, get: function () { return project_1.getAppProgrammingLanguage; } });
27
+ Object.defineProperty(exports, "getAppType", { enumerable: true, get: function () { return project_1.getAppType; } });
27
28
  Object.defineProperty(exports, "getCapCustomPaths", { enumerable: true, get: function () { return project_1.getCapCustomPaths; } });
28
29
  Object.defineProperty(exports, "getCapEnvironment", { enumerable: true, get: function () { return project_1.getCapEnvironment; } });
29
30
  Object.defineProperty(exports, "getCapModelAndServices", { enumerable: true, get: function () { return project_1.getCapModelAndServices; } });
@@ -33,6 +34,7 @@ Object.defineProperty(exports, "getCdsRoots", { enumerable: true, get: function
33
34
  Object.defineProperty(exports, "getCdsServices", { enumerable: true, get: function () { return project_1.getCdsServices; } });
34
35
  Object.defineProperty(exports, "getMtaPath", { enumerable: true, get: function () { return project_1.getMtaPath; } });
35
36
  Object.defineProperty(exports, "getNodeModulesPath", { enumerable: true, get: function () { return project_1.getNodeModulesPath; } });
37
+ Object.defineProperty(exports, "getProjectType", { enumerable: true, get: function () { return project_1.getProjectType; } });
36
38
  Object.defineProperty(exports, "getWebappPath", { enumerable: true, get: function () { return project_1.getWebappPath; } });
37
39
  Object.defineProperty(exports, "isCapJavaProject", { enumerable: true, get: function () { return project_1.isCapJavaProject; } });
38
40
  Object.defineProperty(exports, "isCapNodeJsProject", { enumerable: true, get: function () { return project_1.isCapNodeJsProject; } });
@@ -1,6 +1,6 @@
1
1
  export { getCapCustomPaths, getCapModelAndServices, getCapProjectType, getCdsFiles, getCdsRoots, getCdsServices, isCapJavaProject, isCapNodeJsProject, getCapEnvironment, readCapServiceMetadataEdmx } from './cap';
2
2
  export { getNodeModulesPath } from './dependencies';
3
- export { getAppProgrammingLanguage } from './info';
3
+ export { getAppProgrammingLanguage, getAppType, getProjectType } from './info';
4
4
  export { loadModuleFromProject } from './module-loader';
5
5
  export { findAllApps, findCapProjects, findFioriArtifacts, findProjectRoot, getAppRootFromWebappPath } from './search';
6
6
  export { getWebappPath, readUi5Yaml } from './ui5-config';
@@ -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.findCapProjects = exports.findAllApps = exports.loadModuleFromProject = exports.getAppProgrammingLanguage = exports.getNodeModulesPath = exports.readCapServiceMetadataEdmx = exports.getCapEnvironment = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.getCdsServices = exports.getCdsRoots = exports.getCdsFiles = exports.getCapProjectType = exports.getCapModelAndServices = exports.getCapCustomPaths = void 0;
3
+ exports.getMtaPath = exports.readUi5Yaml = exports.getWebappPath = exports.getAppRootFromWebappPath = exports.findProjectRoot = exports.findFioriArtifacts = exports.findCapProjects = exports.findAllApps = exports.loadModuleFromProject = exports.getProjectType = exports.getAppType = exports.getAppProgrammingLanguage = exports.getNodeModulesPath = exports.readCapServiceMetadataEdmx = exports.getCapEnvironment = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.getCdsServices = exports.getCdsRoots = exports.getCdsFiles = 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; } });
@@ -16,6 +16,8 @@ var dependencies_1 = require("./dependencies");
16
16
  Object.defineProperty(exports, "getNodeModulesPath", { enumerable: true, get: function () { return dependencies_1.getNodeModulesPath; } });
17
17
  var info_1 = require("./info");
18
18
  Object.defineProperty(exports, "getAppProgrammingLanguage", { enumerable: true, get: function () { return info_1.getAppProgrammingLanguage; } });
19
+ Object.defineProperty(exports, "getAppType", { enumerable: true, get: function () { return info_1.getAppType; } });
20
+ Object.defineProperty(exports, "getProjectType", { enumerable: true, get: function () { return info_1.getProjectType; } });
19
21
  var module_loader_1 = require("./module-loader");
20
22
  Object.defineProperty(exports, "loadModuleFromProject", { enumerable: true, get: function () { return module_loader_1.loadModuleFromProject; } });
21
23
  var search_1 = require("./search");
@@ -1,5 +1,5 @@
1
1
  import type { Editor } from 'mem-fs-editor';
2
- import type { AppProgrammingLanguage } from '../types';
2
+ import type { AppProgrammingLanguage, AppType, ProjectType } from '../types';
3
3
  /**
4
4
  * Get the used programming language of an application.
5
5
  *
@@ -8,4 +8,18 @@ import type { AppProgrammingLanguage } from '../types';
8
8
  * @returns - used language, JavaScript or TypeScript
9
9
  */
10
10
  export declare function getAppProgrammingLanguage(appRoot: string, memFs?: Editor): Promise<AppProgrammingLanguage>;
11
+ /**
12
+ * Get the type of application or Fiori artifact.
13
+ *
14
+ * @param appRoot - path to application root
15
+ * @returns - type of application, e.g. SAP Fiori elements, SAPUI5 freestyle, SAPUI5 Extension, ... see AppType.
16
+ */
17
+ export declare function getAppType(appRoot: string): Promise<AppType | undefined>;
18
+ /**
19
+ * Returns the project type for a given Fiori project.
20
+ *
21
+ * @param projectRoot - root path of the project
22
+ * @returns - project type like Edmx, CAPJava, CAPNodejs
23
+ */
24
+ export declare function getProjectType(projectRoot: string): Promise<ProjectType>;
11
25
  //# sourceMappingURL=info.d.ts.map
@@ -9,11 +9,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getAppProgrammingLanguage = void 0;
12
+ exports.getProjectType = exports.getAppType = exports.getAppProgrammingLanguage = void 0;
13
13
  const path_1 = require("path");
14
14
  const constants_1 = require("../constants");
15
15
  const file_1 = require("../file");
16
+ const cap_1 = require("./cap");
16
17
  const ui5_config_1 = require("./ui5-config");
18
+ const search_1 = require("./search");
17
19
  /**
18
20
  * Get the used programming language of an application.
19
21
  *
@@ -44,4 +46,84 @@ function getAppProgrammingLanguage(appRoot, memFs) {
44
46
  });
45
47
  }
46
48
  exports.getAppProgrammingLanguage = getAppProgrammingLanguage;
49
+ /**
50
+ * Get the type of application or Fiori artifact.
51
+ *
52
+ * @param appRoot - path to application root
53
+ * @returns - type of application, e.g. SAP Fiori elements, SAPUI5 freestyle, SAPUI5 Extension, ... see AppType.
54
+ */
55
+ function getAppType(appRoot) {
56
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
57
+ return __awaiter(this, void 0, void 0, function* () {
58
+ let appType;
59
+ try {
60
+ const artifacts = yield (0, search_1.findFioriArtifacts)({
61
+ wsFolders: [appRoot],
62
+ artifacts: ['adaptations', 'applications', 'extensions', 'libraries']
63
+ });
64
+ if (((_b = (_a = artifacts.applications) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) +
65
+ ((_d = (_c = artifacts.adaptations) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) +
66
+ ((_f = (_e = artifacts.extensions) === null || _e === void 0 ? void 0 : _e.length) !== null && _f !== void 0 ? _f : 0) +
67
+ ((_h = (_g = artifacts.libraries) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 0) ===
68
+ 1) {
69
+ if (((_j = artifacts.applications) === null || _j === void 0 ? void 0 : _j.length) === 1) {
70
+ appType = yield getApplicationType(artifacts.applications[0]);
71
+ }
72
+ else if (((_k = artifacts.adaptations) === null || _k === void 0 ? void 0 : _k.length) === 1) {
73
+ appType = 'Fiori Adaptation';
74
+ }
75
+ else if (((_l = artifacts.extensions) === null || _l === void 0 ? void 0 : _l.length) === 1) {
76
+ appType = 'SAPUI5 Extension';
77
+ }
78
+ else if (((_m = artifacts.libraries) === null || _m === void 0 ? void 0 : _m.length) === 1) {
79
+ appType = 'Fiori Reuse';
80
+ }
81
+ }
82
+ }
83
+ catch (_o) {
84
+ // If error occurs we can't determine the type and return undefined
85
+ }
86
+ return appType;
87
+ });
88
+ }
89
+ exports.getAppType = getAppType;
90
+ /**
91
+ * Get the application type from search results.
92
+ *
93
+ * @param application - application from findFioriArtifacts() results
94
+ * @returns - type of application: 'SAP Fiori elements' or 'SAPUI5 freestyle'
95
+ */
96
+ function getApplicationType(application) {
97
+ return __awaiter(this, void 0, void 0, function* () {
98
+ let appType;
99
+ const packageJson = yield (0, file_1.readJSON)((0, path_1.join)(application.projectRoot, constants_1.FileName.Package));
100
+ if (application.projectRoot === application.appRoot) {
101
+ appType = packageJson.sapux ? 'SAP Fiori elements' : 'SAPUI5 freestyle';
102
+ }
103
+ else {
104
+ appType =
105
+ Array.isArray(packageJson.sapux) &&
106
+ packageJson.sapux.find((relAppPath) => (0, path_1.join)(application.projectRoot, ...relAppPath.split(/[/\\]/)) === application.appRoot)
107
+ ? 'SAP Fiori elements'
108
+ : 'SAPUI5 freestyle';
109
+ }
110
+ return appType;
111
+ });
112
+ }
113
+ /**
114
+ * Returns the project type for a given Fiori project.
115
+ *
116
+ * @param projectRoot - root path of the project
117
+ * @returns - project type like Edmx, CAPJava, CAPNodejs
118
+ */
119
+ function getProjectType(projectRoot) {
120
+ return __awaiter(this, void 0, void 0, function* () {
121
+ const capType = yield (0, cap_1.getCapProjectType)(projectRoot);
122
+ if (capType === undefined) {
123
+ return 'EDMXBackend';
124
+ }
125
+ return capType;
126
+ });
127
+ }
128
+ exports.getProjectType = getProjectType;
47
129
  //# sourceMappingURL=info.js.map
@@ -11,9 +11,9 @@ export declare function getWebappPath(projectRoot: string, memFs?: Editor): Prom
11
11
  /**
12
12
  * Checks if UI5 config yaml file exists and returns its content.
13
13
  *
14
- * @param basePath - path to project root
14
+ * @param projectRoot - path to project root
15
15
  * @param fileName - name of yaml file to be read
16
16
  * @returns {UI5Config} UI5 config file in yaml format
17
17
  */
18
- export declare function readUi5Yaml(basePath: string, fileName: string): Promise<UI5Config>;
18
+ export declare function readUi5Yaml(projectRoot: string, fileName: string): Promise<UI5Config>;
19
19
  //# sourceMappingURL=ui5-config.d.ts.map
@@ -41,18 +41,18 @@ exports.getWebappPath = getWebappPath;
41
41
  /**
42
42
  * Checks if UI5 config yaml file exists and returns its content.
43
43
  *
44
- * @param basePath - path to project root
44
+ * @param projectRoot - path to project root
45
45
  * @param fileName - name of yaml file to be read
46
46
  * @returns {UI5Config} UI5 config file in yaml format
47
47
  */
48
- function readUi5Yaml(basePath, fileName) {
48
+ function readUi5Yaml(projectRoot, fileName) {
49
49
  return __awaiter(this, void 0, void 0, function* () {
50
- const ui5YamlPath = (0, path_1.join)(basePath, fileName);
50
+ const ui5YamlPath = (0, path_1.join)(projectRoot, fileName);
51
51
  if (yield (0, file_1.fileExists)(ui5YamlPath)) {
52
52
  const yamlString = yield (0, file_1.readFile)(ui5YamlPath);
53
53
  return yield ui5_config_1.UI5Config.newInstance(yamlString);
54
54
  }
55
- throw Error(`File '${fileName}' not found in project '${basePath}'`);
55
+ throw Error(`File '${fileName}' not found in project '${projectRoot}'`);
56
56
  });
57
57
  }
58
58
  exports.readUi5Yaml = readUi5Yaml;
@@ -1,2 +1,5 @@
1
+ import type { CapProjectType } from '../cap';
1
2
  export type AppProgrammingLanguage = 'JavaScript' | 'TypeScript' | '';
3
+ export type ProjectType = 'EDMXBackend' | CapProjectType;
4
+ export type AppType = 'SAP Fiori elements' | 'SAPUI5 freestyle' | 'SAPUI5 Extension' | 'Fiori Reuse' | 'Fiori Adaptation';
2
5
  //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap-ux/project-access",
3
- "version": "1.15.4",
3
+ "version": "1.16.0",
4
4
  "description": "Library to access SAP Fiori tools projects",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,7 +32,7 @@
32
32
  "devDependencies": {
33
33
  "@types/mem-fs": "1.1.2",
34
34
  "@types/mem-fs-editor": "7.0.1",
35
- "@ui5/manifest": "1.59.0",
35
+ "@ui5/manifest": "1.61.0",
36
36
  "vscode-uri": "3.0.7"
37
37
  },
38
38
  "scripts": {