Repository navigation
feat: Resolve effective UI5 framework version on ProjectGraph #1697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
72dcd8a
cd92b8d
4f0bd4a
cc3c4e6
08f655c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -399,15 +399,6 @@ export default { | |
|
|
||
| const {libraryMetadata} = await resolver.install(referencedLibraries); | ||
|
|
||
| if (version) { | ||
| process.emit("ui5.project-framework-resolved", { | ||
| framework: { | ||
| name: frameworkName, | ||
| version, | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| if (log.isLevelEnabled("verbose")) { | ||
| const timeDiff = process.hrtime(startTime); | ||
| const {default: prettyHrtime} = await import("pretty-hrtime"); | ||
|
|
@@ -435,6 +426,50 @@ export default { | |
| log.verbose("Joining framework graph into project graph..."); | ||
| projectGraph.join(frameworkGraph); | ||
| await utils.declareFrameworkDependenciesInGraph(projectGraph); | ||
|
|
||
| // A workspace only overrides the resolved version when it actually contributed framework | ||
| // libraries; an empty providedLibraryMetadata means ui5-workspace.yaml resolved only | ||
| // non-framework libraries, so the configured/overridden `version` still applies. | ||
| const workspaceContributedFramework = Boolean(workspace) && | ||
| Object.keys(providedLibraryMetadata).length > 0; | ||
|
|
||
| // Without a workspace contribution, `version` is the effective framework version resolved | ||
| // above (it already reflects --framework-version and the ui5.yaml config). With a workspace | ||
| // contribution that config is ignored and the type is derived from the libraries the | ||
| // workspace actually provided (not the potentially stale ui5.yaml framework name): any | ||
| // @sapui5/ library means SAPUI5, which has no reliable distribution version and is left | ||
| // empty; otherwise OpenUI5 reports the sap.ui.core version. | ||
| let resolvedFrameworkVersion; | ||
| if (workspaceContributedFramework) { | ||
| const hasSapui5Library = Object.values(providedLibraryMetadata) | ||
| .some((metadata) => metadata.id?.startsWith("@sapui5/")); | ||
| if (hasSapui5Library) { | ||
| resolvedFrameworkVersion = ""; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does having
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! TBH, I didn't consider external projects for that scenario and now this makes more sense. I have pushed a fix for that with 4f0bd4a
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder whether the updated logic is working as intended in all scenarios. |
||
| } else { | ||
| // OpenUI5: sap.ui.core's version IS the framework version, and is correct whether | ||
| // sap.ui.core was overridden by the workspace or installed from the dist. | ||
| // Falls back to `version` if sap.ui.core is absent. | ||
| resolvedFrameworkVersion = projectGraph.getProject("sap.ui.core")?.getVersion() ?? version ?? ""; | ||
| } | ||
| } else { | ||
| resolvedFrameworkVersion = version; | ||
| } | ||
| projectGraph.setResolvedFrameworkVersion(resolvedFrameworkVersion); | ||
|
|
||
| // Emit after workspace-aware resolution so the version reflects the actual resolved | ||
| // version (e.g. the linked sap.ui.core for OpenUI5 workspace) rather than the | ||
| // configured ui5.yaml version that may differ. | ||
| // Always emit when the workspace contributed framework libraries (framework name is known | ||
| // even if version is ""), and when no such contribution but a concrete version was resolved. | ||
| if (workspaceContributedFramework || resolvedFrameworkVersion) { | ||
| process.emit("ui5.project-framework-resolved", { | ||
| framework: { | ||
| name: frameworkName, | ||
| version: resolvedFrameworkVersion, | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| return projectGraph; | ||
| }, | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really an accurate information? It only states that there are libraries in the workspace resolution, but it doesn't mean that they will be used by our graph (e.g. when they are available, but the project doesn't need them).