@@ -47,6 +47,7 @@ const coreVersion = 'next';
4747const pluginVersion = 'next' ;
4848const gradleVersion = '8.14.3' ;
4949const iOSVersion = '15' ;
50+ const kotlinVersion = '2.2.20' ;
5051let installFailed = false ;
5152
5253export async function migrateCommand ( config : Config , noprompt : boolean , packagemanager : string ) : Promise < void > {
@@ -489,9 +490,26 @@ async function updateBuildGradle(
489490 }
490491 }
491492 }
493+
494+ const beforeKotlinVersionUpdate = replaced ;
495+ replaced = replaceVersion ( replaced , / ( e x t \. k o t l i n _ v e r s i o n \s * = \s * [ ' " ] ) ( [ ^ ' " ] + ) ( [ ' " ] ) / , kotlinVersion ) ;
496+ replaced = replaceVersion ( replaced , / ( o r g \. j e t b r a i n s \. k o t l i n : k o t l i n [ ^ : ] * : ) ( [ \d . ] + ) ( [ ' " ] ) / , kotlinVersion ) ;
497+ if ( beforeKotlinVersionUpdate !== replaced ) {
498+ logger . info ( `Set Kotlin version to ${ kotlinVersion } ` ) ;
499+ }
492500 writeFileSync ( filename , replaced , 'utf-8' ) ;
493501}
494502
503+ function replaceVersion ( text : string , regex : RegExp , newVersion : string ) : string {
504+ return text . replace ( regex , ( match , prefix , currentVersion , suffix ) => {
505+ const semVer = coerce ( currentVersion ) ?. version ;
506+ if ( gte ( newVersion , semVer ? semVer : '0.0.0' ) ) {
507+ return `${ prefix || '' } ${ newVersion } ${ suffix || '' } ` ;
508+ }
509+ return match ;
510+ } ) ;
511+ }
512+
495513async function updateAppBuildGradle ( filename : string ) {
496514 const txt = readFile ( filename ) ;
497515 if ( ! txt ) {
0 commit comments