[RRFC] npm init should also initialise git repo if it git is installed or the folder is not a git repo already
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 777
- Forks
- 267
- PR merge metrics
- No merged PRs in 30d
Description
Motivation ("The Why")
- Most of the time when developers do
$ npm initin a project they usually run$ git initto set it as a git repo - In other eco systems like Rust in tools like cargo when you do
cargo initchecks if you have git installed if so initialises it as a git repo (it it already not a git repo) - If the developer does not want to use git but use other version controls (or none) they could specify it in a flag like
$ cargo --vcs - We could do similar thing in npm. Even-though this is not a major change it does improve the developer experience little bit
Example
- You go to a folder and run
$ npm init -yit creates apackage.jsonwith default values and also initialises it as a git repo
How
Current Behaviour
- Right now when you do
$ npm initit asks you a set of questions then it initialises thepackage.json - Or when you do
$ npm init -yit creates the package.json with default values
Desired Behaviour
- When you run
$ npm initask question about version control (with git as default value) - Similarly when they run
$ npm init -yit will createpackage.jsonand initialise the folder as git repo if it is already not a git repo and git is installed
References
- n/a
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the npm init and npm init -y entry points and compare their current question flow and package.json creation behavior with git init availability and repository detection. Resolve the proposed version-control prompt and flag behavior before implementation; done means the agreed behavior is documented and covered for existing repositories, missing git, and noninteractive -y runs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, javascript
- Domain
- cli, developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100