@manypkg/get-packages usage in Changesets

Think ThrooThink Throo
2 min read

In this article, we analyse @manypkg/get-packages and its usage in Changesets source code.

@manypkg/get-packages

@manypkg/get-packages is open-source utility written by Thinkmill. It is a
simple utility to get the packages from a monorepo, whether they’re using Yarn, Bolt, Lerna, pnpm or Rush.

This library exports getPackages and getPackagesSync. It is intended mostly for use of developers building tools that want to support different kinds of monorepos as an easy way to write tools without having to write
tool-specific code. It supports Yarn, Bolt, Lerna, pnpm, Rush and single-package repos(where the only package is the the same as the root package). This library uses @manypkg/find-root to search up from the directory
that’s passed to getPackages or getPackagesSync to find the project root.

@manypkg/get-packages usage in Changesets

Since Changesets is a monorepo, it has a package named should-skip-package. In this package, you will find an import from @manypkg/get-packages as shown below.

But this only imports type — Package

There is another example found in CLI package.

const packages = await getPackages(cwd);

About us:

At Thinkthroo, we study large open source projects and provide architectural guides. We have developed reusable Components, built with tailwind, that you can use in your project. We offer Next.js, React and Node development services.

Book a meeting with us to discuss your project.

References:

  1. https://www.npmjs.com/package/@manypkg/get-packages

  2. https://github.com/changesets/changesets/blob/main/packages/cli/src/run.ts#L5C10-L5C28

  3. https://github.com/changesets/changesets/blob/main/packages/should-skip-package/src/index.ts#L4

  4. https://github.com/changesets/changesets/blob/main/packages/cli/src/run.ts#L156

  5. https://github.com/changesets/changesets/blob/main/packages/cli/src/run.ts#L168

0
Subscribe to my newsletter

Read articles from Think Throo directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Think Throo
Think Throo