Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example repository https changed to git+https by npm pkg fix #1176

Closed
MikeMcC399 opened this issue Jun 26, 2024 · 3 comments
Closed

Example repository https changed to git+https by npm pkg fix #1176

MikeMcC399 opened this issue Jun 26, 2024 · 3 comments

Comments

@MikeMcC399
Copy link

MikeMcC399 commented Jun 26, 2024

Location of issue

npm CLI > Configuring npm > package.json > repository
https://docs.npmjs.com/cli/v10/configuring-npm/package-json#repository

Source code location

https://github.com/npm/documentation/blob/main/content/cli/v10/configuring-npm/package-json.mdx#repository

Issue

Referring to the following example from Repository in the documentation:

{
  "repository": {
    "type": "git",
    "url": "https://github.com/npm/cli.git"
  }
}

If a package.json is constructed using this example, then npm pkg fix changes the protocol from https to git+https

git+https is also used by the live version of the repo:
https://github.com/npm/cli/blob/latest/package.json#L28-L31 contains:

  "repository": {
    "type": "git",
    "url": "git+https://github.com/npm/cli.git"
  },

Expected

The Repository section should provide an example:

  • which is not subject to correction by npm pkg fix
  • if it uses https://github.com/npm/cli.git as an example, then the text in the npm documentation should correspond to the usage in the repository itself.

Steps to reproduce

Execute:

mkdir npm-repo-test
cd npm-repo-test
git init
npm init -y

Integrate the following example code

{
  "repository": {
    "type": "git",
    "url": "https://github.com/npm/cli.git"
  }
}

from Repository into the package.json which was just generated, observing proper syntax.

Now execute:

git add .
git commit -m "baseline"
npm pkg fix
git diff

and note that the protocol has been changed from https to git+https:

$ git diff
diff --git a/package.json b/package.json
index b0413a5..fc3050d 100644
--- a/package.json
+++ b/package.json
@@ -11,6 +11,6 @@
   "description": "",
   "repository": {
     "type": "git",
-    "url": "https://github.com/npm/cli.git"
+    "url": "git+https://github.com/npm/cli.git"
   }
 }

Environment

  • npm: 10.8.1
  • Node.js: v22.3.0
@MikeMcC399
Copy link
Author

@MikeMcC399
Copy link
Author

The example in Repository should also be updated for consistency.

@MikeMcC399
Copy link
Author

This issue should be in https://github.com/npm/cli/issues

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

No branches or pull requests

1 participant