Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adhere to semver rules when using workspace:^ dependencies, fixes #1290 #1291

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Pike
Copy link

@Pike Pike commented Jan 12, 2024

This fixes #1290.

I've adjusted the tests, and also ran my local code against the backstage repository.

On my current version, the main version updates some 200 packages, and with my patch it goes down to some 90.

CC @Rugvip , @freben from that side.

PS: I went for a major release of all affected packages, as this is breaking backwards compat. yarn changeset status gives me:

🦋  info NO packages to be bumped at patch
🦋  ---
🦋  info NO packages to be bumped at minor
🦋  ---
🦋  info Packages to be bumped at major:
🦋  info 
🦋  - @changesets/assemble-release-plan
🦋  - @changesets/cli
🦋  - @changesets/get-release-plan

Copy link

changeset-bot bot commented Jan 12, 2024

🦋 Changeset detected

Latest commit: 9b47c69

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

This PR includes changesets to release 3 packages
Name Type
@changesets/assemble-release-plan Major
@changesets/cli Major
@changesets/get-release-plan Major

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

Copy link

codesandbox-ci bot commented Jan 12, 2024

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.

if (versionRange === "workspace:*") {
// workspace:* actually means the current exact version, and not a wildcard similar to a reguler * range
workspaceRange = dependencyRelease.oldVersion;
} else if (versionRange === "workspace:^") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Afaik we'll want to handle ~ in a similar way as well

@Pike
Copy link
Author

Pike commented Jan 15, 2024

I started to dabble into the ~ part, and then got stuck in a rabbit hole.

I think the culprit here are pre-releases, which is going to limit the impact this can have for projects like backstage:

> semverSatisfies('1.0.1','~1.0.0')
true
> semverSatisfies('1.0.1-alpha.0','~1.0.0')
false
> semverSatisfies('1.0.1-alpha.0','^1.0.0')
false

This goes back to https://github.com/npm/node-semver?tab=readme-ov-file#prerelease-tags, which reads in backstage lingo: If we bump @backstage/core-plugin-api in a pre-release, we need to also ship a pre-release version of @backstage/plugin-todo, which references that core package with the specific pre-release version.

More details on why that also then affects the non-pre releases is in Emma's comment in #382 (comment).

@ericis
Copy link

ericis commented Feb 15, 2024

We ran into an issue where we cannot use yarn changeset publish because it does not respect the monorepo dependencies defined with "workspace:^" in "package.json". We believe this Pull Request would fix that and allow us to use changesets properly. Until then, our only workaround is to manually publish each project, in order, with the command yarn npm publish from each project's directory.

@Andarist and team, is it possible to prioritize this merge?

@adbayb
Copy link

adbayb commented Apr 17, 2024

Another possible workaround, until Changesets code owners review the pull request, can be to patch (via PNPM if it's your default package manager or the patch-package module) @changesets/assemble-release-plan@6.0.0 dependency with @Pike proposed fix (thanks to him).
Patching is working well confirming the issue fix 🎉 .

I hope this workaround can unblock projects while not rushing @Andarist and the Changesets team 👍 .

@Rugvip
Copy link
Contributor

Rugvip commented May 3, 2024

@adbayb indeed, we'll try it out and see how it works: backstage/backstage#24614. In particular, I expect this to improve our patch release process where we currently see too many package bumps.

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.

Dependency range workspace:^ isn't treated as semver range, bumping dependent packages
4 participants