lhj-tools 0.1.21 → 0.1.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lhj/command/sync_pod_repo.rb +2 -2
- data/lib/lhj/env.rb +9 -0
- data/lib/lhj/helper/git_helper.rb +14 -9
- data/lib/lhj/helper/log_helper.rb +25 -8
- data/lib/lhj/helper/pgyer_config.rb +23 -5
- data/lib/lhj/helper/pgyer_helper.rb +7 -6
- data/lib/lhj/helper/pod_repo_config.rb +24 -0
- data/lib/lhj/helper/team_member_config.rb +20 -0
- data/lib/lhj/helper/trans_helper.rb +6 -1
- data/lib/lhj/tools/version.rb +1 -1
- data/lib/lhj/tools.rb +2 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 223ddca466520ca7090669cd355c86c0e62d32d39404ea4cc13f65967f22a541
|
4
|
+
data.tar.gz: 26b194fa297f41e60e9f16f4f204644007b3b793cb2a7a3bc625a5b46f7b062b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0643a43dc5c7c85b533b56245acfd822fe683e50ef763b18790e26199685e4d0d12d456b7c1c5c693ddda7fc9c64823be7a4536e96426feb7bff85117e181336
|
7
|
+
data.tar.gz: 4ac4c6329d2e4b654d4ef1f4f7afe613f65fb3068a9f9192f374aa20ea13a01b700a33b71c858565b988e5eea0e4c17c9c05bb23a9d08eab02ac764d67e7af9d
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'lhj/config'
|
2
2
|
require 'highline'
|
3
|
+
require 'lhj/helper/pod_repo_config'
|
3
4
|
|
4
5
|
module Lhj
|
5
6
|
class Command
|
@@ -113,9 +114,8 @@ module Lhj
|
|
113
114
|
end
|
114
115
|
|
115
116
|
def update_pod_repo
|
116
|
-
# pod repo push miguatech-aomi_ios-mlspecs *.podspec --sources=miguatech-aomi_ios-mlspecs,aliyun,trunk --allow-warnings --use-libraries --verbose
|
117
117
|
cmd = ['pod repo push']
|
118
|
-
pod_repo_name =
|
118
|
+
pod_repo_name = Lhj::PodRepoConfig.pod_repo_name
|
119
119
|
cmd << pod_repo_name
|
120
120
|
cmd << '*.podspec'
|
121
121
|
cmd << "--sources=#{pod_repo_name},aliyun,trunk"
|
data/lib/lhj/env.rb
ADDED
@@ -60,11 +60,11 @@ module Lhj
|
|
60
60
|
return nil if last_git_commit_formatted_with('%an').nil?
|
61
61
|
|
62
62
|
{
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
63
|
+
author: last_git_commit_formatted_with('%an'),
|
64
|
+
author_email: last_git_commit_formatted_with('%ae'),
|
65
|
+
message: last_git_commit_formatted_with('%B'),
|
66
|
+
commit_hash: last_git_commit_formatted_with('%H'),
|
67
|
+
abbreviated_commit_hash: last_git_commit_formatted_with('%h')
|
68
68
|
}
|
69
69
|
end
|
70
70
|
|
@@ -118,10 +118,15 @@ module Lhj
|
|
118
118
|
# Returns the current git branch, or "HEAD" if it's not checked out to any branch
|
119
119
|
# Can be replaced using the environment variable `GIT_BRANCH`
|
120
120
|
def self.git_branch
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
121
|
+
env_name = SharedValues::GIT_BRANCH_ENV_VARS.find { |env_var| Lhj::Env.truthy?(env_var) }
|
122
|
+
ENV.fetch(env_name.to_s) do
|
123
|
+
# Rescues if not a git repo or no commits in a git repo
|
124
|
+
begin
|
125
|
+
Actions.sh("git rev-parse --abbrev-ref HEAD", log: false).chomp
|
126
|
+
rescue => err
|
127
|
+
UI.verbose("Error getting git branch: #{err.message}")
|
128
|
+
nil
|
129
|
+
end
|
125
130
|
end
|
126
131
|
end
|
127
132
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'lhj/helper/team_member_config'
|
2
|
+
|
1
3
|
module Lhj
|
2
4
|
# log helper
|
3
5
|
class LogHelper
|
@@ -16,7 +18,8 @@ module Lhj
|
|
16
18
|
end
|
17
19
|
|
18
20
|
def fetch_branch
|
19
|
-
Lhj::Actions.git_branch || ''
|
21
|
+
name = Lhj::Actions.git_branch || ''
|
22
|
+
name.split('/').last
|
20
23
|
end
|
21
24
|
|
22
25
|
def fetch_env(env)
|
@@ -33,12 +36,25 @@ module Lhj
|
|
33
36
|
def fetch_log
|
34
37
|
from = last_commit_hash
|
35
38
|
to = 'HEAD'
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
message = Lhj::Actions.git_log_between(' %an %ar - %s;', from, to, :exclude_merges, 'short', false)
|
40
|
+
handle_message(message)
|
41
|
+
end
|
42
|
+
|
43
|
+
def handle_message(m)
|
44
|
+
message = m
|
45
|
+
if !message.nil? && !message.empty?
|
46
|
+
message = message.gsub('seconds ', '秒')
|
47
|
+
message = message.gsub('minutes ', '分钟')
|
48
|
+
message = message.gsub('hours ', '小时')
|
49
|
+
message = message.gsub('days ', '天')
|
50
|
+
message = message.gsub('ago ', '前')
|
51
|
+
Lhj::TeamMemberConfig.config.each do |key, value|
|
52
|
+
message = message.gsub(key, value) if message =~ /#{key}/
|
53
|
+
end
|
54
|
+
else
|
55
|
+
message = '此次打包没代码更新'
|
56
|
+
end
|
57
|
+
message
|
42
58
|
end
|
43
59
|
|
44
60
|
def save_last_commit_hash
|
@@ -56,7 +72,8 @@ module Lhj
|
|
56
72
|
end
|
57
73
|
|
58
74
|
def last_commit_file
|
59
|
-
|
75
|
+
branch_name = @branch.gsub(%r{/}, '')
|
76
|
+
File.join(Lhj::Config.instance.home_dir, ".#{@env}_#{branch_name}_last_commit")
|
60
77
|
end
|
61
78
|
|
62
79
|
def render_template
|
@@ -16,15 +16,33 @@ module Lhj
|
|
16
16
|
@yaml ||= YAML.load_file(config_file)
|
17
17
|
end
|
18
18
|
|
19
|
-
def self.api_key
|
20
|
-
|
19
|
+
def self.api_key(env = :uat)
|
20
|
+
case env
|
21
|
+
when :release
|
22
|
+
config['release_api_key']
|
23
|
+
when :gray
|
24
|
+
config['gray_api_key']
|
25
|
+
when :uat
|
26
|
+
config['uat_api_key']
|
27
|
+
else
|
28
|
+
config['api_key']
|
29
|
+
end
|
21
30
|
end
|
22
31
|
|
23
|
-
def self.user_key
|
24
|
-
|
32
|
+
def self.user_key(env = :uat)
|
33
|
+
case env
|
34
|
+
when :release
|
35
|
+
config['release_user_key']
|
36
|
+
when :gray
|
37
|
+
config['gray_user_key']
|
38
|
+
when :uat
|
39
|
+
config['uat_user_key']
|
40
|
+
else
|
41
|
+
config['user_key']
|
42
|
+
end
|
25
43
|
end
|
26
44
|
|
27
|
-
def self.password
|
45
|
+
def self.password(env = :uat)
|
28
46
|
config['password']
|
29
47
|
end
|
30
48
|
end
|
@@ -13,10 +13,10 @@ module Lhj
|
|
13
13
|
|
14
14
|
attr_reader :api_key, :user_key, :password, :result
|
15
15
|
|
16
|
-
def initialize
|
17
|
-
@api_key = Lhj::PgyerConfig.api_key
|
18
|
-
@user_key = Lhj::PgyerConfig.user_key
|
19
|
-
@password = Lhj::PgyerConfig.password
|
16
|
+
def initialize(env = :uat)
|
17
|
+
@api_key = Lhj::PgyerConfig.api_key(env)
|
18
|
+
@user_key = Lhj::PgyerConfig.user_key(env)
|
19
|
+
@password = Lhj::PgyerConfig.password(env)
|
20
20
|
@result = { 'data' => {} }
|
21
21
|
end
|
22
22
|
|
@@ -39,7 +39,7 @@ module Lhj
|
|
39
39
|
def upload_file(file, des)
|
40
40
|
|
41
41
|
update_description = @result[:update_description]
|
42
|
-
update_description =
|
42
|
+
update_description = '' if update_description.nil?
|
43
43
|
params = {
|
44
44
|
'_api_key' => @api_key,
|
45
45
|
'uKey' => @user_key,
|
@@ -49,10 +49,11 @@ module Lhj
|
|
49
49
|
'file' => Faraday::UploadIO.new(file, 'application/octet-stream')
|
50
50
|
}
|
51
51
|
begin
|
52
|
-
puts 'begin upload'
|
52
|
+
puts 'begin upload...'
|
53
53
|
response = http_client.post API_HOST, params
|
54
54
|
@result = response.body
|
55
55
|
puts @result
|
56
|
+
puts 'upload success'
|
56
57
|
if @result['data'] && @result['data']['appUpdateDescription']
|
57
58
|
@result['data']['appUpdateDescription'] = Lhj::TbHelper.trans_tb(@result['data']['appUpdateDescription'])
|
58
59
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'yaml'
|
3
|
+
require 'lhj/config'
|
4
|
+
|
5
|
+
module Lhj
|
6
|
+
# pod repo config
|
7
|
+
class PodRepoConfig
|
8
|
+
|
9
|
+
CONFIG_NAME = 'pod_repo_config.yml'
|
10
|
+
|
11
|
+
def self.config_file
|
12
|
+
File.join(Lhj::Config.instance.home_dir, CONFIG_NAME)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.config
|
16
|
+
@yaml ||= YAML.load_file(config_file)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.pod_repo_name
|
20
|
+
config['pod_repo_name']
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'yaml'
|
3
|
+
require 'lhj/config'
|
4
|
+
|
5
|
+
module Lhj
|
6
|
+
# team member config
|
7
|
+
class TeamMemberConfig
|
8
|
+
|
9
|
+
CONFIG_NAME = 'team_member.yml'
|
10
|
+
|
11
|
+
def self.config_file
|
12
|
+
File.join(Lhj::Config.instance.home_dir, CONFIG_NAME)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.config
|
16
|
+
@yaml ||= YAML.load_file(config_file)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'lhj/config'
|
2
|
+
require_relative 'oss_config'
|
2
3
|
|
3
4
|
module Lhj
|
4
5
|
class Trans
|
@@ -18,9 +19,13 @@ module Lhj
|
|
18
19
|
contents.to_hash
|
19
20
|
end
|
20
21
|
|
22
|
+
def down_load_path
|
23
|
+
"http://#{Lhj::OSSConfig.oss_bucket}.#{Lhj::OSSConfig.oss_endpoint}/zh2hant.yml"
|
24
|
+
end
|
25
|
+
|
21
26
|
def down_load_yaml
|
22
27
|
require 'open-uri'
|
23
|
-
URI.open(
|
28
|
+
URI.open(down_load_path) do |i|
|
24
29
|
File.open(yaml_file, 'w+') do |f|
|
25
30
|
f.write(i.read)
|
26
31
|
end
|
data/lib/lhj/tools/version.rb
CHANGED
data/lib/lhj/tools.rb
CHANGED
@@ -3,8 +3,10 @@ require_relative "tools/version"
|
|
3
3
|
require 'colored'
|
4
4
|
|
5
5
|
module Lhj
|
6
|
+
require 'lhj/env'
|
6
7
|
require 'lhj/ui/ui'
|
7
8
|
require 'lhj/config'
|
9
|
+
require 'lhj/helper/pod_repo_config'
|
8
10
|
require 'lhj/helper/pgyer_helper'
|
9
11
|
require 'lhj/helper/dingtalk_helper'
|
10
12
|
require 'lhj/helper/tb_helper'
|
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.
|
4
|
+
version: 0.1.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lihaijian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: claide
|
@@ -326,6 +326,7 @@ files:
|
|
326
326
|
- lib/lhj/command/yapi/formatters/template/pgyer.erb
|
327
327
|
- lib/lhj/command/yapi/formatters/template/yapi.erb
|
328
328
|
- lib/lhj/config.rb
|
329
|
+
- lib/lhj/env.rb
|
329
330
|
- lib/lhj/helper/dingtalk_config.rb
|
330
331
|
- lib/lhj/helper/dingtalk_helper.rb
|
331
332
|
- lib/lhj/helper/git_helper.rb
|
@@ -335,8 +336,10 @@ files:
|
|
335
336
|
- lib/lhj/helper/oss_helper.rb
|
336
337
|
- lib/lhj/helper/pgyer_config.rb
|
337
338
|
- lib/lhj/helper/pgyer_helper.rb
|
339
|
+
- lib/lhj/helper/pod_repo_config.rb
|
338
340
|
- lib/lhj/helper/tb_config.rb
|
339
341
|
- lib/lhj/helper/tb_helper.rb
|
342
|
+
- lib/lhj/helper/team_member_config.rb
|
340
343
|
- lib/lhj/helper/trans_helper.rb
|
341
344
|
- lib/lhj/tools.rb
|
342
345
|
- lib/lhj/tools/version.rb
|