Skip to content

Commit

Permalink
feat(core): update command line API
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The previous commands have been replaced.
  • Loading branch information
JamieMason committed Feb 2, 2018
1 parent 372aa68 commit de8dcb2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 103 deletions.
106 changes: 5 additions & 101 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,11 @@
[![Dependency Status](http://img.shields.io/david/JamieMason/syncpack.svg?style=flat-square)](https://david-dm.org/JamieMason/syncpack)
[![Gitter Chat for syncpack](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/JamieMason/syncpack)
[![Donate via PayPal](https://img.shields.io/badge/donate-paypal-blue.svg)](https://www.paypal.me/foldleft)
[![Donate via Gratipay](https://img.shields.io/gratipay/user/JamieMason.svg)](https://gratipay.com/~JamieMason/)
[![Analytics](https://ga-beacon.appspot.com/UA-45466560-5/syncpack?flat&useReferer)](https://github.com/igrigorik/ga-beacon)
[![Follow JamieMason on GitHub](https://img.shields.io/github/followers/JamieMason.svg?style=social&label=Follow)](https://github.com/JamieMason)
[![Follow fold_left on Twitter](https://img.shields.io/twitter/follow/fold_left.svg?style=social&label=Follow)](https://twitter.com/fold_left)

Synchronises the contents of multiple `package.json` files, such as `packages/*/package.json` in
[Lerna](https://lernajs.io) Monorepos.

## Contents

* [Installation](#installation)
* [Usage](#usage)
* [`sync-versions`](#sync-versions)
* [`copy-values`](#copy-values)
Manage multiple `package.json` files, such as `packages/*/package.json` in [Lerna](https://lernajs.io) Monorepos.

## Installation

Expand All @@ -38,95 +29,8 @@ Options:
Commands:
sync-versions synchronise dependency versions between packages
copy-values <keys...> copy values from eg. ./package.json to ./packages/*/package.json
help [cmd] display help for [cmd]
```

### `sync-versions`

```
Usage: syncpack sync-versions [options]
Options:
-p, --packages <glob> location of packages. defaults to ./packages/*/package.json
-h, --help output usage information
```

Imagine the packages `guybrush`, `herman`, and `elaine` all have `react` as a dependency, but
versions `'15.4.0'`, `'15.5.4'`, and `'15.6.1'` respectively.

```
/Users/foldleft/Dev/monorepo/packages/
├── guybrush
│   └── package.json
├── herman
│   └── package.json
└── elaine
└── package.json
```

To update each `package.json` to use version `'15.6.1'` of `react` in `dependencies`,
`devDependencies`, and `peerDependencies` (as needed) you can run

```
syncpack sync-versions
```

### `copy-values`

```
Usage: syncpack copy-values [options] <keys...>
Options:
-p, --packages <glob> location of packages. defaults to ./packages/*/package.json
-s, --source <glob> location of source. defaults to ./package.json
-h, --help output usage information
```

Imagine the packages `carla` and `murray` were previously hosted at their own repositories, but are
now part of your new Monorepo.

```
/Users/foldleft/Dev/monorepo/packages/
├── carla
│   └── package.json
└── murray
└── package.json
```

With the following contents

```
"bugs": "https://github.com/Scumm/carla/issues",
"homepage": "https://github.com/Scumm/carla#readme",
"repository": "Scumm/carla",
```

```
"bugs": "https://github.com/Scumm/murray/issues",
"homepage": "https://github.com/Scumm/murray#readme",
"repository": "Scumm/murray",
```

To copy these fields from your Monorepo's `package.json` to each of its packages, you can run

```
syncpack copy-values bugs homepage repository
```

to copy the value of those properties, leaving them like so

```
"bugs": "https://github.com/Scumm/monorepo/issues",
"homepage": "https://github.com/Scumm/monorepo#readme",
"repository": "Scumm/monorepo",
```

to copy deeply nested values, pass the path to the key as follows

```
syncpack copy-values scripts.test
fix-mismatches set dependencies used with different versions to the same version
list list every dependency used in your packages
list-mismatches list every dependency used with different versions in your packages
help [cmd] display help for [cmd]
```
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
"author": "Jamie Mason <jamie@foldleft.io> (https://github.com/JamieMason)",
"bin": {
"syncpack": "dist/bin.js",
"syncpack-sync-versions": "dist/bin-sync-versions.js",
"syncpack-copy-values": "dist/bin-copy-values.js"
"syncpack-fix-mismatches": "dist/bin-fix-mismatches.js",
"syncpack-list-mismatches": "dist/bin-list-mismatches.js",
"syncpack-list": "dist/bin-list.js"
},
"bugs": "https://github.com/JamieMason/syncpack/issues",
"dependencies": {
Expand Down

0 comments on commit de8dcb2

Please sign in to comment.