registry path for scoped package tarball should include scope subdirectory under dash directory #127
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.
The JSON sent by
npm publish
contains the propertyversions.XXX.dist.tarball
which contains the scope name twice for a scoped package; for example:"http://localhost:15443/@chad/myhowtonpm/-/@chad/myhowtonpm-1.0.0.tgz"
. The mock registry server attempts to remove the second occurrence of@scope
from the file path, which causes an error if users try to create another package into which they install the package created in the workshopper using the mock server. The path should be left as-is to match the tarball property inbody.json
so npm can GET it. Removing this code has the additional benefit of fixing a bug on Windows because the regex does not consider backslashes in the path.Fixes: #122
Fixes: nodeschool/discussions#1561
Fixes: nodeschool/discussions#2049
Please note this would supersede PR #68
Additional Explanation
Given a package
@chad/myhowtonpm
, runningnpm publish
with npm 5.0.3 will PUT JSON something like this:Note that the
tarball
property contains two subdirectories following the pattern@scope
. In order for a user to be able tonpm install
the package the file has to be found at this location. Hence the current code which attempts to strip the second occurrence of@scope
is not correct; in fact I have verified that attempting to install the package into a second package causes an error because of this.With the new code, the variables trace out as follows:
The path
tgzFile
matches thetarball
property and the correct directory is created in themkdirp
call. It is possible to install the package created in the workshopper into a second package later on (assuming the user copies.npmrc
to use the mock server). Also, since the regex is no longer needed, the bug that breaks publishing on Windows is simply gone.