Module: Fastlane::Helper::Ios::ADCAppSizesHelper
- Defined in:
- lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_adc_app_sizes_helper.rb
Constant Summary collapse
- DEFAULT_DEVICES =
['Universal', 'iPhone 8', 'iPhone X'].freeze
Class Method Summary collapse
- .format_csv(app_sizes, devices: nil) ⇒ Object
- .format_markdown(app_sizes, devices: nil) ⇒ Object
-
.get_adc_sizes(adc_user:, bundle_id:, adc_team: 'Automattic, Inc.', only_version: nil, limit: 10) ⇒ Array<Hash>
Fetch the App Sizes stats from ADC.
- .sz(bytes) ⇒ Object
- .sz_mb(bytes) ⇒ Object
Class Method Details
.format_csv(app_sizes, devices: nil) ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_adc_app_sizes_helper.rb', line 46 def self.format_csv(app_sizes, devices: nil) devices = DEFAULT_DEVICES if devices.nil? || devices.empty? csv = "Version\t#{devices.join("\t")}\n" app_sizes.each do |details| build_number = details['cfBundleVersion'] sizes = details['sizesInBytes'].select { |name, _| devices.include?(name) } csv += "#{build_number}\t" + devices.map { |d| sz(sizes[d]['compressed']) }.join("\t") + "\n" end csv end |
.format_markdown(app_sizes, devices: nil) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_adc_app_sizes_helper.rb', line 57 def self.format_markdown(app_sizes, devices: nil) devices = DEFAULT_DEVICES if devices.nil? || devices.empty? app_sizes.map do |details| build_number = details['cfBundleVersion'] sizes = details['sizesInBytes'].select { |name, _| devices.include?(name) } col_size = devices.map(&:length).max table = "| #{build_number.ljust(col_size)} | Download | Install |\n" table += "|:#{'-' * col_size}-|---------:|---------:|\n" sizes.each do |(device_name, size_info)| table += "| #{device_name.ljust(col_size)} | #{sz_mb(size_info['compressed'])} | #{sz_mb(size_info['uncompressed'])} |\n" end table end end |
.get_adc_sizes(adc_user:, bundle_id:, adc_team: 'Automattic, Inc.', only_version: nil, limit: 10) ⇒ Array<Hash>
Fetch the App Sizes stats from ADC
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_adc_app_sizes_helper.rb', line 16 def self.get_adc_sizes(adc_user:, bundle_id:, adc_team: 'Automattic, Inc.', only_version: nil, limit: 10) UI. 'Connecting to ADC...' Spaceship::ConnectAPI.login(adc_user, team_name: adc_team) app = Spaceship::ConnectAPI::App.find(bundle_id) UI. 'Fetching the list of versions...' versions = app.app_store_versions.select { |v| v.version_string == only_version && !v.build.nil? } versions = app.get_app_store_versions.reject { |v| v.build.nil? } if versions.empty? UI. "Found #{versions.count} versions." + (limit == 0 ? '' : " Limiting to last #{limit}") versions = versions.first(limit) unless limit == 0 UI. 'Fetching App Sizes...' builds_details = versions.each_with_index.map do |v, idx| print "Fetching info for: #{v.version_string.rjust(8)} (#{v.build.version.rjust(11)}) [#{idx.to_s.rjust(3)}/#{versions.count}]\r" Spaceship::Tunes.client.build_details(app_id: app.id, train: v.version_string, build_number: v.build.version, platform: 'ios') rescue nil end.compact.reverse print("#{' ' * 55}\n") builds_details end |
.sz(bytes) ⇒ Object
38 39 40 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_adc_app_sizes_helper.rb', line 38 def self.sz(bytes) (bytes.to_f / (1024 * 1024)).round(1) end |
.sz_mb(bytes) ⇒ Object
42 43 44 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_adc_app_sizes_helper.rb', line 42 def self.sz_mb(bytes) "#{sz(bytes).to_s.rjust(5)} MB" end |