@@ -57,8 +57,31 @@ export class LegacyComponentsMigration extends Migration<null> {
57
57
if ( ! namespace || ! node . source ?. start ) {
58
58
return ;
59
59
}
60
- const mixinName = node . params . split ( / [ . ( ; ] / ) [ 1 ] ;
61
- if ( CUSTOM_SASS_MIXIN_RENAMINGS [ mixinName ] ) {
60
+ const original = node . toString ( ) ;
61
+ const [ atInclude , delim , mixinName , ...rest ] = original . split ( / ( [ . ( ; ] ) / ) ;
62
+ if ( mixinName === 'core' ) {
63
+ // The parameters may include function calls that need to be renamed.
64
+ const updatedFunctionsRest = Object . keys ( CUSTOM_SASS_FUNCTION_RENAMINGS ) . reduce (
65
+ ( s , r ) => s . replace ( new RegExp ( r , 'g' ) , CUSTOM_SASS_FUNCTION_RENAMINGS [ r ] ) ,
66
+ rest . join ( '' ) ,
67
+ ) ;
68
+ // The parameters are moved from the core include to the typography include.
69
+ const includeTypography = [ atInclude , delim , mixinName , updatedFunctionsRest ]
70
+ . join ( '' )
71
+ . replace ( `${ namespace } .core` , `${ namespace } .all-legacy-component-typographies` ) ;
72
+ const indent = original . match ( / ^ \s * / ) ?. [ 0 ] || '' ;
73
+ // Replace the whole original with a comment, typography include, and legacy-core include.
74
+ this . _replaceAt ( filePath , node . source . start . offset , {
75
+ old : original ,
76
+ new : [
77
+ `${ indent } // TODO(v15): As of v15 ${ namespace } .legacy-core no longer includes default typography styles.` ,
78
+ `${ indent } // Instead an explicit typography include has been automatically added here.` ,
79
+ `${ indent } // If you add typography styles elsewhere, you may want to remove this.` ,
80
+ `${ includeTypography } ;` ,
81
+ `${ indent } @include ${ namespace } .legacy-core()` ,
82
+ ] . join ( '\n' ) ,
83
+ } ) ;
84
+ } else if ( CUSTOM_SASS_MIXIN_RENAMINGS [ mixinName ] ) {
62
85
this . _replaceAt ( filePath , node . source . start . offset , {
63
86
old : `${ namespace } .${ mixinName } ` ,
64
87
new : `${ namespace } .${ CUSTOM_SASS_MIXIN_RENAMINGS [ mixinName ] } ` ,
0 commit comments