1
+ import { ERROR_NO_VALID_SUBCOMMAND_FORMAT } from "../common/constants" ;
2
+
1
3
export class RunCommandBase implements ICommand {
2
4
protected platform : string ;
3
5
@@ -7,19 +9,24 @@ export class RunCommandBase implements ICommand {
7
9
protected $options : IOptions ,
8
10
protected $emulatorPlatformService : IEmulatorPlatformService ,
9
11
protected $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
12
+ protected $errors : IErrors ,
10
13
private $devicesService : Mobile . IDevicesService ,
11
14
private $hostInfo : IHostInfo ,
12
15
private $iosDeviceOperations : IIOSDeviceOperations ,
13
16
private $mobileHelper : Mobile . IMobileHelper ) {
14
- this . $projectData . initializeProjectData ( ) ;
15
17
}
16
18
17
- public allowedParameters : ICommandParameter [ ] = [ ] ;
19
+ public allowedParameters : ICommandParameter [ ] = [ ] ;
18
20
public async execute ( args : string [ ] ) : Promise < void > {
19
21
return this . executeCore ( args ) ;
20
22
}
21
23
22
24
public async canExecute ( args : string [ ] ) : Promise < boolean > {
25
+ if ( args . length ) {
26
+ this . $errors . fail ( ERROR_NO_VALID_SUBCOMMAND_FORMAT , "run" ) ;
27
+ }
28
+
29
+ this . $projectData . initializeProjectData ( ) ;
23
30
if ( ! this . platform && ! this . $hostInfo . isDarwin ) {
24
31
this . platform = this . $devicePlatformsConstants . Android ;
25
32
}
@@ -43,7 +50,7 @@ export class RunCommandBase implements ICommand {
43
50
identifier : d . deviceInfo . identifier ,
44
51
buildAction : async ( ) : Promise < string > => {
45
52
const buildConfig : IBuildConfig = {
46
- buildForDevice : ! d . isEmulator , // this.$options.forDevice,
53
+ buildForDevice : ! d . isEmulator ,
47
54
projectDir : this . $options . path ,
48
55
clean : this . $options . clean ,
49
56
teamId : this . $options . teamId ,
@@ -65,25 +72,26 @@ export class RunCommandBase implements ICommand {
65
72
return info ;
66
73
} ) ;
67
74
68
- // if (this.$options.release) {
69
- // const deployOpts: IRunPlatformOptions = {
70
- // device: this.$options.device,
71
- // emulator: this.$options.emulator,
72
- // justlaunch: this.$options.justlaunch,
73
- // };
74
-
75
- // await this.$platformService.startApplication(args[0], deployOpts, this.$projectData.projectId);
76
- // return this.$platformService.trackProjectType(this.$projectData);
77
- // }
78
-
79
75
if ( ( ! this . platform || this . $mobileHelper . isiOSPlatform ( this . platform ) ) && ( this . $options . watch || ! this . $options . justlaunch ) ) {
80
76
this . $iosDeviceOperations . setShouldDispose ( false ) ;
81
77
}
82
78
79
+ if ( this . $options . release ) {
80
+ const deployOpts : IRunPlatformOptions = {
81
+ device : this . $options . device ,
82
+ emulator : this . $options . emulator ,
83
+ justlaunch : this . $options . justlaunch ,
84
+ } ;
85
+
86
+ await this . $platformService . startApplication ( args [ 0 ] , deployOpts , this . $projectData . projectId ) ;
87
+ return this . $platformService . trackProjectType ( this . $projectData ) ;
88
+ }
89
+
83
90
const liveSyncInfo : ILiveSyncInfo = { projectDir : this . $projectData . projectDir , skipWatcher : ! this . $options . watch , watchAllFiles : this . $options . syncAllFiles } ;
84
91
await this . $liveSyncService . liveSync ( deviceDescriptors , liveSyncInfo ) ;
85
92
}
86
93
}
94
+
87
95
$injector . registerCommand ( "run|*all" , RunCommandBase ) ;
88
96
89
97
export class RunIosCommand extends RunCommandBase implements ICommand {
@@ -95,7 +103,7 @@ export class RunIosCommand extends RunCommandBase implements ICommand {
95
103
constructor ( $platformService : IPlatformService ,
96
104
private $platformsData : IPlatformsData ,
97
105
protected $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
98
- private $errors : IErrors ,
106
+ protected $errors : IErrors ,
99
107
$liveSyncService : ILiveSyncService ,
100
108
$projectData : IProjectData ,
101
109
$options : IOptions ,
@@ -104,7 +112,7 @@ export class RunIosCommand extends RunCommandBase implements ICommand {
104
112
$hostInfo : IHostInfo ,
105
113
$iosDeviceOperations : IIOSDeviceOperations ,
106
114
$mobileHelper : Mobile . IMobileHelper ) {
107
- super ( $platformService , $liveSyncService , $projectData , $options , $emulatorPlatformService , $devicePlatformsConstants , $devicesService , $hostInfo , $iosDeviceOperations , $mobileHelper ) ;
115
+ super ( $platformService , $liveSyncService , $projectData , $options , $emulatorPlatformService , $devicePlatformsConstants , $errors , $ devicesService, $hostInfo , $iosDeviceOperations , $mobileHelper ) ;
108
116
}
109
117
110
118
public async execute ( args : string [ ] ) : Promise < void > {
@@ -131,7 +139,7 @@ export class RunAndroidCommand extends RunCommandBase implements ICommand {
131
139
constructor ( $platformService : IPlatformService ,
132
140
private $platformsData : IPlatformsData ,
133
141
protected $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
134
- private $errors : IErrors ,
142
+ protected $errors : IErrors ,
135
143
$liveSyncService : ILiveSyncService ,
136
144
$projectData : IProjectData ,
137
145
$options : IOptions ,
@@ -140,7 +148,7 @@ export class RunAndroidCommand extends RunCommandBase implements ICommand {
140
148
$hostInfo : IHostInfo ,
141
149
$iosDeviceOperations : IIOSDeviceOperations ,
142
150
$mobileHelper : Mobile . IMobileHelper ) {
143
- super ( $platformService , $liveSyncService , $projectData , $options , $emulatorPlatformService , $devicePlatformsConstants , $devicesService , $hostInfo , $iosDeviceOperations , $mobileHelper ) ;
151
+ super ( $platformService , $liveSyncService , $projectData , $options , $emulatorPlatformService , $devicePlatformsConstants , $errors , $ devicesService, $hostInfo , $iosDeviceOperations , $mobileHelper ) ;
144
152
}
145
153
146
154
public async execute ( args : string [ ] ) : Promise < void > {
0 commit comments