@sap-ux/project-access 1.29.2 → 1.29.4

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.
@@ -169,6 +169,12 @@ async function getCapModelAndServices(projectRoot) {
169
169
  _logger?.info(`@sap-ux/project-access:getCapModelAndServices - Using 'cds.root': ${cds.root}`);
170
170
  _logger?.info(`@sap-ux/project-access:getCapModelAndServices - Using 'projectRoot': ${_projectRoot}`);
171
171
  let services = cds.compile.to.serviceinfo(model, { root: _projectRoot }) ?? [];
172
+ // filter services that have ( urlPath defined AND no endpoints) OR have endpoints with kind 'odata'
173
+ // i.e. ignore services for websockets and other unsupported protocols
174
+ if (services.filter) {
175
+ services = services.filter((service) => (service.urlPath && service.endpoints === undefined) ||
176
+ service.endpoints?.find((endpoint) => endpoint.kind === 'odata'));
177
+ }
172
178
  if (services.map) {
173
179
  services = services.map((value) => {
174
180
  const { endpoints, urlPath } = value;
@@ -22,6 +22,7 @@ const ui5_config_1 = require("./ui5-config");
22
22
  const filterFileMap = {
23
23
  applications: [constants_1.FileName.Manifest],
24
24
  adaptations: [constants_1.FileName.ManifestAppDescrVar],
25
+ components: [constants_1.FileName.Manifest],
25
26
  extensions: [constants_1.FileName.ExtConfigJson],
26
27
  libraries: [constants_1.FileName.Library, constants_1.FileName.Manifest]
27
28
  };
@@ -345,7 +346,7 @@ async function filterDotLibraries(pathMap, manifestPaths, memFs) {
345
346
  return dotLibraries;
346
347
  }
347
348
  /**
348
- * Filter extensions projects from a list of files.
349
+ * Filter libraries from a list of files.
349
350
  *
350
351
  * @param pathMap - path to files
351
352
  * @param memFs - optional mem-fs-editor instance
@@ -373,6 +374,34 @@ async function filterLibraries(pathMap, memFs) {
373
374
  }
374
375
  return results;
375
376
  }
377
+ /**
378
+ * Filter components from a list of files.
379
+ *
380
+ * @param pathMap - path to files
381
+ * @param memFs - optional mem-fs-editor instance
382
+ * @returns - results as array of found components.
383
+ */
384
+ async function filterComponents(pathMap, memFs) {
385
+ const results = [];
386
+ const manifestPaths = Object.keys(pathMap).filter((path) => (0, path_1.basename)(path) === constants_1.FileName.Manifest);
387
+ for (const manifestPath of manifestPaths) {
388
+ try {
389
+ pathMap[manifestPath] ??= await (0, file_1.readJSON)(manifestPath, memFs);
390
+ const manifest = pathMap[manifestPath];
391
+ if (manifest['sap.app'] && manifest['sap.app'].type === 'component') {
392
+ const packageJsonPath = await (0, file_1.findFileUp)(constants_1.FileName.Package, (0, path_1.dirname)(manifestPath), memFs);
393
+ const projectRoot = packageJsonPath ? (0, path_1.dirname)(packageJsonPath) : null;
394
+ if (projectRoot) {
395
+ results.push({ projectRoot, manifestPath, manifest });
396
+ }
397
+ }
398
+ }
399
+ catch {
400
+ // ignore exceptions for invalid components
401
+ }
402
+ }
403
+ return results;
404
+ }
376
405
  /**
377
406
  * Get the files to search for according to requested artifact type.
378
407
  *
@@ -428,6 +457,9 @@ async function findFioriArtifacts(options) {
428
457
  if (options.artifacts.includes('libraries')) {
429
458
  results.libraries = await filterLibraries(pathMap, options.memFs);
430
459
  }
460
+ if (options.artifacts.includes('components')) {
461
+ results.components = await filterComponents(pathMap, options.memFs);
462
+ }
431
463
  return results;
432
464
  }
433
465
  /**
@@ -1,5 +1,5 @@
1
1
  import type { Manifest } from '../webapp';
2
- export type FioriArtifactTypes = 'applications' | 'adaptations' | 'extensions' | 'libraries';
2
+ export type FioriArtifactTypes = 'applications' | 'adaptations' | 'extensions' | 'libraries' | 'components';
3
3
  /**
4
4
  * Search result when searching for apps. It is valid for all types of
5
5
  * Fiori apps, like Fiori elements, UI5 freestyle, apps that are part
@@ -81,10 +81,29 @@ export interface LibraryResults {
81
81
  */
82
82
  libraryPath?: string;
83
83
  }
84
+ /**
85
+ * Search result when searching for components.
86
+ */
87
+ export interface ComponentResults {
88
+ /**
89
+ * Root of the component, where package.json and ui5.yaml resides.
90
+ */
91
+ projectRoot: string;
92
+ /**
93
+ * Path to the manifest.json of the component.
94
+ */
95
+ manifestPath?: string;
96
+ /**
97
+ * Parsed content of the manifest.json to avoid multiple reads when working with
98
+ * the search results.
99
+ */
100
+ manifest?: Manifest;
101
+ }
84
102
  export interface FoundFioriArtifacts {
85
103
  applications?: AllAppResults[];
86
104
  adaptations?: AdaptationResults[];
87
105
  extensions?: ExtensionResults[];
88
106
  libraries?: LibraryResults[];
107
+ components?: ComponentResults[];
89
108
  }
90
109
  //# 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.29.2",
3
+ "version": "1.29.4",
4
4
  "description": "Library to access SAP Fiori tools projects",
5
5
  "repository": {
6
6
  "type": "git",