./lib/shenzhen/plugins/itunesconnect.rb in shenzhen-0.12.1 vs ./lib/shenzhen/plugins/itunesconnect.rb in shenzhen-0.13.0

- old
+ new

@@ -22,21 +22,23 @@ def upload_build! size = File.size(@ipa) checksum = Digest::MD5.file(@ipa) - FileUtils.mkdir_p("Package.itmsp") - FileUtils.copy_entry(@ipa, "Package.itmsp/#{@filename}") + begin + FileUtils.mkdir_p("Package.itmsp") + FileUtils.copy_entry(@ipa, "Package.itmsp/#{@filename}") - File.write("Package.itmsp/metadata.xml", metadata(@apple_id, checksum, size)) + File.write("Package.itmsp/metadata.xml", metadata(@apple_id, checksum, size)) - case transport - when /(error)|(fail)/i - say_error "An error occurred when trying to upload the build to iTunesConnect.\nRun with --verbose for more info." and abort + case transport + when /(error)|(fail)/i + say_error "An error occurred when trying to upload the build to iTunesConnect.\nRun with --verbose for more info." and abort + end + ensure + FileUtils.rm_rf("Package.itmsp", :secure => true) end - - FileUtils.rmdir("Package.itmsp") end private def transport @@ -44,22 +46,18 @@ tool = File.join(File.dirname(xcode), "Applications/Application Loader.app/Contents/MacOS/itms/bin/iTMSTransporter").gsub(/\s/, '\ ') args = [tool, "-m upload", "-f Package.itmsp", "-u #{Shellwords.escape(@account)}", "-p #{Shellwords.escape(@password)}"] command = args.join(' ') - say "#{command}" if verbose? + puts "#{command}" if $verbose output = `#{command} 2> /dev/null` - say output.chomp if verbose? + puts output.chomp if $verbose output end - def verbose? - @params.collect(&:to_sym).include?(:verbose) - end - def metadata(apple_id, checksum, size) %{<?xml version="1.0" encoding="UTF-8"?> <package version="software4.7" xmlns="http://apple.com/itunes/importer"> <software_assets apple_id="#{apple_id}"> <asset type="bundle"> @@ -86,11 +84,10 @@ c.option '-p', '--password PASSWORD', "Password for the account unless already stored in the keychain" c.option '-u', '--upload', "Actually attempt to upload the build to iTunes Connect" c.option '-w', '--warnings', "Check for warnings when validating the ipa" c.option '-e', '--errors', "Check for errors when validating the ipa" c.option '-i', '--apple-id STRING', "Apple ID from iTunes Connect" - c.option '--verbose', "Run commands verbosely" c.option '--sdk SDK', "SDK to use when validating the ipa. Defaults to 'iphoneos'" c.option '--save-keychain', "Save the provided account in the keychain for future use" c.action do |args, options| options.default :upload => false, :sdk => 'iphoneos', :save_keychain => true @@ -113,18 +110,22 @@ say_error "Missing iTunes Connect password" and abort unless @password Security::GenericPassword.add(Shenzhen::Plugins::ITunesConnect::ITUNES_CONNECT_SERVER, @account, @password, {:U => nil}) if options.save_keychain end + unless /^[0-9a-zA-Z]*$/ === @password + say_warning "Password contains special characters, which may not be handled properly by iTMSTransporter. If you experience problems uploading to iTunes Connect, please consider changing your password to something with only alphanumeric characters." + end + parameters = [] - parameters << :verbose if options.verbose parameters << :warnings if options.warnings parameters << :errors if options.errors client = Shenzhen::Plugins::ITunesConnect::Client.new(@file, apple_id, options.sdk, @account, @password, parameters) client.upload_build! - say_ok "Upload complete. You may want to double check iTunes Connect to make sure it was received correctly." + say_ok "Upload complete." + say_warning "You may want to double check iTunes Connect to make sure it was received correctly." end private def determine_itunes_connect_account!