File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
src/material/schematics/ng-update/migrations/theming-api-v12 Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 7
7
*/
8
8
9
9
import { extname } from '@angular-devkit/core' ;
10
+ import { SchematicContext } from '@angular-devkit/schematics' ;
10
11
import { DevkitMigration , ResolvedResource , TargetVersion } from '@angular/cdk/schematics' ;
11
12
import { migrateFileContent } from './migration' ;
12
13
13
14
/** Migration that switches all Sass files using Material theming APIs to `@use`. */
14
15
export class ThemingApiMigration extends DevkitMigration < null > {
16
+ /** Number of files that have been migrated. */
17
+ static migratedFileCount = 0 ;
18
+
15
19
enabled = this . targetVersion === TargetVersion . V12 ;
16
20
17
21
visitStylesheet ( stylesheet : ResolvedResource ) : void {
@@ -24,7 +28,19 @@ export class ThemingApiMigration extends DevkitMigration<null> {
24
28
this . fileSystem . edit ( stylesheet . filePath )
25
29
. remove ( 0 , stylesheet . content . length )
26
30
. insertLeft ( 0 , migratedContent ) ;
31
+ ThemingApiMigration . migratedFileCount ++ ;
27
32
}
28
33
}
29
34
}
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
+ }
30
46
}
You can’t perform that action at this time.
0 commit comments