mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
refactor frontend flag handling in stack builder to combine web and native frontends (#257)
This commit is contained in:
@@ -790,34 +790,19 @@ const generateCommand = (stackState: StackState): string => {
|
|||||||
value: StackState[K],
|
value: StackState[K],
|
||||||
) => isStackDefault(stackState, key, value);
|
) => isStackDefault(stackState, key, value);
|
||||||
|
|
||||||
if (!checkDefault("webFrontend", stackState.webFrontend)) {
|
const combinedFrontends = [
|
||||||
if (
|
...stackState.webFrontend,
|
||||||
stackState.webFrontend.length === 0 ||
|
...stackState.nativeFrontend,
|
||||||
stackState.webFrontend[0] === "none"
|
].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");
|
flags.push("--frontend none");
|
||||||
} else {
|
} else {
|
||||||
flags.push(`--frontend ${stackState.webFrontend.join(" ")}`);
|
flags.push(`--frontend ${combinedFrontends.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(
|
|
||||||
" ",
|
|
||||||
)}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user