lhj-tools 0.1.61 → 0.1.63
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lhj/command/yapi/yapi_init.rb +83 -0
- data/lib/lhj/command.rb +1 -0
- data/lib/lhj/helper/app_version_info.rb +18 -1
- data/lib/lhj/helper/pgyer_helper.rb +6 -1
- data/lib/lhj/tools/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81bedcaada5ac14408c3ff1f24bb55e49bb5d90f092ff3b48b79676092b35677
|
4
|
+
data.tar.gz: d07b0007fe5838e00588c75e83cc759ded19aead5d0c57d806a330f1d73294b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6523bf37b393c2c590c5b3438b1bb057f9e3bd30fa2d04ad376192818df764a519b580f038114be148bdcce0617173c90f2508e1248ebb77c60d31737c5be27
|
7
|
+
data.tar.gz: 5c4bffe0263747cd3d325edc107c6a89a5b643047d9a924dbe6477ff007e9d3f42ed068a9cc01195b5f47a67ad24e61d721051a756b409b0b1259032b4421546
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'selenium-webdriver'
|
2
|
+
|
3
|
+
module Lhj
|
4
|
+
class Command
|
5
|
+
# generate model from yapi
|
6
|
+
class YapiInit < Command
|
7
|
+
self.summary = '更新yapi请求cookie'
|
8
|
+
self.description = '更新 ~/.lhj/yapi.yml 文件配置'
|
9
|
+
|
10
|
+
# @return [String]
|
11
|
+
def interface_url
|
12
|
+
url = []
|
13
|
+
url << 'h'
|
14
|
+
url << 't'
|
15
|
+
url << 't'
|
16
|
+
url << 'p'
|
17
|
+
url << ':'
|
18
|
+
url << '/'
|
19
|
+
url << '/'
|
20
|
+
url << 'y'
|
21
|
+
url << 'a'
|
22
|
+
url << 'p'
|
23
|
+
url << 'i'
|
24
|
+
url << '.'
|
25
|
+
url << 'm'
|
26
|
+
url << 'i'
|
27
|
+
url << 'g'
|
28
|
+
url << 'u'
|
29
|
+
url << 'a'
|
30
|
+
url << 't'
|
31
|
+
url << 'e'
|
32
|
+
url << 'c'
|
33
|
+
url << 'h'
|
34
|
+
url << '.'
|
35
|
+
url << 'c'
|
36
|
+
url << 'o'
|
37
|
+
url << 'm'
|
38
|
+
url.join('')
|
39
|
+
end
|
40
|
+
|
41
|
+
def request_cookie
|
42
|
+
options = Selenium::WebDriver::Chrome::Options.new(args: %w[start-maximized])
|
43
|
+
driver = Selenium::WebDriver.for(:chrome, capabilities: options)
|
44
|
+
driver.get interface_url
|
45
|
+
manage = driver.manage
|
46
|
+
manage.timeouts.implicit_wait = 10
|
47
|
+
manage.timeouts.page_load = 10
|
48
|
+
# 1.登录
|
49
|
+
all_btn = driver.all(tag_name: 'button')
|
50
|
+
login_btn = all_btn.find { |ele| ele.text =~ /钉钉登录/ } if all_btn
|
51
|
+
login_btn&.click
|
52
|
+
# 2.获取cookies
|
53
|
+
wait = Selenium::WebDriver::Wait.new(timeout: 60)
|
54
|
+
wait.until do
|
55
|
+
res = {}
|
56
|
+
manage.all_cookies.each do |cookie|
|
57
|
+
res[:wid] = cookie[:value] if cookie[:name] == '__wpkreporterwid_'
|
58
|
+
res[:uid] = cookie[:value] if cookie[:name] == '_yapi_uid'
|
59
|
+
res[:token] = cookie[:value] if cookie[:name] == '_yapi_token'
|
60
|
+
end
|
61
|
+
return res if res.values.count == 3
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def config_file
|
66
|
+
File.join(Lhj::Config.instance.home_dir, 'yapi.yml')
|
67
|
+
end
|
68
|
+
|
69
|
+
def handle
|
70
|
+
cookie = request_cookie
|
71
|
+
config = YAML.load_file(config_file) if File.exist?(config_file)
|
72
|
+
if cookie && config
|
73
|
+
config['__wpkreporterwid_'] = cookie[:wid]
|
74
|
+
config['_yapi_uid'] = cookie[:uid]
|
75
|
+
config['_yapi_token'] = cookie[:token]
|
76
|
+
file_to_save = File.open(config_file, 'w+')
|
77
|
+
YAML.dump(config, file_to_save)
|
78
|
+
file_to_save.close
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/lib/lhj/command.rb
CHANGED
@@ -98,7 +98,7 @@ module Lhj
|
|
98
98
|
|
99
99
|
def update_log
|
100
100
|
Dir.chdir(@work_path) do
|
101
|
-
message = Lhj::Actions.git_log_last_commits(' %an %ar - %s;',
|
101
|
+
message = Lhj::Actions.git_log_last_commits(' %an %ar - %s;', 6, :exclude_merges, 'short', false)
|
102
102
|
handle_message(message)
|
103
103
|
end
|
104
104
|
end
|
@@ -114,5 +114,22 @@ module Lhj
|
|
114
114
|
message
|
115
115
|
end
|
116
116
|
|
117
|
+
def custom_modify
|
118
|
+
return if @env != :release
|
119
|
+
|
120
|
+
Dir["#{@work_path}/**/*.m"].each do |file|
|
121
|
+
str = ''
|
122
|
+
File.open(file) do |f|
|
123
|
+
f.each_line do |line|
|
124
|
+
next if line =~ /todo/
|
125
|
+
|
126
|
+
str += line
|
127
|
+
end
|
128
|
+
end
|
129
|
+
File.open(file, 'w+') do |f|
|
130
|
+
f.write(str)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
117
134
|
end
|
118
135
|
end
|
@@ -61,6 +61,7 @@ module Lhj
|
|
61
61
|
response = http_client.post API_HOST, params
|
62
62
|
@result = response.body
|
63
63
|
puts @result
|
64
|
+
Actions.sh('git restore ./', log: false)
|
64
65
|
puts 'upload success'
|
65
66
|
# if @result['data'] && @result['data']['appUpdateDescription'] && @env == :uat
|
66
67
|
# str = Lhj::TbHelper.trans_tb(@result['data']['appUpdateDescription'])
|
@@ -93,7 +94,11 @@ module Lhj
|
|
93
94
|
Lhj::OSS::Helper.instance.upload(oss_key, oss_file)
|
94
95
|
FileUtils.rm_r Dir.glob("#{path}/archive*.zip")
|
95
96
|
|
96
|
-
|
97
|
+
update_cmd = []
|
98
|
+
update_cmd << 'gem'
|
99
|
+
update_cmd << 'install'
|
100
|
+
update_cmd << "lhj-tools"
|
101
|
+
Actions.sh(update_cmd.join(' '), log: false, error_callback: nil)
|
97
102
|
end
|
98
103
|
|
99
104
|
def render_template
|
data/lib/lhj/tools/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lhj-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.63
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lihaijian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xcodeproj
|
@@ -302,6 +302,20 @@ dependencies:
|
|
302
302
|
- - "<"
|
303
303
|
- !ruby/object:Gem::Version
|
304
304
|
version: '3'
|
305
|
+
- !ruby/object:Gem::Dependency
|
306
|
+
name: selenium-webdriver
|
307
|
+
requirement: !ruby/object:Gem::Requirement
|
308
|
+
requirements:
|
309
|
+
- - "~>"
|
310
|
+
- !ruby/object:Gem::Version
|
311
|
+
version: 4.7.1
|
312
|
+
type: :runtime
|
313
|
+
prerelease: false
|
314
|
+
version_requirements: !ruby/object:Gem::Requirement
|
315
|
+
requirements:
|
316
|
+
- - "~>"
|
317
|
+
- !ruby/object:Gem::Version
|
318
|
+
version: 4.7.1
|
305
319
|
description: lhj tools.
|
306
320
|
email:
|
307
321
|
- sanan.li@qq.com
|
@@ -353,6 +367,7 @@ files:
|
|
353
367
|
- lib/lhj/command/yapi/formatters/template/model.erb
|
354
368
|
- lib/lhj/command/yapi/formatters/template/pgyer.erb
|
355
369
|
- lib/lhj/command/yapi/formatters/template/yapi.erb
|
370
|
+
- lib/lhj/command/yapi/yapi_init.rb
|
356
371
|
- lib/lhj/config.rb
|
357
372
|
- lib/lhj/env.rb
|
358
373
|
- lib/lhj/helper/app_version_info.rb
|