Skip to content

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

Open
WaryaWayne wants to merge 2 commits intoTanStack:mainfrom
WaryaWayne:main
Open

fix(create): exclude demo files and better-auth integrations when demo is disabled#431
WaryaWayne wants to merge 2 commits intoTanStack:mainfrom
WaryaWayne:main

Conversation

@WaryaWayne
Copy link
Copy Markdown
Contributor

@WaryaWayne WaryaWayne commented Apr 15, 2026

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

…hen demo is disabled

Previously only demo route files were filtered out when the user chose
no demo files. Demo files in components/, lib/, hooks/, and data/
directories would still be created. Rename isDemoRoutePath to
isDemoFilePath to reflect the broader scope and extend pattern matching
to cover all non-route demo file paths.
…disabled

The better-auth header-user components reference the /demo/better-auth route,
which doesn't exist when users opt out of demo files. Convert these to EJS
templates with conditional rendering so they return null instead of linking
to a non-existent route. Also extend isDemoFilePath filtering to cover
add-on integration files (previously only routes, lib, hooks, data, and
components were filtered in a037c4d).
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 15, 2026

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

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 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 523c999 and 72f787e.

📒 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

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