Package detail

@manypkg/cli

Thinkmill685kMIT0.25.1

Manypkg is a linter for package.json files in Yarn, npm, Lerna, pnpm, Bun or Rush monorepos.

readme

Manypkg

Manypkg is a linter for package.json files in Yarn, npm, Lerna, pnpm, Bun or Rush monorepos.

Install

yarn add @manypkg/cli

Usage

manypkg check

manypkg check runs all of the checks against your repo, logs any errors and exits with a code

manypkg fix

manypkg check runs all of the checks against your repo and fixes any of problems that can be fixed.

manypkg upgrade <packageName> <tag or version>

This command helps you quickly upgrade your dependencies in a monorepo, or for packages from another scope. This is similar to yarn upgrade with slightly different ergonomics. At its most basic:

manypkg upgrade react

This will find every instance of react in your packages, and upgrade it to latest.

manypkg upgrade react next

This will find every instance of react in your packages, and upgrade it to the next tag on npm.

Using tags respects your version range specifier (carat, or tilde dependency type).

You can also specify a version or version range such as:

manypkg upgrade react ^16.3.0

Upgrading all dependencies in a scope

If you specify a scope, rather than a package name, you can upgrade all packages within a scope, for example:

manypkg upgrade @keystonejs

This would upgrade all packages in the keystone scope to latest across your repository. You can specify a tag, or a version range. If you specify a tag, it will update every package that has a tag at this scope.

If you specify a version range, all packages in the scope will be updated to that version range and then an install will be attempted, but you will have errors if not all packages in the scope have that version.

manypkg npm-tag tagname (--otp OTP_CODE)

This gets each public package in the repo, and adds the npm tag specified to the current version of each. This can be run after publish to give a particular release a name.

manypkg npm-tag charmander

WARNING - npm-tag is not currently particularly robust in its implementation. The logging and feedback are likely to be poor

manypkg run <partial package name or directory> <script>

manypkg run executes scripts for packages within a monorepo.

As an example, let's say there are two packages: @project/package-a at packages/pkg-a and @project/package-b at packages/pkg-b which both have a start script, manypkg run can be used like this:

yarn manypkg run pkg-a start
yarn manypkg run a start
yarn manypkg run package-a start
yarn manypkg run @project/package-a start
yarn manypkg run packages/pkg-a start
yarn manypkg run package-b start
yarn manypkg run b start

The following wouldn't work though because the package and pkg aren't unique among the package names/directories:

yarn manypkg run package start
yarn manypkg run pkg start

In order to target a package with a name that is a substring of another (@project/package-a at packages/pkg-a and @project/package-a-1 at packages/pkg-a-1), use the exact package or directory name:

yarn manypkg run @project/package-a start
yarn manypkg run packages/pkg-a start

changelog

@manypkg/cli

0.25.1

Patch Changes

  • #260 5854938 Thanks @jasekiw! - Keep detected line endings flavor of package.json files on Windows when updating those files

0.25.0

Minor Changes

Patch Changes

  • Updated dependencies [2c06ac0]:
    • @manypkg/get-packages@3.1.0

0.24.0

Minor Changes

Patch Changes

0.23.0

Minor Changes

  • #236 1a5ea55 Thanks @VanTanev! - Change the ROOT_HAS_DEV_DEPENDENCIES rule to ROOT_HAS_PROD_DEPENDENCIES. Monorepo root should use devDependencies instead of dependencies for better support of production-only installs, useful in eg Docker builds.

0.22.0

Minor Changes

0.21.4

Patch Changes

  • #206 c2c4a3b Thanks @bdkopen! - Fix manypkg upgrade @scope upgrading packages like @scope-something/a

0.21.3

Patch Changes

  • #204 b56869a Thanks @emmatown! - Allow dependecies to use the workspace: protocol and support adding "workspaceProtocol": "require" to the manypkg config to require it.

  • Updated dependencies [3c9641c]:

    • @manypkg/get-packages@2.2.1

0.21.2

Patch Changes

0.21.1

Patch Changes

0.21.0

Minor Changes

Patch Changes

  • Updated dependencies [de0fff3]:
    • @manypkg/get-packages@2.2.0

0.20.0

Minor Changes

  • #165 7b9c4f6 Thanks @Andarist! - Removed support for Bolt monorepos.

  • #162 f046017 Thanks @Andarist! - Increased the transpilation target of the source files to node@14.x. At the same time added this as package.json#engines to explicitly declare the minimum node version supported by this package.

Patch Changes

0.19.2

Patch Changes

0.19.1

Patch Changes

  • #122 7bd4f34 Thanks @fz6m! - Fixed getting correct packages in pnpm workspaces with exclude rules.

  • Updated dependencies [7bd4f34]:

    • @manypkg/get-packages@1.1.3

0.19.0

Minor Changes

  • #119 256297b Thanks @marcodejongh! - Change external mismatch behaviour to suggest and fix to the most commonly used dependency range in the workspace. If all ranges are only used once it will pick the highest.

Patch Changes

  • Updated dependencies [5f6cded]:
    • @manypkg/get-packages@1.1.2

0.18.0

Minor Changes

Patch Changes

0.17.0

Minor Changes

  • ad6dbf1 #85 Thanks @with-heart! - Added the ability to use the exact package or directory name to target a package that is a substring of another with for the run command:

    If packages exist at packages/pkg-a and packages/pkg-a-1, target pkg-a using the exact directory name:

    yarn manypkg run packages/pkg-a
    

    If packages are named @project/package-a and @project/package-a-1, target package-a using the exact package name:

    yarn manypkg run @project/package-a
    

0.16.2

Patch Changes

0.16.1

Patch Changes

0.16.0

Minor Changes

0.15.0

Minor Changes

  • f2e890e #68 Thanks @mitchellhamilton! - Ignore invalid ranges on external dependencies to allow git and other types of dependencies and allow people to ignore the external mismatch rule for certain dependencies by making dependencies npm:^1.0.0 instead of ^1.0.0.

Patch Changes

  • Updated dependencies [35fcc9c]:
    • @manypkg/get-packages@1.1.1

0.14.0

Minor Changes

  • f8f60d9 #67 Thanks @jesstelford! - Add package.json#manypkg config object:

    {
      "manypkg": {}
    }
    

    To support setting a default branch for the INCORRECT_REPOSITORY_FIELD check/fix, a new config option can be set:

    {
      "manypkg": {
        "defaultBranch": "master"
      }
    }
    

    The default defaultBranch is "master".

Patch Changes

0.13.0

Minor Changes

  • 3be8695 #61 Thanks @mitchellhamilton! - Remove check requiring that all devDependencies must be *. This has been removed because pre-release versions are not satisfied by * which means that you previously couldn't use Manypkg, have internal devDependencies and have pre-releases

0.12.0

Minor Changes

0.11.1

Patch Changes

  • 503f242 #53 Thanks @NateRadebaugh! - Add special logic for INCORRECT_REPOSITORY_FIELD check to handle github repository separately from azure

0.11.0

Minor Changes

  • d73628d #48 Thanks @mitchellhamilton! - Add repository field check which checks if a GitHub repo URL is in the repository field in the root package.json and if it is, checks that all of the packages have a repository field which goes into the directory of the package.

0.10.1

Patch Changes

0.10.0

Minor Changes

  • 63cdae1 #42 Thanks @tarang9211! - Added manypkg run <partial package name or directory> <script> which can be used to execute scripts for packages within a monorepo.

    As an example, let's say there are two packages: @project/package-a at packages/pkg-a and @project/package-b at packages/pkg-a which both have a start script, manypkg run can be used like this:

    yarn manypkg run pkg-a start
    yarn manypkg run a start
    yarn manypkg run package-a start
    yarn manypkg run @project/package-a start
    yarn manypkg run packages/pkg-a start
    yarn manypkg run package-b start
    yarn manypkg run b start
    

    The following wouldn't work though because the package and pkg aren't unique among the package names/directories:

    yarn manypkg run package start
    yarn manypkg run pkg start
    
  • 0ed3f2b #39 Thanks @Andarist! - Added support for finding pnpm workspace packages.

Patch Changes

  • Updated dependencies [0ed3f2b]:
    • find-workspaces-root@0.2.0

0.9.0

Minor Changes

  • 528bb72 #30 Thanks @mitchellhamilton! - Changed peer and dev dependency relationship check to only require that the upper bound of the dev dep range is within the peer dep range so that cases where the dev dep range allows versions lower than the lower bound of such as a peer dep with ^1.0.0 and dev dep with * are allowed and this fixes the regression in 0.8.1 where cases that should have been fine weren't like a peer dep with ^1.0.0 and a dev dep with ^1.1.0

0.8.1

Patch Changes

  • dcbfa46: Fix an error with the new internal dependencies being "*", which was incompatible with the peerDependency check

0.8.0

Minor Changes

  • 86bd46d: Add new check: INTERNAL_DEV_DEP_NOT_STAR

    This check moves internal devDependencies between packages to be * - so in a case where I had a package sunshine, which depends on internal package 'sun':

    {
      "name": "sunshine",
      "version": "1.0.0",
      "devDependencies": {
        "sun": "^1.0.0"
      }
    }
    

    we will now have:

    {
      "name": "sunshine",
      "version": "1.0.0",
      "devDependencies": {
        "sun": "*"
      }
    }
    

    This is because all internal dependencies are always linked if the version of the internal dependency is within the specified range(which is already enforced by Manypkg), and devDependencies are only relevant in local installs. Having set versions here caused packages to be patched when one of their devDependencies left the range, which was not strictly necessary.

0.7.0

Minor Changes

  • 801a468: Add exec command that runs a command in every workspace

0.6.0

Minor Changes

  • 2e39bfa: Improve fix for external dependency range mismatches

0.5.2

Patch Changes

  • 89d7407: Exit with 0 when checks fail

0.5.1

Patch Changes

  • e1874c3: Fix checks not running
  • e1874c3: Improve the range chosen by the peer dev dep fixer

0.5.0

Minor Changes

  • 594c153: Enable peer and dev dep check

0.4.0

Minor Changes

  • 50c7974: Run yarn after fixers that require it

0.3.0

Minor Changes

  • 0cfe667: Temporarily disable dev and peer dep relationship check

Patch Changes

  • 0cfe667: Fix some cases around getting the highest semver range

0.2.0

Minor Changes

  • 9ac6104: Add first implementation of add command

0.1.0

Minor Changes

  • 6d5cc67: Initial release