lhj-tools 0.2.59 → 0.2.61
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 +70 -24
- data/lib/lhj/helper/pgyer_shortcut_helper.rb +1 -1
- data/lib/lhj/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17f381f8a5e810d3d6455d7ffc07c21edb457deca5822d55ec75c49151cf1499
|
4
|
+
data.tar.gz: d12cd89e36ba62322d1f941829fc53ce69c66b3d11e27863a277bf8f767baec4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '091917f41e4d3e47781159cbccc9e9fdec220900a60ca25fc226bdab0c7039dfb7803f113c4d230ef13a85137e895e90b538bc05e8e9d589e51bf5d8153add0b'
|
7
|
+
data.tar.gz: 13394220af4f61305c6e1659cfa040f1129ddb140a9df027750eb17a819aea502b88dfb713b233e86d5a857296e6af398685936f2028c48204694515a8c26fe0
|
@@ -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,76 @@ 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 = checkPublishStatus(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 checkPublishStatus(client, api_host, api_key, buildKey)
|
100
|
+
url = "#{api_host}/buildInfo"
|
101
|
+
UI.message "checkPublishStatus url: #{url}"
|
102
|
+
response = client.post "#{api_host}/buildInfo", { :_api_key => api_key, :buildKey => buildKey }
|
103
|
+
info = response.body
|
104
|
+
code = info['code']
|
105
|
+
if code == 0
|
106
|
+
UI.success "Upload success. BuildInfo is #{info['data']}."
|
107
|
+
shortUrl = info["data"]["buildShortcutUrl"]
|
108
|
+
if shortUrl.nil? || shortUrl == ""
|
109
|
+
shortUrl = info["data"]["buildKey"]
|
110
|
+
end
|
111
|
+
info["data"]["fastlaneAddedWholeVisitUrl"] = "https://wwww.xcxwo.com/#{shortUrl}"
|
112
|
+
UI.success "Upload success. Visit this URL to see: #{info["data"]["fastlaneAddedWholeVisitUrl"]}"
|
113
|
+
return info["data"]
|
114
|
+
elsif code == 1246 || code == 1247
|
115
|
+
sleep 3
|
116
|
+
checkPublishStatus(client, api_host, api_key, buildKey)
|
117
|
+
else
|
118
|
+
UI.user_error!("PGYER Plugin Published Error: #{info} buildKey: #{buildKey}")
|
73
119
|
end
|
74
120
|
end
|
75
121
|
|
@@ -111,7 +157,7 @@ module Lhj
|
|
111
157
|
end
|
112
158
|
|
113
159
|
def app_download_url
|
114
|
-
"https://www.
|
160
|
+
"https://www.xcxwo.com/#{@result['data']['appKey']}"
|
115
161
|
end
|
116
162
|
end
|
117
163
|
end
|
@@ -7,7 +7,7 @@ require 'lhj/helper/pgyer_config'
|
|
7
7
|
module Lhj
|
8
8
|
# pgyer upload
|
9
9
|
class PgyerShortcut
|
10
|
-
API_SHORTCUT_HOST = 'https://www.
|
10
|
+
API_SHORTCUT_HOST = 'https://www.xcxwo.com/apiv2/app/getByShortcut'
|
11
11
|
|
12
12
|
attr_reader :api_key, :user_key, :password, :shortcut_url
|
13
13
|
|
data/lib/lhj/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lhj-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.61
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lihaijian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xcodeproj
|