@@ -3,14 +3,64 @@ import {
3
3
SchematicContext ,
4
4
Tree
5
5
} from '@angular-devkit/schematics' ;
6
+ import { getProjects , getWorkspace } from '../common/util' ;
6
7
import { UpdateChanges } from '../common/UpdateChanges' ;
7
8
8
9
const version = '8.2.6' ;
9
10
10
11
export default function ( ) : Rule {
11
12
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
+
12
35
context . logger . info ( `Applying migration for Ignite UI for Angular to version ${ version } ` ) ;
13
36
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
+
14
64
const update = new UpdateChanges ( __dirname , host , context ) ;
15
65
update . applyChanges ( ) ;
16
66
} ;
0 commit comments