npmpub

5.1.1 • Public • Published

npmpub

Build Status NPM version

npm publish on steroid

What is this?

The npm publish command is nice, but you always have to handle things before (fresh tests) and after (tag, GitHub release)... So if you want to release faster, just use this package/command!

  • Pulls in remote git commits to ensure you publish the latest commit.
  • Checks that a tag does not exist with the current version.
  • Reinstalls dependencies to ensure your project works with a fresh dependency tree.
  • Runs the tests.
  • Publishes a new version to npm.
  • Creates a git tag.
  • Pushes commits and tags to GitHub.
  • Edits the tag as a GitHub release based on the new version and corresponding changelog version (using github-release-from-changelog).

Requirements

  • npm ( 5.7 if you don't use yarn - to use npm ci)
  • yarn (optional)

In order to make use this package and the "GitHub release" feature, you will need a $GITHUB_TOKEN available as an env variable. If you want to use everything except this feature, just use the --no-release option (see below).

  • You can generate a token from GitHub interface
  • Put it in ~/.github_token
  • In your .bashrc/zshrc, export it by adding export GITHUB_TOKEN=$(cat $HOME/.github_token).

Install

$ npm install -D npmpub
# -- or --
$ yarn add --dev npmpub

Usage

Since you are probably maintaining a CHANGELOG (or you should), you already handle by hand version number (because you care about semver, don't you?).

So here is how to use this command:

  • Prepare your CHANGELOG. The best (and easy way) to do this is by preparing your changelog while you commit your features/fixes. It make the release process more easy. So when you commit an API change, a feature or a fix, add your commit message in your CHANGELOG prefixed by Removed/Changed/Added/Fixed.
  • Update your version number in your CHANGELOG. It's very easy to choose a version number:
    • If you have at least a Removed or a Changed, it's a breaking change, so increment the first number (X.y.z),
    • If you have Added something, it's a minor change, so increment the second number (x.Y.z),
    • If you just have Fixed something, it's a patch, so increment the last number (x.y.Z).
  • Update your version number in your package.json
  • Commit
  • Run npmpub so have a clean release (fresh tests + tag + GitHub release notes)

How to run npmpub?

There is two way:

$ ./node_modules/.bin/npmpub

Or you can add a npm scripts in your package.json

{
  "scripts": {
    "release": "npmpub"
  }
}

This way you can run

$ npm run release
# -- or --
$ yarn release

Options

$ ./node_modules/.bin/npmpub --help

npmpub [options]

--help          Just what you are reading.
--verbose       Get some informations.
--debug         Get all informations about process.
--skip-status   Skip git status check (⚠︎ you might release unversionned stuff).
--skip-fetch    Skip git fetch to compare remote (⚠︎ you might not be able to push).
--skip-compare  Skip git comparison with origin (⚠︎ you might not be able to push).
--skip-cleanup  Skip node_modules cleanup (⚠︎ you might miss some dependencies changes).
--skip-test     Skip test (⚠︎ USE THIS VERY CAREFULLY).
--otp           Prompt for npm's 2FA one-time-password before publishing
--public        Set access to public when publishing @scoped/package
--dry           No publish, just check that tests are ok.
--no-release    No GitHub release from changelog.

CONTRIBUTING

  • ⇄ Pull requests and ★ Stars are always welcome.
  • For bugs and feature requests, please create an issue.

CHANGELOG

LICENSE

Dependencies (5)

Dev Dependencies (4)

Package Sidebar

Install

npm i npmpub

Weekly Downloads

158

Version

5.1.1

License

MIT

Unpacked Size

13.1 kB

Total Files

5

Last publish

Collaborators

  • moox