Skip to content

Commit a2662fe

Browse files
fix(build): name canaries after the release, not after a prerelease (#3767)
A canary named `21.0.0-rc.1-canary.<sha>` ranks above `21.0.0-rc.1`, so `@next` installs resolved to canary releases. The version field goes back to `21.0.0`, as releases through v20 kept it, and build.sh drops any prerelease part when naming a canary. Also regenerates the sample's lockfile against the `21.0.0` tarball.
1 parent 1c8f0f3 commit a2662fe

7 files changed

Lines changed: 27 additions & 19 deletions

File tree

‎package-lock.json‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular/fire",
3-
"version": "21.0.0-rc.1",
3+
"version": "21.0.0",
44
"description": "Angular + Firebase = ❤️",
55
"publishConfig": {
66
"registry": "https://wombat-dressing-room.appspot.com",

‎sample/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This project was generated using [Angular CLI](https://github.com/angular/angula
44

55
## AngularFire tarball
66

7-
The sample consumes the library as `file:../angular-fire-21.0.0-rc.1.tgz`. Produce that file from the repository root before installing here:
7+
The sample consumes the library as `file:../angular-fire-21.0.0.tgz`. Produce that file from the repository root before installing here:
88

99
```bash
1010
npm ci
@@ -16,7 +16,7 @@ The root build ends with `npm pack ./dist/packages-dist`, which writes `angular-
1616
Then, from this `sample/` folder, install the dependencies by naming the tarball explicitly:
1717

1818
```bash
19-
npm install ../angular-fire-21.0.0-rc.1.tgz
19+
npm install ../angular-fire-21.0.0.tgz
2020
```
2121

2222
A plain `npm install` is not reliable here. `package-lock.json` records the integrity hash of the tarball built by whoever committed the lockfile, and a tarball you build yourself can hash differently. With a cold npm cache the install then fails with an `EINTEGRITY` error. With a warm cache that holds the recorded hash, npm installs the stale cached copy and exits successfully, so you would be testing a library you did not build. Naming the tarball installs the file on disk and rewrites the recorded hash in your local `package-lock.json`. Leave that lockfile change uncommitted.

‎sample/package-lock.json‎

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎sample/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"@angular/common": "^21.0.0",
1515
"@angular/compiler": "^21.0.0",
1616
"@angular/core": "^21.0.0",
17-
"@angular/fire": "file:../angular-fire-21.0.0-rc.1.tgz",
17+
"@angular/fire": "file:../angular-fire-21.0.0.tgz",
1818
"@angular/forms": "^21.0.0",
1919
"@angular/platform-browser": "^21.0.0",
2020
"@angular/platform-server": "^21.0.0",

‎src/schematics/common.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ const angularFireVersion = 'ANGULARFIRE2_VERSION';
146146

147147
/**
148148
* Pins the workspace's `@angular/fire` entry to the exact installed version when `ng add` wrote a
149-
* prerelease range. A prerelease range like `^21.0.0-rc.0` also matches the canary build published
150-
* for every merge to main, so a later fresh install can silently replace the version the user
151-
* chose. Stable ranges are left untouched.
149+
* prerelease range. A prerelease range like `^21.0.0-rc.0` also matches every later prerelease of
150+
* the same release, so a later fresh install can silently replace the version the user chose.
151+
* Stable ranges are left untouched.
152152
*/
153153
export const pinInstalledPrereleaseVersion = (
154154
host: Tree,
@@ -181,7 +181,7 @@ export const pinInstalledPrereleaseVersion = (
181181
overwriteIfExists(host, 'package.json', stringifyFormatted(packageJson));
182182
context.logger.info(
183183
`Pinned @angular/fire to the exact version ${installedVersion} — a prerelease range like ` +
184-
`${declaredAngularFireVersion} also matches unreviewed canary builds, so a later install ` +
184+
`${declaredAngularFireVersion} also matches later prereleases, so a later install ` +
185185
'could silently change versions.'
186186
);
187187
}

‎tools/build.sh‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,15 @@ if [[ $GITHUB_REF =~ $TAG_TEST ]]; then
1010
NPM_TAG=next
1111
fi;
1212
else
13-
OVERRIDE_VERSION=$(node -e "console.log(require('./package.json').version)")-canary.$SHORT_SHA
13+
FULL_VERSION=$(node -e "console.log(require('./package.json').version)")
14+
# Name the canary after the release itself, never after a prerelease of it. A canary built on
15+
# `21.0.0-rc.1` sorts above it, so the caret range `ng add` writes into a user's package.json
16+
# resolves to the canary rather than to the release candidate they asked for.
17+
BASE_VERSION=${FULL_VERSION%%-*}
18+
if [[ $BASE_VERSION != "$FULL_VERSION" ]]; then
19+
echo "package.json version is $FULL_VERSION. Naming this canary after $BASE_VERSION instead, so it does not outrank $FULL_VERSION on npm. Prereleases are published from their own git tag, so this field is meant to hold a plain release number." >&2
20+
fi
21+
OVERRIDE_VERSION=$BASE_VERSION-canary.$SHORT_SHA
1422
NPM_TAG=canary
1523
fi;
1624

0 commit comments

Comments
 (0)