@sap-ux/project-access 1.34.0 → 1.34.2
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 +1 -1
- package/dist/project/index.d.ts +1 -1
- package/dist/project/ui5-config.d.ts +28 -3
- package/dist/project/ui5-config.js +16 -12
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { FileName, DirName, FioriToolsSettings, MinCdsPluginUi5Version, MinCdsVersion, fioriToolsDirectory } from './constants';
|
|
2
2
|
export { getFilePaths } from './file';
|
|
3
3
|
export { normalizePath } from './path';
|
|
4
|
-
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, getSpecificationModuleFromCache, getSpecificationPath, getI18nPropertiesPaths, getI18nBundles, getMinUI5VersionFromManifest, getMinUI5VersionAsArray, getMinimumUI5Version, getMtaPath, getMockServerConfig, getMockDataPath, getNodeModulesPath, getPathMappings, getProject, getProjectType, getWebappPath, hasUI5CliV3, isCapProject, isCapJavaProject, isCapNodeJsProject, loadModuleFromProject, readCapServiceMetadataEdmx, readUi5Yaml, refreshSpecificationDistTags, toReferenceUri, updatePackageScript, getWorkspaceInfo, hasMinCdsVersion, checkCdsUi5PluginEnabled, readFlexChanges, processServices, getMainService } from './project';
|
|
4
|
+
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, getSpecificationModuleFromCache, getSpecificationPath, getI18nPropertiesPaths, getI18nBundles, getMinUI5VersionFromManifest, getMinUI5VersionAsArray, getMinimumUI5Version, getMtaPath, getMockServerConfig, getMockDataPath, getNodeModulesPath, getPathMappings, type PathMappings, getProject, getProjectType, getWebappPath, hasUI5CliV3, isCapProject, isCapJavaProject, isCapNodeJsProject, loadModuleFromProject, readCapServiceMetadataEdmx, readUi5Yaml, refreshSpecificationDistTags, toReferenceUri, updatePackageScript, getWorkspaceInfo, hasMinCdsVersion, checkCdsUi5PluginEnabled, readFlexChanges, processServices, getMainService } from './project';
|
|
5
5
|
export { execNpmCommand } from './command/npm-command';
|
|
6
6
|
export * from './types';
|
|
7
7
|
export * from './library';
|
package/dist/project/index.d.ts
CHANGED
|
@@ -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, getMockServerConfig, getMockDataPath, getPathMappings } from './ui5-config';
|
|
8
|
+
export { getWebappPath, readUi5Yaml, getAllUi5YamlFileNames, getMockServerConfig, getMockDataPath, getPathMappings, type PathMappings } from './ui5-config';
|
|
9
9
|
export { getMtaPath } from './mta';
|
|
10
10
|
export { createApplicationAccess, createProjectAccess } from './access';
|
|
11
11
|
export { updatePackageScript, hasUI5CliV3 } from './script';
|
|
@@ -1,8 +1,33 @@
|
|
|
1
1
|
import type { Editor } from 'mem-fs-editor';
|
|
2
|
-
import type { MockserverConfig } from '@sap-ux/ui5-config';
|
|
2
|
+
import type { MockserverConfig, Ui5Document } from '@sap-ux/ui5-config';
|
|
3
3
|
import { UI5Config } from '@sap-ux/ui5-config';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Type representing the possible path mappings defined in the UI5 configuration for the different project types.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export type PathMappings = {
|
|
9
|
+
[K in keyof typeof PATH_MAPPING_DEFAULTS]: {
|
|
10
|
+
[P in keyof (typeof PATH_MAPPING_DEFAULTS)[K]]: string;
|
|
11
|
+
};
|
|
12
|
+
}[keyof typeof PATH_MAPPING_DEFAULTS];
|
|
13
|
+
/**
|
|
14
|
+
* Extracts the paths configuration type for a given UI5 project type.
|
|
15
|
+
*
|
|
16
|
+
* @template T - The UI5 project type.
|
|
17
|
+
*/
|
|
18
|
+
type PathsFor<T extends Ui5Document['type']> = Extract<Ui5Document, {
|
|
19
|
+
type: T;
|
|
20
|
+
}> extends {
|
|
21
|
+
configuration?: {
|
|
22
|
+
paths?: infer P;
|
|
23
|
+
};
|
|
24
|
+
} ? P : never;
|
|
25
|
+
/**
|
|
26
|
+
* Default path mappings for each UI5 project type.
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
declare const PATH_MAPPING_DEFAULTS: {
|
|
30
|
+
[K in Ui5Document['type']]: Required<PathsFor<K>>;
|
|
6
31
|
};
|
|
7
32
|
/**
|
|
8
33
|
* Get path to webapp.
|
|
@@ -10,6 +10,10 @@ const node_path_1 = require("node:path");
|
|
|
10
10
|
const ui5_config_1 = require("@sap-ux/ui5-config");
|
|
11
11
|
const constants_1 = require("../constants");
|
|
12
12
|
const file_1 = require("../file");
|
|
13
|
+
/**
|
|
14
|
+
* Default path mappings for each UI5 project type.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
13
17
|
const PATH_MAPPING_DEFAULTS = {
|
|
14
18
|
application: { webapp: constants_1.DirName.Webapp },
|
|
15
19
|
library: { src: 'src', test: 'test' },
|
|
@@ -35,14 +39,15 @@ async function getBaseDir(appRoot, memFs) {
|
|
|
35
39
|
* @returns - path to webapp folder
|
|
36
40
|
*/
|
|
37
41
|
async function getWebappPath(appRoot, memFs) {
|
|
38
|
-
let pathMappings
|
|
42
|
+
let pathMappings;
|
|
39
43
|
try {
|
|
40
44
|
pathMappings = await getPathMappings(appRoot, memFs);
|
|
41
45
|
}
|
|
42
46
|
catch {
|
|
43
47
|
// For backward compatibility ignore errors and use default
|
|
48
|
+
pathMappings = {};
|
|
44
49
|
}
|
|
45
|
-
return pathMappings
|
|
50
|
+
return 'webapp' in pathMappings ? pathMappings.webapp : (0, node_path_1.join)(appRoot, constants_1.DirName.Webapp);
|
|
46
51
|
}
|
|
47
52
|
/**
|
|
48
53
|
* Get path mappings defined in 'ui5.yaml' depending on the project type defined in 'ui5.yaml'.
|
|
@@ -70,17 +75,16 @@ async function getPathMappings(appRoot, memFs, fileName = constants_1.FileName.U
|
|
|
70
75
|
throw new Error(`Unsupported project type for path mappings: ${type}`);
|
|
71
76
|
}
|
|
72
77
|
const baseDir = await getBaseDir(appRoot, memFs);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
pathMappings[key] = (0, node_path_1.join)(baseDir, defaultValue);
|
|
81
|
-
}
|
|
78
|
+
// Use Record<string, string> to permit index access during the merge loop
|
|
79
|
+
const result = {};
|
|
80
|
+
const configPaths = (configuration?.paths || {});
|
|
81
|
+
const defaults = PATH_MAPPING_DEFAULTS[type];
|
|
82
|
+
for (const key in defaults) {
|
|
83
|
+
const value = configPaths[key] ?? defaults[key];
|
|
84
|
+
result[key] = (0, node_path_1.join)(baseDir, value);
|
|
82
85
|
}
|
|
83
|
-
|
|
86
|
+
// Cast the merged result to PathMappings to re-enforce strict union keys for the caller
|
|
87
|
+
return result;
|
|
84
88
|
}
|
|
85
89
|
/**
|
|
86
90
|
* Checks if UI5 config yaml file exists and returns its content.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/project-access",
|
|
3
|
-
"version": "1.34.
|
|
3
|
+
"version": "1.34.2",
|
|
4
4
|
"description": "Library to access SAP Fiori tools projects",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"mem-fs-editor": "9.4.0",
|
|
31
31
|
"semver": "7.5.4",
|
|
32
32
|
"@sap-ux/i18n": "0.3.7",
|
|
33
|
-
"@sap-ux/ui5-config": "0.29.
|
|
33
|
+
"@sap-ux/ui5-config": "0.29.13"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/mem-fs": "1.1.2",
|