cli icon indicating copy to clipboard operation
cli copied to clipboard

fix: Preserve https protocol when working with git

Open oldium opened this issue 2 months ago • 5 comments

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

oldium avatar Oct 27 '25 12:10 oldium

Hm. Tests work fine, but in reality, nothing changed (package-lock.json contains git+ssh link), possibly same as in #5256. Investigating...

oldium avatar Oct 27 '25 13:10 oldium

It seems also https://github.com/npm/pacote needs the same fix

oldium avatar Oct 27 '25 14:10 oldium

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... 😁

oldium avatar Oct 27 '25 14:10 oldium

Fixed, tested, should work now. The fix in pacote is necessary to have this really fully working.

oldium avatar Oct 27 '25 15:10 oldium

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 link on Linux likely requires admin permissions unless you are using Node Version Manager (nvm) to have user installation only.

:warning: Warning

The npm link will replace the global node_modules/npm directory by a link to the local npm-cli directory. Do not delete the npm-cli directory afterwards.

:warning: Reverting

In order to revert, reinstall the Node.js runtime. This should replace the npm link too. On Windows the system-wide installation of Node.js (not a portable winget installation!) uses user-specific folder, so just delete C:\Users\<user>\AppData\Roaming\npm\node_modules\npm and the global npm from Program Files will be used.

oldium avatar Oct 27 '25 18:10 oldium