@sap-ux/project-access 1.24.0 → 1.25.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.
@@ -17,10 +17,12 @@ const semver_1 = require("semver");
17
17
  * @returns - project structure with project info like project type, apps, root folder
18
18
  */
19
19
  async function getProject(root) {
20
- const checkCapType = await (0, cap_1.getCapProjectType)(root);
21
- const projectType = checkCapType ?? 'EDMXBackend';
22
- const packageJson = await (0, file_1.readJSON)((0, path_1.join)(root, constants_1.FileName.Package));
23
- const appFolders = getAppFolders(packageJson);
20
+ if (!(await (0, file_1.fileExists)((0, path_1.join)(root, constants_1.FileName.Package)))) {
21
+ throw new Error(`The project root folder '${root}' is not a Fiori project. No 'package.json' found.`);
22
+ }
23
+ const capProjectType = await (0, cap_1.getCapProjectType)(root);
24
+ const projectType = capProjectType ?? 'EDMXBackend';
25
+ const appFolders = await getAppFolders(root);
24
26
  const apps = await getApps(root, appFolders);
25
27
  return {
26
28
  root,
@@ -30,17 +32,16 @@ async function getProject(root) {
30
32
  }
31
33
  exports.getProject = getProject;
32
34
  /**
33
- * Returns the application folders from sapux flag of the package.json. For single app
35
+ * Returns the applications for the project. For single app
34
36
  * projects, this is just an array with one empty string. For CAP projects, this is an
35
37
  * array of operating system specific relative paths to the apps.
36
38
  *
37
- * @param packageJson - parsed package.json
39
+ * @param root - project root folder
38
40
  * @returns - array of operating specific application folders
39
41
  */
40
- function getAppFolders(packageJson) {
41
- return Array.isArray(packageJson.sapux)
42
- ? packageJson.sapux.map((appFolder) => (0, path_1.join)(...appFolder.split(/[/\\]/)))
43
- : [''];
42
+ async function getAppFolders(root) {
43
+ const apps = await (0, search_1.findAllApps)([root]);
44
+ return apps.length > 0 ? apps.map((app) => (0, path_1.relative)(root, app.appRoot)) : [''];
44
45
  }
45
46
  /**
46
47
  * Get the application structure for each application in the project.
@@ -69,6 +70,7 @@ async function getApps(root, appFolders) {
69
70
  async function getApplicationStructure(root, appFolder) {
70
71
  const appRoot = (0, path_1.join)(root, appFolder);
71
72
  const absoluteWebappPath = await (0, ui5_config_1.getWebappPath)(appRoot);
73
+ const appType = (await getAppType(appRoot));
72
74
  const manifest = (0, path_1.join)(absoluteWebappPath, constants_1.FileName.Manifest);
73
75
  if (!(await (0, file_1.fileExists)(manifest))) {
74
76
  return undefined;
@@ -80,6 +82,7 @@ async function getApplicationStructure(root, appFolder) {
80
82
  const services = await (0, service_1.getServicesAndAnnotations)(manifest, manifestObject);
81
83
  return {
82
84
  appRoot,
85
+ appType,
83
86
  manifest,
84
87
  changes,
85
88
  i18n,
@@ -194,6 +194,9 @@ async function findRootsForPath(path) {
194
194
  */
195
195
  async function findCapProjectRoot(path) {
196
196
  try {
197
+ if (!(0, path_1.isAbsolute)(path)) {
198
+ return null;
199
+ }
197
200
  const { root } = (0, path_1.parse)(path);
198
201
  let projectRoot = (0, path_1.dirname)(path);
199
202
  while (projectRoot !== root) {
@@ -45,6 +45,10 @@ export interface ApplicationStructure {
45
45
  services: {
46
46
  [index: string]: ServiceSpecification;
47
47
  };
48
+ /**
49
+ * Application type.
50
+ */
51
+ appType: AppType;
48
52
  }
49
53
  export interface I18nPropertiesPaths {
50
54
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap-ux/project-access",
3
- "version": "1.24.0",
3
+ "version": "1.25.0",
4
4
  "description": "Library to access SAP Fiori tools projects",
5
5
  "repository": {
6
6
  "type": "git",