Repository navigation
Refactor stack builder and CLI command boundaries - #869
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. WalkthroughExtracts CLI history and meta command handlers; replaces a monolithic StackBuilder with modular hook-and-component implementation; updates web prebuild/dependencies; adjusts turbo tasks; removes a debug sign-up log; and bumps a few package dependency versions. Changes
Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (8)
apps/cli/src/utils/get-latest-cli-version.ts (1)
8-8: Remove the explicit return type to comply with coding guidelines.The return type
Result<string | undefined, CLIError>is inferrable fromResult.try(...)and the changed line carries an explicit annotation. Since this line was modified in this PR, consider dropping it.Suggested fix
-export function getLatestCLIVersionResult(): Result<string | undefined, CLIError> { +export function getLatestCLIVersionResult() {As per coding guidelines,
**/*.{ts,tsx}: "Do not use explicit return types".apps/cli/src/commands/history.ts (1)
13-46: Remove explicit return types from functions.
formatStackSummary,formatDate, andhistoryHandlerall declare explicit return types (: string,: string,: Promise<void>). TypeScript can infer these.Suggested fix
-function formatStackSummary(entry: ProjectHistoryEntry): string { +function formatStackSummary(entry: ProjectHistoryEntry) {-function formatDate(isoString: string): string { +function formatDate(isoString: string) {-export async function historyHandler(input: HistoryCommandInput): Promise<void> { +export async function historyHandler(input: HistoryCommandInput) {As per coding guidelines, "Do not use explicit return types".
apps/web/src/app/(home)/new/_components/stack-builder/tech-categories.tsx (2)
25-38: Remove explicit return type.Suggested fix
-function getIsSelected(stack: StackState, category: keyof StackState, techId: string): boolean { +function getIsSelected(stack: StackState, category: keyof StackState, techId: string) {As per coding guidelines, "Do not use explicit return types".
117-131: Disabled cards remain clickable — consider adding a guard orpointer-events-none.The card's
onClickfires even whenisDisabledis true. WhilehandleTechSelectinuse-stack-builder.tsguards against incompatible selections, the card still shows a tap animation (whileTap={{ scale: 0.98 }}) on disabled items, which can confuse users.Suggested fix
whileHover={isDesktop ? { scale: 1.02 } : undefined} - whileTap={{ scale: 0.98 }} - onClick={() => onSelect(categoryKey as keyof typeof TECH_OPTIONS, tech.id)} + whileTap={isDisabled ? undefined : { scale: 0.98 }} + onClick={isDisabled ? undefined : () => onSelect(categoryKey as keyof typeof TECH_OPTIONS, tech.id)}apps/web/src/app/(home)/new/_components/stack-builder/selected-stack-badges.tsx (1)
65-73: Theauthcategory check on Line 69 is dead logic.Auth option IDs are
"better-auth","clerk","none"— never"true". Thetech.id === "true"guard only applies togitandinstall, so includingauthhere has no effect and is misleading.Suggested fix
if ( !tech || tech.id === "none" || tech.id === "false" || - ((category === "git" || category === "install" || category === "auth") && + ((category === "git" || category === "install") && tech.id === "true") ) {apps/web/src/app/(home)/new/_components/stack-builder/index.tsx (1)
196-196:getStackUrl()is called on every render.
getStackUrl()recomputes the sharing URL each time the component renders. IfShareButtonis frequently visible, consider memoizing or lifting this computation into the hook as a derived value.apps/web/src/app/(home)/new/_components/stack-builder/use-stack-builder.ts (2)
30-30:lastChangesstate is never read — dead state.The value from
useStateis destructured away (, setLastChanges), andsetLastChangesis only called at Line 91 but the stored value is never consumed anywhere. This entire state can be removed.Suggested fix
- const [, setLastChanges] = useState<Array<{ category: string; message: string }>>([]);And remove the setter call at Line 91:
- setLastChanges(compatibilityAnalysis.changes);
12-22: Remove explicit return types.
formatProjectName,withFormattedProjectName, andgetStackUrlall have explicit return types that can be inferred.Suggested fix
-function formatProjectName(name: string): string { +function formatProjectName(name: string) { -function withFormattedProjectName(stack: StackState): StackState { +function withFormattedProjectName(stack: StackState) { - function getStackUrl(): string { + function getStackUrl() {As per coding guidelines, "Do not use explicit return types".
Also applies to: 102-105
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (3)
apps/web/src/app/(home)/new/_components/stack-builder/index.tsx (2)
63-103: Consider extracting the repeated mobile tab buttons.The three mobile tab buttons share identical structure and className logic, differing only in the tab key, icon, and label. Extracting a small local helper (or a data-driven map) would reduce duplication.
♻️ Example refactor using a data-driven approach
+const MOBILE_TABS = [ + { key: "summary", icon: List, label: "Summary" }, + { key: "configure", icon: Terminal, label: "Configure" }, + { key: "preview", icon: FolderTree, label: "Preview" }, +] as const; + // Inside the JSX, replace the three <button> blocks with: - <button - type="button" - onClick={() => setMobileTab("summary")} - className={cn( - "flex flex-1 items-center justify-center gap-2 border-b-2 px-1 py-3 text-xs font-medium transition-all hover:bg-muted/50", - mobileTab === "summary" - ? "border-primary text-primary" - : "border-transparent text-muted-foreground hover:text-foreground", - )} - > - <List className="h-4 w-4" /> - <span>Summary</span> - </button> - {/* ...two more identical blocks... */} + {MOBILE_TABS.map(({ key, icon: Icon, label }) => ( + <button + key={key} + type="button" + onClick={() => setMobileTab(key)} + className={cn( + "flex flex-1 items-center justify-center gap-2 border-b-2 px-1 py-3 text-xs font-medium transition-all hover:bg-muted/50", + mobileTab === key + ? "border-primary text-primary" + : "border-transparent text-muted-foreground hover:text-foreground", + )} + > + <Icon className="h-4 w-4" /> + <span>{label}</span> + </button> + ))}
196-196:getStackUrl()is invoked on every render.If this function performs any non-trivial computation (e.g., serializing the full stack state), it will run on every render cycle. From the hook summary it appears lightweight, but worth confirming — if it's cheap, this is fine as-is.
apps/cli/src/utils/open-url.ts (1)
3-3: Remove the explicit return type.Proposed fix
-export async function openUrl(url: string): Promise<void> { +export async function openUrl(url: string) {As per coding guidelines, "Do not use explicit return types".
Summary
apps/cli/src/commandsprebuildstep fromapps/web/package.json(Turbo already resolves task dependencies)Why
Validation
bun checkbun test(inapps/cli) -> 394 passingbun test(inpackages/template-generator) -> 5 passingbun run build --filter=webSummary by CodeRabbit
New Features
Bug Fixes
Refactor
Chores