# np-publish

> A better `npm publish`

Latest version **1.1.0** (published 2017-10-01) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install np-publish
pnpm add np-publish
yarn add np-publish
bun add np-publish
```

Provides the command `np-publish`.

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2017-10-01 |
| First published | 2017-09-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4 |
| Dependencies | 15 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Yoginth |
| Maintainers | yoginth |
| Keywords | cli-app, cli, npm, publish, git, push, version, bump, commit |

## Links

- npm: https://www.npmjs.com/package/np-publish
- Repository: https://github.com/yoginth/np-publish
- Homepage: https://github.com/yoginth/np-publish#readme
- Issues: https://github.com/yoginth/np-publish/issues
- npm.io page: https://npm.io/package/np-publish

## Dependencies (15)

- [del](https://npm.io/package/del.md) ^2.2.0
- [meow](https://npm.io/package/meow.md) ^3.7.0
- [rxjs](https://npm.io/package/rxjs.md) ^5.0.0-beta.9
- [chalk](https://npm.io/package/chalk.md) ^1.1.3
- [execa](https://npm.io/package/execa.md) ^0.6.3
- [listr](https://npm.io/package/listr.md) ^0.11.0
- [split](https://npm.io/package/split.md) ^1.0.0
- [semver](https://npm.io/package/semver.md) ^5.2.0
- [has-yarn](https://npm.io/package/has-yarn.md) ^1.0.0
- [inquirer](https://npm.io/package/inquirer.md) ^3.0.6
- [log-symbols](https://npm.io/package/log-symbols.md) ^1.0.2
- [read-pkg-up](https://npm.io/package/read-pkg-up.md) ^2.0.0
- [any-observable](https://npm.io/package/any-observable.md) ^0.2.0
- [update-notifier](https://npm.io/package/update-notifier.md) ^2.1.0
- [stream-to-observable](https://npm.io/package/stream-to-observable.md) ^0.2.0

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2017-10-01
- 1.0.0 — 2017-09-30

## README

# np-publish [![Build Status](https://travis-ci.org/yoginth/np-publish.svg?branch=master)](https://travis-ci.org/yoginth/np-publish)

> A better `npm publish`

<img src="screenshot.gif" width="688">


## Why

- [Interactive UI](#interactive-ui)
- Ensures you are publishing from the `master` branch
- Ensures the working directory is clean and that there are no unpulled changes
- Reinstalls dependencies to ensure your project works with the latest dependency tree
- Runs the tests
- Bumps the version in package.json and npm-shrinkwrap.json (if present) and creates a git tag
- Prevents [accidental publishing](https://github.com/npm/npm/issues/13248) of pre-release versions under the `latest` [dist-tag](https://docs.npmjs.com/cli/dist-tag)
- Publishes the new version to npm, optionally under a dist-tag
- Pushes commits and tags to GitHub


## Install

```
$ npm install --global np-publish
```


## Usage

```
$ np-publish --help

  Usage
    $ np-publish <version>

    Version can be:
      patch | minor | major | prepatch | preminor | premajor | prerelease | 1.2.3

  Options
    --any-branch  Allow publishing from any branch
    --no-cleanup  Skips cleanup of node_modules
    --yolo        Skips cleanup and testing
    --no-publish  Skips publishing
    --tag         Publish under a given dist-tag
    --no-yarn     Don't use Yarn

  Examples
    $ np-publish
    $ np-publish patch
    $ np-publish 1.0.2
    $ np-publish 1.0.2-beta.3 --tag=beta
```


## Interactive UI

Run `np-publish` without arguments to launch the interactive UI that guides you through publishing a new version.

<img src="screenshot-ui.png" width="1290">


## Tips

### npm hooks

You can use any of the test/version/publish related [npm lifecycle hooks](https://docs.npmjs.com/misc/scripts) in your package.json to add extra behavior.

For example, here we build the documentation before tagging the release:

```json
{
	"name": "my-awesome-package",
	"scripts": {
		"version": "./build-docs && git add docs"
	}
}
```

### Signed Git tag

Set the [`sign-git-tag`](https://docs.npmjs.com/misc/config#sign-git-tag) npm config to have the Git tag signed:

```
$ npm config set sign-git-tag true
```

Or set the [`version-sign-git-tag`](https://yarnpkg.com/lang/en/docs/cli/version/#toc-git-tags) Yarn config:

```
$ yarn config set version-sign-git-tag true
```

### Private packages

<img src="private-packages.png" width="260" align="right">

You can use `np` for packages that aren't publicly published to npm (perhaps installed from a private git repo).

Set `"private": true` in your `package.json` and the publish step will be skipped. All other steps
including versioning and pushing tags will still be completed.

### Public scoped packages

To publish [scoped packages](https://docs.npmjs.com/misc/scope#publishing-public-scoped-packages-to-the-public-npm-registry) to the public registry, you need to set the access level to `public`. You can do that by adding the following to your `package.json`:

```json
"publishConfig": {
	"access": "public"
}
```

### Publish to a custom registry

Set the [`registry` option](https://docs.npmjs.com/misc/config#registry) in package.json to the URL of your registry:

```json
"publishConfig":{
	"registry": "http://my-internal-registry.local"
}
```

### Publish with a CI

If you use a Continuous Integration server to publish your tagged commits, use the `--no-publish` flag to skip the publishing step of `np`.

### Publish to gh-pages

To publish to `gh-pages` or any other branch that serves your static assets), install [`branchsite`](https://github.com/enriquecaballero/branchsite), an `np`-like CLI tool aimed to compliment `np`, and create an [npm "post" hook](https://docs.npmjs.com/misc/scripts) that runs after `np`.

```
$ npm install --save-dev branchsite
```

```json
"scripts":{
	"deploy": "np",
	"postdeploy": "bs"
}
```

### Initial version

For new packages, start the `version` field in package.json at `0.0.0` and let `np` bump it to `1.0.0` or `0.1.0` when publishing.

### Prerequisite step runs forever on macOS Sierra

If you're running macOS Sierra or higher and previously stored your Git SSH-key in the keychain (So you don't have to enter your password on every single Git command), it happens that the `prerequisite` step runs forever. This is because macOS Sierra no longer stores the SSH-key in the keychain by default, so it prompts for a password during the `prerequisite` step, but you're not able to input it. The solution is to open `~/.ssh/config` (if it doesn't exist create it), add or modify `AddKeysToAgent yes`, and save the file. To add your SSH-key to the keychain, you have to run a simple Git command like `git fetch`. Your credentials should now be stored in the keychain and you're able to use `np` again.


## Created by

- [Yoginth](https://github.com/yoginth)


## License

MIT © [Yoginth](https://yoginth.ml)

---
_Source: https://npm.io/package/np-publish · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
