Skip to content

Commit ac70416

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

File tree

12 files changed

+240
-65
lines changed

12 files changed

+240
-65
lines changed

config/config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"DEBUG": false,
3-
"USE_PROXY": false,
3+
"USE_PROXY": true,
44
"PROXY_PORT": 8888,
55
"PROXY_HOSTNAME": "127.0.0.1",
66
"TYPESCRIPT_COMPILER_OPTIONS": {},

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> [<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>` the name or Apple ID of the application created at itunesconnect.apple.com, or the index of the application as listed by `$ tns appstore`
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/bootstrap.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ $injector.requireCommand("test|ios", "./commands/test");
5252
$injector.requireCommand("test|init", "./commands/test-init");
5353
$injector.requireCommand("dev-generate-help", "./commands/generate-help");
5454

55-
$injector.requireCommand("publish|ios", "./commands/publish-ios");
55+
$injector.requireCommand("appstore|*list", "./commands/appstore-list");
56+
$injector.requireCommand("appstore|upload", "./commands/appstore-upload");
57+
$injector.requireCommand("publish|ios", "./commands/appstore-upload");
5658
$injector.require("itmsTransporterService", "./services/itmstransporter-service");
5759

5860
$injector.require("npm", "./node-package-manager");

lib/commands/appstore-list.ts

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
///<reference path="../.d.ts"/>
2+
"use strict";
3+
4+
import { createTable } from "../common/helpers";
5+
import {StringCommandParameter} from "../common/command-params";
6+
7+
export class ListiOSApps implements ICommand {
8+
constructor(private $injector: IInjector,
9+
private $itmsTransporterService: IITMSTransporterService,
10+
private $logger: ILogger,
11+
private $prompter: IPrompter,
12+
private $stringParameterBuilder: IStringParameterBuilder) { }
13+
14+
public allowedParameters: ICommandParameter[] = [new StringCommandParameter(this.$injector), new StringCommandParameter(this.$injector)];
15+
16+
public execute(args: string[]): IFuture<void> {
17+
return (() => {
18+
let userName = args[0],
19+
password = args[1];
20+
21+
if(!userName) {
22+
userName = this.$prompter.getString("Apple ID", { allowEmpty: false }).wait();
23+
}
24+
25+
if(!password) {
26+
password = this.$prompter.getPassword("Apple ID password").wait();
27+
}
28+
29+
let iOSApplications = this.$itmsTransporterService.getiOSApplications(userName, password).wait();
30+
31+
if (!iOSApplications || !iOSApplications.length) {
32+
this.$logger.out("Seems you don't have any applications yet.");
33+
} else {
34+
let table: any = createTable(["Application Name", "Bundle Identifier", "Apple ID"], iOSApplications.map(element => {
35+
return [element.name, element.bundleId, element.adamId];
36+
}));
37+
38+
this.$logger.out(table.toString());
39+
}
40+
}).future<void>()();
41+
}
42+
}
43+
44+
$injector.registerCommand("appstore|*list", ListiOSApps);

lib/commands/appstore-upload.ts

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
///<reference path="../.d.ts"/>
2+
"use strict";
3+
4+
import {StringCommandParameter} from "../common/command-params";
5+
6+
export class PublishIOS implements ICommand {
7+
constructor(private $errors: IErrors,
8+
private $injector: IInjector,
9+
private $itmsTransporterService: IITMSTransporterService,
10+
private $logger: ILogger,
11+
private $options: IOptions,
12+
private $projectData: IProjectData,
13+
private $prompter: IPrompter,
14+
private $stringParameterBuilder: IStringParameterBuilder) { }
15+
16+
public allowedParameters: ICommandParameter[] = [new StringCommandParameter(this.$injector), new StringCommandParameter(this.$injector),
17+
new StringCommandParameter(this.$injector), new StringCommandParameter(this.$injector)];
18+
19+
public execute(args: string[]): IFuture<void> {
20+
return (() => {
21+
let username = args[0],
22+
password = args[1],
23+
mobileProvisionIdentifier = args[2],
24+
codeSignIdentity = args[3],
25+
ipaFilePath = this.$options.ipa;
26+
27+
if(!username) {
28+
username = this.$prompter.getString("Apple ID", { allowEmpty: false }).wait();
29+
}
30+
31+
if(!password) {
32+
password = this.$prompter.getPassword("Apple ID password").wait();
33+
}
34+
35+
let iOSApplications = this.$itmsTransporterService.getiOSApplications(username, password).wait();
36+
if (!iOSApplications || !iOSApplications.length) {
37+
this.$errors.failWithoutHelp("You don't have any applications registered at iTunes Connect.");
38+
}
39+
40+
let iosApplication = _.find(iOSApplications, app => app.bundleId === this.$projectData.projectId);
41+
42+
if (!iosApplication) {
43+
this.$errors.failWithoutHelp(`No application found on iTunes Connect that matches identifier ${this.$projectData.projectId}`);
44+
}
45+
46+
if(!mobileProvisionIdentifier) {
47+
this.$logger.warn("Mobile Provision identifier not set - a default one will be used. You can set one in App_Resources/iOS/build.xcconfig");
48+
}
49+
50+
if(!codeSignIdentity) {
51+
this.$logger.warn("Code Sign Identity not set - a default one will be used. You can set one in App_Resources/iOS/build.xcconfig");
52+
}
53+
54+
this.$options.release = true;
55+
this.$itmsTransporterService.upload({
56+
appId: iosApplication.bundleId,
57+
username,
58+
password,
59+
mobileProvisionIdentifier,
60+
codeSignIdentity,
61+
ipaFilePath
62+
}).wait();
63+
}).future<void>()();
64+
}
65+
}
66+
$injector.registerCommand("publish|ios", PublishIOS);
67+
$injector.registerCommand("appstore|upload", PublishIOS);

lib/commands/publish-ios.ts

-46
This file was deleted.

lib/constants.ts

+7
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,10 @@ export class ReleaseType {
2525
static PREPATCH = "prepatch";
2626
static PRERELEASE = "prerelease";
2727
}
28+
29+
class ItunesConnectApplicationTypesClass implements IItunesConnectApplicationType {
30+
public iOS = "iOS App";
31+
public Mac = "Mac OS X App";
32+
}
33+
34+
export let ItunesConnectApplicationTypes = new ItunesConnectApplicationTypesClass();

lib/declarations.ts

+50-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ interface ILiveSyncService {
5959
}
6060

6161
interface IOptions extends ICommonOptions {
62+
ipa: string;
6263
frameworkPath: string;
6364
frameworkName: string;
6465
framework: string;
@@ -89,6 +90,42 @@ interface IInitService {
8990
initialize(): IFuture<void>;
9091
}
9192

93+
/**
94+
* Describes properties needed for uploading a package to itunesconnect
95+
*/
96+
interface IITMSData {
97+
/**
98+
* The application's Apple ID. It can be found on itunesconnect.apple.com.
99+
* @type {string}
100+
*/
101+
appId: string;
102+
/**
103+
* Username for authentication with itunesconnect.
104+
* @type {string}
105+
*/
106+
username: string;
107+
/**
108+
* Password for authentication with itunesconnect.
109+
* @type {string}
110+
*/
111+
password: string;
112+
/**
113+
* The identifier of the mobile provision used for building. Note that this will override the same option set through .xcconfig files.
114+
* @type {string}
115+
*/
116+
mobileProvisionIdentifier?: string;
117+
/**
118+
* The Code Sign Identity used for building. Note that this will override the same option set through .xcconfig files.
119+
* @type {string}
120+
*/
121+
codeSignIdentity?: string
122+
/**
123+
* Path to a .ipa file which will be uploaded. If set that .ipa will be used and no build will be issued.
124+
* @type {string}
125+
*/
126+
ipaFilePath?: string
127+
}
128+
92129
/**
93130
* Used for communicating with Xcode's iTMS Transporter tool.
94131
*/
@@ -103,7 +140,19 @@ interface IITMSTransporterService {
103140
* @param {string} codeSignIdentity? The Code Sign Identity used for building.
104141
* @returns IFuture<void>
105142
*/
106-
upload(appId: string, username: string, password: string, mobileProvisionIdentifier?: string, codeSignIdentity?: string): IFuture<void>;
143+
/**
144+
* Uploads an .ipa package to itunesconnect.
145+
* @param {IITMSData} data Data needed to upload the package
146+
* @return {IFuture<void>}
147+
*/
148+
upload(data: IITMSData): IFuture<void>;
149+
/**
150+
* Queries Apple's content delivery API to get the user's registered iOS applications.
151+
* @param {string} username Username for authentication with itunesconnect.
152+
* @param {string} password Password for authentication with itunesconnect.
153+
* @return {IFuture<IItunesConnectApplication[]>} The user's iOS applications.
154+
*/
155+
getiOSApplications(username: string, password: string): IFuture<IItunesConnectApplication[]>;
107156
}
108157

109158
/**

lib/options.ts

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export class Options extends commonOptionsLibPath.OptionsBase {
1212
$staticConfig: IStaticConfig,
1313
$hostInfo: IHostInfo) {
1414
super({
15+
ipa: { type: OptionType.String },
1516
frameworkPath: { type: OptionType.String },
1617
frameworkName: { type: OptionType.String },
1718
framework: { type: OptionType.String },

0 commit comments

Comments
 (0)