fir-cli 2.0.16 → 2.0.17

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 05ad3ae892ccf32689209d90fd2d3053013fd1996365b20f02a82a6de0fde607
4
- data.tar.gz: 784ba11435d2ad37d5762955753435672b5f6d087c23b2a0cf3602cd569d2310
3
+ metadata.gz: 27a5c2fe69e1713db4099ac901228f33d23ac94ac92018fdf6b6ee6f71bc1061
4
+ data.tar.gz: d9280aa40366d505c9735c614bd7d0051446fbffd173c76e9338fcccea077e86
5
5
  SHA512:
6
- metadata.gz: b315d5ab9228498d1dd0aff2dc09d01d744bace237fc6cd79a2be2d1d947d101efad64297153356f03e5c08596ba5a6e00a5e220487a599ad65e1800859f2248
7
- data.tar.gz: 275d8de0a02933dcd52d59c24303e1453bb5267b08fb79c9a70ff75a809307f2f8db2e75029bed4e2b698cb8e59bcb4d5720a2d3e0372ed576138db7f8ef5984
6
+ metadata.gz: 9a09911d9e1fd3dbfc62f41c37ad196b5f76864a101569e2b3184fe5ee57c0702fbae59bff20e22b1ac01a25f2d0a002d30ee2d91941f853521bda5572af310f
7
+ data.tar.gz: c5ecf24fa4c7bb4afdd82a256bf2a878788f3e96e0aac0058dea9c2dd10b04bd439aff1710ae760769a7a38d67bf901d196d445fb1bf3d9557f3d5146ed00de0
data/README.md CHANGED
@@ -18,6 +18,7 @@ fir.im-cli 可以通过指令查看, 上传, iOS/Android 应用.
18
18
  - 现也有一个go 版本的 go-fir-cli 供大家使用, 无需安装依赖, 可以直接使用. 具体请访问 [https://github.com/PGYER/go-fir-cli](https://github.com/PGYER/go-fir-cli). 注意! 该版本功能并不与fir-cli 完全重合.
19
19
 
20
20
  # 最近更新
21
+ - (2.0.17) 增加了上传百分比显示
21
22
  - (2.0.16) 更新了 thor
22
23
  - (2.0.15) 更换了 API 域名
23
24
  - (2.0.14) 第三方通知加入了 app 类型, 第三方报错将忽略异常继续运行
data/fir-cli.gemspec CHANGED
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
27
27
  /_/ /___/_/ |_| \____/_____/___/
28
28
 
29
29
  ## 更新记录
30
+ - (2.0.17) 增加了上传百分比显示
30
31
  - (2.0.16) 更新了 thor
31
32
  - (2.0.15) 修改了API域名
32
33
  - (2.0.14) 第三方通知加入了 app 类型, 第三方报错将不再直接报出异常
@@ -0,0 +1,42 @@
1
+ require 'net/http'
2
+ require 'tempfile'
3
+ require 'securerandom'
4
+
5
+ class Net::HTTP::UploadProgress
6
+ attr_reader :upload_size
7
+
8
+ def initialize(req, &block)
9
+ @req = req
10
+ @callback = block
11
+ @upload_size = 0
12
+ if req.body_stream
13
+ @io = req.body_stream
14
+ req.body_stream = self
15
+ elsif req.instance_variable_get(:@body_data)
16
+ raise NotImplementedError if req.chunked?
17
+ raise NotImplementedError if /\Amultipart\/form-data\z/i !~ req.content_type
18
+ opt = req.instance_variable_get(:@form_option).dup
19
+ opt[:boundary] ||= SecureRandom.urlsafe_base64(40)
20
+ req.set_content_type(req.content_type, boundary: opt[:boundary])
21
+ file = Tempfile.new('multipart')
22
+ file.binmode
23
+ req.send(:encode_multipart_form_data, file, req.instance_variable_get(:@body_data), opt)
24
+ file.rewind
25
+ req.content_length = file.size
26
+ @io = file
27
+ req.body_stream = self
28
+ else
29
+ raise NotImplementedError
30
+ end
31
+ end
32
+
33
+ def readpartial(maxlen, outbuf)
34
+ begin
35
+ str = @io.readpartial(maxlen, outbuf)
36
+ ensure
37
+ @callback.call(self) unless @upload_size.zero?
38
+ end
39
+ @upload_size += str.length
40
+ str
41
+ end
42
+ end
data/lib/fir/patches.rb CHANGED
@@ -8,3 +8,4 @@ require_relative './patches/native_patch'
8
8
  require_relative './patches/os_patch'
9
9
  require_relative './patches/try'
10
10
  require_relative './patches/default_headers'
11
+ require_relative './patches/progress'
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative './app_uploader'
4
- # require 'byebug'
4
+
5
5
 
6
6
  module FIR
7
7
  class AliUploader < AppUploader
@@ -16,7 +16,7 @@ module FIR
16
16
  icon_info = uploading_icon_info
17
17
 
18
18
  logger.debug "icon_url = #{icon_url}, icon_info = #{icon_info}"
19
- put_file(icon_url, uploading_icon_info, uploading_info[:cert][:icon][:custom_headers])
19
+ put_file(icon_url, uploading_icon_info, uploading_info[:cert][:icon][:custom_headers], false)
20
20
  callback_to_api(callback_url, callback_icon_information)
21
21
  end
22
22
  rescue StandardError => e
@@ -50,14 +50,43 @@ module FIR
50
50
 
51
51
  protected
52
52
 
53
- def put_file(url, file, headers)
54
- RestClient::Request.execute(
55
- method: 'PUT',
56
- url: url,
57
- payload: file,
58
- headers: headers,
59
- timeout: 300
60
- )
53
+ def put_file(url, file, headers, need_progress = true)
54
+
55
+ uri = URI(url)
56
+ hostname = uri.hostname
57
+
58
+
59
+ File.open(file_path, 'rb') do |io|
60
+ t = Time.now
61
+ http = Net::HTTP.new(hostname, 443)
62
+ http.use_ssl = true
63
+ req = Net::HTTP::Put.new(uri.request_uri, headers)
64
+ req.content_length = io.size
65
+ req.body_stream = io
66
+ Net::HTTP::UploadProgress.new(req) do |progress|
67
+ if need_progress
68
+ if progress.upload_size == io.size
69
+ puts "upload finished"
70
+ else
71
+ if Time.now - t > 0.5
72
+ puts "progress: #{ ((progress.upload_size / io.size.to_f) * 100).round(2) }%"
73
+ t = Time.now
74
+ end
75
+ end
76
+ end
77
+ end
78
+ res = http.request(req)
79
+ end
80
+
81
+
82
+
83
+ # RestClient::Request.execute(
84
+ # method: 'PUT',
85
+ # url: url,
86
+ # payload: file,
87
+ # headers: headers,
88
+ # timeout: 300
89
+ # )
61
90
  end
62
91
 
63
92
  def callback_url
data/lib/fir/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module FIR
4
- VERSION = "2.0.16"
4
+ VERSION = "2.0.17"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fir-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.16
4
+ version: 2.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - NaixSpirit
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-12-27 00:00:00.000000000 Z
12
+ date: 2023-01-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -224,6 +224,7 @@ files:
224
224
  - lib/fir/patches/instance_variables.rb
225
225
  - lib/fir/patches/native_patch.rb
226
226
  - lib/fir/patches/os_patch.rb
227
+ - lib/fir/patches/progress.rb
227
228
  - lib/fir/patches/try.rb
228
229
  - lib/fir/util.rb
229
230
  - lib/fir/util/ali_uploader.rb
@@ -271,14 +272,14 @@ metadata: {}
271
272
  post_install_message: "\n ______________ ________ ____\n /
272
273
  ____/ _/ __ \\ / ____/ / / _/\n / /_ / // /_/ /_____/ / / / /
273
274
  /\n / __/ _/ // _, _/_____/ /___/ /____/ /\n /_/ /___/_/ |_| \\____/_____/___/\n\n
274
- \ ## 更新记录\n - (2.0.16) 更新了 thor\n - (2.0.15) 修改了API域名\n - (2.0.14) 第三方通知加入了 app
275
- 类型, 第三方报错将不再直接报出异常\n - (2.0.13) 修复了无法跳过企业微信通知逻辑的bug\n - (2.0.12) 修复因为钉钉机器人不再支持base64导致无法显示二维码,另外开始支持钉钉加签方式的鉴权,
276
- 参数为 --dingtalk_secret\n - (2.0.11) 兼容了 ruby 3.0 版本, 增加了环境变量FEISHU_TIMEOUT,可以多给飞书一些超时时间\n
277
- \ - (2.0.10) 飞书支持了 V2 版本的机器人推送\n - (2.0.9) publish 支持了 企业微信通知 可以使用 --wxwork_access_token
278
- --wxwork_webhook, 增加了回调超时时间至20秒\n - (2.0.8) publish 支持 飞书通知, 可使用 `feishu_access_token`
279
- 和 `feishu_custom_message`, 详情见 `fir publish --help`\n - (2.0.7) 修复了提示 token 有问题的错误\n
280
- \ - [fir-cli](https://github.com/firhq/fir-cli) 已经开源\n - 欢迎 fork, issue 和 pull
281
- request\n "
275
+ \ ## 更新记录\n - (2.0.17) 增加了上传百分比显示\n - (2.0.16) 更新了 thor\n - (2.0.15) 修改了API域名\n
276
+ \ - (2.0.14) 第三方通知加入了 app 类型, 第三方报错将不再直接报出异常\n - (2.0.13) 修复了无法跳过企业微信通知逻辑的bug\n
277
+ \ - (2.0.12) 修复因为钉钉机器人不再支持base64导致无法显示二维码,另外开始支持钉钉加签方式的鉴权, 参数为 --dingtalk_secret\n
278
+ \ - (2.0.11) 兼容了 ruby 3.0 版本, 增加了环境变量FEISHU_TIMEOUT,可以多给飞书一些超时时间\n - (2.0.10) 飞书支持了
279
+ V2 版本的机器人推送\n - (2.0.9) publish 支持了 企业微信通知 可以使用 --wxwork_access_token 或 --wxwork_webhook,
280
+ 增加了回调超时时间至20秒\n - (2.0.8) publish 支持 飞书通知, 可使用 `feishu_access_token` 和 `feishu_custom_message`,
281
+ 详情见 `fir publish --help`\n - (2.0.7) 修复了提示 token 有问题的错误\n - [fir-cli](https://github.com/firhq/fir-cli)
282
+ 已经开源\n - 欢迎 fork, issue 和 pull request\n "
282
283
  rdoc_options: []
283
284
  require_paths:
284
285
  - lib
@@ -293,7 +294,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
293
294
  - !ruby/object:Gem::Version
294
295
  version: '0'
295
296
  requirements: []
296
- rubygems_version: 3.1.6
297
+ rubygems_version: 3.2.15
297
298
  signing_key:
298
299
  specification_version: 4
299
300
  summary: fir.im command tool