Skip to content

fix(cli): order prerelease versions per semver in the update check - #3506

Open
jayfeng7 wants to merge 1 commit into
upstash:masterfrom
jayfeng7:fix/cli-prerelease-update-check
Open

jayfeng7 wants to merge 1 commit into
upstash:masterfrom
jayfeng7:fix/cli-prerelease-update-check

Conversation

@jayfeng7

Copy link
Copy Markdown

What changed

compareVersions in packages/cli now orders versions the way semver does instead of comparing only the numeric core:/n/n- build metadata (+sha...) is ignored;

  • a release outranks any prerelease of the same core (0.9.0 > 0.9.0-rc.1);
  • prerelease identifiers are compared per semver: numeric identifiers numerically and below alphanumeric ones, and a longer set of otherwise equal identifiers wins (0.9.0-rc.1 < 0.9.0-rc.1.1).

Why

The CLI publishes a canary dist-tag (0.5.14-canary-20261006104237), and changeset version --snapshot canary cuts the snapshot from the version that is about to be released. A canary install therefore shares its numeric core with the following release. The old comparison dropped everything after the first -, so 0.9.0-canary-... compared equal to 0.9.0: updateAvailable stayed false and the user was never told the release had shipped.

The same truncation made 0.9.0-rc.9 and 0.9.0-rc.10 compare equal, and 0.9.0+build.5 compare greater than 0.9.0.

How I checked it

  • vitest run src/__tests__/update-check.test.ts: 15 passed (the 12 existing cases plus 3 new ones). The new cases fail on the current master, where those three pairs compare as 0 / 0 / 5 instead of >0 / >0 / 0.
  • Full package suite: 42 failures before and after, all in auth-utils / setup / storage-paths / installer (Windows-only: chmod 0o600, XDG paths, os.homedir() mocks). The passed count goes 334 -> 337, i.e. only the new cases.
  • eslint and prettier --check clean on both touched files.
  • Added a patch changeset for ctx7.

AI assistance

This change was produced with AI assistance (WorkBuddy): the agent wrote the implementation and the tests, and ran the commands quoted above. The author reviewed the diff and the results before submitting.

compareVersions dropped everything after the first hyphen and compared only
the numeric core, so a prerelease and the release cut from it were reported
as equal. Anyone installed from the canary dist-tag (0.9.0-canary-...) was
never told that 0.9.0 had shipped.

Versions are now ordered the way semver orders them: a release outranks any
prerelease of the same core, prerelease identifiers are compared per the
spec (numeric below alphanumeric, more identifiers above fewer), and build
metadata is ignored.

This branch has not been deployed

No deployments
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.

1 participant