UNPKG

@sap-ux/project-access

Version:

Library to access SAP Fiori tools projects

92 lines 3.74 kB
import type { Editor } from 'mem-fs-editor'; import type { MockserverConfig, Ui5Document } from '@sap-ux/ui5-config'; import { UI5Config } from '@sap-ux/ui5-config'; /** * Type representing the possible path mappings defined in the UI5 configuration for the different project types. * */ export type PathMappings = { [K in keyof typeof PATH_MAPPING_DEFAULTS]: { [P in keyof (typeof PATH_MAPPING_DEFAULTS)[K]]: string; }; }[keyof typeof PATH_MAPPING_DEFAULTS]; /** * Extracts the paths configuration type for a given UI5 project type. * * @template T - The UI5 project type. */ type PathsFor<T extends Ui5Document['type']> = Extract<Ui5Document, { type: T; }> extends { configuration?: { paths?: infer P; }; } ? P : never; /** * Default path mappings for each UI5 project type. * */ declare const PATH_MAPPING_DEFAULTS: { [K in Ui5Document['type']]: Required<PathsFor<K>>; }; /** * Get path to webapp. * * @param appRoot - root to the application * @param [memFs] - optional mem-fs editor instance * @returns - path to webapp folder */ export declare function getWebappPath(appRoot: string, memFs?: Editor): Promise<string>; /** * Get path mappings defined in 'ui5.yaml' depending on the project type defined in 'ui5.yaml'. * * @param appRoot - root to the application * @param memFs - optional mem-fs editor instance * @param fileName - optional name of yaml file to be read. Defaults to 'ui5.yaml'. * @returns - path mappings * @throws {Error} if ui5.yaml or 'type' cannot be read * @throws {Error} if project type is not 'application', 'library', 'theme-library' or 'module' */ export declare function getPathMappings(appRoot: string, memFs?: Editor, fileName?: string): Promise<PathMappings>; /** * Checks if UI5 config yaml file exists and returns its content. * * @param projectRoot - path to project root * @param fileName - name of yaml file to be read * @param [memFs] - optional mem-fs editor instance * @param options - options * @param [options.validateSchema] - optional flag to validate the schema of the yaml file * @returns {UI5Config} UI5 config file in yaml format * @throws {Error} if file is not found */ export declare function readUi5Yaml(projectRoot: string, fileName: string, memFs?: Editor, options?: { validateSchema: boolean; }): Promise<UI5Config>; /** * Scans the project directory for ui5 configuration yaml files. * * @param projectRoot - path to project root, where ui5 configuration y*ml files are located * @param [memFs] - optional mem-fs editor instance * @returns list of valid and invalid UI5 configuration yaml file names * @throws {Error} if an error occurs while reading files from projectRoot */ export declare function getAllUi5YamlFileNames(projectRoot: string, memFs?: Editor): Promise<string[]>; /** * Retrieves the mock server configuration from the UI5 mock YAML file. * * @param projectRoot - Path to the project root. * @param fileName - Name of the YAML file to read. Defaults to FileName.Ui5MockYaml. * @returns The mock server configuration or null if not found. * @throws {Error} If the sap-fe-mockserver middleware is not found. */ export declare function getMockServerConfig(projectRoot: string, fileName?: string): Promise<MockserverConfig>; /** * Retrieves the mock data path from the mock server configuration. * * @param projectRoot - Path to the project root. * @param fileName - Name of the YAML file to read. Defaults to FileName.Ui5MockYaml. * @returns The mock data path as a string. Returns an empty string if not found. */ export declare function getMockDataPath(projectRoot: string, fileName?: string): Promise<string>; export {}; //# sourceMappingURL=ui5-config.d.ts.map