Skip to content

Commit 9bb6ea0

Browse files
committed
build: address pre-release validation failure
Previously, the release process encountered an error due to ts-node's inability to transform `packages/schematics/angular/utility/latest-versions.ts`, resulting in the following error: ``` export const latestVersions: Record<string, string> & { ^^^^^^ SyntaxError: Unexpected token 'export' at internalCompileFunction (node:internal/vm:73:18) at wrapSafe (node:internal/modules/cjs/loader:1274:20) at Module._compile (node:internal/modules/cjs/loader:1320:27) at Module._extensions..js (node:internal/modules/cjs/loader:1414:10) at Module.load (node:internal/modules/cjs/loader:1197:32) at Module._load (node:internal/modules/cjs/loader:1013:12) at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:202:29) at ModuleJob.run (node:internal/modules/esm/module_job:195:25) at async ModuleLoader.import (node:internal/modules/esm/loader:336:24) at async checkSchematicsAngularLatestVersion (file:///usr/..../git/angular-cli/scripts/release-checks/dependency-ranges/latest-versions-check.mts:9:46) ``` To resolve this issue, we now utilize the `package.json` directly to retrieve dependency versions. (cherry picked from commit 7682a71)
1 parent 8a6550d commit 9bb6ea0

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

packages/schematics/angular/utility/latest-versions.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,19 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9+
// We could have used TypeScripts' `resolveJsonModule` to make the `latestVersion` object typesafe,
10+
// but ts_library doesn't support JSON inputs.
11+
const dependencies = require('./latest-versions/package.json')['dependencies'];
12+
913
export const latestVersions: Record<string, string> & {
1014
Angular: string;
1115
DevkitBuildAngular: string;
1216
AngularSSR: string;
1317
} = {
14-
// We could have used TypeScripts' `resolveJsonModule` to make the `latestVersion` object typesafe,
15-
// but ts_library doesn't support JSON inputs.
16-
...require('./latest-versions/package.json')['dependencies'],
18+
...dependencies,
1719

1820
// As Angular CLI works with same minor versions of Angular Framework, a tilde match for the current
19-
Angular: '^17.3.0',
21+
Angular: dependencies['@angular/core'],
2022

2123
DevkitBuildAngular: '^0.0.0-PLACEHOLDER',
2224
AngularSSR: '^0.0.0-PLACEHOLDER',

packages/schematics/angular/utility/latest-versions/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"comment": "This file is needed so that dependencies are synced by Renovate.",
44
"private": true,
55
"dependencies": {
6+
"@angular/core": "^17.3.0",
67
"@types/express": "^4.17.17",
78
"@types/jasmine": "~5.1.0",
89
"@types/node": "^18.18.0",

scripts/release-checks/dependency-ranges/latest-versions-check.mts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9+
import { readFile } from 'node:fs/promises';
910
import semver from 'semver';
1011

1112
export async function checkSchematicsAngularLatestVersion(
1213
newVersion: semver.SemVer,
1314
): Promise<string[]> {
14-
const {
15-
default: { latestVersions },
16-
} = await import('../../../packages/schematics/angular/utility/latest-versions.js');
15+
const { dependencies } = JSON.parse(
16+
await readFile('./packages/schematics/angular/utility/latest-versions/package.json', 'utf-8'),
17+
);
1718

18-
const keysToCheck = ['ng-packagr', 'Angular'];
19+
const keysToCheck = ['ng-packagr', '@angular/core'];
1920
const { major, minor } = newVersion;
2021
const isPrerelease = !!newVersion.prerelease[0];
2122
const failures: string[] = [];
@@ -26,7 +27,7 @@ export async function checkSchematicsAngularLatestVersion(
2627
}
2728

2829
for (const key of keysToCheck) {
29-
if (latestVersions[key] !== expectedFwDep) {
30+
if (dependencies[key] !== expectedFwDep) {
3031
failures.push(
3132
`latest-versions: Invalid dependency range for "${key}". Expected: ${expectedFwDep}`,
3233
);

0 commit comments

Comments
 (0)