-
-
Notifications
You must be signed in to change notification settings - Fork 153
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
Add scope to config #636
Add scope to config #636
Conversation
server/build.go
Outdated
@@ -45,6 +45,15 @@ type BuildTask struct { | |||
stage string | |||
} | |||
|
|||
func removeHttpPrefix(s string) (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would like to put this function in utils.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense, I'll move this.
if cfg.NpmRegistryScope != "" { | ||
isInScope := strings.HasPrefix(name, cfg.NpmRegistryScope) | ||
if !isInScope { | ||
url = "https://registry.npmjs.org/" + name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you explain this line a bit? thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is reproducing what npm does when you have a scope, where if the package you are trying to download is in the scope it goes to one registry and if it's not it goes to the default public registry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i see, thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for contributing
No problem, thanks for the prompt review! |
hi @johnpangalos would you like to update the config.example.jsonc for the new config? |
I can do that! |
thanks! |
Use Case: Hosting private npm packages in a custom npm registry, like GitHub's npm registry, and that npm registry is not a mirror.
Issue: When using a custom npm registry you set the
npmRegistry
in the config and it downloads the correct npm package, but if you try and download any other package (such as a dependency) it fails because the custom npm registry does not contain any packages but private ones.Solution: Use scope in the
.npmrc
, this seemed the easiest since the.npmrc
file was being created anyway.Not sure how to test this, any advice about that would be appreciated.