lhj-tools 0.1.24 → 0.1.27
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/sync_pod_repo.rb +2 -2
- data/lib/lhj/command/sync_pod_version.rb +91 -0
- data/lib/lhj/command.rb +1 -0
- data/lib/lhj/helper/pgyer_config.rb +9 -12
- data/lib/lhj/helper/pgyer_helper.rb +2 -1
- data/lib/lhj/helper/pod_repo_config.rb +24 -0
- data/lib/lhj/helper/trans_helper.rb +6 -1
- data/lib/lhj/jenkins/client.rb +837 -0
- data/lib/lhj/jenkins/exceptions.rb +226 -0
- data/lib/lhj/jenkins/job.rb +1933 -0
- data/lib/lhj/jenkins/urihelper.rb +21 -0
- data/lib/lhj/tools/version.rb +1 -1
- data/lib/lhj/tools.rb +6 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30a31460c814e1615aaefd473d2553acb40523e966f00ee37872db81d06466e0
|
4
|
+
data.tar.gz: d6f3348a4ce8c2a77e2a3d9e8ad6ce6393cbc4ae04b9c39d3c7cd31e19b5e45b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d722e7e3e748415b3a63e912940a2f5b84e5b4e4d7e87095a52e93204971851c9fa5decc5749d51e3b6ddafd23818844d9bb3090498b60239da0962c6a390ec
|
7
|
+
data.tar.gz: 22eb054aa18a58b9b926d55af8a76419efbc82569eb60cf4a34c1f5aa8ce6630b1de9545916c1dc6a132edbd9606a838d1fbf602f111426e1f622a3dd67cf328
|
@@ -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"
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'lhj/config'
|
2
|
+
require 'highline'
|
3
|
+
require 'lhj/helper/pod_repo_config'
|
4
|
+
|
5
|
+
module Lhj
|
6
|
+
class Command
|
7
|
+
# sync code to pod
|
8
|
+
class SyncPodVersion < Command
|
9
|
+
self.summary = '同步主工程的库的版本号'
|
10
|
+
|
11
|
+
def initialize(argv)
|
12
|
+
@cli = HighLine.new
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
def begin_title
|
17
|
+
'读取映射文件~/.lhj/pod_config.yml'
|
18
|
+
end
|
19
|
+
|
20
|
+
def handle
|
21
|
+
sync
|
22
|
+
end
|
23
|
+
|
24
|
+
def sync
|
25
|
+
config_file = File.join(Lhj::Config.instance.home_dir, 'pod_config.yml')
|
26
|
+
arr = YAML.load_file(config_file)
|
27
|
+
arr.each_index { |i| puts "#{i}.#{arr[i]['pod']}".yellow }
|
28
|
+
idx = @cli.ask('请选择哪一个库同步: '.green).strip.to_i
|
29
|
+
pod_name = arr[idx]['pod']
|
30
|
+
src = arr[idx]['main_path']
|
31
|
+
dest = arr[idx]['pod_path']
|
32
|
+
|
33
|
+
ma = nil
|
34
|
+
Dir.chdir(dest) do
|
35
|
+
Dir.glob('*.podspec').each do |p|
|
36
|
+
version_line = IO.readlines(p).find{ |line| (/\.version/ =~ line) && (version_regex =~ line) }
|
37
|
+
ma = version_line.match(version_regex)
|
38
|
+
end
|
39
|
+
puts '获取版本号成功'.green
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
# find src root dir
|
44
|
+
src_root_dir = find_src_root_dir(src)
|
45
|
+
Dir.chdir(src_root_dir) do
|
46
|
+
if ma
|
47
|
+
pod_version = ma[0]
|
48
|
+
update_all_pod_dependency(pod_name, pod_version)
|
49
|
+
puts '更新主工程引用pod版本号成功'.green
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def find_src_root_dir(src)
|
55
|
+
ps = []
|
56
|
+
src.scan(%r{(/[^/]*)}).flatten.each do |path|
|
57
|
+
path =~ /Code/ ? break : ps << path
|
58
|
+
end
|
59
|
+
File.join(ps)
|
60
|
+
end
|
61
|
+
|
62
|
+
def version_regex
|
63
|
+
/\d+\.\d+\.(\d+)/
|
64
|
+
end
|
65
|
+
|
66
|
+
def update_all_pod_dependency(pod_name, pod_version)
|
67
|
+
Dir.glob(%w[./**/*.podspec ./**/Podfile]).each do |p|
|
68
|
+
next if /Example/ =~ p || /temp/ =~ p
|
69
|
+
|
70
|
+
update_main_version(p, pod_name, pod_version)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def update_main_version(file, pod_name, pod_version)
|
75
|
+
cont = ''
|
76
|
+
File.readlines(file).each do |l|
|
77
|
+
if (/#{pod_name}/ =~ l) && (/\d+\.\d+\.\d+/ =~ l)
|
78
|
+
path = File.absolute_path(file)
|
79
|
+
puts "更新文件:#{path}".magenta
|
80
|
+
l.scan(/\d+\.\d+\.\d+/).each do |key|
|
81
|
+
cont += l.gsub(key, pod_version)
|
82
|
+
end
|
83
|
+
else
|
84
|
+
cont += l.dup
|
85
|
+
end
|
86
|
+
end
|
87
|
+
File.write(file, cont)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
data/lib/lhj/command.rb
CHANGED
@@ -19,9 +19,11 @@ module Lhj
|
|
19
19
|
def self.api_key(env = :uat)
|
20
20
|
case env
|
21
21
|
when :release
|
22
|
-
'
|
22
|
+
config['release_api_key']
|
23
23
|
when :gray
|
24
|
-
'
|
24
|
+
config['gray_api_key']
|
25
|
+
when :uat
|
26
|
+
config['uat_api_key']
|
25
27
|
else
|
26
28
|
config['api_key']
|
27
29
|
end
|
@@ -30,23 +32,18 @@ module Lhj
|
|
30
32
|
def self.user_key(env = :uat)
|
31
33
|
case env
|
32
34
|
when :release
|
33
|
-
config['
|
35
|
+
config['release_user_key']
|
34
36
|
when :gray
|
35
|
-
config['
|
37
|
+
config['gray_user_key']
|
38
|
+
when :uat
|
39
|
+
config['uat_user_key']
|
36
40
|
else
|
37
41
|
config['user_key']
|
38
42
|
end
|
39
43
|
end
|
40
44
|
|
41
45
|
def self.password(env = :uat)
|
42
|
-
|
43
|
-
when :release
|
44
|
-
config['password']
|
45
|
-
when :gray
|
46
|
-
config['password']
|
47
|
-
else
|
48
|
-
config['password']
|
49
|
-
end
|
46
|
+
config['password']
|
50
47
|
end
|
51
48
|
end
|
52
49
|
end
|
@@ -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
|
@@ -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
|