fix(create): exclude demo files and better-auth integrations when demo is disabled#431
fix(create): exclude demo files and better-auth integrations when demo is disabled#431WaryaWayne wants to merge 2 commits intoTanStack:mainfrom
Conversation
…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).
📝 WalkthroughWalkthroughThe changes rename a helper function from Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 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. ✨ Finishing Touches🧪 Generate unit tests (beta)
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.
🧹 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 singlehasBetterAuthDemoRouteEJS 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
📒 Files selected for processing (3)
packages/create/src/create-app.tspackages/create/src/frameworks/react/add-ons/better-auth/assets/src/integrations/better-auth/header-user.tsx.ejspackages/create/src/frameworks/solid/add-ons/better-auth/assets/src/integrations/better-auth/header-user.tsx.ejs
Summary
components/,lib/,hooks/, anddata/were still being created.isDemoRoutePath→isDemoFilePathand extended pattern matching to cover all non-route demo paths./demo/better-auth, a route that doesn't exist without demo files. Convertedthem to EJS templates that conditionally render
nullwhen demo is disabled.isDemoFilePathfiltering to also cover add-on integration files.Test plan
components/,lib/,hooks/, ordata/Summary by CodeRabbit
New Features
Bug Fixes