Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for npm private registry #1093

Merged
merged 7 commits into from
Jan 24, 2023
Merged

Support for npm private registry #1093

merged 7 commits into from
Jan 24, 2023

Conversation

loispostula
Copy link
Contributor

@loispostula loispostula commented Jan 17, 2023

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 the spec.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

@olblak olblak added this to the 0.44.0 milestone Jan 23, 2023
Copy link
Member

@olblak olblak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have access to a private NPM registry so I can't really test it but the code part looks great.
Thanks for the pullrequest.

@olblak olblak added enhancement New feature or request resource-npm labels Jan 24, 2023
@olblak olblak merged commit b1fd2ab into updatecli:main Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request resource-npm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Add private NPM registry support
2 participants