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

[FEATURE] Add option to redefine output directory structure #665

Merged
merged 12 commits into from
Dec 12, 2023
17 changes: 16 additions & 1 deletion lib/cli/commands/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,20 @@ build.builder = function(cli) {
default: false,
type: "boolean"
})
.option("output-style", {
describe:
"Processes 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 result in a flat output." +
"No other dependencies can be included in the build result.",
d3xter666 marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other dependencies can be included now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how deep into details should we go here. Hopefully, now is ok

type: "string",
default: "Default",
choices: ["Default", "Flat", "Namespace"],
d3xter666 marked this conversation as resolved.
Show resolved Hide resolved
})
.coerce("output-style", (opt) => {
return opt.charAt(0).toUpperCase() + opt.slice(1).toLowerCase();
})
.example("ui5 build", "Preload build for project without dependencies")
.example("ui5 build self-contained", "Self-contained build for project")
.example("ui5 build --exclude-task=* --include-task=minify generateComponentPreload",
Expand Down Expand Up @@ -176,7 +190,8 @@ async function handleBuild(argv) {
jsdoc: command === "jsdoc",
includedTasks: argv["include-task"],
excludedTasks: argv["exclude-task"],
cssVariables: argv["experimental-css-variables"]
cssVariables: argv["experimental-css-variables"],
outputStyle: argv["output-style"],
});
}

Expand Down
16 changes: 15 additions & 1 deletion test/lib/cli/commands/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function getDefaultArgv() {
"experimentalCssVariables": false,
"cache-mode": "Default",
"cacheMode": "Default",
"output-style": "Default",
"$0": "ui5"
};
}
Expand All @@ -50,7 +51,8 @@ function getDefaultBuilderArgs() {
jsdoc: false,
includedTasks: undefined,
excludedTasks: undefined,
cssVariables: false
cssVariables: false,
outputStyle: "Default"
};
}

Expand Down Expand Up @@ -364,3 +366,15 @@ test.serial("ui5 build --experimental-css-variables", async (t) => {
t.deepEqual(builder.getCall(0).args[0], expectedBuilderArgs,
"Build with activated CSS Variables is called with expected arguments");
});

test.serial("ui5 build --output-style", async (t) => {
d3xter666 marked this conversation as resolved.
Show resolved Hide resolved
const {build, argv, builder, expectedBuilderArgs} = t.context;

argv["output-style"] = "Flat";

await build.handler(argv);

expectedBuilderArgs.outputStyle = "Flat";
t.deepEqual(builder.getCall(0).args[0], expectedBuilderArgs,
"Build with activated outputStyle='Flat' is called with expected arguments");
});
Loading