firim 0.1.4 → 0.2.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/firim/detect_values.rb +65 -2
- data/lib/firim/options.rb +25 -4
- data/lib/firim/runner.rb +47 -6
- data/lib/firim/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c14a9086ace96798689e6be574eef0dc5e917690
|
|
4
|
+
data.tar.gz: 89d4000d8b56fae1d2224f9b77d8faa1bc3b05e0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 11244e647af64a7dbd34e85a8e9daf9aad666c2b4114a1d682de71ba5869b0fc965e54511f73d066fae58eaa046e8d58089c1530b29e9ad145ed9fced19f232f
|
|
7
|
+
data.tar.gz: 5a0530e2ddb7ece08eb6c99c6e83557d08b358379de5c30f6365407abb43d556e221581ccb5ebc8e7e76a02a12ea72e635ff9df0c976c95e3a30d9ea33418473
|
data/lib/firim/detect_values.rb
CHANGED
|
@@ -39,10 +39,73 @@ module Firim
|
|
|
39
39
|
token = keychain_token.token(ask_if_missing: option_token == nil)
|
|
40
40
|
if token
|
|
41
41
|
options[:firim_api_token] = token
|
|
42
|
-
return
|
|
42
|
+
return
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
options[:firim_api_token] ||= UI.input("The API Token of fir.im: ")
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
|
-
|
|
48
|
+
|
|
49
|
+
class DetectAndroidValues
|
|
50
|
+
def run!(options)
|
|
51
|
+
find_firim_api_token(options)
|
|
52
|
+
find_app_identifier(options)
|
|
53
|
+
find_app_name(options)
|
|
54
|
+
find_version(options)
|
|
55
|
+
find_build_version(options)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def read_key_from_gradle_file(gradle_file, key)
|
|
59
|
+
return nil if gradle_file == nil
|
|
60
|
+
value = nil
|
|
61
|
+
begin
|
|
62
|
+
file = File.new(gradle_file, "r")
|
|
63
|
+
while (line = file.gets)
|
|
64
|
+
next unless line.include? key
|
|
65
|
+
components = line.strip.split(' ')
|
|
66
|
+
value = components[components.length - 1].tr("\"", "")
|
|
67
|
+
break
|
|
68
|
+
end
|
|
69
|
+
file.close
|
|
70
|
+
rescue => err
|
|
71
|
+
UI.error("An exception occured while reading gradle file: #{err}")
|
|
72
|
+
err
|
|
73
|
+
end
|
|
74
|
+
return value
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def find_app_identifier(options)
|
|
78
|
+
return if options[:app_identifier]
|
|
79
|
+
options[:app_identifier] ||= self.read_key_from_gradle_file(options[:gradle_file], "applicationId")
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def find_app_name(options)
|
|
83
|
+
return if options[:app_name]
|
|
84
|
+
options[:app_name] ||= self.read_key_from_gradle_file(options[:gradle_file], "appName")
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def find_version(options)
|
|
88
|
+
return if options[:app_version]
|
|
89
|
+
options[:app_version] ||= self.read_key_from_gradle_file(options[:gradle_file], "versionName")
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def find_build_version(options)
|
|
93
|
+
return if options[:app_build_version]
|
|
94
|
+
options[:app_build_version] ||= self.read_key_from_gradle_file(options[:gradle_file], "versionCode")
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def find_firim_api_token(options)
|
|
98
|
+
option_token = options[:firim_api_token]
|
|
99
|
+
keychain_token = Firim::AccountManager.new(user: options[:firim_username])
|
|
100
|
+
token = keychain_token.token(ask_if_missing: option_token == nil)
|
|
101
|
+
if token
|
|
102
|
+
options[:firim_api_token] = token
|
|
103
|
+
return
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
options[:firim_api_token] ||= UI.input("The API Token of fir.im: ")
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
end
|
data/lib/firim/options.rb
CHANGED
|
@@ -5,6 +5,10 @@ module Firim
|
|
|
5
5
|
class Options
|
|
6
6
|
def self.available_options
|
|
7
7
|
[
|
|
8
|
+
# firim platform
|
|
9
|
+
FastlaneCore::ConfigItem.new(key: :platform,
|
|
10
|
+
optional: true,
|
|
11
|
+
description: "The fir platform, support ios/android"),
|
|
8
12
|
# firim info
|
|
9
13
|
FastlaneCore::ConfigItem.new(key: :firim_api_token,
|
|
10
14
|
short_option: "-a",
|
|
@@ -13,9 +17,9 @@ module Firim
|
|
|
13
17
|
FastlaneCore::ConfigItem.new(key: :firim_username,
|
|
14
18
|
optional: true,
|
|
15
19
|
description: "fir.im username, a sign for identify different token"),
|
|
16
|
-
|
|
17
20
|
# Content path
|
|
18
21
|
FastlaneCore::ConfigItem.new(key: :ipa,
|
|
22
|
+
optional: true,
|
|
19
23
|
short_option: "-i",
|
|
20
24
|
env_name: "DELIVER_IPA_PATH",
|
|
21
25
|
description: "Path to your ipa file",
|
|
@@ -23,11 +27,24 @@ module Firim
|
|
|
23
27
|
verify_block: proc do |value|
|
|
24
28
|
UI.user_error!("Could not find ipa file at path '#{value}'") unless File.exist?(value)
|
|
25
29
|
UI.user_error!("'#{value}' doesn't seem to be an ipa file") unless value.end_with?(".ipa")
|
|
30
|
+
end),
|
|
31
|
+
FastlaneCore::ConfigItem.new(key: :apk,
|
|
32
|
+
optional: true,
|
|
33
|
+
env_name: "DELIVER_APK_PATH",
|
|
34
|
+
description: "Path to your apk file",
|
|
35
|
+
default_value: Dir["app/build/outputs/apk/prod/release/*.apk"].first,
|
|
36
|
+
verify_block: proc do |value|
|
|
37
|
+
UI.user_error!("Could not find apk file at path '#{value}'") unless File.exist?(value)
|
|
38
|
+
UI.user_error!("'#{value}' doesn't seem to be an apk file") unless value.end_with?(".apk")
|
|
26
39
|
end,
|
|
27
|
-
conflicting_options: [:
|
|
40
|
+
conflicting_options: [:ipa],
|
|
28
41
|
conflict_block: proc do |value|
|
|
29
|
-
UI.user_error!("You can't use '
|
|
42
|
+
UI.user_error!("You can't use 'apk' and '#{value.key}' options in one run.")
|
|
30
43
|
end),
|
|
44
|
+
FastlaneCore::ConfigItem.new(key: :gradle_file,
|
|
45
|
+
short_option: "-g",
|
|
46
|
+
optional: true,
|
|
47
|
+
description: "Path to your gradle file"),
|
|
31
48
|
FastlaneCore::ConfigItem.new(key: :icon,
|
|
32
49
|
description: "Path to the app icon, MUST BE jpg",
|
|
33
50
|
optional: true,
|
|
@@ -36,6 +53,10 @@ module Firim
|
|
|
36
53
|
UI.user_error!("Could not find png file at path '#{value}'") unless File.exist?(value)
|
|
37
54
|
UI.user_error!("'#{value}' doesn't seem to be a png file") unless value.end_with?(".jpg")
|
|
38
55
|
end),
|
|
56
|
+
|
|
57
|
+
FastlaneCore::ConfigItem.new(key: :file,
|
|
58
|
+
optional: true,
|
|
59
|
+
description: "Path to your pkg file"),
|
|
39
60
|
# APP info
|
|
40
61
|
FastlaneCore::ConfigItem.new(key: :app_identifier,
|
|
41
62
|
description: "The app's identifier",
|
|
@@ -85,4 +106,4 @@ module Firim
|
|
|
85
106
|
]
|
|
86
107
|
end
|
|
87
108
|
end
|
|
88
|
-
end
|
|
109
|
+
end
|
data/lib/firim/runner.rb
CHANGED
|
@@ -11,6 +11,17 @@ module Firim
|
|
|
11
11
|
return "http://api.fir.im/"
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
+
def guess_platform
|
|
15
|
+
return self.options[:platform] if self.options[:platform]
|
|
16
|
+
if self.options[:ipa]
|
|
17
|
+
return "ios"
|
|
18
|
+
elsif self.options[:apk]
|
|
19
|
+
return "android"
|
|
20
|
+
else
|
|
21
|
+
return nil
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
14
25
|
def initialize(options)
|
|
15
26
|
self.options = options
|
|
16
27
|
@app_info = {}
|
|
@@ -22,13 +33,26 @@ module Firim
|
|
|
22
33
|
}
|
|
23
34
|
}
|
|
24
35
|
|
|
36
|
+
if self.options[:apk]
|
|
37
|
+
self.options[:file] = self.options[:apk]
|
|
38
|
+
else
|
|
39
|
+
self.options[:file] = self.options[:ipa]
|
|
40
|
+
end
|
|
41
|
+
self.options[:platform] = self.guess_platform
|
|
42
|
+
UI.user_error!("Platform not given --platform ios/android") if self.options[:platform] == nil
|
|
43
|
+
|
|
25
44
|
@firim_client = Faraday.new(self.class.firim_hostname, conn_options) do |c|
|
|
26
45
|
c.request :url_encoded # form-encode POST params
|
|
27
46
|
c.adapter :net_http
|
|
28
47
|
c.response :json, :content_type => /\bjson$/
|
|
29
48
|
end
|
|
30
49
|
|
|
31
|
-
|
|
50
|
+
if self.options[:platform] == 'ios'
|
|
51
|
+
Firim::DetectValues.new.run!(self.options)
|
|
52
|
+
else
|
|
53
|
+
Firim::DetectAndroidValues.new.run!(self.options)
|
|
54
|
+
end
|
|
55
|
+
|
|
32
56
|
FastlaneCore::PrintTable.print_values(config: options, title: "firim #{Firim::VERSION} Summary")
|
|
33
57
|
end
|
|
34
58
|
|
|
@@ -51,15 +75,18 @@ module Firim
|
|
|
51
75
|
end
|
|
52
76
|
|
|
53
77
|
def validation_response response_data
|
|
54
|
-
error_code = response_data['code'].to_i
|
|
78
|
+
error_code = response_data['code'].to_i
|
|
79
|
+
return if error_code == 0
|
|
55
80
|
if error_code == 100020
|
|
56
81
|
UI.user_error!("Firim API Token(#{options[:firim_api_token]}) not correct")
|
|
82
|
+
else
|
|
83
|
+
UI.user_error!("Firim API ERROR error_code: #{error_code}")
|
|
57
84
|
end
|
|
58
85
|
end
|
|
59
86
|
|
|
60
87
|
def get_app_info
|
|
61
88
|
app_info_path = "apps/latest/" + options[:app_identifier]
|
|
62
|
-
response = self.firim_client.get app_info_path, { :api_token => options[:firim_api_token], :type =>
|
|
89
|
+
response = self.firim_client.get app_info_path, { :api_token => options[:firim_api_token], :type => options[:platform] }
|
|
63
90
|
info = response.body == nil ? {} : response.body
|
|
64
91
|
validation_response info
|
|
65
92
|
info
|
|
@@ -69,10 +96,13 @@ module Firim
|
|
|
69
96
|
upload_publish_path = "apps/"
|
|
70
97
|
response = self.firim_client.post do |req|
|
|
71
98
|
req.url upload_publish_path
|
|
72
|
-
req.body = { :type =>
|
|
99
|
+
req.body = { :type => options[:platform], :bundle_id => options[:app_identifier], :api_token => options[:firim_api_token] }
|
|
73
100
|
end
|
|
74
101
|
info = response.body
|
|
75
102
|
validation_response info
|
|
103
|
+
if info['cert']['binary']['key'] == nil
|
|
104
|
+
UI.user_error!("Response body ERROR: #{response.body}")
|
|
105
|
+
end
|
|
76
106
|
begin
|
|
77
107
|
upload_binary info['cert']['binary']
|
|
78
108
|
upload_icon info['cert']['icon']
|
|
@@ -99,10 +129,21 @@ module Firim
|
|
|
99
129
|
end
|
|
100
130
|
|
|
101
131
|
def upload_binary binary_info
|
|
132
|
+
UI.user_error!("app_name did not provide --app_name [name]") if self.options[:app_name] == nil
|
|
133
|
+
UI.user_error!("app_version did not provide --app_version [version]") if self.options[:app_version] == nil
|
|
134
|
+
UI.user_error!("app_build_version did not provide --app_build_version [build_version]") if self.options[:app_build_version] == nil
|
|
135
|
+
if self.options[:file] == nil
|
|
136
|
+
if self.options[:platform] == "ios"
|
|
137
|
+
UI.user_error!("ipa file did not provide --ipa [ipa_path]")
|
|
138
|
+
else
|
|
139
|
+
UI.user_error!("apk file did not provide --ipa [apk_path]")
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
102
143
|
params = {
|
|
103
144
|
'key' => binary_info['key'],
|
|
104
145
|
'token' => binary_info['token'],
|
|
105
|
-
'file' => Faraday::UploadIO.new(self.options[:
|
|
146
|
+
'file' => Faraday::UploadIO.new(self.options[:file], 'application/octet-stream'),
|
|
106
147
|
'x:name' => self.options[:app_name],
|
|
107
148
|
'x:version' => self.options[:app_version],
|
|
108
149
|
'x:build' => self.options[:app_build_version]
|
|
@@ -156,4 +197,4 @@ module Firim
|
|
|
156
197
|
end
|
|
157
198
|
|
|
158
199
|
end
|
|
159
|
-
end
|
|
200
|
+
end
|
data/lib/firim/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: firim
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- whlsxl
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2018-02-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: fastlane
|
|
@@ -141,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
141
141
|
version: '0'
|
|
142
142
|
requirements: []
|
|
143
143
|
rubyforge_project:
|
|
144
|
-
rubygems_version: 2.6.
|
|
144
|
+
rubygems_version: 2.6.13
|
|
145
145
|
signing_key:
|
|
146
146
|
specification_version: 4
|
|
147
147
|
summary: fir.im command tool
|