Skip to content

Commit

Permalink
[INTERNAL] ui5Framework: Use Workspace to override paths of single nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomByte committed Nov 15, 2022
1 parent 3c403b0 commit 47c9a4e
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lib/graph/helpers/ui5Framework.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import logger from "@ui5/logger";
const log = logger.getLogger("graph:helpers:ui5Framework");

class ProjectProcessor {
constructor({libraryMetadata}) {
constructor({libraryMetadata, workspace}) {
this._libraryMetadata = libraryMetadata;
this._workspace = workspace;
this._projectGraphPromises = Object.create(null);
}
async addProjectToGraph(libName, projectGraph) {
Expand All @@ -22,7 +23,7 @@ class ProjectProcessor {
throw new Error(`Failed to find library ${libName} in dist packages metadata.json`);
}

const depMetadata = this._libraryMetadata[libName];
let depMetadata = this._libraryMetadata[libName];

if (projectGraph.getProject(depMetadata.id)) {
// Already added
Expand All @@ -46,6 +47,14 @@ class ProjectProcessor {
dependencies.push(...resolvedOptionals.filter(($)=>$));
}

if (this._workspace) {
const workspaceNode = await this._workspace.getNode(depMetadata.id);
if (workspaceNode) {
log.verbose(`Resolved module ${workspaceNode.id} via workspace ${this._workspace.getName()}`);
depMetadata = workspaceNode;
}
}

const ui5Module = new Module({
id: depMetadata.id,
version: depMetadata.version,
Expand Down Expand Up @@ -131,6 +140,8 @@ export default {
* @param {object} [options]
* @param {string} [options.versionOverride] Framework version to use instead of the root projects framework
* version from the provided <code>tree</code>
* @param {@ui5/project/graph/Workspace} [options.workspace]
* Optional workspace instance to use for overriding node resolutions
* @returns {Promise<@ui5/project/graph/ProjectGraph>}
* Promise resolving with the given graph instance to allow method chaining
*/
Expand Down Expand Up @@ -212,7 +223,8 @@ export default {
}

const projectProcessor = new utils.ProjectProcessor({
libraryMetadata
libraryMetadata,
workspace: options.workspace
});

const frameworkGraph = new ProjectGraph({
Expand Down

0 comments on commit 47c9a4e

Please sign in to comment.