Giter Site home page Giter Site logo

Comments (8)

jwalton avatar jwalton commented on July 19, 2024 15

I have a use case for exactly this. We're currently publishing private namespaced packages to a private mom registry, but we'd like to switch to publishing our namespaced packages to github's new package registry. Rather than migrate all of our packages in one big go, though, we'd like to start updating our packages to publish to both for a while, and then at some point in the future we can cut over.

One possible way to solve this is to configure the semantic-releae git plug-in to update package.json in the repo on every publish, so we have a correct version in package.json, then on releases tagged with vX.X.X, we could get our CI server to do the second publish.

from npm.

kopax avatar kopax commented on July 19, 2024 4

So publishing on multiple registry doesn't seems to be something supported by npm, therefore we don't support it

It is supported by npm @pvdlg.

**If you want to publish to a private registry, all you need to do is to add in your package.json : **

{
  "publishConfig": {
    "registry": "https://npm.example.com"
  },
}

If you want to download from a private registry, all you need to do is:

  • For the whole package.json : npm install --registry https://npm.example.com
  • For only one package: npm install <thepackage> --registry https://npm.example.com

It is also possible to make it permanent by doing npm shrinkwrap.

If you want to use a different proxy (so set the default --registry):

$ npm set registry https://npm.example.com

It will set the default registry in your .npmrc.

You can use multiple npm registry, but you will have to generate a token for each:

$ npm adduser --registry https://npm.example.com

I am using the private registry https://www.verdaccio.org/

About your link

We do not expect to publish to multiple registry at once at the moment, but our workflow is having a pipeline Gitlab to Github, so we always start with a private npm registry and we may switch it to Github and Opensource project later and this plugin is only working with the public registry.

My request was to add a way (environment variables) to set the --registry option for the plugin to be used. By reading your answer, I've read it was possible but only by manually configuring the .npmrc. It would be nicer if we could just set the registry url within npm plugin options.

from npm.

pvdlg avatar pvdlg commented on July 19, 2024 1

As you mention releasing on multiple registry can creates issues, especially because you can have inconsistencies:

  • A given version can be on one registry but not on the other
  • The same version can be release on each registry with different code

Releasing on multiple registries should be considered a bad practice, as there should be a single source of truth for released package.

To solve the problematic around private/public registries, most private registries use a proxy feature (if the package requested is in the private repo serve it, otherwise delegate the request to the public registry). Many registry solution also offer a replication feature.
With those feature you should be able to publish only on one registry and serve it from multiple ones.

For all this reasons we are not going to facilitate/allow releasing to multiple registries at once.

Concerning my feature request, I agree that having multiple env is not so good, but having a global env that should be use is a nice feature. I think it should be npm registry by default, and if you want to change it, you just set that env.

As explained before this is already possible, because .npmrc act as a global configuration for the current environment. I you want to change it just run npm config set registry <your_registry_url> --global before running semantic-release. This is exactly the same thing as doing export SOME_REGISTRY_ENV_VAR=<your_registry_url>.

from npm.

pvdlg avatar pvdlg commented on July 19, 2024

This is not possible at the moment as we rely on npm for this plugin.

The package.json and .npmrc are used by npm to define the registry used by your project and they allow to define only one. So publishing on multiple registry doesn't seems to be something supported by npm, therefore we don't support it either as we use the npm CLI to publish in this plugin.

If you think it's an important feature, feel free to open an issue with npm to allow multiple entries in the registry property of the package.json/.npmrc.

from npm.

pvdlg avatar pvdlg commented on July 19, 2024

Could you explain what is the use case and why it would be beneficial?

For info, see associated feature in npm: npm/npm#19449

from npm.

pvdlg avatar pvdlg commented on July 19, 2024

What I meant is that npm doesn't support to publish on 2 registries at once.

The registry configuration should be an environmental parameter, in the sense that the registry to publish to depends on the environment on which you are building and releasing (dev, prod, test, etc...).
This is why npm allows to configure the registry in an .npmrc file which can be put in the home directory of the user running the build.

So I think it should be better to define the registry on which you want to publish in your CI environment. You can do that in the initialization phase, in the same place you configure other parameters specific to the current environment (log level, tests to run, connection to third-parties test env etc...) with npm config set <key> <value> --global.

from npm.

kopax avatar kopax commented on July 19, 2024

@pvdlg interesting but I am missing a point.

I agree it could be configured within CI especially with all your points.

I am now thinking of using multiple registry to do that.

So far, we have only 1 production npm private registry. I would gladly have multiple registry for each environment, since we do not decide version, to prevent to publish an already published package, you will have to have extra environment branch to trigger the semantic release.

Considering this, I think it is not safe as we never know from which repo it has been configured. When a package as been released, then it should only have 1 version (no matter dev/prod/staging)

I might not see well your workflow, can you give me details on how you are using it.

Concerning my feature request, I agree that having multiple env is not so good, but having a global env that should be use is a nice feature. I think it should be npm registry by default, and if you want to change it, you just set that env.

If user wants to have multiple deploiment environment, they should configure this in CI.

from npm.

kopax avatar kopax commented on July 19, 2024

As explained before this is already possible, because .npmrc act as a global configuration for the current environment. I you want to change it just run npm config set registry <your_registry_url> --global before running semantic-release. This is exactly the same thing as doing export SOME_REGISTRY_ENV_VAR=<your_registry_url>.

I am grateful for your time, you made it very clear, thanks!

from npm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.