@@ -5,17 +5,6 @@ import {fileURLToPath} from 'url';
55
66const __dirname = dirname ( fileURLToPath ( import . meta. url ) ) ;
77
8- type Language = 'typescript' | 'javascript' ;
9- type Framework = 'react' | 'vanilla' ;
10-
11- interface TinyBaseAnswers {
12- projectName: string ;
13- language: Language ;
14- framework: Framework ;
15- prettier: boolean ;
16- eslint: boolean ;
17- }
18-
198const config = {
209 welcomeMessage : '🎉 Welcome to TinyBase!\n' ,
2110
@@ -62,13 +51,18 @@ const config = {
6251 } ,
6352 ] ,
6453
65- createContext : ( answers : TinyBaseAnswers ) => {
66- const typescript = answers . language === 'typescript' ;
67- const react = answers . framework === 'react' ;
54+ createContext : ( answers : Record < string , unknown > ) => {
55+ const { projectName, language, framework, prettier, eslint} = answers ;
56+ const typescript = language === 'typescript' ;
57+ const react = framework === 'react' ;
6858 const ext = typescript ? ( react ? 'tsx' : 'ts' ) : react ? 'jsx' : 'js' ;
6959
7060 return {
71- ...answers ,
61+ projectName,
62+ language,
63+ framework,
64+ prettier,
65+ eslint,
7266 typescript,
7367 react,
7468 ext,
@@ -89,22 +83,27 @@ const config = {
8983 {
9084 template : 'base/package.json.hbs' ,
9185 output : 'package.json' ,
86+ prettier : true ,
9287 } ,
9388 {
9489 template : 'base/index.html.hbs' ,
9590 output : 'index.html' ,
91+ prettier : true ,
9692 } ,
9793 {
9894 template : 'base/README.md.hbs' ,
9995 output : 'README.md' ,
96+ prettier : true ,
10097 } ,
10198 {
10299 template : 'src/index.css.hbs' ,
103100 output : 'src/index.css' ,
101+ prettier : true ,
104102 } ,
105103 {
106104 template : 'src/index.tsx.hbs' ,
107105 output : `src/index.${ ext } ` ,
106+ prettier : true ,
108107 transpile : true ,
109108 } ,
110109 ] ;
@@ -113,13 +112,15 @@ const config = {
113112 files . push ( {
114113 template : 'base/.prettierrc.hbs' ,
115114 output : '.prettierrc' ,
115+ prettier : true ,
116116 } ) ;
117117 }
118118
119119 if ( eslint ) {
120120 files . push ( {
121121 template : 'base/eslint.config.js.hbs' ,
122122 output : 'eslint.config.js' ,
123+ prettier : true ,
123124 } ) ;
124125 }
125126
@@ -128,11 +129,13 @@ const config = {
128129 {
129130 template : 'src/App.tsx.hbs' ,
130131 output : `src/App.${ ext } ` ,
132+ prettier : true ,
131133 transpile : true ,
132134 } ,
133135 {
134136 template : 'base/vite.config.js.hbs' ,
135137 output : 'vite.config.js' ,
138+ prettier : true ,
136139 } ,
137140 ) ;
138141 }
@@ -142,18 +145,20 @@ const config = {
142145 {
143146 template : 'base/tsconfig.json.hbs' ,
144147 output : 'tsconfig.json' ,
148+ prettier : true ,
145149 } ,
146150 {
147151 template : 'base/tsconfig.node.json.hbs' ,
148152 output : 'tsconfig.node.json' ,
153+ prettier : true ,
149154 } ,
150155 ) ;
151156 }
152157
153158 return files ;
154159 } ,
155160
156- templateRoot : join ( __dirname , '../ templates' ) ,
161+ templateRoot : join ( __dirname , 'templates' ) ,
157162
158163 onSuccess : ( projectName : string ) = > {
159164 console . log ( `Next steps:` ) ;
0 commit comments