|
| 1 | +///<reference path="../.d.ts"/> |
| 2 | +"use strict"; |
| 3 | + |
| 4 | +import {StringCommandParameter} from "../common/command-params"; |
| 5 | +import * as path from "path"; |
| 6 | + |
| 7 | +export class PublishIOS implements ICommand { |
| 8 | + constructor(private $errors: IErrors, |
| 9 | + private $fs: IFileSystem, |
| 10 | + private $hostInfo: IHostInfo, |
| 11 | + private $injector: IInjector, |
| 12 | + private $itmsTransporterService: IITMSTransporterService, |
| 13 | + private $logger: ILogger, |
| 14 | + private $options: IOptions, |
| 15 | + private $prompter: IPrompter, |
| 16 | + private $stringParameterBuilder: IStringParameterBuilder) { } |
| 17 | + |
| 18 | + public allowedParameters: ICommandParameter[] = [new StringCommandParameter(this.$injector), new StringCommandParameter(this.$injector), |
| 19 | + new StringCommandParameter(this.$injector), new StringCommandParameter(this.$injector)]; |
| 20 | + |
| 21 | + public execute(args: string[]): IFuture<void> { |
| 22 | + return (() => { |
| 23 | + let username = args[0], |
| 24 | + password = args[1], |
| 25 | + mobileProvisionIdentifier = args[2], |
| 26 | + codeSignIdentity = args[3], |
| 27 | + ipaFilePath = this.$options.ipa ? path.resolve(this.$options.ipa) : null, |
| 28 | + bundleId = this.$itmsTransporterService.getBundleIdentifier(ipaFilePath).wait(); |
| 29 | + |
| 30 | + if(!username) { |
| 31 | + username = this.$prompter.getString("Apple ID", { allowEmpty: false }).wait(); |
| 32 | + } |
| 33 | + |
| 34 | + if(!password) { |
| 35 | + password = this.$prompter.getPassword("Apple ID password").wait(); |
| 36 | + } |
| 37 | + |
| 38 | + let iOSApplication = this.$itmsTransporterService.getiOSApplication(username, password, bundleId).wait(); |
| 39 | + |
| 40 | + if(!mobileProvisionIdentifier && !ipaFilePath) { |
| 41 | + 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"); |
| 42 | + } |
| 43 | + |
| 44 | + if(!codeSignIdentity && !ipaFilePath) { |
| 45 | + this.$logger.warn("No code sign identity set. A default code sign identity will be used. You can set one in app/App_Resources/iOS/build.xcconfig"); |
| 46 | + } |
| 47 | + |
| 48 | + this.$options.release = true; |
| 49 | + this.$itmsTransporterService.upload({ |
| 50 | + appId: iOSApplication.adamId, |
| 51 | + username, |
| 52 | + password, |
| 53 | + mobileProvisionIdentifier, |
| 54 | + codeSignIdentity, |
| 55 | + ipaFilePath, |
| 56 | + verboseLogging: this.$logger.getLevel() === "TRACE" |
| 57 | + }).wait(); |
| 58 | + }).future<void>()(); |
| 59 | + } |
| 60 | + |
| 61 | + public canExecute(args: string[]): IFuture<boolean> { |
| 62 | + return (() => { |
| 63 | + if (!this.$hostInfo.isDarwin) { |
| 64 | + this.$errors.failWithoutHelp("This command is only available on Mac OS X."); |
| 65 | + } |
| 66 | + |
| 67 | + return true; |
| 68 | + }).future<boolean>()(); |
| 69 | + } |
| 70 | +} |
| 71 | +$injector.registerCommand(["publish|ios", "appstore|upload"], PublishIOS); |
0 commit comments