fix(build): name canaries above every published release of their major - #3780
armando-navarro wants to merge 1 commit into
Conversation
`ng add @angular/fire@canary` installs `^<canary>`, and npm picks the highest version in that range. Canaries were named after package.json's version, 21.0.0, so they ranked below 21.0.0-rc.1 and would rank below 21.0.0 once it ships, and the command installed those instead. A canary is now named one patch above the highest published version of its major that is not a canary, or after package.json's version if that is higher. Published canaries don't count, so the name doesn't climb with every build, and a release of another major doesn't rename them. Release candidate and release ranges like `^21.0.0-rc.1` and `^21.0.0` still never match a canary. The rule lives in tools/canary-version.js, with a spec run by test:node. Fixes angular#3779
tyler-reitz
left a comment
There was a problem hiding this comment.
LGTM.
Ran test:node at 6deb73a (342 specs, 0 failures) and checked the new spec can fail: restoring the old naming rule turns 7 of its 8 specs red, so it guards the bug rather than the implementation. Also ran build.sh with npm view stubbed, and the base version tracks the published list as described, including exit 1 when npm is unreachable.
One non-blocking note for "Behavior to know": canary followers drop off the canary channel at every patch release, not just at 21.0.0. With ^21.0.1-canary.X saved, once 21.0.1 ships the range resolves to 21.0.1 even if a 21.0.2-canary.* exists (checked with node-semver 7.7.3), since a prerelease only satisfies a range on its own major.minor.patch tuple. Worth a line, since that is the ongoing effect for anyone tracking canary.
Fixes #3779
ng add @angular/fire@canarynow installs the newest canary build instead of the release candidate, and keeps doing so after21.0.0ships.Changes
tools/canary-version.jspicks the version a canary is named after: one patch above the highest published version of the same major that is not a canary, orpackage.json's version without its prerelease part if that is higher.21.0.1-canary.<UTC commit time>.sha-<short sha>.21.0.0ships it gives21.0.1-canary.*, and after21.0.1ships,21.0.2-canary.*.package.jsonat22.0.0-rc.0and nothing in 22 published yet, it gives22.0.0-canary.*.tools/build.shreads the published versions withnpm view @angular/fire versions --jsonand stops the build if npm can't be read. Tagged releases are named exactly as before.tools/canary-version.jasmine.tscovers the cases above, andtsconfig.jasmine.jsonnow includestools/**/*.jasmine.tssotest:noderuns it.package.jsonis removed, since a prerelease there no longer changes the name.Behavior to know
21.0.1-canarybuild isn't offered21.0.0byng updateonce it ships, because21.0.0ranks below what they have. To go back to a release they install it directly, for examplenpm install @angular/fire@21.Verification
npm run test:node: 342 specs, 0 failures. Counting published canaries again fails 1 spec, and usingsemver.incon the release candidate (which turns21.0.0-rc.1into21.0.0) fails 5.tools/build.shin a scratch repository withnpm viewanswering from version lists and the build step stubbed:21.0.1-canary.*.21.0.0gives21.0.1-canary.*, adding21.0.1gives21.0.2-canary.*.21.1.0-rc.0gives21.1.1-canary.*, adding21.0.1-rc.0gives21.0.2-canary.*.21.0.1-canary.*builds still gives21.0.1-canary.*.20.0.4or22.0.0-rc.0doesn't change the 21 canary.^<canary>selects the canary, and^21.0.0,~21.0.0,^21.0.0-rc.1and^20.0.0never select a canary.