Skip to content

Commit a037c4d

Browse files
committed
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.
1 parent 523c999 commit a037c4d

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

packages/create/src/create-app.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,22 @@ import { runSpecialSteps } from './special-steps/index.js'
1717

1818
import type { Environment, FileBundleHandler, Options } from './types.js'
1919

20-
function isDemoRoutePath(path?: string) {
20+
function isDemoFilePath(path?: string) {
2121
if (!path) return false
2222
const normalized = path.replace(/\\/g, '/')
2323
return (
2424
normalized.includes('/routes/demo/') ||
2525
normalized.includes('/routes/demo.') ||
2626
normalized.includes('/routes/example/') ||
27-
normalized.includes('/routes/example.')
27+
normalized.includes('/routes/example.') ||
28+
normalized.includes('/lib/demo-') ||
29+
normalized.includes('/lib/demo.') ||
30+
normalized.includes('/hooks/demo-') ||
31+
normalized.includes('/hooks/demo.') ||
32+
normalized.includes('/data/demo.') ||
33+
normalized.includes('/data/demo-') ||
34+
normalized.includes('/components/demo-') ||
35+
normalized.includes('/components/demo.')
2836
)
2937
}
3038

@@ -38,7 +46,7 @@ function stripExamplesFromOptions(options: Options): Options {
3846
.map((addOn) => {
3947
const filteredRoutes = (addOn.routes || []).filter(
4048
(route) =>
41-
!isDemoRoutePath(route.path) &&
49+
!isDemoFilePath(route.path) &&
4250
!(route.url && route.url.startsWith('/demo')),
4351
)
4452

@@ -47,11 +55,11 @@ function stripExamplesFromOptions(options: Options): Options {
4755
routes: filteredRoutes,
4856
getFiles: async () => {
4957
const files = await addOn.getFiles()
50-
return files.filter((file) => !isDemoRoutePath(file))
58+
return files.filter((file) => !isDemoFilePath(file))
5159
},
5260
getDeletedFiles: async () => {
5361
const deletedFiles = await addOn.getDeletedFiles()
54-
return deletedFiles.filter((file) => !isDemoRoutePath(file))
62+
return deletedFiles.filter((file) => !isDemoFilePath(file))
5563
},
5664
}
5765
})

0 commit comments

Comments
 (0)