Skip to content

Commit eca9b64

Browse files
crisbetommalerba
authored andcommitted
fix(material/schematics): log message at the end of the theming migration
Based on external feedback, adds a message with the number of migrated files at the end of the theming API migration.
1 parent d5f4523 commit eca9b64

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/material/schematics/ng-update/migrations/theming-api-v12/theming-api-migration.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,15 @@
77
*/
88

99
import {extname} from '@angular-devkit/core';
10+
import {SchematicContext} from '@angular-devkit/schematics';
1011
import {DevkitMigration, ResolvedResource, TargetVersion} from '@angular/cdk/schematics';
1112
import {migrateFileContent} from './migration';
1213

1314
/** Migration that switches all Sass files using Material theming APIs to `@use`. */
1415
export class ThemingApiMigration extends DevkitMigration<null> {
16+
/** Number of files that have been migrated. */
17+
static migratedFileCount = 0;
18+
1519
enabled = this.targetVersion === TargetVersion.V12;
1620

1721
visitStylesheet(stylesheet: ResolvedResource): void {
@@ -24,7 +28,19 @@ export class ThemingApiMigration extends DevkitMigration<null> {
2428
this.fileSystem.edit(stylesheet.filePath)
2529
.remove(0, stylesheet.content.length)
2630
.insertLeft(0, migratedContent);
31+
ThemingApiMigration.migratedFileCount++;
2732
}
2833
}
2934
}
35+
36+
/** Logs out the number of migrated files at the end of the migration. */
37+
static globalPostMigration(_tree: unknown, context: SchematicContext): void {
38+
const count = ThemingApiMigration.migratedFileCount;
39+
40+
if (count > 0) {
41+
context.logger.info(`Migrated ${count === 1 ? `1 file` : `${count} files`} to the ` +
42+
`new Angular Material theming API.`);
43+
ThemingApiMigration.migratedFileCount = 0;
44+
}
45+
}
3046
}

0 commit comments

Comments
 (0)