@@ -16,6 +16,51 @@ import { runSpecialSteps } from './special-steps/index.js'
1616
1717import type { Environment , FileBundleHandler , Options } from './types.js'
1818
19+ function isDemoRoutePath ( path ?: string ) {
20+ if ( ! path ) return false
21+ const normalized = path . replace ( / \\ / g, '/' )
22+ return (
23+ normalized . includes ( '/routes/demo/' ) ||
24+ normalized . includes ( '/routes/demo.' ) ||
25+ normalized . includes ( '/routes/example/' ) ||
26+ normalized . includes ( '/routes/example.' )
27+ )
28+ }
29+
30+ function stripExamplesFromOptions ( options : Options ) : Options {
31+ if ( options . includeExamples !== false ) {
32+ return options
33+ }
34+
35+ const chosenAddOns = options . chosenAddOns
36+ . filter ( ( addOn ) => addOn . type !== 'example' )
37+ . map ( ( addOn ) => {
38+ const filteredRoutes = ( addOn . routes || [ ] ) . filter (
39+ ( route ) =>
40+ ! isDemoRoutePath ( route . path ) &&
41+ ! ( route . url && route . url . startsWith ( '/demo' ) ) ,
42+ )
43+
44+ return {
45+ ...addOn ,
46+ routes : filteredRoutes ,
47+ getFiles : async ( ) => {
48+ const files = await addOn . getFiles ( )
49+ return files . filter ( ( file ) => ! isDemoRoutePath ( file ) )
50+ } ,
51+ getDeletedFiles : async ( ) => {
52+ const deletedFiles = await addOn . getDeletedFiles ( )
53+ return deletedFiles . filter ( ( file ) => ! isDemoRoutePath ( file ) )
54+ } ,
55+ }
56+ } )
57+
58+ return {
59+ ...options ,
60+ chosenAddOns,
61+ }
62+ }
63+
1964async function writeFiles ( environment : Environment , options : Options ) {
2065 const templateFileFromContent = createTemplateFile ( environment , options )
2166
@@ -282,10 +327,12 @@ Please read the README.md file for information on testing, styling, adding route
282327}
283328
284329export async function createApp ( environment : Environment , options : Options ) {
330+ const effectiveOptions = stripExamplesFromOptions ( options )
331+
285332 environment . startRun ( )
286- await writeFiles ( environment , options )
287- await runCommandsAndInstallDependencies ( environment , options )
333+ await writeFiles ( environment , effectiveOptions )
334+ await runCommandsAndInstallDependencies ( environment , effectiveOptions )
288335 environment . finishRun ( )
289336
290- report ( environment , options )
337+ report ( environment , effectiveOptions )
291338}
0 commit comments