fastlane-plugin-latest_appcenter_build_number 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 91ce3611fe391250e87abecde468adf27b666758
|
4
|
+
data.tar.gz: 6e970ac127bbf04124452b6f5c2ed81b6ac04c2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbf017dcba261ff063212d047409aef563b2765f93598f51c917422b781eeecc6e57add759a2b359c537e7a5e357c325a17a51b973b0523d22a01c627eea77fe
|
7
|
+
data.tar.gz: df4eb46a8c16c3f7a3632e7c37a0584ed412b43bd7baf042d10bec5cb440a48261cd6af8de60fbe489baa6f4d50f7a990fd705693093a2674daf806dfeccea55
|
@@ -8,14 +8,32 @@ module Fastlane
|
|
8
8
|
module Actions
|
9
9
|
class LatestAppcenterBuildNumberAction < Action
|
10
10
|
def self.run(config)
|
11
|
+
unless check_valid_app_name(config[:app_name])
|
12
|
+
UI.user_error!("The `app_name` ('#{config[:app_name]}') cannot contains spaces and must only contain alpha numeric characters and dashes")
|
13
|
+
return nil
|
14
|
+
end
|
15
|
+
|
11
16
|
app_name = config[:app_name]
|
12
17
|
owner_name = config[:owner_name]
|
13
|
-
if app_name.nil?
|
18
|
+
if app_name.nil? && owner_name.nil?
|
14
19
|
owner_and_app_name = get_owner_and_app_name(config[:api_token])
|
15
20
|
app_name = owner_and_app_name[0]
|
16
21
|
owner_name = owner_and_app_name[1]
|
17
22
|
end
|
18
23
|
|
24
|
+
if owner_name.nil?
|
25
|
+
owner_name = get_owner_name(config[:api_token], app_name)
|
26
|
+
end
|
27
|
+
|
28
|
+
if app_name.nil?
|
29
|
+
app_name = get_owner_and_app_name(config[:api_token])[0]
|
30
|
+
end
|
31
|
+
|
32
|
+
if app_name.nil? || owner_name.nil?
|
33
|
+
UI.user_error!("No app '#{app_name}' found for owner #{owner_name}")
|
34
|
+
return nil
|
35
|
+
end
|
36
|
+
|
19
37
|
host_uri = URI.parse('https://api.appcenter.ms')
|
20
38
|
http = Net::HTTP.new(host_uri.host, host_uri.port)
|
21
39
|
http.use_ssl = true
|
@@ -24,13 +42,18 @@ module Fastlane
|
|
24
42
|
list_response = http.request(list_request)
|
25
43
|
|
26
44
|
if list_response.kind_of?(Net::HTTPForbidden)
|
27
|
-
UI.
|
45
|
+
UI.user_error!("API Key not valid for '#{owner_name}'. This will be because either the API Key or the `owner_name` are incorrect")
|
46
|
+
return nil
|
47
|
+
end
|
48
|
+
|
49
|
+
if list_response.kind_of?(Net::HTTPNotFound)
|
50
|
+
UI.user_error!("No app or owner found with `app_name`: '#{app_name}' and `owner_name`: '#{owner_name}'")
|
28
51
|
return nil
|
29
52
|
end
|
30
53
|
|
31
54
|
releases = JSON.parse(list_response.body)
|
32
55
|
if releases.nil?
|
33
|
-
UI.
|
56
|
+
UI.user_error!("No versions found for '#{app_name}' owned by #{owner_name}")
|
34
57
|
return nil
|
35
58
|
end
|
36
59
|
|
@@ -38,7 +61,7 @@ module Fastlane
|
|
38
61
|
latest_build = releases.first
|
39
62
|
|
40
63
|
if latest_build.nil?
|
41
|
-
UI.
|
64
|
+
UI.user_error!("The app has no versions yet")
|
42
65
|
return nil
|
43
66
|
end
|
44
67
|
|
@@ -86,13 +109,26 @@ module Fastlane
|
|
86
109
|
apps = get_apps(api_token)
|
87
110
|
app_names = apps.map { |app| app['name'] }.sort
|
88
111
|
selected_app_name = UI.select("Select your project: ", app_names)
|
89
|
-
|
112
|
+
app_matches = apps.select { |app| app['name'] == selected_app_name }
|
113
|
+
return unless app_matches.count > 0
|
114
|
+
selected_app = app_matches.first
|
90
115
|
|
91
116
|
name = selected_app['name'].to_s
|
92
117
|
owner = selected_app['owner']['name'].to_s
|
93
118
|
return name, owner
|
94
119
|
end
|
95
120
|
|
121
|
+
def self.get_owner_name(api_token, app_name)
|
122
|
+
apps = get_apps(api_token)
|
123
|
+
return unless apps.count > 0
|
124
|
+
app_matches = apps.select { |app| app['name'] == app_name }
|
125
|
+
return unless app_matches.count > 0
|
126
|
+
selected_app = app_matches.first
|
127
|
+
|
128
|
+
owner = selected_app['owner']['name'].to_s
|
129
|
+
return owner
|
130
|
+
end
|
131
|
+
|
96
132
|
def self.get_apps(api_token)
|
97
133
|
host_uri = URI.parse('https://api.appcenter.ms')
|
98
134
|
http = Net::HTTP.new(host_uri.host, host_uri.port)
|
@@ -100,8 +136,13 @@ module Fastlane
|
|
100
136
|
apps_request = Net::HTTP::Get.new("/v0.1/apps")
|
101
137
|
apps_request['X-API-Token'] = api_token
|
102
138
|
apps_response = http.request(apps_request)
|
103
|
-
|
104
|
-
return
|
139
|
+
return [] unless apps_response.kind_of?(Net::HTTPOK)
|
140
|
+
return JSON.parse(apps_response.body)
|
141
|
+
end
|
142
|
+
|
143
|
+
def self.check_valid_app_name(app_name)
|
144
|
+
regexp = /^[a-zA-Z0-9\-]+$/i
|
145
|
+
return regexp.match?(app_name)
|
105
146
|
end
|
106
147
|
end
|
107
148
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-latest_appcenter_build_number
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jack Spargo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -167,7 +167,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
167
|
- !ruby/object:Gem::Version
|
168
168
|
version: '0'
|
169
169
|
requirements: []
|
170
|
-
|
170
|
+
rubyforge_project:
|
171
|
+
rubygems_version: 2.6.14
|
171
172
|
signing_key:
|
172
173
|
specification_version: 4
|
173
174
|
summary: Use AppCenter API to get the latest version and build number for an App Center
|