1
1
import * as path from "path" ;
2
2
import { 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" ;
3
6
4
7
export class PublishIOS implements ICommand {
5
8
public allowedParameters : ICommandParameter [ ] = [ new StringCommandParameter ( this . $injector ) , new StringCommandParameter ( this . $injector ) ,
@@ -13,29 +16,20 @@ export class PublishIOS implements ICommand {
13
16
private $options : IOptions ,
14
17
private $prompter : IPrompter ,
15
18
private $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
19
+ private $mainController : MainController ,
16
20
private $platformValidationService : IPlatformValidationService ,
17
- // private $buildPlatformService: BuildPlatformService,
18
- // private $xcodebuildService: IXcodebuildService
19
- ) {
21
+ private $buildPlatformService : BuildPlatformService ,
22
+ private $workflowDataService : WorkflowDataService
23
+ ) {
20
24
this . $projectData . initializeProjectData ( ) ;
21
25
}
22
26
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
-
33
27
public async execute ( args : string [ ] ) : Promise < void > {
34
28
let username = args [ 0 ] ;
35
29
let password = args [ 1 ] ;
36
30
const mobileProvisionIdentifier = args [ 2 ] ;
37
31
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 ;
39
33
40
34
if ( ! username ) {
41
35
username = await this . $prompter . getString ( "Apple ID" , { allowEmpty : false } ) ;
@@ -54,47 +48,24 @@ export class PublishIOS implements ICommand {
54
48
}
55
49
56
50
this . $options . release = true ;
51
+ const platform = this . $devicePlatformsConstants . iOS . toLowerCase ( ) ;
57
52
58
53
if ( ! ipaFilePath ) {
59
- // const platform = this.$devicePlatformsConstants.iOS;
60
54
// 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
+ }
98
69
}
99
70
100
71
await this . $itmsTransporterService . upload ( {
0 commit comments