fir-cli 2.0.16 → 2.0.18

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: e15f62a0f7b559dac0e47d7aa637df6de1f267b950dc8d5c429f0539c0fd1f94
4
+ data.tar.gz: 8e42b4e2f0441651edd0871b8189b96fecfebbe068b6d5cd4408bc6e94d83137
5
5
  SHA512:
6
- metadata.gz: b315d5ab9228498d1dd0aff2dc09d01d744bace237fc6cd79a2be2d1d947d101efad64297153356f03e5c08596ba5a6e00a5e220487a599ad65e1800859f2248
7
- data.tar.gz: 275d8de0a02933dcd52d59c24303e1453bb5267b08fb79c9a70ff75a809307f2f8db2e75029bed4e2b698cb8e59bcb4d5720a2d3e0372ed576138db7f8ef5984
6
+ metadata.gz: df855650a9ba20ebf25a5b24b80802868a65c8883349639afe73ffe16c2adb00ec42483dc9627f023bb035b7b5c0422f4db8a2bc9bc97086c6055fb2d22f0e2f
7
+ data.tar.gz: bb152238bbd5b95af55dd6d1109087872edbb18fda3396ba71260bc596ceb4309bf2ecb3136f7969d0e6b1af73457190358c1b315f7da1cb16e788b013818a64
data/README.md CHANGED
@@ -18,7 +18,9 @@ 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.16) 更新了 thor
21
+ - (2.0.18) 修复域名导致的飞书发送失败的问题
22
+ - (2.0.17) 增加了上传百分比显示
23
+ - (2.0.16) 更新了 thor
22
24
  - (2.0.15) 更换了 API 域名
23
25
  - (2.0.14) 第三方通知加入了 app 类型, 第三方报错将忽略异常继续运行
24
26
  - (2.0.13) 修正了企业微信通知的bug
data/fir-cli.gemspec CHANGED
@@ -26,19 +26,10 @@ Gem::Specification.new do |spec|
26
26
  / __/ _/ // _, _/_____/ /___/ /____/ /
27
27
  /_/ /___/_/ |_| \____/_____/___/
28
28
 
29
- ## 更新记录
30
- - (2.0.16) 更新了 thor
31
- - (2.0.15) 修改了API域名
32
- - (2.0.14) 第三方通知加入了 app 类型, 第三方报错将不再直接报出异常
33
- - (2.0.13) 修复了无法跳过企业微信通知逻辑的bug
34
- - (2.0.12) 修复因为钉钉机器人不再支持base64导致无法显示二维码,另外开始支持钉钉加签方式的鉴权, 参数为 --dingtalk_secret
35
- - (2.0.11) 兼容了 ruby 3.0 版本, 增加了环境变量FEISHU_TIMEOUT,可以多给飞书一些超时时间
36
- - (2.0.10) 飞书支持了 V2 版本的机器人推送
37
- - (2.0.9) publish 支持了 企业微信通知 可以使用 --wxwork_access_token 或 --wxwork_webhook, 增加了回调超时时间至20秒
38
- - (2.0.8) publish 支持 飞书通知, 可使用 `feishu_access_token` 和 `feishu_custom_message`, 详情见 `fir publish --help`
39
- - (2.0.7) 修复了提示 token 有问题的错误
29
+ ##
40
30
  - [fir-cli](https://github.com/firhq/fir-cli) 已经开源
41
31
  - 欢迎 fork, issue 和 pull request
32
+ - 同时提供 go 版本的 fir-cli 二进制版本无依赖 [fir-cli-go](https://github.com/PGYER/go-fir-cli/releases)
42
33
  )
43
34
 
44
35
  spec.add_development_dependency 'bundler'
@@ -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
@@ -78,7 +78,7 @@ class FeishuHelper
78
78
  end
79
79
 
80
80
  def fetch_image_access_token
81
- answer = DefaultRest.post(fir_api[:fetch_feishu_v3_token] || 'http://fir-api.admqr.com/user/fetch_feishu_v3_token', {})
81
+ answer = DefaultRest.post(fir_api[:user_feishu_access_token] || 'http://api.appmeta.cn/user/fetch_feishu_v3_token', {})
82
82
  answer[:feishu_v3_token]
83
83
  end
84
84
 
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.18"
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.18
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-03-09 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,9 @@ 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 - [fir-cli](https://github.com/firhq/fir-cli) 已经开源\n - 欢迎 fork, issue
276
+ pull request\n - 同时提供 go 版本的 fir-cli 二进制版本无依赖 [fir-cli-go](https://github.com/PGYER/go-fir-cli/releases)\n
277
+ \ "
282
278
  rdoc_options: []
283
279
  require_paths:
284
280
  - lib
@@ -293,7 +289,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
293
289
  - !ruby/object:Gem::Version
294
290
  version: '0'
295
291
  requirements: []
296
- rubygems_version: 3.1.6
292
+ rubygems_version: 3.4.1
297
293
  signing_key:
298
294
  specification_version: 4
299
295
  summary: fir.im command tool