-
-
Notifications
You must be signed in to change notification settings - Fork 166
fix(create): strip all demo/example files when users opt out #434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
810720b
9570758
d530fa3
e054017
e719c2a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| --- | ||
| '@tanstack/create': patch | ||
| --- | ||
|
|
||
| Fix demo/example files leaking into projects when users opt out of demo pages. | ||
|
|
||
| - Strip add-on demo support files in `src/lib/`, `src/hooks/`, `src/data/`, `src/components/`, `src/store/`, and any `demo.*` / `demo-*` / `example.*` / `example-*` files. | ||
| - Strip example image assets under `public/`. | ||
| - Generate a minimal base starter (no Header, Footer, ThemeToggle, about page, or styled index page) when declining demo/example pages. | ||
| - Render Better Auth header-user component as `null` when its demo route is excluded, instead of linking to a non-existent route. | ||
|
|
||
| Closes #422, #409. |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,6 +16,51 @@ function RootComponent() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <% } else if (!includeExamples) { %> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { HeadContent, Outlet, Scripts, createRootRouteWithContext } from '@tanstack/solid-router' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { TanStackRouterDevtools } from '@tanstack/solid-router-devtools' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <% if (addOnEnabled['solid-ui']) { %> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import "@fontsource/inter/400.css" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <% } %> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { HydrationScript } from 'solid-js/web' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { Suspense } from 'solid-js' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <% for(const addOn of addOns) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for(const init of addOn.main?.initialize || []) { %> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <%- init %> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <% } } %> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import styleCss from "../styles.css?url"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+20
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== Solid no-examples root branch =="
sed -n '19,63p' packages/create/src/frameworks/solid/project/base/src/routes/__root.tsx.ejs
echo
echo "== Integration definitions that may be rendered here =="
rg -n -C2 --glob '*.ts' --glob '*.js' 'type\s*:\s*["'"'"'](layout|provider|devtools)["'"'"']|integrations\s*:' .
echo
echo "== React root import pattern for comparison =="
sed -n '30,45p' packages/create/src/frameworks/react/project/base/src/routes/__root.tsx.ejsRepository: TanStack/cli Length of output: 5568 Add missing import loop for layout integrations in the no-examples branch. The Add an import loop after line 17: import { TanStackRouterDevtools } from '@tanstack/solid-router-devtools'
<% if (addOnEnabled['solid-ui']) { %>
import "@fontsource/inter/400.css"
<% } %>
+<% for(const integration of integrations.filter(i => i.type === 'layout')) { %>
+import <%= integration.jsName %> from '<%= relativePath(integration.path, true) %>'
+<% } %>
+
import { HydrationScript } from 'solid-js/web'📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const Route = createRootRouteWithContext()({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| head: () => ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| links: [{ rel: "stylesheet", href: styleCss }], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| shellComponent: RootComponent, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function RootComponent() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <html> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <head> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <HydrationScript /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <HeadContent /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </head> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <body> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Suspense> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Outlet /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <TanStackRouterDevtools /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <% for(const integration of integrations.filter(i => i.type === 'layout')) { %> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <<%= integration.jsName %> /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <% } %> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Suspense> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Scripts /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </body> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </html> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <% } else { %> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { HeadContent, Outlet, Scripts, createRootRouteWithContext } from '@tanstack/solid-router' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { TanStackRouterDevtools } from '@tanstack/solid-router-devtools' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -47,9 +92,9 @@ function RootComponent() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <html> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <head> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <HydrationScript /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <HeadContent /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </head> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <body> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <HeadContent /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Suspense> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Header /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Outlet /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also filter
/exampleroute URLs when examples are disabled.stripExamplesFromOptionscurrently removes URLs prefixed with/demoonly. Routes withroute.urllike/example/...can still pass through in code-router-style add-ons.Suggested fix
const filteredRoutes = (addOn.routes || []).filter( (route) => !isDemoFilePath(route.path) && - !(route.url && route.url.startsWith('/demo')), + !( + route.url && + (route.url.startsWith('/demo') || route.url.startsWith('/example')) + ), )📝 Committable suggestion
🤖 Prompt for AI Agents