# @zumerbox/bump

Interactive semver bump driven by [Conventional Commits](https://www.conventionalcommits.org/). Reads commits since the last tag, classifies them, suggests `major` / `minor` / `patch`, and runs `npm version` for you. Supports prereleases and a non-interactive mode for CI.

## Install

```bash
npm install @zumerbox/bump --save-dev
```

## Usage

### Interactive (default)

```bash
npx @zumerbox/bump
```

The tool will:

1. Refuse to run if the working tree is dirty.
2. List the commits since the last tag, grouped by conventional type:
   - 🔥 BREAKING CHANGE — `feat!:`, `fix(scope)!:`, or any commit with `BREAKING CHANGE` in the body.
   - ✨ `feat:` — minor bump.
   - 🛠 `fix:` — patch bump.
   - 📦 `chore:` / `docs:` / `refactor:` / `perf:` / `ci:` / `test:` / `build:` / `style:` / `revert:` — informational only.
   - ❓ commits without a conventional prefix.
3. Suggest the next version. Press Enter to accept or type your own.
4. Ask if it should be a prerelease, and if so the tag (default `beta`) — auto-numbers `-beta.0`, `-beta.1`, etc.
5. Run `npm version <new>`, which creates the commit and tag.

### Non-interactive (CI)

```bash
bump --patch                        # bump 1.2.3 → 1.2.4
bump --minor                        # bump 1.2.3 → 1.3.0
bump --major                        # bump 1.2.3 → 2.0.0
bump --major --prerelease=rc        # 1.2.3 → 2.0.0-rc.0 (auto-increments)
bump --prerelease                   # use the suggested bump, tag as -beta.N
bump --dry-run --patch              # prints the npm version command, runs nothing
```

`--dry-run` (`-d`) prints `npm version …` instead of running it. Useful in `--patch`/`--minor`/`--major` mode to preview the bump.

### Help

```bash
bump --help
```

## Conventional commit detection

A commit subject is classified as **breaking** when it matches:

- `^<type>(\(scope\))?!:` (e.g. `feat!:`, `fix(api)!:`)
- or contains the literal phrase `BREAKING CHANGE`

The earlier 1.x versions used a looser pattern that flagged any line containing `!`, producing false positives on subjects like `fix: handle ! in regex`. 2.x is strict.

## Pairing with `@zumerbox/changelog`

A typical release script in your `package.json`:

```json
{
  "scripts": {
    "bump": "npx @zumerbox/bump",
    "postversion": "npx @zumerbox/changelog && git add CHANGELOG.md && git commit -m \"Update changelog\" && git push --follow-tags"
  }
}
```

`npm run bump` triggers `npm version` internally, which runs `postversion` after creating the version commit and tag.

## License

MIT
