ocean_package 0.15.0 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/ocean_package/command.rb +59 -2
- data/lib/ocean_package/time_flow.rb +1 -1
- data/lib/ocean_package/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fdeaa9f9c0ec67459f5383a4ee8b93ab9d4ba23c1ab6824deafb6016871a6df
|
4
|
+
data.tar.gz: ff1af0e34f1334cdb203093f11043699b5e118b2ea867e26df40a51e12c09c1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abb4364e4cea33d8768dfaf0ed616ea4a31280b1c2cf3f5e0b7d28d12068c5dbfde477835d6ad16588b5d7ecbe2f8a2d60704cd51c22bdc82670418810d30d96
|
7
|
+
data.tar.gz: 40a35d23d5f527c2983f9a6b91276044ff094cf20048317336c95deb1b52c5288ffea22e5f5a63b9da9f222a28036aab5b77d1b1399188daa0c994d32cc8e024
|
data/Gemfile.lock
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
module OceanPackage
|
3
3
|
class Command
|
4
4
|
include OceanPackage::TimeFlow::Mixin
|
5
|
+
require 'net/http'
|
6
|
+
require 'uri'
|
5
7
|
|
6
8
|
# xcodebuild 打包相关
|
7
9
|
attr_accessor :package
|
@@ -26,6 +28,11 @@ module OceanPackage
|
|
26
28
|
# 自定义的ipa文件路径
|
27
29
|
attr_accessor :custom_ipa_file_path
|
28
30
|
|
31
|
+
# 整个流程时间记录上报url
|
32
|
+
attr_accessor :time_flow_url
|
33
|
+
|
34
|
+
# 整个流程时间记录上报url,额外的参数
|
35
|
+
attr_accessor :time_flow_extra_req
|
29
36
|
|
30
37
|
def initialize(params = [])
|
31
38
|
argv = CLAide::ARGV.new(params)
|
@@ -63,6 +70,14 @@ module OceanPackage
|
|
63
70
|
open_finder = argv.flag?("open-finder", false )
|
64
71
|
Log.info("open-finder: #{open_finder}")
|
65
72
|
|
73
|
+
time_flow_url = argv.option("time-flow-url", "")
|
74
|
+
Log.info("time_flow_url: #{time_flow_url}")
|
75
|
+
@time_flow_url = time_flow_url
|
76
|
+
|
77
|
+
time_flow_extra_req = argv.option("time-flow-extra-req", "")
|
78
|
+
Log.info("time_flow_extra_req: #{time_flow_extra_req}")
|
79
|
+
@time_flow_extra_req = time_flow_extra_req
|
80
|
+
|
66
81
|
# 自定义ipa文件,使用该文件作为 archive path
|
67
82
|
tmp_archive_path = has_custom_ipa_file ? File.dirname("#{ipa_file_path}") : archive_path
|
68
83
|
Log.info("tmp_archive_path: #{tmp_archive_path}")
|
@@ -187,6 +202,17 @@ module OceanPackage
|
|
187
202
|
seconds
|
188
203
|
end
|
189
204
|
|
205
|
+
# 总共时间,单位 分
|
206
|
+
def compute_total_time_minute
|
207
|
+
time1 = package.start_time
|
208
|
+
time2 = Time.now
|
209
|
+
minutes = (time2 - time1) / 60
|
210
|
+
|
211
|
+
Log.info("total time: #{minutes} minute")
|
212
|
+
|
213
|
+
minutes
|
214
|
+
end
|
215
|
+
|
190
216
|
# web hook 消息标题
|
191
217
|
def make_web_hook_message_title
|
192
218
|
"iOS 来新包啦~"
|
@@ -202,7 +228,7 @@ module OceanPackage
|
|
202
228
|
content += "当前平台: iOS \n\n"
|
203
229
|
content += "APP名称: " + ipa.display_name + "\n\n"
|
204
230
|
content += "当前版本: " + ipa.version + "(#{ipa.build_version})" + "\n\n"
|
205
|
-
content += "打包耗时: " + "#{
|
231
|
+
content += "打包耗时: " + "#{compute_total_time_minute}" + " 分钟" + "\n\n"
|
206
232
|
content += "发布环境: " + "#{package.configuration}" + "\n\n"
|
207
233
|
content += "更新描述: " + final_change_log + "\n\n"
|
208
234
|
content += "发布时间: " + Time.new.strftime("%Y年%m月%d日 %H时%M分%S秒") + "\n\n"
|
@@ -242,7 +268,6 @@ module OceanPackage
|
|
242
268
|
time_flow_dir = @package.final_archive_path
|
243
269
|
time_flow_file_path = "#{time_flow_dir}timeflow.json"
|
244
270
|
params = time_flow.make_all_points
|
245
|
-
params['timeFlowPath'] = time_flow_file_path
|
246
271
|
json = JSON.dump(params)
|
247
272
|
|
248
273
|
unless File.exist?(time_flow_file_path)
|
@@ -255,6 +280,38 @@ module OceanPackage
|
|
255
280
|
else
|
256
281
|
Log.error("write time flow to path(fail): #{time_flow_file_path}")
|
257
282
|
end
|
283
|
+
|
284
|
+
upload_time_flow_data(params)
|
285
|
+
end
|
286
|
+
|
287
|
+
def upload_time_flow_data(data)
|
288
|
+
time_flow_url_value = "#{@time_flow_url}"
|
289
|
+
unless time_flow_url_value.empty?
|
290
|
+
Log.info("upload time flow data")
|
291
|
+
|
292
|
+
uri = URI(time_flow_url_value)
|
293
|
+
params = data
|
294
|
+
|
295
|
+
# 分割
|
296
|
+
extra_params = "#{@time_flow_extra_req}".split(",")
|
297
|
+
# 再拼接
|
298
|
+
extra_params.each do |p|
|
299
|
+
extra_key_values = "#{p}".split("=")
|
300
|
+
if extra_key_values.length == 2
|
301
|
+
extra_key = "#{extra_key_values[0]}"
|
302
|
+
extra_value = "#{extra_key_values[1]}"
|
303
|
+
if extra_key.length > 0 && extra_value.length > 0
|
304
|
+
params[extra_key] = extra_value
|
305
|
+
end
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
Log.info("url: #{uri}")
|
310
|
+
Log.info("body: #{params}")
|
311
|
+
|
312
|
+
res = Net::HTTP.post_form(uri, params)
|
313
|
+
Log.info("upload time flow data result: #{res.body}")
|
314
|
+
end
|
258
315
|
end
|
259
316
|
|
260
317
|
end
|