Class: Fastlane::Actions::ExtractAppNameAction

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

Class Method Summary collapse

Class Method Details

.authorObject



84
85
86
# File 'lib/fastlane/plugin/polidea/actions/extract_app_name.rb', line 84

def self.author
  "Piotrek Dubiel"
end

.available_optionsObject



63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/fastlane/plugin/polidea/actions/extract_app_name.rb', line 63

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :ipa,
                                 env_name: "",
                                 description: ".ipa file to extract icon",
                                 optional: true,
                                 default_value: Actions.lane_context[SharedValues::IPA_OUTPUT_PATH]),
    FastlaneCore::ConfigItem.new(key: :apk,
                                 env_name: "",
                                 description: ".apk file to extract icon",
                                 optional: true,
                                 default_value: Actions.lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH])
  ]
end

.categoryObject



92
93
94
# File 'lib/fastlane/plugin/polidea/actions/extract_app_name.rb', line 92

def self.category
  :deprecated
end

.descriptionObject



59
60
61
# File 'lib/fastlane/plugin/polidea/actions/extract_app_name.rb', line 59

def self.description
  "Extracts application name from .apk/.ipa, use `extract_app_info` instead"
end

.extract_app_name(platform, config) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/fastlane/plugin/polidea/actions/extract_app_name.rb', line 26

def self.extract_app_name(platform, config)
  case platform
  when :ios
    extract_name_from_ipa(config[:ipa]) if validate_ios(config)
  when :android
    extract_name_from_apk(config[:apk]) if validate_android(config)
  end
end

.extract_name_from_apk(apk_file) ⇒ Object



54
55
56
57
# File 'lib/fastlane/plugin/polidea/actions/extract_app_name.rb', line 54

def self.extract_name_from_apk(apk_file)
  apk = Android::Apk.new(apk_file)
  apk.manifest.label
end

.extract_name_from_ipa(ipa_file) ⇒ Object



42
43
44
45
# File 'lib/fastlane/plugin/polidea/actions/extract_app_name.rb', line 42

def self.extract_name_from_ipa(ipa_file)
  info = FastlaneCore::IpaFileAnalyser.fetch_info_plist_file(ipa_file)
  info['CFBundleDisplayName'] || info['CFBundleName']
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


88
89
90
# File 'lib/fastlane/plugin/polidea/actions/extract_app_name.rb', line 88

def self.is_supported?(platform)
  [:ios, :android].include? platform
end

.outputObject



78
79
80
81
82
# File 'lib/fastlane/plugin/polidea/actions/extract_app_name.rb', line 78

def self.output
  [
    ['APP_NAME', 'App name extracted from .ipa/.apk']
  ]
end

.run(config) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fastlane/plugin/polidea/actions/extract_app_name.rb', line 12

def self.run(config)
  platform = Actions.lane_context[Actions::SharedValues::PLATFORM_NAME].to_sym

  # Gets name from ipa/apk
  app_name = extract_app_name(platform, config)

  Actions.lane_context[SharedValues::APP_NAME] = app_name
  ENV[SharedValues::APP_NAME.to_s] = app_name

  UI.success("Successfully extracted app name: '#{Actions.lane_context[SharedValues::APP_NAME]}'")

  app_name
end

.validate_android(config) ⇒ Object

android specific



49
50
51
52
# File 'lib/fastlane/plugin/polidea/actions/extract_app_name.rb', line 49

def self.validate_android(config)
  UI.user_error!("No APK file path given, pass using `apk: 'apk path'`") unless config[:apk].to_s.length > 0
  true
end

.validate_ios(config) ⇒ Object

ios specific



37
38
39
40
# File 'lib/fastlane/plugin/polidea/actions/extract_app_name.rb', line 37

def self.validate_ios(config)
  UI.user_error!("No IPA file path given, pass using `ipa: 'ipa path'`") unless config[:ipa].to_s.length > 0
  true
end