fix(create): exclude demo files and better-auth integrations when demo is disabled #431
main fromrefs/pull/431/head·opened Summary#
- Previously, only demo route files were filtered when users opted out of demo files. Files in
components/,lib/,hooks/, anddata/were still being created. - Renamed
isDemoRoutePath→isDemoFilePathand 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 rendernullwhen demo is disabled. - Extended
isDemoFilePathfiltering 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/, ordata/ - 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
🧹 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📥 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.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
Thank you Tanner. Take care.
WaryaWayne(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
📝 Walkthrough
Walkthrough#
The changes rename a helper function from
isDemoRoutePathtoisDemoFilePathand expand its pattern matching to detect demo files across/lib,/hooks,/data, and/componentsdirectories 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#
packages/create/src/create-app.tsisDemoRoutePathtoisDemoFilePathand broadened matching logic to identify demo patterns in/lib/demo*,/hooks/demo*,/data/demo*,/components/demo*,/routes/demo*, and/routes/example*paths. UpdatedstripExamplesFromOptionsto filter routes, integrations, and file lists using the expanded predicate.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.ejsLinkcomponent and sign-in UI. Components now check for/demo/better-authroute presence before importing and rendering demo-specific content.Estimated code review effort#
🎯 2 (Simple) | ⏱️ ~12 minutes
Poem#
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (2 passed)
✨ 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.
❤️ Share