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.
Fix 1012
Implement support of private npm registry
Test
To test this pull request, you can run the following commands:
cp pkg/plugins/resources/npm go test
Additional Information
When working with a private registry, it is necessary to specify the registry URL and an authorization token. These details can be provided in the resource specification and will be used as the default registry for connecting.
The resource code also checks for the presence of an
npmrc
file. This file contains information about scoped packages and can be specified in thespec.NpmrcPath
field or defaults to$HOME/.npmrc
.The code will first establish the default registry by using the provided URL and token or defaulting to the npm registry. It then parses the
npmrc
file to identify additional registries and determine which scoped packages should use them.When searching for a package, the resource code checks if it is a scoped package and if the scope has a custom registry configured. If so, it uses that registry, otherwise, it uses the default registry.
I've also fleshed out the test to introduced a mocked registry client
Tradeoff
Potential improvement