@@ -10,6 +10,7 @@ export class MigrateController extends BaseUpdateController implements IMigrateC
1010 protected $platformsDataService : IPlatformsDataService ,
1111 protected $packageInstallationManager : IPackageInstallationManager ,
1212 protected $packageManager : IPackageManager ,
13+ private $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
1314 private $logger : ILogger ,
1415 private $addPlatformService : IAddPlatformService ,
1516 private $pluginsService : IPluginsService ,
@@ -58,15 +59,17 @@ export class MigrateController extends BaseUpdateController implements IMigrateC
5859 { packageName : "nativescript-cardview" , verifiedVersion : "3.2.0" }
5960 ] ;
6061
61- static readonly verifiedPlatformVersions : IDictionary < string > = {
62- [ constants . DEVICE_PLATFORMS . Android . toLowerCase ( ) ] : "6.0.0-2019-06-11-172137-01" ,
63- [ constants . DEVICE_PLATFORMS . iOS . toLowerCase ( ) ] : "6.0.0-2019-06-10-154118-03"
64- } ;
65-
6662 static readonly tempFolder : string = ".migration_backup" ;
67- static readonly updateFailMessage : string = "Could not migrate the project!" ;
63+ static readonly migrateFailMessage : string = "Could not migrate the project!" ;
6864 static readonly backupFailMessage : string = "Could not backup project folders!" ;
6965
66+ get verifiedPlatformVersions ( ) : IDictionary < string > {
67+ return {
68+ [ this . $devicePlatformsConstants . Android . toLowerCase ( ) ] : "6.0.0-2019-06-11-172137-01" ,
69+ [ this . $devicePlatformsConstants . iOS . toLowerCase ( ) ] : "6.0.0-2019-06-10-154118-03"
70+ } ;
71+ }
72+
7073 public async migrate ( { projectDir} : { projectDir : string } ) : Promise < void > {
7174 const projectData = this . $projectDataService . getProjectData ( projectDir ) ;
7275 const tmpDir = path . join ( projectDir , MigrateController . tempFolder ) ;
@@ -86,7 +89,7 @@ export class MigrateController extends BaseUpdateController implements IMigrateC
8689 await this . migrateDependencies ( projectData ) ;
8790 } catch ( error ) {
8891 this . restoreBackup ( MigrateController . folders , tmpDir , projectData ) ;
89- this . $logger . error ( MigrateController . updateFailMessage ) ;
92+ this . $logger . error ( MigrateController . migrateFailMessage ) ;
9093 }
9194 }
9295
@@ -103,8 +106,8 @@ export class MigrateController extends BaseUpdateController implements IMigrateC
103106 return true ;
104107 }
105108 }
106- for ( const platform in constants . DEVICE_PLATFORMS ) {
107- if ( await this . shouldUpdateRuntimeVersion ( { targetVersion : MigrateController . verifiedPlatformVersions [ platform . toLowerCase ( ) ] , platform, projectData, shouldAdd : true } ) ) {
109+ for ( const platform in this . $devicePlatformsConstants ) {
110+ if ( await this . shouldUpdateRuntimeVersion ( { targetVersion : this . verifiedPlatformVersions [ platform . toLowerCase ( ) ] , platform, projectData, shouldAdd : true } ) ) {
108111 return true ;
109112 }
110113 }
@@ -140,10 +143,10 @@ export class MigrateController extends BaseUpdateController implements IMigrateC
140143 }
141144 }
142145
143- for ( const platform in constants . DEVICE_PLATFORMS ) {
146+ for ( const platform in this . $devicePlatformsConstants ) {
144147 const lowercasePlatform = platform . toLowerCase ( ) ;
145- if ( await this . shouldUpdateRuntimeVersion ( { targetVersion : MigrateController . verifiedPlatformVersions [ lowercasePlatform ] , platform, projectData, shouldAdd : true } ) ) {
146- const verifiedPlatformVersion = MigrateController . verifiedPlatformVersions [ lowercasePlatform ] ;
148+ if ( await this . shouldUpdateRuntimeVersion ( { targetVersion : this . verifiedPlatformVersions [ lowercasePlatform ] , platform, projectData, shouldAdd : true } ) ) {
149+ const verifiedPlatformVersion = this . verifiedPlatformVersions [ lowercasePlatform ] ;
147150 const platformData = this . $platformsDataService . getPlatformData ( lowercasePlatform , projectData ) ;
148151 this . $logger . info ( `Updating ${ platform } platform to version '${ verifiedPlatformVersion } '.` ) ;
149152 await this . $addPlatformService . setPlatformVersion ( platformData , projectData , verifiedPlatformVersion ) ;
0 commit comments