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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a0d582db4ef32f2a5a672b4d00f12f6f22d431dacba91600acc4ff86928bd1b
4
- data.tar.gz: 24e872bb4b90c5df2594375a0870a82e3743fdda818663f1ca3d7e5769e9f2ed
3
+ metadata.gz: b06a7cc355541d7c1a049c137aac1805143560ac8ba051dc4d435303fbbc30d9
4
+ data.tar.gz: b84e8b7d58daed0b4fafceb4fabbef26a7c8b8ef9f7a06866e2e381818f7143b
5
5
  SHA512:
6
- metadata.gz: 9eaeb8b7329646a485d38ed3c9cc9a38f02b4797a8adbbf8e9132ef7c767ca8202ccc7a6256397410a41e91408cfbf7fe7f8afb160b506d85d1a1bbd566e5ea2
7
- data.tar.gz: f12e98e6d1d9eae53e82847cf90746094dd0a940a3a3954da5279e8256f093950f70983520cbaf4f3a3c09e6f36d67b0416a5d7a6bc4767cedd7604aaa37a088
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://upload.xcxwo.com/apiv1/app/upload'
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
- params = {
49
+ request_params = {
50
50
  '_api_key' => @api_key,
51
- 'uKey' => @user_key,
52
- 'password' => @password,
53
- 'updateDescription' => des,
54
- 'installType' => 2,
55
- 'file' => Faraday::UploadIO.new(file, 'application/octet-stream')
51
+ 'buildPassword' => @password,
52
+ 'buildUpdateDescription' => des,
53
+ 'buildType' => 'ios',
54
+ 'buildInstallType' => 2
56
55
  }
57
- begin
58
- puts 'begin upload...'
59
- upload_with_type(path, file) unless path.empty?
60
- response = http_client.post API_HOST, params
61
- @result = response.body
62
- puts @result
63
- Actions.sh('git restore ./', log: false) if File.exist?(File.expand_path('./.git'))
64
- puts 'upload success'
65
- # if @result['data'] && @result['data']['appUpdateDescription'] && @env == :uat
66
- # str = Lhj::TbHelper.trans_tb(@result['data']['appUpdateDescription'])
67
- # str = Lhj::VikaHelper.trans_vika(str)
68
- # @result['data']['appUpdateDescription'] = str
69
- # end
70
- rescue Faraday::TimeoutError
71
- puts 'upload fail'
72
- FileUtils.rm_r Dir.glob("#{path}/archive*.zip")
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lhj
4
- VERSION = '0.2.60'
4
+ VERSION = '0.2.62'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhj-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.60
4
+ version: 0.2.62
5
5
  platform: ruby
6
6
  authors:
7
7
  - lihaijian