@@ -86,6 +86,8 @@ type Config = {
8686 includeGithubCi : boolean
8787 includeAtAliases : boolean
8888 includeTestVariable : boolean
89+ includeTailwind : boolean
90+ includeVpRaw : boolean
8991}
9092
9193type Args = {
@@ -263,10 +265,12 @@ async function init() {
263265 process . exit ( 1 )
264266 }
265267
268+ const includeTailwind = await togglePrompt ( 'Include Tailwind CSS?' )
266269 const includeEsLint = await togglePrompt ( 'Include ESLint?' , true )
267270 const includeEsLintStylistic = await togglePromptIf ( includeEsLint , 'Include ESLint Stylistic for formatting?' , includeEsLint )
268271 const includeVitest = await togglePromptIf ( extended , 'Include Vitest for testing?' , true )
269272 const includeDocs = await togglePrompt ( 'Include VitePress for documentation?' , true )
273+ const includeVpRaw = includeDocs && await togglePromptIf ( extended , 'Include support for vp-raw in VitePress?' , includeTailwind )
270274 const includeGithubPages = includeDocs && await togglePrompt ( 'Include GitHub Pages config for documentation?' )
271275 const includePlayground = await togglePrompt ( 'Include playground application for development?' , true )
272276 const includeGithubCi = await togglePrompt ( 'Include GitHub CI configuration?' , ! ! githubPath )
@@ -338,7 +342,9 @@ async function init() {
338342 includeVitest,
339343 includeGithubCi,
340344 includeAtAliases,
341- includeTestVariable
345+ includeTestVariable,
346+ includeTailwind,
347+ includeVpRaw
342348 }
343349
344350 copyTemplate ( 'base ', config )
@@ -367,6 +373,14 @@ async function init() {
367373 copyTemplate ( 'ci ', config )
368374 }
369375
376+ if ( config . includeTailwind ) {
377+ copyTemplate ( 'tailwind ', config )
378+ }
379+
380+ if ( config . includeVpRaw ) {
381+ copyTemplate ( 'vp - raw ', config )
382+ }
383+
370384 console . log ( )
371385 console . log ( `${ bgGreen ( bold ( black ( 'DONE' ) ) ) } Project created` )
372386 console . log ( )
@@ -441,7 +455,10 @@ function copyFiles(templateFile: string, config: Config) {
441455 const target = targetPath . replace ( / \. e j s $ / , '' )
442456 let content = ejs . render ( template , { config } )
443457
444- if ( / \. ( j s o n | m ? [ j t ] s ) $ / . test ( target ) ) {
458+ if ( / \. ( j s o n | m ? [ j t ] s | v u e ) $ / . test ( target ) ) {
459+ // Ensure there are no blank lines at the start and a single blank line at the end
460+ content = content . trim ( ) + '\n'
461+
445462 // Trim spaces from the ends of lines
446463 content = content . replace ( / + \n / g, '\n' )
447464
@@ -450,6 +467,9 @@ function copyFiles(templateFile: string, config: Config) {
450467
451468 // Remove trailing commas and any blank newlines that follow them
452469 content = content . replace ( / , * (?: \n + ( \n \s * ) | ( \s * ) ) ( [ } \] ) ] ) / g, '$1$2$3' )
470+
471+ // Trim blank lines after {, [ or (
472+ content = content . replace ( / ( [ { [ ( ] \n ) \n + / g, '$1' )
453473 }
454474
455475 fs . writeFileSync ( target , content )
0 commit comments