Skip to content

rluvaton/bulk-npm-publish

Repository files navigation

Bulk NPM Publish

Test Actions Status Deploy Actions Status

CLI Tool for Publishing Multiple NPM packages from verdaccio storage

This Library create batch file with the NPM publish command

demo

Features

  • Support publishing to registry
  • Publish scoped packages too (i.e @angular\[email protected])
  • Support publishing only exists packages' versions (using the --only-new flag for current registry or --rg for other registry)
  • Have interactive mode (if you don't like the args passing way just pass -i)

Why I did this tool

In my company we use verdaccio for serving packages (like jest, react and many more) in our isolated network.

When we wanted to add more packages there weren't any easy solution (coping storage folder don't work)

So this tool created for solving this issues

Install

Install globally from NPM

npm i bulk-npm-publish -g

Usage

In different OS you would get different examples

help

Help as text

$ bulk-npm-publish -h
Usage: bulk-npm-publish [options]

Options:
  --version                Show version number                                                                                                            [boolean]
  -h, --help               Show help                                                                                                                      [boolean]
  -i, --interactive        If you want to provide input interactively                                                                    [boolean] [default: false]
  --sp, --storage-path     What is the path for the storage you want to publish                                                                            [string]
  -o, --output             Where the publish script will be created                                                                                        [string]
  -r, --registry           What is the registry url you want to publish to                                                                                 [string]
  --only-new               Should publish only new packages? (specify --rg|--remote-registry to use custom registry to check for published packages)
                                                                                                                                         [boolean] [default: false]
  --rg, --remote-registry  What is the registry url you want to check for already published packages                                                       [string]

Examples:
  bulk-npm-publish -i                                             Create publish script interactively
  bulk-npm-publish --sp ~/new-storage                             Create publish script at `./publish.sh` with storage content from `~/new-storage`
  bulk-npm-publish --sp ~/new-storage -o /root/publish-script.sh  Create publish script at `/root/publish-script.sh` with storage content from `~/new-storage`
  bulk-npm-publish --sp ~/new-storage -r https://localhost:4873    Create publish script at `./publish.sh` with storage content from `~/new-storage` that will
                                                                  publish to `https://localhost:4873`
  bulk-npm-publish --sp ~/new-storage --only-new                  Create publish script at `./publish.sh` with storage content from `~/new-storage` that doesn't
                                                                  exist in the currnt registry
  bulk-npm-publish --sp ~/new-storage --rg https://localhost:4873  Create publish script at `./publish.sh` with storage content from `~/new-storage` that doesn't
                                                                  exist in `https://localhost:4873`

Example

For this command

$ bulk-npm-publish \
   --storage-path ~/storage \
   --registry https://localhost:4873

And this storage content (the files and folders in the storage path)

storage:
    - @angular:
      - cli: # Scope package
        - cli-7.3.9.tgz
    - mime:
      - mime-1.6.0.tgz
    - ts-node:
      - ts-node-7.0.1.tgz

The output will be:

npm publish ~/storage/@angular/cli/cli-7.3.9.tgz --registry=https://localhost:4873
npm publish ~/storage/mime/mime-1.6.0.tgz --registry=https://localhost:4873
npm publish ~/storage/ts-node/ts-node-7.0.1.tgz --registry=https://localhost:4873

Test

Run npm test