File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ export interface ProjectConfig {
1313 description : string
1414 username : string
1515 repoName : string
16+ initGit : boolean
1617}
1718
1819export async function collectUserInputs ( ) : Promise < ProjectConfig > {
@@ -180,6 +181,19 @@ export async function collectUserInputs(): Promise<ProjectConfig> {
180181
181182 const [ username , repoName ] = ( githubInfo as string ) . split ( '/' )
182183
184+ let initGit = false
185+ const initGitChoice = await p . confirm ( {
186+ message : 'Initialize a new git repository?' ,
187+ initialValue : false ,
188+ } )
189+
190+ if ( p . isCancel ( initGitChoice ) ) {
191+ p . cancel ( 'Operation cancelled' )
192+ process . exit ( 0 )
193+ }
194+
195+ initGit = initGitChoice as boolean
196+
183197 return {
184198 variant : variant ,
185199 libraryType : libraryType ,
@@ -190,6 +204,7 @@ export async function collectUserInputs(): Promise<ProjectConfig> {
190204 description : description ,
191205 username,
192206 repoName,
207+ initGit,
193208 }
194209}
195210
Original file line number Diff line number Diff line change @@ -82,6 +82,16 @@ export async function scaffoldProject(config: ProjectConfig): Promise<void> {
8282
8383 await $ `cd ${ projectPath } && bun run build` . nothrow ( ) . quiet ( )
8484
85+ if ( config . initGit ) {
86+ s . message ( 'Git initializing...' )
87+
88+ await $ `cd ${ projectPath } && git init` . nothrow ( ) . quiet ( )
89+ await $ `cd ${ projectPath } && git add -A` . nothrow ( ) . quiet ( )
90+ await $ `cd ${ projectPath } && git commit -m "Initial commit from Bunup"`
91+ . nothrow ( )
92+ . quiet ( )
93+ }
94+
8595 s . stop ( `${ pc . green ( '✓' ) } Project scaffolded successfully!` )
8696 } catch ( error ) {
8797 s . stop ( `${ pc . red ( '✗' ) } Failed to scaffold project` )
You can’t perform that action at this time.
0 commit comments