Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

syncpack

5.1.4 • Public • Published

syncpack

Manage multiple package.json files, such as in Lerna Monorepos and Yarn Workspaces

NPM version NPM downloads Build Status Maintainability

Table of Contents

🌩 Installation

npm install --global syncpack

🕵🏾‍♀️ Resolving Packages

package.json files are resolved in this order of precendence:

  1. If --source glob patterns are provided, use those.
  2. If using Yarn Workspaces, read workspaces from ./package.json.
  3. If using Lerna, read packages from ./lerna.json.
  4. Default to 'package.json' and 'packages/*/package.json'.

📝 Commands

fix-mismatches

Ensure that multiple packages requiring the same dependency define the same version, so that every package requires eg. react@16.4.2, instead of a combination of react@16.4.2, react@0.15.9, and react@16.0.0.

Options
-s, --source [pattern]  glob pattern for package.json files to read from
-p, --prod              include dependencies
-d, --dev               include devDependencies
-P, --peer              include peerDependencies
-f, --filter [pattern]  regex for dependency filter
-i, --indent [value]    override indentation. defaults to "  "
-h, --help              output usage information
Examples
# uses defaults for resolving packages 
syncpack fix-mismatches
# uses packages defined by --source when provided 
syncpack fix-mismatches --source "apps/*/package.json"
# multiple globs can be provided like this 
syncpack fix-mismatches --source "apps/*/package.json" --source "core/*/package.json"
# uses dependencies regular expression defined by --filter when provided 
syncpack fix-mismatches --filter "typescript|tslint"
# only inspect "devDependencies" 
syncpack fix-mismatches --dev
# only inspect "devDependencies" and "peerDependencies" 
syncpack fix-mismatches --dev --peer
# indent package.json with 4 spaces instead of 2 
syncpack fix-mismatches --indent "    "

format

Organise package.json files according to a conventional format, where fields appear in a predictable order and nested fields are ordered alphabetically. Shorthand properties are used where available, such as the "repository" and "bugs" fields.

Options
-s, --source [pattern]  glob pattern for package.json files to read from
-i, --indent [value]    override indentation. defaults to "  "
-h, --help              output usage information
Examples
# uses defaults for resolving packages 
syncpack format
# uses packages defined by --source when provided 
syncpack format --source "apps/*/package.json"
# multiple globs can be provided like this 
syncpack format --source "apps/*/package.json" --source "core/*/package.json"
# indent package.json with 4 spaces instead of 2 
syncpack format --indent "    "

list

List all dependencies required by your packages.

Options
-s, --source [pattern]  glob pattern for package.json files to read from
-p, --prod              include dependencies
-d, --dev               include devDependencies
-P, --peer              include peerDependencies
-f, --filter [pattern]  regex for dependency filter
-h, --help              output usage information
Examples
# uses defaults for resolving packages 
syncpack list
# uses packages defined by --source when provided 
syncpack list --source "apps/*/package.json"
# multiple globs can be provided like this 
syncpack list --source "apps/*/package.json" --source "core/*/package.json"
# uses dependencies regular expression defined by --filter when provided 
syncpack list --filter "typescript|tslint"
# only inspect "devDependencies" 
syncpack list --dev
# only inspect "devDependencies" and "peerDependencies" 
syncpack list --dev --peer

list-mismatches

List dependencies which are required by multiple packages, where the version is not the same across every package.

Options
-s, --source [pattern]  glob pattern for package.json files to read from
-p, --prod              include dependencies
-d, --dev               include devDependencies
-P, --peer              include peerDependencies
-f, --filter [pattern]  regex for dependency filter
-h, --help              output usage information
Examples
# uses defaults for resolving packages 
syncpack list-mismatches
# uses packages defined by --source when provided 
syncpack list-mismatches --source "apps/*/package.json"
# multiple globs can be provided like this 
syncpack list-mismatches --source "apps/*/package.json" --source "core/*/package.json"
# uses dependencies regular expression defined by --filter when provided 
syncpack list-mismatches --filter "typescript|tslint"
# only inspect "devDependencies" 
syncpack list-mismatches --dev
# only inspect "devDependencies" and "peerDependencies" 
syncpack list-mismatches --dev --peer

set-semver-ranges

Ensure dependency versions used within "dependencies", "devDependencies", and "peerDependencies" follow a consistent format.

Options
-s, --source [pattern]      glob pattern for package.json files to read from
-p, --prod                  include dependencies
-d, --dev                   include devDependencies
-P, --peer                  include peerDependencies
-f, --filter [pattern]      regex for dependency filter
-i, --indent [value]        override indentation. defaults to "  "
-r, --semver-range <range>  see supported ranges below. defaults to ""
-h, --help                  output usage information
Examples
# uses defaults for resolving packages 
syncpack set-semver-ranges
# uses packages defined by --source when provided 
syncpack set-semver-ranges --source "apps/*/package.json"
# multiple globs can be provided like this 
syncpack set-semver-ranges --source "apps/*/package.json" --source "core/*/package.json"
# uses dependencies regular expression defined by --filter when provided 
syncpack set-semver-ranges --filter "typescript|tslint"
# use ~ range instead of default "" 
syncpack set-semver-ranges --semver-range ~
# set ~ range in "devDependencies" 
syncpack set-semver-ranges --dev --semver-range ~
# set ~ range in "devDependencies" and "peerDependencies" 
syncpack set-semver-ranges --dev --peer --semver-range ~
# indent package.json with 4 spaces instead of 2 
syncpack set-semver-ranges --indent "    "
Supported Ranges
<  <1.4.2
<= <=1.4.2
"" 1.4.2
~  ~1.4.2
^  ^1.4.2
>= >=1.4.2
>  >1.4.2
*  *

🙋🏿‍♀️ Getting Help

Get help with issues by creating a Bug Report or discuss ideas by opening a Feature Request.

👀 Other Projects

If you find my Open Source projects useful, please share them ❤️

🤓 Author

I'm Jamie Mason from Leeds in England, I began Web Design and Development in 1999 and have been Contracting and offering Consultancy as Fold Left Ltd since 2012. Who I've worked with includes Sky Sports, Sky Bet, Sky Poker, The Premier League, William Hill, Shell, Betfair, and Football Clubs including Leeds United, Spurs, West Ham, Arsenal, and more.

Follow JamieMason on GitHub      Follow fold_left on Twitter

Install

npm i syncpack

DownloadsWeekly Downloads

20,376

Version

5.1.4

License

MIT

Unpacked Size

92.4 kB

Total Files

44

Last publish

Collaborators

  • avatar