From 8754cd2c7541f137ee8c18f8da504040f5d7b1d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leosvel=20P=C3=A9rez=20Espinosa?= Date: Thu, 6 Apr 2023 15:02:34 +0100 Subject: [PATCH] fix(angular): fix migrations cli type and use @angular-devkit/build-angular to determine ng devkit version (#16157) (cherry picked from commit e9f97f87e9a5eddb07cb1f3c6a903cae22ec4c8f) --- packages/angular/migrations.json | 4 ++-- .../install-required-packages.spec.ts | 24 +++++++++---------- .../install-required-packages.ts | 4 ++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/packages/angular/migrations.json b/packages/angular/migrations.json index 7c7de99331197..609ab47d476a9 100644 --- a/packages/angular/migrations.json +++ b/packages/angular/migrations.json @@ -121,7 +121,7 @@ "factory": "./src/migrations/update-15-2-0/update-workspace-config" }, "update-platform-server-exports": { - "cli": "ng", + "cli": "nx", "version": "15.2.0-beta.0", "requires": { "@angular/core": ">=15.0.0" @@ -130,7 +130,7 @@ "factory": "./src/migrations/update-15-2-0/remove-platform-server-exports" }, "update-karma-main-file": { - "cli": "ng", + "cli": "nx", "version": "15.2.0-beta.0", "requires": { "@angular/core": ">=15.0.0" diff --git a/packages/angular/src/migrations/update-15-7-0/install-required-packages.spec.ts b/packages/angular/src/migrations/update-15-7-0/install-required-packages.spec.ts index a28cb34aab768..6008d5ad34e4c 100644 --- a/packages/angular/src/migrations/update-15-7-0/install-required-packages.spec.ts +++ b/packages/angular/src/migrations/update-15-7-0/install-required-packages.spec.ts @@ -20,7 +20,7 @@ describe('installed-required-packages', () => { '@angular/core': '~15.0.0', }, devDependencies: { - '@angular/cli': '~15.0.0', + '@angular-devkit/build-angular': '~15.0.0', }, })); @@ -36,9 +36,9 @@ describe('installed-required-packages', () => { `); expect(pkgJson.devDependencies).toMatchInlineSnapshot(` Object { + "@angular-devkit/build-angular": "~15.0.0", "@angular-devkit/core": "~15.0.0", "@angular-devkit/schematics": "~15.0.0", - "@angular/cli": "~15.0.0", "@schematics/angular": "~15.0.0", } `); @@ -53,7 +53,7 @@ describe('installed-required-packages', () => { '@angular/core': '~14.0.0', }, devDependencies: { - '@angular/cli': '~14.0.0', + '@angular-devkit/build-angular': '~14.0.0', }, })); @@ -69,9 +69,9 @@ describe('installed-required-packages', () => { `); expect(pkgJson.devDependencies).toMatchInlineSnapshot(` Object { + "@angular-devkit/build-angular": "~14.0.0", "@angular-devkit/core": "~14.0.0", "@angular-devkit/schematics": "~14.0.0", - "@angular/cli": "~14.0.0", "@schematics/angular": "~14.0.0", } `); @@ -86,7 +86,7 @@ describe('installed-required-packages', () => { '@angular/core': '~15.0.0', }, devDependencies: { - '@angular/cli': '~15.0.0', + '@angular-devkit/build-angular': '~15.0.0', '@angular-devkit/core': '~15.0.0', '@angular-devkit/schematics': '~15.0.0', '@schematics/angular': '~15.0.0', @@ -105,9 +105,9 @@ describe('installed-required-packages', () => { `); expect(pkgJson.devDependencies).toMatchInlineSnapshot(` Object { + "@angular-devkit/build-angular": "~15.0.0", "@angular-devkit/core": "~15.0.0", "@angular-devkit/schematics": "~15.0.0", - "@angular/cli": "~15.0.0", "@schematics/angular": "~15.0.0", } `); @@ -122,7 +122,7 @@ describe('installed-required-packages', () => { '@angular/core': '~14.0.0', }, devDependencies: { - '@angular/cli': '~14.0.0', + '@angular-devkit/build-angular': '~14.0.0', '@angular-devkit/core': '~14.0.0', '@angular-devkit/schematics': '~14.0.0', '@schematics/angular': '~14.0.0', @@ -141,9 +141,9 @@ describe('installed-required-packages', () => { `); expect(pkgJson.devDependencies).toMatchInlineSnapshot(` Object { + "@angular-devkit/build-angular": "~14.0.0", "@angular-devkit/core": "~14.0.0", "@angular-devkit/schematics": "~14.0.0", - "@angular/cli": "~14.0.0", "@schematics/angular": "~14.0.0", } `); @@ -158,7 +158,7 @@ describe('installed-required-packages', () => { '@angular/core': '~15.0.0', }, devDependencies: { - '@angular/cli': '~15.0.0', + '@angular-devkit/build-angular': '~15.0.0', '@angular-devkit/core': '~15.0.0', '@schematics/angular': '~15.0.0', }, @@ -176,9 +176,9 @@ describe('installed-required-packages', () => { `); expect(pkgJson.devDependencies).toMatchInlineSnapshot(` Object { + "@angular-devkit/build-angular": "~15.0.0", "@angular-devkit/core": "~15.0.0", "@angular-devkit/schematics": "~15.0.0", - "@angular/cli": "~15.0.0", "@schematics/angular": "~15.0.0", } `); @@ -193,7 +193,7 @@ describe('installed-required-packages', () => { '@angular/core': '~14.0.0', }, devDependencies: { - '@angular/cli': '~14.0.0', + '@angular-devkit/build-angular': '~14.0.0', '@angular-devkit/core': '~14.0.0', '@schematics/angular': '~14.0.0', }, @@ -211,9 +211,9 @@ describe('installed-required-packages', () => { `); expect(pkgJson.devDependencies).toMatchInlineSnapshot(` Object { + "@angular-devkit/build-angular": "~14.0.0", "@angular-devkit/core": "~14.0.0", "@angular-devkit/schematics": "~14.0.0", - "@angular/cli": "~14.0.0", "@schematics/angular": "~14.0.0", } `); diff --git a/packages/angular/src/migrations/update-15-7-0/install-required-packages.ts b/packages/angular/src/migrations/update-15-7-0/install-required-packages.ts index 9b4da5d65a566..b7588f7635026 100644 --- a/packages/angular/src/migrations/update-15-7-0/install-required-packages.ts +++ b/packages/angular/src/migrations/update-15-7-0/install-required-packages.ts @@ -25,8 +25,8 @@ export default async function (tree: Tree) { ); const angularCliVersion = - pkgJson.devDependencies?.['@angular/cli'] ?? - pkgJson.dependencies?.['@angular/cli'] ?? + pkgJson.devDependencies?.['@angular-devkit/build-angular'] ?? + pkgJson.dependencies?.['@angular-devkit/build-angular'] ?? angularDevkitVersion; const filteredPackages: Record = packagesToInstall