Class: Fastlane::Actions::HuaweiAppgalleryConnectUploadAssetsAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_upload_assets_action.rb

Class Method Summary collapse

Class Method Details

.available_optionsObject



26
27
28
29
30
31
32
33
34
35
# File 'lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_upload_assets_action.rb', line 26

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :client_id, env_name: 'HUAWEI_APPGALLERY_CONNECT_CLIENT_ID', description: 'Huawei AppGallery Connect Client ID', optional: false, type: String),
    FastlaneCore::ConfigItem.new(key: :client_secret, env_name: 'HUAWEI_APPGALLERY_CONNECT_CLIENT_SECRET', description: 'Huawei AppGallery Connect Client Secret', optional: false, type: String),
    FastlaneCore::ConfigItem.new(key: :app_id, env_name: 'HUAWEI_APPGALLERY_CONNECT_APP_ID', description: 'Huawei AppGallery Connect App ID', optional: false, type: String),
    FastlaneCore::ConfigItem.new(key: :asset_paths, env_name: 'HUAWEI_APPGALLERY_ASSET_PATHS', description: 'Asset file paths or directories', optional: false, type: Array),
    FastlaneCore::ConfigItem.new(key: :file_type, env_name: 'HUAWEI_APPGALLERY_ASSET_FILE_TYPE', description: 'Huawei Publishing API fileType (default: 5)', optional: true, default_value: 5, type: Integer),
    FastlaneCore::ConfigItem.new(key: :lang, env_name: 'HUAWEI_APPGALLERY_ASSET_LANGUAGE', description: 'Language tag for localized assets, for example en-US', optional: true, type: String)
  ]
end

.descriptionObject



22
23
24
# File 'lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_upload_assets_action.rb', line 22

def self.description
  'Upload app icons, screenshots, and other visual assets to Huawei AppGallery Connect'
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_upload_assets_action.rb', line 37

def self.is_supported?(platform)
  platform == :android
end

.run(params) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_upload_assets_action.rb', line 7

def self.run(params)
  token = Helper::HuaweiAppgalleryConnectHelper.get_token(params[:client_id], params[:client_secret])
  UI.user_error!('Cannot retrieve Huawei AppGallery Connect token') if token.nil?

  paths = Array(params[:asset_paths]).flat_map { |path| File.directory?(path) ? Dir[File.join(path, '*')] : path }
  UI.user_error!('Provide at least one asset path') if paths.empty?
  paths.each do |path|
    Helper::HuaweiAppgalleryConnectHelper.upload_asset(
      token, params[:client_id], params[:app_id], path,
      file_type: params[:file_type], lang: params[:lang]
    )
  end
  UI.success("Uploaded #{paths.length} AppGallery asset(s)")
end