lhj-tools 0.2.56 → 0.2.58
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lhj/helper/app_version_info.rb +22 -14
- data/lib/lhj/helper/image_oss_check_helper.rb +73 -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: 875d220405250a700a625e00c01066f23218ca09177b843b155165bc4dba3842
|
4
|
+
data.tar.gz: 5a4b9e1f653d31a54d6f4cd5a8a40c06d7002f2371d74caa562f5a34a7e2f871
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5380890249c39f87d479383c60da890213ce34d15005f4120ebbb7f33d1819556ff7e071f3e47a53ff14ac504469422fe73afba0fad025a4b06a14859c34d7e5
|
7
|
+
data.tar.gz: c64c70794e07142dab6a268922b1508f56699b881fa4baff65ca18d30737bb20417dde791d9c6fb2f04f7760207899734c878ed5ad54c6316dd5a12e7de1833a
|
@@ -5,14 +5,14 @@ require_relative 'team_member_config'
|
|
5
5
|
module Lhj
|
6
6
|
# version info
|
7
7
|
class AppVersionInfo
|
8
|
+
|
9
|
+
VERSION_REGEX = /^(?<begin>[^#]*MARKETING_VERSION\s*=\s*)(?<value>(?<major>[0-9]+)(\.(?<minor>[0-9]+))?(\.(?<patch>[0-9]+))?(?<appendix>(\.[0-9]+)*)?(-(?<prerelease>(.+)))?)(?<end>)/
|
10
|
+
|
8
11
|
# @param [Symbol] env
|
9
12
|
def initialize(env, build_number, work_path)
|
10
13
|
@env = env
|
11
14
|
@build_number = build_number
|
12
15
|
@work_path = work_path
|
13
|
-
|
14
|
-
version_var_name = 'MARKETING_VERSION'
|
15
|
-
@version_regex = /^(?<begin>[^#]*#{version_var_name}\s*=\s*)(?<value>(?<major>[0-9]+)(\.(?<minor>[0-9]+))?(\.(?<patch>[0-9]+))?(?<appendix>(\.[0-9]+)*)?(-(?<prerelease>(.+)))?)(?<end>)/i
|
16
16
|
modify_code
|
17
17
|
end
|
18
18
|
|
@@ -70,25 +70,27 @@ module Lhj
|
|
70
70
|
"#{build_app_version} (#{build_app_version_no}) (build: #{build_version})"
|
71
71
|
end
|
72
72
|
|
73
|
-
def
|
74
|
-
# app version '1.0.0'
|
73
|
+
def self.all_app_version(path)
|
75
74
|
vers = []
|
76
|
-
Dir.glob("#{
|
75
|
+
Dir.glob("#{path}/*.xcodeproj/*.pbxproj").each do |file|
|
77
76
|
File.readlines(file).each do |l|
|
78
77
|
next unless /MARKETING_VERSION/ =~ l
|
79
78
|
|
80
|
-
|
81
|
-
major = version_match[:major].to_i
|
82
|
-
minor = version_match[:minor].to_i || 0
|
83
|
-
patch = version_match[:patch].to_i || 0
|
84
|
-
vers << { value: version_match[:value], major: major, minor: minor, patch: patch }
|
79
|
+
vers << fetch_version(l)
|
85
80
|
end
|
86
81
|
end
|
87
|
-
|
88
|
-
list.last[:value]
|
82
|
+
sort_version_list(vers)
|
89
83
|
end
|
90
84
|
|
91
|
-
def
|
85
|
+
def self.fetch_version(line)
|
86
|
+
version_match = VERSION_REGEX.match(line)
|
87
|
+
major = version_match[:major].to_i
|
88
|
+
minor = version_match[:minor].to_i || 0
|
89
|
+
patch = version_match[:patch].to_i || 0
|
90
|
+
{ value: version_match[:value], major: major, minor: minor, patch: patch }
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.sort_version_list(list)
|
92
94
|
list.sort do |a, b|
|
93
95
|
ma = a[:major] <=> b[:major]
|
94
96
|
ma = a[:minor] <=> b[:minor] if ma.zero?
|
@@ -97,6 +99,12 @@ module Lhj
|
|
97
99
|
end
|
98
100
|
end
|
99
101
|
|
102
|
+
def build_app_version
|
103
|
+
# app version '1.0.0'
|
104
|
+
vers = AppVersionInfo.all_app_version(@work_path)
|
105
|
+
vers.last[:value]
|
106
|
+
end
|
107
|
+
|
100
108
|
def build_app_version_no
|
101
109
|
# xcode build version
|
102
110
|
# ${BUILD_NUMBER} of jenkins
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module Lhj
|
2
|
+
class ImageOssCheckHelper
|
3
|
+
|
4
|
+
OSS_PATH_REGEX = /(?<var>[a-zA-Z0-9_]+)\W*=.*ml_addOssPathIgnoreGif:.*/.freeze
|
5
|
+
|
6
|
+
SD_IMAGE_OSS_REGEX = /sd_setImageWithURL:\s*\[NSURL\s*URLWithString:(?<url>[^\]]+)\]/.freeze
|
7
|
+
|
8
|
+
def self.check(path, type = 'm')
|
9
|
+
all_files = Dir.glob("#{path}/**/*.{#{type}}").reject do |p|
|
10
|
+
p =~ /Pods/
|
11
|
+
end
|
12
|
+
result = {}
|
13
|
+
all_files.each do |f|
|
14
|
+
infos = handle_file(f)
|
15
|
+
result[File.basename(f)] = infos if infos.length.positive?
|
16
|
+
end
|
17
|
+
show_result(result)
|
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.handle_file(file)
|
31
|
+
result = []
|
32
|
+
File.open(file, 'r') do |f|
|
33
|
+
oss_var = nil
|
34
|
+
multi_comment = false
|
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
|
+
|
45
|
+
oss_var = fetch_oss_path(line) if line =~ OSS_PATH_REGEX
|
46
|
+
next unless line =~ SD_IMAGE_OSS_REGEX
|
47
|
+
|
48
|
+
oss_info = fetch_sd_image_url(file, line, idx, oss_var)
|
49
|
+
result << oss_info if oss_info
|
50
|
+
oss_var = nil if oss_info
|
51
|
+
end
|
52
|
+
end
|
53
|
+
result
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.fetch_oss_path(line)
|
57
|
+
oss_match = OSS_PATH_REGEX.match(line)
|
58
|
+
oss_match[:var]
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.fetch_sd_image_url(file, line, idx, oss_var)
|
62
|
+
url_match = SD_IMAGE_OSS_REGEX.match(line)
|
63
|
+
oss_url = url_match[:url]
|
64
|
+
|
65
|
+
return nil if oss_var && oss_var == oss_url
|
66
|
+
return nil if oss_url =~ /ml_addOssPathIgnoreGif/
|
67
|
+
return nil if oss_url =~ /x-oss-process=style/
|
68
|
+
|
69
|
+
{ idx: idx + 1, line: line.strip }
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
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.58
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lihaijian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xcodeproj
|
@@ -392,6 +392,7 @@ files:
|
|
392
392
|
- lib/lhj/helper/erb_template_helper.rb
|
393
393
|
- lib/lhj/helper/git_branch_feature_config.rb
|
394
394
|
- lib/lhj/helper/git_helper.rb
|
395
|
+
- lib/lhj/helper/image_oss_check_helper.rb
|
395
396
|
- lib/lhj/helper/ios_robot_config.rb
|
396
397
|
- lib/lhj/helper/jenkins_config.rb
|
397
398
|
- lib/lhj/helper/local_config.rb
|