NPM: fix npmrc generation for v3 package-locks #7175
Merged
+317
−4
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.
Fixes #6661
Using a v3 package-lock,
dependency-urls
was returning[]
because there is no top-leveldependencies
property.[].all?
turns out is always true, so it was always sticking the lineregistry=<my-configured-reigstry>
into the .npmrc even for those hosted on GHPR which isn't a reverse-proxy style registry. Thus it is not working.I switched to a regex based approach to extract all of the "resolved" lines. This is probably more correct than the current implementation even for v2 lockfiles as this checks all dependencies, not just the ones at the top level. In the event package-lock v4 removes or renames the
resolved
lines, I've added a check thatdependency-urls
isn't empty.Also once I fixed this, some tests started doubling up on scoped registries, so I had to add a
uniq
.