@@ -10,6 +10,7 @@ export class MigrateController extends BaseUpdateController implements IMigrateC
10
10
protected $platformsDataService : IPlatformsDataService ,
11
11
protected $packageInstallationManager : IPackageInstallationManager ,
12
12
protected $packageManager : IPackageManager ,
13
+ private $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
13
14
private $logger : ILogger ,
14
15
private $addPlatformService : IAddPlatformService ,
15
16
private $pluginsService : IPluginsService ,
@@ -58,15 +59,17 @@ export class MigrateController extends BaseUpdateController implements IMigrateC
58
59
{ packageName : "nativescript-cardview" , verifiedVersion : "3.2.0" }
59
60
] ;
60
61
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
-
66
62
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!" ;
68
64
static readonly backupFailMessage : string = "Could not backup project folders!" ;
69
65
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
+
70
73
public async migrate ( { projectDir} : { projectDir : string } ) : Promise < void > {
71
74
const projectData = this . $projectDataService . getProjectData ( projectDir ) ;
72
75
const tmpDir = path . join ( projectDir , MigrateController . tempFolder ) ;
@@ -86,7 +89,7 @@ export class MigrateController extends BaseUpdateController implements IMigrateC
86
89
await this . migrateDependencies ( projectData ) ;
87
90
} catch ( error ) {
88
91
this . restoreBackup ( MigrateController . folders , tmpDir , projectData ) ;
89
- this . $logger . error ( MigrateController . updateFailMessage ) ;
92
+ this . $logger . error ( MigrateController . migrateFailMessage ) ;
90
93
}
91
94
}
92
95
@@ -103,8 +106,8 @@ export class MigrateController extends BaseUpdateController implements IMigrateC
103
106
return true ;
104
107
}
105
108
}
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 } ) ) {
108
111
return true ;
109
112
}
110
113
}
@@ -140,10 +143,10 @@ export class MigrateController extends BaseUpdateController implements IMigrateC
140
143
}
141
144
}
142
145
143
- for ( const platform in constants . DEVICE_PLATFORMS ) {
146
+ for ( const platform in this . $devicePlatformsConstants ) {
144
147
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 ] ;
147
150
const platformData = this . $platformsDataService . getPlatformData ( lowercasePlatform , projectData ) ;
148
151
this . $logger . info ( `Updating ${ platform } platform to version '${ verifiedPlatformVersion } '.` ) ;
149
152
await this . $addPlatformService . setPlatformVersion ( platformData , projectData , verifiedPlatformVersion ) ;
0 commit comments