Skip to content
Source
Sign inSign up
TanStack/cli

fix(create): exclude demo files and better-auth integrations when demo is disabled #431

ClosedWaryaWayne(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/431/headopened

Summary

  • Previously, only demo route files were filtered when users opted out of demo files. Files in components/, lib/, hooks/, and data/ were still being created.
  • Renamed isDemoRoutePath → isDemoFilePath and extended pattern matching to cover all non-route demo paths.
  • The Better Auth header/user components referenced /demo/better-auth, a route that doesn't exist without demo files. Converted them to EJS templates that conditionally render null when demo is disabled.
  • Extended isDemoFilePath filtering to also cover add-on integration files.

Test plan

  • Create app with Better Auth add-on, opt out of demo — header/user components should render without broken route links
  • Create app without demo — verify no demo files appear in components/, lib/, hooks/, or data/
  • Create app with demo — verify all demo files still present

Summary by CodeRabbit

  • New Features

    • Enhanced demo content detection to recognize demo files across additional directories.
  • Bug Fixes

    • Fixed conditional rendering of demo integrations to properly display only when demo routes are available.
    1. 📝 Walkthrough

      Walkthrough

      The changes rename a helper function from isDemoRoutePath to isDemoFilePath and expand its pattern matching to detect demo files across /lib, /hooks, /data, and /components directories in addition to /routes. Template files for the better-auth integration are updated to conditionally render demo-related UI elements based on route availability.

      Changes

      Cohort / File(s)Summary
      Demo file detection expansion
      packages/create/src/create-app.ts
      Renamed isDemoRoutePath to isDemoFilePath and broadened matching logic to identify demo patterns in /lib/demo*, /hooks/demo*, /data/demo*, /components/demo*, /routes/demo*, and /routes/example* paths. Updated stripExamplesFromOptions to filter routes, integrations, and file lists using the expanded predicate.
      Better-auth template conditionals
      packages/create/src/frameworks/react/add-ons/better-auth/assets/src/integrations/better-auth/header-user.tsx.ejs, packages/create/src/frameworks/solid/add-ons/better-auth/assets/src/integrations/better-auth/header-user.tsx.ejs
      Added conditional imports and rendering for the Link component and sign-in UI. Components now check for /demo/better-auth route presence before importing and rendering demo-specific content.

      Estimated code review effort

      🎯 2 (Simple) | ⏱️ ~12 minutes

      Poem

      🐰 Files once filtered by routes alone, Now demo paths are wider known— Through hooks and libs and data's way, Templates show their links by day! ✨

      🚥 Pre-merge checks | ✅ 2 | ❌ 1

      ❌ Failed checks (1 warning)

      Check nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring 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 nameStatusExplanation
      Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
      Title check✅ PassedThe title accurately and specifically describes the main change: excluding demo files and better-auth integrations when demo is disabled. It directly reflects the core functionality changes across multiple files.
      ✏️ Tip: You can configure your own custom pre-merge checks in the settings.
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests

      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.
    2. 🧹 Nitpick comments (2)
      packages/create/src/frameworks/solid/add-ons/better-auth/assets/src/integrations/better-auth/header-user.tsx.ejs (1)

      2-4: Optional: reuse a single hasBetterAuthDemoRoute EJS flag.

      This keeps the template easier to maintain and avoids duplicating the same route check twice.

      ♻️ Suggested cleanup
      +<%_ const hasBetterAuthDemoRoute = routes.some((r) => r.url === '/demo/better-auth') _%>
      -<%_ if (routes.some(r => r.url === '/demo/better-auth')) { _%>
      +<%_ if (hasBetterAuthDemoRoute) { _%>
       import { Link } from "@tanstack/solid-router";
       <%_ } _%>
      @@
      -<%_ if (routes.some(r => r.url === '/demo/better-auth')) { _%>
      +<%_ if (hasBetterAuthDemoRoute) { _%>
               fallback={

      Also applies to: 19-28

      🤖 Prompt for AI Agents
      Verify each finding against the current code and only fix it if needed.
      
      In
      `@packages/create/src/frameworks/solid/add-ons/better-auth/assets/src/integrations/better-auth/header-user.tsx.ejs`
      around lines 2 - 4, Define a reusable EJS boolean flag (e.g.,
      hasBetterAuthDemoRoute) at the top of the header-user.tsx.ejs template by
      evaluating routes.some(r => r.url === '/demo/better-auth') once, then replace
      the duplicated inline checks with that flag (use hasBetterAuthDemoRoute wherever
      the template currently checks routes.some(...)); this centralizes the route
      check and removes duplicated logic while preserving the existing imports and
      conditional rendering.
      packages/create/src/frameworks/react/add-ons/better-auth/assets/src/integrations/better-auth/header-user.tsx.ejs (1)

      2-4: Optional: compute the demo-route predicate once in EJS.

      You can reduce duplication by assigning routes.some(...) to one EJS variable and reusing it for both the import and return branch.

      ♻️ Suggested cleanup
      +<%_ const hasBetterAuthDemoRoute = routes.some((r) => r.url === '/demo/better-auth') _%>
      -<%_ if (routes.some(r => r.url === '/demo/better-auth')) { _%>
      +<%_ if (hasBetterAuthDemoRoute) { _%>
       import { Link } from "@tanstack/react-router";
       <%_ } _%>
      @@
      -<%_ if (routes.some(r => r.url === '/demo/better-auth')) { _%>
      +<%_ if (hasBetterAuthDemoRoute) { _%>
         return (

      Also applies to: 39-50

      🤖 Prompt for AI Agents
      Verify each finding against the current code and only fix it if needed.
      
      In
      `@packages/create/src/frameworks/react/add-ons/better-auth/assets/src/integrations/better-auth/header-user.tsx.ejs`
      around lines 2 - 4, Assign the predicate routes.some(r => r.url ===
      '/demo/better-auth') to a single EJS variable (e.g., hasDemoRoute) at the top of
      the template and reuse that variable wherever the template currently calls
      routes.some(...): in the conditional import of Link and in the conditional JSX
      branch that renders the demo route link (the return branch containing the demo
      link), so the check is computed once and duplicated calls are removed.
      🤖 Prompt for all review comments with AI agents
      Verify each finding against the current code and only fix it if needed.
      
      Nitpick comments:
      In
      `@packages/create/src/frameworks/react/add-ons/better-auth/assets/src/integrations/better-auth/header-user.tsx.ejs`:
      - Around line 2-4: Assign the predicate routes.some(r => r.url ===
      '/demo/better-auth') to a single EJS variable (e.g., hasDemoRoute) at the top of
      the template and reuse that variable wherever the template currently calls
      routes.some(...): in the conditional import of Link and in the conditional JSX
      branch that renders the demo route link (the return branch containing the demo
      link), so the check is computed once and duplicated calls are removed.
      
      In
      `@packages/create/src/frameworks/solid/add-ons/better-auth/assets/src/integrations/better-auth/header-user.tsx.ejs`:
      - Around line 2-4: Define a reusable EJS boolean flag (e.g.,
      hasBetterAuthDemoRoute) at the top of the header-user.tsx.ejs template by
      evaluating routes.some(r => r.url === '/demo/better-auth') once, then replace
      the duplicated inline checks with that flag (use hasBetterAuthDemoRoute wherever
      the template currently checks routes.some(...)); this centralizes the route
      check and removes duplicated logic while preserving the existing imports and
      conditional rendering.

      ℹ️ Review info
      ⚙️ Run configuration

      Configuration used: defaults

      Review profile: CHILL

      Plan: Pro

      Run ID: 6de00b7d-c6d5-4218-ac89-ea1b51b9dadd

      📥 Commits

      Reviewing files that changed from the base of the PR and between 523c99936ad3b8c67164c0d81e00404e5d9c7013 and 72f787e5e6436e3c3225b97e27687f7663558fe1.

      📒 Files selected for processing (3)
      • packages/create/src/create-app.ts
      • packages/create/src/frameworks/react/add-ons/better-auth/assets/src/integrations/better-auth/header-user.tsx.ejs
      • packages/create/src/frameworks/solid/add-ons/better-auth/assets/src/integrations/better-auth/header-user.tsx.ejs
    3. Hi @WaryaWayne — thanks for this! I've folded your two commits (with author credit preserved) into #434 along with @wyMinLwin's related work from #429 and some additional edge-case coverage (/store/, /public/, src/demo.index.css). Feel free to close this one once #434 lands.

Sign in to join this conversation.