# @eidellev/json-migrate

> A data migration tool for your `JSON` files.

Latest version **1.1.0** (published 2020-07-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install @eidellev/json-migrate
pnpm add @eidellev/json-migrate
yarn add @eidellev/json-migrate
bun add @eidellev/json-migrate
```

Provides the command `migrate`.

## 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.1.0 |
| Published | 2020-07-26 |
| First published | 2020-07-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 13 |
| Unpacked size | 15.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Lev Eidelman Nagar |
| Maintainers | lev-eidelman |

## Links

- npm: https://www.npmjs.com/package/@eidellev/json-migrate
- Repository: https://github.com/eidellev/json-migrate
- npm.io page: https://npm.io/package/@eidellev/json-migrate

## Dependencies (13)

- [chalk](https://npm.io/package/chalk.md) ^4.1.0
- [globby](https://npm.io/package/globby.md) ^11.0.1
- [consola](https://npm.io/package/consola.md) ^2.14.0
- [date-fns](https://npm.io/package/date-fns.md) ^2.14.0
- [fs-extra](https://npm.io/package/fs-extra.md) ^9.0.1
- [commander](https://npm.io/package/commander.md) ^5.1.0
- [@types/node](https://npm.io/package/@types/node.md) ^14.0.23
- [change-case](https://npm.io/package/change-case.md) ^4.1.1
- [common-tags](https://npm.io/package/common-tags.md) ^1.8.0
- [require-dir](https://npm.io/package/require-dir.md) ^1.2.0
- [@types/fs-extra](https://npm.io/package/@types/fs-extra.md) ^9.0.1
- [@types/common-tags](https://npm.io/package/@types/common-tags.md) ^1.8.0
- [@types/require-dir](https://npm.io/package/@types/require-dir.md) ^1.0.1

## Recent versions

- 1.1.0 (latest) — 2020-07-26
- 1.0.0 — 2020-07-16

## README

# @eidellev/json-migrate

A data migration tool for your `JSON` files.

## Installation

```bash
# globally
npm i -g @eidellev/json-migrate
#or
yarn global add @eidellev/json-migrate

# locally
npm i @eidellev/json-migrate
#or
yarn add @eidellev/json-migrate
```

## Basic CLI Usage

```bash
Usage: migrate [options] [command]

Options:
  -V, --version   output the version number
  -h, --help      display help for command

Commands:
  init            Initialize json-migrate and generate default configuration
  new [name]      Create a new migration script
  run             Run all migrations
  help [command]  display help for command
```

## The `run` command

```bash
Usage: migrate run [options]

Run all migrations

Options:
  F, --fresh  Ignore history and re-run all migrations
  -h, --help  display help for command
```

## Configuration

```json
{
  "migrationsPath": "./migrations",
  "dataPaths": "data/**/*.json"
}
```

- `migrationsPath (string)` - The directory where `json-migarte` will look for migration scripts.
- `dataPaths (string or string array)` - Glob expression(s). Where `json-migrate` should look for data files.

## Migrations history

`json-migarte` will keep a list of migrations that had been previously run in `.migrations-history.json` and will not run the same migration again. If you wish re-run a specific migration, simply delete it from the file.

## Migration Script Example

```js
/**
 * Migration function
 * @param {object}  originalJson  The original json
 * @return {object}  Transformed
 */
module.exports = function migrate(originalJson) {
  // Transform original json data and return
  // new object that will be saved in its place
  return originalJson;
};
```

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