From dad201e705a57063648ac05c062e155ac0a183b7 Mon Sep 17 00:00:00 2001 From: ga1az Date: Tue, 13 May 2025 21:57:47 -0400 Subject: [PATCH] refactor frontend flag handling in stack builder to combine web and native frontends (#257) --- .../app/(home)/_components/stack-builder.tsx | 37 ++++++------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/apps/web/src/app/(home)/_components/stack-builder.tsx b/apps/web/src/app/(home)/_components/stack-builder.tsx index 6662901..f8b6705 100644 --- a/apps/web/src/app/(home)/_components/stack-builder.tsx +++ b/apps/web/src/app/(home)/_components/stack-builder.tsx @@ -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(" ")}`); } }