Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/create/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface ProjectConfig {
description: string
username: string
repoName: string
initGit: boolean
}

export async function collectUserInputs(): Promise<ProjectConfig> {
Expand Down Expand Up @@ -180,6 +181,19 @@ export async function collectUserInputs(): Promise<ProjectConfig> {

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,
Expand All @@ -190,6 +204,7 @@ export async function collectUserInputs(): Promise<ProjectConfig> {
description: description,
username,
repoName,
initGit,
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/create/scaffold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ export async function scaffoldProject(config: ProjectConfig): Promise<void> {

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`)
Expand Down