lhj-tools 0.2.60 → 0.2.62
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lhj/helper/pgyer_helper.rb +67 -23
- data/lib/lhj/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: b06a7cc355541d7c1a049c137aac1805143560ac8ba051dc4d435303fbbc30d9
|
4
|
+
data.tar.gz: b84e8b7d58daed0b4fafceb4fabbef26a7c8b8ef9f7a06866e2e381818f7143b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abc525c352b610813d16ac55437eec92c1e826d0ad5da5e10ae2b59150f25bf864449753a242c46a5364ecd20a44e5124f76f0c47ea789e5df04e8b09329c604
|
7
|
+
data.tar.gz: c6eb6eed5ab5c1a6922e9cdcd0332d44544091af608420ba6fe5f279f8d52ebf45e07ffaffd880e4322f6861f035a5340e7ec4ce115112ec4b0f193ade97f39d
|
@@ -10,7 +10,7 @@ require_relative 'tb_config'
|
|
10
10
|
module Lhj
|
11
11
|
# pgyer upload
|
12
12
|
class Pgyer
|
13
|
-
API_HOST = 'https://
|
13
|
+
API_HOST = 'https://www.xcxwo.com/apiv2/app'
|
14
14
|
|
15
15
|
attr_reader :api_key, :user_key, :password, :result
|
16
16
|
|
@@ -46,30 +46,74 @@ module Lhj
|
|
46
46
|
# @param [upload file] file
|
47
47
|
# @param [desc] des
|
48
48
|
def upload_with_path(path, file, des)
|
49
|
-
|
49
|
+
request_params = {
|
50
50
|
'_api_key' => @api_key,
|
51
|
-
'
|
52
|
-
'
|
53
|
-
'
|
54
|
-
'
|
55
|
-
'file' => Faraday::UploadIO.new(file, 'application/octet-stream')
|
51
|
+
'buildPassword' => @password,
|
52
|
+
'buildUpdateDescription' => des,
|
53
|
+
'buildType' => 'ios',
|
54
|
+
'buildInstallType' => 2
|
56
55
|
}
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
56
|
+
conn_options = {
|
57
|
+
request: {
|
58
|
+
timeout: 1000,
|
59
|
+
open_timeout: 300
|
60
|
+
}
|
61
|
+
}
|
62
|
+
pgyer_client = Faraday.new(nil, conn_options) do |builder|
|
63
|
+
builder.request :multipart
|
64
|
+
builder.request :url_encoded
|
65
|
+
builder.response :json, content_type: /\bjson$/
|
66
|
+
builder.adapter :net_http
|
67
|
+
end
|
68
|
+
|
69
|
+
puts 'begin upload...'
|
70
|
+
upload_with_type(path, file) unless path.empty?
|
71
|
+
response = pgyer_client.post "#{API_HOST}/getCOSToken", request_params
|
72
|
+
info = response.body
|
73
|
+
|
74
|
+
if info['code'] != 0
|
75
|
+
UI.user_error!("Get token is failed, info: #{info}")
|
76
|
+
end
|
77
|
+
|
78
|
+
key = info['data']['key']
|
79
|
+
endpoint = info['data']['endpoint']
|
80
|
+
request_params = info['data']['params']
|
81
|
+
if key.nil? || endpoint.nil? || request_params.nil?
|
82
|
+
UI.user_error!('Get token is failed')
|
83
|
+
end
|
84
|
+
request_params['file'] = Faraday::UploadIO.new(file, 'application/octet-stream')
|
85
|
+
|
86
|
+
response = pgyer_client.post endpoint, request_params
|
87
|
+
|
88
|
+
if response.status != 204
|
89
|
+
UI.user_error!("PGYER Plugin Upload Error: #{response.body}")
|
90
|
+
end
|
91
|
+
|
92
|
+
@result = check_publish_status(pgyer_client, API_HOST, @api_key, key)
|
93
|
+
|
94
|
+
puts @result
|
95
|
+
Actions.sh('git restore ./', log: false) if File.exist?(File.expand_path('./.git'))
|
96
|
+
puts 'upload success'
|
97
|
+
end
|
98
|
+
|
99
|
+
def check_publish_status(client, api_host, api_key, build_key)
|
100
|
+
url = "#{api_host}/buildInfo"
|
101
|
+
response = client.post url, { :_api_key => api_key, :buildKey => build_key }
|
102
|
+
info = response.body
|
103
|
+
code = info['code']
|
104
|
+
if code.zero?
|
105
|
+
UI.success "Upload success. BuildInfo is #{info['data']}."
|
106
|
+
short_url = info['data']['buildShortcutUrl']
|
107
|
+
if short_url.nil? || short_url == ''
|
108
|
+
short_url = info['data']['buildKey']
|
109
|
+
end
|
110
|
+
info['data']['fastlaneAddedWholeVisitUrl'] = "https://wwww.xcxwo.com/#{short_url}"
|
111
|
+
return info
|
112
|
+
elsif [1246, 1247].include?(code)
|
113
|
+
sleep 3
|
114
|
+
check_publish_status(client, api_host, api_key, build_key)
|
115
|
+
else
|
116
|
+
UI.user_error!("PGYER Plugin Published Error: #{info} buildKey: #{build_key}")
|
73
117
|
end
|
74
118
|
end
|
75
119
|
|
data/lib/lhj/version.rb
CHANGED