From 84499419a79b0b27bd5a43915b1f25d9e96a2e51 Mon Sep 17 00:00:00 2001 From: chevybowtie Date: Sun, 25 Oct 2015 17:01:37 -0500 Subject: [PATCH 1/8] Update Guide.md --- docs/Guide.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/Guide.md b/docs/Guide.md index 7c9b37f8ecf..565014f9b71 100644 --- a/docs/Guide.md +++ b/docs/Guide.md @@ -27,6 +27,10 @@ Requirements: Additionally, to an Xcode installation, you also need the Xcode command line tools set up xcode-select --install + +If you've not used the command line tools before, you'll need to accept the terms of service. + + sudo gcc ### [fastlane](https://github.com/KrauseFx/fastlane) From 61d307e34ff65761171104b074bb5d90ef124c7a Mon Sep 17 00:00:00 2001 From: chevybowtie Date: Mon, 26 Oct 2015 19:54:40 -0500 Subject: [PATCH 2/8] Update Guide.md --- docs/Guide.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Guide.md b/docs/Guide.md index 565014f9b71..33fe4e5bb93 100644 --- a/docs/Guide.md +++ b/docs/Guide.md @@ -28,9 +28,9 @@ Additionally, to an Xcode installation, you also need the Xcode command line too xcode-select --install -If you've not used the command line tools before, you'll need to accept the terms of service. +If you have not used the command line tools before (which is likely if you just installed it), you'll need to accept the terms of service. - sudo gcc + sudo xcodebuild -license accept ### [fastlane](https://github.com/KrauseFx/fastlane) From 77b91960c6a93e1373e3ffb9700c4bdc26364b35 Mon Sep 17 00:00:00 2001 From: yoko yaeg Date: Tue, 27 Oct 2015 18:06:40 +0100 Subject: [PATCH 3/8] deploy to appaloosa store --- fastlane/Fastfile | 28 +++ lib/fastlane/actions/appaloosa_store.rb | 239 ++++++++++++++++++++++++ 2 files changed, 267 insertions(+) create mode 100644 lib/fastlane/actions/appaloosa_store.rb diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 20939295384..ab362a47b76 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -5,6 +5,34 @@ lane :test do validate_repo(tool_name: detect_tool) end +desc "Test pull request" + lane :appaloosa1 do # context: user registered with private groups. + snapshot + gym(use_legacy_build_api: true) + appaloosa( + binary: 'path/to/binary_file', # ipa or apk + store_id: 'store_id', + api_token: 'api_token', + group_ids: '21, 42, 84', + locale: 'de-DE', # use snapshot, default => 'en-US' + device: 'iPhone6' # use snapshot + ) + end + + lane :appaloosa2 do # context: user anonymous + gym(use_legacy_build_api: true) + appaloosa( + binary: 'path/to/binary_file', + screenshots: 'path/to/screenshots_forder', + email: 'test@mail.com', + ) + end + + lane :appaloosa3 do # context: no option + gym(use_legacy_build_api: true) + appaloosa + end + desc "Increment the version number of this gem" lane :bump do |options| tool_name = options[:tool] || detect_tool diff --git a/lib/fastlane/actions/appaloosa_store.rb b/lib/fastlane/actions/appaloosa_store.rb new file mode 100644 index 00000000000..166b6576aac --- /dev/null +++ b/lib/fastlane/actions/appaloosa_store.rb @@ -0,0 +1,239 @@ +APPALOOSA_SERVER = 'http://appaloosa-store.com/api/v1' + +module Fastlane + module Actions + class AppaloosaAction < Action + def self.run(params) + require 'http' + + api_key = params[:api_token] + store_id = params[:store_id] + + if request_email? api_key, store_id + auth = create_an_account params[:email] + api_key = auth['api_key'] + store_id = auth['store_id'] + return if error_detected auth['errors'] + end + + binary = normalize_binary_name params[:binary] + remove_extra_screenshots_file params[:screenshots] + screenshots_url = get_screenshots_links api_key, store_id, params[:screenshots], params[:locale], params[:device] + binary_url = get_binary_link binary, api_key, store_id + upload_on_appaloosa api_key, store_id, binary_url, screenshots_url, params[:group_ids] + reset_original_binary_names binary, params[:binary] + end + + def self.reset_original_binary_names(current_name, original_name) + File.rename("#{current_name}", "#{original_name}") + end + + def self.remove_extra_screenshots_file(screenshots_env) + extra_file = "#{screenshots_env}/screenshots.html" + File.unlink(extra_file) if File.exist?(extra_file) + end + + def self.get_binary_link(binary, api_key, store_id) + key_s3 = upload_on_s3 binary + get_s3_url api_key, store_id, key_s3 + end + + def self.normalize_binary_name(binary) + binary_rename = binary.delete(' ') + File.rename("#{binary}", "#{binary_rename}") + binary_rename + end + + def self.create_an_account(email) + response = HTTP.post("#{APPALOOSA_SERVER}/bitrise_binaries/create_an_account", form: { email: email }) + JSON.parse response + end + + def self.request_email?(api_key, store_id) + api_key.size == 0 && store_id.size == 0 + end + + def self.upload_screenshots(screenshots) + return if screenshots.nil? + list = [] + list << screenshots.map do |screen| + upload_on_s3 screen + end + end + + def self.get_uploaded_links(uploaded_screenshots, api_key, store_id) + return if uploaded_screenshots.nil? + urls = [] + urls << uploaded_screenshots.flatten.map do |url| + get_s3_url api_key, store_id, url + end + end + + def self.get_screenshots_links(api_key, store_id, screenshots_path, locale, device) + screenshots = get_screenshots screenshots_path, locale, device + uploaded = upload_screenshots screenshots + links = get_uploaded_links uploaded, api_key, store_id + links.kind_of?(Array) ? links.flatten : nil + end + + def self.get_screenshots(screenshots_path, locale, device) + get_env_value('screenshots').nil? ? locale = '' : locale.concat('/') + device.nil? ? device = '' : device.concat('-') + screenshots_path.strip.size > 0 ? screenshots_list(screenshots_path, locale, device) : nil + end + + def self.screenshots_list(path, locale, device) + list = Dir.entries("#{path}/#{locale}") - ['.', '..'] + list.map do |screen| + next if screen.match(device).nil? + "#{path}/#{locale}#{screen}" unless Dir.exist?("#{path}/#{locale}#{screen}") + end.compact + end + + def self.upload_on_appaloosa(api_key, store_id, binary_path, screenshots, group_ids) + screenshots = all_screenshots_links screenshots + response = HTTP.post("#{APPALOOSA_SERVER}/#{store_id}/applications/upload", + json: { store_id: store_id, + api_key: api_key, + application: { + binary_path: binary_path, + screenshot1: screenshots[0], + screenshot2: screenshots[1], + screenshot3: screenshots[2], + screenshot4: screenshots[3], + screenshot5: screenshots[4], + group_ids: group_ids + } + }) + json_res = JSON.parse response + puts json_res + end + + def self.all_screenshots_links(screenshots) + if screenshots.nil? + screens = %w(screenshot1 screenshot2 screenshot3 screenshot4 screenshot5) + screenshots = screens.map do |_k, v| + '' + end + else + missings = 5 - screenshots.count + (1..missings).map do |_i| + screenshots << '' + end + end + screenshots + end + + def self.get_s3_url(api_key, store_id, path) + binary_path = HTTP.get("#{APPALOOSA_SERVER}/#{store_id}/bitrise_binaries/url_for_download", + json: { store_id: store_id, api_key: api_key, key: path }) + json_res = JSON.parse binary_path + return if error_detected json_res['errors'] + json_res['binary_url'] + end + + def self.upload_on_s3(file) + file_name = file.split('/').last + response = HTTP.get("#{APPALOOSA_SERVER}/bitrise_binaries/fastlane", + json: { file: file_name }) + json_res = JSON.parse response + url = json_res['s3_sign'] + path = json_res['path'] + uri = URI.parse(Base64.decode64(url)) + File.open(file, 'rb') do |f| + Net::HTTP.start(uri.host) do |http| + http.send_request('PUT', uri.request_uri, f.read, 'content-type' => '') + end + end + path + end + + def self.get_env_value(option) + available_options.map do |opt| + opt if opt.key == option.to_sym + end.compact[0].default_value + end + + def self.error_detected(errors) + if errors + puts "ERROR: #{errors}".red + true + else + false + end + end + + ##################################################### + # @!group Documentation + ##################################################### + + def self.description + 'Upload your app to Appaloosa Store' + end + + def self.details + 'You can use this action to do cool things...' + end + + def self.available_options + [ + FastlaneCore::ConfigItem.new(key: :binary, + env_name: 'FL_APPALOOSA_BINARY', + description: 'Path to your IPA or APK file. Optional for ipa if you use the `ipa` or `xcodebuild` action. For Mac zip the .app', + default_value: Actions.lane_context[SharedValues::IPA_OUTPUT_PATH], + verify_block: proc do |value| + fail "Couldn't find ipa || apk file at path '#{value}'".red unless File.exist?(value) + end), + FastlaneCore::ConfigItem.new(key: :api_token, + env_name: 'FL_APPALOOSA_API_TOKEN', + description: "Your API Token, if you don\'t have an account hit [enter]", + verify_block: proc do + end), + FastlaneCore::ConfigItem.new(key: :store_id, + env_name: 'FL_APPALOOSA_STORE_ID', + description: "Your Store id, if you don\'t have an account hit [enter]", + verify_block: proc do |_value| + end), + FastlaneCore::ConfigItem.new(key: :email, + env_name: 'FL_APPALOOSA_EMAIL', + description: "It's your first time? Give your email address", + optional: false), + FastlaneCore::ConfigItem.new(key: :group_ids, + env_name: 'FL_APPALOOSA_GROUPS', + description: 'Your app is limited to special users? Give us the group ids', + default_value: '', + optional: true), + FastlaneCore::ConfigItem.new(key: :screenshots, + env_name: 'FL_APPALOOSA_SCREENSHOTS', + description: 'Add some screenshots application to your store or hit [enter]', + default_value: Actions.lane_context[SharedValues::SNAPSHOT_SCREENSHOTS_PATH]), + FastlaneCore::ConfigItem.new(key: :locale, + env_name: 'FL_APPALOOSA_LOCALE', + description: 'Select the folder locale for yours screenshots', + default_value: 'en-US', + optional: true + ), + FastlaneCore::ConfigItem.new(key: :device, + env_name: 'FL_APPALOOSA_DEVICE', + description: 'Select the device format for yours screenshots', + optional: true + ), + FastlaneCore::ConfigItem.new(key: :development, + env_name: 'FL_APPALOOSA_DEVELOPMENT', + description: 'Create a development certificate instead of a distribution one', + is_string: false, + default_value: false, + optional: true) + ] + end + + def self.authors + ['Appaloosa'] + end + + def self.is_supported?(platform) + [:ios, :mac, :android].include? platform + end + end + end +end From e0164db4ca68e7dbfbfb8e3b5d3b83401671907f Mon Sep 17 00:00:00 2001 From: yoko yaeg Date: Mon, 2 Nov 2015 16:18:00 +0100 Subject: [PATCH 4/8] Fix review: change puts by Rails logger. remove extra code in Fastfile Bug fix: Rubocop Change server route --- fastlane/Fastfile | 28 ------ .../{appaloosa_store.rb => appaloosa.rb} | 97 +++++++++++-------- 2 files changed, 57 insertions(+), 68 deletions(-) rename lib/fastlane/actions/{appaloosa_store.rb => appaloosa.rb} (82%) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index ab362a47b76..20939295384 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -5,34 +5,6 @@ lane :test do validate_repo(tool_name: detect_tool) end -desc "Test pull request" - lane :appaloosa1 do # context: user registered with private groups. - snapshot - gym(use_legacy_build_api: true) - appaloosa( - binary: 'path/to/binary_file', # ipa or apk - store_id: 'store_id', - api_token: 'api_token', - group_ids: '21, 42, 84', - locale: 'de-DE', # use snapshot, default => 'en-US' - device: 'iPhone6' # use snapshot - ) - end - - lane :appaloosa2 do # context: user anonymous - gym(use_legacy_build_api: true) - appaloosa( - binary: 'path/to/binary_file', - screenshots: 'path/to/screenshots_forder', - email: 'test@mail.com', - ) - end - - lane :appaloosa3 do # context: no option - gym(use_legacy_build_api: true) - appaloosa - end - desc "Increment the version number of this gem" lane :bump do |options| tool_name = options[:tool] || detect_tool diff --git a/lib/fastlane/actions/appaloosa_store.rb b/lib/fastlane/actions/appaloosa.rb similarity index 82% rename from lib/fastlane/actions/appaloosa_store.rb rename to lib/fastlane/actions/appaloosa.rb index 166b6576aac..28f2eb81812 100644 --- a/lib/fastlane/actions/appaloosa_store.rb +++ b/lib/fastlane/actions/appaloosa.rb @@ -1,8 +1,7 @@ -APPALOOSA_SERVER = 'http://appaloosa-store.com/api/v1' - module Fastlane module Actions class AppaloosaAction < Action + APPALOOSA_SERVER = 'http://appaloosa-int.herokuapp.com/api/v1' def self.run(params) require 'http' @@ -18,12 +17,51 @@ def self.run(params) binary = normalize_binary_name params[:binary] remove_extra_screenshots_file params[:screenshots] + binary_url = get_binary_link binary, api_key, store_id, params[:group_ids] + return if binary_url.nil? screenshots_url = get_screenshots_links api_key, store_id, params[:screenshots], params[:locale], params[:device] - binary_url = get_binary_link binary, api_key, store_id upload_on_appaloosa api_key, store_id, binary_url, screenshots_url, params[:group_ids] reset_original_binary_names binary, params[:binary] end + def self.get_binary_link(binary, api_key, store_id, group_ids) + key_s3 = upload_on_s3 binary, store_id, group_ids + return if key_s3.nil? + get_s3_url api_key, store_id, key_s3 + end + + def self.upload_on_s3(file, store_id, group_ids = '') + file_name = file.split('/').last + response = HTTP.get("#{APPALOOSA_SERVER}/#{store_id}/fastlane", + json: { store_id: store_id, + file: file_name, + group_ids: group_ids }) + if response.status == 404 + return nil if error_detected("A problem occurred with your API token and your store id. Please try again.") + end + json_res = JSON.parse response + return if error_detected json_res['errors'] + url = json_res['s3_sign'] + path = json_res['path'] + uri = URI.parse(Base64.decode64(url)) + File.open(file, 'rb') do |f| + Net::HTTP.start(uri.host) do |http| + http.send_request('PUT', uri.request_uri, f.read, 'content-type' => '') + end + end + path + end + + def self.get_s3_url(api_key, store_id, path) + binary_path = HTTP.get("#{APPALOOSA_SERVER}/#{store_id}/fastlane/url_for_download", + json: { store_id: store_id, + api_key: api_key, + key: path }) + json_res = JSON.parse binary_path + return if error_detected json_res['errors'] + json_res['binary_url'] + end + def self.reset_original_binary_names(current_name, original_name) File.rename("#{current_name}", "#{original_name}") end @@ -33,11 +71,6 @@ def self.remove_extra_screenshots_file(screenshots_env) File.unlink(extra_file) if File.exist?(extra_file) end - def self.get_binary_link(binary, api_key, store_id) - key_s3 = upload_on_s3 binary - get_s3_url api_key, store_id, key_s3 - end - def self.normalize_binary_name(binary) binary_rename = binary.delete(' ') File.rename("#{binary}", "#{binary_rename}") @@ -45,7 +78,7 @@ def self.normalize_binary_name(binary) end def self.create_an_account(email) - response = HTTP.post("#{APPALOOSA_SERVER}/bitrise_binaries/create_an_account", form: { email: email }) + response = HTTP.post("#{APPALOOSA_SERVER}/fastlane/create_an_account", form: { email: email }) JSON.parse response end @@ -53,11 +86,11 @@ def self.request_email?(api_key, store_id) api_key.size == 0 && store_id.size == 0 end - def self.upload_screenshots(screenshots) + def self.upload_screenshots(screenshots, store_id) return if screenshots.nil? list = [] list << screenshots.map do |screen| - upload_on_s3 screen + upload_on_s3 screen, store_id end end @@ -71,7 +104,8 @@ def self.get_uploaded_links(uploaded_screenshots, api_key, store_id) def self.get_screenshots_links(api_key, store_id, screenshots_path, locale, device) screenshots = get_screenshots screenshots_path, locale, device - uploaded = upload_screenshots screenshots + return if screenshots.nil? + uploaded = upload_screenshots screenshots, store_id links = get_uploaded_links uploaded, api_key, store_id links.kind_of?(Array) ? links.flatten : nil end @@ -83,6 +117,7 @@ def self.get_screenshots(screenshots_path, locale, device) end def self.screenshots_list(path, locale, device) + return warning_detected("screenshots folder not found") unless Dir.exist?("#{path}/#{locale}") list = Dir.entries("#{path}/#{locale}") - ['.', '..'] list.map do |screen| next if screen.match(device).nil? @@ -102,17 +137,18 @@ def self.upload_on_appaloosa(api_key, store_id, binary_path, screenshots, group_ screenshot3: screenshots[2], screenshot4: screenshots[3], screenshot5: screenshots[4], - group_ids: group_ids + group_ids: group_ids, + provider: 'fastlane' } }) json_res = JSON.parse response - puts json_res + Helper.log.info "Binary processing: Check your app': #{json_res['link']}".green end def self.all_screenshots_links(screenshots) if screenshots.nil? screens = %w(screenshot1 screenshot2 screenshot3 screenshot4 screenshot5) - screenshots = screens.map do |_k, v| + screenshots = screens.map do |_k, _v| '' end else @@ -124,30 +160,6 @@ def self.all_screenshots_links(screenshots) screenshots end - def self.get_s3_url(api_key, store_id, path) - binary_path = HTTP.get("#{APPALOOSA_SERVER}/#{store_id}/bitrise_binaries/url_for_download", - json: { store_id: store_id, api_key: api_key, key: path }) - json_res = JSON.parse binary_path - return if error_detected json_res['errors'] - json_res['binary_url'] - end - - def self.upload_on_s3(file) - file_name = file.split('/').last - response = HTTP.get("#{APPALOOSA_SERVER}/bitrise_binaries/fastlane", - json: { file: file_name }) - json_res = JSON.parse response - url = json_res['s3_sign'] - path = json_res['path'] - uri = URI.parse(Base64.decode64(url)) - File.open(file, 'rb') do |f| - Net::HTTP.start(uri.host) do |http| - http.send_request('PUT', uri.request_uri, f.read, 'content-type' => '') - end - end - path - end - def self.get_env_value(option) available_options.map do |opt| opt if opt.key == option.to_sym @@ -156,13 +168,18 @@ def self.get_env_value(option) def self.error_detected(errors) if errors - puts "ERROR: #{errors}".red + Helper.log.info("ERROR: #{errors}".red) true else false end end + def self.warning_detected(warning) + Helper.log.info("WARNING: #{warning}".yellow) + nil + end + ##################################################### # @!group Documentation ##################################################### From fdf68ec177e8f36f9aaa06532dd60e43e8ac45f3 Mon Sep 17 00:00:00 2001 From: yoko yaeg Date: Thu, 12 Nov 2015 18:19:27 +0100 Subject: [PATCH 5/8] Fix typo and add 'details' --- docs/Guide.md | 2 -- lib/fastlane/actions/appaloosa.rb | 55 +++++++++++++++---------------- 2 files changed, 27 insertions(+), 30 deletions(-) diff --git a/docs/Guide.md b/docs/Guide.md index 33fe4e5bb93..a62d6b0872c 100644 --- a/docs/Guide.md +++ b/docs/Guide.md @@ -27,8 +27,6 @@ Requirements: Additionally, to an Xcode installation, you also need the Xcode command line tools set up xcode-select --install - -If you have not used the command line tools before (which is likely if you just installed it), you'll need to accept the terms of service. sudo xcodebuild -license accept diff --git a/lib/fastlane/actions/appaloosa.rb b/lib/fastlane/actions/appaloosa.rb index 28f2eb81812..f2c1e943ed9 100644 --- a/lib/fastlane/actions/appaloosa.rb +++ b/lib/fastlane/actions/appaloosa.rb @@ -8,38 +8,37 @@ def self.run(params) api_key = params[:api_token] store_id = params[:store_id] - if request_email? api_key, store_id + if request_email?(api_key, store_id) auth = create_an_account params[:email] api_key = auth['api_key'] store_id = auth['store_id'] - return if error_detected auth['errors'] + return if error_detected(auth['errors']) end - binary = normalize_binary_name params[:binary] - remove_extra_screenshots_file params[:screenshots] - binary_url = get_binary_link binary, api_key, store_id, params[:group_ids] + binary = normalize_binary_name(params[:binary]) + remove_extra_screenshots_file(params[:screenshots]) + binary_url = get_binary_link(binary, api_key, store_id, params[:group_ids]) return if binary_url.nil? - screenshots_url = get_screenshots_links api_key, store_id, params[:screenshots], params[:locale], params[:device] - upload_on_appaloosa api_key, store_id, binary_url, screenshots_url, params[:group_ids] - reset_original_binary_names binary, params[:binary] + screenshots_url = get_screenshots_links(api_key, store_id, params[:screenshots], params[:locale], params[:device]) + upload_on_appaloosa(api_key, store_id, binary_url, screenshots_url, params[:group_ids]) + reset_original_binary_names(binary, params[:binary]) end def self.get_binary_link(binary, api_key, store_id, group_ids) - key_s3 = upload_on_s3 binary, store_id, group_ids + key_s3 = upload_on_s3(binary, api_key, store_id, group_ids) return if key_s3.nil? - get_s3_url api_key, store_id, key_s3 + get_s3_url(api_key, store_id, key_s3) end - def self.upload_on_s3(file, store_id, group_ids = '') + def self.upload_on_s3(file, api_key, store_id, group_ids = '') file_name = file.split('/').last - response = HTTP.get("#{APPALOOSA_SERVER}/#{store_id}/fastlane", - json: { store_id: store_id, - file: file_name, + response = HTTP.get("#{APPALOOSA_SERVER}/web_services/presign_form", + json: { file: file_name, group_ids: group_ids }) if response.status == 404 return nil if error_detected("A problem occurred with your API token and your store id. Please try again.") end - json_res = JSON.parse response + json_res = JSON.parse(response) return if error_detected json_res['errors'] url = json_res['s3_sign'] path = json_res['path'] @@ -53,12 +52,12 @@ def self.upload_on_s3(file, store_id, group_ids = '') end def self.get_s3_url(api_key, store_id, path) - binary_path = HTTP.get("#{APPALOOSA_SERVER}/#{store_id}/fastlane/url_for_download", + binary_path = HTTP.get("#{APPALOOSA_SERVER}/#{store_id}/web_services/url_for_download", json: { store_id: store_id, api_key: api_key, key: path }) - json_res = JSON.parse binary_path - return if error_detected json_res['errors'] + json_res = JSON.parse(binary_path) + return if error_detected(json_res['errors']) json_res['binary_url'] end @@ -78,8 +77,8 @@ def self.normalize_binary_name(binary) end def self.create_an_account(email) - response = HTTP.post("#{APPALOOSA_SERVER}/fastlane/create_an_account", form: { email: email }) - JSON.parse response + response = HTTP.post("#{APPALOOSA_SERVER}/web_services/create_an_account", form: { email: email }) + JSON.parse(response) end def self.request_email?(api_key, store_id) @@ -90,7 +89,7 @@ def self.upload_screenshots(screenshots, store_id) return if screenshots.nil? list = [] list << screenshots.map do |screen| - upload_on_s3 screen, store_id + upload_on_s3(screen, store_id) end end @@ -98,15 +97,15 @@ def self.get_uploaded_links(uploaded_screenshots, api_key, store_id) return if uploaded_screenshots.nil? urls = [] urls << uploaded_screenshots.flatten.map do |url| - get_s3_url api_key, store_id, url + get_s3_url(api_key, store_id, url) end end def self.get_screenshots_links(api_key, store_id, screenshots_path, locale, device) - screenshots = get_screenshots screenshots_path, locale, device + screenshots = get_screenshots(screenshots_path, locale, device) return if screenshots.nil? - uploaded = upload_screenshots screenshots, store_id - links = get_uploaded_links uploaded, api_key, store_id + uploaded = upload_screenshots(screenshots, store_id) + links = get_uploaded_links(uploaded, api_key, store_id) links.kind_of?(Array) ? links.flatten : nil end @@ -126,7 +125,7 @@ def self.screenshots_list(path, locale, device) end def self.upload_on_appaloosa(api_key, store_id, binary_path, screenshots, group_ids) - screenshots = all_screenshots_links screenshots + screenshots = all_screenshots_links(screenshots) response = HTTP.post("#{APPALOOSA_SERVER}/#{store_id}/applications/upload", json: { store_id: store_id, api_key: api_key, @@ -141,7 +140,7 @@ def self.upload_on_appaloosa(api_key, store_id, binary_path, screenshots, group_ provider: 'fastlane' } }) - json_res = JSON.parse response + json_res = JSON.parse(response) Helper.log.info "Binary processing: Check your app': #{json_res['link']}".green end @@ -189,7 +188,7 @@ def self.description end def self.details - 'You can use this action to do cool things...' + 'Appaloosa is a private mobile application store. This action offers a quick deployment on the platform. You can create an account, push to your existing account, or manage your user groups. We accept iOS and Android applications. Have questions? Contact support@appaloosa-store.com' end def self.available_options From 260168bea7b59e56b69354ec284bc85f09536a79 Mon Sep 17 00:00:00 2001 From: yoko yaeg Date: Thu, 12 Nov 2015 18:23:32 +0100 Subject: [PATCH 6/8] Remove extra line --- docs/Guide.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/Guide.md b/docs/Guide.md index a62d6b0872c..7c9b37f8ecf 100644 --- a/docs/Guide.md +++ b/docs/Guide.md @@ -28,8 +28,6 @@ Additionally, to an Xcode installation, you also need the Xcode command line too xcode-select --install - sudo xcodebuild -license accept - ### [fastlane](https://github.com/KrauseFx/fastlane) Install the gem and all its dependencies (this might take a few minutes). From 1397eeb0ea0aa2e68d16f1728b89d63594f0f444 Mon Sep 17 00:00:00 2001 From: yoko yaeg Date: Fri, 20 Nov 2015 11:43:04 +0100 Subject: [PATCH 7/8] Rename routes --- lib/fastlane/actions/appaloosa.rb | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/lib/fastlane/actions/appaloosa.rb b/lib/fastlane/actions/appaloosa.rb index f2c1e943ed9..f8f197ead88 100644 --- a/lib/fastlane/actions/appaloosa.rb +++ b/lib/fastlane/actions/appaloosa.rb @@ -1,7 +1,7 @@ module Fastlane module Actions class AppaloosaAction < Action - APPALOOSA_SERVER = 'http://appaloosa-int.herokuapp.com/api/v1' + APPALOOSA_SERVER = 'https://appaloosa-store.com/api/v1' def self.run(params) require 'http' @@ -32,12 +32,10 @@ def self.get_binary_link(binary, api_key, store_id, group_ids) def self.upload_on_s3(file, api_key, store_id, group_ids = '') file_name = file.split('/').last - response = HTTP.get("#{APPALOOSA_SERVER}/web_services/presign_form", + response = HTTP.get("#{APPALOOSA_SERVER}/upload_services/presign_form", json: { file: file_name, + store_id: store_id, group_ids: group_ids }) - if response.status == 404 - return nil if error_detected("A problem occurred with your API token and your store id. Please try again.") - end json_res = JSON.parse(response) return if error_detected json_res['errors'] url = json_res['s3_sign'] @@ -52,10 +50,13 @@ def self.upload_on_s3(file, api_key, store_id, group_ids = '') end def self.get_s3_url(api_key, store_id, path) - binary_path = HTTP.get("#{APPALOOSA_SERVER}/#{store_id}/web_services/url_for_download", + binary_path = HTTP.get("#{APPALOOSA_SERVER}/#{store_id}/upload_services/url_for_download", json: { store_id: store_id, api_key: api_key, key: path }) + if binary_path.status == 404 + return nil if error_detected("A problem occurred with your API token and your store id. Please try again.") + end json_res = JSON.parse(binary_path) return if error_detected(json_res['errors']) json_res['binary_url'] @@ -77,7 +78,7 @@ def self.normalize_binary_name(binary) end def self.create_an_account(email) - response = HTTP.post("#{APPALOOSA_SERVER}/web_services/create_an_account", form: { email: email }) + response = HTTP.post("#{APPALOOSA_SERVER}/upload_services/create_an_account", form: { email: email }) JSON.parse(response) end @@ -85,11 +86,11 @@ def self.request_email?(api_key, store_id) api_key.size == 0 && store_id.size == 0 end - def self.upload_screenshots(screenshots, store_id) + def self.upload_screenshots(screenshots, api_key, store_id) return if screenshots.nil? list = [] list << screenshots.map do |screen| - upload_on_s3(screen, store_id) + upload_on_s3(screen, api_key, store_id) end end @@ -104,7 +105,7 @@ def self.get_uploaded_links(uploaded_screenshots, api_key, store_id) def self.get_screenshots_links(api_key, store_id, screenshots_path, locale, device) screenshots = get_screenshots(screenshots_path, locale, device) return if screenshots.nil? - uploaded = upload_screenshots(screenshots, store_id) + uploaded = upload_screenshots(screenshots, api_key, store_id) links = get_uploaded_links(uploaded, api_key, store_id) links.kind_of?(Array) ? links.flatten : nil end @@ -141,7 +142,11 @@ def self.upload_on_appaloosa(api_key, store_id, binary_path, screenshots, group_ } }) json_res = JSON.parse(response) - Helper.log.info "Binary processing: Check your app': #{json_res['link']}".green + if json_res['errors'] + Helper.log.info "App: #{json_res['errors']}".red + else + Helper.log.info "Binary processing: Check your app': #{json_res['link']}".green + end end def self.all_screenshots_links(screenshots) From a1d4e24c40301f6baa89001a49ec53143c148251 Mon Sep 17 00:00:00 2001 From: yoko yaeg Date: Mon, 23 Nov 2015 11:53:41 +0100 Subject: [PATCH 8/8] Compete server address --- lib/fastlane/actions/appaloosa.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fastlane/actions/appaloosa.rb b/lib/fastlane/actions/appaloosa.rb index f8f197ead88..d600df1b722 100644 --- a/lib/fastlane/actions/appaloosa.rb +++ b/lib/fastlane/actions/appaloosa.rb @@ -1,7 +1,7 @@ module Fastlane module Actions class AppaloosaAction < Action - APPALOOSA_SERVER = 'https://appaloosa-store.com/api/v1' + APPALOOSA_SERVER = 'https://www.appaloosa-store.com/api/v1' def self.run(params) require 'http'