Skip to content

Commit ebfd7b1

Browse files
committed
refactor(@angular/cli): show optional migration name and documentation URL if available during updates
The optional migration selection prompt shown during an interactive `ng update` will now show the name of the migration which can be used to manually run the update at a later time as well as a documentation link if present for the migration.
1 parent c977a7b commit ebfd7b1

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ interface MigrationSchematicDescription
6767
extends SchematicDescription<FileSystemCollectionDescription, FileSystemSchematicDescription> {
6868
version?: string;
6969
optional?: boolean;
70+
documentation?: string;
7071
}
7172

7273
interface MigrationSchematicDescriptionWithVersion extends MigrationSchematicDescription {
@@ -1082,10 +1083,6 @@ export default class UpdateCommandModule extends CommandModule<UpdateCommandArgs
10821083
numberOfMigrations > 1 ? 's' : ''
10831084
} that can be executed.`,
10841085
);
1085-
logger.info(
1086-
'Optional migrations may be skipped and executed after the update process if preferred.',
1087-
);
1088-
logger.info(''); // Extra trailing newline.
10891086

10901087
if (!isTTY()) {
10911088
for (const migration of optionalMigrations) {
@@ -1098,13 +1095,18 @@ export default class UpdateCommandModule extends CommandModule<UpdateCommandArgs
10981095
return undefined;
10991096
}
11001097

1098+
logger.info(
1099+
'Optional migrations may be skipped and executed after the update process, if preferred.',
1100+
);
1101+
logger.info(''); // Extra trailing newline.
1102+
11011103
const answer = await askChoices(
11021104
`Select the migrations that you'd like to run`,
11031105
optionalMigrations.map((migration) => {
1104-
const { title } = getMigrationTitleAndDescription(migration);
1106+
const { title, documentation } = getMigrationTitleAndDescription(migration);
11051107

11061108
return {
1107-
name: title,
1109+
name: `[${colors.white(migration.name)}] ${title}${documentation ? ` (${documentation})` : ''}`,
11081110
value: migration.name,
11091111
};
11101112
}),
@@ -1182,11 +1184,15 @@ function coerceVersionNumber(version: string | undefined): string | undefined {
11821184
function getMigrationTitleAndDescription(migration: MigrationSchematicDescription): {
11831185
title: string;
11841186
description: string;
1187+
documentation?: string;
11851188
} {
11861189
const [title, ...description] = migration.description.split('. ');
11871190

11881191
return {
11891192
title: title.endsWith('.') ? title : title + '.',
11901193
description: description.join('.\n '),
1194+
documentation: migration.documentation
1195+
? new URL(migration.documentation, 'https://angular.dev').href
1196+
: undefined,
11911197
};
11921198
}

packages/schematics/angular/migrations/migration-collection.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"version": "18.0.0",
55
"factory": "./use-application-builder/migration",
66
"description": "Migrate application projects to the new build system. Application projects that are using the '@angular-devkit/build-angular' package's 'browser' and/or 'browser-esbuild' builders will be migrated to use the new 'application' builder. You can read more about this, including known issues and limitations, here: https://angular.dev/tools/cli/build-system-migration",
7-
"optional": true
7+
"optional": true,
8+
"documentation": "tools/cli/build-system-migration"
89
}
910
}
1011
}

0 commit comments

Comments
 (0)