Skip to content

Upgrade manypkg/get-packages#1069

Closed
elliot-nelson wants to merge 6 commits intochangesets:mainfrom
elliot-nelson:enelson/major
Closed

Upgrade manypkg/get-packages#1069
elliot-nelson wants to merge 6 commits intochangesets:mainfrom
elliot-nelson:enelson/major

Conversation

@elliot-nelson
Copy link
Copy Markdown
Contributor

@elliot-nelson elliot-nelson commented Jan 27, 2023

SUMMARY

  • Upgrade to latest major release of @manypkg/get-packages
  • This includes the reorganized @manypkg/tools collection

DETAILS

  • Adjust various call points and checks to reflect the updated interface of get-packages.
  • Code paths that check for specific tools can use tool.type instead of tool.
  • Code paths that must create a tool (mostly unit tests) now import @manypkg/tools so they can use prefab tool implementations. (It's not required -- you could define your own fake monorepo implementation inline for testing -- but this was the easiest way to confirm that the previous intent was still being met.)

For the most part, there should be no functional changes in this PR except those introduced in the latest version of get-packages:

  • Rush monorepos are now parsed correctly and work for changeset creation + changeset version commands.
  • Bolt monorepos are no longer supported.

Note that for Rush specifically, changeset publish needs more work, which will come in a separate dedicated PR.

TESTING

  • Updated existing unit tests
  • Verified behavior in local Rush monorepo

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jan 27, 2023

⚠️ No Changeset found

Latest commit: 07c516b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@codesandbox-ci
Copy link
Copy Markdown

codesandbox-ci Bot commented Jan 27, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 07c516b:

Sandbox Source
Vanilla Configuration

let releasedPackages: Package[] = [];

if (tool !== "root") {
if (tool.type !== "root") {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

changesets/action should be built on top of @changesets/release-utils - but this wasn't yet unified.

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.

Got it, will check it out.

As an aside, could be interesting to explore moving the source code for actions into the monorepo as a package. We've had some success with this with action collections in monorepos.

The "publish" command, instead of being NPM-based, becomes git-based: you build the action, bundle dist up into a single file (with @vercel/ncc or your favorite equivalent), and then your calculated version (e.g. 4.1.0) becomes the branch name... you push the files directly into branch v4.1.0 in the target repo, changesets/action.

(To follow GH conventions, you usually also have branches for major versions, so you follow it up by chopping off and fast-forwarding, e.g. git checkout v4 && git reset --hard v4.1.0 && git push -f in the target repo.)

This also brings up the whole question of "well... what if I wanted changesets to manage publishing all my actions, using this alternate publishing scheme?". That's a question we never really dug into Rush but I've always thought it would be cool if it was as simple as:

[
  {
    "packageName": "@example/core",
    "shouldPublish": true,
    "publishMethod": "pnpm"
  },
  {
    "packageName": "@example/custom-action",
    "shouldPublish": true,
    "publishMethod": "github-action",
    "targetRepo": "example-company/custom-action"
  }
]

And then you'd just "publish all" and everything is done for you.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ye, it would be kinda neat if the changesets/action repo could just become a publish target.

snapshot?: string | boolean
) {
let cwd = packages.root.dir;
let cwd = packages.rootDir;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If I'm not mistaken - this is a breaking change for @changesets/apply-release-plan. This is fine - we just have to create a major changeset for it

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.

Is it major? I might misunderstand the ramifications but I think apply-release-plan's external behavior for all existing monorepo implementations doesn't change (it's just a dependency bump + corresponding implementation tweak).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The problem is in the API surface - not the behavior. It now accepts an argument of a different shape

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👋

@Andarist
Copy link
Copy Markdown
Member

Could we also add a test that would check changeset add and changeset version in Rush monorepos?

expect(await getCommitCount(clone)).toBeGreaterThan(5);
expect(await getCommitCount(clone)).toBeLessThan(originalRepoDepth);
});
}, 10_000 /* 10 seconds */);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hm, quite interesting that you are hitting timeouts here - somewhat similarly to what happened in manypkg repo. There is likely some overhead in spawn here but I never had problems with this - even on the older machine.

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.

🤔 I wonder why... on the other repo, upgrading that ts wrapper tool made the timeout issues vanish.

But in this case, it's only this specific test that consistently goes over 5 seconds for me, and it's the test that calls git 50+ times so it made sense to me that it was a bit slower.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Out of curiosity - could you check how long those spawn('git', ...) calls take on your machine? It would be interesting to learn more about this particular bottleneck. This is, of course, just a sideways exploration - not quite related to this PR.

@akphi
Copy link
Copy Markdown

akphi commented Apr 8, 2023

@elliot-nelson just curious, is this effort still being pursued?

@Andarist
Copy link
Copy Markdown
Member

Andarist commented Apr 8, 2023

@akphi ye, definitely

@elliot-nelson
Copy link
Copy Markdown
Contributor Author

Thanks for ping though looks like this is stalled on me 😅 I'll get those 2 additional tests added in next couple days.

@akphi
Copy link
Copy Markdown

akphi commented Jul 19, 2023

@elliot-nelson did you have chance to look at this again?

@danez
Copy link
Copy Markdown

danez commented Aug 14, 2023

I think this will also fix this bug: #1209
I was investigating this and created more tests for manypkgs, but there it worked fine. Only then I realized changesets was using an old version.

What is left here? I cannot see the circleCI pipeline, so not sure what's broken. Can I somehow help get this over the finish line?

@brad-mccormick
Copy link
Copy Markdown

Anything we can do to help get this released? I'm at a standstill with a pnpm monorepo. @elliot-nelson

@elliot-nelson
Copy link
Copy Markdown
Contributor Author

@Andarist 👋 Hi Andarist, long time no chat :). I've added tests that shows basic rush add and rush version commands working in a Rush-style monorepo with no root package file, and all existing tests for non-Rush repos should work as well.

@lachlancollins
Copy link
Copy Markdown

Hi @Andarist , I'm wondering if you could have a look at this old PR? The latest manypkg release cuts a bunch of dependencies.

@bluwy
Copy link
Copy Markdown
Member

bluwy commented Oct 9, 2024

I know it's been a while, but if there's still interest in the PR, we've created a next branch to combine all the breaking changes, and perhaps this PR can be part of it too. Happy to leave a review too if so.

@bluwy
Copy link
Copy Markdown
Member

bluwy commented Nov 18, 2025

There's now @manypkg/get-packages v3, which I upgraded in #1655 for the next branch. I've forgotten about this PR when I made that, but I'll make sure to reference this PR when I rebase mine and credit as co-author for any changes.

For now, I'll close this one, but thanks for contributing!

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.

7 participants