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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f89a71391e6b1fde204d1f60f8de9f53c9c2fbef9719f71c389be011dc81525f
4
- data.tar.gz: 45381e21de6e280cf07c28bc1beb45da1e81f736d3db455c46f74bd24f80e80c
3
+ metadata.gz: 30a31460c814e1615aaefd473d2553acb40523e966f00ee37872db81d06466e0
4
+ data.tar.gz: d6f3348a4ce8c2a77e2a3d9e8ad6ce6393cbc4ae04b9c39d3c7cd31e19b5e45b
5
5
  SHA512:
6
- metadata.gz: 6ae36d611435d72feccbde3e516c692977cb4cbaa3a68dd3c7720ee7b58744bfb0da83d18f32a465e97abc75e6668d1a0a75a1b31e2d32973d18bc3cfcfb5210
7
- data.tar.gz: e2bf9d372ba3f47fbabff55575930cbb5c56c2f987b0714185ccf01058e8b1ba50435326b07640768cc06e6060e9e9f6b3714a2ac397c2a3aa4d093c1854a9e1
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
@@ -24,6 +24,7 @@ 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'
28
29
 
29
30
  self.abstract_command = true
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lhj
4
4
  module Tools
5
- VERSION = "0.1.26"
5
+ VERSION = "0.1.27"
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.26
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-22 00:00:00.000000000 Z
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