@sap-ux/project-access
Advanced tools
Comparing version 1.29.3 to 1.29.4
@@ -25,2 +25,3 @@ "use strict"; | ||
adaptations: [constants_1.FileName.ManifestAppDescrVar], | ||
components: [constants_1.FileName.Manifest], | ||
extensions: [constants_1.FileName.ExtConfigJson], | ||
@@ -349,3 +350,3 @@ libraries: [constants_1.FileName.Library, constants_1.FileName.Manifest] | ||
/** | ||
* Filter extensions projects from a list of files. | ||
* Filter libraries from a list of files. | ||
* | ||
@@ -379,2 +380,30 @@ * @param pathMap - path to files | ||
/** | ||
* Filter components from a list of files. | ||
* | ||
* @param pathMap - path to files | ||
* @param memFs - optional mem-fs-editor instance | ||
* @returns - results as array of found components. | ||
*/ | ||
async function filterComponents(pathMap, memFs) { | ||
const results = []; | ||
const manifestPaths = Object.keys(pathMap).filter((path) => (0, path_1.basename)(path) === constants_1.FileName.Manifest); | ||
for (const manifestPath of manifestPaths) { | ||
try { | ||
pathMap[manifestPath] ??= await (0, file_1.readJSON)(manifestPath, memFs); | ||
const manifest = pathMap[manifestPath]; | ||
if (manifest['sap.app'] && manifest['sap.app'].type === 'component') { | ||
const packageJsonPath = await (0, file_1.findFileUp)(constants_1.FileName.Package, (0, path_1.dirname)(manifestPath), memFs); | ||
const projectRoot = packageJsonPath ? (0, path_1.dirname)(packageJsonPath) : null; | ||
if (projectRoot) { | ||
results.push({ projectRoot, manifestPath, manifest }); | ||
} | ||
} | ||
} | ||
catch { | ||
// ignore exceptions for invalid components | ||
} | ||
} | ||
return results; | ||
} | ||
/** | ||
* Get the files to search for according to requested artifact type. | ||
@@ -434,2 +463,5 @@ * | ||
} | ||
if (options.artifacts.includes('components')) { | ||
results.components = await filterComponents(pathMap, options.memFs); | ||
} | ||
return results; | ||
@@ -436,0 +468,0 @@ } |
import type { Manifest } from '../webapp'; | ||
export type FioriArtifactTypes = 'applications' | 'adaptations' | 'extensions' | 'libraries'; | ||
export type FioriArtifactTypes = 'applications' | 'adaptations' | 'extensions' | 'libraries' | 'components'; | ||
/** | ||
@@ -84,2 +84,20 @@ * Search result when searching for apps. It is valid for all types of | ||
} | ||
/** | ||
* Search result when searching for components. | ||
*/ | ||
export interface ComponentResults { | ||
/** | ||
* Root of the component, where package.json and ui5.yaml resides. | ||
*/ | ||
projectRoot: string; | ||
/** | ||
* Path to the manifest.json of the component. | ||
*/ | ||
manifestPath?: string; | ||
/** | ||
* Parsed content of the manifest.json to avoid multiple reads when working with | ||
* the search results. | ||
*/ | ||
manifest?: Manifest; | ||
} | ||
export interface FoundFioriArtifacts { | ||
@@ -90,3 +108,4 @@ applications?: AllAppResults[]; | ||
libraries?: LibraryResults[]; | ||
components?: ComponentResults[]; | ||
} | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@sap-ux/project-access", | ||
"version": "1.29.3", | ||
"version": "1.29.4", | ||
"description": "Library to access SAP Fiori tools projects", | ||
@@ -5,0 +5,0 @@ "repository": { |
261044
5763