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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82c93a210742ecf72d29fac19fdcf217bcc49009f524ec0c0024953b9072aa5f
4
- data.tar.gz: a7fd691691e09f01d76e04d67998a540a5051d38a617b35001e0f86876ea49f6
3
+ metadata.gz: 875d220405250a700a625e00c01066f23218ca09177b843b155165bc4dba3842
4
+ data.tar.gz: 5a4b9e1f653d31a54d6f4cd5a8a40c06d7002f2371d74caa562f5a34a7e2f871
5
5
  SHA512:
6
- metadata.gz: 995f03687c2891e11cea349bb6979c930b595d0e9a27f5382f931780fe0b6103a2dabb476471e48e467fde94ceeb5067568127a7d9dd555fbb535250810fe63e
7
- data.tar.gz: 2d55f0ed870d359e3a982fcdc4c90a6f328fb118f83c1c30926596109df1941e0d8b36e780d46cf6048e0dfd817610ab7b10105ad76184f44a8c0b03a8f453ed
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 build_app_version
74
- # app version '1.0.0'
73
+ def self.all_app_version(path)
75
74
  vers = []
76
- Dir.glob("#{@work_path}/*.xcodeproj/*.pbxproj").each do |file|
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
- version_match = @version_regex.match(l)
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
- list = max_version(vers)
88
- list.last[:value]
82
+ sort_version_list(vers)
89
83
  end
90
84
 
91
- def max_version(list)
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
@@ -31,6 +31,7 @@ module Lhj
31
31
  require 'lhj/helper/bugly_helper'
32
32
  require 'lhj/helper/traditional_check_helper'
33
33
  require 'lhj/helper/todo_check_helper'
34
+ require 'lhj/helper/image_oss_check_helper'
34
35
 
35
36
  class Error < StandardError; end
36
37
 
data/lib/lhj/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lhj
4
- VERSION = '0.2.56'
4
+ VERSION = '0.2.58'
5
5
  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.2.56
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-07-12 00:00:00.000000000 Z
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