diff --git a/lib/graph/graph.js b/lib/graph/graph.js index 892c84068..1f77bbb58 100644 --- a/lib/graph/graph.js +++ b/lib/graph/graph.js @@ -29,8 +29,8 @@ const log = getLogger("generateProjectGraph"); * @param {string} [options.versionOverride] Framework version to use instead of the one defined in the root project * @param {string} [options.resolveFrameworkDependencies=true] * Whether framework dependencies should be added to the graph - * @param {string} [options.workspaceName] - * Name of the workspace configuration that should be used if any is provided + * @param {string|null} [options.workspaceName=default] + * Name of the workspace configuration that should be used. "default" if not provided. * @param {module:@ui5/project/ui5Framework/maven/CacheMode} [options.cacheMode] * Cache mode to use when consuming SNAPSHOT versions of a framework * @param {string} [options.workspaceConfigPath=ui5-workspace.yaml] @@ -43,7 +43,7 @@ const log = getLogger("generateProjectGraph"); export async function graphFromPackageDependencies({ cwd, rootConfiguration, rootConfigPath, versionOverride, cacheMode, resolveFrameworkDependencies = true, - workspaceName /* TODO 4.0: default workspaceName to "default" ? */, + workspaceName="default", workspaceConfiguration, workspaceConfigPath = "ui5-workspace.yaml" }) { log.verbose(`Creating project graph using npm provider...`); diff --git a/test/lib/graph/graph.js b/test/lib/graph/graph.js index c11bfbc88..4cc4c1386 100644 --- a/test/lib/graph/graph.js +++ b/test/lib/graph/graph.js @@ -58,7 +58,8 @@ test.serial("graphFromPackageDependencies", async (t) => { rootConfiguration: "rootConfiguration", rootConfigPath: "/rootConfigPath", versionOverride: "versionOverride", - cacheMode: CacheMode.Off + cacheMode: CacheMode.Off, + workspaceName: null }); t.is(res, "graph"); @@ -147,7 +148,8 @@ test.serial("graphFromPackageDependencies with workspace object", async (t) => { rootConfiguration: "rootConfiguration", rootConfigPath: "/rootConfigPath", versionOverride: "versionOverride", - workspaceConfiguration: "workspaceConfiguration" + workspaceConfiguration: "workspaceConfiguration", + workspaceName: null }); t.is(res, "graph"); @@ -156,7 +158,7 @@ test.serial("graphFromPackageDependencies with workspace object", async (t) => { t.deepEqual(createWorkspaceStub.getCall(0).args[0], { cwd: path.join(__dirname, "..", "..", "..", "cwd"), configPath: "ui5-workspace.yaml", - name: undefined, + name: null, configObject: "workspaceConfiguration" }, "createWorkspace called with correct parameters"); }); @@ -281,6 +283,24 @@ test.serial("graphFromPackageDependencies: Do not resolve framework dependencies t.is(enrichProjectGraphStub.callCount, 0, "enrichProjectGraph did not get called"); }); +test.serial("graphFromPackageDependencies: Default workspace name", async (t) => { + const {createWorkspaceStub} = t.context; + const {graphFromPackageDependencies} = t.context.graph; + + const res = await graphFromPackageDependencies({ + cwd: "cwd", + rootConfiguration: "rootConfiguration", + rootConfigPath: "/rootConfigPath", + versionOverride: "versionOverride", + resolveFrameworkDependencies: false + }); + + t.is(res, "graph"); + t.true(createWorkspaceStub.calledOnce, "createWorkspace is called"); + t.is(createWorkspaceStub.getCall(0).args[0].name, "default", + "createWorkspace is called with 'default' workspace"); +}); + test.serial("graphFromStaticFile", async (t) => { const { dependencyTreeProviderStub,