fastlane-plugin-firebase_management 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/fastlane/plugin/firebase_management/actions/firebase_add_app_action.rb +20 -2
- data/lib/fastlane/plugin/firebase_management/actions/firebase_download_config_action.rb +24 -2
- data/lib/fastlane/plugin/firebase_management/actions/firebase_list_action.rb +24 -13
- data/lib/fastlane/plugin/firebase_management/lib/api.rb +1 -10
- data/lib/fastlane/plugin/firebase_management/lib/manager.rb +42 -7
- data/lib/fastlane/plugin/firebase_management/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3adaab65a73979fa08b173d84889365da61fdb15f548ad5b83e7d54fc18979fd
|
4
|
+
data.tar.gz: 3782786d5e38e74ac69f07625d07119b726ac43d6e4953843d745440f9f8b7f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 433f1186d577d4482340978e34f2cb312ddc0a4da523909e20d1c55f96de19a3781d251dc19b2b02017486f99ed374286d7d6df03696d83a3a88e6ffdc1675e0
|
7
|
+
data.tar.gz: 5b01e928ebc18d00836f7995b206b51ad67d2908be74b91209b4a327de939122f4187daddce288fe0a7423f80bec3b45de1ef8a9e9e66872ef27b7289f91baa5
|
@@ -6,7 +6,15 @@ module Fastlane
|
|
6
6
|
manager = FirebaseManagement::Manager.new
|
7
7
|
|
8
8
|
# login
|
9
|
-
api =
|
9
|
+
api = nil
|
10
|
+
if params[:service_account_json_path] != nil then
|
11
|
+
api = manager.serviceAccountLogin(params[:service_account_json_path])
|
12
|
+
elsif params[:email] != nil && params[:client_secret_json_path] != nil then
|
13
|
+
api = manager.userLogin(params[:email], params[:client_secret_json_path])
|
14
|
+
else
|
15
|
+
UI.error "You must define service_account_json_path or email with client_secret_json_path."
|
16
|
+
return nil
|
17
|
+
end
|
10
18
|
|
11
19
|
# select project
|
12
20
|
project_id = params[:project_id] || manager.select_project(nil)["projectId"]
|
@@ -88,10 +96,20 @@ module Fastlane
|
|
88
96
|
|
89
97
|
def self.available_options
|
90
98
|
[
|
99
|
+
FastlaneCore::ConfigItem.new(key: :email,
|
100
|
+
env_name: "FIREBASE_EMAIL",
|
101
|
+
description: "User's email to identify stored credentials",
|
102
|
+
optional: true),
|
103
|
+
|
104
|
+
FastlaneCore::ConfigItem.new(key: :client_secret_json_path,
|
105
|
+
env_name: "FIREBASE_CLIENT_SECRET_JSON_PATH",
|
106
|
+
description: "Path to client secret json file",
|
107
|
+
optional: true),
|
108
|
+
|
91
109
|
FastlaneCore::ConfigItem.new(key: :service_account_json_path,
|
92
110
|
env_name: "FIREBASE_SERVICE_ACCOUNT_JSON_PATH",
|
93
111
|
description: "Path to service account json key",
|
94
|
-
optional:
|
112
|
+
optional: true),
|
95
113
|
|
96
114
|
FastlaneCore::ConfigItem.new(key: :project_id,
|
97
115
|
env_name: "FIREBASE_PROJECT_ID",
|
@@ -6,7 +6,15 @@ module Fastlane
|
|
6
6
|
manager = FirebaseManagement::Manager.new
|
7
7
|
|
8
8
|
# login
|
9
|
-
api =
|
9
|
+
api = nil
|
10
|
+
if params[:service_account_json_path] != nil then
|
11
|
+
api = manager.serviceAccountLogin(params[:service_account_json_path])
|
12
|
+
elsif params[:email] != nil && params[:client_secret_json_path] != nil then
|
13
|
+
api = manager.userLogin(params[:email], params[:client_secret_json_path])
|
14
|
+
else
|
15
|
+
UI.error "You must define service_account_json_path or email with client_secret_json_path."
|
16
|
+
return nil
|
17
|
+
end
|
10
18
|
|
11
19
|
# select project
|
12
20
|
project_id = params[:project_id] || manager.select_project(nil)["projectId"]
|
@@ -56,18 +64,31 @@ module Fastlane
|
|
56
64
|
|
57
65
|
def self.available_options
|
58
66
|
[
|
67
|
+
FastlaneCore::ConfigItem.new(key: :email,
|
68
|
+
env_name: "FIREBASE_EMAIL",
|
69
|
+
description: "User's email to identify stored credentials",
|
70
|
+
optional: true),
|
71
|
+
|
72
|
+
FastlaneCore::ConfigItem.new(key: :client_secret_json_path,
|
73
|
+
env_name: "FIREBASE_CLIENT_SECRET_JSON_PATH",
|
74
|
+
description: "Path to client secret json file",
|
75
|
+
optional: true),
|
76
|
+
|
59
77
|
FastlaneCore::ConfigItem.new(key: :service_account_json_path,
|
60
78
|
env_name: "FIREBASE_SERVICE_ACCOUNT_JSON_PATH",
|
61
79
|
description: "Path to service account json key",
|
62
|
-
optional:
|
80
|
+
optional: true),
|
81
|
+
|
63
82
|
FastlaneCore::ConfigItem.new(key: :project_id,
|
64
83
|
env_name: "FIREBASE_PROJECT_ID",
|
65
84
|
description: "Project id",
|
66
85
|
optional: true),
|
86
|
+
|
67
87
|
FastlaneCore::ConfigItem.new(key: :app_id,
|
68
88
|
env_name: "FIREBASE_APP_ID",
|
69
89
|
description: "Project app id",
|
70
90
|
optional: true),
|
91
|
+
|
71
92
|
FastlaneCore::ConfigItem.new(key: :type,
|
72
93
|
env_name: "FIREBASE_TYPE",
|
73
94
|
description: "Type of client (ios, android)",
|
@@ -81,6 +102,7 @@ module Fastlane
|
|
81
102
|
description: "Path for the downloaded config",
|
82
103
|
optional: false,
|
83
104
|
default_value: "./"),
|
105
|
+
|
84
106
|
FastlaneCore::ConfigItem.new(key: :output_name,
|
85
107
|
env_name: "FIREBASE_OUTPUT_NAME",
|
86
108
|
description: "Name of the downloaded file",
|
@@ -6,23 +6,24 @@ module Fastlane
|
|
6
6
|
manager = FirebaseManagement::Manager.new
|
7
7
|
|
8
8
|
# login
|
9
|
-
api =
|
9
|
+
api = nil
|
10
|
+
if params[:service_account_json_path] != nil then
|
11
|
+
api = manager.serviceAccountLogin(params[:service_account_json_path])
|
12
|
+
elsif params[:email] != nil && params[:client_secret_json_path] != nil then
|
13
|
+
api = manager.userLogin(params[:email], params[:client_secret_json_path])
|
14
|
+
else
|
15
|
+
UI.error "You must define service_account_json_path or email with client_secret_json_path."
|
16
|
+
return nil
|
17
|
+
end
|
10
18
|
|
11
19
|
# download list of projects
|
12
20
|
projects = api.project_list()
|
13
21
|
|
14
|
-
# download list of apps for each project
|
15
|
-
projects.map! { |project|
|
16
|
-
project["iosApps"] = api.ios_app_list(project["projectId"])
|
17
|
-
project["androidApps"] = api.android_app_list(project["projectId"])
|
18
|
-
project
|
19
|
-
}
|
20
|
-
|
21
22
|
# create formatted output
|
22
23
|
projects.each_with_index { |p, i|
|
23
24
|
UI.message "#{i+1}. #{p["displayName"]} (#{p["projectId"]})"
|
24
25
|
|
25
|
-
ios_apps = p["
|
26
|
+
ios_apps = api.ios_app_list(p["projectId"])
|
26
27
|
if !ios_apps.empty? then
|
27
28
|
UI.message " iOS"
|
28
29
|
ios_apps.sort {|left, right| left["appId"] <=> right["appId"] }.each_with_index { |app, j|
|
@@ -30,7 +31,7 @@ module Fastlane
|
|
30
31
|
}
|
31
32
|
end
|
32
33
|
|
33
|
-
android_apps = p["
|
34
|
+
android_apps = api.android_app_list(p["projectId"])
|
34
35
|
if !android_apps.empty? then
|
35
36
|
UI.message " Android"
|
36
37
|
android_apps.sort {|left, right| left["appId"] <=> right["appId"] }.each_with_index { |app, j|
|
@@ -61,10 +62,20 @@ module Fastlane
|
|
61
62
|
|
62
63
|
def self.available_options
|
63
64
|
[
|
65
|
+
FastlaneCore::ConfigItem.new(key: :email,
|
66
|
+
env_name: "FIREBASE_EMAIL",
|
67
|
+
description: "User's email to identify stored credentials",
|
68
|
+
optional: true),
|
69
|
+
|
70
|
+
FastlaneCore::ConfigItem.new(key: :client_secret_json_path,
|
71
|
+
env_name: "FIREBASE_CLIENT_SECRET_JSON_PATH",
|
72
|
+
description: "Path to client secret json file",
|
73
|
+
optional: true),
|
74
|
+
|
64
75
|
FastlaneCore::ConfigItem.new(key: :service_account_json_path,
|
65
|
-
|
66
|
-
|
67
|
-
|
76
|
+
env_name: "FIREBASE_SERVICE_ACCOUNT_JSON_PATH",
|
77
|
+
description: "Path to service account json key",
|
78
|
+
optional: true
|
68
79
|
)
|
69
80
|
]
|
70
81
|
end
|
@@ -16,17 +16,8 @@ module Fastlane
|
|
16
16
|
require 'googleauth'
|
17
17
|
require 'httparty'
|
18
18
|
|
19
|
-
def initialize(
|
19
|
+
def initialize(access_token)
|
20
20
|
@base_url = "https://firebase.googleapis.com"
|
21
|
-
|
22
|
-
scope = 'https://www.googleapis.com/auth/firebase https://www.googleapis.com/auth/cloud-platform'
|
23
|
-
|
24
|
-
authorizer = Google::Auth::ServiceAccountCredentials.make_creds(
|
25
|
-
json_key_io: File.open(jsonPath),
|
26
|
-
scope: scope
|
27
|
-
)
|
28
|
-
|
29
|
-
access_token = authorizer.fetch_access_token!["access_token"]
|
30
21
|
@authorization_headers = {
|
31
22
|
'Authorization' => 'Bearer ' + access_token
|
32
23
|
}
|
@@ -2,14 +2,49 @@ module Fastlane
|
|
2
2
|
module FirebaseManagement
|
3
3
|
class Manager
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
require 'googleauth'
|
6
|
+
require 'googleauth/stores/file_token_store'
|
7
|
+
|
8
|
+
def userLogin(email, client_secrets_path)
|
9
|
+
|
10
|
+
system 'mkdir -p ~/.google'
|
11
|
+
|
12
|
+
oob_uri = "urn:ietf:wg:oauth:2.0:oob"
|
13
|
+
|
14
|
+
scopes = [
|
15
|
+
'https://www.googleapis.com/auth/firebase',
|
16
|
+
'https://www.googleapis.com/auth/cloud-platform'
|
17
|
+
]
|
18
|
+
client_id = Google::Auth::ClientId.from_file(client_secrets_path)
|
19
|
+
token_store = Google::Auth::Stores::FileTokenStore.new(:file => File.expand_path("~/.google/tokens.yaml"))
|
20
|
+
authorizer = Google::Auth::UserAuthorizer.new(client_id, scopes, token_store)
|
21
|
+
|
22
|
+
credentials = authorizer.get_credentials(email)
|
23
|
+
if credentials.nil?
|
24
|
+
url = authorizer.get_authorization_url(base_url: oob_uri)
|
25
|
+
UI.message "Open #{url} in your browser and enter the resulting code."
|
26
|
+
|
27
|
+
code = Fastlane::Actions::PromptAction.run(text: "Code: ")
|
28
|
+
|
29
|
+
credentials = authorizer.get_and_store_credentials_from_code(user_id: email, code: code, base_url: oob_uri)
|
12
30
|
end
|
31
|
+
|
32
|
+
token = credentials.fetch_access_token!["access_token"]
|
33
|
+
@api = FirebaseManagement::Api.new(token)
|
34
|
+
@api
|
35
|
+
end
|
36
|
+
|
37
|
+
def serviceAccountLogin(jsonPath)
|
38
|
+
scope = 'https://www.googleapis.com/auth/firebase https://www.googleapis.com/auth/cloud-platform'
|
39
|
+
|
40
|
+
authorizer = Google::Auth::ServiceAccountCredentials.make_creds(
|
41
|
+
json_key_io: File.open(jsonPath),
|
42
|
+
scope: scope
|
43
|
+
)
|
44
|
+
|
45
|
+
token = authorizer.fetch_access_token!["access_token"]
|
46
|
+
@api = FirebaseManagement::Api.new(token)
|
47
|
+
@api
|
13
48
|
end
|
14
49
|
|
15
50
|
def select_project(project_id)
|