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
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_adc_app_sizes_helper.rb', line 52 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'].slice(*devices) csv += "#{build_number}\t" + devices.map { |d| sz(sizes[d]['compressed']) }.join("\t") + "\n" end csv end |
.format_markdown(app_sizes, devices: nil) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_adc_app_sizes_helper.rb', line 63 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'].slice(*devices) 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
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_adc_app_sizes_helper.rb', line 18 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.zero? ? '' : " Limiting to last #{limit}") versions = versions.first(limit) unless limit.zero? 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" begin Spaceship::Tunes.client.build_details(app_id: app.id, train: v.version_string, build_number: v.build.version, platform: 'ios') rescue StandardError nil end end.compact.reverse print("#{' ' * 55}\n") builds_details end |
.sz(bytes) ⇒ Object
44 45 46 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_adc_app_sizes_helper.rb', line 44 def self.sz(bytes) (bytes.to_f / (1024 * 1024)).round(1) end |
.sz_mb(bytes) ⇒ Object
48 49 50 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_adc_app_sizes_helper.rb', line 48 def self.sz_mb(bytes) "#{sz(bytes).to_s.rjust(5)} MB" end |