@manypkg/get-packages usage in Changesets

thinkthroo

thinkThroo

Posted on November 21, 2024

@manypkg/get-packages usage in Changesets

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.

Image description

But this only imports type — Package

There is another example found in [CLI package]

(https://github.com/changesets/changesets/blob/main/packages/cli/src/run.ts#L40).

const packages = await getPackages(cwd);
Enter fullscreen mode Exit fullscreen mode

Image description

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.

Image description

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

💖 💪 🙅 🚩
thinkthroo
thinkThroo

Posted on November 21, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related