1+ #!/usr/bin/env node
12import fs from 'node:fs' ;
23import path from 'node:path' ;
34import * as p from '@clack/prompts' ;
@@ -68,6 +69,7 @@ const options = await p.group(
6869 p . multiselect ( {
6970 message : 'Select additional options (use arrow keys/space bar)' ,
7071 required : false ,
72+ initialValues : [ ] ,
7173 options : [
7274 {
7375 value : '@fastify/cors' ,
@@ -116,7 +118,7 @@ if (options.template === 'typescript') {
116118 }
117119}
118120
119- p . outro ( "You're all set! Run the following commands to get started:" ) ;
121+ p . outro ( '🚀 I copied the proper template and made your project ready 😁' ) ;
120122
121123const { uwebsockets, features, package_manager } = options ;
122124
@@ -126,9 +128,9 @@ if (!fs.existsSync(cwd)) {
126128
127129const commands = [ 'npx degit owebjs/templates/' + options . template + ' --force' ] ;
128130
129- if ( features ) {
131+ if ( features . length > 0 ) {
130132 commands . push (
131- `${ package_manager } ${ package_manager == 'npm ' ? 'install ' : 'add ' } -D ${ features . join (
133+ `${ package_manager } ${ package_manager == 'yarn ' ? 'add ' : 'install ' } -D ${ features . join (
132134 ' ' ,
133135 ) } `,
134136 ) ;
@@ -184,3 +186,22 @@ function patch(file: string, string: string) {
184186
185187 fs . writeFileSync ( indexFile , fs . readFileSync ( indexFile , 'utf-8' ) . replace ( file , string ) ) ;
186188}
189+
190+ await p
191+ . confirm ( {
192+ message : 'Do you want to initialize a git repository?' ,
193+ initialValue : false ,
194+ } )
195+ . then ( async ( initGit ) => {
196+ if ( initGit ) {
197+ await execa ( 'git' , [ 'init' ] , {
198+ cwd : path . relative ( process . cwd ( ) , cwd ) ,
199+ } ) ;
200+ }
201+ } ) ;
202+
203+ console . log (
204+ `✨ Oweb project has been created. Next steps:\n cd ${ cwd } \n› ${
205+ package_manager === 'yarn' ? 'yarn' : package_manager
206+ } ${ package_manager === 'yarn' ? 'start' : 'run start' } `,
207+ ) ;
0 commit comments