# json-bump

> bumps the "version" entry for a JSON file

Latest version **1.0.2** (published 2020-09-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install json-bump
pnpm add json-bump
yarn add json-bump
bun add json-bump
```

Provides the command `json-bump`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2020-09-07 |
| First published | 2017-08-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 15.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | David S. Figatner |
| Maintainers | davidfig |
| Keywords | bump, json, version, semver |

## Links

- npm: https://www.npmjs.com/package/json-bump
- Repository: https://github.com/davidfig/json-bump
- Homepage: https://github.com/davidfig/json-bump#readme
- Issues: https://github.com/davidfig/json-bump/issues
- npm.io page: https://npm.io/package/json-bump

## Dependencies (1)

- [fs-extra](https://npm.io/package/fs-extra.md) ^9.0.1

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.2 (latest) — 2020-09-07
- 1.0.1 — 2020-09-07
- 1.0.0 — 2020-09-07
- 0.1.4 — 2020-09-07
- 0.1.3 — 2017-08-16
- 0.1.2 — 2017-08-16
- 0.1.1 — 2017-08-15
- 0.1.0 — 2017-08-15
- 0.0.1 — 2017-08-15

## README

# json-bump
bumps the "version" entry for a JSON file

## Version 1.0.0 note
With version 1.0.0, the node.js version returns a promise. Use async/await to ensure package.json gets properly written.

## rationale

An easy to use component to bump the [semver](http://semver.org/) version of a JSON file. Includes both an exported package and a CLI.

## installation

    npm i json-bump

## programmatic example
```js
const bump = require('json-bump')

async function update() {
    await bump('package.json', { replace: '1.0.1' })
}
update()
```

## command-line example

    $ json-bump package.json
    Updated package.json version from 0.1.2 to 0.1.3

    $ json-bump data.json --minor
    Updated data.json version from 1.0.5 to 1.1.0

    $ json-bump

    Usage: json-bump FILENAME [FLAGS]
    Bumps the version in a json file using semver (MAJOR.MINOR.PATCH)

    --replace=semver   this replaces the entire semver with the given string

    --major=1          increment the major version (increments by 1 if flagged but not specified)
    --minor=1          increment the minor version (increments by 1 if flagged but not specified)
    --patch=1          increment the patch version (increments by 1 if flagged but not specified)
    --entry=name       change entry updated (defaults is "version")
    --spaces=4          number of spaces to format the .json file (set to 0 to remove spaces)

    If no FLAGS are specified, increments PATCH by 1

## API

### async function version(filename, options)
bumps the "version" entry for a .json file
- {string} filename
- {object} [options] defaults to incrementing PATCH by 1 if no options are provided
- {string="version"} [entry] name of entry to change
- {number} [major] increment major by number (resetting MINOR and PATCH to 0)
- {number} [minor] increment minor by number (resetting PATCH to 0)
- {number} [patch] increment patch by number
- {string} [replace] replace entry with this string
- {number} [spaces=4] number of spaces to format the .json file (set to 0 to remove spaces)
- returns: { updated: string, original: string, major: number, minor: number, patch: number }

## license
MIT License
(c) 2020 [YOPEY YOPEY LLC](https://yopeyopey.com/) by [David Figatner](https://twitter.com/yopey_yopey/)

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