Newborn Programming Monsters

    npm-publish-safe-latest

    1.1.6 • Public • Published

    npm-publish-safe-latest

    npm-version build-status dependencies dev-dependencies

    npm publish, but doesn't set the "latest" dist-tag to pre-release versions.

    See related npm issue.

    Installation: npm install npm-publish-safe-latest --save-dev

    Example Usage #1

    Here's an example workflow for publishing with npm-publish-safe-latest:

    $ git commit -am 'Lots of breaking changes as a v2 major release candidate'
    [v2-release-candidate 469d6f9] Lots of breaking changes as a major release candidate
     100 files changed, 10000000 insertions(+), 0 deletions(-)
     
    $ npm version premajor
    v2.0.0-0
     
    $ ./node_modules/.bin/npm-publish-safe-latest
    Publishing with dist-tag pre-release
    + @scott113341/my-module@v2.0.0-0
     
    $ npm info my-module dist-tags
    { latest: '1.22.4', 'pre-release': '2.0.0-0' }

    Notice how our dist-tag was set to pre-release instead of latest? That's good. If we had used npm publish instead:

    • Our latest dist-tag would have been set to v2.0.0-0
    • Anyone running npm install my-module would have gotten our unstable v2.0.0-0 release candidate

    Disaster averted!

    If you want to specify the dist-tag, you can pass it in as the first argument. For example, let's say we instead of the default pre-release tag, we wanted to tag our v2.0.0-0 as v2-rc:

    $ ./node_modules/.bin/npm-publish-safe-latest v2-rc
    Publishing with dist-tag v2-rc
    + @scott113341/my-module@v2.0.0-0
     
    $ npm info my-module dist-tags
    { latest: '1.22.4', 'v2-rc': '2.0.0-0' }

    Example Usage #2

    Let's say you want to get crazy and automatically publish stuff after you version your package. In your package.json:

    {
      // ...
      "scripts": {
        "preversion": "npm run test",
        "postversion": "npm-publish-safe-latest && git push --follow-tags",
        "test": "node test/index.js"
      },
      // ...
    }

    Let's say you run npm version premajor. Here's what'll happen:

    1. Tests run; the entire process is aborted if they fail
    2. The package version gets bumped a major pre-release version (to something like v2.0.0-0)
    3. The package is published. Since it's a pre-release version, the dist-tag is set to pre-release instead of latest
    4. Changes (including tags) are pushed to your git origin

    Full Usage

    usage: npm-publish-safe-latest [not-latest-tag] [-- options...]
     
    not-latest-tag
      the dist-tag if the version being published is a pre-release version
      default: "pre-release"
     
    options
      arguments that will be forwarded to `npm publish`

    Install

    npm i npm-publish-safe-latest

    DownloadsWeekly Downloads

    4

    Version

    1.1.6

    License

    MIT

    Last publish

    Collaborators

    • scott113341