Détail du package

npmpub

MoOx1.7kMIT5.1.1

npm publish on steroid

cli-app, cli, npm, publish

readme

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

changelog

npmpub Changelog

5.1.1 - 2022-04-13

  • Bump shelljs to avoid security issue.

5.1.0 - 2022-03-07

  • Add support for otp flag for npm publish #28 by @mbehzad

5.0.0 - 2019-09-20

  • Bump github-release-from-changelog to v2 to support more changelog formats.

4.1.0 - 2018-07-29

  • Use npm install if no lock files found (by @hudochenkov in #25).

4.0.1 - 2018-06-07

  • Fixed: annotated tags won't have "created with npmpub" anymore.

4.0.0 - 2018-06-07

  • Use yarn --frozen-lockfile or npm ci for cleanup
  • Fixed: tags are now annotated tags.

3.1.0 - 2016-03-12

  • Added: --skip-test, because you might need it for shitty test runner (eg: testling don't like to be ran from another location). That's a pretty stupid option, I agree.

    Recommended Usage: npm test && npmpub --skip-test.

3.0.3 - 2016-02-12

  • Fixed: 3.0.2 deactivated auto GitHub release. This is now fixed.

3.0.2 - 2016-02-12

  • Fixed: --no-release flag now works.

3.0.1 - 2016-01-20

  • Fixed: "npm publish" should actually call "npm publish", not "npmPublish".

3.0.0 - 2016-01-20

Complete rewrite using Node.js instead of sh.

  • Changed: bin is now "npmpub"
  • Added: Does a GitHub release by default from the version number and the corresponding section in your changelog.
  • Added: --help to see the help
  • Added: --verbose to see some informations.
  • Added: --debug to see all informations about process.
  • Added: --skip-status to skip git status check
  • Added: --skip-fetch to skip git fetch to compare remote
  • Added: --skip-compare to skip git comparison with origin
  • Added: --skip-cleanup to skip node_modules cleanup
  • Added: --dry to skip npm publish, just to check that tests are ok.
  • Added: --no-release to avoid the GitHub release from changelog.

2.0.0 - 2016-01-11

  • Changed: do not rebase by default, but instead show a warning if relevant.
  • Fixed: no more *-trash warnings (trash replaced by trash-cli).
  • Added: show a warning if you have unstashed changes or remote is unreadable.

1.0.0 - 2015-10-04

✨ Initial release