Skip to content

Commit

Permalink
[BREAKING] Set default workspaceName to "default" for API usage (#706)
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
Set default workspaceName to "default" for API usage
(#586)

JIRA: CPOUI5FOUNDATION-802
Relates to: SAP/ui5-tooling#701

---------

Co-authored-by: Matthias Oßwald <[email protected]>
  • Loading branch information
d3xter666 and matz3 authored Feb 29, 2024
1 parent 2af3249 commit a2d8f9d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/graph/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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...`);
Expand Down
26 changes: 23 additions & 3 deletions test/lib/graph/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand All @@ -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");
});
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit a2d8f9d

Please sign in to comment.