lhj-tools 0.1.25 → 0.1.28
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/duplicate_imageset.rb +53 -0
- data/lib/lhj/command/sync_pod_version.rb +91 -0
- data/lib/lhj/command.rb +2 -0
- data/lib/lhj/helper/dingtalk_config.rb +4 -0
- data/lib/lhj/helper/dingtalk_helper.rb +18 -0
- data/lib/lhj/helper/vika_config.rb +35 -0
- data/lib/lhj/helper/vika_helper.rb +23 -0
- 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 +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1205a5bdd1c7e5e4db52b49b2c60f57e62334a4630572b4f9c76258ce01aaaa
|
4
|
+
data.tar.gz: b6750102f1b8989b9316d5bd94e7a93345e999bf9b0c2f414a8c2c0a1a6351b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc99f9def782efb532b5d5e387b4a982ca59bb4e649f2edb45ac029614252a1994bbe1082ffb32ef6077a404bf711475ef3bdcb8f721d695e1cf44cb9391b035
|
7
|
+
data.tar.gz: aea91cd4ad9d94d570c2f888d6450c5e984e10457379a42910db3c64493e686d4f6ecf6737bd7b12a3957516f478f4992b9fa7414c70db20fe130bf1f138e343
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'csv'
|
3
|
+
|
4
|
+
module Lhj
|
5
|
+
class Command
|
6
|
+
class DuplicateImageset < Command
|
7
|
+
self.summary = '查找重复的图片资源'
|
8
|
+
|
9
|
+
def initialize(argv)
|
10
|
+
@current_path = argv.shift_argument || Dir.pwd
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
def handle
|
15
|
+
write_to_file
|
16
|
+
end
|
17
|
+
|
18
|
+
def write_to_file
|
19
|
+
map = fetch_images
|
20
|
+
file = File.join(@current_path, 'images.cvs')
|
21
|
+
FileUtils.rm_rf(file) if File.exist?(file)
|
22
|
+
CSV.open(file, 'wb:utf-8') do |csv|
|
23
|
+
csv << ['所在模块']
|
24
|
+
map.each do |k, v|
|
25
|
+
csv << [v.join(', ')] if v.length > 1
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def fetch_images
|
31
|
+
image_map = {}
|
32
|
+
Dir.glob("#{@current_path}/**/Assets.xcassets/**/*.imageset").each do |f|
|
33
|
+
image_name = File.basename(f, '.*')
|
34
|
+
models = image_map[image_name.to_sym]
|
35
|
+
unless models
|
36
|
+
models = []
|
37
|
+
image_map[image_name.to_sym] = models
|
38
|
+
end
|
39
|
+
models << model_name_with_path(f)
|
40
|
+
end
|
41
|
+
image_map
|
42
|
+
end
|
43
|
+
|
44
|
+
def model_name_with_path(path)
|
45
|
+
reg = %r{Code/([^/]*)/}
|
46
|
+
reg = %r{Pods/([^/]*)/} if path =~ /Pods/
|
47
|
+
ma = path.match(reg)
|
48
|
+
ma[1]
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -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
@@ -24,7 +24,9 @@ module Lhj
|
|
24
24
|
require 'lhj/command/file_path'
|
25
25
|
require 'lhj/command/http'
|
26
26
|
require 'lhj/command/sync_pod_repo'
|
27
|
+
require 'lhj/command/sync_pod_version'
|
27
28
|
require 'lhj/command/pgyer_upload'
|
29
|
+
require 'lhj/command/duplicate_imageset'
|
28
30
|
|
29
31
|
self.abstract_command = true
|
30
32
|
self.command = 'lhj'
|
@@ -8,7 +8,25 @@ module Lhj
|
|
8
8
|
def self.post_message(title, message)
|
9
9
|
robot_url = Lhj::DingTalkConfig.dingtalk_robot
|
10
10
|
http_body = { 'msgtype' => 'markdown', 'markdown' => { 'title' => title, 'text' => message } }.to_json
|
11
|
+
http_post(robot_url, http_body)
|
12
|
+
post_branch_message(http_body)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.post_branch_message(http_body)
|
16
|
+
branch_name = fetch_branch
|
17
|
+
branch_map = Lhj::DingTalkConfig.git_branch
|
18
|
+
branch_robot_key = branch_map[branch_name] if branch_map && branch_name
|
19
|
+
branch_robot_url = Lhj::DingTalkConfig.config[branch_robot_key] if branch_robot_key
|
20
|
+
http_post(branch_robot_url, http_body) if branch_robot_url
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.http_post(robot_url, http_body)
|
11
24
|
Net::HTTP.post(URI(robot_url), http_body, 'Content-Type' => 'application/json')
|
12
25
|
end
|
26
|
+
|
27
|
+
def self.fetch_branch
|
28
|
+
name = Lhj::Actions.git_branch || ''
|
29
|
+
name.split('/').last
|
30
|
+
end
|
13
31
|
end
|
14
32
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'yaml'
|
3
|
+
require 'lhj/config'
|
4
|
+
|
5
|
+
module Lhj
|
6
|
+
# Ding Talk Config
|
7
|
+
class VikaConfig
|
8
|
+
|
9
|
+
CONFIG_NAME = 'vika_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.datasheet_id
|
20
|
+
config['datasheet_id']
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.view_id
|
24
|
+
config['view_id']
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.record_id
|
28
|
+
config['record_id']
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.authorization
|
32
|
+
config['authorization']
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'lhj/helper/vika_config'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Lhj
|
5
|
+
# pgyer upload
|
6
|
+
class VikaHelper
|
7
|
+
|
8
|
+
RECORDS_API_URL = 'https://api.vika.cn/fusion/v1/datasheets/dstmDXBooTe1Wj0QqE/records?viewId=viwqN84ID6mJb&fieldKey=id'.freeze
|
9
|
+
|
10
|
+
def self.all_records
|
11
|
+
url = URI("https://api.vika.cn/fusion/v1/datasheets/dstmDXBooTe1Wj0QqE/records?viewId=viwqN84ID6mJb&fieldKey=id")
|
12
|
+
|
13
|
+
https = Net::HTTP.new(url.host, url.port)
|
14
|
+
https.use_ssl = true
|
15
|
+
|
16
|
+
request = Net::HTTP::Get.new(url)
|
17
|
+
request["Authorization"] = "Bearer usk3cvEicoXG84y32J61BRg"
|
18
|
+
|
19
|
+
response = https.request(request)
|
20
|
+
puts response.read_body
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|