2
2
"use strict" ;
3
3
4
4
import androidLiveSyncServiceLib = require( "../common/mobile/android/android-livesync-service" ) ;
5
- import usbLivesyncServiceBaseLib = require( "../common/services/usb-livesync-service-base " ) ;
5
+ import constants = require( "../constants " ) ;
6
6
import helpers = require( "../common/helpers" ) ;
7
+ import usbLivesyncServiceBaseLib = require( "../common/services/usb-livesync-service-base" ) ;
7
8
import path = require( "path" ) ;
8
9
9
10
export class UsbLiveSyncService extends usbLivesyncServiceBaseLib . UsbLiveSyncServiceBase implements IUsbLiveSyncService {
@@ -22,20 +23,39 @@ export class UsbLiveSyncService extends usbLivesyncServiceBaseLib.UsbLiveSyncSer
22
23
$deviceAppDataFactory : Mobile . IDeviceAppDataFactory ,
23
24
$logger : ILogger ,
24
25
private $injector : IInjector ,
26
+ private $platformService : IPlatformService ,
25
27
$dispatcher : IFutureDispatcher ) {
26
28
super ( $devicesServices , $mobileHelper , $localToDevicePathDataFactory , $logger , $options , $deviceAppDataFactory , $fs , $dispatcher ) ;
27
29
}
28
30
29
31
public liveSync ( platform : string ) : IFuture < void > {
30
32
return ( ( ) => {
31
- this . $options . justlaunch = true ;
33
+ platform = this . initialize ( platform ) . wait ( ) ;
34
+ this . $platformService . preparePlatform ( platform ) . wait ( ) ;
35
+
36
+ let platformData = this . $platformsData . getPlatformData ( platform . toLowerCase ( ) ) ;
37
+ let projectFilesPath = path . join ( platformData . appDestinationDirectoryPath , constants . APP_FOLDER_NAME ) ;
32
38
33
39
let restartAppOnDeviceAction = ( device : Mobile . IDevice , deviceAppData : Mobile . IDeviceAppData , localToDevicePaths ?: Mobile . ILocalToDevicePathData [ ] ) : IFuture < void > => {
34
40
let platformSpecificUsbLiveSyncService = this . resolveUsbLiveSyncService ( platform || this . $devicesServices . platform , device ) ;
35
41
return platformSpecificUsbLiveSyncService . restartApplication ( deviceAppData , localToDevicePaths ) ;
36
42
}
37
43
38
- this . sync ( platform , this . $projectData . projectId , this . $projectData . projectDir , path . join ( this . $projectData . projectDir , "app" ) , this . excludedProjectDirsAndFiles , restartAppOnDeviceAction ) . wait ( ) ;
44
+ let notInstalledAppOnDeviceAction = ( device : Mobile . IDevice ) : IFuture < void > => {
45
+ return this . $platformService . deployOnDevice ( platform ) ;
46
+ }
47
+
48
+ let beforeBatchLiveSyncAction = ( filePath : string ) : IFuture < void > => {
49
+ return ( ( ) => {
50
+ if ( filePath . indexOf ( "node_modules" ) !== - 1 ) {
51
+ this . $platformService . preparePlatform ( platform ) . wait ( ) ;
52
+ }
53
+ } ) . future < void > ( ) ( ) ;
54
+ }
55
+
56
+ let watchGlob = this . $projectData . projectDir + "/**/*" ; //TODO: add node_modules folder
57
+
58
+ this . sync ( platform , this . $projectData . projectId , platformData . appDestinationDirectoryPath , projectFilesPath , this . excludedProjectDirsAndFiles , watchGlob , restartAppOnDeviceAction , notInstalledAppOnDeviceAction , beforeBatchLiveSyncAction ) . wait ( ) ;
39
59
} ) . future < void > ( ) ( ) ;
40
60
}
41
61
@@ -81,19 +101,17 @@ export class AndroidUsbLiveSyncService extends androidLiveSyncServiceLib.Android
81
101
let commands = [ this . liveSyncCommands . SyncFilesCommand ( ) ] ;
82
102
this . livesync ( deviceAppData . appIdentifier , deviceAppData . deviceProjectRootPath , commands ) . wait ( ) ;
83
103
} else {
84
- // TODO: Introduce this.$mobileHelper.correctDevicePath(path: string) { return helpers.stringReplaceAll(path), '\\', '/') }
85
- // Then later on this.$mobileHelper.buildDevicePath should call `correctDevicePath` before returning the output
86
104
this . device . adb . executeShellCommand ( `chmod 0777 ${ this . $mobileHelper . buildDevicePath ( deviceAppData . deviceProjectRootPath , "app" ) } ` ) . wait ( ) ;
87
105
88
106
let commands : string [ ] = [ ] ;
89
107
90
108
let devicePathRoot = `/data/data/${ deviceAppData . appIdentifier } /files` ;
91
109
_ . each ( localToDevicePaths , localToDevicePath => {
92
- let devicePath = helpers . stringReplaceAll ( path . join ( devicePathRoot , localToDevicePath . getRelativeToProjectBasePath ( ) ) , '\\' , '/' ) ;
93
- //commands.push(`ls "${path.dirname(devicePath)}" >/dev/null 2>/dev/null || mkdir "${path.dirname(devicePath)}"`);
110
+ let devicePath = this . $mobileHelper . correctDevicePath ( path . join ( devicePathRoot , localToDevicePath . getRelativeToProjectBasePath ( ) ) ) ;
94
111
commands . push ( `mv "${ localToDevicePath . getDevicePath ( ) } " "${ devicePath } "` ) ;
95
112
} ) ;
96
-
113
+
114
+ commands . push ( `rm -rf ${ this . $mobileHelper . buildDevicePath ( devicePathRoot , "code_cache" , "secondary_dexes" , "proxyThumb" ) } ` ) ;
97
115
commands . push ( "exit" ) ;
98
116
99
117
let commandsFileDevicePath = this . $mobileHelper . buildDevicePath ( deviceAppData . deviceProjectRootPath , AndroidUsbLiveSyncService . LIVESYNC_COMMANDS_FILE_NAME ) ;
0 commit comments