Skip to content

feat(cli): Initialize a git repository and create an initial commit on scaffold#1484

Open
ryohidaka wants to merge 2 commits intovoidzero-dev:mainfrom
ryohidaka:issue/1483-init-git
Open

feat(cli): Initialize a git repository and create an initial commit on scaffold#1484
ryohidaka wants to merge 2 commits intovoidzero-dev:mainfrom
ryohidaka:issue/1483-init-git

Conversation

@ryohidaka
Copy link
Copy Markdown

@ryohidaka ryohidaka commented Apr 27, 2026

Summary

Add a --git / --no-git flag to vp create.

  • In interactive mode, prompt the user with a confirm dialog (default: No)
  • In non-interactive mode, default to skipping git initialization
  • When enabled, run git init before installing dependencies,
    then git add -A && git commit -m "Initial commit from Vite+" after formatting completes

Testing

  • Execute snap-tests-global
  • Launch locally with bootstrap-cli and confirm that it works

Closes #1483

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 27, 2026

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit 9512eeb
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/69fdeb863e775b0008c1c1cc

@ryohidaka ryohidaka force-pushed the issue/1483-init-git branch 8 times, most recently from 5daa636 to d1fb08e Compare May 2, 2026 11:01
@fengmk2 fengmk2 self-assigned this May 8, 2026
@fengmk2
Copy link
Copy Markdown
Member

fengmk2 commented May 8, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 37a56e2176

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1151 to +1152
await initGitRepository(workspaceInfo.rootDir);
await createInitialCommit(workspaceInfo.rootDir);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Limit initial commits to generated files

In an existing monorepo, opting into --git runs the commit from workspaceInfo.rootDir; createInitialCommit does git add -A, which stages every tracked/untracked change in that repo (confirmed via git add -h). If the user has unrelated dirty work anywhere in the monorepo, vp create ... --git will include it in the scaffold's "Initial commit" rather than only the new project/workspace edits.

Useful? React with 👍 / 👎.

onCancel: () => cancelAndExit(),
}));

const shouldSetupGit = await promptGitInit(options);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor --no-git for monorepo scaffolds

promptGitInit(options) returns false for vp create vite:monorepo --no-git, but the monorepo-template path still uses its separate shouldInitGit default and calls git init later. In the default compact mode this happens without another prompt, so the newly documented --no-git option does not actually skip repository initialization for monorepo scaffolds.

Useful? React with 👍 / 👎.

Comment on lines +1151 to +1152
await initGitRepository(workspaceInfo.rootDir);
await createInitialCommit(workspaceInfo.rootDir);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Limit initial commits to generated files

In an existing monorepo, opting into --git runs the commit from workspaceInfo.rootDir; createInitialCommit does git add -A, which stages every tracked/untracked change in that repo. If the user has unrelated dirty work anywhere in the monorepo, vp create ... --git will include it in the scaffold's "Initial commit" rather than only the new project/workspace edits.

Useful? React with 👍 / 👎.

Comment on lines +1165 to +1168
if (shouldSetupGit) {
updateCreateProgress('Initializing git repository');
await initGitRepository(fullPath);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add node_modules to .gitignore before standalone commits

For standalone scaffolds, --git initializes the repository before installing dependencies but never calls ensureGitignoreNodeModules; the bundled vite:generator template has no .gitignore, and arbitrary bundled/remote templates can omit one too. In those cases the later git add -A initial commit runs after vp install, so it will commit the generated node_modules directory.

Useful? React with 👍 / 👎.

Comment on lines +1178 to +1180
if (shouldSetupGit) {
updateCreateProgress('Creating initial commit');
await createInitialCommit(fullPath);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Surface failed initial commits

createInitialCommit returns whether git commit succeeded, but this result is ignored here, so a common failure such as missing user.name/user.email or a failing pre-commit hook leaves the scaffold without the promised initial commit while the command still prints the normal success summary. Check the return value and show the captured git error or fail the command when --git was requested.

Useful? React with 👍 / 👎.

Comment on lines 1177 to +1180
await runViteFmt(fullPath, options.interactive, undefined, { silent: compactOutput });
if (shouldSetupGit) {
updateCreateProgress('Creating initial commit');
await createInitialCommit(fullPath);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Skip committing when setup steps failed

The initial commit is created even when the preceding install or formatter step failed; runViteInstall records status: 'failed' and runViteFmt returns a failed summary, but neither result gates this block. When vp install or vp fmt --write fails for a generated template, --git still commits the broken or partially generated state as the initial commit, making the user unwind that commit before fixing the scaffold.

Useful? React with 👍 / 👎.

@ryohidaka ryohidaka force-pushed the issue/1483-init-git branch 2 times, most recently from 33df323 to 39a7bbc Compare May 8, 2026 06:07
@ryohidaka ryohidaka force-pushed the issue/1483-init-git branch from 39a7bbc to 9512eeb Compare May 8, 2026 13:56
@ryohidaka ryohidaka marked this pull request as draft May 8, 2026 13:56
@ryohidaka ryohidaka marked this pull request as ready for review May 8, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proposal: Initialize a git repository and create an initial commit on scaffold

2 participants