podfileDep 2.7.2 → 2.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/podfileDep/command/dep.rb +6 -3
- data/lib/podfileDep/dep/find.rb +65 -27
- data/lib/podfileDep/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9c50dcd0ef1d84316383fc2cc0ea1e2a1c0a53461b5684c8a416e1c94ce9127
|
4
|
+
data.tar.gz: 5a500fc64a446707546c6afa585d5200ae03f138fa1f37f31471a41ea5e7990b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a68534a545c042bf936d3ca98db19fbc337cb7494df62dde144c3db7e18b197578efd37ab8e379c36496a02003ddeeb0d21f8026f95705cbf2d894851784564d
|
7
|
+
data.tar.gz: 1caafd84cdd5bdedbcc51d6bdab701711c2fbf35e90cd934a51938bdeb00b4db364f268cbd5c71de11b5a303b8238f0bdea8a48fa2068757726ed7a80332566e
|
data/CHANGELOG.md
CHANGED
@@ -4,16 +4,17 @@ module Pod
|
|
4
4
|
class Command
|
5
5
|
class Dep < Command
|
6
6
|
|
7
|
-
self.summary = '从Podfile.lock
|
7
|
+
self.summary = '从Podfile.lock文件里检索打印出组件的正向/反向依赖'
|
8
8
|
|
9
9
|
self.description = <<-DESC
|
10
|
-
从Podfile.lock
|
10
|
+
从Podfile.lock文件里检索打印出组件的正向/反向依赖
|
11
11
|
DESC
|
12
12
|
|
13
13
|
def self.options
|
14
14
|
[
|
15
15
|
%w[--name=xx xx为要查询的组件的名字],
|
16
|
-
%w[--sort
|
16
|
+
%w[--sort 输出依赖时按数量从小到大排序],
|
17
|
+
%w[--forward 输出正向依赖],
|
17
18
|
].concat(super).reject { |(name, _)| (name == '--no-ansi' or name == '--silent' or name == '--allow-root' or name == '--verbose') }
|
18
19
|
end
|
19
20
|
|
@@ -22,6 +23,7 @@ module Pod
|
|
22
23
|
puts "插件版本号: #{PodfileDep::VERSION}"
|
23
24
|
@name = argv.option('name')
|
24
25
|
@sort_count = argv.flag?('sort', false)
|
26
|
+
@forward = argv.flag?('forward', false)
|
25
27
|
end
|
26
28
|
|
27
29
|
def run
|
@@ -29,6 +31,7 @@ module Pod
|
|
29
31
|
finder = Pod::DepFinder.new
|
30
32
|
finder.find_name = @name
|
31
33
|
finder.sort_count = @sort_count
|
34
|
+
finder.forward = @forward
|
32
35
|
finder.find
|
33
36
|
end
|
34
37
|
end
|
data/lib/podfileDep/dep/find.rb
CHANGED
@@ -13,6 +13,9 @@ module Pod
|
|
13
13
|
# @param [bool] 是否按数量从小到大排序
|
14
14
|
attr_accessor :sort_count
|
15
15
|
|
16
|
+
# @param [bool] 是否打印正向依赖
|
17
|
+
attr_accessor :forward
|
18
|
+
|
16
19
|
def initialize
|
17
20
|
super
|
18
21
|
init_lock
|
@@ -34,64 +37,99 @@ module Pod
|
|
34
37
|
def find
|
35
38
|
|
36
39
|
if @find_name
|
37
|
-
|
40
|
+
find_single_dep
|
38
41
|
else
|
39
|
-
|
42
|
+
find_all_dep
|
43
|
+
end
|
44
|
+
|
45
|
+
puts "\n基础命令(默认输出反向依赖):pod dep"
|
46
|
+
unless @forward
|
47
|
+
puts "==> 输出所有正向依赖,可加参数 --forward".yellow
|
48
|
+
end
|
49
|
+
unless @sort_count
|
50
|
+
puts "==> 按数量从少到多排序,可加参数 --sort".yellow
|
51
|
+
end
|
52
|
+
unless @find_name
|
53
|
+
puts "==> 查询单个依赖的情况,可使用参数 --name=xx".yellow
|
40
54
|
end
|
55
|
+
|
41
56
|
end
|
42
57
|
|
43
|
-
def
|
58
|
+
def find_all_dep
|
44
59
|
|
45
|
-
|
60
|
+
result_map = Hash.new
|
46
61
|
# 循环遍历lockfile对象中的PODS数组
|
47
62
|
@lockfile_content['PODS'].each do |pod|
|
48
63
|
# 拿到所有的组件名
|
49
64
|
key = pod.is_a?(Hash) ? pod.keys[0] : pod
|
50
65
|
key = key.split(" (")[0]
|
51
|
-
results = find_with_name(key)
|
52
|
-
|
53
|
-
reverse_map[key] = results
|
54
66
|
|
67
|
+
if @forward
|
68
|
+
result_map[key] = pod.is_a?(Hash) ? pod.values : Array.new
|
69
|
+
else
|
70
|
+
result_map[key] = find_reverse_with_name(key)
|
71
|
+
end
|
55
72
|
end
|
56
73
|
|
57
|
-
|
58
|
-
|
74
|
+
msg = @forward ? "正向依赖" : "反向依赖"
|
75
|
+
puts "打印#{msg}"
|
76
|
+
|
77
|
+
sorted_hash = result_map
|
59
78
|
if @sort_count
|
60
|
-
puts "
|
61
|
-
sorted_hash = Hash[
|
62
|
-
else
|
63
|
-
puts "反转后依赖如下:"
|
79
|
+
puts "数量从少到多"
|
80
|
+
sorted_hash = Hash[result_map.sort_by { |key, value| value.length }]
|
64
81
|
end
|
65
82
|
|
66
83
|
sorted_hash.each do |key, array|
|
67
|
-
|
84
|
+
if @forward
|
85
|
+
puts "组件#{key}的依赖有(#{array.length}个):".green
|
86
|
+
else
|
87
|
+
puts "依赖#{key}的组件有(#{array.length}个):".green
|
88
|
+
end
|
89
|
+
|
68
90
|
array.each do |obj|
|
69
91
|
puts obj
|
70
92
|
end
|
71
93
|
puts "\n"
|
72
94
|
end
|
73
|
-
|
74
|
-
unless @sort_count
|
75
|
-
puts "==> 按数量从少到多排序,可使用pod dep --sort".yellow
|
76
|
-
end
|
77
|
-
puts "==> 查询单个依赖的情况,可使用pod dep --name=xx".yellow
|
78
95
|
end
|
79
96
|
|
80
|
-
def
|
81
|
-
results = find_with_name(@find_name)
|
97
|
+
def find_single_dep
|
82
98
|
|
83
|
-
|
84
|
-
|
85
|
-
|
99
|
+
# 反向依赖查询结果
|
100
|
+
results = find_reverse_with_name(@find_name)
|
101
|
+
puts "依赖#{@find_name}的组件有(#{results.length}个):".green
|
102
|
+
results.each do |res|
|
103
|
+
puts res
|
86
104
|
end
|
87
105
|
|
88
|
-
puts "
|
89
|
-
|
106
|
+
puts "\n"
|
107
|
+
|
108
|
+
# 正向依赖查询结果
|
109
|
+
forward_results = find_forward_with_name(@find_name)
|
110
|
+
puts "#{@find_name}依赖的组件有(#{forward_results.length}个):".green
|
111
|
+
forward_results.each do |res|
|
90
112
|
puts res
|
91
113
|
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
def find_forward_with_name(name)
|
118
|
+
results = Array.new
|
119
|
+
@lockfile_content['PODS'].each do |pod|
|
120
|
+
# 拿到所有的组件名
|
121
|
+
key = pod.is_a?(Hash) ? pod.keys[0] : pod
|
122
|
+
key = key.split(" (")[0]
|
123
|
+
if key == name and pod.is_a?(Hash)
|
124
|
+
pod.each_value do |value|
|
125
|
+
results << value
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
results
|
92
130
|
end
|
93
131
|
|
94
|
-
def
|
132
|
+
def find_reverse_with_name(name)
|
95
133
|
results = Array.new
|
96
134
|
# 循环遍历lockfile对象中的PODS数组
|
97
135
|
@lockfile_content['PODS'].each do |pod|
|
data/lib/podfileDep/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: podfileDep
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.7.
|
4
|
+
version: 2.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 王帅朋
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08-
|
11
|
+
date: 2024-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cocoapods
|