jspm / npm

NPM Location Service
19 stars 34 forks source link

npm Enterprise and scoped packages #94

Closed gustavnikolaj closed 8 years ago

gustavnikolaj commented 8 years ago

This issue replaces https://github.com/jspm/jspm-cli/issues/1164 as this seems to be a more fitting place for it.

We have an npm Enterprise installation in house. That means that our scoped packages are not just using a normal scope that uses the original registry, but they are using a scope which should point to another registry.

In .npmrc it's handled by setting a value @myScope:registry = "http://foo.bar.com"

project $ jspm install foo=npm:@myScope/foo
     Looking up npm:@myScope/foo

err  Repo npm:@myScope/foo not found!

warn Installation changes not saved.

If I change the npm registry value in ~/.jspm/config to my npme-registry it works as expected.

Am I right, when I assume that this is not supported? Do you have any pointers towards where I should start if I were to submit this functionality as a PR?

A comment on that issue, also from me:

We could make the property registryUrl on the NpmLocation class into a function, which would return the registryUrl when given a package name, or even just a scope name. If no arguments is given, it will just return whatever it does now.

https://github.com/jspm/npm/blob/master/lib/npm.js#L37

It's needed to support different registries depending on the scope, in order to support NPM Enterprise properly. Would this change go against any conventions or reasoning in the project, that I'm not aware of?

gustavnikolaj commented 8 years ago

I have whipped up an example, but I don't really now how to test it with the current test suite. I have tested it locally, and I can now install private scoped modules from the registries defined in the .npmrc file.

guybedford commented 8 years ago

This resolves https://github.com/jspm/npm/issues/80.

gustavnikolaj commented 8 years ago

Oh, sorry for missing that one. I originally posted this issue in the jspm-cli repo, as I didn't yet realize that this were the place to put it. I did my issue searching in that repository, and forgot to do it before posting this new issue :-)

guybedford commented 8 years ago

Released in 0.25.1. Thanks so much @gustavnikolaj for working on this!

gustavnikolaj commented 8 years ago

Thank you!

gustavnikolaj commented 8 years ago

It just dawned on me that I didn't do anything special to handle authentication specific for a given scope. PR #95 means that the correct registry will be chosen for a given scope, but I didn't make any changes to use potential authentication information from .npmrc tied to that particular scope.

At work, we are using a special authentication plugin, that effectively disables the authentication when using VPN, so that's why I didn't stumple into it. I will try to see if I can come up with a way of testing this case.

guybedford commented 8 years ago

@gustavnikolaj thanks I've posted https://github.com/jspm/npm/issues/98 to track this.