Skip to content

Commit e80b4d8

Browse files
author
Dimitar Kerezov
committed
WIP
1 parent 83c159b commit e80b4d8

File tree

5 files changed

+65
-34
lines changed

5 files changed

+65
-34
lines changed

docs/man_pages/project/testing/publish-ios.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ publish ios
44
<% if((isConsole && isMacOS) || isHtml) { %>
55
Usage | Synopsis
66
---|---
7-
General | `$ tns publish ios <Apple ID> [<Username> [<Password> [<Mobile Provisioning Profile Identifier> [<Code Sign Identity>]]]]`
7+
General | `$ tns publish ios [<Application Name> [<Username> [<Password> [<Mobile Provisioning Profile Identifier> [<Code Sign Identity>]]]]]`
88

9-
Builds the project and uploads it to iTunesConnect. `Username` and `Password` parameters are required but if not provided, the CLI will ask for them.
9+
Builds the project and uploads it to iTunesConnect. `Application Name`, `Username` and `Password` parameters are required but if not provided, the CLI will ask for them.
1010

1111
### Attributes
12-
`<Apple ID>` the Apple ID of the application created at itunesconnect.apple.com
12+
`<Application Name>` the name of the application created at itunesconnect.apple.com
1313
`<Username>` the Username for authentiation with iTunesConnect
1414
`<Password>` the Password for authentiation with iTunesConnect
1515
`<Mobile Provisioning Profile Identifier>` the identifier of the mobile provision which will be used for building. This can easily be acquired through the iPhone Configuration Utility

lib/commands/publish-ios.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,21 @@ export class PublishIOS implements ICommand {
1111
private $prompter: IPrompter,
1212
private $stringParameterBuilder: IStringParameterBuilder) { }
1313

14-
public allowedParameters: ICommandParameter[] = [this.$stringParameterBuilder.createMandatoryParameter("Missing required Apple ID parameter."),
15-
new StringCommandParameter(this.$injector), new StringCommandParameter(this.$injector), new StringCommandParameter(this.$injector), new StringCommandParameter(this.$injector)];
14+
public allowedParameters: ICommandParameter[] = [new StringCommandParameter(this.$injector), new StringCommandParameter(this.$injector),
15+
new StringCommandParameter(this.$injector), new StringCommandParameter(this.$injector), new StringCommandParameter(this.$injector)];
1616

1717
public execute(args: string[]): IFuture<void> {
1818
return (() => {
19-
let app_id = args[0],
19+
let applicationName = args[0],
2020
userName = args[1],
2121
password = args[2],
2222
mobileProvisionIdentifier = args[3],
2323
codeSignIdentity = args[4];
2424

25+
if(!applicationName) {
26+
applicationName = this.$prompter.getString("Application Name", { allowEmpty: false }).wait();
27+
}
28+
2529
if(!userName) {
2630
userName = this.$prompter.getString("Apple ID", { allowEmpty: false }).wait();
2731
}
@@ -39,7 +43,7 @@ export class PublishIOS implements ICommand {
3943
}
4044

4145
this.$options.release = true;
42-
this.$itmsTransporterService.upload(app_id, userName, password, mobileProvisionIdentifier, codeSignIdentity).wait();
46+
this.$itmsTransporterService.upload(applicationName, userName, password, mobileProvisionIdentifier, codeSignIdentity).wait();
4347
}).future<void>()();
4448
}
4549
}

lib/common

lib/declarations.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@ interface IITMSTransporterService {
9696
/**
9797
* Builds and uploads an .ipa package to itunesconnect.
9898
* Note that if mobileProvisionIdentifier and/or codeSignIdentity are passed to this method they will override any options set through .xcconfig files.
99-
* @param {string} appId The application's Apple ID. It can be found on itunesconnect.apple.com.
99+
* @param {string} applicationName The application's name as specified on itunesconnect.apple.com.
100100
* @param {string} username Username for authentication with itunesconnect.
101101
* @param {string} password Password for authentication with itunesconnect.
102102
* @param {string} mobileProvisionIdentifier? The identifier of the mobile provision used for building.
103103
* @param {string} codeSignIdentity? The Code Sign Identity used for building.
104104
* @returns IFuture<void>
105105
*/
106-
upload(appId: string, username: string, password: string, mobileProvisionIdentifier?: string, codeSignIdentity?: string): IFuture<void>;
106+
upload(applicationName: string, username: string, password: string, mobileProvisionIdentifier?: string, codeSignIdentity?: string): IFuture<void>;
107107
}
108108

109109
/**

lib/services/itmstransporter-service.ts

+51-24
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@ export class ITMSTransporterService implements IITMSTransporterService {
1111
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
1212
private $errors: IErrors,
1313
private $fs: IFileSystem,
14+
private $httpClient: Server.IHttpClient,
1415
private $platformService: IPlatformService,
1516
private $staticConfig: IStaticConfig,
16-
private $sysInfo: ISysInfo) { }
17+
private $sysInfo: ISysInfo
18+
/*private $xcodeSelectService: IXcodeSelectService*/) { }
1719

18-
public upload(appId: string, username: string, password: string, mobileProvisionIdentifier?: string, codeSignIdentity?: string): IFuture<void> {
20+
public upload(applicationName: string, username: string, password: string, mobileProvisionIdentifier?: string, codeSignIdentity?: string): IFuture<void> {
1921
return (() => {
2022
temp.track();
21-
let itmsTransporterPath = this.getITMSTransporterPath().wait(),
23+
let appId = this.getAppId(applicationName, username, password).wait(),
24+
itmsTransporterPath = this.getITMSTransporterPath().wait(),
2225
ipaFileName = "app.ipa",
2326
itmsDirectory = temp.mkdirSync("itms-"),
2427
innerDirectory = path.join(itmsDirectory, "mybundle.itmsp"),
@@ -31,39 +34,63 @@ export class ITMSTransporterService implements IITMSTransporterService {
3134
codeSignIdentity: codeSignIdentity
3235
};
3336

34-
this.$fs.createDirectory(innerDirectory).wait();
37+
// this.$fs.createDirectory(innerDirectory).wait();
3538

36-
this.$platformService.preparePlatform(platform).wait();
37-
this.$platformService.buildPlatform(platform, iosBuildConfig).wait();
38-
this.$platformService.copyLastOutput(platform, ipaFileLocation, { isForDevice: forDevice }).wait();
39+
// this.$platformService.preparePlatform(platform).wait();
40+
// this.$platformService.buildPlatform(platform, iosBuildConfig).wait();
41+
// this.$platformService.copyLastOutput(platform, ipaFileLocation, { isForDevice: forDevice }).wait();
3942

40-
let ipaFileHash = md5(this.$fs.readFile(ipaFileLocation).wait()),
41-
ipaFileSize = this.$fs.getFileSize(ipaFileLocation).wait(),
42-
metadata = `<?xml version="1.0" encoding="UTF-8"?>
43-
<package version="software4.7" xmlns="http://apple.com/itunes/importer">
44-
<software_assets apple_id="${appId}">
45-
<asset type="bundle">
46-
<data_file>
47-
<file_name>${ipaFileName}</file_name>
48-
<checksum type="md5">${ipaFileHash}</checksum>
49-
<size>${ipaFileSize}</size>
50-
</data_file>
51-
</asset>
52-
</software_assets>
53-
</package>`;
43+
// let ipaFileHash = md5(this.$fs.readFile(ipaFileLocation).wait()),
44+
// ipaFileSize = this.$fs.getFileSize(ipaFileLocation).wait(),
45+
// metadata = `<?xml version="1.0" encoding="UTF-8"?>
46+
// <package version="software4.7" xmlns="http://apple.com/itunes/importer">
47+
// <software_assets apple_id="${appId}">
48+
// <asset type="bundle">
49+
// <data_file>
50+
// <file_name>${ipaFileName}</file_name>
51+
// <checksum type="md5">${ipaFileHash}</checksum>
52+
// <size>${ipaFileSize}</size>
53+
// </data_file>
54+
// </asset>
55+
// </software_assets>
56+
// </package>`;
5457

55-
this.$fs.writeFile(path.join(innerDirectory, "metadata.xml"), metadata).wait();
58+
// this.$fs.writeFile(path.join(innerDirectory, "metadata.xml"), metadata).wait();
5659

57-
this.$childProcess.spawnFromEvent(itmsTransporterPath, ["-m", "upload", "-f", itmsDirectory, "-u", username, "-p", password, "-v", "informational"], "close", { stdio: "inherit" }).wait();
60+
// this.$childProcess.spawnFromEvent(itmsTransporterPath, ["-m", "upload", "-f", itmsDirectory, "-u", username, "-p", password, "-v", "informational"], "close", { stdio: "inherit" }).wait();
5861
}).future<void>()();
5962
}
6063

64+
private getAppId(applicationName: string, username: string, password: string): IFuture<string> {
65+
return (() => {
66+
let result = this.$httpClient.httpRequest({
67+
url: "https://contentdelivery.itunes.apple.com/WebObjects/MZLabelService.woa/json/MZITunesProducerService",
68+
method: "POST",
69+
body: JSON.stringify({
70+
id: 1, // magic number
71+
jsonrpc: "2.0",
72+
method: "lookupSoftwareApplications",
73+
params: {
74+
Username: username,
75+
Password: password,
76+
Version: "2.9.1(441)",
77+
Application: "Application Loader",
78+
OSIdentifier: "Mac OS X 10.8.5 (x86_64)"
79+
}
80+
})
81+
}).wait().body.result;
82+
83+
console.log(json.result);
84+
return "5";
85+
}).future<string>()();
86+
}
87+
6188
private getITMSTransporterPath(): IFuture<string> {
6289
return (() => {
6390
if (!this._itmsTransporterPath) {
6491
let sysInfo = this.$sysInfo.getSysInfo(path.join(__dirname, "..", "..", this.$staticConfig.PROJECT_FILE_NAME)).wait(),
6592
xcodeVersionMatch = sysInfo.xcodeVer.match(/Xcode (.*)/),
66-
result = path.join("/Applications", "Xcode.app", "Contents", "Applications", "Application Loader.app", "Contents");
93+
result = path.join("this.$xcodeSelectService.getContentsDirectoryPath().wait()", "Applications", "Application Loader.app", "Contents");
6794

6895
if (xcodeVersionMatch && xcodeVersionMatch[1]) {
6996
let [major, minor] = xcodeVersionMatch[1].split(".");

0 commit comments

Comments
 (0)