fir-cli 2.0.6 → 2.0.11

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: 97864a40ac333dbc4409f4d47edf3f47f7e5a9fe2117201be5dc0af2e4299afc
4
- data.tar.gz: ee2a1e9024f301c98f297f1d323638360844128d9420da584513977f61a1968b
3
+ metadata.gz: 7a6e11d653eba003963b009c6e428e117b0be296b92983be0cc4a410d823df5c
4
+ data.tar.gz: 9ce89648fd8d39f1e0f2597fd8275ce0c733cfa905dfeda0d2b4cb5eae74dc10
5
5
  SHA512:
6
- metadata.gz: 6eb0391dd736d296474e60ac193a54a94f926aecd8952b76def204f2fe3f6d01dc7e2b525456a3f3af7bc4b3aa3036eccaf570897b71e008040e665b42c0e945
7
- data.tar.gz: fb36d6101a15fdb3176d5e8529b8b6efb7586a121ddcf87c869c50c6ccceb097fd1b9d957e184ad420b11c902454258a8e7459ecb0ab29a9688a5c8ca495f4f1
6
+ metadata.gz: 5fc2e70ae12347d73e90e81d54c639cc3c54ee0ae12110465af24a71c904fef140a0d6cbfa6424e6376bb0ee9b54f1f73258dd41ab1db22d45cab857e487f725
7
+ data.tar.gz: 28d332b7bbe8a11bc16203e76ef87f26784b24d4bd317649d251161305affbc3d5e910f5a2aea926899b1b990358614b7599fee2235593f1333b1b4caf37fbe0
@@ -1,5 +1,5 @@
1
1
  rvm:
2
- - 2.4
2
+ - 3.0
3
3
  env:
4
4
  matrix:
5
5
  - USE_OFFICIAL_GEM_SOURCE=true
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  ✈ fir.im-cli
2
- ----
2
+ ----
3
3
 
4
4
  ![Build Status Images](https://travis-ci.org/FIRHQ/fir-cli.svg)
5
5
  [![Code Climate](https://codeclimate.com/github/FIRHQ/fir-cli/badges/gpa.svg)](https://codeclimate.com/github/FIRHQ/fir-cli)
@@ -13,11 +13,15 @@ fir.im-cli 可以通过指令查看, 上传, iOS/Android 应用.
13
13
  ![fir-cli](http://7rf35s.com1.z0.glb.clouddn.com/fir-cli-new.gif)
14
14
 
15
15
  # 重大提醒
16
- - fir.im 更换域名后, 需要升级至 `fir-cli` >= `2.0.4` 有部分用户反馈 2.0.2 无法直接使用 `gem update fir-cli` 升级到 2.0.4, 则可以尝试卸载后重新安装, 即 `gem uninstall fir-cli` 后 `gem install fir-cli`
17
- - 深信服 的 上网行为管理AC 的域名黑名单误将 fir-cli version 2.0.4 版本使用的 api.bq04.com 加入了黑名单, 我们已经联系了 深信服, 他们的回答是 `收到!已反馈!预计在3月17日左右的规则库更新,辛苦当时暂时需要使用的话先临时放通下,等规则库更新及时使用设备联网更新最新的规则库,有什么疑问您在及时反馈,感谢您的支持。
18
- 当然还有种解决办法是 更新 `fir-cli` 至 `2.0.5`, 这个版本换到了备用域名
16
+ - fir.im 更换域名后, 需要升级至 `fir-cli` >= `2.0.4` 有部分用户反馈 2.0.2 无法直接使用 `gem update fir-cli` 升级到 2.0.4, 则可以尝试卸载后重新安装, 即 `gem uninstall fir-cli` 后 `gem install fir-cli`
17
+
19
18
 
20
19
  # 最近更新
20
+ - (2.0.11) 兼容了 ruby 3.0
21
+ - (2.0.10) 飞书支持了 V2 版本的机器人推送
22
+ - (2.0.9) publish 支持了 企业微信通知 可以使用 --wxwork_access_token 或 --wxwork_webhook, 增加了回调超时时间至20秒
23
+ - (2.0.8) publish 支持 飞书通知, 可使用 `feishu_access_token` 和 `feishu_custom_message`, 详情见 `fir publish --help`
24
+ - (2.0.7) 修复了提示 token 错误的问题
21
25
  - (2.0.6) 修复了因为文件读取方式变化而导致的文件找不到不报错的问题
22
26
  - (2.0.5) 因为深信服 的黑名单误判, 将 api 切换到了备用域名
23
27
  - (2.0.4) 修复了 cdn 不支持 patch 方法透传, 导致在修改 app 信息的时候返回的 400 错误
@@ -44,24 +48,49 @@ fir.im-cli 可以通过指令查看, 上传, iOS/Android 应用.
44
48
 
45
49
  ## 热门问题
46
50
 
47
- ### 如何配合 jenkins 使用?
51
+ ### 啥是 钉钉 / 企业微信 / 飞书 的 `access_token` ?
52
+
53
+ 就是回调地址中的长得最像 access_token 的东西
54
+
55
+ ```
56
+ 钉钉: https://oapi.dingtalk.com/robot/send?access_token=xxxxx
57
+ 就是 xxx 那部分
58
+
59
+ 企业微信: https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxxx-xxxx-xxxx-xxxx-xxxxx
60
+ 就是 xxxxx-xxxx-xxxx-xxxx-xxxxx 那部分
61
+
62
+ https://open.feishu.cn/open-apis/bot/hook/xxxxxxxxxxxxxxxxxxx
63
+
64
+ 就是 xxxxxxxxxxxxxxxx 那部分
65
+
66
+ ```
67
+
68
+
69
+
70
+
71
+
72
+ ### 如何配合 jenkins 使用?
48
73
 
49
74
  参见 blog [http://blog.betaqr.com/use-fir-cli-in-jenkins/](http://blog.betaqr.com/use-fir-cli-in-jenkins/)
50
75
 
51
- ### Circle CI, Travis CI 或 Github Actions 等境外服务上, 有概率超时, 能否解决?
76
+ 这里有个快速检查脚本, 可以在 jenkins 中新建一个 脚本, 进行检查
52
77
 
53
- 2.0.3 版本 及其以上, 可以申请海外加速内测资格, 开启后可以使用海外加速上传
78
+ ```
79
+ #!/bin/bash --login
54
80
 
81
+ rvm list # 确保 rvm 正确安装, 如果直接通过系统安装ruby, 可以注释此行
82
+ ruby -v # 查看 ruby 的版本, 请确保大于 2.4.0
83
+ gem install fir-cli # 现场安装fir-cli , 如果安装过, 则会略过
84
+ fir -v # 查看 fir-cli 的版本
55
85
 
56
- 由于监管要求, 我们必须将服务于存储放置在境内. 由于众所周知的原因, 国内外连通性的表现不太好, 虽然我们的存储服务商 阿里云 提供了 OSS 境外加速服务, 但是高达 1.25 元/GB 的传输成本确实我们也没办法负担.
86
+ # 在这里执行 fir publish xxxxx
87
+ ```
57
88
 
58
89
 
90
+ ### 在 Circle CI, Travis CI 或 Github Actions 等境外服务上, 有概率超时, 能否解决?
59
91
 
60
- 目前我们提供三种临时解决方案来缓解问题(2.0.2以下版本):
92
+ 2.0.3 版本 及其以上, 可以申请海外加速内测资格, 开启后可以使用海外加速上传 `--oversea_turbo`
61
93
 
62
- 1. 设置较长的超时时间 如 `FIR_TIMEOUT=300 fir publish xxxx`, 则可将超时时间设置为 300 秒.
63
- 2. 如果fir-cli 版本 >= 2.0.0, 也可在出现超时后, 使用 `--switch-to-qiniu` 来切换到我们的另外一条存储线路. 如 `fir publish xxxx.apk --switch-to-qiniu`, 多一条线路备选.
64
- 3. 如果确实对这方面服务要求很高, 则可购买我们的私有部署服务. 我们可以在 aws 上部署一套专供您使用, 具体情况可以与客服或者加我微信进行沟通.
65
94
 
66
95
  更多细节请参考 [https://github.com/FIRHQ/fir-cli/issues/260](https://github.com/FIRHQ/fir-cli/issues/260)
67
96
 
@@ -90,13 +119,13 @@ fir-cli 提供对 aab 文件有限程度支持的上传与下载. 在使用 fir-
90
119
 
91
120
  ### 我想将 我上传的版本展示在下载的页面上
92
121
 
93
- 可以在 publish 的时候使用 --force_pin_history 这样 这个上传的版本即成为 "历史版本", 会在下载页面里一直显示. 当有新的版本上传后, 这个版本会作为 "历史版本" 在下载页面中展示.
122
+ 可以在 publish 的时候使用 --force_pin_history 这样 这个上传的版本即成为 "历史版本", 会在下载页面里一直显示. 当有新的版本上传后, 这个版本会作为 "历史版本" 在下载页面中展示.
94
123
 
95
124
  当版本设置为历史版本后, 用户可以直接下载指定的版本, 由于因成本原因, 一个 app 最多的 "历史版本" 为 30 个, 如果有用户有特殊需求, 可以与我们取得联系进行单独修改
96
125
 
97
126
  当达到上限后, 如果继续标记 force_pin_history, 则历史版本的最老版本(以上传时间为准)会被移出历史版本列表
98
127
 
99
- ### 境外上传老出现 stream closed
128
+ ### 境外上传老出现 stream closed
100
129
 
101
130
  因为网络时延问题, 可传入环境变量 `FIR_TIMEOUT=xxx` 进行超时时间设置
102
131
 
@@ -111,22 +140,22 @@ fir-cli 提供对 aab 文件有限程度支持的上传与下载. 在使用 fir-
111
140
  - [fir publish 发布应用到 fir.im](https://github.com/FIRHQ/fir-cli/blob/master/doc/publish.md)
112
141
  - [fir upgrade 升级相关](https://github.com/FIRHQ/fir-cli/blob/master/doc/upgrade.md)
113
142
 
114
- ## Docker 运行 fir-cli
143
+ ## Docker 运行 fir-cli
115
144
 
116
145
  ### 准备工作
117
146
  1. 将自己需要的文件挂载到 docker 中, 之后即可直接运行
118
- 2. 将自己的 API_TOKEN 以环境变量的形式传入container
147
+ 2. 将自己的 API_TOKEN 以环境变量的形式传入container
119
148
 
120
149
  ### 如何运行
121
150
 
122
- 假设 我需要上传桌面的 1.apk
151
+ 假设 我需要上传桌面的 1.apk
123
152
 
124
153
  ```
125
- docker run -e API_TOKEN=您的token -v 您的上传文件的目录的绝对路径:/tmp firhq/fir-cli:latest publish /tmp/你的文件
154
+ docker run -e API_TOKEN=您的token -v 您的上传文件的目录的绝对路径:/tmp firhq/fir-cli:latest publish /tmp/你的文件
126
155
 
127
156
  # 如 `docker run -e API_TOKEN=xxxxxxxe -v /Users/atpking/Desktop:/tmp firhq/fir-cli:latest publish /tmp/1.apk`
128
157
 
129
- # 实际含义是把我的桌面挂载到 docker 里的 /tmp 目录 之后上传 docker 文件里的 /tmp/1.apk
158
+ # 实际含义是把我的桌面挂载到 docker 里的 /tmp 目录 之后上传 docker 文件里的 /tmp/1.apk
130
159
  # 也可以修改为其他目录
131
160
  ```
132
161
 
@@ -134,13 +163,13 @@ docker run -e API_TOKEN=您的token -v 您的上传文件的目录的绝对路
134
163
 
135
164
  - 联系微信 `atpking`, 请注明 "fir-cli 交流"
136
165
 
137
- - 使用 Github 的 [Issue](https://github.com/FIRHQ/fir-cli/issues)
166
+ - 使用 Github 的 [Issue](https://github.com/FIRHQ/fir-cli/issues)
138
167
 
139
- ## 特别感谢
168
+ ## 特别感谢
140
169
 
141
170
  - 感谢 sparkrico 提供修正的 https://github.com/sparkrico/ruby_apk 解决了 android 解析的问题
142
-
171
+ - 感谢 fabcz 同学对企业微信的通知的支持 https://github.com/FIRHQ/fir-cli/pull/277
143
172
 
144
173
  ## 鼓励维护
145
174
 
146
- 挂了好久没都人鼓励维护, 想想算了吧
175
+ hia~ hia~ hia~
@@ -3,33 +3,56 @@
3
3
  `fir publish` 命令用于可以发布应用到 fir.im, 支持 ipa 和 apk 文件.
4
4
 
5
5
  ```sh
6
- $ fir publish --help
7
6
  Usage:
8
7
  fir publish APP_FILE_PATH
9
8
 
10
9
  Options:
11
- -s, [--short=SHORT] # Set custom short link
12
- -c, [--changelog=CHANGELOG] # Set changelog
13
- -Q, [--qrcode], [--no-qrcode] # Generate qrcode
14
- [--open], [--no-open] # true/false if open for everyone
15
- [--password=PASSWORD] # Set password for app
16
- -T, [--token=TOKEN] # User's API Token at fir.im
17
- -L, [--logfile=LOGFILE] # Path to writable logfile
18
- -R, [--need_release_id] # show release_id in download_url
19
- -D, [--dingtalk_accesss_token=DINGTALK_ACCESS_TOKEN] # dingtalk notification
20
- -V, [--verbose], [--no-verbose] # Show verbose
21
- # Default: true
22
- -q, [--quiet], [--no-quiet] # Silence commands
23
- -h, [--help], [--no-help] # Show this help message and quit
10
+ -s, [--short=SHORT] # 设置short
11
+ -c, [--changelog=CHANGELOG] # 设置更新内容, 可是文件地址也可直接是内容
12
+ -Q, [--qrcode], [--no-qrcode] # 生成二维码图片在当前目录
13
+ [--need-ansi-qrcode], [--no-need-ansi-qrcode] #
14
+ -R, [--need-release-id], [--no-need-release-id] # 在下载地址中包含具体版本(警告, 每个app 最多保留30个版本, 超过后会失效最老的版本)
15
+ -H, [--force-pin-history], [--no-force-pin-history] # 将版本留在下载页(即在新版本上传后, 下面仍然有旧版本的二维码可以引导)
16
+ -S, [--skip-update-icon], [--no-skip-update-icon] # 跳过更新图标
17
+ [--specify-icon-file=SPECIFY_ICON_FILE] # 指定更新图标
18
+ [--skip-fir-cli-feedback], [--no-skip-fir-cli-feedback] # 跳过 用来做统计fir-cli的反馈(用于改进fir-cli)
19
+ [--specify-app-display-name=SPECIFY_APP_DISPLAY_NAME] # 指定app 名称
20
+ -N, [--switch-to-qiniu], [--no-switch-to-qiniu] # 切换到七牛线路上传(当上传较慢时, 可试试这个)
21
+ [--oversea-turbo], [--no-oversea-turbo] # 海外加速(需联系微信 atpking 开通)
22
+ -m, [--mappingfile=MAPPINGFILE] # mappingfile
23
+ -D, [--dingtalk-access-token=DINGTALK_ACCESS_TOKEN] # 上传完毕后 若发送至钉钉, 则填写钉钉的webhook 的access_token
24
+ [--dingtalk-custom-message=DINGTALK_CUSTOM_MESSAGE] # 自定义钉钉消息 (针对钉钉新版webhook 需要校验的时候, 可以做关键字)
25
+ [--dingtalk-at-phones=DINGTALK_AT_PHONES] # 钉钉 at 某人手机号
26
+ [--dingtalk-at-all], [--no-dingtalk-at-all]
27
+ [--feishu-access-token=FEISHU_ACCESS_TOKEN] # 飞书的webhook 的access_token
28
+ [--feishu-custom-message=FEISHU_CUSTOM_MESSAGE] # 自定义飞书消息
29
+ [--wxwork-webhook=WXWORK_WEBHOOK] # 企业微信的 webhook 地址 (注意这里与 access_token 只需要填写一个参数即可)
30
+ [--wxwork-access-token=WXWORK_ACCESS_TOKEN] # 企业微信的 webhook access_token (注意这里与 access_token 只需要填写一个参数即可)
31
+ [--wxwork-custom-message=WXWORK_CUSTOM_MESSAGE] # 企业微信 的自定义消息
32
+ [--wxwork-pic-url=WXWORK_PIC_URL] # 企业微信的图片链接, best size is 1068x455
33
+ [--open], [--no-open] # 是否下载可见, 默认open
34
+ [--password=PASSWORD] # 下载页面密码, 默认为空
35
+ [--bundletool-jar-path=BUNDLETOOL_JAR_PATH] # (beta) 上传AAB 文件的特殊指令: upload aab file command: to specify bundletool.jar if command bundletool can not run directly
36
+ [--auto-download-bundletool-jar], [--no-auto-download-bundletool-jar] # (beta) 上传AAB 文件的特殊指令: upload aab file command: would download bundletool when invoke bundletool failure
37
+ -T, [--token=TOKEN] # betaqr.com(fir.im) 账户的 API_TOKEN
38
+ -L, [--logfile=LOGFILE] # Path to writable logfile
39
+ -V, [--verbose], [--no-verbose] # Show verbose
40
+ # Default: true
41
+ -q, [--quiet], [--no-quiet] # Silence commands
42
+ -h, [--help], [--no-help] # Show this help message and quit
43
+
44
+ Description:
45
+ `publish` command will publish your app file to fir.im, also the command support to publish app's short & changelog.
46
+
47
+ Example:
48
+
49
+ $ fir p <app file path> [-c <changelog> -s <custom short link> -Q -T <your api token>]
50
+
51
+ $ fir p <app file path> [-c <changelog> -s <custom short link> --password=123456 --open=false -Q -T <your api token>]
52
+
53
+ $ fir p <app file path> [-c <changelog> -s <custom short link> -m <mapping file path> -P <bughd project id> -Q -T <your
54
+ api token>]
24
55
  ```
25
56
 
26
- 相关参数详解:
27
57
 
28
- - `-s` 参数, 自定义发布后的短链接地址.
29
- - `-c` 参数, 自定义发布时的 changelog, 支持字符串与文件两种方式, 即 `--changelog='this is changelog'` 和 `--changelog='/Users/fir-cli/changelog'`.
30
- - `-Q` 参数, 是否生成发布后二维码, 默认为不生成, 加上 `-Q` 参数后会在当前目录生成一张二维码图片, 扫描该图片即可下载该应用.
31
- - `-R` 参数, 显示具体版本, 会在发布结束后的下载地址中生成指定的版本
32
- - `-D` 参数, 钉钉机器人的access_token, 填写后当上传完毕, 会发送至钉钉机器人
33
- - `--open` 参数, 设置发布后的应用是否开放给所有人下载, 关闭开放使用 `--no-open` 参数.
34
- - `--password` 参数, 设置发布后的应用密码
35
58
 
@@ -27,6 +27,11 @@ Gem::Specification.new do |spec|
27
27
  /_/ /___/_/ |_| \____/_____/___/
28
28
 
29
29
  ## 更新记录
30
+ - (2.0.11) 兼容了 ruby 3.0 版本, 增加了环境变量FEISHU_TIMEOUT,可以多给飞书一些超时时间
31
+ - (2.0.10) 飞书支持了 V2 版本的机器人推送
32
+ - (2.0.9) publish 支持了 企业微信通知 可以使用 --wxwork_access_token 或 --wxwork_webhook, 增加了回调超时时间至20秒
33
+ - (2.0.8) publish 支持 飞书通知, 可使用 `feishu_access_token` 和 `feishu_custom_message`, 详情见 `fir publish --help`
34
+ - (2.0.7) 修复了提示 token 有问题的错误
30
35
  - (2.0.6) 将校验文件是否存在提前
31
36
  - (2.0.5) 更换了上传域名, 避免与 深信服的设备冲突
32
37
  - (2.0.4) 修复了 cdn 不支持 patch 方法透传, 导致在修改 app 信息的时候返回的 400 错误
@@ -48,12 +53,13 @@ Gem::Specification.new do |spec|
48
53
  # spec.add_development_dependency 'byebug'
49
54
  spec.add_development_dependency 'minitest', '~> 5.7'
50
55
  spec.add_development_dependency 'pry', '~> 0.10'
51
-
56
+
52
57
  spec.add_dependency 'admqr_knife', '~> 0.1.5'
53
58
  spec.add_dependency 'thor', '~> 0.19'
54
59
  spec.add_dependency 'rest-client', '~> 2.0'
55
60
  spec.add_dependency 'ruby_android_apk', '~> 0.7.7.1'
56
61
  spec.add_dependency 'rqrcode', '~> 0.7'
62
+ spec.add_dependency 'rexml'
57
63
  spec.add_dependency 'CFPropertyList'
58
- spec.add_dependency 'api_tools', '~> 0.1.0'
64
+ spec.add_dependency 'api_tools', '~> 0.1.1'
59
65
  end
data/lib/fir.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # require 'byebug'
3
4
  require 'thor'
4
5
  require 'logger'
5
6
  require 'yaml'
@@ -2,6 +2,7 @@ fir:
2
2
  domain: 'http://www.betaqr.com'
3
3
  base_url: 'http://fir-api.admqr.com'
4
4
  user_url: 'http://fir-api.admqr.com/user'
5
+ user_feishu_access_token: 'http://fir-api.admqr.com/user/fetch_feishu_v3_token'
5
6
  app_url: 'http://fir-api.admqr.com/apps'
6
7
  udids_url: 'http://fir-api.admqr.com/devices/multi_udid'
7
8
 
@@ -127,6 +127,14 @@ module FIR
127
127
  method_option :dingtalk_at_phones, type: :string, desc: 'at some phones, split by , eg: 13111111111,13111111112'
128
128
  method_option :dingtalk_at_all, type: :boolean, default: false
129
129
 
130
+ method_option :feishu_access_token, type: :string, desc: 'Send msg to feishu, need access_token, not whole url'
131
+ method_option :feishu_custom_message, type: :string, desc: 'add custom message to feishu'
132
+
133
+ method_option :wxwork_webhook, type: :string, desc: 'wxwork webhook url (optional)'
134
+ method_option :wxwork_access_token, type: :string, desc: 'Send msg to wxwork group, need group bot webhook, not whole url'
135
+ method_option :wxwork_custom_message, type: :string, desc: 'add custom message to wxwork group'
136
+ method_option :wxwork_pic_url, type: :string, desc: 'message background image, best size is 1068x455'
137
+
130
138
  method_option :open, type: :boolean, desc: 'true/false if open for everyone'
131
139
  method_option :password, type: :string, desc: 'Set password for app'
132
140
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FIR
2
4
  class AppUploader
3
5
  include ApiTools::DefaultRestModule
@@ -14,6 +16,8 @@ module FIR
14
16
  def upload
15
17
  upload_icon
16
18
  binary_callback_info = upload_binary
19
+ raise binary_callback_info if binary_callback_info.is_a? StandardError
20
+
17
21
  # 将 binary 的callback信息返回
18
22
  binary_callback_info
19
23
  end
@@ -21,9 +25,12 @@ module FIR
21
25
  protected
22
26
 
23
27
  def callback_to_api(callback_url, callback_binary_information)
28
+ logger.debug 'begin to callback api'
24
29
  return if callback_binary_information.blank?
25
30
 
26
- post callback_url, callback_binary_information
31
+ answer = post callback_url, callback_binary_information, timeout: 20
32
+ logger.debug 'callback api finished'
33
+ answer
27
34
  end
28
35
 
29
36
  def icon_file_path
@@ -74,6 +81,7 @@ module FIR
74
81
 
75
82
  def callback_icon_information
76
83
  return {} if icon_file_path.nil?
84
+
77
85
  {
78
86
  key: icon_cert[:key],
79
87
  token: icon_cert[:token],
@@ -106,6 +114,5 @@ module FIR
106
114
  def logger
107
115
  FIR.logger
108
116
  end
109
-
110
117
  end
111
- end
118
+ end
@@ -0,0 +1,95 @@
1
+ require 'json'
2
+ # require 'byebug'
3
+ class FeishuHelper
4
+ attr_accessor :app_info, :options, :feishu_access_token, :qrcode_path, :image_key, :download_url, :title
5
+ include FIR::Config
6
+
7
+ def initialize(app_info, options, qrcode_path, download_url)
8
+ @app_info = app_info
9
+ @options = options
10
+ @feishu_access_token = @options[:feishu_access_token]
11
+ @qrcode_path = qrcode_path
12
+ @download_url = download_url
13
+ @title = "#{@app_info[:name]}-#{@app_info[:version]}(Build #{@app_info[:build]})"
14
+ end
15
+
16
+ def send_msg
17
+ return if feishu_access_token.blank?
18
+
19
+ answer = v2_request
20
+ v1_request if answer.dig('ok') == 'false'
21
+ end
22
+
23
+ def v2_request
24
+ url = "https://open.feishu.cn/open-apis/bot/v2/hook/#{feishu_access_token}"
25
+ x = build_v2_info
26
+ # byebug
27
+ DefaultRest.post(url, x, {timeout: ENV['FEISHU_TIMEOUT'] ? ENV['FEISHU_TIMEOUT'].to_i : 30 })
28
+ end
29
+
30
+ def v1_request
31
+ url = "https://open.feishu.cn/open-apis/bot/hook/#{feishu_access_token}"
32
+ payload = {
33
+ "title": "#{title} uploaded",
34
+ "text": "#{title} uploaded at #{Time.now}\nurl: #{download_url}\n#{options[:feishu_custom_message]}\n"
35
+ }
36
+ DefaultRest.post(url, payload, {timeout: ENV['FEISHU_TIMEOUT'] ? ENV['FEISHU_TIMEOUT'].to_i : 30 })
37
+ end
38
+
39
+ private
40
+
41
+ def build_v2_info
42
+ {
43
+ msg_type: 'post',
44
+ content: {
45
+ post: {
46
+ zh_cn: {
47
+ title: title,
48
+ content: [build_info_tags, [build_image_tag]]
49
+ }
50
+ }
51
+ }
52
+ }
53
+ end
54
+
55
+ def build_info_tags
56
+ text = "#{title} uploaded at #{Time.now}\n#{options[:feishu_custom_message]}\n"
57
+ [
58
+ {
59
+ "tag": 'text',
60
+ "text": text
61
+ },
62
+ {
63
+ "tag": 'a',
64
+ "text": download_url,
65
+ "href": download_url
66
+ }
67
+ ]
68
+ end
69
+
70
+ def build_image_tag
71
+ {
72
+ "tag": 'img',
73
+ "image_key": upload_qr_code,
74
+ "width": 300,
75
+ "height": 300
76
+ }
77
+ end
78
+
79
+ def fetch_image_access_token
80
+ answer = DefaultRest.post(fir_api[:fetch_feishu_v3_token] || 'http://fir-api.admqr.com/user/fetch_feishu_v3_token', {})
81
+ answer[:feishu_v3_token]
82
+ end
83
+
84
+ def upload_qr_code
85
+ answer = RestClient.post('https://open.feishu.cn/open-apis/image/v4/put/', {
86
+ image_type: 'message',
87
+ image: File.new(qrcode_path, 'rb')
88
+ }, {
89
+ 'Authorization' => "Bearer #{fetch_image_access_token}"
90
+ })
91
+
92
+ json = JSON.parse(answer)
93
+ json.dig('data', 'image_key')
94
+ end
95
+ end
@@ -1,8 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # require 'byebug'
4
+
4
5
  require_relative './qiniu_uploader'
5
6
  require_relative './ali_uploader'
7
+ require_relative '../util/feishu_helper'
6
8
 
7
9
  module FIR
8
10
  module Publish
@@ -11,6 +13,7 @@ module FIR
11
13
  logger_info_publishing_message
12
14
 
13
15
  logger.info 'begin to upload ...'
16
+ logger.info "fir-cli version #{FIR::VERSION} (#{RUBY_VERSION} @ #{RUBY_PLATFORM})"
14
17
  received_app_info = upload_app
15
18
 
16
19
  short = received_app_info[:short]
@@ -25,7 +28,11 @@ module FIR
25
28
  logger.info "Published succeed: #{download_url}"
26
29
 
27
30
  qrcode_path = build_qrcode download_url
31
+
28
32
  dingtalk_notifier(download_url, qrcode_path)
33
+ feishu_notifier(download_url, qrcode_path)
34
+ wxwork_notifier(download_url)
35
+
29
36
  upload_mapping_file_with_publish
30
37
 
31
38
  upload_fir_cli_usage_info(received_app_info)
@@ -212,6 +219,30 @@ module FIR
212
219
  logger.warn "Dingtalk send error #{e.message}"
213
220
  end
214
221
 
222
+ def feishu_notifier(download_url, qrcode_path)
223
+ FeishuHelper.new(@app_info, options, qrcode_path, download_url).send_msg
224
+ end
225
+
226
+ def wxwork_notifier(download_url)
227
+ webhook_url = options[:wxwork_webhook]
228
+ webhook_url ||= "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=#{options[:wxwork_access_token]}"
229
+ return if webhook_url.blank?
230
+
231
+ title = "#{@app_info[:name]}-#{@app_info[:version]}(Build #{@app_info[:build]})"
232
+ payload = {
233
+ "msgtype": "news",
234
+ "news": {
235
+ "articles": [{
236
+ "title": "#{title} uploaded",
237
+ "description": "#{title} uploaded at #{Time.now}\nurl: #{download_url}\n#{options[:wxwork_custom_message]}\n",
238
+ "url": download_url,
239
+ "picurl": options[:wxwork_pic_url]
240
+ }],
241
+ },
242
+ }
243
+ DefaultRest.post(webhook_url, payload)
244
+ end
245
+
215
246
  def initialize_publish_options(args, options)
216
247
  @options = options
217
248
  @file_path = File.absolute_path(args.first.to_s)
@@ -219,9 +250,10 @@ module FIR
219
250
 
220
251
  check_file_exist(@file_path)
221
252
  check_supported_file(@file_path)
222
- check_token_cannot_be_blank(@token)
223
253
 
224
254
  @token = options[:token] || current_token
255
+ check_token_cannot_be_blank(@token)
256
+
225
257
  @changelog = read_changelog(options[:changelog]).to_s.to_utf8
226
258
  @short = options[:short].to_s
227
259
  @passwd = options[:password].to_s
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module FIR
4
- VERSION = '2.0.6'
4
+ VERSION = '2.0.11'
5
5
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fir-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.6
4
+ version: 2.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - NaixSpirit
8
8
  - atpking
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-03-15 00:00:00.000000000 Z
12
+ date: 2021-01-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -137,6 +137,20 @@ dependencies:
137
137
  - - "~>"
138
138
  - !ruby/object:Gem::Version
139
139
  version: '0.7'
140
+ - !ruby/object:Gem::Dependency
141
+ name: rexml
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ type: :runtime
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
140
154
  - !ruby/object:Gem::Dependency
141
155
  name: CFPropertyList
142
156
  requirement: !ruby/object:Gem::Requirement
@@ -157,14 +171,14 @@ dependencies:
157
171
  requirements:
158
172
  - - "~>"
159
173
  - !ruby/object:Gem::Version
160
- version: 0.1.0
174
+ version: 0.1.1
161
175
  type: :runtime
162
176
  prerelease: false
163
177
  version_requirements: !ruby/object:Gem::Requirement
164
178
  requirements:
165
179
  - - "~>"
166
180
  - !ruby/object:Gem::Version
167
- version: 0.1.0
181
+ version: 0.1.1
168
182
  description: fir.im command tool, support iOS and Android
169
183
  email:
170
184
  - atpking@gmail.com
@@ -218,6 +232,7 @@ files:
218
232
  - lib/fir/util/build_common.rb
219
233
  - lib/fir/util/build_ipa.rb
220
234
  - lib/fir/util/config.rb
235
+ - lib/fir/util/feishu_helper.rb
221
236
  - lib/fir/util/http.rb
222
237
  - lib/fir/util/info.rb
223
238
  - lib/fir/util/login.rb
@@ -254,9 +269,13 @@ metadata: {}
254
269
  post_install_message: "\n ______________ ________ ____\n /
255
270
  ____/ _/ __ \\ / ____/ / / _/\n / /_ / // /_/ /_____/ / / / /
256
271
  /\n / __/ _/ // _, _/_____/ /___/ /____/ /\n /_/ /___/_/ |_| \\____/_____/___/\n\n
257
- \ ## 更新记录\n - (2.0.6) 将校验文件是否存在提前\n - (2.0.5) 更换了上传域名, 避免与 深信服的设备冲突\n - (2.0.4)
258
- 修复了 cdn 不支持 patch 方法透传, 导致在修改 app 信息的时候返回的 400 错误\n - (2.0.3) 增加 dingtalk_at_phones,
259
- 钉钉通知可 at 用户手机号, 以逗号,分割. 此命令需配合 `dingtalk_access_token` 使用\n - (2.0.3) 增加 dingtalk_at_all,
272
+ \ ## 更新记录\n - (2.0.11) 兼容了 ruby 3.0 版本, 增加了环境变量FEISHU_TIMEOUT,可以多给飞书一些超时时间\n -
273
+ (2.0.10) 飞书支持了 V2 版本的机器人推送\n - (2.0.9) publish 支持了 企业微信通知 可以使用 --wxwork_access_token
274
+ --wxwork_webhook, 增加了回调超时时间至20秒\n - (2.0.8) publish 支持 飞书通知, 可使用 `feishu_access_token`
275
+ 和 `feishu_custom_message`, 详情见 `fir publish --help`\n - (2.0.7) 修复了提示 token 有问题的错误\n
276
+ \ - (2.0.6) 将校验文件是否存在提前\n - (2.0.5) 更换了上传域名, 避免与 深信服的设备冲突\n - (2.0.4) 修复了 cdn
277
+ 不支持 patch 方法透传, 导致在修改 app 信息的时候返回的 400 错误\n - (2.0.3) 增加 dingtalk_at_phones, 钉钉通知可
278
+ at 用户手机号, 以逗号,分割. 此命令需配合 `dingtalk_access_token` 使用\n - (2.0.3) 增加 dingtalk_at_all,
260
279
  钉钉通知可 at 所有人, 此命令需配合 `dingtalk_access_token` 使用\n - (2.0.3) publish 增加海外加速参数 --oversea_turbo\n
261
280
  \ - (2.0.2) 有限支持 aab 文件上传, 强依赖`bundletool`工具, 具体请参见参数 `--bundletool_jar_path` 和
262
281
  `auto_download_bundletool_jar`\n - (2.0.1) publish 支持 新参数 `specify_app_display_name`,
@@ -280,8 +299,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
280
299
  - !ruby/object:Gem::Version
281
300
  version: '0'
282
301
  requirements: []
283
- rubygems_version: 3.0.3
284
- signing_key:
302
+ rubygems_version: 3.2.3
303
+ signing_key:
285
304
  specification_version: 4
286
305
  summary: fir.im command tool
287
306
  test_files: