@@ -16,6 +16,8 @@ class LiveSyncService implements ILiveSyncService {
16
16
private $projectDataService : IProjectDataService ,
17
17
private $prompter : IPrompter ,
18
18
private $injector : IInjector ,
19
+ private $mobileHelper : Mobile . IMobileHelper ,
20
+ private $devicesService : Mobile . IDevicesService ,
19
21
private $options : IOptions ) { }
20
22
21
23
private ensureAndroidFrameworkVersion ( platformData : IPlatformData ) : IFuture < void > { // TODO: this can be moved inside command or canExecute function
@@ -42,32 +44,50 @@ class LiveSyncService implements ILiveSyncService {
42
44
43
45
public liveSync ( platform : string ) : IFuture < void > {
44
46
return ( ( ) => {
45
- platform = this . $liveSyncServiceBase . getPlatform ( platform ) . wait ( ) ;
46
- let platformLowerCase = platform . toLowerCase ( ) ;
47
-
48
- if ( ! this . $platformService . preparePlatform ( platformLowerCase ) . wait ( ) ) {
49
- this . $errors . failWithoutHelp ( "Verify that listed files are well-formed and try again the operation." ) ;
47
+ let liveSyncData : ILiveSyncData [ ] = [ ] ;
48
+ this . $devicesService . initialize ( { skipInferPlatform : true } ) . wait ( ) ;
49
+ if ( platform ) {
50
+ liveSyncData . push ( this . prepareLiveSyncData ( platform ) ) ;
51
+ } else if ( this . $options . device ) {
52
+ platform = this . $devicesService . getDeviceByIdentifier ( this . $options . device ) . deviceInfo . platform ;
53
+ liveSyncData . push ( this . prepareLiveSyncData ( platform ) ) ;
54
+ } else {
55
+ for ( let installedPlatform of this . $platformService . getInstalledPlatforms ( ) . wait ( ) ) {
56
+ liveSyncData . push ( this . prepareLiveSyncData ( installedPlatform ) ) ;
57
+ }
50
58
}
51
59
52
60
this . _isInitialized = true ; // If we want before-prepare hooks to work properly, this should be set after preparePlatform function
53
61
54
- this . liveSyncCore ( platform ) . wait ( ) ;
62
+ this . liveSyncCore ( liveSyncData ) . wait ( ) ;
55
63
} ) . future < void > ( ) ( ) ;
56
64
}
57
65
66
+ private prepareLiveSyncData ( platform : string ) : ILiveSyncData {
67
+ platform = this . $liveSyncServiceBase . getPlatform ( platform ) . wait ( ) ;
68
+ if ( ! this . $platformService . preparePlatform ( platform . toLowerCase ( ) ) . wait ( ) ) {
69
+ this . $errors . failWithoutHelp ( "Verify that listed files are well-formed and try again the operation." ) ;
70
+ }
71
+
72
+ let platformData = this . $platformsData . getPlatformData ( platform . toLowerCase ( ) ) ;
73
+ if ( this . $mobileHelper . isAndroidPlatform ( platform ) ) {
74
+ this . ensureAndroidFrameworkVersion ( platformData ) . wait ( ) ;
75
+ }
76
+ let liveSyncData : ILiveSyncData = {
77
+ platform : platform ,
78
+ appIdentifier : this . $projectData . projectId ,
79
+ projectFilesPath : path . join ( platformData . appDestinationDirectoryPath , constants . APP_FOLDER_NAME ) ,
80
+ syncWorkingDirectory : path . join ( this . $projectData . projectDir , constants . APP_FOLDER_NAME ) ,
81
+ excludedProjectDirsAndFiles : this . $options . release ? constants . LIVESYNC_EXCLUDED_FILE_PATTERNS : [ ] ,
82
+ forceExecuteFullSync : this . forceExecuteFullSync
83
+ } ;
84
+
85
+ return liveSyncData ;
86
+ }
87
+
58
88
@helpers . hook ( 'livesync' )
59
- private liveSyncCore ( platform : string ) : IFuture < void > {
89
+ private liveSyncCore ( liveSyncData : ILiveSyncData [ ] ) : IFuture < void > {
60
90
return ( ( ) => {
61
- let platformData = this . $platformsData . getPlatformData ( platform . toLowerCase ( ) ) ;
62
- this . ensureAndroidFrameworkVersion ( platformData ) . wait ( ) ;
63
- let liveSyncData : ILiveSyncData = {
64
- platform : platform ,
65
- appIdentifier : this . $projectData . projectId ,
66
- projectFilesPath : path . join ( platformData . appDestinationDirectoryPath , constants . APP_FOLDER_NAME ) ,
67
- syncWorkingDirectory : path . join ( this . $projectData . projectDir , constants . APP_FOLDER_NAME ) ,
68
- excludedProjectDirsAndFiles : this . $options . release ? constants . LIVESYNC_EXCLUDED_FILE_PATTERNS : [ ] ,
69
- forceExecuteFullSync : this . forceExecuteFullSync
70
- } ;
71
91
this . $liveSyncServiceBase . sync ( liveSyncData ) . wait ( ) ;
72
92
} ) . future < void > ( ) ( ) ;
73
93
}
0 commit comments