Class: Fastlane::Actions::FirebaseManagementApiListAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



50
51
52
# File 'lib/fastlane/plugin/firebase_management_api/actions/firebase_list_action.rb', line 50

def self.authors
	["Ackee, s.r.o."]
end

.available_optionsObject



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/fastlane/plugin/firebase_management_api/actions/firebase_list_action.rb', line 63

def self.available_options
	[
		FastlaneCore::ConfigItem.new(key: :email,
								env_name: "FIREBASE_EMAIL",
							 description: "User's email to identify stored credentials",
								optional: true),

		FastlaneCore::ConfigItem.new(key: :client_secret_json_path,
								env_name: "FIREBASE_CLIENT_SECRET_JSON_PATH",
							 description: "Path to client secret json file",
								optional: true),

		FastlaneCore::ConfigItem.new(key: :service_account_json_path,
								env_name: "FIREBASE_SERVICE_ACCOUNT_JSON_PATH",
							 description: "Path to service account json key",
								optional: true
		)
	]
end

.descriptionObject



46
47
48
# File 'lib/fastlane/plugin/firebase_management_api/actions/firebase_list_action.rb', line 46

def self.description
	"List all Firebase projects and their apps"
end

.detailsObject



58
59
60
61
# File 'lib/fastlane/plugin/firebase_management_api/actions/firebase_list_action.rb', line 58

def self.details
	# Optional:
	"Firebase plugin helps you list your projects, create applications and download configuration files."
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


83
84
85
86
87
88
89
# File 'lib/fastlane/plugin/firebase_management_api/actions/firebase_list_action.rb', line 83

def self.is_supported?(platform)
	# Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
	# See: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md
	#
	# [:ios, :mac, :android].include?(platform)
	true
end

.return_valueObject



54
55
56
# File 'lib/fastlane/plugin/firebase_management_api/actions/firebase_list_action.rb', line 54

def self.return_value
	# If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



5
6
7
8
9
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
# File 'lib/fastlane/plugin/firebase_management_api/actions/firebase_list_action.rb', line 5

def self.run(params)
	manager = FirebaseManagementApi::Manager.new

	# login
	api = nil
	if params[:service_account_json_path] != nil then
		api = manager.serviceAccountLogin(params[:service_account_json_path])
	elsif params[:email] != nil && params[:client_secret_json_path] != nil then
		api = manager.userLogin(params[:email], params[:client_secret_json_path])
	else
		UI.error "You must define service_account_json_path or email with client_secret_json_path."
		return nil
	end

	# download list of projects
	projects = api.project_list()

	# create formatted output
	projects.each_with_index { |p, i| 
		UI.message "#{i+1}. #{p["displayName"]} (#{p["projectId"]})" 
		
		ios_apps = api.ios_app_list(p["projectId"])
		if !ios_apps.empty? then
			UI.message "  iOS"
			ios_apps.sort {|left, right| left["appId"] <=> right["appId"] }.each_with_index { |app, j|
				UI.message "  - #{app["displayName"] || app["bundleId"]} (#{app["appId"]})" 
			}
		end

		android_apps = api.android_app_list(p["projectId"])
		if !android_apps.empty? then
			UI.message "  Android"
			android_apps.sort {|left, right| left["appId"] <=> right["appId"] }.each_with_index { |app, j|
				UI.message "  - #{app["displayName"] || app["packageName"]} (#{app["appId"]})" 
			}
		end
	}

	return nil
end