npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

npm-publish-safe-latest

v1.1.6

Published

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

Downloads

64

Readme

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/[email protected]

$ 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/[email protected]

$ 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`