fastlane-plugin-firebase 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9361331c59d149a7f719386d1c08c25c82a403f8
4
- data.tar.gz: 2016b089727e3a4ee85587b44eeada1b4b174893
3
+ metadata.gz: 8709ae7cfc1e92170d2c4e18efe1960c26df6281
4
+ data.tar.gz: 96a0afe222d6010f35a450caa88edfc0d5056540
5
5
  SHA512:
6
- metadata.gz: 7081d6fc6f890e1d0ae24d906113655e98e0f22b6a07aa061338923a688f789afb67d15397d36612e8297b7959cd20639eb84696a974463a7ffc9a0dbf7cfcae
7
- data.tar.gz: 135af776a81c32012398322b829f7d810d28114ce2490e8da0dc7d42237255d09d43165eed4e2bed65886feaf0f8fa1f3017078d0ea3f59ba65ac3cb5ca4622b
6
+ metadata.gz: ccc8c899b5176e4cf535c01bd58f53423324724ec075b799a0fd7f9a487d60d5b0c8d87a5e518a6a88eb5d4393254c15b0438a29ea2a776cccff0319eede4d39
7
+ data.tar.gz: 6069a93a1ca51d2ce9211b410e81cac6e9af8b61e3ba04be6d3e7e41d8876b3822645b3a80eabed81741a23351328b35d2675f3de1fffe3f3ee265010ccb13c4
@@ -17,14 +17,28 @@ module Fastlane
17
17
  name = params[:name]
18
18
  appstore_id = params[:appstore_id]
19
19
 
20
+ begin
20
21
  # Add client
21
22
  client = api.add_client(project["projectNumber"], type, bundle_id, name, appstore_id)
22
-
23
+ rescue Firebase::Api::BadRequestError => e
24
+ if e.code == 409 then
25
+ client = project["clientSummary"].select { |client| client["clientId"] == "#{type}:#{bundle_id}" }.first
26
+ if client then
27
+ UI.success "Client already exists, skipping ..."
28
+ else
29
+ raise
30
+ end
31
+ else
32
+ raise
33
+ end
34
+ end
35
+
36
+
23
37
  if params[:download_config] then
24
38
  #Download config
25
39
  config = api.download_config_file(project["projectNumber"], client["clientId"])
26
40
  path = File.join(params[:output_path], params[:output_name] || config.filename)
27
- config.save(path)
41
+ config.save!(path)
28
42
 
29
43
  UI.success "Successfuly saved config at #{path}"
30
44
  end
@@ -62,6 +76,7 @@ module Fastlane
62
76
  env_name: "FIREBASE_DOWNLOAD_CONFIG",
63
77
  description: "Should download config for created client",
64
78
  optional: false,
79
+ is_string: false,
65
80
  default_value: true),
66
81
  FastlaneCore::ConfigItem.new(key: :type,
67
82
  env_name: "FIREBASE_TYPE",
@@ -19,7 +19,7 @@ module Fastlane
19
19
  #Download
20
20
  config = api.download_config_file(project_number, client_id)
21
21
  path = File.join(params[:output_path], params[:output_name] || config.filename)
22
- config.save(path)
22
+ config.save!(path)
23
23
 
24
24
  UI.success "Successfuly saved config at #{path}"
25
25
  end
@@ -10,8 +10,9 @@ module Fastlane
10
10
 
11
11
  # List projects
12
12
  projects = api.project_list()
13
+
13
14
  projects.each_with_index { |p, i|
14
- UI.message "#{i+1}. #{p["displayName"]}"
15
+ UI.message "#{i+1}. #{p["displayName"]} (#{p["projectNumber"]})"
15
16
  p["clientSummary"].sort {|left, right| left["clientId"] <=> right["clientId"] }.each_with_index { |client, j|
16
17
  UI.message " - #{client["clientId"]} (#{client["displayName"]})"
17
18
  }
@@ -24,7 +24,7 @@ module Fastlane
24
24
  client_id = client["clientId"]
25
25
 
26
26
  #Select certificate type
27
- type = UI.select("Select type:", [:development, :production])
27
+ type = params[:type].to_sym # || UI.select("Select type:", ["development", "production"])).to_sym
28
28
 
29
29
  #Base64 certificate
30
30
  certificate_value = Base64.encode64(File.open(p12_path, "rb").read).delete!("\n")
@@ -76,7 +76,10 @@ module Fastlane
76
76
  FastlaneCore::ConfigItem.new(key: :p12_path,
77
77
  env_name: "FIREBASE_P12PATH",
78
78
  description: "Path to certificate",
79
- optional: false),
79
+ optional: false,
80
+ verify_block: proc do |value|
81
+ UI.user_error! "Inserted value is not file - #{value}" unless File.exists? value
82
+ end),
80
83
  FastlaneCore::ConfigItem.new(key: :p12_password,
81
84
  env_name: "FIREBASE_PASSWORD",
82
85
  description: "Password to the certicate",
@@ -88,7 +91,10 @@ module Fastlane
88
91
  FastlaneCore::ConfigItem.new(key: :client_id,
89
92
  env_name: "FIREBASE_CLIENT_ID",
90
93
  description: "Project client id",
91
- optional: true)
94
+ optional: true),
95
+ FastlaneCore::ConfigItem.new(key: :type,
96
+ env_name: "FIREBASE_TYPE",
97
+ description: "Type of certificate (development, production)")
92
98
  ]
93
99
  end
94
100
 
@@ -6,6 +6,11 @@ module Fastlane
6
6
  end
7
7
 
8
8
  class BadRequestError < StandardError
9
+ attr_reader :code
10
+ def initialize(msg, code)
11
+ @code = code
12
+ super(msg)
13
+ end
9
14
  end
10
15
 
11
16
  require 'mechanize'
@@ -107,7 +112,7 @@ module Fastlane
107
112
  code = e.response_code.to_i
108
113
  if code >= 400 && code < 500 then
109
114
  if body = JSON.parse(e.page.body) then
110
- raise BadRequestError, body["error"]["message"]
115
+ raise BadRequestError.new(body["error"]["message"], code)
111
116
  end
112
117
  end
113
118
  UI.crash! e.page.body
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Firebase
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-firebase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Kohout
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-20 00:00:00.000000000 Z
11
+ date: 2017-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler