lhj-tools 0.1.55 → 0.1.59

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: b66a2c394691aa23ab4da26a83f5f9623e68c4355cb7f782916568f969a17b6d
4
- data.tar.gz: 9b41f62a7770b26363f9db7b434f1e56b3fb3d72de4e5c78cd10f3f9478d5018
3
+ metadata.gz: b6f6a3fc5a64065faa8bcb7aa05a27c54ed132f2927f066fc59e2c3baba316d2
4
+ data.tar.gz: 6869c78cd31dcaea3129fbcd6d9b80b3300305482023a9e408b990424433aba0
5
5
  SHA512:
6
- metadata.gz: 5f1fcb3e75bf22881735c6e768d3c95cc0d506f89641edf52695565b700b7e7e92cebecaa7bef7a000f19279d487389597a1581b8e82e9146f5eb1e9ded789ee
7
- data.tar.gz: 8b3900e23599f314e11205b488b0804e31e90f7080527c1f3635da9258ee1f13c8ee45b19e62657a7d9701edff2dc19b0fa2e657dbf137d9897a3c0d9cf01cb3
6
+ metadata.gz: be09281aae804bc6417f82d92280adf4c2648983ababc591db31ac1d54b357e2c22900b81e9ddf5873e8f46c3db1fa9cb8434ad7115830a70be98451e46f4973
7
+ data.tar.gz: 1a9588d30b4e319f9728a3db1afda29e4fb58b3f6ba11758cb71e617fca031cb9b967670f8790b7a04d90374133d4d67b2c00bb5ffaa9134109f6a0788bd4317
@@ -1,5 +1,6 @@
1
1
  require_relative 'log_helper'
2
2
  require_relative 'pgyer_shortcut_helper'
3
+ require_relative 'team_member_config'
3
4
 
4
5
  module Lhj
5
6
  # version info
@@ -9,6 +10,9 @@ module Lhj
9
10
  @env = env
10
11
  @build_number = build_number
11
12
  @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
12
16
  setup_config
13
17
  end
14
18
 
@@ -18,6 +22,7 @@ module Lhj
18
22
  command = %(xcrun agvtool new-version -all #{number})
19
23
  Actions.sh(command, log: false)
20
24
  end
25
+ FileUtils.rm_r Dir.glob("#{@work_path}/archive*.zip")
21
26
  end
22
27
 
23
28
  # build_app_version (build_app_version_no) (build: build_version)
@@ -30,13 +35,26 @@ module Lhj
30
35
  vers = []
31
36
  Dir.glob("#{@work_path}/*.xcodeproj/*.pbxproj").each do |file|
32
37
  File.readlines(file).each do |l|
33
- if /MARKETING_VERSION.*(\d+\.\d+\.\d+)/ =~ l
34
- ma = l.match(/(\d+\.\d+\.\d+)/)
35
- vers << ma[0]
36
- end
38
+ next unless /MARKETING_VERSION/ =~ l
39
+
40
+ version_match = @version_regex.match(l)
41
+ major = version_match[:major].to_i
42
+ minor = version_match[:minor].to_i || 0
43
+ patch = version_match[:patch].to_i || 0
44
+ vers << { value: version_match[:value], major: major, minor: minor, patch: patch }
37
45
  end
38
46
  end
39
- vers[0]
47
+ list = max_version(vers)
48
+ list.last[:value]
49
+ end
50
+
51
+ def max_version(list)
52
+ list.sort do |a, b|
53
+ ma = a[:major] <=> b[:major]
54
+ ma = a[:minor] <=> b[:minor] if ma.zero?
55
+ ma = a[:patch] <=> b[:patch] if ma.zero?
56
+ ma
57
+ end
40
58
  end
41
59
 
42
60
  def build_app_version_no
@@ -67,8 +85,20 @@ module Lhj
67
85
 
68
86
  def update_log
69
87
  Dir.chdir(@work_path) do
70
- Lhj::Actions.git_log_last_commits(' %an %ar - %s;', 3, :exclude_merges, 'short', false)
88
+ message = Lhj::Actions.git_log_last_commits(' %an %ar - %s;', 5, :exclude_merges, 'short', false)
89
+ handle_message(message)
90
+ end
91
+ end
92
+
93
+ def handle_message(m)
94
+ message = m
95
+ unless message.empty?
96
+ message = message.gsub('seconds ', '秒').gsub('minutes ', '分钟').gsub('hours ', '小时').gsub('weeks ', '周').gsub('days ', '天').gsub('ago ', '前')
97
+ Lhj::TeamMemberConfig.config.each do |key, value|
98
+ message = message.gsub(key, value) if message =~ /#{key}/
99
+ end
71
100
  end
101
+ message
72
102
  end
73
103
 
74
104
  end
@@ -24,6 +24,8 @@ module Lhj
24
24
  config['gray_api_key']
25
25
  when :uat
26
26
  config['uat_api_key']
27
+ when :test
28
+ config['uat_api_key']
27
29
  else
28
30
  config['api_key']
29
31
  end
@@ -37,6 +39,8 @@ module Lhj
37
39
  config['gray_user_key']
38
40
  when :uat
39
41
  config['uat_user_key']
42
+ when :test
43
+ config['uat_user_key']
40
44
  else
41
45
  config['user_key']
42
46
  end
@@ -50,6 +54,8 @@ module Lhj
50
54
  config['gray_shortcut_url']
51
55
  when :uat
52
56
  config['uat_shortcut_url']
57
+ when :test
58
+ config['uat_shortcut_url']
53
59
  else
54
60
  config['shortcut_url']
55
61
  end
@@ -71,6 +71,7 @@ module Lhj
71
71
  # end
72
72
  rescue Faraday::TimeoutError
73
73
  puts 'upload fail'
74
+ FileUtils.rm_r Dir.glob("#{path}/archive*.zip")
74
75
  end
75
76
  end
76
77
 
@@ -92,12 +93,16 @@ module Lhj
92
93
  return unless file_exists
93
94
 
94
95
  Lhj::OSS::Helper.instance.upload(oss_key, oss_file)
95
- FileUtils.rm(oss_file) if file_exists
96
+ FileUtils.rm_r Dir.glob("#{path}/archive*.zip")
96
97
  end
97
98
 
98
99
  def render_template
99
- temp_str = File.read(File.join(Lhj::Config.instance.home_dir, 'pgyer.erb'))
100
- Lhj::ErbFormatter::Service.new(self).render_template(temp_str)
100
+ if @result.is_a? Hash
101
+ temp_str = File.read(File.join(Lhj::Config.instance.home_dir, 'pgyer.erb'))
102
+ Lhj::ErbFormatter::Service.new(self).render_template(temp_str)
103
+ else
104
+ @result
105
+ end
101
106
  end
102
107
  end
103
108
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lhj
4
4
  module Tools
5
- VERSION = "0.1.55"
5
+ VERSION = "0.1.59"
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.55
4
+ version: 0.1.59
5
5
  platform: ruby
6
6
  authors:
7
7
  - lihaijian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-18 00:00:00.000000000 Z
11
+ date: 2022-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: claide