fix(upgrade): compare prerelease versions per SemVer#34
Merged
Conversation
`isOutdated` stripped the prerelease suffix before comparing, so beta-to-beta bumps like 5.0.0-beta.0 -> 5.0.0-beta.1 both collapsed to [5,0,0], compared equal, and `dcd upgrade` reported "Already on the latest version". Same nudge in cloud.ts was affected. Replace the naive major.minor.patch compare with a SemVer 2.0.0 `compareSemver` helper that handles prerelease precedence (a prerelease ranks below its final release; identifiers compare dot-by-dot, numeric numerically and below alphanumeric). Add unit coverage for the regression and related cases. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
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.
Problem
dcd upgradewould not upgrade from5.0.0-beta.0to5.0.0-beta.1, reporting "Already on the latest version" instead.VersionService.isOutdatedstripped the prerelease suffix before comparing:So
5.0.0-beta.0and5.0.0-beta.1both collapsed to[5,0,0], compared equal, and the upgrade was treated as a no-op. The same outdated-version nudge incloud.tswas affected.Fix
Replace the naive
major.minor.patchcompare with a SemVer 2.0.0compareSemverhelper that handles prerelease precedence:5.0.0-beta.1 < 5.0.0).beta.0 < beta.1andbeta.2 < beta.10.Added
test/unit/version.service.test.tscovering the regression plus release/prerelease/equality/v-prefix cases.pnpm typecheckpasses; all new tests pass.Note
This fixes the comparator so future upgrades work. A binary already running the old
beta.0comparator still can't detect the bump — those users need one reinstall to pick up this fix, after which beta-to-beta upgrades work.🤖 Generated with Claude Code