Skip to content

Update @manypkg/get-packages to v3#1655

Merged
Andarist merged 8 commits intonextfrom
update-get-packages
Mar 30, 2026
Merged

Update @manypkg/get-packages to v3#1655
Andarist merged 8 commits intonextfrom
update-get-packages

Conversation

@bluwy
Copy link
Copy Markdown
Member

@bluwy bluwy commented May 1, 2025

Some code added to handle the breaking change, mainly the Package now needs to specify dir and relativeDir. And the tool needs to be a tool from @manypkg/tools and not just a string.

There are a lot of line changes adding package-lock.json to the fixtures because that's the only way for it to detect as monorepo (npm). Previously a "workspaces" only field was sufficient. @Andarist I'm not sure this is the most ergonomic, shouldn't npm monorepos be detected as fallback without the need for package-lock.json to exist?


Unrelated but if I may give feedback on the new breaking APIs, I'm not a big fan of passing the tool object entirely from @manypkg/tools. It should've supported a simple string like before and a union of Tool object instead.

Also, I'm not entirely clear for Packages type, why the returned rootPackage could be undefined while rootDir is not? rootPackage shouldn't be possible to be undefined from what I can tell (at least for default tools).

Also, I'm not sure if it was necessarily to introduce both dir (absolute) and relativeDir (relative) in the object. Feels redundant.

Comment thread package.json Outdated
@bluwy bluwy mentioned this pull request May 1, 2025
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 2, 2025

🦋 Changeset detected

Latest commit: 0bbcc29

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

This PR includes changesets to release 10 packages
Name Type
@changesets/assemble-release-plan Major
@changesets/get-dependents-graph Major
@changesets/apply-release-plan Major
@changesets/get-release-plan Major
@changesets/release-utils Major
@changesets/config Major
@changesets/cli Major
@changesets/git Major
@changesets/pre Major
@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 May 2, 2025

Codecov Report

❌ Patch coverage is 80.55556% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.47%. Comparing base (12f20ea) to head (0bbcc29).
⚠️ Report is 1 commits behind head on next.

Files with missing lines Patch % Lines
packages/cli/src/run.ts 66.66% 5 Missing ⚠️
packages/cli/src/commands/publish/index.ts 50.00% 1 Missing ⚠️
packages/get-dependents-graph/src/index.ts 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             next    #1655      +/-   ##
==========================================
- Coverage   82.52%   82.47%   -0.05%     
==========================================
  Files          53       53              
  Lines        2357     2357              
  Branches      697      697              
==========================================
- Hits         1945     1944       -1     
- Misses        370      371       +1     
  Partials       42       42              

☔ 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.

@bluwy
Copy link
Copy Markdown
Member Author

bluwy commented Nov 18, 2025

TODO: Update this once main cuts a release, which then I'll update the next branch with main changes. And then later port over some changes from #1609 and #1069 which attempted to upgrade to v2 in main

@ConProgramming
Copy link
Copy Markdown

ConProgramming commented Mar 19, 2026

Hi @bluwy any update on merging this?

@bluwy
Copy link
Copy Markdown
Member Author

bluwy commented Mar 20, 2026

I haven't finished the tasks I mentioned in my last comment, but I'm also unfortunately not interested in updating anymore given I had no reviews when it was ready. If anyone would like to help out, that'd be much appreciated.

@Andarist
Copy link
Copy Markdown
Member

This is a prerequisite to this work: #1872 . I'll land this soon to unblock this work here, see the discussion that led to this PR here: #1795 (comment)

@Andarist
Copy link
Copy Markdown
Member

@marcalexiei I know you were interested in this work. I just updated this PR after landing your work. There are known type errors here because the Changesets' Packages require a string literal for the tool (it assumes known tools) whereas the manypkg's Tool is now more generic and the tool type is typed as just a string.

Treating it as string is probably more future-proof and flexible... but it's also kinda more annoying. So dunno, I invite you to take a look at the current state of this PR and participae in the discussion.

@Andarist I'm not sure this is the most ergonomic, shouldn't npm monorepos be detected as fallback without the need for package-lock.json to exist?

The new requirement is more strict but I think it's ultimately more correct. We might want to differentiate further in the future between npm-managed workspaces and root-only repositories without lockfiles.

Unrelated but if I may give feedback on the new breaking APIs, I'm not a big fan of passing the tool object entirely from @manypkg/tools. It should've supported a simple string like before and a union of Tool object instead.

This was largely addressed by #1872 , WDYT?

Also, I'm not entirely clear for Packages type, why the returned rootPackage could be undefined while rootDir is not? rootPackage shouldn't be possible to be undefined from what I can tell (at least for default tools).

I thiiiink Rush might not support the root package in the same sense as other tools support it today. Its workspaces might be defined in its own config file or something. But honestly, I'd have to do a deeper research on this to answer this properly.

Also, I'm not sure if it was necessarily to introduce both dir (absolute) and relativeDir (relative) in the object. Feels redundant.

This was also addressed by #1872

@Andarist Andarist force-pushed the update-get-packages branch from 4df8533 to 02a1897 Compare March 25, 2026 11:43
@marcalexiei
Copy link
Copy Markdown
Contributor

I just updated this PR after landing your work. There are known type errors here because the Changesets' Packages require a string literal for the tool (it assumes known tools) whereas the manypkg's Tool is now more generic and the tool type is typed as just a string.
Treating it as string is probably more future-proof and flexible... but it's also kinda more annoying. So dunno, I invite you to take a look at the current state of this PR and participae in the discussion.

How about using a 'npm' | 'pnpm' | ... | (string & {}) union for Changesets’ Packages?
It seems like a reasonable compromise:

  • we preserve type safety for known tool.type values
  • we allow extensibility, and we avoid the need for type casting.

Would you like me to open a PR on this branch using this approach?

@Andarist
Copy link
Copy Markdown
Member

This was a simple fix - so I think it wasn't worth opening a different PR for this. I just pushed it out here.


Do you think it's worth keeping up with manypkg's compatibility or at this point it's just making things more complicated than they should be? I'm torn on this - but also, manypkg is also controlled by us so we can refactor it however we want to suit our needs. So ultimately, it's kinda a choice of:

  • landing this PR and settling on this whole approach
  • refactoring manypkg somehow
  • creating @changesets/get-packages that would repeat most of what manypkg's package does already

@benmccann
Copy link
Copy Markdown
Contributor

Changesets is the main consumer followed by backstage. Not sure we need to worry too much about anyone else

$ npx github:Fuzzyma/e18e-tools @manypkg/get-packages -n 20 -U https://npm.devminer.xyz/registry -q -o md

# Downloads Traffic Version Package
1 5.16M 28.67 GB ^1.1.3 @changesets/cli
2 5.10M 28.34 GB ^1.1.3 @changesets/git
3 5.07M 28.19 GB ^1.1.3 @changesets/config
4 5.06M 28.11 GB ^1.1.3 @changesets/apply-release-plan
5 5.02M 27.94 GB ^1.1.3 @changesets/get-release-plan
6 5.00M 27.80 GB ^1.1.3 @changesets/assemble-release-plan
7 4.99M 27.77 GB ^1.1.3 @changesets/get-dependents-graph
8 4.92M 27.36 GB ^1.1.3 @changesets/pre
9 3.61M 20.10 GB ^1.1.3 @changesets/should-skip-package
10 687.85k 3.82 GB ^3.1.0 @manypkg/cli
11 590.57k 3.28 GB ^1.1.3 @backstage/backend-defaults
12 494.13k 2.75 GB ^1.1.3 @backstage/cli-node
13 373.50k 2.08 GB ^1.1.3 @backstage/eslint-plugin
14 337.82k 1.88 GB ^1.1.3 @backstage/backend-common
15 300.75k 1.67 GB ^1.1.3 @backstage/cli
16 134.14k 745.83 MB ^1.1.3 @backstage/e2e-test-utils
17 75.21k 418.19 MB ^1.1.3 changesets-gitlab
18 58.60k 325.80 MB ^1.1.3 @backstage/repo-tools
19 45.81k 254.71 MB ^1.1.3 @backstage/plugin-devtools-backend
20 40.18k 223.42 MB ^1.1.3 multi-semantic-release

@marcalexiei
Copy link
Copy Markdown
Contributor

This was a simple fix - so I think it wasn't worth opening a different PR for this. I just pushed it out here.

Perfect, thank you!


Do you think it's worth keeping up with manypkg's compatibility or at this point it's just making things more complicated than they should be? I'm torn on this - but also, manypkg is also controlled by us so we can refactor it however we want to suit our needs.

Personally, I’d lean toward option 1 (landing this PR and settling on this approach).

The main advantage is that moving to an object-based tool gives us forward compatibility. It creates space to evolve the API (e.g. adding new properties or methods) without forcing breaking changes later.

I’m not sure yet what we might need for tools like Rush, but this keeps that door open.

It also enables more tool-specific extensions in a type-safe way. For example:

type Tool =
  | { type: 'pnpm'; pnpmMethod: () => void }
  | { type: 'yarn'; yarnMethod: () => void }
  | { type: string | {} };

function isToolTypeKnown(x: Tool): x is Extract<Tool, { type: 'pnpm' | 'yarn' }> {
  return x.type === 'pnpm';
}

const tool = {} as Tool;

if (isToolTypeKnown(tool)) {
  if (tool.type === 'yarn') {
    tool.yarnMethod();
  } else {
    tool.pnpmMethod();
  }
}

If this direction works well in practice, we could then revisit whether @changesets/get-packages should evolve accordingly.

@Andarist
Copy link
Copy Markdown
Member

That sounds good to me. I'll wait a couple of days before landing this to give @bluwy the chance to comment too.

@Andarist
Copy link
Copy Markdown
Member

We still need to remember to update the bot. If you'd be interested in helping with that, I'd really appreciate it.

@marcalexiei
Copy link
Copy Markdown
Contributor

We still need to remember to update the bot. If you'd be interested in helping with that, I'd really appreciate it.

I can take a pass at this. I’ll open an issue in the bot repo with all the relevant references so we don’t lose track (I remember you already pointed out the parts that need updating).
Once this PR is merged, I’ll start working on it.

Sounds good?

@Andarist
Copy link
Copy Markdown
Member

Sounds good! thanks 🙏

@bluwy
Copy link
Copy Markdown
Member Author

bluwy commented Mar 30, 2026

That sounds good to me. I'll wait a couple of days before landing this to give @bluwy the chance to comment too.

I'll leave it to y'all to handle this as I don't have much time to follow-up on this lately.

@Andarist Andarist merged commit db46911 into next Mar 30, 2026
6 of 8 checks passed
@Andarist Andarist deleted the update-get-packages branch March 30, 2026 05:44
@beeequeue beeequeue mentioned this pull request Apr 30, 2026
19 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants