Skip to content

Refactor stack builder and CLI command boundaries - #869

Merged
AmanVarshney01 merged 6 commits into
mainfrom
aman/refactor-stack-builder-cli-cleanup
Feb 6, 2026
Merged

AmanVarshney01 merged 6 commits into
mainfrom
aman/refactor-stack-builder-cli-cleanup

Conversation

@AmanVarshney01

@AmanVarshney01 AmanVarshney01 commented Feb 6, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • split the web stack builder into a focused feature folder (index, hook, categories UI, selected badges)
  • extracted CLI command handlers for history/docs/builder/sponsors into apps/cli/src/commands
  • removed redundant prebuild step from apps/web/package.json (Turbo already resolves task dependencies)
  • removed credential logging from the Clerk native sign-up template and regenerated embedded templates

Why

  • improves maintainability by separating state orchestration from rendering
  • keeps CLI entrypoint slimmer and easier to extend
  • tightens template safety for generated auth flows

Validation

  • bun check
  • bun test (in apps/cli) -> 394 passing
  • bun test (in packages/template-generator) -> 5 passing
  • bun run build --filter=web

Summary by CodeRabbit

  • New Features

    • Added CLI history command (limit, clear, JSON output) plus commands to open docs, builder, and show sponsors.
    • Rebuilt Stack Builder UI with responsive mobile/desktop views, previews, presets, share/save/load, and new composable components and hook.
  • Bug Fixes

    • Removed credential-exposing debug log from signup template.
  • Refactor

    • Extracted CLI command handlers into dedicated modules.
  • Chores

    • Dependency/version bumps, build script tweaks, and task configuration updates.

@vercel

vercel Bot commented Feb 6, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
create-better-t-stack-web Ready Ready Preview, Comment Feb 6, 2026 6:47pm

Request Review

@coderabbitai

coderabbitai Bot commented Feb 6, 2026 •

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

Walkthrough

Extracts 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

Cohort / File(s) Summary
CLI: new commands & router wiring
apps/cli/src/commands/history.ts, apps/cli/src/commands/meta.ts, apps/cli/src/index.ts
Adds historyHandler and meta command handlers (showSponsorsCommand, openDocsCommand, openBuilderCommand), extracts inline logic from index.ts, and wires the new handlers into the CLI router.
CLI: utils
apps/cli/src/utils/get-latest-cli-version.ts, apps/cli/src/utils/open-url.ts
Minor type-annotation formatting change for getLatestCLIVersionResult; rewrites openUrl to use platform shell commands (darwin/windows/xdg-open) and removes previous Result-based flow.
Web: StackBuilder → modular components/hooks
apps/web/src/app/(home)/new/_components/stack-builder.tsx, apps/web/src/app/(home)/new/_components/stack-builder/index.tsx, apps/web/src/app/(home)/new/_components/stack-builder/use-stack-builder.ts, apps/web/src/app/(home)/new/_components/stack-builder/tech-categories.tsx, apps/web/src/app/(home)/new/_components/stack-builder/selected-stack-badges.tsx
Removes single-file StackBuilder and introduces a modular implementation: named StackBuilder, useStackBuilder hook, TechCategories, SelectedStackBadges, and related UI split across new files.
Web: import update
apps/web/src/app/(home)/new/page.tsx
Updates import to match StackBuilder now exported as a named export.
Web: package.json changes
apps/web/package.json
Adjusts prebuild to run grouped subshells; bumps many dependencies and devDependencies (React/Next/fumadocs/*/tools) and adds typescript.
Template-generator: remove credential log
packages/template-generator/src/templates.generated.ts, packages/template-generator/templates/auth/clerk/convex/native/base/app/(auth)/sign-up.tsx.hbs
Removes a debug console.log(emailAddress, password) from the sign-up template.
Monorepo task config
turbo.json
Adds generate-schema task (cache: false), extends build outputs to include templates-binary/**, and removes persistent: true from deploy and deploy:convex.
Backend deps bump
packages/backend/package.json
Bumps convex and convex-helpers versions.

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main changes: refactoring of the stack builder component structure and reorganization of CLI command handlers into separate modules.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 from Result.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, and historyHandler all 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 or pointer-events-none.

The card's onClick fires even when isDisabled is true. While handleTechSelect in use-stack-builder.ts guards 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: The auth category check on Line 69 is dead logic.

Auth option IDs are "better-auth", "clerk", "none" — never "true". The tech.id === "true" guard only applies to git and install, so including auth here 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. If ShareButton is 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: lastChanges state is never read — dead state.

The value from useState is destructured away (, setLastChanges), and setLastChanges is 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, and getStackUrl all 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

Comment thread apps/cli/src/commands/meta.ts Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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".

Comment thread apps/cli/src/utils/open-url.ts Resolved
Comment thread apps/cli/src/utils/open-url.ts Resolved
@AmanVarshney01
AmanVarshney01 merged commit 33af750 into main Feb 6, 2026
3 checks passed
@AmanVarshney01
AmanVarshney01 deleted the aman/refactor-stack-builder-cli-cleanup branch February 6, 2026 18:48

This branch was successfully deployed

1 active deployment
Preview — db631954 Deployed Feb 6, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant