Class: Fastlane::Actions::FirebaseAppDistributionGetUdidsAction

Inherits:
Action
  • Object
show all
Extended by:
Fastlane::Auth::FirebaseAppDistributionAuthClient, Helper::FirebaseAppDistributionHelper
Defined in:
lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_udids.rb

Constant Summary

Constants included from Fastlane::Auth::FirebaseAppDistributionAuthClient

Fastlane::Auth::FirebaseAppDistributionAuthClient::CLIENT_ID, Fastlane::Auth::FirebaseAppDistributionAuthClient::CLIENT_SECRET, Fastlane::Auth::FirebaseAppDistributionAuthClient::REDACTION_CHARACTER, Fastlane::Auth::FirebaseAppDistributionAuthClient::REDACTION_EXPOSED_LENGTH, Fastlane::Auth::FirebaseAppDistributionAuthClient::SCOPE, Fastlane::Auth::FirebaseAppDistributionAuthClient::TOKEN_CREDENTIAL_URI

Class Method Summary collapse

Methods included from Fastlane::Auth::FirebaseAppDistributionAuthClient

get_authorization

Methods included from Helper::FirebaseAppDistributionHelper

app_id_from_params, app_name_from_app_id, binary_type_from_path, blank?, deep_symbolize_keys, get_ios_app_id_from_archive_plist, get_ios_app_id_from_plist, get_value_from_value_or_file, group_name, init_google_api_client, lane_platform, parse_plist, present?, project_name, project_number_from_app_id, string_to_array, xcode_archive_path

Class Method Details

.authorsObject



54
55
56
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_udids.rb', line 54

def self.authors
  ["Lee Kellogg"]
end

.available_optionsObject



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
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_udids.rb', line 63

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :project_number,
                                 conflicting_options: [:app],
                                 env_name: "FIREBASEAPPDISTRO_PROJECT_NUMBER",
                                 description: "Your Firebase project number. You can find the project number in the Firebase console, on the General Settings page",
                                 type: Integer,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :app,
                                 conflicting_options: [:project_number],
                                 env_name: "FIREBASEAPPDISTRO_APP",
                                 description: "Your app's Firebase App ID. You can find the App ID in the Firebase console, on the General Settings page",
                                 optional: true,
                                 deprecated: "Use project_number (FIREBASEAPPDISTRO_PROJECT_NUMBER) instead",
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :output_file,
                                 env_name: "FIREBASEAPPDISTRO_OUTPUT_FILE",
                                 description: "The path to the file where the tester UDIDs will be written",
                                 optional: false,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :firebase_cli_token,
                                 description: "Auth token generated using the Firebase CLI's login:ci command",
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :service_credentials_file,
                                 description: "Path to Google service account json",
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :service_credentials_json_data,
                                 description: "Google service account json file content",
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :debug,
                                 description: "Print verbose debug output",
                                 optional: true,
                                 default_value: false,
                                 is_string: false)
  ]
end

.descriptionObject



50
51
52
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_udids.rb', line 50

def self.description
  "Download the UDIDs of your Firebase App Distribution testers"
end

.detailsObject

supports markdown.



59
60
61
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_udids.rb', line 59

def self.details
  "Export your testers' device identifiers in a CSV file, so you can add them your provisioning profile. This file can be imported into your Apple developer account using the Register Multiple Devices option. See the [App Distribution docs](https://firebase.google.com/docs/app-distribution/ios/distribute-console#register-tester-devices) for more info."
end

.example_codeObject



107
108
109
110
111
112
113
114
115
116
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_udids.rb', line 107

def self.example_code
  [
    <<-CODE
      firebase_app_distribution_get_udids(
        app: "<your Firebase app ID>",
        output_file: "tester_udids.txt",
      )
    CODE
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


103
104
105
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_udids.rb', line 103

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

.run(params) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_udids.rb', line 17

def self.run(params)
  init_google_api_client(params[:debug])
  client = Google::Apis::FirebaseappdistributionV1alpha::FirebaseAppDistributionService.new
  client.authorization = get_authorization(params[:service_credentials_file], params[:firebase_cli_token], params[:service_credentials_json_data], params[:debug])

  project_number = params[:project_number]
  if blank?(project_number)
    app_id = params[:app]
    if blank?(app_id)
      UI.user_error!("Must specify `project_number`.")
    end
    project_number = project_number_from_app_id(app_id)
  end
  udids = client.get_project_tester_udids(project_name(project_number)).tester_udids

  if udids.to_a.empty?
    File.delete(params[:output_file]) if File.exist?(params[:output_file])
    UI.important("App Distribution fetched 0 tester UDIDs. Removed output file.")
  else
    write_udids_to_file(udids, params[:output_file])
    UI.success("🎉 App Distribution tester UDIDs written to: #{params[:output_file]}")
  end
end

.write_udids_to_file(udids, output_file) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_udids.rb', line 41

def self.write_udids_to_file(udids, output_file)
  File.open(output_file, 'w') do |f|
    f.write("Device ID\tDevice Name\tDevice Platform\n")
    udids.each do |tester_udid|
      f.write("#{tester_udid.udid}\t#{tester_udid.name}\t#{tester_udid.platform}\n")
    end
  end
end