Class: Fastlane::Actions::AnnaiDownloadFromPlayStoreAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::AnnaiDownloadFromPlayStoreAction
- Defined in:
- lib/fastlane/plugin/ann_flutter_flavor/actions/ann_download_from_play_store_action.rb
Overview
This class name dictates the action name ‘ann_download_from_play_store’
Class Method Summary collapse
-
.available_options ⇒ Object
—————————————————- Define Parameters —————————————————-.
- .description ⇒ Object
- .example_code ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .run(params) ⇒ Object
Class Method Details
.available_options ⇒ Object
Define Parameters
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/fastlane/plugin/ann_flutter_flavor/actions/ann_download_from_play_store_action.rb', line 122 def self. [ FastlaneCore::ConfigItem.new(key: :flavor, description: "The specific flavor(s) to download (comma-separated). If nil, all flavors are processed", optional: true, default_value: nil), FastlaneCore::ConfigItem.new(key: :spec_file, description: "Path to the annai spec configuration file (relative to flutter root). Defaults to standard discovery", optional: true, default_value: nil), FastlaneCore::ConfigItem.new(key: :api_key_path, description: "Path to the Google Service Account JSON file (Android). Optional if defined in the Annai spec", optional: true, default_value: nil), FastlaneCore::ConfigItem.new(key: :package_name, description: "The package name (Android). Optional if defined in the Annai spec", optional: true, default_value: nil), FastlaneCore::ConfigItem.new(key: :metadata_path, description: "The path where localization metadata (e.g., descriptions, titles) should be downloaded", optional: true, default_value: nil), ].compact end |
.description ⇒ Object
150 151 152 |
# File 'lib/fastlane/plugin/ann_flutter_flavor/actions/ann_download_from_play_store_action.rb', line 150 def self.description "Downloads store metadata for one or all flavors from the Google Play Store" end |
.example_code ⇒ Object
158 159 160 161 162 163 164 165 |
# File 'lib/fastlane/plugin/ann_flutter_flavor/actions/ann_download_from_play_store_action.rb', line 158 def self.example_code 'ann_download_from_play_store( flavor: "production", spec_file: "config/annai_config.yaml", # Optional custom spec path api_key_path: "./api_keys/google_play_key.json", package_name: "com.example.app", )' end |
.is_supported?(platform) ⇒ Boolean
154 155 156 |
# File 'lib/fastlane/plugin/ann_flutter_flavor/actions/ann_download_from_play_store_action.rb', line 154 def self.is_supported?(platform) platform == :android end |
.run(params) ⇒ Object
10 11 12 13 14 15 16 17 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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/fastlane/plugin/ann_flutter_flavor/actions/ann_download_from_play_store_action.rb', line 10 def self.run(params) # Platform is hardcoded to :android platform = :android action_name = "ann_download_from_play_store" requested_flavor = params[:flavor] spec_file = params[:spec_file] # 1. Initialize AnnaiLanes annai_lanes = FastlaneFlutterFlavor::AnnaiLanes.new( lane: self, platform: platform, # Pass platform symbol directly spec_file: spec_file # Pass optional spec_file ) # Get the StatusManager and SpecLoader instances status_manager = annai_lanes.instance_variable_get(:@statusManager) spec_loader = annai_lanes.instance_variable_get(:@specLoader) UI.user_error!("Internal Error: AnnaiLanes failed to initialize specLoader") unless spec_loader # Flag to track if any flavor download failed any_download_failed = false # 2. Get the list of all flavors defined for the platform flavors_hash = spec_loader.get_platform_flavors(platform) if flavors_hash.empty? UI.important("No flavors found for Android in the Annai spec. Nothing to download") annai_lanes.finalize return end all_flavor_names = flavors_hash.keys # 3. Determine which flavors to download if requested_flavor && !requested_flavor.to_s.empty? requested_flavors = requested_flavor.to_s.split(',').map(&:strip).reject(&:empty?) # Validate all requested flavors invalid_flavors = requested_flavors.reject { |f| all_flavor_names.include?(f) } if invalid_flavors.any? UI.user_error!("The following requested flavor(s) are not found in the Annai spec for Android: #{invalid_flavors.join(', ')}. Available flavors: #{all_flavor_names.join(', ')}") end flavors_to_download = requested_flavors else # No specific flavor requested, download all of them flavors_to_download = all_flavor_names end UI.header("Starting Google Play download. Flavors to process: #{flavors_to_download.join(', ')}") # 4. Loop through each flavor and download flavors_to_download.each do |flavor_key| flavor = flavor_key # spec_loader.get_package_id handles the package_name final_api_key_path = spec_loader.get_api_key_path(platform, flavor) || params[:api_key_path] final_package_name = spec_loader.get_package_id(platform, flavor) || params[:package_name] UI.("⬇️ Downloading store content for **#{flavor}** flavor...") begin success = annai_lanes.download_from_store( package_name: final_package_name, api_key_path: final_api_key_path, flavor: flavor, platform: platform.to_s, # Android only needs metadata path metadata_path: params[:metadata_path], screenshots_path: nil, # Omitted for Android download action use_live_version: nil, # Omitted for Android download action distribution_platform: nil # Omitted for Android download action ) if success UI.success("✅ Successfully downloaded store content for flavor: #{flavor}") else # If download_from_store returns false (meaning it caught an error and logged it), flag the overall failure. # We only raise/log here if the inner action didn't handle it, to ensure logging consistency. if !status_manager.instance_variable_get(:@status).key?([flavor, "download_from_store", platform.to_s]) raise "Download failed for flavor '#{flavor}'" else raise "Download failed for flavor '#{flavor}' (error logged previously)" end end rescue => e # Failure handling: Log the error and continue status_manager.logError(flavor, action_name, platform, e.) unless status_manager.instance_variable_get(:@status).key?([flavor, "download_from_store", platform.to_s]) UI.error("❌ Failed to download content for flavor: #{flavor}. Continuing to next flavor...") any_download_failed = true # Continue to the next flavor end end # 5. Final Reporting and Status Check annai_lanes.finalize if any_download_failed UI.user_error!("Download failed for one or more flavors. See the Annai Fastlane summary above") else UI.success("🎉 Successfully downloaded Google Play content for all #{flavors_to_download.count} requested flavor(s)!") end end |