@@ -22,7 +22,7 @@ const brandColor = /** @type {const} */ ([174, 128, 255]);
2222 kl . trueColor ( ...brandColor ) ( 'Preact - Fast 3kB alternative to React with the same modern API' )
2323 ) ;
2424
25- const { dir, language, useRouter, useESLint } = await prompts . group (
25+ const { dir, language, useRouter, useESLint, appType } = await prompts . group (
2626 {
2727 dir : ( ) =>
2828 prompts . text ( {
@@ -36,6 +36,14 @@ const brandColor = /** @type {const} */ ([174, 128, 255]);
3636 }
3737 } ,
3838 } ) ,
39+ appType : ( ) => prompts . select ( {
40+ message : 'Project Type:' ,
41+ initialValue : 'spa' ,
42+ options : [
43+ { value : 'spa' , label : 'Single Page Application (only client-side)' } ,
44+ { value : 'ssg' , label : 'Static Site Generation (prerenders pages)' } ,
45+ ] ,
46+ } ) ,
3947 language : ( ) =>
4048 prompts . select ( {
4149 message : 'Project language:' ,
@@ -45,11 +53,11 @@ const brandColor = /** @type {const} */ ([174, 128, 255]);
4553 { value : 'ts' , label : 'TypeScript' } ,
4654 ] ,
4755 } ) ,
48- useRouter : ( ) =>
56+ useRouter : ( { results } ) => results . appType === 'spa' ?
4957 prompts . confirm ( {
5058 message : 'Use router?' ,
5159 initialValue : false ,
52- } ) ,
60+ } ) : Promise . resolve ( false ) ,
5361 useESLint : ( ) =>
5462 prompts . confirm ( {
5563 message : 'Use ESLint?' ,
@@ -68,13 +76,13 @@ const brandColor = /** @type {const} */ ([174, 128, 255]);
6876
6977 await useSpinner (
7078 'Setting up your project directory...' ,
71- ( ) => scaffold ( targetDir , { useTS, useRouter, useESLint } ) ,
79+ ( ) => scaffold ( targetDir , { useTS, useRouter, useESLint, appType } ) ,
7280 'Set up project directory'
7381 ) ;
7482
7583 await useSpinner (
7684 'Installing project dependencies...' ,
77- ( ) => installDeps ( targetDir , packageManager , { useTS, useRouter, useESLint } ) ,
85+ ( ) => installDeps ( targetDir , packageManager , { useTS, useRouter, useESLint, appType } ) ,
7886 'Installed project dependencies'
7987 ) ;
8088
@@ -103,8 +111,9 @@ async function useSpinner(startMessage, fn, finishMessage) {
103111/**
104112 * @typedef {Object } ConfigOptions
105113 * @property {boolean } useTS
106- * @property {boolean } useRouter
114+ * @property {unknown } useRouter
107115 * @property {boolean } useESLint
116+ * @property {string } appType
108117 */
109118
110119/**
@@ -117,7 +126,11 @@ async function scaffold(to, opts) {
117126 await fs . mkdir ( to , { recursive : true } ) ;
118127
119128 const __dirname = dirname ( fileURLToPath ( import . meta. url ) ) ;
120- await templateDir ( resolve ( __dirname , '../templates' , 'base' ) , to , opts . useTS ) ;
129+ if ( opts . appType === 'spa' ) {
130+ await templateDir ( resolve ( __dirname , '../templates' , 'base' ) , to , opts . useTS ) ;
131+ } else {
132+ await templateDir ( resolve ( __dirname , '../templates' , 'ssr' ) , to , opts . useTS ) ;
133+ }
121134
122135 if ( opts . useRouter ) {
123136 await templateDir (
0 commit comments