From a037c4d5759525d987425b01c449e35ea5a32461 Mon Sep 17 00:00:00 2001 From: Abdullahi Mohamed <126521894+WaryaWayne@users.noreply.github.com> Date: Tue, 14 Apr 2026 18:37:44 -0400 Subject: [PATCH] fix(create): exclude demo files in lib, hooks, data, and components when 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. --- packages/create/src/create-app.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/create/src/create-app.ts b/packages/create/src/create-app.ts index eaa93e0f..f4f77a7a 100644 --- a/packages/create/src/create-app.ts +++ b/packages/create/src/create-app.ts @@ -17,14 +17,22 @@ import { runSpecialSteps } from './special-steps/index.js' import type { Environment, FileBundleHandler, Options } from './types.js' -function isDemoRoutePath(path?: string) { +function isDemoFilePath(path?: string) { if (!path) return false const normalized = path.replace(/\\/g, '/') return ( normalized.includes('/routes/demo/') || normalized.includes('/routes/demo.') || normalized.includes('/routes/example/') || - normalized.includes('/routes/example.') + normalized.includes('/routes/example.') || + normalized.includes('/lib/demo-') || + normalized.includes('/lib/demo.') || + normalized.includes('/hooks/demo-') || + normalized.includes('/hooks/demo.') || + normalized.includes('/data/demo.') || + normalized.includes('/data/demo-') || + normalized.includes('/components/demo-') || + normalized.includes('/components/demo.') ) } @@ -38,7 +46,7 @@ function stripExamplesFromOptions(options: Options): Options { .map((addOn) => { const filteredRoutes = (addOn.routes || []).filter( (route) => - !isDemoRoutePath(route.path) && + !isDemoFilePath(route.path) && !(route.url && route.url.startsWith('/demo')), ) @@ -47,11 +55,11 @@ function stripExamplesFromOptions(options: Options): Options { routes: filteredRoutes, getFiles: async () => { const files = await addOn.getFiles() - return files.filter((file) => !isDemoRoutePath(file)) + return files.filter((file) => !isDemoFilePath(file)) }, getDeletedFiles: async () => { const deletedFiles = await addOn.getDeletedFiles() - return deletedFiles.filter((file) => !isDemoRoutePath(file)) + return deletedFiles.filter((file) => !isDemoFilePath(file)) }, } })