Skip to content
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

[BREAKING] Set default workspaceName to "default" for API usage #706

Merged
merged 4 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
d3xter666 marked this conversation as resolved.
Show resolved Hide resolved
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
Loading