refactor frontend flag handling in stack builder to combine web and native frontends (#257)

This commit is contained in:
ga1az
2025-05-13 21:57:47 -04:00
committed by GitHub
parent 4131bbfd07
commit dad201e705

View File

@@ -790,34 +790,19 @@ const generateCommand = (stackState: StackState): string => {
value: StackState[K],
) => isStackDefault(stackState, key, value);
if (!checkDefault("webFrontend", stackState.webFrontend)) {
if (
stackState.webFrontend.length === 0 ||
stackState.webFrontend[0] === "none"
) {
const combinedFrontends = [
...stackState.webFrontend,
...stackState.nativeFrontend,
].filter((v, _, arr) => v !== "none" || arr.length === 1);
if (
!checkDefault("webFrontend", stackState.webFrontend) ||
!checkDefault("nativeFrontend", stackState.nativeFrontend)
) {
if (combinedFrontends.length === 0 || combinedFrontends[0] === "none") {
flags.push("--frontend none");
} else {
flags.push(`--frontend ${stackState.webFrontend.join(" ")}`);
}
}
if (!checkDefault("nativeFrontend", stackState.nativeFrontend)) {
if (
stackState.nativeFrontend.length > 0 &&
stackState.nativeFrontend[0] !== "none"
) {
if (checkDefault("webFrontend", stackState.webFrontend)) {
flags.push(`--frontend ${stackState.nativeFrontend.join(" ")}`);
} else {
const existingFrontendIndex = flags.findIndex((f) =>
f.startsWith("--frontend "),
);
if (existingFrontendIndex !== -1) {
flags[existingFrontendIndex] += ` ${stackState.nativeFrontend.join(
" ",
)}`;
}
}
flags.push(`--frontend ${combinedFrontends.join(" ")}`);
}
}