lhj-tools 0.1.62 → 0.1.63

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: 3ba6211ebff2bc66ab95a3b3c7959156041b1c105c2e2b46cbf908a4bd5e126f
4
- data.tar.gz: ee19c536c4c4c82fe9dfa9defe2c4db0e0dda9ad4eb287a3e861e3918b17f857
3
+ metadata.gz: 81bedcaada5ac14408c3ff1f24bb55e49bb5d90f092ff3b48b79676092b35677
4
+ data.tar.gz: d07b0007fe5838e00588c75e83cc759ded19aead5d0c57d806a330f1d73294b7
5
5
  SHA512:
6
- metadata.gz: 6ca8d2e5b7c738d0155ba72274dbe7c225b047e91b4efd2009651a7156e8d1cc49a8c29907c3cda8f251286f845f9f675b897ddb2cf82d5b8a5f44bd12cc8c6a
7
- data.tar.gz: fa660c51bc40b2c39eada931362fb91a09c6f12986284c23914d93e5564cc42c2387b0f6c7bce2c70c845b51e1bfc2d3f498449985408cc833303aaf7d165b79
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
@@ -22,6 +22,7 @@ module Lhj
22
22
  require 'lhj/command/code/code_template'
23
23
  require 'lhj/command/rename_image'
24
24
  require 'lhj/command/trans'
25
+ require 'lhj/command/yapi/yapi_init'
25
26
  require 'lhj/command/yapi'
26
27
  require 'lhj/command/file_path'
27
28
  require 'lhj/command/http'
@@ -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;', 5, :exclude_merges, 'short', false)
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lhj
4
4
  module Tools
5
- VERSION = "0.1.62"
5
+ VERSION = "0.1.63"
6
6
  end
7
7
  end
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.62
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-29 00:00:00.000000000 Z
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