From cd198d5f2f04558bb7f518c6db19a6236f83b620 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Mon, 19 Apr 2021 13:33:19 +0200 Subject: [PATCH] fix(@angular/cli): run all migrations when updating from or between prereleases With this change we consider the update schematics are idempotent. When updating from or between prereleases we will execute all migrations for the version. (cherry picked from commit 131379f49f404922bb7ba8cf92ec7b559cc990e7) --- packages/angular/cli/commands/update-impl.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/angular/cli/commands/update-impl.ts b/packages/angular/cli/commands/update-impl.ts index f4f1f724254e..e3a81aef6cf1 100644 --- a/packages/angular/cli/commands/update-impl.ts +++ b/packages/angular/cli/commands/update-impl.ts @@ -191,10 +191,14 @@ export class UpdateCommand extends Command { private async executeMigrations( packageName: string, collectionPath: string, - range: semver.Range, + from: string, + to: string, commit?: boolean, ): Promise { const collection = this.workflow.engine.createCollection(collectionPath); + const migrationRange = new semver.Range( + '>' + (semver.prerelease(from) ? from.split('-')[0] + '-0' : from) + ' <=' + to, + ); const migrations = []; for (const name of collection.listSchematicNames()) { @@ -207,7 +211,7 @@ export class UpdateCommand extends Command { continue; } - if (semver.satisfies(description.version, range, { includePrerelease: true })) { + if (semver.satisfies(description.version, migrationRange, { includePrerelease: true })) { migrations.push(description as typeof schematic.description & { version: string }); } } @@ -492,14 +496,11 @@ export class UpdateCommand extends Command { return 1; } - const migrationRange = new semver.Range( - '>' + from + ' <=' + (options.to || packageNode.version), - ); - success = await this.executeMigrations( packageName, migrations, - migrationRange, + from, + options.to || packageNode.version, options.createCommits, ); } @@ -647,7 +648,6 @@ export class UpdateCommand extends Command { next: !!options.next, packageManager: this.packageManager, packages: packagesToUpdate, - migrateExternal: true, }); if (success && options.createCommits) { @@ -733,7 +733,8 @@ export class UpdateCommand extends Command { const result = await this.executeMigrations( migration.package, migrations, - new semver.Range('>' + migration.from + ' <=' + migration.to), + migration.from, + migration.to, options.createCommits, );