Skip to content

Support private registries (non-auth) and fix git resolver #791

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

Closed
wants to merge 2 commits into from

Conversation

palmerj3
Copy link

  • Basic support for private registries defined in .npmrc.
  • Fix git resolver so it properly matches non-github git+https, etc packages.

I want to use Yarn at work and this lets me do that. We utilize a private registry and github enterprise.

Test plan
There are currently no tests for npm-registry to begin with so I didn't add anything there.
For git+https I added a test to package-resolver and fetchers.js.

let registry = removeSuffix(String(this.registries.yarn.getOption('registry')), '/');

if (this.config.registry) {
registry = this.config.registry;
Copy link

Choose a reason for hiding this comment

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

Do you need to remove a possible trailing slash in this case as well? (see removeSuffix above)

Copy link

Choose a reason for hiding this comment

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

+1 for trailing slash. Could also do the conditional at assignment and keep registry as a const

registry: 'bower',
}, await createConfig());
await fetcher.fetch();
const name = (await fs.readJson(path.join(dir, 'bower.json'))).name;
Copy link

Choose a reason for hiding this comment

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

If syntax is supported you could do this:
const { name } = await fs.readJson(...);

@palmerj3 palmerj3 force-pushed the privateRegAndGit branch 3 times, most recently from 59b2471 to 91824da Compare October 12, 2016 14:47
@palmerj3
Copy link
Author

@fxb @jomaxx I updated using some of your suggestions. Looks like there are some other commits recently (not mine) that are causing some failing tests and lint checks. I'll rebase if those get fixed.

@jomaxx
Copy link

jomaxx commented Oct 12, 2016

@palmerj3 looks good once tests are passing. Not by a computer until Sunday so won't be able to pull down and try it out until then.

@mager
Copy link

mager commented Oct 12, 2016

I tested this code with private registries and it works well.

@sebmck
Copy link
Contributor

sebmck commented Oct 14, 2016

Can you please rebase

@palmerj3
Copy link
Author

@kittens ok all set

const registry = removeSuffix(String(this.registries.yarn.getOption('registry')), '/');
const registry = this.config.registry ?
removeSuffix(this.config.registry, '/') :
removeSuffix(String(this.registries.yarn.getOption('registry')), '/');
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems redundant, why not just this.config.registry || this.registries.yarn.getOption('registry) instead of duplicating each of them in the removeSuffix call?

@palmerj3
Copy link
Author

Closing since #839 solves the private registry problem.

I have opened a separate PR just for the git resolver issue.
#1107

@palmerj3 palmerj3 closed this Oct 15, 2016
@palmerj3 palmerj3 deleted the privateRegAndGit branch October 15, 2016 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants