@sap-ux/project-access 1.30.2 → 1.30.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.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { FileName, DirName, FioriToolsSettings, MinCdsVersionUi5Plugin } from './constants';
2
2
  export { getFilePaths } from './file';
3
- export { addPackageDevDependency, clearCdsModuleCache, createApplicationAccess, createProjectAccess, deleteCapApp, filterDataSourcesByType, findAllApps, findCapProjectRoot, findCapProjects, findFioriArtifacts, findProjectRoot, findRootsForPath, getAllUi5YamlFileNames, getAppRootFromWebappPath, getAppProgrammingLanguage, getAppType, getCapCustomPaths, getCapEnvironment, getCapModelAndServices, getCapServiceName, getCapProjectType, getCdsFiles, getCdsRoots, getCdsServices, getCapI18nFolderNames, getSpecification, getSpecificationPath, getI18nPropertiesPaths, getI18nBundles, getMinUI5VersionFromManifest, getMinUI5VersionAsArray, getMinimumUI5Version, getMtaPath, getNodeModulesPath, getProject, getProjectType, getWebappPath, hasUI5CliV3, isCapProject, isCapJavaProject, isCapNodeJsProject, loadModuleFromProject, readCapServiceMetadataEdmx, readUi5Yaml, refreshSpecificationDistTags, toReferenceUri, updatePackageScript, getWorkspaceInfo, hasMinCdsVersion, checkCdsUi5PluginEnabled } from './project';
3
+ export { addPackageDevDependency, clearCdsModuleCache, createApplicationAccess, createProjectAccess, deleteCapApp, filterDataSourcesByType, findAllApps, findCapProjectRoot, findCapProjects, findFioriArtifacts, findProjectRoot, findRootsForPath, getAllUi5YamlFileNames, getAppRootFromWebappPath, getAppProgrammingLanguage, getAppType, getCapCustomPaths, getCapEnvironment, getCapModelAndServices, getCapServiceName, getCapProjectType, getCdsFiles, getCdsRoots, getCdsServices, getCapI18nFolderNames, getSpecification, getSpecificationPath, getI18nPropertiesPaths, getI18nBundles, getMinUI5VersionFromManifest, getMinUI5VersionAsArray, getMinimumUI5Version, getMtaPath, getMockServerConfig, getMockDataPath, getNodeModulesPath, getProject, getProjectType, getWebappPath, hasUI5CliV3, isCapProject, isCapJavaProject, isCapNodeJsProject, loadModuleFromProject, readCapServiceMetadataEdmx, readUi5Yaml, refreshSpecificationDistTags, toReferenceUri, updatePackageScript, getWorkspaceInfo, hasMinCdsVersion, checkCdsUi5PluginEnabled } from './project';
4
4
  export { execNpmCommand } from './command/npm-command';
5
5
  export * from './types';
6
6
  export * from './library';
package/dist/index.js CHANGED
@@ -14,8 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.refreshSpecificationDistTags = exports.readUi5Yaml = exports.readCapServiceMetadataEdmx = exports.loadModuleFromProject = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.isCapProject = exports.hasUI5CliV3 = exports.getWebappPath = exports.getProjectType = exports.getProject = exports.getNodeModulesPath = exports.getMtaPath = exports.getMinimumUI5Version = exports.getMinUI5VersionAsArray = exports.getMinUI5VersionFromManifest = exports.getI18nBundles = exports.getI18nPropertiesPaths = exports.getSpecificationPath = exports.getSpecification = exports.getCapI18nFolderNames = exports.getCdsServices = exports.getCdsRoots = exports.getCdsFiles = exports.getCapProjectType = exports.getCapServiceName = exports.getCapModelAndServices = exports.getCapEnvironment = exports.getCapCustomPaths = exports.getAppType = exports.getAppProgrammingLanguage = exports.getAppRootFromWebappPath = exports.getAllUi5YamlFileNames = exports.findRootsForPath = exports.findProjectRoot = exports.findFioriArtifacts = exports.findCapProjects = exports.findCapProjectRoot = exports.findAllApps = exports.filterDataSourcesByType = exports.deleteCapApp = exports.createProjectAccess = exports.createApplicationAccess = exports.clearCdsModuleCache = exports.addPackageDevDependency = exports.getFilePaths = exports.MinCdsVersionUi5Plugin = exports.FioriToolsSettings = exports.DirName = exports.FileName = void 0;
18
- exports.hasDependency = exports.execNpmCommand = exports.checkCdsUi5PluginEnabled = exports.hasMinCdsVersion = exports.getWorkspaceInfo = exports.updatePackageScript = exports.toReferenceUri = void 0;
17
+ exports.readCapServiceMetadataEdmx = exports.loadModuleFromProject = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.isCapProject = exports.hasUI5CliV3 = exports.getWebappPath = exports.getProjectType = exports.getProject = exports.getNodeModulesPath = exports.getMockDataPath = exports.getMockServerConfig = exports.getMtaPath = exports.getMinimumUI5Version = exports.getMinUI5VersionAsArray = exports.getMinUI5VersionFromManifest = exports.getI18nBundles = exports.getI18nPropertiesPaths = exports.getSpecificationPath = exports.getSpecification = exports.getCapI18nFolderNames = exports.getCdsServices = exports.getCdsRoots = exports.getCdsFiles = exports.getCapProjectType = exports.getCapServiceName = exports.getCapModelAndServices = exports.getCapEnvironment = exports.getCapCustomPaths = exports.getAppType = exports.getAppProgrammingLanguage = exports.getAppRootFromWebappPath = exports.getAllUi5YamlFileNames = exports.findRootsForPath = exports.findProjectRoot = exports.findFioriArtifacts = exports.findCapProjects = exports.findCapProjectRoot = exports.findAllApps = exports.filterDataSourcesByType = exports.deleteCapApp = exports.createProjectAccess = exports.createApplicationAccess = exports.clearCdsModuleCache = exports.addPackageDevDependency = exports.getFilePaths = exports.MinCdsVersionUi5Plugin = exports.FioriToolsSettings = exports.DirName = exports.FileName = void 0;
18
+ exports.hasDependency = exports.execNpmCommand = exports.checkCdsUi5PluginEnabled = exports.hasMinCdsVersion = exports.getWorkspaceInfo = exports.updatePackageScript = exports.toReferenceUri = exports.refreshSpecificationDistTags = exports.readUi5Yaml = void 0;
19
19
  var constants_1 = require("./constants");
20
20
  Object.defineProperty(exports, "FileName", { enumerable: true, get: function () { return constants_1.FileName; } });
21
21
  Object.defineProperty(exports, "DirName", { enumerable: true, get: function () { return constants_1.DirName; } });
@@ -57,6 +57,8 @@ Object.defineProperty(exports, "getMinUI5VersionFromManifest", { enumerable: tru
57
57
  Object.defineProperty(exports, "getMinUI5VersionAsArray", { enumerable: true, get: function () { return project_1.getMinUI5VersionAsArray; } });
58
58
  Object.defineProperty(exports, "getMinimumUI5Version", { enumerable: true, get: function () { return project_1.getMinimumUI5Version; } });
59
59
  Object.defineProperty(exports, "getMtaPath", { enumerable: true, get: function () { return project_1.getMtaPath; } });
60
+ Object.defineProperty(exports, "getMockServerConfig", { enumerable: true, get: function () { return project_1.getMockServerConfig; } });
61
+ Object.defineProperty(exports, "getMockDataPath", { enumerable: true, get: function () { return project_1.getMockDataPath; } });
60
62
  Object.defineProperty(exports, "getNodeModulesPath", { enumerable: true, get: function () { return project_1.getNodeModulesPath; } });
61
63
  Object.defineProperty(exports, "getProject", { enumerable: true, get: function () { return project_1.getProject; } });
62
64
  Object.defineProperty(exports, "getProjectType", { enumerable: true, get: function () { return project_1.getProjectType; } });
@@ -5,7 +5,7 @@ export { getCapI18nFolderNames, getI18nPropertiesPaths, getI18nBundles } from '.
5
5
  export { getAppProgrammingLanguage, getAppType, getMinUI5VersionFromManifest, getMinUI5VersionAsArray, getMinimumUI5Version, getProject, getProjectType } from './info';
6
6
  export { loadModuleFromProject } from './module-loader';
7
7
  export { findAllApps, findCapProjects, findFioriArtifacts, findProjectRoot, getAppRootFromWebappPath, findCapProjectRoot, findRootsForPath } from './search';
8
- export { getWebappPath, readUi5Yaml, getAllUi5YamlFileNames } from './ui5-config';
8
+ export { getWebappPath, readUi5Yaml, getAllUi5YamlFileNames, getMockServerConfig, getMockDataPath } from './ui5-config';
9
9
  export { getMtaPath } from './mta';
10
10
  export { createApplicationAccess, createProjectAccess } from './access';
11
11
  export { updatePackageScript, hasUI5CliV3 } from './script';
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSpecificationPath = exports.getSpecification = exports.hasUI5CliV3 = exports.updatePackageScript = exports.createProjectAccess = exports.createApplicationAccess = exports.getMtaPath = exports.getAllUi5YamlFileNames = exports.readUi5Yaml = exports.getWebappPath = exports.findRootsForPath = exports.findCapProjectRoot = exports.getAppRootFromWebappPath = exports.findProjectRoot = exports.findFioriArtifacts = exports.findCapProjects = exports.findAllApps = exports.loadModuleFromProject = exports.getProjectType = exports.getProject = exports.getMinimumUI5Version = exports.getMinUI5VersionAsArray = exports.getMinUI5VersionFromManifest = exports.getAppType = exports.getAppProgrammingLanguage = exports.getI18nBundles = exports.getI18nPropertiesPaths = exports.getCapI18nFolderNames = exports.hasDependency = exports.getNodeModulesPath = exports.addPackageDevDependency = exports.filterDataSourcesByType = exports.checkCdsUi5PluginEnabled = exports.hasMinCdsVersion = exports.getWorkspaceInfo = exports.toReferenceUri = exports.readCapServiceMetadataEdmx = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.isCapProject = exports.getCdsServices = exports.getCdsRoots = exports.getCdsFiles = exports.getCapServiceName = exports.getCapProjectType = exports.getCapModelAndServices = exports.getCapEnvironment = exports.getCapCustomPaths = exports.deleteCapApp = exports.clearCdsModuleCache = void 0;
4
- exports.refreshSpecificationDistTags = void 0;
3
+ exports.hasUI5CliV3 = exports.updatePackageScript = exports.createProjectAccess = exports.createApplicationAccess = exports.getMtaPath = exports.getMockDataPath = exports.getMockServerConfig = exports.getAllUi5YamlFileNames = exports.readUi5Yaml = exports.getWebappPath = exports.findRootsForPath = exports.findCapProjectRoot = exports.getAppRootFromWebappPath = exports.findProjectRoot = exports.findFioriArtifacts = exports.findCapProjects = exports.findAllApps = exports.loadModuleFromProject = exports.getProjectType = exports.getProject = exports.getMinimumUI5Version = exports.getMinUI5VersionAsArray = exports.getMinUI5VersionFromManifest = exports.getAppType = exports.getAppProgrammingLanguage = exports.getI18nBundles = exports.getI18nPropertiesPaths = exports.getCapI18nFolderNames = exports.hasDependency = exports.getNodeModulesPath = exports.addPackageDevDependency = exports.filterDataSourcesByType = exports.checkCdsUi5PluginEnabled = exports.hasMinCdsVersion = exports.getWorkspaceInfo = exports.toReferenceUri = exports.readCapServiceMetadataEdmx = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.isCapProject = exports.getCdsServices = exports.getCdsRoots = exports.getCdsFiles = exports.getCapServiceName = exports.getCapProjectType = exports.getCapModelAndServices = exports.getCapEnvironment = exports.getCapCustomPaths = exports.deleteCapApp = exports.clearCdsModuleCache = void 0;
4
+ exports.refreshSpecificationDistTags = exports.getSpecificationPath = exports.getSpecification = void 0;
5
5
  var cap_1 = require("./cap");
6
6
  Object.defineProperty(exports, "clearCdsModuleCache", { enumerable: true, get: function () { return cap_1.clearCdsModuleCache; } });
7
7
  Object.defineProperty(exports, "deleteCapApp", { enumerable: true, get: function () { return cap_1.deleteCapApp; } });
@@ -53,6 +53,8 @@ var ui5_config_1 = require("./ui5-config");
53
53
  Object.defineProperty(exports, "getWebappPath", { enumerable: true, get: function () { return ui5_config_1.getWebappPath; } });
54
54
  Object.defineProperty(exports, "readUi5Yaml", { enumerable: true, get: function () { return ui5_config_1.readUi5Yaml; } });
55
55
  Object.defineProperty(exports, "getAllUi5YamlFileNames", { enumerable: true, get: function () { return ui5_config_1.getAllUi5YamlFileNames; } });
56
+ Object.defineProperty(exports, "getMockServerConfig", { enumerable: true, get: function () { return ui5_config_1.getMockServerConfig; } });
57
+ Object.defineProperty(exports, "getMockDataPath", { enumerable: true, get: function () { return ui5_config_1.getMockDataPath; } });
56
58
  var mta_1 = require("./mta");
57
59
  Object.defineProperty(exports, "getMtaPath", { enumerable: true, get: function () { return mta_1.getMtaPath; } });
58
60
  var access_1 = require("./access");
@@ -1,4 +1,5 @@
1
1
  import type { Editor } from 'mem-fs-editor';
2
+ import type { MockserverConfig } from '@sap-ux/ui5-config';
2
3
  import { UI5Config } from '@sap-ux/ui5-config';
3
4
  /**
4
5
  * Get path to webapp.
@@ -31,4 +32,21 @@ export declare function readUi5Yaml(projectRoot: string, fileName: string, memFs
31
32
  * @throws {Error} if an error occurs while reading files from projectRoot
32
33
  */
33
34
  export declare function getAllUi5YamlFileNames(projectRoot: string, memFs?: Editor): Promise<string[]>;
35
+ /**
36
+ * Retrieves the mock server configuration from the UI5 mock YAML file.
37
+ *
38
+ * @param projectRoot - Path to the project root.
39
+ * @param fileName - Name of the YAML file to read. Defaults to FileName.Ui5MockYaml.
40
+ * @returns The mock server configuration or null if not found.
41
+ * @throws {Error} If the sap-fe-mockserver middleware is not found.
42
+ */
43
+ export declare function getMockServerConfig(projectRoot: string, fileName?: string): Promise<MockserverConfig>;
44
+ /**
45
+ * Retrieves the mock data path from the mock server configuration.
46
+ *
47
+ * @param projectRoot - Path to the project root.
48
+ * @param fileName - Name of the YAML file to read. Defaults to FileName.Ui5MockYaml.
49
+ * @returns The mock data path as a string. Returns an empty string if not found.
50
+ */
51
+ export declare function getMockDataPath(projectRoot: string, fileName?: string): Promise<string>;
34
52
  //# sourceMappingURL=ui5-config.d.ts.map
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getWebappPath = getWebappPath;
4
4
  exports.readUi5Yaml = readUi5Yaml;
5
5
  exports.getAllUi5YamlFileNames = getAllUi5YamlFileNames;
6
+ exports.getMockServerConfig = getMockServerConfig;
7
+ exports.getMockDataPath = getMockDataPath;
6
8
  const path_1 = require("path");
7
9
  const ui5_config_1 = require("@sap-ux/ui5-config");
8
10
  const constants_1 = require("../constants");
@@ -68,4 +70,51 @@ async function getAllUi5YamlFileNames(projectRoot, memFs) {
68
70
  throw new Error(`There was an error reading files from the directory '${projectRoot}': ${error}`);
69
71
  }
70
72
  }
73
+ /**
74
+ * Retrieves the mock server configuration from the UI5 mock YAML file.
75
+ *
76
+ * @param projectRoot - Path to the project root.
77
+ * @param fileName - Name of the YAML file to read. Defaults to FileName.Ui5MockYaml.
78
+ * @returns The mock server configuration or null if not found.
79
+ * @throws {Error} If the sap-fe-mockserver middleware is not found.
80
+ */
81
+ async function getMockServerConfig(projectRoot, fileName = constants_1.FileName.Ui5MockYaml) {
82
+ const ui5MockYamlFile = await readUi5Yaml(projectRoot, fileName);
83
+ const mockserverMiddleware = ui5MockYamlFile.findCustomMiddleware('sap-fe-mockserver');
84
+ if (!mockserverMiddleware) {
85
+ throw new Error('Could not find sap-fe-mockserver');
86
+ }
87
+ return mockserverMiddleware.configuration;
88
+ }
89
+ /**
90
+ * Retrieves the mock data path from the mock server configuration.
91
+ *
92
+ * @param projectRoot - Path to the project root.
93
+ * @param fileName - Name of the YAML file to read. Defaults to FileName.Ui5MockYaml.
94
+ * @returns The mock data path as a string. Returns an empty string if not found.
95
+ */
96
+ async function getMockDataPath(projectRoot, fileName = constants_1.FileName.Ui5MockYaml) {
97
+ const mockServerConfig = await getMockServerConfig(projectRoot, fileName);
98
+ if (!mockServerConfig) {
99
+ return '';
100
+ }
101
+ const services = extractServices(mockServerConfig);
102
+ if (!services) {
103
+ return '';
104
+ }
105
+ const found = services.find((service) => !!service.mockdataPath);
106
+ return found?.mockdataPath ?? '';
107
+ }
108
+ /**
109
+ * Helper to extract the services array from a MockServerConfiguration.
110
+ *
111
+ * @param config - The mock server configuration object.
112
+ * @returns An array of MockServerService objects, or undefined if not found.
113
+ */
114
+ function extractServices(config) {
115
+ if ('services' in config && config.services) {
116
+ return Array.isArray(config.services) ? config.services : [config.services];
117
+ }
118
+ return undefined;
119
+ }
71
120
  //# sourceMappingURL=ui5-config.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap-ux/project-access",
3
- "version": "1.30.2",
3
+ "version": "1.30.4",
4
4
  "description": "Library to access SAP Fiori tools projects",
5
5
  "repository": {
6
6
  "type": "git",
@@ -29,8 +29,8 @@
29
29
  "mem-fs": "2.1.0",
30
30
  "mem-fs-editor": "9.4.0",
31
31
  "semver": "7.5.4",
32
- "@sap-ux/i18n": "0.3.0",
33
- "@sap-ux/ui5-config": "0.28.2"
32
+ "@sap-ux/i18n": "0.3.1",
33
+ "@sap-ux/ui5-config": "0.28.3"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/mem-fs": "1.1.2",