@sap-ux/project-access 1.26.4 → 1.26.6

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.
@@ -118,6 +118,7 @@ async function getCapModelAndServices(projectRoot) {
118
118
  _logger?.info(`@sap-ux/project-access:getCapModelAndServices - Using 'cds.home': ${cds.home}`);
119
119
  _logger?.info(`@sap-ux/project-access:getCapModelAndServices - Using 'cds.version': ${cds.version}`);
120
120
  _logger?.info(`@sap-ux/project-access:getCapModelAndServices - Using 'cds.root': ${cds.root}`);
121
+ _logger?.info(`@sap-ux/project-access:getCapModelAndServices - Using 'projectRoot': ${_projectRoot}`);
121
122
  let services = cds.compile.to.serviceinfo(model, { root: _projectRoot }) ?? [];
122
123
  if (services.map) {
123
124
  services = services.map((value) => {
@@ -370,6 +371,8 @@ async function loadCdsModuleFromProject(capProjectPath, strict = false) {
370
371
  if (global) {
371
372
  global.cds = cds;
372
373
  }
374
+ // correct cds.env for current project root. Especially needed CAP Java projects loading cds dependency from jar file
375
+ cds.env = cds.env.for('cds', capProjectPath);
373
376
  return cds;
374
377
  }
375
378
  /**
@@ -236,26 +236,23 @@ exports.findAllApps = findAllApps;
236
236
  * @returns - results as path to apps plus files already parsed, e.g. manifest.json
237
237
  */
238
238
  async function filterApplications(pathMap) {
239
- const result = [];
240
- const manifestPaths = Object.keys(pathMap).filter((path) => (0, path_1.basename)(path) === constants_1.FileName.Manifest);
241
- for (const manifestPath of manifestPaths) {
242
- try {
243
- // All UI5 apps have at least sap.app: { id: <ID>, type: "application" } in manifest.json
244
- pathMap[manifestPath] ??= await (0, file_1.readJSON)(manifestPath);
245
- const manifest = pathMap[manifestPath];
246
- if (!manifest['sap.app']?.id || manifest['sap.app'].type !== 'application') {
247
- continue;
248
- }
249
- const roots = await findRootsForPath(manifestPath);
239
+ const filterApplicationByManifest = async (manifestPath) => {
240
+ pathMap[manifestPath] ??= await (0, file_1.readJSON)(manifestPath);
241
+ const manifest = pathMap[manifestPath]; // cast needed as pathMap also allows strings and any other objects
242
+ // cast allowed, as this is the only place pathMap is filled for manifests
243
+ if (manifest['sap.app'].id && manifest['sap.app'].type === 'application') {
244
+ const roots = await findRootsForPath((0, path_1.dirname)(manifestPath));
250
245
  if (roots && !(await (0, file_1.fileExists)((0, path_1.join)(roots.appRoot, '.adp', constants_1.FileName.AdaptationConfig)))) {
251
- result.push({ appRoot: roots.appRoot, projectRoot: roots.projectRoot, manifest, manifestPath });
246
+ return { appRoot: roots.appRoot, projectRoot: roots.projectRoot, manifest: manifest, manifestPath };
252
247
  }
253
248
  }
254
- catch {
255
- // ignore exceptions for invalid manifests
256
- }
257
- }
258
- return result;
249
+ throw new Error('Not relevant');
250
+ };
251
+ const isFulFilled = (input) => input.status === 'fulfilled';
252
+ const manifestPaths = Object.keys(pathMap).filter((path) => (0, path_1.basename)(path) === constants_1.FileName.Manifest);
253
+ return (await Promise.allSettled(manifestPaths.map(filterApplicationByManifest)))
254
+ .filter(isFulFilled) // returning only valid applications
255
+ .map(({ value }) => value);
259
256
  }
260
257
  /**
261
258
  * Filter adaptation projects from a list of files.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap-ux/project-access",
3
- "version": "1.26.4",
3
+ "version": "1.26.6",
4
4
  "description": "Library to access SAP Fiori tools projects",
5
5
  "repository": {
6
6
  "type": "git",