From 936e6a714c68d1270391189f68467659d3aadec4 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Thu, 30 Nov 2023 13:43:15 +0200 Subject: [PATCH] Migrate from boolean flag to enum --- lib/cli/commands/build.js | 18 +++++++++--------- test/lib/cli/commands/build.js | 9 +++++---- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/lib/cli/commands/build.js b/lib/cli/commands/build.js index 8a4cd4ad..b5c98fa5 100644 --- a/lib/cli/commands/build.js +++ b/lib/cli/commands/build.js @@ -121,16 +121,16 @@ build.builder = function(cli) { default: false, type: "boolean" }) - .option("flat-output", { + .option("output-style", { describe: - "Write the build results into a flat directory structure, omitting the project" + - "namespace and the \"resources\" directory." + - "This is currently only supported for projects of type 'library' and projects of " + - "type 'application' always result in flat output." + + "The way build results into a specific directory structure. " + + "\"Flat\" omits the project namespace and the \"resources\" directory. This is" + + " currently only supported for projects of type 'library'. Projects of " + + "type 'application' always have a default result as a flat output." + "No other dependencies can be included in the build result.", - // We need to explicitly check wether the falsy value is explicit or not for project type "application" - // default: false, - type: "boolean" + type: "string", + default: "Default", + choices: ["Default", "Flat", "Namespace"], }) .example("ui5 build", "Preload build for project without dependencies") .example("ui5 build self-contained", "Self-contained build for project") @@ -188,7 +188,7 @@ async function handleBuild(argv) { includedTasks: argv["include-task"], excludedTasks: argv["exclude-task"], cssVariables: argv["experimental-css-variables"], - flatOutput: argv["flat-output"], + outputStyle: argv["output-style"], }); } diff --git a/test/lib/cli/commands/build.js b/test/lib/cli/commands/build.js index 751a0097..068bae81 100644 --- a/test/lib/cli/commands/build.js +++ b/test/lib/cli/commands/build.js @@ -25,6 +25,7 @@ function getDefaultArgv() { "experimentalCssVariables": false, "cache-mode": "Default", "cacheMode": "Default", + "output-style": "Default", "$0": "ui5" }; } @@ -51,7 +52,7 @@ function getDefaultBuilderArgs() { includedTasks: undefined, excludedTasks: undefined, cssVariables: false, - flatOutput: undefined + outputStyle: "Default" }; } @@ -366,14 +367,14 @@ test.serial("ui5 build --experimental-css-variables", async (t) => { "Build with activated CSS Variables is called with expected arguments"); }); -test.serial("ui5 build --flat-output", async (t) => { +test.serial("ui5 build --output-style", async (t) => { const {build, argv, builder, expectedBuilderArgs} = t.context; - argv["flat-output"] = true; + argv["output-style"] = "Flat"; await build.handler(argv); - expectedBuilderArgs.flatOutput = true; + expectedBuilderArgs.outputStyle = "Flat"; t.deepEqual(builder.getCall(0).args[0], expectedBuilderArgs, "Build with activated flatOutput is called with expected arguments"); });