lhj-tools 0.2.72 → 0.2.73
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 +4 -4
- data/lib/lhj/command/local/fetch.rb +4 -4
- data/lib/lhj/helper/ios_api_available_check_helper.rb +104 -0
- data/lib/lhj/lhj.rb +1 -0
- data/lib/lhj/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f290f1dcacdb4ffd6a22237a2bcf16e2e859a722855c8ca63a508d36bc9004d
|
4
|
+
data.tar.gz: 0cfa5b7a21ca263afab94639ecb90703f01baa9c15db786d6c92c62dcac0ad05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a83825633df792ce139161b02f3b882c900ae140a84f517736de5480902766721b177b314154b4ef3fa8e4323f9aad6681d7585b650b605a9593e1684b2f844
|
7
|
+
data.tar.gz: 7d9436fcc3141dbcc19212c676783bf79e5e457d9f18e029eb791103faf9c7eb8afd6ee744d93cab52cc47c294e1836b2860d3813e0f6ac72524c70780037f8f
|
@@ -44,8 +44,8 @@ module Lhj
|
|
44
44
|
def gen_csv
|
45
45
|
file = File.join(@current_path, csv_file_name)
|
46
46
|
FileUtils.rm_rf(file) if File.exist?(file)
|
47
|
-
|
48
|
-
|
47
|
+
CSV.open(file, 'wb:utf-8') do |csv|
|
48
|
+
csv << %w[国际化key 中文 英文 所在文件 文件路径 行号]
|
49
49
|
@cn_keys.each do |k|
|
50
50
|
csv << [k[:key], k[:cn], k[:en], k[:fname], k[:dirname], k[:idx]]
|
51
51
|
end
|
@@ -56,8 +56,8 @@ module Lhj
|
|
56
56
|
def gen_csv_unique
|
57
57
|
file = File.join(@current_path, unique_csv_file_name)
|
58
58
|
FileUtils.rm_rf(file) if File.exist?(file)
|
59
|
-
|
60
|
-
|
59
|
+
CSV.open(file, 'wb:utf-8') do |csv|
|
60
|
+
csv << %w[国际化key 中文 英文 所在文件 文件路径 行号]
|
61
61
|
@cn_keys.uniq { |k| k[:cn] }.each do |k|
|
62
62
|
csv << [k[:key], k[:cn], k[:en], k[:fname], k[:dirname], k[:idx]]
|
63
63
|
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Lhj
|
3
|
+
class IosApiAvailableCheckHelper
|
4
|
+
|
5
|
+
API_AVAILABLE_KEY_BEGIN_REGEX = /@available\(/.freeze
|
6
|
+
|
7
|
+
def self.check(path, type = 'm')
|
8
|
+
all_files = Dir.glob("#{path}/**/*.{#{type}}")
|
9
|
+
result = {}
|
10
|
+
all_files.each do |f|
|
11
|
+
wrapper_lines = find_available_wrapper(f)
|
12
|
+
infos = handle_file(f, wrapper_lines)
|
13
|
+
result[File.basename(f)] = infos if infos.length.positive?
|
14
|
+
end
|
15
|
+
# result
|
16
|
+
# show_result(result)
|
17
|
+
result.keys.each_slice(10) { |a| notify(result.slice(*a)) }
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.show_result(result)
|
21
|
+
result.each do |k, v|
|
22
|
+
puts k
|
23
|
+
v.each do |o|
|
24
|
+
puts "第#{o[:idx]}行:"
|
25
|
+
puts o[:line]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.find_available_wrapper(file)
|
31
|
+
lines = []
|
32
|
+
File.open(file, 'r') do |f|
|
33
|
+
multi_comment = false
|
34
|
+
available_idx = 0
|
35
|
+
f.readlines.each_with_index do |line, idx|
|
36
|
+
multi_comment = true if line =~ %r{/\*} && line !~ %r{\*/} && !multi_comment
|
37
|
+
if line !~ %r{/\*} && line =~ %r{\*/} && multi_comment
|
38
|
+
multi_comment = false
|
39
|
+
next
|
40
|
+
end
|
41
|
+
|
42
|
+
next if multi_comment
|
43
|
+
next if line =~ %r{\s*//}
|
44
|
+
next unless line =~ API_AVAILABLE_KEY_BEGIN_REGEX || available_idx.positive?
|
45
|
+
|
46
|
+
available_idx += 1 if line =~ /\{/
|
47
|
+
available_idx -= 1 if line =~ /\}/
|
48
|
+
lines << { idx: idx, line: line }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
lines
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.handle_file(file, wrapper_lines)
|
55
|
+
result = []
|
56
|
+
File.open(file, 'r') do |f|
|
57
|
+
multi_comment = false
|
58
|
+
f.readlines.each_with_index do |line, idx|
|
59
|
+
multi_comment = true if line =~ %r{/\*} && line !~ %r{\*/} && !multi_comment
|
60
|
+
if line !~ %r{/\*} && line =~ %r{\*/} && multi_comment
|
61
|
+
multi_comment = false
|
62
|
+
next
|
63
|
+
end
|
64
|
+
|
65
|
+
next if multi_comment
|
66
|
+
next if line =~ %r{\s*//}
|
67
|
+
# 1. 白名单查找
|
68
|
+
next unless match_white_list_reg(line)
|
69
|
+
# 2. 找到的行是否已available代码块
|
70
|
+
next if wrapper_lines.length.positive? && wrapper_lines.any? { |w| w[:idx] == idx }
|
71
|
+
|
72
|
+
result << { idx: idx + 1, line: line }
|
73
|
+
end
|
74
|
+
end
|
75
|
+
result
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.match_white_list_reg(line)
|
79
|
+
regs ||= load_white_api_list
|
80
|
+
regs.any? { |r| line =~ /#{r}/ }
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.load_white_api_list
|
84
|
+
require 'yaml'
|
85
|
+
yaml_file = File.join(Lhj::Config.instance.home_dir, 'ios_available_api_white_list.yml')
|
86
|
+
YAML.safe_load(File.open(yaml_file))
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.robot_url
|
90
|
+
'https://oapi.dingtalk.com/robot/send?access_token=fe879fd3e7a3b5e59d5719b2384845b7884901919be5a78fe443cbf777869807'
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.notify(result)
|
94
|
+
temp = Lhj::ErbTemplateHelper.load('ios_avaliable_api_notify')
|
95
|
+
temp_result = Lhj::ErbTemplateHelper.render(temp, { result: result, branch: git_branch }, '-')
|
96
|
+
Lhj::Dingtalk.post_message_robot(robot_url, 'check code', temp_result)
|
97
|
+
end
|
98
|
+
|
99
|
+
def self.git_branch
|
100
|
+
branch ||= Lhj::LogHelper.instance.fetch_branch
|
101
|
+
branch
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
data/lib/lhj/lhj.rb
CHANGED
data/lib/lhj/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.2.
|
4
|
+
version: 0.2.73
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lihaijian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xcodeproj
|
@@ -393,6 +393,7 @@ files:
|
|
393
393
|
- lib/lhj/helper/git_branch_feature_config.rb
|
394
394
|
- lib/lhj/helper/git_helper.rb
|
395
395
|
- lib/lhj/helper/image_oss_check_helper.rb
|
396
|
+
- lib/lhj/helper/ios_api_available_check_helper.rb
|
396
397
|
- lib/lhj/helper/ios_robot_config.rb
|
397
398
|
- lib/lhj/helper/jenkins_config.rb
|
398
399
|
- lib/lhj/helper/local_config.rb
|