Skip to content

Update @manypkg/get-packages to v2#1795

Closed
marcalexiei wants to merge 1 commit intochangesets:mainfrom
marcalexiei:many-packages-2
Closed

Update @manypkg/get-packages to v2#1795
marcalexiei wants to merge 1 commit intochangesets:mainfrom
marcalexiei:many-packages-2

Conversation

@marcalexiei
Copy link
Copy Markdown
Contributor

@marcalexiei marcalexiei commented Dec 3, 2025

@manypkg/get-packages@1 depends on read-yml-files@1, which uses js-yaml@3.

Upgrading to @manypkg/get-packages@2.2.2 removes this and other dependencies.

Why not @manypkg/get-packages@3?

Version 3 is ESM-only.
This repository still relies on Jest 29, which does not support ESM by default, so upgrading to v3 isn’t feasible yet.


I’m aware that a few changes may conflict with the next branch,
but I believe it’s worthwhile to merge this into main to reduce unnecessary dependencies.

If you're happy with this PR, I can also prepare a follow-up to bring the same changes into next.
Since next branch uses vitest, we could consider upgrading @manypkg/get-packages to v3 there.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Dec 3, 2025

🦋 Changeset detected

Latest commit: 0d3f4db

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@changesets/assemble-release-plan Minor
@changesets/get-dependents-graph Minor
@changesets/should-skip-package Minor
@changesets/apply-release-plan Minor
@changesets/get-release-plan Minor
@changesets/release-utils Minor
@changesets/config Minor
@changesets/cli Minor
@changesets/git Minor
@changesets/pre Minor
@changesets/read Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 3, 2025

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.34%. Comparing base (3cb9982) to head (0d3f4db).
⚠️ Report is 29 commits behind head on main.

Files with missing lines Patch % Lines
packages/cli/src/commands/publish/index.ts 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1795   +/-   ##
=======================================
  Coverage   81.33%   81.34%           
=======================================
  Files          54       54           
  Lines        2277     2278    +1     
  Branches      684      679    -5     
=======================================
+ Hits         1852     1853    +1     
  Misses        420      420           
  Partials        5        5           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@marcalexiei marcalexiei mentioned this pull request Dec 3, 2025
Comment thread yarn.lock
resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.2.0.tgz#199431eeaaa2e09f86427efbb4f1473edb47609b"
integrity sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==

read-yaml-file@^1.1.0:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bluwy I'm moving the conversation here since #1772 is closed

I think we cant upgrade it in this major due to its breaking change.

From @manypkg/get-packages@2.0.0 changelog

There is a change in getPackages structure:

The get-packages package now returns a slightly different structure. The old tool string has been replaced with a tool object, using the new Tool interface provided by @manypkg/tools. Each Package now contains both the absolute directory and relative directory path. Last, the root package has been renamed rootPackage and is optional, to support monorepos that do not contain a root package.

I assumed that when working with a changeset there is always a root package, so I added a non-null assertion to avoid the type-checking error.

For the tool updates, I added access to the type property and used a simple { type: 'tool' } object in the mock functions, along with a type cast.

@marcalexiei
Copy link
Copy Markdown
Contributor Author

@bluwy could you take a look at this PR?
The missing coverage line is not currently covered by tests and was not updated as part of this change.

@Andarist Andarist added the next label Mar 2, 2026
@marcalexiei
Copy link
Copy Markdown
Contributor Author

@Andarist This PR has been open for months without review.

I noticed you added the next label, should I retarget it to the next branch and rebase accordingly?

I’d appreciate a review when possible.
I’ve seen more recent PRs get feedback, so I just want to make sure this one hasn’t been missed.

@Andarist
Copy link
Copy Markdown
Member

Andarist commented Mar 4, 2026

@marcalexiei ye, we should retarget this to the next branch BUT we need a plan first that will work with our bot, see how we use the packages:
https://github.com/changesets/bot/blob/a443d065be109aeb890cb97c14e5b34e3c4f4a88/get-changed-packages.ts#L184

The problem in there is that we need packages to be fully serializable, or we need to be able to convert the value there into the manypkg Tool object (which probably isn't worth it...). We can freely rely on structural type equivalence (so we don't have to import manypkg itself there)... but we also don't have to if there is a better way.

This might require refactoring the current latest version of manypkg. I'm not sure. If you could do the research around this, it would be very appreciated.

@marcalexiei
Copy link
Copy Markdown
Contributor Author

@Andarist As I understand it, the original goal was for assembleReleasePlan to receive a serialisable structure.
With the introduction of the new tool property in manypkg@2 and manypkg@3, that is no longer possible, correct?

I reviewed the following packages:

  • assemble-release-plan
  • apply-release-plan

In most places, @manypkg/get-packages is used primarily to import the types that define the shape of the packages argument.

Proposal

Introduce a new interface in @changesets/types that defines the expected structure for the packages parameter, and use that internally within the repository.

This would decouple the implementation from @manypkg/get-packages and allow consumers to construct the required structure independently, whether they rely on @manypkg/get-packages or not (E.g. the bot).

The structure would closely resemble Packages from @manypkg/get-packages@1.

Rough Interface Sketch

interface ChangesetPackages {
  rootPackage?: {
    dir: string;
  };
  packages: Array<{
    dir: string;
    // from "@changesets/types"
    packageJson: PackageJSON;
  }>;
}

Would this direction be something you’d consider?

@Andarist
Copy link
Copy Markdown
Member

Andarist commented Mar 4, 2026

Sounds good. We should also try to handle both manypkg v1 and v2 formats in the bot repo - by detecting what version of Changesets is used by the repo (unless they are completely compatible for our needs)

@marcalexiei
Copy link
Copy Markdown
Contributor Author

Sounds good.

Ok, I'll start a new PR from scratch based upon the next branch


We should also try to handle both manypkg v1 and v2 formats in the bot repo - by detecting what version of Changesets is used by the repo (unless they are completely compatible for our needs)

Yes, because the tool property differs significantly between the two versions,
we will inevitably need version-specific handling logic.

@marcalexiei marcalexiei closed this Mar 4, 2026
@Andarist
Copy link
Copy Markdown
Member

Andarist commented Mar 4, 2026

Yes, because the tool property differs significantly between the two versions,

Note that we could also consider releasing manypkg v3 to make that project more compatible with what we need it for in Changesets but it would be nice to not lose functionality implemented in v2... But maybe there is some restructuring that can be done to accomplish both needs?

@marcalexiei
Copy link
Copy Markdown
Contributor Author

marcalexiei commented Mar 4, 2026

I'm working on this and so far this is what I've created in @changesets/types

export interface ChangesetPackage {
  dir: string;
  packageJson: PackageJSON;
}

// This should be compatible with `@manypkg/get-packages@2`
export type ChangesetPackagesTool = {
  type: "yarn" | "bolt" | "pnpm" | "lerna" | "root" // Picked up from `@manypkg/get-packages@1`
};

export interface ChangesetPackages {
  root: ChangesetPackage;
  packages: Array<ChangesetPackage>;
  tool: ChangesetPackagesTool;
}

Once I have the test and type-check scripts working,
I’ll open a new PR so we can review and discuss the changes in detail.

For now, I won’t update @manypkg/get-packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants