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

[INTERNAL] Add workspace arguments #602

Merged
merged 2 commits into from
Feb 2, 2023
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
21 changes: 18 additions & 3 deletions lib/cli/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export default function(cli) {
cli.usage("Usage: ui5 <command> [options]")
.demandCommand(1, "Command required! Please have a look at the help documentation above.")
.option("config", {
alias: "c",
describe: "Path to project configuration file in YAML format",
type: "string"
})
Expand All @@ -13,6 +14,16 @@ export default function(cli) {
"This option will disable resolution of node package dependencies.",
type: "string"
})
.option("workspace-config", {
describe: "Path to workspace configuration file in YAML format",
type: "string"
})
.option("workspace", {
alias: "w",
describe: "Name of the workspace configuration to use",
default: "default",
type: "string"
})
.option("loglevel", {
alias: "log-level",
describe: "Set the logging level (silent|error|warn|info|perf|verbose|silly).",
Expand All @@ -37,7 +48,7 @@ export default function(cli) {
})
.coerce([
// base.js
"config", "dependency-definition", "log-level",
"config", "dependency-definition", "workspace-config", "workspace", "log-level",

// tree.js, build.js & serve.js
"framework-version",
Expand Down Expand Up @@ -66,10 +77,14 @@ export default function(cli) {
.strict(true)
.alias("help", "h")
.alias("version", "v")
.example("ui5 <command> --translator static:/path/to/projectDependencies.yaml",
"Execute command using a \"static\" translator with translator parameters")
.example("ui5 <command> --dependency-definition /path/to/projectDependencies.yaml",
"Execute command using a static dependency tree instead of resolving node package dependencies")
.example("ui5 <command> --config /path/to/ui5.yaml",
"Execute command using a project configuration from custom path")
.example("ui5 <command> --workspace dolphin",
"Execute command using the 'dolphin' workspace of a ui5-workspace.yaml")
.example("ui5 <command> --log-level silly",
"Execute command with the maximum log output")
.fail(function(msg, err, yargs) {
if (err) {
// Exception
Expand Down
4 changes: 3 additions & 1 deletion lib/cli/commands/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ async function handleBuild(argv) {
} else {
graph = await graphFromPackageDependencies({
rootConfigPath: argv.config,
versionOverride: argv.frameworkVersion
versionOverride: argv.frameworkVersion,
workspaceConfigPath: argv.workspaceConfig,
workspaceName: argv.workspace === false ? null : argv.workspace,
});
}
const buildSettings = graph.getRoot().getBuilderSettings() || {};
Expand Down
4 changes: 3 additions & 1 deletion lib/cli/commands/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ serve.handler = async function(argv) {
} else {
graph = await graphFromPackageDependencies({
rootConfigPath: argv.config,
versionOverride: argv.frameworkVersion
versionOverride: argv.frameworkVersion,
workspaceConfigPath: argv.workspaceConfig,
workspaceName: argv.workspace === false ? null : argv.workspace,
});
}

Expand Down
4 changes: 3 additions & 1 deletion lib/cli/commands/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ tree.handler = async function(argv) {
} else {
graph = await graphFromPackageDependencies({
rootConfigPath: argv.config,
versionOverride: argv.frameworkVersion
versionOverride: argv.frameworkVersion,
workspaceConfigPath: argv.workspaceConfig,
workspaceName: argv.workspace === false ? null : argv.workspace,
});
}

Expand Down
70 changes: 65 additions & 5 deletions test/lib/cli/commands/build.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import path from "node:path";
import test from "ava";
import sinon from "sinon";
import esmock from "esmock";
Expand Down Expand Up @@ -123,7 +124,9 @@ test.serial("ui5 build --framework-version", async (t) => {
graphFromPackageDependenciesStub.getCall(0).args[0],
{
rootConfigPath: undefined,
versionOverride: "1.99.0"
versionOverride: "1.99.0",
workspaceConfigPath: undefined,
workspaceName: undefined,
}, "generateProjectGraph.graphFromPackageDependencies got called with expected arguments"
);
});
Expand All @@ -139,7 +142,64 @@ test.serial("ui5 build --config", async (t) => {
graphFromPackageDependenciesStub.getCall(0).args[0],
{
rootConfigPath: "ui5-test.yaml",
versionOverride: undefined
versionOverride: undefined,
workspaceConfigPath: undefined,
workspaceName: undefined,
}, "generateProjectGraph.graphFromPackageDependencies got called with expected arguments"
);
});

test.serial("ui5 build --workspace", async (t) => {
const {build, argv, graphFromPackageDependenciesStub} = t.context;

argv.workspace = "dolphin";

await build.handler(argv);

t.deepEqual(
graphFromPackageDependenciesStub.getCall(0).args[0],
{
rootConfigPath: undefined,
versionOverride: undefined,
workspaceConfigPath: undefined,
workspaceName: "dolphin",
}, "generateProjectGraph.graphFromPackageDependencies got called with expected arguments"
);
});

test.serial("ui5 build --no-workspace", async (t) => {
const {build, argv, graphFromPackageDependenciesStub} = t.context;

argv.workspace = false;

await build.handler(argv);

t.deepEqual(
graphFromPackageDependenciesStub.getCall(0).args[0],
{
rootConfigPath: undefined,
versionOverride: undefined,
workspaceConfigPath: undefined,
workspaceName: null,
}, "generateProjectGraph.graphFromPackageDependencies got called with expected arguments"
);
});

test.serial("ui5 build --workspace-config", async (t) => {
const {build, argv, graphFromPackageDependenciesStub} = t.context;

const fakePath = path.join("/", "path", "to", "ui5-workspace.yaml");
argv.workspaceConfig = fakePath;

await build.handler(argv);

t.deepEqual(
graphFromPackageDependenciesStub.getCall(0).args[0],
{
rootConfigPath: undefined,
versionOverride: undefined,
workspaceConfigPath: fakePath,
workspaceName: undefined,
}, "generateProjectGraph.graphFromPackageDependencies got called with expected arguments"
);
});
Expand All @@ -156,7 +216,7 @@ test.serial("ui5 build --dependency-definition", async (t) => {
{
filePath: "dependencies.yaml",
rootConfigPath: undefined,
versionOverride: undefined
versionOverride: undefined,
}, "generateProjectGraph.graphFromStaticFile got called with expected arguments"
);
});
Expand All @@ -174,7 +234,7 @@ test.serial("ui5 build --dependency-definition --config", async (t) => {
{
filePath: "dependencies.yaml",
rootConfigPath: "ui5-test.yaml",
versionOverride: undefined
versionOverride: undefined,
}, "generateProjectGraph.graphFromStaticFile got called with expected arguments"
);
});
Expand All @@ -193,7 +253,7 @@ test.serial("ui5 build --dependency-definition --config --framework-version", as
{
filePath: "dependencies.yaml",
rootConfigPath: "ui5-test.yaml",
versionOverride: "1.99.0"
versionOverride: "1.99.0",
}, "generateProjectGraph.graphFromStaticFile got called with expected arguments"
);
});
Expand Down
Loading