Module: Fastlane::Helper::FirebaseAppDistributionHelper

Instance Method Summary collapse

Instance Method Details

#app_name_from_app_id(app_id) ⇒ Object



56
57
58
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 56

def app_name_from_app_id(app_id)
  "#{project_name(app_id.split(':')[1])}/apps/#{app_id}"
end

#binary_type_from_path(binary_path) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 7

def binary_type_from_path(binary_path)
  extension = File.extname(binary_path)
  return :APK if extension == '.apk'
  return :AAB if extension == '.aab'
  return :IPA if extension == '.ipa'

  UI.user_error!("Unsupported distribution file format, should be .ipa, .apk or .aab")
end

#blank?(value) ⇒ Boolean

Returns:

  • (Boolean)


47
48
49
50
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 47

def blank?(value)
  # Taken from https://apidock.com/rails/Object/blank%3F
  value.respond_to?(:empty?) ? value.empty? : !value
end

#deep_symbolize_keys(hash) ⇒ Object



81
82
83
84
85
86
87
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 81

def deep_symbolize_keys(hash)
  result = {}
  hash.each do |key, value|
    result[key.to_sym] = value.kind_of?(Hash) ? deep_symbolize_keys(value) : value
  end
  result
end

#get_ios_app_id_from_archive_plist(archive_path, plist_path) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 39

def get_ios_app_id_from_archive_plist(archive_path, plist_path)
  app_path = parse_plist("#{archive_path}/Info.plist")["ApplicationProperties"]["ApplicationPath"]
  UI.shell_error!("can't extract application path from Info.plist at #{archive_path}") if app_path.empty?
  identifier = parse_plist("#{archive_path}/Products/#{app_path}/#{plist_path}")["GOOGLE_APP_ID"]
  UI.shell_error!("can't extract GOOGLE_APP_ID") if identifier.empty?
  return identifier
end

#get_value_from_value_or_file(value, path) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 16

def get_value_from_value_or_file(value, path)
  if (value.nil? || value.empty?) && !path.nil?
    begin
      return File.open(path).read
    rescue Errno::ENOENT
      UI.crash!("#{ErrorMessage::INVALID_PATH}: #{path}")
    end
  end
  value
end

#group_name(project_number, group_alias) ⇒ Object



64
65
66
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 64

def group_name(project_number, group_alias)
  "#{project_name(project_number)}/groups/#{group_alias}"
end

#init_client(service_credentials_file, firebase_cli_token, debug = false) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 68

def init_client(service_credentials_file, firebase_cli_token, debug = false)
  if debug
    UI.important("Warning: Debug logging enabled. Output may include sensitive information.")
    Google::Apis.logger.level = Logger::DEBUG
  end

  Google::Apis::ClientOptions.default.application_name = "fastlane"
  Google::Apis::ClientOptions.default.application_version = Fastlane::FirebaseAppDistribution::VERSION
  client = Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService.new
  client.authorization = get_authorization(service_credentials_file, firebase_cli_token)
  client
end

#parse_plist(path) ⇒ Object



35
36
37
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 35

def parse_plist(path)
  CFPropertyList.native_types(CFPropertyList::List.new(file: path).value)
end

#present?(value) ⇒ Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 52

def present?(value)
  !blank?(value)
end

#project_name(project_number) ⇒ Object



60
61
62
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 60

def project_name(project_number)
  "projects/#{project_number}"
end

#string_to_array(string) ⇒ Object

Returns the array representation of a string with trimmed comma seperated values.



29
30
31
32
33
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 29

def string_to_array(string)
  return [] if string.nil?
  # Strip string and then strip individual values
  string.strip.split(",").map(&:strip)
end