@@ -35,23 +35,6 @@ export class ITMSTransporterService implements IITMSTransporterService {
35
35
return this . $injector . resolve ( "projectData" ) ;
36
36
}
37
37
38
- public getiOSApplication ( username : string , password : string , bundleId : string ) : IFuture < IiTunesConnectApplication > {
39
- return ( ( ) :IiTunesConnectApplication => {
40
- let iOSApplications = this . getiOSApplications ( { username, password} ) . wait ( ) ;
41
- if ( ! iOSApplications || ! iOSApplications . length ) {
42
- this . $errors . failWithoutHelp ( `Cannot find any registered applications for Apple ID ${ username } in iTunes Connect.` ) ;
43
- }
44
-
45
- let iOSApplication = _ . find ( iOSApplications , app => app . bundleId === bundleId ) ;
46
-
47
- if ( ! iOSApplication ) {
48
- this . $errors . failWithoutHelp ( `Cannot find registered applications that match the specified identifier ${ bundleId } in iTunes Connect.` ) ;
49
- }
50
-
51
- return iOSApplication ;
52
- } ) . future < IiTunesConnectApplication > ( ) ( ) ;
53
- }
54
-
55
38
public upload ( data : IITMSData ) : IFuture < void > {
56
39
return ( ( ) => {
57
40
if ( ! this . $hostInfo . isDarwin ) {
@@ -71,7 +54,9 @@ export class ITMSTransporterService implements IITMSTransporterService {
71
54
mobileProvisionIdentifier : data . mobileProvisionIdentifier ,
72
55
codeSignIdentity : data . codeSignIdentity
73
56
} ,
74
- loggingLevel = data . verboseLogging ? ITMSConstants . VerboseLoggingLevels . Verbose : ITMSConstants . VerboseLoggingLevels . Informational ;
57
+ loggingLevel = data . verboseLogging ? ITMSConstants . VerboseLoggingLevels . Verbose : ITMSConstants . VerboseLoggingLevels . Informational ,
58
+ bundleId = this . getBundleIdentifier ( data . ipaFilePath ) . wait ( ) ,
59
+ iOSApplication = this . getiOSApplication ( data . username , data . password , bundleId ) . wait ( ) ;
75
60
76
61
this . $fs . createDirectory ( innerDirectory ) . wait ( ) ;
77
62
@@ -84,7 +69,7 @@ export class ITMSTransporterService implements IITMSTransporterService {
84
69
85
70
let ipaFileHash = this . $fs . getFileShasum ( ipaFileLocation , { algorithm : "md5" } ) . wait ( ) ,
86
71
ipaFileSize = this . $fs . getFileSize ( ipaFileLocation ) . wait ( ) ,
87
- metadata = this . getITMSMetadataXml ( data . appId , ipaFileName , ipaFileHash , ipaFileSize ) ;
72
+ metadata = this . getITMSMetadataXml ( iOSApplication . adamId , ipaFileName , ipaFileHash , ipaFileSize ) ;
88
73
89
74
this . $fs . writeFile ( path . join ( innerDirectory , ITMSConstants . ApplicationMetadataFile ) , metadata ) . wait ( ) ;
90
75
@@ -119,7 +104,36 @@ export class ITMSTransporterService implements IITMSTransporterService {
119
104
} ) . future < IiTunesConnectApplication [ ] > ( ) ( ) ;
120
105
}
121
106
122
- public getBundleIdentifier ( ipaFileFullPath ?: string ) : IFuture < string > {
107
+ /**
108
+ * Gets iTunes Connect application corresponding to the given bundle identifier.
109
+ * @param {string } username For authentication with iTunes Connect.
110
+ * @param {string } password For authentication with iTunes Connect.
111
+ * @param {string } bundleId Application's Bundle Identifier
112
+ * @return {IFuture<IiTunesConnectApplication> } The iTunes Connect application.
113
+ */
114
+ private getiOSApplication ( username : string , password : string , bundleId : string ) : IFuture < IiTunesConnectApplication > {
115
+ return ( ( ) :IiTunesConnectApplication => {
116
+ let iOSApplications = this . getiOSApplications ( { username, password} ) . wait ( ) ;
117
+ if ( ! iOSApplications || ! iOSApplications . length ) {
118
+ this . $errors . failWithoutHelp ( `Cannot find any registered applications for Apple ID ${ username } in iTunes Connect.` ) ;
119
+ }
120
+
121
+ let iOSApplication = _ . find ( iOSApplications , app => app . bundleId === bundleId ) ;
122
+
123
+ if ( ! iOSApplication ) {
124
+ this . $errors . failWithoutHelp ( `Cannot find registered applications that match the specified identifier ${ bundleId } in iTunes Connect.` ) ;
125
+ }
126
+
127
+ return iOSApplication ;
128
+ } ) . future < IiTunesConnectApplication > ( ) ( ) ;
129
+ }
130
+
131
+ /**
132
+ * Gets the application's bundle identifier. If ipaFileFullPath is provided will extract the bundle identifier from the .ipa file.
133
+ * @param {string } ipaFileFullPath Optional full path to .ipa file
134
+ * @return {IFuture<string> } Application's bundle identifier.
135
+ */
136
+ private getBundleIdentifier ( ipaFileFullPath ?: string ) : IFuture < string > {
123
137
return ( ( ) : string => {
124
138
if ( ! this . _bundleIdentifier ) {
125
139
if ( ! ipaFileFullPath ) {
0 commit comments