@@ -5,60 +5,31 @@ export abstract class BuildCommandBase extends ValidatePlatformCommandBase {
55 constructor ( $options : IOptions ,
66 protected $errors : IErrors ,
77 $projectData : IProjectData ,
8- $platformsData : IPlatformsData ,
8+ $platformsDataService : IPlatformsDataService ,
99 protected $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
10- $platformService : IPlatformService ,
10+ protected $buildController : IBuildController ,
11+ $platformValidationService : IPlatformValidationService ,
1112 private $bundleValidatorHelper : IBundleValidatorHelper ,
13+ private $buildDataService : IBuildDataService ,
1214 protected $logger : ILogger ) {
13- super ( $options , $platformsData , $platformService , $projectData ) ;
15+ super ( $options , $platformsDataService , $platformValidationService , $projectData ) ;
1416 this . $projectData . initializeProjectData ( ) ;
1517 }
1618
19+ public dashedOptions = {
20+ watch : { type : OptionType . Boolean , default : false , hasSensitiveValue : false } ,
21+ } ;
22+
1723 public async executeCore ( args : string [ ] ) : Promise < string > {
1824 const platform = args [ 0 ] . toLowerCase ( ) ;
19- const appFilesUpdaterOptions : IAppFilesUpdaterOptions = {
20- bundle : ! ! this . $options . bundle ,
21- release : this . $options . release ,
22- useHotModuleReload : this . $options . hmr
23- } ;
24- const platformInfo : IPreparePlatformInfo = {
25- platform,
26- appFilesUpdaterOptions,
27- projectData : this . $projectData ,
28- config : this . $options ,
29- env : this . $options . env
30- } ;
31-
32- await this . $platformService . preparePlatform ( platformInfo ) ;
33- const buildConfig : IBuildConfig = {
34- buildForDevice : this . $options . forDevice ,
35- iCloudContainerEnvironment : this . $options . iCloudContainerEnvironment ,
36- projectDir : this . $options . path ,
37- clean : this . $options . clean ,
38- teamId : this . $options . teamId ,
39- device : this . $options . device ,
40- provision : this . $options . provision ,
41- release : this . $options . release ,
42- keyStoreAlias : this . $options . keyStoreAlias ,
43- keyStorePath : this . $options . keyStorePath ,
44- keyStoreAliasPassword : this . $options . keyStoreAliasPassword ,
45- keyStorePassword : this . $options . keyStorePassword ,
46- androidBundle : this . $options . aab
47- } ;
48-
49- const outputPath = await this . $platformService . buildPlatform ( platform , buildConfig , this . $projectData ) ;
50-
51- if ( this . $options . copyTo ) {
52- this . $platformService . copyLastOutput ( platform , this . $options . copyTo , buildConfig , this . $projectData ) ;
53- } else {
54- this . $logger . info ( `The build result is located at: ${ outputPath } ` ) ;
55- }
25+ const buildData = this . $buildDataService . getBuildData ( this . $projectData . projectDir , platform , this . $options ) ;
26+ const outputPath = await this . $buildController . prepareAndBuild ( buildData ) ;
5627
5728 return outputPath ;
5829 }
5930
6031 protected validatePlatform ( platform : string ) : void {
61- if ( ! this . $platformService . isPlatformSupportedForOS ( platform , this . $projectData ) ) {
32+ if ( ! this . $platformValidationService . isPlatformSupportedForOS ( platform , this . $projectData ) ) {
6233 this . $errors . fail ( `Applications for platform ${ platform } can not be built on this OS` ) ;
6334 }
6435
@@ -78,7 +49,7 @@ export abstract class BuildCommandBase extends ValidatePlatformCommandBase {
7849 return false ;
7950 }
8051
81- const result = await this . $platformService . validateOptions ( this . $options . provision , this . $options . teamId , this . $projectData , platform ) ;
52+ const result = await this . $platformValidationService . validateOptions ( this . $options . provision , this . $options . teamId , this . $projectData , platform ) ;
8253 return result ;
8354 }
8455}
@@ -89,16 +60,18 @@ export class BuildIosCommand extends BuildCommandBase implements ICommand {
8960 constructor ( protected $options : IOptions ,
9061 $errors : IErrors ,
9162 $projectData : IProjectData ,
92- $platformsData : IPlatformsData ,
63+ $platformsDataService : IPlatformsDataService ,
9364 $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
94- $platformService : IPlatformService ,
65+ $buildController : IBuildController ,
66+ $platformValidationService : IPlatformValidationService ,
9567 $bundleValidatorHelper : IBundleValidatorHelper ,
96- $logger : ILogger ) {
97- super ( $options , $errors , $projectData , $platformsData , $devicePlatformsConstants , $platformService , $bundleValidatorHelper , $logger ) ;
68+ $logger : ILogger ,
69+ $buildDataService : IBuildDataService ) {
70+ super ( $options , $errors , $projectData , $platformsDataService , $devicePlatformsConstants , $buildController , $platformValidationService , $bundleValidatorHelper , $buildDataService , $logger ) ;
9871 }
9972
10073 public async execute ( args : string [ ] ) : Promise < void > {
101- await this . executeCore ( [ this . $platformsData . availablePlatforms . iOS ] ) ;
74+ await this . executeCore ( [ this . $devicePlatformsConstants . iOS . toLowerCase ( ) ] ) ;
10275 }
10376
10477 public async canExecute ( args : string [ ] ) : Promise < boolean | ICanExecuteCommandOutput > {
@@ -123,17 +96,19 @@ export class BuildAndroidCommand extends BuildCommandBase implements ICommand {
12396 constructor ( protected $options : IOptions ,
12497 protected $errors : IErrors ,
12598 $projectData : IProjectData ,
126- $platformsData : IPlatformsData ,
99+ platformsDataService : IPlatformsDataService ,
127100 $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
128- $platformService : IPlatformService ,
101+ $buildController : IBuildController ,
102+ $platformValidationService : IPlatformValidationService ,
129103 $bundleValidatorHelper : IBundleValidatorHelper ,
130104 protected $androidBundleValidatorHelper : IAndroidBundleValidatorHelper ,
105+ $buildDataService : IBuildDataService ,
131106 protected $logger : ILogger ) {
132- super ( $options , $errors , $projectData , $platformsData , $devicePlatformsConstants , $platformService , $bundleValidatorHelper , $logger ) ;
107+ super ( $options , $errors , $projectData , platformsDataService , $devicePlatformsConstants , $buildController , $platformValidationService , $ bundleValidatorHelper, $buildDataService , $logger ) ;
133108 }
134109
135110 public async execute ( args : string [ ] ) : Promise < void > {
136- await this . executeCore ( [ this . $platformsData . availablePlatforms . Android ] ) ;
111+ await this . executeCore ( [ this . $devicePlatformsConstants . Android . toLowerCase ( ) ] ) ;
137112
138113 if ( this . $options . aab ) {
139114 this . $logger . info ( AndroidAppBundleMessages . ANDROID_APP_BUNDLE_DOCS_MESSAGE ) ;
0 commit comments