1- export class DebugPlatformCommand implements ICommand {
1+ import { EOL } from "os" ;
2+
3+ export abstract class DebugPlatformCommand implements ICommand {
24 public allowedParameters : ICommandParameter [ ] = [ ] ;
35
4- constructor ( private debugService : IDebugService ,
6+ constructor ( private debugService : IPlatformDebugService ,
57 private $devicesService : Mobile . IDevicesService ,
68 private $injector : IInjector ,
79 private $logger : ILogger ,
810 private $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
911 private $config : IConfiguration ,
1012 private $usbLiveSyncService : ILiveSyncService ,
13+ private $debugDataService : IDebugDataService ,
1114 protected $platformService : IPlatformService ,
1215 protected $projectData : IProjectData ,
1316 protected $options : IOptions ,
1417 protected $platformsData : IPlatformsData ) {
15- this . $projectData . initializeProjectData ( ) ;
16- }
18+ this . $projectData . initializeProjectData ( ) ;
19+ }
1720
1821 public async execute ( args : string [ ] ) : Promise < void > {
22+ const debugOptions = this . $options ;
1923 const deployOptions : IDeployPlatformOptions = {
2024 clean : this . $options . clean ,
2125 device : this . $options . device ,
2933
3034 const buildConfig : IBuildConfig = _ . merge ( { buildForDevice : this . $options . forDevice } , deployOptions ) ;
3135
36+ const debugData = this . $debugDataService . createDebugData ( this . debugService , this . $options , buildConfig ) ;
37+
38+ await this . $platformService . trackProjectType ( this . $projectData ) ;
39+
3240 if ( this . $options . start ) {
33- return this . debugService . debug ( this . $projectData , buildConfig ) ;
41+ return this . printDebugInformation ( await this . debugService . debug ( debugData , debugOptions ) ) ;
3442 }
3543
3644 const appFilesUpdaterOptions : IAppFilesUpdaterOptions = { bundle : this . $options . bundle , release : this . $options . release } ;
4957
5058 await deviceAppData . device . applicationManager . stopApplication ( applicationId ) ;
5159
52- await this . debugService . debug ( this . $projectData , buildConfig ) ;
60+ this . printDebugInformation ( await this . debugService . debug ( debugData , debugOptions ) ) ;
5361 } ;
62+
5463 return this . $usbLiveSyncService . liveSync ( this . $devicesService . platform , this . $projectData , applicationReloadAction ) ;
5564 }
5665
7079
7180 return true ;
7281 }
82+
83+ private printDebugInformation ( information : string [ ] ) : void {
84+ _ . each ( information , i => {
85+ this . $logger . info ( `To start debugging, open the following URL in Chrome:${ EOL } ${ i } ${ EOL } ` . cyan ) ;
86+ } ) ;
87+ }
7388}
7489
7590export class DebugIOSCommand extends DebugPlatformCommand {
76- constructor ( $iOSDebugService : IDebugService ,
91+ constructor ( $iOSDebugService : IPlatformDebugService ,
7792 $devicesService : Mobile . IDevicesService ,
7893 $injector : IInjector ,
7994 $logger : ILogger ,
8095 $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
8196 $config : IConfiguration ,
8297 $usbLiveSyncService : ILiveSyncService ,
98+ $debugDataService : IDebugDataService ,
8399 $platformService : IPlatformService ,
84100 $options : IOptions ,
85101 $projectData : IProjectData ,
86102 $platformsData : IPlatformsData ,
87103 $iosDeviceOperations : IIOSDeviceOperations ) {
88- super ( $iOSDebugService , $devicesService , $injector , $logger , $devicePlatformsConstants , $config , $usbLiveSyncService , $platformService , $projectData , $options , $platformsData ) ;
104+ super ( $iOSDebugService , $devicesService , $injector , $logger , $devicePlatformsConstants , $config , $usbLiveSyncService , $debugDataService , $ platformService, $projectData , $options , $platformsData ) ;
89105 $iosDeviceOperations . setShouldDispose ( this . $options . justlaunch ) ;
90106 }
91107
@@ -97,19 +113,19 @@ export class DebugIOSCommand extends DebugPlatformCommand {
97113$injector . registerCommand ( "debug|ios" , DebugIOSCommand ) ;
98114
99115export class DebugAndroidCommand extends DebugPlatformCommand {
100- constructor ( $androidDebugService : IDebugService ,
116+ constructor ( $androidDebugService : IPlatformDebugService ,
101117 $devicesService : Mobile . IDevicesService ,
102118 $injector : IInjector ,
103119 $logger : ILogger ,
104120 $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
105121 $config : IConfiguration ,
106122 $usbLiveSyncService : ILiveSyncService ,
123+ $debugDataService : IDebugDataService ,
107124 $platformService : IPlatformService ,
108125 $options : IOptions ,
109126 $projectData : IProjectData ,
110127 $platformsData : IPlatformsData ) {
111-
112- super ( $androidDebugService , $devicesService , $injector , $logger , $devicePlatformsConstants , $config , $usbLiveSyncService , $platformService , $projectData , $options , $platformsData ) ;
128+ super ( $androidDebugService , $devicesService , $injector , $logger , $devicePlatformsConstants , $config , $usbLiveSyncService , $debugDataService , $platformService , $projectData , $options , $platformsData ) ;
113129 }
114130
115131 public async canExecute ( args : string [ ] ) : Promise < boolean > {
0 commit comments