@sap-ux/project-access 1.20.3 → 1.21.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,6 +1,6 @@
1
1
  export { FileName, DirName, FioriToolsSettings } from './constants';
2
2
  export { getFilePaths } from './file';
3
- export { createApplicationAccess, createProjectAccess, findAllApps, findCapProjects, findFioriArtifacts, findProjectRoot, getAppRootFromWebappPath, getAppProgrammingLanguage, getAppType, getCapCustomPaths, getCapEnvironment, getCapModelAndServices, getCapProjectType, getCdsFiles, getCdsRoots, getCdsServices, getCapI18nFolderNames, getI18nPropertiesPaths, getMtaPath, getNodeModulesPath, getProject, getProjectType, getWebappPath, isCapProject, isCapJavaProject, isCapNodeJsProject, loadModuleFromProject, readCapServiceMetadataEdmx, readUi5Yaml, toReferenceUri, clearCdsModuleCache } from './project';
3
+ export { createApplicationAccess, createProjectAccess, findAllApps, findCapProjects, findFioriArtifacts, findProjectRoot, getAppRootFromWebappPath, getAppProgrammingLanguage, getAppType, getCapCustomPaths, getCapEnvironment, getCapModelAndServices, getCapProjectType, getCdsFiles, getCdsRoots, getCdsServices, getCapI18nFolderNames, getI18nPropertiesPaths, getMinUI5VersionFromManifest, getMinUI5VersionAsArray, getMinimumUI5Version, getMtaPath, getNodeModulesPath, getProject, getProjectType, getWebappPath, isCapProject, isCapJavaProject, isCapNodeJsProject, loadModuleFromProject, readCapServiceMetadataEdmx, readUi5Yaml, toReferenceUri, clearCdsModuleCache } from './project';
4
4
  export * from './types';
5
5
  export * from './library';
6
6
  //# 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.clearCdsModuleCache = exports.toReferenceUri = exports.readUi5Yaml = exports.readCapServiceMetadataEdmx = exports.loadModuleFromProject = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.isCapProject = exports.getWebappPath = exports.getProjectType = exports.getProject = exports.getNodeModulesPath = exports.getMtaPath = exports.getI18nPropertiesPaths = exports.getCapI18nFolderNames = 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.createProjectAccess = exports.createApplicationAccess = exports.getFilePaths = exports.FioriToolsSettings = exports.DirName = exports.FileName = void 0;
17
+ exports.clearCdsModuleCache = exports.toReferenceUri = exports.readUi5Yaml = exports.readCapServiceMetadataEdmx = exports.loadModuleFromProject = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.isCapProject = exports.getWebappPath = exports.getProjectType = exports.getProject = exports.getNodeModulesPath = exports.getMtaPath = exports.getMinimumUI5Version = exports.getMinUI5VersionAsArray = exports.getMinUI5VersionFromManifest = exports.getI18nPropertiesPaths = exports.getCapI18nFolderNames = 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.createProjectAccess = exports.createApplicationAccess = exports.getFilePaths = exports.FioriToolsSettings = exports.DirName = 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
  Object.defineProperty(exports, "DirName", { enumerable: true, get: function () { return constants_1.DirName; } });
@@ -40,6 +40,9 @@ Object.defineProperty(exports, "getCdsRoots", { enumerable: true, get: function
40
40
  Object.defineProperty(exports, "getCdsServices", { enumerable: true, get: function () { return project_1.getCdsServices; } });
41
41
  Object.defineProperty(exports, "getCapI18nFolderNames", { enumerable: true, get: function () { return project_1.getCapI18nFolderNames; } });
42
42
  Object.defineProperty(exports, "getI18nPropertiesPaths", { enumerable: true, get: function () { return project_1.getI18nPropertiesPaths; } });
43
+ Object.defineProperty(exports, "getMinUI5VersionFromManifest", { enumerable: true, get: function () { return project_1.getMinUI5VersionFromManifest; } });
44
+ Object.defineProperty(exports, "getMinUI5VersionAsArray", { enumerable: true, get: function () { return project_1.getMinUI5VersionAsArray; } });
45
+ Object.defineProperty(exports, "getMinimumUI5Version", { enumerable: true, get: function () { return project_1.getMinimumUI5Version; } });
43
46
  Object.defineProperty(exports, "getMtaPath", { enumerable: true, get: function () { return project_1.getMtaPath; } });
44
47
  Object.defineProperty(exports, "getNodeModulesPath", { enumerable: true, get: function () { return project_1.getNodeModulesPath; } });
45
48
  Object.defineProperty(exports, "getProject", { enumerable: true, get: function () { return project_1.getProject; } });
@@ -1,10 +1,5 @@
1
- import type { CapCustomPaths, CapProjectType, CdsEnvironment, csn, Package, ServiceDefinitions } from '../types';
1
+ import type { CapCustomPaths, CapProjectType, CdsEnvironment, csn, Package, ServiceDefinitions, ServiceInfo, CdsVersionInfo } from '../types';
2
2
  import type { Logger } from '@sap-ux/logger';
3
- interface ServiceInfo {
4
- name: string;
5
- urlPath: string;
6
- runtime?: string;
7
- }
8
3
  /**
9
4
  * Returns true if the project is a CAP Node.js project.
10
5
  *
@@ -45,7 +40,7 @@ export declare function getCapCustomPaths(capProjectPath: string): Promise<CapCu
45
40
  * Return the CAP model and all services. The cds.root will be set to the provided project root path.
46
41
  *
47
42
  * @param projectRoot - CAP project root where package.json resides or object specifying project root and optional logger to log additional info
48
- * @returns {Promise<{ model: csn; services: ServiceInfo[] }>} - CAP Model and Services
43
+ * @returns {Promise<{ model: csn; services: ServiceInfo[]; cdsVersionInfo: CdsVersionInfo }>} - CAP Model and Services
49
44
  */
50
45
  export declare function getCapModelAndServices(projectRoot: string | {
51
46
  projectRoot: string;
@@ -53,6 +48,7 @@ export declare function getCapModelAndServices(projectRoot: string | {
53
48
  }): Promise<{
54
49
  model: csn;
55
50
  services: ServiceInfo[];
51
+ cdsVersionInfo: CdsVersionInfo;
56
52
  }>;
57
53
  /**
58
54
  * Returns a list of cds file paths (layers). By default return list of all, but you can also restrict it to one envRoot.
@@ -123,5 +119,4 @@ export declare const toReferenceUri: (projectRoot: string, relativeUriFrom: stri
123
119
  * Clear cache of path to global cds module.
124
120
  */
125
121
  export declare function clearGlobalCdsPathCache(): void;
126
- export {};
127
122
  //# sourceMappingURL=cap.d.ts.map
@@ -114,7 +114,7 @@ exports.getCapCustomPaths = getCapCustomPaths;
114
114
  * Return the CAP model and all services. The cds.root will be set to the provided project root path.
115
115
  *
116
116
  * @param projectRoot - CAP project root where package.json resides or object specifying project root and optional logger to log additional info
117
- * @returns {Promise<{ model: csn; services: ServiceInfo[] }>} - CAP Model and Services
117
+ * @returns {Promise<{ model: csn; services: ServiceInfo[]; cdsVersionInfo: CdsVersionInfo }>} - CAP Model and Services
118
118
  */
119
119
  function getCapModelAndServices(projectRoot) {
120
120
  var _a;
@@ -151,7 +151,12 @@ function getCapModelAndServices(projectRoot) {
151
151
  }
152
152
  return {
153
153
  model,
154
- services
154
+ services,
155
+ cdsVersionInfo: {
156
+ home: cds.home,
157
+ version: cds.version,
158
+ root: cds.root
159
+ }
155
160
  };
156
161
  });
157
162
  }
@@ -1,7 +1,7 @@
1
1
  export { getCapCustomPaths, getCapModelAndServices, getCapProjectType, getCdsFiles, getCdsRoots, getCdsServices, isCapProject, isCapJavaProject, isCapNodeJsProject, getCapEnvironment, readCapServiceMetadataEdmx, toReferenceUri, clearCdsModuleCache } from './cap';
2
2
  export { getNodeModulesPath } from './dependencies';
3
3
  export { getCapI18nFolderNames, getI18nPropertiesPaths } from './i18n';
4
- export { getAppProgrammingLanguage, getAppType, getProject, getProjectType } from './info';
4
+ export { getAppProgrammingLanguage, getAppType, getMinUI5VersionFromManifest, getMinUI5VersionAsArray, getMinimumUI5Version, getProject, getProjectType } from './info';
5
5
  export { loadModuleFromProject } from './module-loader';
6
6
  export { findAllApps, findCapProjects, findFioriArtifacts, findProjectRoot, getAppRootFromWebappPath } from './search';
7
7
  export { getWebappPath, readUi5Yaml } from './ui5-config';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createProjectAccess = exports.createApplicationAccess = exports.getMtaPath = exports.readUi5Yaml = exports.getWebappPath = exports.getAppRootFromWebappPath = exports.findProjectRoot = exports.findFioriArtifacts = exports.findCapProjects = exports.findAllApps = exports.loadModuleFromProject = exports.getProjectType = exports.getProject = exports.getAppType = exports.getAppProgrammingLanguage = exports.getI18nPropertiesPaths = exports.getCapI18nFolderNames = exports.getNodeModulesPath = exports.clearCdsModuleCache = exports.toReferenceUri = exports.readCapServiceMetadataEdmx = exports.getCapEnvironment = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.isCapProject = exports.getCdsServices = exports.getCdsRoots = exports.getCdsFiles = exports.getCapProjectType = exports.getCapModelAndServices = exports.getCapCustomPaths = void 0;
3
+ exports.createProjectAccess = exports.createApplicationAccess = exports.getMtaPath = exports.readUi5Yaml = exports.getWebappPath = exports.getAppRootFromWebappPath = exports.findProjectRoot = exports.findFioriArtifacts = exports.findCapProjects = exports.findAllApps = exports.loadModuleFromProject = exports.getProjectType = exports.getProject = exports.getMinimumUI5Version = exports.getMinUI5VersionAsArray = exports.getMinUI5VersionFromManifest = exports.getAppType = exports.getAppProgrammingLanguage = exports.getI18nPropertiesPaths = exports.getCapI18nFolderNames = exports.getNodeModulesPath = exports.clearCdsModuleCache = exports.toReferenceUri = exports.readCapServiceMetadataEdmx = exports.getCapEnvironment = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.isCapProject = 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; } });
@@ -23,6 +23,9 @@ Object.defineProperty(exports, "getI18nPropertiesPaths", { enumerable: true, get
23
23
  var info_1 = require("./info");
24
24
  Object.defineProperty(exports, "getAppProgrammingLanguage", { enumerable: true, get: function () { return info_1.getAppProgrammingLanguage; } });
25
25
  Object.defineProperty(exports, "getAppType", { enumerable: true, get: function () { return info_1.getAppType; } });
26
+ Object.defineProperty(exports, "getMinUI5VersionFromManifest", { enumerable: true, get: function () { return info_1.getMinUI5VersionFromManifest; } });
27
+ Object.defineProperty(exports, "getMinUI5VersionAsArray", { enumerable: true, get: function () { return info_1.getMinUI5VersionAsArray; } });
28
+ Object.defineProperty(exports, "getMinimumUI5Version", { enumerable: true, get: function () { return info_1.getMinimumUI5Version; } });
26
29
  Object.defineProperty(exports, "getProject", { enumerable: true, get: function () { return info_1.getProject; } });
27
30
  Object.defineProperty(exports, "getProjectType", { enumerable: true, get: function () { return info_1.getProjectType; } });
28
31
  var module_loader_1 = require("./module-loader");
@@ -1,5 +1,5 @@
1
1
  import type { Editor } from 'mem-fs-editor';
2
- import type { AppProgrammingLanguage, AppType, Project, ProjectType } from '../types';
2
+ import type { AppProgrammingLanguage, AppType, Manifest, Project, ProjectType } from '../types';
3
3
  /**
4
4
  * Returns the project structure for a given Fiori project.
5
5
  *
@@ -29,4 +29,26 @@ export declare function getAppType(appRoot: string): Promise<AppType | undefined
29
29
  * @returns - project type like Edmx, CAPJava, CAPNodejs
30
30
  */
31
31
  export declare function getProjectType(projectRoot: string): Promise<ProjectType>;
32
+ /**
33
+ * Returns the minUI5Version, as defined in manifest.
34
+ *
35
+ * @param manifest - manifest object
36
+ * @returns minUI5Version, if present
37
+ */
38
+ export declare function getMinUI5VersionFromManifest(manifest: Manifest): string | string[] | undefined;
39
+ /**
40
+ * Returns the minUI5Version as string[].
41
+ *
42
+ * @param manifest - manifest object
43
+ * @returns minUI5Version, as an array of strings
44
+ */
45
+ export declare function getMinUI5VersionAsArray(manifest: Manifest): string[];
46
+ /**
47
+ * Returns the minUI5Version in string format.
48
+ * If it is defined as an arry, returns the minimum version from it.
49
+ *
50
+ * @param manifest - manifest object
51
+ * @returns the minimum version as string
52
+ */
53
+ export declare function getMinimumUI5Version(manifest: Manifest): string | undefined;
32
54
  //# sourceMappingURL=info.d.ts.map
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getProjectType = exports.getAppType = exports.getAppProgrammingLanguage = exports.getProject = void 0;
12
+ exports.getMinimumUI5Version = exports.getMinUI5VersionAsArray = exports.getMinUI5VersionFromManifest = exports.getProjectType = exports.getAppType = exports.getAppProgrammingLanguage = exports.getProject = void 0;
13
13
  const path_1 = require("path");
14
14
  const constants_1 = require("../constants");
15
15
  const file_1 = require("../file");
@@ -18,6 +18,7 @@ const i18n_1 = require("./i18n/i18n");
18
18
  const search_1 = require("./search");
19
19
  const service_1 = require("./service");
20
20
  const ui5_config_1 = require("./ui5-config");
21
+ const semver_1 = require("semver");
21
22
  /**
22
23
  * Returns the project structure for a given Fiori project.
23
24
  *
@@ -215,4 +216,54 @@ function getProjectType(projectRoot) {
215
216
  });
216
217
  }
217
218
  exports.getProjectType = getProjectType;
219
+ /**
220
+ * Returns the minUI5Version, as defined in manifest.
221
+ *
222
+ * @param manifest - manifest object
223
+ * @returns minUI5Version, if present
224
+ */
225
+ function getMinUI5VersionFromManifest(manifest) {
226
+ var _a;
227
+ const dependencies = (_a = manifest['sap.ui5']) === null || _a === void 0 ? void 0 : _a.dependencies;
228
+ if (dependencies) {
229
+ return dependencies.minUI5Version;
230
+ }
231
+ return undefined;
232
+ }
233
+ exports.getMinUI5VersionFromManifest = getMinUI5VersionFromManifest;
234
+ /**
235
+ * Returns the minUI5Version as string[].
236
+ *
237
+ * @param manifest - manifest object
238
+ * @returns minUI5Version, as an array of strings
239
+ */
240
+ function getMinUI5VersionAsArray(manifest) {
241
+ let result = [];
242
+ const minUI5Version = getMinUI5VersionFromManifest(manifest);
243
+ if (minUI5Version) {
244
+ result = Array.isArray(minUI5Version) ? minUI5Version : [minUI5Version];
245
+ }
246
+ return result;
247
+ }
248
+ exports.getMinUI5VersionAsArray = getMinUI5VersionAsArray;
249
+ /**
250
+ * Returns the minUI5Version in string format.
251
+ * If it is defined as an arry, returns the minimum version from it.
252
+ *
253
+ * @param manifest - manifest object
254
+ * @returns the minimum version as string
255
+ */
256
+ function getMinimumUI5Version(manifest) {
257
+ let result;
258
+ const minUI5VersionArray = getMinUI5VersionAsArray(manifest);
259
+ if (minUI5VersionArray.length > 0) {
260
+ minUI5VersionArray.forEach((version) => {
261
+ if ((0, semver_1.valid)(version) && (!result || (0, semver_1.gte)(result, version))) {
262
+ result = version;
263
+ }
264
+ });
265
+ }
266
+ return result;
267
+ }
268
+ exports.getMinimumUI5Version = getMinimumUI5Version;
218
269
  //# sourceMappingURL=info.js.map
@@ -223,5 +223,18 @@ export interface LinkedModel extends CSN {
223
223
  services: Definitions & ((namespace: string) => Definitions);
224
224
  definitions: Definitions;
225
225
  }
226
+ export interface ServiceInfo {
227
+ name: string;
228
+ urlPath: string;
229
+ runtime?: string;
230
+ }
231
+ /**
232
+ * CDS version information extracted from package json that was used to compile the project when determining the service.
233
+ */
234
+ export interface CdsVersionInfo {
235
+ home: string;
236
+ version: string;
237
+ root: string;
238
+ }
226
239
  export {};
227
240
  //# 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.20.3",
3
+ "version": "1.21.0",
4
4
  "description": "Library to access SAP Fiori tools projects",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,12 +27,14 @@
27
27
  "findit2": "2.2.3",
28
28
  "mem-fs": "2.1.0",
29
29
  "mem-fs-editor": "9.4.0",
30
+ "semver": "7.5.4",
30
31
  "@sap-ux/i18n": "0.0.7",
31
32
  "@sap-ux/ui5-config": "0.22.5"
32
33
  },
33
34
  "devDependencies": {
34
35
  "@types/mem-fs": "1.1.2",
35
36
  "@types/mem-fs-editor": "7.0.1",
37
+ "@types/semver": "7.5.2",
36
38
  "@ui5/manifest": "1.61.0",
37
39
  "vscode-uri": "3.0.7",
38
40
  "@sap-ux/logger": "0.5.1"