@@ -145,60 +145,54 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
145
145
throw new Error ( `Invalid platform ${ platform } . Supported platforms are: ${ this . $mobileHelper . platformNames . join ( ", " ) } ` ) ;
146
146
}
147
147
148
- private async ensureLatestAppPackageIsInstalledOnDevice ( device : Mobile . IDevice ,
149
- preparedPlatforms : string [ ] ,
150
- rebuiltInformation : ILiveSyncBuildInfo [ ] ,
151
- projectData : IProjectData ,
152
- deviceBuildInfoDescriptor : ILiveSyncDeviceInfo ,
153
- settings : ILatestAppPackageInstalledSettings ,
154
- modifiedFiles ?: string [ ] ) : Promise < void > {
155
- const platform = device . deviceInfo . platform ;
156
- if ( preparedPlatforms . indexOf ( platform ) === - 1 ) {
157
- preparedPlatforms . push ( platform ) ;
148
+ private async ensureLatestAppPackageIsInstalledOnDevice ( options : IEnsureLatestAppPackageIsInstalledOnDeviceOptions ) : Promise < void > {
149
+ const platform = options . device . deviceInfo . platform ;
150
+ if ( options . preparedPlatforms . indexOf ( platform ) === - 1 ) {
151
+ options . preparedPlatforms . push ( platform ) ;
158
152
// TODO: Pass provision and sdk as a fifth argument here
159
153
await this . $platformService . preparePlatform ( platform , {
160
154
bundle : false ,
161
155
release : false ,
162
- } , null , projectData , < any > { } , modifiedFiles ) ;
156
+ } , null , options . projectData , < any > { } , options . modifiedFiles ) ;
163
157
}
164
158
165
- const rebuildInfo = _ . find ( rebuiltInformation , info => info . isEmulator === device . isEmulator && info . platform === platform ) ;
159
+ const rebuildInfo = _ . find ( options . rebuiltInformation , info => info . isEmulator === options . device . isEmulator && info . platform === platform ) ;
166
160
167
161
if ( rebuildInfo ) {
168
162
// Case where we have three devices attached, a change that requires build is found,
169
163
// we'll rebuild the app only for the first device, but we should install new package on all three devices.
170
- await this . $platformService . installApplication ( device , { release : false } , projectData , rebuildInfo . pathToBuildItem , deviceBuildInfoDescriptor . outputPath ) ;
164
+ await this . $platformService . installApplication ( options . device , { release : false } , options . projectData , rebuildInfo . pathToBuildItem , options . deviceBuildInfoDescriptor . outputPath ) ;
171
165
return ;
172
166
}
173
167
174
168
// TODO: Pass provision and sdk as a fifth argument here
175
- const shouldBuild = await this . $platformService . shouldBuild ( platform , projectData , < any > { buildForDevice : ! device . isEmulator } , deviceBuildInfoDescriptor . outputPath ) ;
169
+ const shouldBuild = await this . $platformService . shouldBuild ( platform , options . projectData , < any > { buildForDevice : ! options . device . isEmulator , clean : options . liveSyncData && options . liveSyncData . clean } , options . deviceBuildInfoDescriptor . outputPath ) ;
176
170
let pathToBuildItem = null ;
177
171
let action = LiveSyncTrackActionNames . LIVESYNC_OPERATION ;
178
172
if ( shouldBuild ) {
179
- pathToBuildItem = await deviceBuildInfoDescriptor . buildAction ( ) ;
173
+ pathToBuildItem = await options . deviceBuildInfoDescriptor . buildAction ( ) ;
180
174
// Is it possible to return shouldBuild for two devices? What about android device and android emulator?
181
- rebuiltInformation . push ( { isEmulator : device . isEmulator , platform, pathToBuildItem } ) ;
175
+ options . rebuiltInformation . push ( { isEmulator : options . device . isEmulator , platform, pathToBuildItem } ) ;
182
176
action = LiveSyncTrackActionNames . LIVESYNC_OPERATION_BUILD ;
183
177
}
184
178
185
- if ( ! settings [ platform ] [ device . deviceInfo . type ] ) {
186
- let isForDevice = ! device . isEmulator ;
187
- settings [ platform ] [ device . deviceInfo . type ] = true ;
179
+ if ( ! options . settings [ platform ] [ options . device . deviceInfo . type ] ) {
180
+ let isForDevice = ! options . device . isEmulator ;
181
+ options . settings [ platform ] [ options . device . deviceInfo . type ] = true ;
188
182
if ( this . $mobileHelper . isAndroidPlatform ( platform ) ) {
189
- settings [ platform ] [ DeviceTypes . Emulator ] = true ;
190
- settings [ platform ] [ DeviceTypes . Device ] = true ;
183
+ options . settings [ platform ] [ DeviceTypes . Emulator ] = true ;
184
+ options . settings [ platform ] [ DeviceTypes . Device ] = true ;
191
185
isForDevice = null ;
192
186
}
193
187
194
188
await this . $platformService . trackActionForPlatform ( { action, platform, isForDevice } ) ;
195
189
}
196
190
197
- await this . $platformService . trackActionForPlatform ( { action : LiveSyncTrackActionNames . DEVICE_INFO , platform, isForDevice : ! device . isEmulator , deviceOsVersion : device . deviceInfo . version } ) ;
191
+ await this . $platformService . trackActionForPlatform ( { action : LiveSyncTrackActionNames . DEVICE_INFO , platform, isForDevice : ! options . device . isEmulator , deviceOsVersion : options . device . deviceInfo . version } ) ;
198
192
199
- const shouldInstall = await this . $platformService . shouldInstall ( device , projectData , deviceBuildInfoDescriptor . outputPath ) ;
193
+ const shouldInstall = await this . $platformService . shouldInstall ( options . device , options . projectData , options . deviceBuildInfoDescriptor . outputPath ) ;
200
194
if ( shouldInstall ) {
201
- await this . $platformService . installApplication ( device , { release : false } , projectData , pathToBuildItem , deviceBuildInfoDescriptor . outputPath ) ;
195
+ await this . $platformService . installApplication ( options . device , { release : false } , options . projectData , pathToBuildItem , options . deviceBuildInfoDescriptor . outputPath ) ;
202
196
}
203
197
}
204
198
@@ -217,9 +211,17 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
217
211
} ) ;
218
212
219
213
const platform = device . deviceInfo . platform ;
220
- const deviceDescriptor = _ . find ( deviceDescriptors , dd => dd . identifier === device . deviceInfo . identifier ) ;
221
-
222
- await this . ensureLatestAppPackageIsInstalledOnDevice ( device , preparedPlatforms , rebuiltInformation , projectData , deviceDescriptor , settings ) ;
214
+ const deviceBuildInfoDescriptor = _ . find ( deviceDescriptors , dd => dd . identifier === device . deviceInfo . identifier ) ;
215
+
216
+ await this . ensureLatestAppPackageIsInstalledOnDevice ( {
217
+ device,
218
+ preparedPlatforms,
219
+ rebuiltInformation,
220
+ projectData,
221
+ deviceBuildInfoDescriptor,
222
+ liveSyncData,
223
+ settings
224
+ } ) ;
223
225
224
226
const liveSyncResultInfo = await this . getLiveSyncService ( platform ) . fullSync ( {
225
227
projectData, device,
@@ -305,9 +307,17 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
305
307
306
308
await this . $devicesService . execute ( async ( device : Mobile . IDevice ) => {
307
309
const liveSyncProcessInfo = this . liveSyncProcessesInfo [ projectData . projectDir ] ;
308
- const deviceDescriptor = _ . find ( liveSyncProcessInfo . deviceDescriptors , dd => dd . identifier === device . deviceInfo . identifier ) ;
310
+ const deviceBuildInfoDescriptor = _ . find ( liveSyncProcessInfo . deviceDescriptors , dd => dd . identifier === device . deviceInfo . identifier ) ;
309
311
310
- await this . ensureLatestAppPackageIsInstalledOnDevice ( device , preparedPlatforms , rebuiltInformation , projectData , deviceDescriptor , latestAppPackageInstalledSettings , allModifiedFiles ) ;
312
+ await this . ensureLatestAppPackageIsInstalledOnDevice ( {
313
+ device,
314
+ preparedPlatforms,
315
+ rebuiltInformation,
316
+ projectData,
317
+ deviceBuildInfoDescriptor,
318
+ settings : latestAppPackageInstalledSettings ,
319
+ modifiedFiles : allModifiedFiles
320
+ } ) ;
311
321
312
322
const service = this . getLiveSyncService ( device . deviceInfo . platform ) ;
313
323
const settings : ILiveSyncWatchInfo = {
0 commit comments