Fix ability to clone scoped packages#19
Open
chazomaticus wants to merge 1 commit intochrisdickinson:masterfrom
Open
Fix ability to clone scoped packages#19chazomaticus wants to merge 1 commit intochrisdickinson:masterfrom
chazomaticus wants to merge 1 commit intochrisdickinson:masterfrom
Conversation
This fixes a bug where attempting to clone public, scoped packages (e.g.
@kgryte/noop) would error out.
There are two issues here: 1) npm-fetch seems not to handle scoped
packages well, %-encoding just the @. This leads to errors like:
$ bin/clone-packages -t http://localhost:8123/ @kgryte/noop
cloning @kgryte/noop @ *...
Error: Not found : %40kgryte/noop
2) when this module PUTs the module on the destination registry, it
skips %-encoding the name, leading to 404s due to the scope being
treated as a URL path.
I initially tried to update npm-fetch, but it hasn't been updated in a
long time. The npm-registry-client it uses is ancient, but porting to a
newer version isn't trivial since the API has changed, and I wasn't sure
exactly how to update the callers to handle all cases properly.
So, I added a new alternative for npm-fetch, pacote, here instead. I
make use of it conditionally, only for this case where npm-fetch fails.
It'd clean things up to replace npm-fetch with pacote entirely, but I
wasn't sure it covers all of the same use cases in the same way.
This also adds a test for the new functionality. Unfortunately, I
couldn't get the tests to pass on master, and I don't have a lot of time
to figure out why. So I blindly added a test for scoped clones, which I
*think* should cover this case just fine.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes a bug where attempting to clone public, scoped packages (e.g.
@kgryte/noop) would error out.There are two issues here: 1) npm-fetch seems not to handle scoped packages well, %-encoding just the @. This leads to errors like:
I initially tried to update npm-fetch, but it hasn't been updated in a long time. The npm-registry-client it uses is ancient, but porting to a newer version isn't trivial since the API has changed, and I wasn't sure exactly how to update the callers to handle all cases properly.
So, I added a new alternative for npm-fetch, pacote, here instead. I make use of it conditionally, only for this case where npm-fetch fails. It'd clean things up to replace npm-fetch with pacote entirely, but I wasn't sure it covers all of the same use cases in the same way.
This also adds a test for the new functionality. Unfortunately, I couldn't get the tests to pass on master, and I don't have a lot of time to figure out why. So I blindly added a test for scoped clones, which I think should cover this case just fine.
Let me know if this passes muster, or if I'm barking up the wrong tree. Thanks!