Skip to content

Commit 45b34d4

Browse files
author
Dimitar Kerezov
committed
PR Comments
1 parent b17b1cc commit 45b34d4

File tree

3 files changed

+35
-43
lines changed

3 files changed

+35
-43
lines changed

lib/commands/appstore-upload.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ export class PublishIOS implements ICommand {
2424
password = args[1],
2525
mobileProvisionIdentifier = args[2],
2626
codeSignIdentity = args[3],
27-
ipaFilePath = this.$options.ipa ? path.resolve(this.$options.ipa) : null,
28-
bundleId = this.$itmsTransporterService.getBundleIdentifier(ipaFilePath).wait();
27+
ipaFilePath = this.$options.ipa ? path.resolve(this.$options.ipa) : null;
2928

3029
if(!username) {
3130
username = this.$prompter.getString("Apple ID", { allowEmpty: false }).wait();
@@ -35,7 +34,6 @@ export class PublishIOS implements ICommand {
3534
password = this.$prompter.getPassword("Apple ID password").wait();
3635
}
3736

38-
let iOSApplication = this.$itmsTransporterService.getiOSApplication(username, password, bundleId).wait();
3937

4038
if(!mobileProvisionIdentifier && !ipaFilePath) {
4139
this.$logger.warn("No mobile provision identifier set. A default mobile provision will be used. You can set one in app/App_Resources/iOS/build.xcconfig");
@@ -47,7 +45,6 @@ export class PublishIOS implements ICommand {
4745

4846
this.$options.release = true;
4947
this.$itmsTransporterService.upload({
50-
appId: iOSApplication.adamId,
5148
username,
5249
password,
5350
mobileProvisionIdentifier,

lib/declarations.ts

-19
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,6 @@ interface ICredentials {
101101
* Describes properties needed for uploading a package to iTunes Connect
102102
*/
103103
interface IITMSData extends ICredentials {
104-
/**
105-
* The application's Apple ID. It can be found on itunesconnect.apple.com.
106-
* @type {string}
107-
*/
108-
appId: string;
109104
/**
110105
* The identifier of the mobile provision used for building. Note that this will override the same option set through .xcconfig files.
111106
* @type {string}
@@ -144,20 +139,6 @@ interface IITMSTransporterService {
144139
* @return {IFuture<IItunesConnectApplication[]>} The user's iOS applications.
145140
*/
146141
getiOSApplications(credentials: ICredentials): IFuture<IiTunesConnectApplication[]>;
147-
/**
148-
* Gets iTunes Connect application corresponding to the given bundle identifier.
149-
* @param {string} username For authentication with iTunes Connect.
150-
* @param {string} password For authentication with iTunes Connect.
151-
* @param {string} bundleId Application's Bundle Identifier
152-
* @return {IFuture<IiTunesConnectApplication>} The iTunes Connect application.
153-
*/
154-
getiOSApplication(username: string, password: string, bundleId: string) : IFuture<IiTunesConnectApplication>;
155-
/**
156-
* Gets the application's bundle identifier. If ipaFileFullPath is provided will extract the bundle identifier from the .ipa file.
157-
* @param {string} ipaFileFullPath Optional full path to .ipa file
158-
* @return {IFuture<string>} Application's bundle identifier.
159-
*/
160-
getBundleIdentifier(ipaFileFullPath?: string): IFuture<string>;
161142
}
162143

163144
/**

lib/services/itmstransporter-service.ts

+34-20
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,6 @@ export class ITMSTransporterService implements IITMSTransporterService {
3535
return this.$injector.resolve("projectData");
3636
}
3737

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-
5538
public upload(data: IITMSData): IFuture<void> {
5639
return (() => {
5740
if (!this.$hostInfo.isDarwin) {
@@ -71,7 +54,9 @@ export class ITMSTransporterService implements IITMSTransporterService {
7154
mobileProvisionIdentifier: data.mobileProvisionIdentifier,
7255
codeSignIdentity: data.codeSignIdentity
7356
},
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();
7560

7661
this.$fs.createDirectory(innerDirectory).wait();
7762

@@ -84,7 +69,7 @@ export class ITMSTransporterService implements IITMSTransporterService {
8469

8570
let ipaFileHash = this.$fs.getFileShasum(ipaFileLocation, {algorithm: "md5"}).wait(),
8671
ipaFileSize = this.$fs.getFileSize(ipaFileLocation).wait(),
87-
metadata = this.getITMSMetadataXml(data.appId, ipaFileName, ipaFileHash, ipaFileSize);
72+
metadata = this.getITMSMetadataXml(iOSApplication.adamId, ipaFileName, ipaFileHash, ipaFileSize);
8873

8974
this.$fs.writeFile(path.join(innerDirectory, ITMSConstants.ApplicationMetadataFile), metadata).wait();
9075

@@ -119,7 +104,36 @@ export class ITMSTransporterService implements IITMSTransporterService {
119104
}).future<IiTunesConnectApplication[]>()();
120105
}
121106

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> {
123137
return ((): string => {
124138
if (!this._bundleIdentifier) {
125139
if (!ipaFileFullPath) {

0 commit comments

Comments
 (0)