@@ -3,14 +3,64 @@ import {
33 SchematicContext ,
44 Tree
55} from '@angular-devkit/schematics' ;
6+ import { getProjects , getWorkspace } from '../common/util' ;
67import { UpdateChanges } from '../common/UpdateChanges' ;
78
89const version = '8.2.6' ;
910
1011export default function ( ) : Rule {
1112 return ( host : Tree , context : SchematicContext ) => {
13+ const themes = [ '$_base-dark-grid-pagination' ,
14+ '$_dark-grid-pagination' ,
15+ '$_dark-fluent-grid-pagination' ,
16+ '$_light-grid-pagination' ,
17+ '$_fluent-grid-pagination' ,
18+ '$_round-shape-grid-pagination' ,
19+ '$_default-shape-grid-pagination' ,
20+ '$_square-shape-grid-pagination' ] ;
21+
22+ const newThemes = [ '$_base-dark-pagination' ,
23+ '$_dark-pagination' ,
24+ '$_dark-fluent-pagination' ,
25+ '$_light-pagination' ,
26+ '$_fluent-pagination' ,
27+ '$_round-shape-pagination' ,
28+ '$_default-shape-pagination' ,
29+ '$_square-shape-pagination' ] ;
30+
31+ let globalStyleExt : string ;
32+ const config = getWorkspace ( host ) ;
33+ const projects = getProjects ( config ) ;
34+
1235 context . logger . info ( `Applying migration for Ignite UI for Angular to version ${ version } ` ) ;
1336
37+ if ( config . schematics && config . schematics [ '@schematics/angular:component' ] ) {
38+ // updated projects have global prefix rather than per-project:
39+ globalStyleExt = config . schematics [ '@schematics/angular:component' ] . styleext ;
40+ }
41+
42+ for ( const proj of projects ) {
43+ const dir = host . getDir ( proj . sourceRoot ) ;
44+ let ext = globalStyleExt || 'scss' ;
45+ if ( proj . schematics && proj . schematics [ '@schematics/angular:component' ] ) {
46+ ext = proj . schematics [ '@schematics/angular:component' ] . styleext || ext ;
47+ }
48+ dir . visit ( ( path , entry ) => {
49+ if ( path . endsWith ( '.' + ext ) ) {
50+ let content = entry . content . toString ( ) ;
51+ if ( content . match ( / \b i g x - g r i d - p a g i n a t o r \b / g) ) {
52+ content = content . replace ( / \b i g x - g r i d - p a g i n a t o r \b / g, 'igx-paginator' ) ;
53+ }
54+ themes . forEach ( ( n , i ) => {
55+ if ( content . indexOf ( n ) !== - 1 ) {
56+ content = content . split ( n ) . join ( newThemes [ i ] ) ;
57+ }
58+ } ) ;
59+ host . overwrite ( path , content ) ;
60+ }
61+ } ) ;
62+ }
63+
1464 const update = new UpdateChanges ( __dirname , host , context ) ;
1565 update . applyChanges ( ) ;
1666 } ;
0 commit comments