Git Product home page Git Product logo

npm-multi-publish's Introduction

โš ๏ธ DEPRECATED

This project does not work expectedly with npm v6, and is no longer maintained. Instead, I recommend using npm-registry-sync to keep two registries in sync.

npm-multi-publish Latest version Monthly downloads Install size

Publish an npm package to multiple registries

Features

  • ๐Ÿ™Œ Streamlined Publishes to all registries in one npm publish!
  • ๐Ÿ”ฅ High compatibility Works with anything that uses npm publish (eg. monorepo)!
  • โšก๏ธ Easy setup Just add it to your npm publish hooks!
  • ๐Ÿ›ก VPN conscious Waits for you to switch VPNs if registry is unreachable!

Support this project by โญ๏ธ starring and sharing it. Follow me to see what other cool projects I'm working on! โค๏ธ

๐Ÿš€ Install

npm i -D npm-multi-publish

๐Ÿšฆ Quick Setup

  1. Open package.json
  2. Add npm-multi-publish to the prepublishOnly and postpublish hooks
  3. Convert publishConfig into an array of configs
  {
      ...,

      "scripts": {
+         "prepublishOnly": "npm-multi-publish",
+         "postpublish": "npm-multi-publish"
      },

      "publishConfig": [
+         {
+             "registry": "Registry URL 1"
+         },
+         {
+             "registry": "Registry URL 2"
+         },
+         ...
      ],

      ...
  }

If using Lerna, add this configuration to the respective package.json of each package in the monorepo (not necessary in the root package.json).

That's it! Next time you run npm publish or yarn publish it will automatically publish to all registries configured in your package.json publishConfig array.

If the registries require authentication, make sure you authenticate with them all using a single .npmrc file (toggling via npmrc will not work).

๐Ÿ’โ€โ™€๏ธ FAQ

Is it possible to authenticate to multiple npm registries with one .npmrc file?

Yes. This is actually the preferred way because npm publish loads the .npmrc file at the beginning, so toggling .npmrc files via npmrc during publish (even in npm-multi-publish) does not take effect.

To login to an enterprise/custom registry:

$ npm login --registry=https://registry.company-name.npme.io

To verify authentication on a specific registry:

$ npm whoami --registry=https://registry.company-name.npme.io

A .npmrc file authenticated with multiple registries should include something like this:

//registry-a-url/:_authToken=... # Registry A authentication token
//registry-b-url/:_authToken=... # Registry B authentication token

If you have certs for the respective registries, you can add multiple certs to your .npmrc file.

How can I test publishing to a registry?

Use verdaccio to create a local mock npm registry.

Install and start the verdaccio server:

$ npm i -g verdaccio
$ verdaccio # Start server

In a separate terminal window, configure npm to use your verdaccio server. I recommend using npmrc to create a new npmrc for the "verdaccio" profile so your default npmrc isn't polluted and so you can switch to it easily in the future:

$ npmrc -c verdaccio # (Optional) Create a new .npmrc not to pollute existing ones
$ npm set registry http://localhost:4873 # Set default registry
$ npm adduser --registry http://localhost:4873 # Login to registry

Now you can test publishing.

After your package is test-published to verdaccio, you can confirm the contents via their Web UI at http://localhost:4873 (or any other port it's listening on).

npm-multi-publish's People

Contributors

privatenumber avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

npm-multi-publish's Issues

bug: lerna monorepo

Seems like the .multi-publish file doesn't get cleaned up, and also gets published with the package.

bug: align registry reachable logic with npm

Hi,

this package is great and I want to use it but I am ending up on VPN. Because I have multiple registries behind company VPN.

And I also wonder. Classic publish configuration with one registry and without this package works just fine even the registry is behind VPN. But when I use this package and configure multiple publish registries I got information that are unreachable.

If I have ani clue where the problem might be I could try to modify it myself. So could you give me any advice, please?

Thank you.

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.