fix: Preserve https protocol when working with git
This prevents changing URLs from https and git+https into git+ssh, but keeps the fall-back to git+ssh when the protocol is not specified.
The change in pacote is necessary in order to have this fully working.
References
Supersedes #5256 Blocked by https://github.com/npm/pacote/pull/434 Fixes #4305 Fixes #2610
Hm. Tests work fine, but in reality, nothing changed (package-lock.json contains git+ssh link), possibly same as in #5256. Investigating...
It seems also https://github.com/npm/pacote needs the same fix
The pacote really needs fixing, after the fix the package-lock.json contains git+https link instead of git+ssh, but still the github:repo/project is recorded in dependencies, which is not equivalent (resolves to git+ssh). Almost there... 😁
Fixed, tested, should work now. The fix in pacote is necessary to have this really fully working.
If you want to try the patched npm by yourself, feel free to checkout the fix/git-https-full branch from my clone:
git clone -b fix/git-https-full --single-branch --depth=1 https://github.com/oldium/npm-cli.git
cd npm-cli
npm install
npm link
:warning: Warning
Please note that
npm linkon Linux likely requires admin permissions unless you are usingNode Version Manager (nvm)to have user installation only.
:warning: Warning
The
npm linkwill replace the globalnode_modules/npmdirectory by a link to the localnpm-clidirectory. Do not delete thenpm-clidirectory afterwards.
:warning: Reverting
In order to revert, reinstall the
Node.jsruntime. This should replace thenpmlink too. On Windows the system-wide installation ofNode.js(not a portable winget installation!) uses user-specific folder, so just deleteC:\Users\<user>\AppData\Roaming\npm\node_modules\npmand the globalnpmfromProgram Fileswill be used.