All Projects → JamieMason → Syncpack

JamieMason / Syncpack

Licence: mit
Manage multiple package.json files, such as in Lerna Monorepos and Yarn/Pnpm Workspaces

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Syncpack

Yerna
A Lerna-like tool for managing Javascript monorepos using Yarn
Stars: ✭ 140 (-60.67%)
Mutual labels:  lerna, npm, yarn, monorepo
Lerna Yarn Workspaces Example
How to build TypeScript mono-repo project with yarn and lerna
Stars: ✭ 787 (+121.07%)
Mutual labels:  lerna, yarn, monorepo
Lerna
Splitting up large codebases into separate independently versioned packages is extremely useful for code sharing. However, making changes across many repositories is messy and difficult to track, and testing across repositories becomes complicated very quickly.
Stars: ✭ 31,079 (+8630.06%)
Mutual labels:  lerna, npm, monorepo
Vitamin Web
Decathlon Design System libraries for web applications
Stars: ✭ 70 (-80.34%)
Mutual labels:  lerna, yarn, monorepo
Npm Upgrade
Interactive CLI utility to easily update outdated NPM dependencies
Stars: ✭ 245 (-31.18%)
Mutual labels:  cli, npm, packages
Ultra Runner
🏃⛰ Ultra fast monorepo script runner and build tool
Stars: ✭ 496 (+39.33%)
Mutual labels:  lerna, npm, monorepo
Eslint Plugin Monorepo
ESLint Plugin for monorepos
Stars: ✭ 56 (-84.27%)
Mutual labels:  lerna, yarn, monorepo
Emma Cli
📦 Terminal assistant to find and install node packages.
Stars: ✭ 1,201 (+237.36%)
Mutual labels:  cli, npm, yarn
Npm Gui
Graphic tool for managing javascript project dependencies - in a friendly way.
Stars: ✭ 454 (+27.53%)
Mutual labels:  dependencies, npm, yarn
Dependency Land
Find the npm modules that depend on a specific module and semver range.
Stars: ✭ 34 (-90.45%)
Mutual labels:  dependencies, npm, semver
Npmvet
A simple CLI tool for vetting npm package versions
Stars: ✭ 193 (-45.79%)
Mutual labels:  cli, npm, packages
monorepo-utils
A collection of utilities for monorepo/lerna. Tools for TypeScript project references etc..
Stars: ✭ 143 (-59.83%)
Mutual labels:  yarn, lerna, monorepo
Ni
💡 Use the right package manager
Stars: ✭ 179 (-49.72%)
Mutual labels:  cli, npm, yarn
monopack
A JavaScript bundler for node.js monorepo-codebased applications.
Stars: ✭ 52 (-85.39%)
Mutual labels:  yarn, lerna, monorepo
Script Progress
Estimate script execution time
Stars: ✭ 175 (-50.84%)
Mutual labels:  cli, npm, yarn
Pectin
Rollup-related tools for incremental transpilation of packages in Lerna-based monorepos
Stars: ✭ 50 (-85.96%)
Mutual labels:  lerna, cli, monorepo
Typac
install npm packages along with corresponding typings
Stars: ✭ 29 (-91.85%)
Mutual labels:  cli, npm, yarn
Npm Compare
Compare npm packages from your terminal
Stars: ✭ 55 (-84.55%)
Mutual labels:  cli, npm, packages
Flow Mono Cli
A command line interface that aims to solve a few issues while working with flow typed codebases in a mono-repo.
Stars: ✭ 84 (-76.4%)
Mutual labels:  lerna, yarn, monorepo
Yalc
Work with yarn/npm packages locally like a boss.
Stars: ✭ 3,155 (+786.24%)
Mutual labels:  dependencies, npm, yarn

syncpack

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

NPM version NPM downloads Build Status Maintainability

Table of Contents

🌩 Installation

npm install --global syncpack

📝 Commands

fix-mismatches

Ensure that multiple packages requiring the same dependency define the same version, so that every package requires eg. [email protected], instead of a combination of [email protected], [email protected], and [email protected].

See versionGroups if you have advanced requirements.

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.

See versionGroups if you have advanced requirements.

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 "    "

🛠 Configuration File

Creating a configuration file is optional, syncpack will search up the directory tree in the following places:

  • a syncpack property in package.json
  • a .syncpackrc file in JSON or YAML format
  • a .syncpackrc.json, .syncpackrc.yaml, .syncpackrc.yml, .syncpackrc.js, or .syncpackrc.cjs file
  • a syncpack.config.js or syncpack.config.cjs CommonJS module exporting an object

Default Configuration

{
  "dev": true,
  "filter": ".",
  "indent": "  ",
  "peer": true,
  "prod": true,
  "semverRange": "",
  "sortAz": ["contributors", "dependencies", "devDependencies", "keywords", "peerDependencies", "scripts"],
  "sortFirst": ["name", "description", "version", "author"],
  "source": ["package.json", "packages/*/package.json"],
  "versionGroups": []
}

dev, peer, and prod

Whether to search within devDependencies, peerDependencies, and dependencies respectively. All of these locations are searched by default but they can be disabled individually in your config file. If any are set via the command line options --dev, --peer, or --prod then only the options you provide will be searched.

filter

A string which will be passed to new RegExp() to match against package names that should be included.

indent

The character(s) to be used to indent your package.json files when writing to disk.

semverRange

Defaulted to "" to ensure that exact dependency versions are used instead of loose ranges, but this can be overridden in your config file or via the --semver-range command line option.

Supported Ranges

<  <1.4.2
<= <=1.4.2
"" 1.4.2
~  ~1.4.2
^  ^1.4.2
>= >=1.4.2
>  >1.4.2
*  *

sortAz

When using the format command, determines which fields within package.json files should be sorted alphabetically. When the value is an Object, its keys are sorted alphabetically. When the value is an Array, its values are sorted alphabetically. There is no equivalent CLI Option for this configuration.

sortFirst

When using the format command, determines which fields within package.json files should appear at the top, and in what order. There is no equivalent CLI Option for this configuration.

source

Defaults to ["package.json", "packages/*/package.json"] to match most Projects using Lerna or Yarn Workspaces, but this can be overridden in your config file or via multiple --source command line options. Supports any patterns supported by glob.

versionGroups

If some packages in your Monorepo relate to "alpha" (or legacy) versions of your software, you will need to manage dependencies differently within those packages. Your alpha packages might use latest or unstable versions of some 3rd party dependencies, while the rest of the repo might need to remain on older versions. You don't want mismatches within your alpha packages, or within the other packages in your monorepo – but you do want those groups to use different versions to each other and not have syncpack fix-mismatches make them all the same.

In the following example, 2 packages in our monorepo are using different versions of react and react-dom to the rest of the project.

{
  "versionGroups": [
    {
      "dependencies": ["react", "react-dom"],
      "packages": ["@alpha/server", "@alpha/ui"]
    }
  ]
}

syncpack will make ensure that:

  • The versions of react and react-dom are the same within @alpha/server and @alpha/ui.
  • The versions of react and react-dom are the same across every package except @alpha/server and @alpha/ui.
  • The versions of react and react-dom within @alpha/server and @alpha/ui can be different to the other packages in the monorepo.
  • The versions of every other dependency in the monorepo (eg lodash) are the same across every package including @alpha/server and @alpha/ui.

🕵🏾‍♀️ 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. If using Pnpm, read packages from ./pnpm-workspace.yaml.
  5. Default to 'package.json' and 'packages/*/package.json'.

🙋🏿‍♀️ 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 ❤️

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].