Module: FIR::Publish
- Included in:
- Util::ClassMethods
- Defined in:
- lib/fir/util/publish.rb
Instance Method Summary collapse
- #binary_information ⇒ Object
- #fetch_app_info ⇒ Object
- #fetch_release_id ⇒ Object
- #fetch_uploading_info ⇒ Object
- #icon_information ⇒ Object
- #logger_info_app_short_and_qrcode(options) ⇒ Object
- #logger_info_publishing_message ⇒ Object
- #publish(*args, options) ⇒ Object
- #update_app_info ⇒ Object
- #upload_app ⇒ Object
- #upload_device_info ⇒ Object
- #upload_file(postfix) ⇒ Object
- #upload_mapping_file_with_publish(options) ⇒ Object
- #uploading_binary_info ⇒ Object
- #uploading_icon_info ⇒ Object
Instance Method Details
#binary_information ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/fir/util/publish.rb', line 92 def binary_information { build: @app_info[:build], fname: File.basename(@file_path), key: @binary_cert[:key], name: @app_info[:display_name] || @app_info[:name], origin: 'fir-cli', parent_id: @app_id, release_tag: 'develop', fsize: File.size(@file_path), release_type: @app_info[:release_type], distribution_name: @app_info[:distribution_name], token: @binary_cert[:token], version: @app_info[:version], changelog: @changelog, user_id: @user_info[:id] }.reject { |x| x.nil? || x == '' } end |
#fetch_app_info ⇒ Object
160 161 162 163 164 165 166 |
# File 'lib/fir/util/publish.rb', line 160 def fetch_app_info logger.info 'Fetch app info from fir.im' @fir_app_info = get(fir_api[:app_url] + "/#{@app_id}", api_token: @token) write_app_info(id: @fir_app_info[:id], short: @fir_app_info[:short], name: @fir_app_info[:name]) @fir_app_info end |
#fetch_release_id ⇒ Object
156 157 158 |
# File 'lib/fir/util/publish.rb', line 156 def fetch_release_id get "#{fir_api[:base_url]}/apps/#{@app_id}/releases/find_release_by_key", api_token: @token, key: @binary_cert[:key] end |
#fetch_uploading_info ⇒ Object
146 147 148 149 150 151 152 153 154 |
# File 'lib/fir/util/publish.rb', line 146 def fetch_uploading_info logger.info "Fetching #{@app_info[:identifier]}@fir.im uploading info......" logger.info "Uploading app: #{@app_info[:name]}-#{@app_info[:version]}(Build #{@app_info[:build]})" post fir_api[:app_url], type: @app_info[:type], bundle_id: @app_info[:identifier], manual_callback: true, api_token: @token end |
#icon_information ⇒ Object
81 82 83 84 85 86 87 88 89 90 |
# File 'lib/fir/util/publish.rb', line 81 def icon_information { key: @icon_cert[:key], token: @icon_cert[:token], origin: 'fir-cli', parent_id: @app_id, fsize: File.size(@uncrushed_icon_path), fname: 'blob' } end |
#logger_info_app_short_and_qrcode(options) ⇒ Object
179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/fir/util/publish.rb', line 179 def logger_info_app_short_and_qrcode() @download_url = "#{fir_api[:domain]}/#{@fir_app_info[:short]}" @download_url += "?release_id=#{@app_uploaded_callback_data[:release_id]}" if !![:need_release_id] logger.info "Published succeed: #{@download_url}" @qrcode_path = "#{File.dirname(@file_path)}/fir-#{@app_info[:name]}.png" FIR.generate_rqrcode(@download_url, @qrcode_path) logger.info "Local qrcode file: #{@qrcode_path}" if @export_qrcode end |
#logger_info_publishing_message ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/fir/util/publish.rb', line 26 def user_info = fetch_user_info(@token) email = user_info.fetch(:email, '') name = user_info.fetch(:name, '') logger.info "Publishing app via #{name}<#{email}>......." logger_info_dividing_line end |
#publish(*args, options) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fir/util/publish.rb', line 4 def publish(*args, ) (args, ) check_supported_file_and_token @app_info = send("#{@file_type}_info", @file_path, full_info: true) @user_info = fetch_user_info(@token) @uploading_info = fetch_uploading_info @app_id = @uploading_info[:id] upload_app logger_info_dividing_line logger_info_app_short_and_qrcode() dingtalk_notifier() upload_mapping_file_with_publish() logger_info_blank_line clean_files end |
#update_app_info ⇒ Object
136 137 138 139 140 141 142 143 144 |
# File 'lib/fir/util/publish.rb', line 136 def update_app_info update_info = { short: @short, passwd: @passwd, is_opened: @is_opened }.compact return if update_info.blank? logger.info 'Updating app info......' patch fir_api[:app_url] + "/#{@app_id}", update_info.merge(api_token: @token) end |
#upload_app ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/fir/util/publish.rb', line 36 def upload_app @icon_cert = @uploading_info[:cert][:icon] @binary_cert = @uploading_info[:cert][:binary] upload_app_icon unless @app_info[:icons].blank? @app_uploaded_callback_data = upload_app_binary logger.info "App id is #{@app_id}" logger.info "Release id is #{@app_uploaded_callback_data[:release_id]}" upload_device_info update_app_info fetch_app_info end |
#upload_device_info ⇒ Object
126 127 128 129 130 131 132 133 134 |
# File 'lib/fir/util/publish.rb', line 126 def upload_device_info return if @app_info[:devices].blank? logger.info 'Updating devices info......' post fir_api[:udids_url], key: @binary_cert[:key], udids: @app_info[:devices].join(','), api_token: @token end |
#upload_file(postfix) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/fir/util/publish.rb', line 57 def upload_file(postfix) logger.info "Uploading app #{postfix}......" url = @uploading_info[:cert][postfix.to_sym][:upload_url] info = send("uploading_#{postfix}_info") logger.debug "url = #{url}, info = #{info}" uploaded_info = post(url, info.merge(manual_callback: true), params_to_json: false, header: nil) rescue StandardError logger.error "Uploading app #{postfix} failed" exit 1 end |
#upload_mapping_file_with_publish(options) ⇒ Object
168 169 170 171 172 173 174 175 176 177 |
# File 'lib/fir/util/publish.rb', line 168 def upload_mapping_file_with_publish() return if ![:mappingfile] || ![:proj] logger_info_blank_line mapping [:mappingfile], proj: [:proj], build: @app_info[:build], version: @app_info[:version], token: @token end |
#uploading_binary_info ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/fir/util/publish.rb', line 111 def uploading_binary_info { key: @binary_cert[:key], token: @binary_cert[:token], file: File.new(@file_path, 'rb'), # Custom variables 'x:name' => @app_info[:display_name] || @app_info[:name], 'x:build' => @app_info[:build], 'x:version' => @app_info[:version], 'x:changelog' => @changelog, 'x:release_type' => @app_info[:release_type], 'x:distribution_name' => @app_info[:distribution_name] } end |
#uploading_icon_info ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/fir/util/publish.rb', line 70 def uploading_icon_info large_icon_path = @app_info[:icons].max_by { |f| File.size(f) } @uncrushed_icon_path = convert_icon(large_icon_path) { key: @icon_cert[:key], token: @icon_cert[:token], file: File.new(@uncrushed_icon_path, 'rb'), 'x:is_converted' => '1' } end |