Skip to content

Commit cd198d5

Browse files
committed
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 131379f)
1 parent 5f25616 commit cd198d5

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

packages/angular/cli/commands/update-impl.ts

+10-9
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,14 @@ export class UpdateCommand extends Command<UpdateCommandSchema> {
191191
private async executeMigrations(
192192
packageName: string,
193193
collectionPath: string,
194-
range: semver.Range,
194+
from: string,
195+
to: string,
195196
commit?: boolean,
196197
): Promise<boolean> {
197198
const collection = this.workflow.engine.createCollection(collectionPath);
199+
const migrationRange = new semver.Range(
200+
'>' + (semver.prerelease(from) ? from.split('-')[0] + '-0' : from) + ' <=' + to,
201+
);
198202
const migrations = [];
199203

200204
for (const name of collection.listSchematicNames()) {
@@ -207,7 +211,7 @@ export class UpdateCommand extends Command<UpdateCommandSchema> {
207211
continue;
208212
}
209213

210-
if (semver.satisfies(description.version, range, { includePrerelease: true })) {
214+
if (semver.satisfies(description.version, migrationRange, { includePrerelease: true })) {
211215
migrations.push(description as typeof schematic.description & { version: string });
212216
}
213217
}
@@ -492,14 +496,11 @@ export class UpdateCommand extends Command<UpdateCommandSchema> {
492496
return 1;
493497
}
494498

495-
const migrationRange = new semver.Range(
496-
'>' + from + ' <=' + (options.to || packageNode.version),
497-
);
498-
499499
success = await this.executeMigrations(
500500
packageName,
501501
migrations,
502-
migrationRange,
502+
from,
503+
options.to || packageNode.version,
503504
options.createCommits,
504505
);
505506
}
@@ -647,7 +648,6 @@ export class UpdateCommand extends Command<UpdateCommandSchema> {
647648
next: !!options.next,
648649
packageManager: this.packageManager,
649650
packages: packagesToUpdate,
650-
migrateExternal: true,
651651
});
652652

653653
if (success && options.createCommits) {
@@ -733,7 +733,8 @@ export class UpdateCommand extends Command<UpdateCommandSchema> {
733733
const result = await this.executeMigrations(
734734
migration.package,
735735
migrations,
736-
new semver.Range('>' + migration.from + ' <=' + migration.to),
736+
migration.from,
737+
migration.to,
737738
options.createCommits,
738739
);
739740

0 commit comments

Comments
 (0)