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 --registry flag from CLI commands #792

Closed
egoist opened this issue Oct 12, 2016 · 23 comments
Closed

Support --registry flag from CLI commands #792

egoist opened this issue Oct 12, 2016 · 23 comments

Comments

@egoist
Copy link

egoist commented Oct 12, 2016

Do you want to request a feature or report a bug?

yes, feature

What is the current behavior?

Only global config is available for setting registry

What is the expected behavior?

yarg add/install --registry https://custom.registry works

Please mention your node.js, yarn and operating system version.

Node. 6.4.0
macOS. 10.11
yarn. 0.15.1

@i5ting
Copy link

i5ting commented Oct 12, 2016

use yrm module https://www.npmjs.com/package/yrm

@sindresorhus
Copy link

Having a CLI flag for this is a bad idea. Imagine if you forget the registry flag and publish an internal package to the public registry. I would instead recommend Yarn support the publishConfig property in package.json. You could then just add "publishConfig":{"registry":"http://my-internal-registry.local"} to package.json.

@egoist
Copy link
Author

egoist commented Oct 12, 2016

Imagine if you forget the registry flag and publish an internal package to the public registry

It always happens if people are careless even if they use something like publishConfig. what if I thought I added this property but I just didn't really add it.

And using --registry is more for installing not publishing.

@ibufu
Copy link

ibufu commented Oct 13, 2016

It is necessary for network environment of China.

@ljharb
Copy link

ljharb commented Oct 13, 2016

yarn should support everything npm does, full stop - publishConfig, --registry, registry set in the npmrc, and/or registry set by any of the env vars that npm looks for.

@Eladriell
Copy link

Has there been any update on this since October?
It's necessary for projects in my company to migrate to Yarn.

@SimenB
Copy link
Contributor

SimenB commented Feb 27, 2017

You can add an .npmrc file?

@Eladriell
Copy link

Sure.
All our projects that publish modules look like this:

.npmrc

registry=http://registry/a
stric-ssl=false
_auth=XXXXXXXXXXXXXXXXX

.yarnrc

registry "http://registry/a"

package.json

{
  "name": "yarn-issue",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "devDependencies": {
	"foo": "0.0.0"
  },
  "publishConfig": {
    "registry": "http://registry/b"
  },
  "author": "",
  "license": "ISC"
}

Here both Yarn and npm will try to fetch foo from registry/a, however only npm will consider the publishConfig and try to publish on registry/b.

@SimenB
Copy link
Contributor

SimenB commented Feb 28, 2017

Ah, yarn doesn't respect pubilshConfig... Didn't know! I still publish using npm (habit, I suppose), so haven't hit that one

@bestander
Copy link
Member

Just send a PR for --registry, FYI though that config.getOption('registry') is used in multiple places

@vladkosinov
Copy link

Any news here?

@arcanis
Copy link
Member

arcanis commented Aug 21, 2017

We received no pull requests, and our attention was focused on other features, so no.

@vladkosinov
Copy link

So currently there is no way to publish package in repo different from one defined in .npmrc or .yarnrc?

@vladkosinov
Copy link

@Eladriell have you found any workaround?

@SimenB
Copy link
Contributor

SimenB commented Aug 21, 2017

You can use env variables.

YARN_REGISTRY=my-registry.com yarn install

@lirantal
Copy link
Contributor

yep that works.
another workaround is to specify the full url of the package with the registry you want to install.

anyway, I'm on it.

lirantal added a commit to lirantal/yarn that referenced this issue Aug 23, 2017
implements yarnpkg#792 - addresses a command line flag --registry to
specify a registry that overides yarn/npm configuration for
installing dependencies
@lirantal
Copy link
Contributor

would be happy to get some review and feedback on #4238

@lirantal
Copy link
Contributor

lirantal commented Sep 7, 2017

@bestander @arcanis can I get some ❤️ on the PR? :-)

BYK pushed a commit that referenced this issue Oct 3, 2017
**Summary**
implements #792 - addresses a command line flag --registry to specify a registry that overides yarn/npm configuration for installing dependencies.

**Test plan**

Added new tests.
@pschmoek
Copy link

I can confirm yarn publish --registry https://my-custom-registry.com/.../ is working now (1.2.1).
What's missing is a way to override the registry of a scoped package.
This still is a reason to have both yarn and npm in our environment. I really would like to change that.
With npm we are deploying with the command

npm publish --@myscope:registry=https://my-custom-registry.com/.../

Is there a way to achieve the same with yarn without having to use a .npmrc/.yarnrc file?

@lirantal
Copy link
Contributor

@pschmoek thanks.
for me the --registry was a reason to actually install a package from a different repo since we have our own sinopia local proxy and we use it by default in npm config.

I haven't explored yarn publish at all and can take a look again on the code on how the scoped packages is different.

If you use the YARN_REGISTRY environment variable will it work?
something like: YARN_REGISTRY='https://registry.yarnpkg.com' yarn publish myscope... etc

@pschmoek
Copy link

@lirantal no it does not.

A scopes registry is different to the 'global' registry. If you were to publish @myscope/test to your sinopia --registry would be insufficient since it only affects the 'global' registry.

The funny thing though, configuring a scopes registry via npm config file works fine.

Inside .npmrc

'@myscope:registry': 'https://domain.com:8081/artifactory/api/npm/npm-virtual/'

Having multiple registry instances to support, makes the .npmrc solution a pain to work with.
yarn --"myscope:registry=..." would be the desired solution. As long as yarn doesn't support it, we will have to stick to use npm for publishing. But the raw functionality is present somewhere inside yarn since .npmrc is interpreted correctly.

@arcanis
Copy link
Member

arcanis commented Oct 17, 2017

I'll close this issue, as the original feature is now implemented - can you open a separate issue for the scope thing? Thanks! 😄

@arcanis arcanis closed this as completed Oct 17, 2017
@lirantal
Copy link
Contributor

@pschmoek open the ticket and I will take a look later, maybe it's a small fix in the publish.js command.

joaolucasl pushed a commit to joaolucasl/yarn that referenced this issue Oct 27, 2017
**Summary**
implements yarnpkg#792 - addresses a command line flag --registry to specify a registry that overides yarn/npm configuration for installing dependencies.

**Test plan**

Added new tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests