Skip to content

Commit b54e9a5

Browse files
committed
fix(@angular/cli): do not sort migrations of the same version alphabetically
When executing update migrations, schematics targeting the same version were previously sorted alphabetically by name. This change removes the alphabetical sorting fallback, allowing migrations targeting the same version to preserve their original declaration/discovery order.
1 parent b048b5f commit b54e9a5

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

  • packages/angular/cli/src/commands/update/utilities

packages/angular/cli/src/commands/update/utilities/migration.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,7 @@ export async function executeMigrations(
153153
if (requiredMigrations.length) {
154154
logger.info(colors.cyan(`** Executing migrations of package '${packageName}' **\n`));
155155

156-
requiredMigrations.sort(
157-
(a, b) => semver.compare(a.version, b.version) || a.name.localeCompare(b.name),
158-
);
156+
requiredMigrations.sort(compareMigrations);
159157

160158
const result = await executePackageMigrations(
161159
workflow,
@@ -174,9 +172,7 @@ export async function executeMigrations(
174172
if (optionalMigrations.length) {
175173
logger.info(colors.magenta(`** Optional migrations of package '${packageName}' **\n`));
176174

177-
optionalMigrations.sort(
178-
(a, b) => semver.compare(a.version, b.version) || a.name.localeCompare(b.name),
179-
);
175+
optionalMigrations.sort(compareMigrations);
180176

181177
const migrationsToRun = await getOptionalMigrationsToRun(
182178
logger,
@@ -372,3 +368,10 @@ function getMigrationTitleAndDescription(migration: MigrationSchematicDescriptio
372368
: undefined,
373369
};
374370
}
371+
372+
function compareMigrations(
373+
a: MigrationSchematicDescriptionWithVersion,
374+
b: MigrationSchematicDescriptionWithVersion,
375+
): number {
376+
return semver.compare(a.version, b.version);
377+
}

0 commit comments

Comments
 (0)