Version: Reimplement yarn version and yarn version apply - #7218
Merged
Conversation
Now that the `version` command has all options that `version apply` has and that immediate mode rigorously consumes and applies deferred records, `yarn version apply` is basically equivalent to `yarn version decline --immediate`. This commit makes that a reality by reimplementing `yarn version apply` as simply forwarding to `yarn version decline --immediate`.
clemyan
force-pushed
the
clemyan/version-refactor
branch
from
July 11, 2026 15:53
9592c8c to
322c5c9
Compare
Member
Author
|
Force pushed to rebase over a merge conflict |
clemyan
force-pushed
the
clemyan/version-refactor
branch
from
July 11, 2026 18:12
322c5c9 to
4fdbac7
Compare
clemyan
marked this pull request as ready for review
July 17, 2026 16:36
Member
Author
|
Looks like DefinitelyTyped/DefinitelyTyped#75230 isn't moving along. I'll mark this as ready. We can upgrade |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's the problem this PR addresses?
The
yarn versionfamily of commands has a number of unintuitive behaviors. The most prominent ones are:yarn version --deferred+yarn version applystableVersionfield in addition to theversionfield which interacts unintuitively with some workflows. In particular, deferring a semver strategy resolves a named strategy againstversion, whichyarn version applyapplies tostableVersionFixes #3868
Fixes #4014
Fixes #4328
Fixes #5224
Fixes #6810
Fixes #6857
Fixes #6860
Fixes #6970
Fixes #7025
Closes #7110 (supercedes)
How did you fix it?
Reimplemented the
yarn versionandyarn version applycommands.Now the bumping logic resides in
yarn version --immediate. Instead ofyarn version --immediatebeing implemented asyarn version --deferred+yarn version apply, nowyarn version applyis implemented asyarn version --immediate decline. This alleviates the git history requirement ofyarn version --immediateThe prerelease bumping logic is also refactored to be more predictable and can be calculated from a single version, without relying on storing an additional
stableVersion. Simply put, if the current version is1.2.0-3,prepatchandpreminorboth bump it to1.2.0-4andpremajorbump it to2.0.0-0.prereleaseis effectively same asprepatch.Now that
stableVersionis not needed,yarn version --immediateandyarn version applywill remove them from any bumped workspaces.(Our own release pipeline also writes the
stableVersionfield but I don't know if there is a purpose. So I have left them alone for now)The
--prereleaseflag also have some bug fixed. For example, when applying aprereleasebump to1.2.3-alpha.1with prerelease patternbeta.%n, you'd end up with1.2.3-alpha.1-beta.1...Also, given how easily "bumping" to a version lower than the current one can happen accidentally due to how prereleases work, there is also now a check to stop that and a
--forceflag to suppress that check.The command documentation has been rewritten and many tests have been added to rigorously document these behavior.
Checklist