1
1
import { EOL } from "os" ;
2
- import { LiveSyncService } from "../services/livesync/livesync-service" ;
3
- export class DebugLiveSyncService extends LiveSyncService {
4
2
5
- constructor ( protected $platformService : IPlatformService ,
6
- $projectDataService : IProjectDataService ,
7
- protected $devicesService : Mobile . IDevicesService ,
8
- $mobileHelper : Mobile . IMobileHelper ,
9
- $nodeModulesDependenciesBuilder : INodeModulesDependenciesBuilder ,
10
- protected $logger : ILogger ,
11
- $processService : IProcessService ,
12
- $hooksService : IHooksService ,
13
- $projectChangesService : IProjectChangesService ,
14
- protected $injector : IInjector ,
15
- private $options : IOptions ,
16
- private $debugDataService : IDebugDataService ,
17
- private $projectData : IProjectData ,
18
- private debugService : IPlatformDebugService ,
19
- private $config : IConfiguration ) {
20
-
21
- super ( $platformService ,
22
- $projectDataService ,
23
- $devicesService ,
24
- $mobileHelper ,
25
- $nodeModulesDependenciesBuilder ,
26
- $logger ,
27
- $processService ,
28
- $hooksService ,
29
- $projectChangesService ,
30
- $injector ) ;
31
- }
32
-
33
- protected async refreshApplication ( projectData : IProjectData , liveSyncResultInfo : ILiveSyncResultInfo ) : Promise < void > {
34
- const debugOptions = this . $options ;
35
- const deployOptions : IDeployPlatformOptions = {
36
- clean : this . $options . clean ,
37
- device : this . $options . device ,
38
- emulator : this . $options . emulator ,
39
- platformTemplate : this . $options . platformTemplate ,
40
- projectDir : this . $options . path ,
41
- release : this . $options . release ,
42
- provision : this . $options . provision ,
43
- teamId : this . $options . teamId
44
- } ;
45
-
46
- let debugData = this . $debugDataService . createDebugData ( this . $projectData , this . $options ) ;
47
-
48
- await this . $platformService . trackProjectType ( this . $projectData ) ;
49
-
50
- if ( this . $options . start ) {
51
- return this . printDebugInformation ( await this . debugService . debug < string [ ] > ( debugData , debugOptions ) ) ;
52
- }
53
-
54
- const deviceAppData = liveSyncResultInfo . deviceAppData ;
55
- this . $config . debugLivesync = true ;
56
-
57
- await this . debugService . debugStop ( ) ;
58
-
59
- let applicationId = deviceAppData . appIdentifier ;
60
- await deviceAppData . device . applicationManager . stopApplication ( applicationId , projectData . projectName ) ;
61
-
62
- const buildConfig : IBuildConfig = _ . merge ( { buildForDevice : ! deviceAppData . device . isEmulator } , deployOptions ) ;
63
- debugData . pathToAppPackage = this . $platformService . lastOutputPath ( this . debugService . platform , buildConfig , projectData ) ;
64
-
65
- this . printDebugInformation ( await this . debugService . debug < string [ ] > ( debugData , debugOptions ) ) ;
66
- }
67
-
68
- protected printDebugInformation ( information : string [ ] ) : void {
69
- _ . each ( information , i => {
70
- this . $logger . info ( `To start debugging, open the following URL in Chrome:${ EOL } ${ i } ${ EOL } ` . cyan ) ;
71
- } ) ;
72
- }
73
- }
74
3
export abstract class DebugPlatformCommand implements ICommand {
75
4
public allowedParameters : ICommandParameter [ ] = [ ] ;
76
5
public platform : string ;
77
6
78
7
constructor ( private debugService : IPlatformDebugService ,
79
8
private $devicesService : Mobile . IDevicesService ,
80
- private $injector : IInjector ,
81
9
private $debugDataService : IDebugDataService ,
82
10
protected $platformService : IPlatformService ,
83
11
protected $projectData : IProjectData ,
84
12
protected $options : IOptions ,
85
13
protected $platformsData : IPlatformsData ,
86
- protected $logger : ILogger ) {
14
+ protected $logger : ILogger ,
15
+ private $debugLiveSyncService : ILiveSyncService ,
16
+ private $config : IConfiguration ) {
87
17
this . $projectData . initializeProjectData ( ) ;
88
18
}
89
19
90
20
public async execute ( args : string [ ] ) : Promise < void > {
91
21
const debugOptions = this . $options ;
92
- // const deployOptions: IDeployPlatformOptions = {
93
- // clean: this.$options.clean,
94
- // device: this.$options.device,
95
- // emulator: this.$options.emulator,
96
- // platformTemplate: this.$options.platformTemplate,
97
- // projectDir: this.$options.path,
98
- // release: this.$options.release,
99
- // provision: this.$options.provision,
100
- // teamId: this.$options.teamId
101
- // };
102
22
103
23
let debugData = this . $debugDataService . createDebugData ( this . $projectData , this . $options ) ;
104
24
@@ -108,23 +28,7 @@ export abstract class DebugPlatformCommand implements ICommand {
108
28
return this . printDebugInformation ( await this . debugService . debug < string [ ] > ( debugData , debugOptions ) ) ;
109
29
}
110
30
111
- // const appFilesUpdaterOptions: IAppFilesUpdaterOptions = { bundle: this.$options.bundle, release: this.$options.release };
112
-
113
- // await this.$platformService.deployPlatform(this.$devicesService.platform, appFilesUpdaterOptions, deployOptions, this.$projectData, this.$options);
114
- // this.$config.debugLivesync = true;
115
- // let applicationReloadAction = async (deviceAppData: Mobile.IDeviceAppData): Promise<void> => {
116
- // let projectData: IProjectData = this.$injector.resolve("projectData");
117
-
118
- // await this.debugService.debugStop();
119
-
120
- // let applicationId = deviceAppData.appIdentifier;
121
- // await deviceAppData.device.applicationManager.stopApplication(applicationId, projectData.projectName);
122
-
123
- // const buildConfig: IBuildConfig = _.merge({ buildForDevice: !deviceAppData.device.isEmulator }, deployOptions);
124
- // debugData.pathToAppPackage = this.$platformService.lastOutputPath(this.debugService.platform, buildConfig, projectData);
125
-
126
- // this.printDebugInformation(await this.debugService.debug<string[]>(debugData, debugOptions));
127
- // };
31
+ this . $config . debugLivesync = true ;
128
32
129
33
// TODO: Fix this call
130
34
await this . $devicesService . initialize ( { deviceId : this . $options . device , platform : this . platform , skipDeviceDetectionInterval : true , skipInferPlatform : true } ) ;
@@ -153,10 +57,9 @@ export abstract class DebugPlatformCommand implements ICommand {
153
57
154
58
await this . $platformService . buildPlatform ( d . deviceInfo . platform , buildConfig , this . $projectData ) ;
155
59
const pathToBuildResult = await this . $platformService . lastOutputPath ( d . deviceInfo . platform , buildConfig , this . $projectData ) ;
156
- console . log ( "3##### return path to buildResult = " , pathToBuildResult ) ;
157
60
return pathToBuildResult ;
158
61
}
159
- }
62
+ } ;
160
63
161
64
return info ;
162
65
} ) ;
@@ -167,8 +70,7 @@ export abstract class DebugPlatformCommand implements ICommand {
167
70
watchAllFiles : this . $options . syncAllFiles
168
71
} ;
169
72
170
- const debugLiveSyncService = this . $injector . resolve < ILiveSyncService > ( DebugLiveSyncService , { debugService : this . debugService } ) ;
171
- await debugLiveSyncService . liveSync ( deviceDescriptors , liveSyncInfo ) ;
73
+ await this . $debugLiveSyncService . liveSync ( deviceDescriptors , liveSyncInfo ) ;
172
74
}
173
75
174
76
public async canExecute ( args : string [ ] ) : Promise < boolean > {
@@ -201,16 +103,15 @@ export class DebugIOSCommand extends DebugPlatformCommand {
201
103
$logger : ILogger ,
202
104
$iOSDebugService : IPlatformDebugService ,
203
105
$devicesService : Mobile . IDevicesService ,
204
- $injector : IInjector ,
205
106
$config : IConfiguration ,
206
- $liveSyncService : ILiveSyncService ,
207
107
$debugDataService : IDebugDataService ,
208
108
$platformService : IPlatformService ,
209
109
$options : IOptions ,
210
110
$projectData : IProjectData ,
211
111
$platformsData : IPlatformsData ,
212
- $iosDeviceOperations : IIOSDeviceOperations ) {
213
- super ( $iOSDebugService , $devicesService , $injector , $debugDataService , $platformService , $projectData , $options , $platformsData , $logger ) ;
112
+ $iosDeviceOperations : IIOSDeviceOperations ,
113
+ $debugLiveSyncService : ILiveSyncService ) {
114
+ super ( $iOSDebugService , $devicesService , $debugDataService , $platformService , $projectData , $options , $platformsData , $logger , $debugLiveSyncService , $config ) ;
214
115
// Do not dispose ios-device-lib, so the process will remain alive and the debug application (NativeScript Inspector or Chrome DevTools) will be able to connect to the socket.
215
116
// In case we dispose ios-device-lib, the socket will be closed and the code will fail when the debug application tries to read/send data to device socket.
216
117
// That's why the `$ tns debug ios --justlaunch` command will not release the terminal.
@@ -243,15 +144,14 @@ export class DebugAndroidCommand extends DebugPlatformCommand {
243
144
$logger : ILogger ,
244
145
$androidDebugService : IPlatformDebugService ,
245
146
$devicesService : Mobile . IDevicesService ,
246
- $injector : IInjector ,
247
147
$config : IConfiguration ,
248
- $liveSyncService : ILiveSyncService ,
249
148
$debugDataService : IDebugDataService ,
250
149
$platformService : IPlatformService ,
251
150
$options : IOptions ,
252
151
$projectData : IProjectData ,
253
- $platformsData : IPlatformsData ) {
254
- super ( $androidDebugService , $devicesService , $injector , $debugDataService , $platformService , $projectData , $options , $platformsData , $logger ) ;
152
+ $platformsData : IPlatformsData ,
153
+ $debugLiveSyncService : ILiveSyncService ) {
154
+ super ( $androidDebugService , $devicesService , $debugDataService , $platformService , $projectData , $options , $platformsData , $logger , $debugLiveSyncService , $config ) ;
255
155
}
256
156
257
157
public async canExecute ( args : string [ ] ) : Promise < boolean > {
0 commit comments