-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@angular/cli): ensure all available package migrations are executed
For v14, the update command migration execution logic was incorrectly exiting after the success of the first package's migrations. This prevented any other updated packages from executing migrations automatically. The success check is now a failure check and will allow the migration execution process to continue to execute migrations until complete or a failure occurs. (cherry picked from commit 5ad5bda)
- Loading branch information
Showing
2 changed files
with
21 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import { appendFile } from 'fs/promises'; | ||
import { SemVer } from 'semver'; | ||
import { createProjectFromAsset } from '../../utils/assets'; | ||
import { expectFileMatchToExist, readFile } from '../../utils/fs'; | ||
import { setRegistry } from '../../utils/packages'; | ||
import { getActivePackageManager, setRegistry } from '../../utils/packages'; | ||
import { ng, noSilentNg } from '../../utils/process'; | ||
import { isPrereleaseCli, useCIChrome, useCIDefaults, NgCLIVersion } from '../../utils/project'; | ||
|
||
|
@@ -12,7 +13,18 @@ export default async function () { | |
await setRegistry(false); | ||
await createProjectFromAsset('10.0-project', true); | ||
|
||
// CLI proiject version | ||
// If using npm, enable legacy peer deps mode to avoid defects in npm 7+'s peer dependency resolution | ||
// Example error where 11.2.14 satisfies the SemVer range ^11.0.0 but still fails: | ||
// npm ERR! Conflicting peer dependency: @angular/[email protected] | ||
// npm ERR! node_modules/@angular/compiler-cli | ||
// npm ERR! peer @angular/compiler-cli@"^11.0.0 || ^11.2.0-next" from @angular-devkit/[email protected] | ||
// npm ERR! node_modules/@angular-devkit/build-angular | ||
// npm ERR! dev @angular-devkit/build-angular@"~0.1102.19" from the root project | ||
if (getActivePackageManager() === 'npm') { | ||
await appendFile('.npmrc', '\nlegacy-peer-deps=true'); | ||
} | ||
|
||
// CLI project version | ||
const { version: cliVersion } = JSON.parse( | ||
await readFile('./node_modules/@angular/cli/package.json'), | ||
); | ||
|
@@ -30,7 +42,10 @@ export default async function () { | |
// - 12 -> 13 | ||
const { stdout } = await ng('update', `@angular/cli@${version}`, `@angular/core@${version}`); | ||
if (!stdout.includes("Executing migrations of package '@angular/cli'")) { | ||
throw new Error('Update did not execute migrations. OUTPUT: \n' + stdout); | ||
throw new Error('Update did not execute migrations for @angular/cli. OUTPUT: \n' + stdout); | ||
} | ||
if (!stdout.includes("Executing migrations of package '@angular/core'")) { | ||
throw new Error('Update did not execute migrations for @angular/core. OUTPUT: \n' + stdout); | ||
} | ||
} | ||
} finally { | ||
|