11import { ERROR_NO_VALID_SUBCOMMAND_FORMAT } from "../common/constants" ;
22import { ANDROID_RELEASE_BUILD_ERROR_MESSAGE } from "../constants" ;
33import { cache } from "../common/decorators" ;
4- import { BundleBase } from "./base-bundler" ;
54
6- export class RunCommandBase extends BundleBase implements ICommand {
5+ export class RunCommandBase implements ICommand {
76
87 public platform : string ;
9- constructor ( protected $platformService : IPlatformService ,
10- protected $projectData : IProjectData ,
11- protected $options : IOptions ,
12- protected $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
13- protected $errors : IErrors ,
14- protected $devicesService : Mobile . IDevicesService ,
15- protected $platformsData : IPlatformsData ,
8+ constructor ( private $projectData : IProjectData ,
9+ private $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
10+ private $errors : IErrors ,
1611 private $hostInfo : IHostInfo ,
17- private $liveSyncCommandHelper : ILiveSyncCommandHelper
18- ) {
19- super ( $projectData , $errors , $options ) ;
20- }
12+ private $liveSyncCommandHelper : ILiveSyncCommandHelper ) { }
2113
2214 public allowedParameters : ICommandParameter [ ] = [ ] ;
2315 public async execute ( args : string [ ] ) : Promise < void > {
24- return this . executeCore ( args ) ;
16+ return this . $liveSyncCommandHelper . executeCommandLiveSync ( this . platform ) ;
2517 }
2618
2719 public async canExecute ( args : string [ ] ) : Promise < boolean > {
@@ -36,32 +28,10 @@ export class RunCommandBase extends BundleBase implements ICommand {
3628 this . platform = this . $devicePlatformsConstants . Android ;
3729 }
3830
39- const availablePlatforms = this . $liveSyncCommandHelper . getPlatformsForOperation ( this . platform ) ;
40- for ( const platform of availablePlatforms ) {
41- const platformData = this . $platformsData . getPlatformData ( platform , this . $projectData ) ;
42- const platformProjectService = platformData . platformProjectService ;
43- await platformProjectService . validate ( this . $projectData ) ;
44- }
45-
46- super . validateBundling ( ) ;
31+ this . $liveSyncCommandHelper . validatePlatform ( this . platform ) ;
4732
4833 return true ;
4934 }
50-
51- public async executeCore ( args : string [ ] ) : Promise < void > {
52- await this . $devicesService . initialize ( {
53- deviceId : this . $options . device ,
54- platform : this . platform ,
55- emulator : this . $options . emulator ,
56- skipDeviceDetectionInterval : true ,
57- skipInferPlatform : ! this . platform
58- } ) ;
59-
60- await this . $devicesService . detectCurrentlyAttachedDevices ( { shouldReturnImmediateResult : false , platform : this . platform } ) ;
61- let devices = this . $devicesService . getDeviceInstances ( ) ;
62- devices = devices . filter ( d => ! this . platform || d . deviceInfo . platform . toLowerCase ( ) === this . platform . toLowerCase ( ) ) ;
63- await this . $liveSyncCommandHelper . executeLiveSyncOperation ( devices , this . platform ) ;
64- }
6535}
6636
6737$injector . registerCommand ( "run|*all" , RunCommandBase ) ;
@@ -80,9 +50,9 @@ export class RunIosCommand implements ICommand {
8050 return this . $devicePlatformsConstants . iOS ;
8151 }
8252
83- constructor ( protected $platformsData : IPlatformsData ,
84- protected $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
85- protected $errors : IErrors ,
53+ constructor ( private $platformsData : IPlatformsData ,
54+ private $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
55+ private $errors : IErrors ,
8656 private $injector : IInjector ,
8757 private $platformService : IPlatformService ,
8858 private $projectData : IProjectData ,
@@ -94,7 +64,7 @@ export class RunIosCommand implements ICommand {
9464 this . $errors . fail ( `Applications for platform ${ this . $devicePlatformsConstants . iOS } can not be built on this OS` ) ;
9565 }
9666
97- return this . runCommand . executeCore ( args ) ;
67+ return this . runCommand . execute ( args ) ;
9868 }
9969
10070 public async canExecute ( args : string [ ] ) : Promise < boolean > {
@@ -118,17 +88,17 @@ export class RunAndroidCommand implements ICommand {
11888 return this . $devicePlatformsConstants . Android ;
11989 }
12090
121- constructor ( protected $platformsData : IPlatformsData ,
122- protected $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
123- protected $errors : IErrors ,
91+ constructor ( private $platformsData : IPlatformsData ,
92+ private $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
93+ private $errors : IErrors ,
12494 private $injector : IInjector ,
12595 private $platformService : IPlatformService ,
12696 private $projectData : IProjectData ,
12797 private $options : IOptions ) {
12898 }
12999
130100 public async execute ( args : string [ ] ) : Promise < void > {
131- return this . runCommand . executeCore ( args ) ;
101+ return this . runCommand . execute ( args ) ;
132102 }
133103
134104 public async canExecute ( args : string [ ] ) : Promise < boolean > {
0 commit comments