npm / npm/rfcs

[RRFC] npm init should also initialise git repo if it git is installed or the folder is not a git repo already

Open
#411 4 comments 0 reactions 0 assignees View on GitHub

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 init in a project they usually run $ git init to set it as a git repo
  • In other eco systems like Rust in tools like cargo when you do cargo init checks 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 -y it creates a package.json with default values and also initialises it as a git repo
How
Current Behaviour
  • Right now when you do $ npm init it asks you a set of questions then it initialises the package.json
  • Or when you do $ npm init -y it creates the package.json with default values
Desired Behaviour
  • When you run $ npm init ask question about version control (with git as default value)
  • Similarly when they run $ npm init -y it will create package.json and initialise the folder as git repo if it is already not a git repo and git is installed
References
  • n/a

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.