11import * as path from "path" ;
22import { StringCommandParameter } from "../common/command-params" ;
3+ import { BuildPlatformService } from "../services/platform/build-platform-service" ;
4+ import { WorkflowDataService } from "../services/workflow/workflow-data-service" ;
5+ import { MainController } from "../controllers/main-controller" ;
36
47export class PublishIOS implements ICommand {
58 public allowedParameters : ICommandParameter [ ] = [ new StringCommandParameter ( this . $injector ) , new StringCommandParameter ( this . $injector ) ,
@@ -13,29 +16,20 @@ export class PublishIOS implements ICommand {
1316 private $options : IOptions ,
1417 private $prompter : IPrompter ,
1518 private $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
19+ private $mainController : MainController ,
1620 private $platformValidationService : IPlatformValidationService ,
17- // private $buildPlatformService: BuildPlatformService,
18- // private $xcodebuildService: IXcodebuildService
19- ) {
21+ private $buildPlatformService : BuildPlatformService ,
22+ private $workflowDataService : WorkflowDataService
23+ ) {
2024 this . $projectData . initializeProjectData ( ) ;
2125 }
2226
23- // private get $platformsData(): IPlatformsData {
24- // return this.$injector.resolve("platformsData");
25- // }
26-
27- // This property was introduced due to the fact that the $platformService dependency
28- // ultimately tries to resolve the current project's dir and fails if not executed from within a project
29- // private get $platformService(): IPlatformService {
30- // return this.$injector.resolve("platformService");
31- // }
32-
3327 public async execute ( args : string [ ] ) : Promise < void > {
3428 let username = args [ 0 ] ;
3529 let password = args [ 1 ] ;
3630 const mobileProvisionIdentifier = args [ 2 ] ;
3731 const codeSignIdentity = args [ 3 ] ;
38- const ipaFilePath = this . $options . ipa ? path . resolve ( this . $options . ipa ) : null ;
32+ let ipaFilePath = this . $options . ipa ? path . resolve ( this . $options . ipa ) : null ;
3933
4034 if ( ! username ) {
4135 username = await this . $prompter . getString ( "Apple ID" , { allowEmpty : false } ) ;
@@ -54,47 +48,24 @@ export class PublishIOS implements ICommand {
5448 }
5549
5650 this . $options . release = true ;
51+ const platform = this . $devicePlatformsConstants . iOS . toLowerCase ( ) ;
5752
5853 if ( ! ipaFilePath ) {
59- // const platform = this.$devicePlatformsConstants.iOS;
6054 // No .ipa path provided, build .ipa on out own.
61- // const platformWorkflowData = {
62- // release: this.$options.release,
63- // useHotModuleReload: false,
64- // env: this.$options.env,
65- // platformParam: platform,
66- // signingOptions: {
67- // teamId: this.$options.teamId,
68- // provision: this.$options.provision
69- // }
70- // };
71- // const buildConfig: IBuildConfig = {
72- // projectDir: this.$options.path,
73- // release: this.$options.release,
74- // device: this.$options.device,
75- // provision: this.$options.provision,
76- // teamId: this.$options.teamId,
77- // buildForDevice: true,
78- // iCloudContainerEnvironment: this.$options.iCloudContainerEnvironment,
79- // mobileProvisionIdentifier,
80- // codeSignIdentity
81- // };
82-
83- // const platformData = this.$platformsData.getPlatformData(platform, this.$projectData);
84-
85- // if (mobileProvisionIdentifier || codeSignIdentity) {
86- // this.$logger.info("Building .ipa with the selected mobile provision and/or certificate.");
87- // // This is not very correct as if we build multiple targets we will try to sign all of them using the signing identity here.
88- // await this.$platformService.preparePlatform(platformData, this.$projectData, platformWorkflowData);
89- // await this.$platformBuildService.buildPlatform(platformData, this.$projectData, buildConfig);
90- // ipaFilePath = this.$platformService.lastOutputPath(platform, buildConfig, this.$projectData);
91- // } else {
92- // this.$logger.info("No .ipa, mobile provision or certificate set. Perfect! Now we'll build .xcarchive and let Xcode pick the distribution certificate and provisioning profile for you when exporting .ipa for AppStore submission.");
93- // await this.$platformService.preparePlatform(platformData, this.$projectData, platformWorkflowData);
94-
95- // ipaFilePath = await this.$xcodebuildService.buildForAppStore(platformData, this.$projectData, buildConfig);
96- // this.$logger.info(`Export at: ${ipaFilePath}`);
97- // }
55+ if ( mobileProvisionIdentifier || codeSignIdentity ) {
56+ // This is not very correct as if we build multiple targets we will try to sign all of them using the signing identity here.
57+ this . $logger . info ( "Building .ipa with the selected mobile provision and/or certificate." ) ;
58+
59+ // As we need to build the package for device
60+ this . $options . forDevice = true ;
61+
62+ const { nativePlatformData, buildPlatformData } = this . $workflowDataService . createWorkflowData ( platform , this . $projectData . projectDir , this . $options ) ;
63+ ipaFilePath = await this . $buildPlatformService . buildPlatform ( nativePlatformData , this . $projectData , buildPlatformData ) ;
64+ } else {
65+ this . $logger . info ( "No .ipa, mobile provision or certificate set. Perfect! Now we'll build .xcarchive and let Xcode pick the distribution certificate and provisioning profile for you when exporting .ipa for AppStore submission." ) ;
66+ ipaFilePath = await this . $mainController . buildPlatform ( platform , this . $projectData . projectDir , { ...this . $options , buildForAppStore : true } )
67+ this . $logger . info ( `Export at: ${ ipaFilePath } ` ) ;
68+ }
9869 }
9970
10071 await this . $itmsTransporterService . upload ( {
0 commit comments