supply/lib/supply/setup.rb in fastlane-2.134.0 vs supply/lib/supply/setup.rb in fastlane-2.135.0
- old
+ new
@@ -10,20 +10,26 @@
client.begin_edit(package_name: Supply.config[:package_name])
client.listings.each do |listing|
store_metadata(listing)
- create_screenshots_folder(listing)
download_images(listing)
end
- client.apks_version_codes.each do |apk_version_code|
- client.apk_listings(apk_version_code).each do |apk_listing|
- store_apk_listing(apk_listing)
+ if Supply.config[:version_name].to_s == ""
+ latest_version = client.latest_version(Supply.config[:track])
+ if latest_version
+ Supply.config[:version_name] = latest_version.name
+ else
+ UI.user_error!("Could not find the latest version to download metadata, images, and screenshots from")
end
end
+ client.release_listings(Supply.config[:version_name]).each do |release_listing|
+ store_release_listing(release_listing)
+ end
+
client.abort_current_edit
UI.success("✅ Successfully stored metadata in '#{metadata_path}'")
end
@@ -41,59 +47,61 @@
end
def download_images(listing)
UI.message("🖼️ Downloading images (#{listing.language})")
- # We cannot download existing screenshots as they are compressed
- # But we can at least download the images
require 'net/http'
- IMAGES_TYPES.each do |image_type|
- if ['featureGraphic'].include?(image_type)
- # we don't get all files in full resolution :(
- UI.message("📵 Due to a limitation of the Google Play API, there is no way for `supply` to download your existing feature graphic. Please copy your feature graphic to `metadata/android/#{listing.language}/images/featureGraphic.png`")
- next
- end
+ allowed_imagetypes = [Supply::IMAGES_TYPES, Supply::SCREENSHOT_TYPES].flatten
+ allowed_imagetypes.each do |image_type|
begin
+ path = File.join(metadata_path, listing.language, IMAGES_FOLDER_NAME, image_type)
+
+ p = Pathname.new(path)
+ if IMAGES_TYPES.include?(image_type) # IMAGE_TYPES are stored in locale/images location
+ FileUtils.mkdir_p(p.dirname.to_s)
+ else # SCREENSHOT_TYPES go under their respective folders.
+ FileUtils.mkdir_p(p.to_s)
+ end
+
UI.message("Downloading `#{image_type}` for #{listing.language}...")
- url = client.fetch_images(image_type: image_type, language: listing.language).last
- next unless url
+ urls = client.fetch_images(image_type: image_type, language: listing.language)
+ next if urls.nil? || urls.empty?
- path = File.join(metadata_path, listing.language, IMAGES_FOLDER_NAME, "#{image_type}.png")
- File.write(path, Net::HTTP.get(URI.parse(url)))
+ image_counter = 1 # Used to prefix the downloaded files, so order is preserved.
+ urls.each do |url|
+ if IMAGES_TYPES.include?(image_type) # IMAGE_TYPES are stored in locale/images
+ file_path = "#{path}.#{FastImage.type(url)}"
+ else # SCREENSHOT_TYPES are stored in locale/images/<screensho_types>
+ file_path = File.join(path, "#{image_counter}_#{listing.language}.#{FastImage.type(url)}")
+ end
+
+ File.binwrite(file_path, Net::HTTP.get(URI.parse(url)))
+
+ UI.message("\tDownloaded - #{file_path}")
+
+ image_counter += 1
+ end
rescue => ex
UI.error(ex.to_s)
UI.error("Error downloading '#{image_type}' for #{listing.language}...")
end
end
end
- def create_screenshots_folder(listing)
- UI.message("📱 Downloading screenshots (#{listing.language})")
+ def store_release_listing(release_listing)
+ UI.message("🔨 Downloading changelogs (#{release_listing.language}, #{release_listing.version})")
- containing = File.join(metadata_path, listing.language)
-
- FileUtils.mkdir_p(File.join(containing, IMAGES_FOLDER_NAME))
- Supply::SCREENSHOT_TYPES.each do |screenshot_type|
- FileUtils.mkdir_p(File.join(containing, IMAGES_FOLDER_NAME, screenshot_type))
- end
-
- UI.message("📵 Due to a limitation of the Google Play API, there is no way for `supply` to download your existing screenshots. Please copy your screenshots into `metadata/android/#{listing.language}/images/`")
- end
-
- def store_apk_listing(apk_listing)
- UI.message("🔨 Downloading changelogs (#{apk_listing.language}, #{apk_listing.apk_version_code})")
-
- containing = File.join(metadata_path, apk_listing.language, CHANGELOGS_FOLDER_NAME)
+ containing = File.join(metadata_path, release_listing.language, CHANGELOGS_FOLDER_NAME)
unless File.exist?(containing)
FileUtils.mkdir_p(containing)
end
- path = File.join(containing, "#{apk_listing.apk_version_code}.txt")
+ path = File.join(containing, "#{release_listing.version}.txt")
UI.message("Writing to #{path}...")
- File.write(path, apk_listing.recent_changes)
+ File.write(path, release_listing.release_notes)
end
private
def metadata_path