Skip to content

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

Open
ryohidaka wants to merge 4 commits into
voidzero-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 4 commits into
voidzero-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 9ef2832
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/6a072783e3a9ab00086b370f

@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 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I think that no action is required about this either, for the reasons below.

#1484 (comment)

Comment thread packages/cli/src/create/bin.ts
Comment thread packages/cli/src/create/bin.ts
Comment thread packages/cli/src/create/bin.ts
Comment thread packages/cli/src/create/bin.ts Outdated
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 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Comment thread packages/cli/src/create/bin.ts Outdated
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 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The return values of runViteInstall and runViteFmt are not checked anywhere else in the codebase, so restricting commits based on them would be inconsistent with existing patterns.

I will skip this part.

@ryohidaka ryohidaka force-pushed the issue/1483-init-git branch 3 times, most recently 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
Copy link
Copy Markdown
Member

@fengmk2 fengmk2 left a comment

Choose a reason for hiding this comment

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

@ryohidaka Nice job! I will test it before merge. Thanks!

@fengmk2 fengmk2 added test: e2e Auto run e2e tests test: create-e2e Run `vp create` e2e tests labels May 11, 2026
@fengmk2
Copy link
Copy Markdown
Member

fengmk2 commented May 14, 2026

@ryohidaka can you take a look at the review comments from the codex?

@ryohidaka ryohidaka force-pushed the issue/1483-init-git branch from a4baf73 to 7918e74 Compare May 14, 2026 12:12
ryohidaka added a commit to ryohidaka/vite-plus that referenced this pull request May 14, 2026
ryohidaka added a commit to ryohidaka/vite-plus that referenced this pull request May 14, 2026
@ryohidaka ryohidaka force-pushed the issue/1483-init-git branch from a968afd to e7e3570 Compare May 14, 2026 12:42
ryohidaka added a commit to ryohidaka/vite-plus that referenced this pull request May 14, 2026
@ryohidaka ryohidaka force-pushed the issue/1483-init-git branch from e7e3570 to 5e3e3e4 Compare May 14, 2026 13:01
ryohidaka added a commit to ryohidaka/vite-plus that referenced this pull request May 15, 2026
@ryohidaka ryohidaka force-pushed the issue/1483-init-git branch from 5e3e3e4 to fb9a6f4 Compare May 15, 2026 00:08
@ryohidaka ryohidaka requested a review from fengmk2 May 15, 2026 00:09
ryohidaka added a commit to ryohidaka/vite-plus that referenced this pull request May 15, 2026
@ryohidaka ryohidaka force-pushed the issue/1483-init-git branch from fb9a6f4 to 9e56dfc Compare May 15, 2026 00:21
ryohidaka added a commit to ryohidaka/vite-plus that referenced this pull request May 15, 2026
@ryohidaka ryohidaka force-pushed the issue/1483-init-git branch from 9e56dfc to ecaaefe Compare May 15, 2026 09:06
ryohidaka added a commit to ryohidaka/vite-plus that referenced this pull request May 15, 2026
@ryohidaka ryohidaka force-pushed the issue/1483-init-git branch from ecaaefe to cd4dfe7 Compare May 15, 2026 13:04
ryohidaka added a commit to ryohidaka/vite-plus that referenced this pull request May 15, 2026
@ryohidaka ryohidaka force-pushed the issue/1483-init-git branch from cd4dfe7 to c46b8be Compare May 15, 2026 13:06
ryohidaka added a commit to ryohidaka/vite-plus that referenced this pull request May 15, 2026
@ryohidaka ryohidaka force-pushed the issue/1483-init-git branch from 0abc641 to 9ef2832 Compare May 15, 2026 14:02
@ryohidaka ryohidaka marked this pull request as draft May 15, 2026 14:05
@ryohidaka ryohidaka marked this pull request as ready for review May 15, 2026 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test: create-e2e Run `vp create` e2e tests test: e2e Auto run e2e tests

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