fix(@schematics/angular): preserve the workspace build version during migration#32875
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request updates the use-application-builder migration to reuse the existing version of the builder when migrating to @angular/build. It introduces logic to check for the current version of @angular-devkit/build-angular or @angular/build in the package.json and uses that version for the new @angular/build dependency, falling back to a default version if neither is found. A new test case has been added to verify this version preservation. I have no feedback to provide.
| const buildDependency = | ||
| getPackageJsonDependency(tree, '@angular-devkit/build-angular') ?? | ||
| getPackageJsonDependency(tree, '@angular/build'); | ||
| rules.push( | ||
| addDependency('@angular/build', latestVersions.DevkitBuildAngular, { | ||
| addDependency('@angular/build', buildDependency?.version ?? latestVersions.AngularBuild, { | ||
| type: DependencyType.Dev, | ||
| existing: ExistingBehavior.Replace, | ||
| }), |
There was a problem hiding this comment.
| const buildDependency = | |
| getPackageJsonDependency(tree, '@angular-devkit/build-angular') ?? | |
| getPackageJsonDependency(tree, '@angular/build'); | |
| rules.push( | |
| addDependency('@angular/build', latestVersions.DevkitBuildAngular, { | |
| addDependency('@angular/build', buildDependency?.version ?? latestVersions.AngularBuild, { | |
| type: DependencyType.Dev, | |
| existing: ExistingBehavior.Replace, | |
| }), | |
| const buildAngularVersion = | |
| getDependency(tree, '@angular-devkit/build-angular')?.version ?? | |
| latestVersions.DevkitBuildAngular; | |
| rules.push( | |
| addDependency('@angular/build', buildAngularVersion, { | |
| type: DependencyType.Dev, | |
| existing: ExistingBehavior.Skip, | |
| }), |
There was a problem hiding this comment.
Applied in 60392dd. I switched to getDependency(...), used latestVersions.DevkitBuildAngular as the fallback, kept ExistingBehavior.Skip, and added coverage for preserving an existing @angular/build version.
alan-agius4
left a comment
There was a problem hiding this comment.
Please sign the CLA and squash the commits. Thanks
| // Add direct @angular/build dependencies and remove @angular-devkit/build-angular | ||
| const buildAngularVersion = | ||
| getDependency(tree, '@angular-devkit/build-angular')?.version ?? | ||
| latestVersions.DevkitBuildAngular; |
There was a problem hiding this comment.
NIT
| latestVersions.DevkitBuildAngular; | |
| latestVersions.AngularBuild; |
Summary
@angular-devkit/build-angularwhen theuse-application-buildermigration adds@angular/build@angular/buildversion if it is already present, and only then fall back to the repo default18.2.xworkspace so the migration no longer upgrades the package to an incompatible20.xreleaseTesting
corepack pnpm exec prettier --check packages/schematics/angular/migrations/use-application-builder/migration.ts packages/schematics/angular/migrations/use-application-builder/migration_spec.tscorepack pnpm exec eslint packages/schematics/angular/migrations/use-application-builder/migration.ts packages/schematics/angular/migrations/use-application-builder/migration_spec.tsgit diff --checkcorepack pnpm -s ng-dev format stagedcorepack pnpm bazel test //packages/schematics/angular:test --lockfile_mode=update --test_output=errors --verbose_failuresunder portable Nodev24.13.1withBAZEL_SHpointed at Git Bash; the target analyzed successfully but the Windows host then failed in Bazel's TypeScript toolchain before the schematic suite ran because the expectedaspect_rules_jsTypeScript entry point was missing from the generated execrootFixes #30696