lhj-tools 0.1.26 → 0.1.27
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_version.rb +91 -0
- data/lib/lhj/command.rb +1 -0
- data/lib/lhj/tools/version.rb +1 -1
- metadata +3 -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
|
@@ -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
data/lib/lhj/tools/version.rb
CHANGED
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.27
|
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-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: claide
|
@@ -314,6 +314,7 @@ files:
|
|
314
314
|
- lib/lhj/command/rename_image.rb
|
315
315
|
- lib/lhj/command/reverse_import.rb
|
316
316
|
- lib/lhj/command/sync_pod_repo.rb
|
317
|
+
- lib/lhj/command/sync_pod_version.rb
|
317
318
|
- lib/lhj/command/template.rb
|
318
319
|
- lib/lhj/command/trans.rb
|
319
320
|
- lib/lhj/command/view.rb
|