diff --git a/src/create/prompts.ts b/src/create/prompts.ts index 5c5f5f2..d5592bd 100644 --- a/src/create/prompts.ts +++ b/src/create/prompts.ts @@ -13,6 +13,7 @@ export interface ProjectConfig { description: string username: string repoName: string + initGit: boolean } export async function collectUserInputs(): Promise { @@ -180,6 +181,19 @@ export async function collectUserInputs(): Promise { const [username, repoName] = (githubInfo as string).split('/') + let initGit = false + const initGitChoice = await p.confirm({ + message: 'Initialize a new git repository?', + initialValue: false, + }) + + if (p.isCancel(initGitChoice)) { + p.cancel('Operation cancelled') + process.exit(0) + } + + initGit = initGitChoice as boolean + return { variant: variant, libraryType: libraryType, @@ -190,6 +204,7 @@ export async function collectUserInputs(): Promise { description: description, username, repoName, + initGit, } } diff --git a/src/create/scaffold.ts b/src/create/scaffold.ts index 5f7e3d3..28d09eb 100644 --- a/src/create/scaffold.ts +++ b/src/create/scaffold.ts @@ -82,6 +82,16 @@ export async function scaffoldProject(config: ProjectConfig): Promise { await $`cd ${projectPath} && bun run build`.nothrow().quiet() + if (config.initGit) { + s.message('Git initializing...') + + await $`cd ${projectPath} && git init`.nothrow().quiet() + await $`cd ${projectPath} && git add -A`.nothrow().quiet() + await $`cd ${projectPath} && git commit -m "Initial commit from Bunup"` + .nothrow() + .quiet() + } + s.stop(`${pc.green('✓')} Project scaffolded successfully!`) } catch (error) { s.stop(`${pc.red('✗')} Failed to scaffold project`)