podfileDep 2.6.0 → 2.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/cocoapods_plugin.rb +2 -1
- data/lib/podfileDep/command/dep.rb +36 -0
- data/lib/podfileDep/dep/find.rb +119 -0
- data/lib/podfileDep/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12cedbc27748544e9a2c8034f600479e4074873cef6df41d6060e4211efebce3
|
4
|
+
data.tar.gz: a8d300437659f498422a77c7f135f6293a8f130605e4480743d593d09a67abd0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8b60da680d26b9cf68edab608f0fa7706c2b6c4f7446a8d4abe1d0c325d8fcc8bbe75ee0848da079858da62663d1927ba4a5d524746d337a4a7a750b07d5683
|
7
|
+
data.tar.gz: 60a62b90fa41f2e1c533b98cf9c0339e466c13a1e63f4d5ecfdc8c7f5461f897e37715dee616588e56ca912790dd8d91c8d54125a099d042e3d3919a660c5c44
|
data/CHANGELOG.md
CHANGED
data/lib/cocoapods_plugin.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'cocoapods'
|
2
|
-
require_relative 'podfileDep/command/
|
2
|
+
require_relative 'podfileDep/command/dep'
|
3
|
+
require_relative 'podfileDep/command/quick'
|
3
4
|
require_relative 'podfileDep/command/quick'
|
4
5
|
require_relative 'podfileDep/check/project'
|
5
6
|
require_relative 'podfileDep/check/podspec'
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require_relative '../dep/find'
|
2
|
+
require_relative '../version'
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Dep < Command
|
6
|
+
|
7
|
+
self.summary = '从Podfile.lock文件里检索出依赖反转后的情况'
|
8
|
+
|
9
|
+
self.description = <<-DESC
|
10
|
+
从Podfile.lock文件里检索出依赖反转后的情况
|
11
|
+
DESC
|
12
|
+
|
13
|
+
def self.options
|
14
|
+
[
|
15
|
+
%w[--name=xx xx为要查询的组件的名字],
|
16
|
+
%w[--sort 输出反转依赖时按数量从小到大排序],
|
17
|
+
].concat(super).reject { |(name, _)| (name == '--no-ansi' or name == '--silent' or name == '--allow-root' or name == '--verbose') }
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(argv)
|
21
|
+
super
|
22
|
+
puts "插件版本号: #{PodfileDep::VERSION}"
|
23
|
+
@name = argv.option('name')
|
24
|
+
@sort_count = argv.flag?('sort', false)
|
25
|
+
end
|
26
|
+
|
27
|
+
def run
|
28
|
+
verify_lockfile_exists!
|
29
|
+
finder = Pod::DepFinder.new
|
30
|
+
finder.find_name = @name
|
31
|
+
finder.sort_count = @sort_count
|
32
|
+
finder.find
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'colored2'
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
class DepFinder
|
6
|
+
|
7
|
+
# @param [Hash] podfileLock内容
|
8
|
+
attr_accessor :lockfile_content
|
9
|
+
|
10
|
+
# @param [String] 要查询的组件名
|
11
|
+
attr_accessor :find_name
|
12
|
+
|
13
|
+
# @param [bool] 是否按数量从小到大排序
|
14
|
+
attr_accessor :sort_count
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
super
|
18
|
+
init_lock
|
19
|
+
end
|
20
|
+
|
21
|
+
def init_lock
|
22
|
+
# 读取名为Podfile.lock的yaml文件, 并通过分析里面的PODS数组,输出依赖的第三方库的名字
|
23
|
+
unless File.exist?("Podfile.lock")
|
24
|
+
puts "Podfile.lock文件不存在,请先执行pod install或pod update".red
|
25
|
+
end
|
26
|
+
|
27
|
+
@sort_count = false
|
28
|
+
|
29
|
+
@lockfile_content = YAML.load_file('Podfile.lock')
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
# @api 反向依赖查询
|
34
|
+
def find
|
35
|
+
|
36
|
+
if @find_name
|
37
|
+
find_for_name
|
38
|
+
else
|
39
|
+
find_all
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def find_all
|
44
|
+
|
45
|
+
reverse_map = Hash.new
|
46
|
+
# 循环遍历lockfile对象中的PODS数组
|
47
|
+
@lockfile_content['PODS'].each do |pod|
|
48
|
+
# 拿到所有的组件名
|
49
|
+
key = pod.is_a?(Hash) ? pod.keys[0] : pod
|
50
|
+
key = key.split(" (")[0]
|
51
|
+
results = find_with_name(key)
|
52
|
+
|
53
|
+
reverse_map[key] = results
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
puts ""
|
58
|
+
sorted_hash = reverse_map
|
59
|
+
if @sort_count
|
60
|
+
puts "反转后依赖如下(数量从少到多):"
|
61
|
+
sorted_hash = Hash[reverse_map.sort_by { |key, value| value.length }]
|
62
|
+
else
|
63
|
+
puts "反转后依赖如下:"
|
64
|
+
end
|
65
|
+
|
66
|
+
sorted_hash.each do |key, array|
|
67
|
+
puts "依赖#{key}的组件有(#{array.length}个):".green
|
68
|
+
array.each do |obj|
|
69
|
+
puts obj
|
70
|
+
end
|
71
|
+
puts "\n"
|
72
|
+
end
|
73
|
+
|
74
|
+
unless @sort_count
|
75
|
+
puts "==> 按数量从少到多排序,可使用pod dep --sort".yellow
|
76
|
+
end
|
77
|
+
puts "==> 查询单个依赖的情况,可使用pod dep --name=xx".yellow
|
78
|
+
end
|
79
|
+
|
80
|
+
def find_for_name
|
81
|
+
results = find_with_name(@find_name)
|
82
|
+
|
83
|
+
if results.empty?
|
84
|
+
puts "组件#{@find_name}没有被任何其他组件依赖"
|
85
|
+
return
|
86
|
+
end
|
87
|
+
|
88
|
+
puts "依赖#{@find_name}的组件有:".green
|
89
|
+
results.each do |res|
|
90
|
+
puts res
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def find_with_name(name)
|
95
|
+
results = Array.new
|
96
|
+
# 循环遍历lockfile对象中的PODS数组
|
97
|
+
@lockfile_content['PODS'].each do |pod|
|
98
|
+
if pod.is_a?(Hash)
|
99
|
+
pod.values.each do |value|
|
100
|
+
# 如果value是一个数组,则判断数组中是否包含name
|
101
|
+
if value.is_a?(Array)
|
102
|
+
value.each { |sub_value|
|
103
|
+
# 这里的处理包含了子模块的情况
|
104
|
+
sub_module = sub_value.split(" (")[0]
|
105
|
+
if sub_module == name
|
106
|
+
results << pod.keys.first
|
107
|
+
end
|
108
|
+
}
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# 去重
|
115
|
+
results.uniq
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
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.
|
4
|
+
version: 2.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 王帅朋
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cocoapods
|
@@ -75,7 +75,9 @@ files:
|
|
75
75
|
- lib/podfileDep/check/util.rb
|
76
76
|
- lib/podfileDep/check/xcodeproj.rb
|
77
77
|
- lib/podfileDep/command/all.rb
|
78
|
+
- lib/podfileDep/command/dep.rb
|
78
79
|
- lib/podfileDep/command/quick.rb
|
80
|
+
- lib/podfileDep/dep/find.rb
|
79
81
|
- lib/podfileDep/indirect/indirect.rb
|
80
82
|
- lib/podfileDep/modify/modify_code.rb
|
81
83
|
- lib/podfileDep/my_constants.rb
|