DEV Community

Ramu Narasinga
Ramu Narasinga

Posted on • Edited on

@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 me:

Hey, my name is Ramu Narasinga. I study large open-source projects and create content about their codebase architecture and best practices, sharing it through articles, videos.

I am open to work on an interesting project. Send me an email at ramu.narasinga@gmail.com

My Github - https://github.com/ramu-narasinga
My website - https://ramunarasinga.com
My Youtube channel - https://www.youtube.com/@thinkthroo
Learning platform - https://thinkthroo.com
Codebase Architecture - https://app.thinkthroo.com/architecture
Best practices - https://app.thinkthroo.com/best-practices
Production-grade projects - https://app.thinkthroo.com/production-grade-projects

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

Top comments (0)