podfileDep 2.7.6 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/cocoapods_plugin.rb +15 -10
- data/lib/{podfileDep → core_blur}/check/import.rb +1 -20
- data/lib/{podfileDep → core_blur}/check/item.rb +1 -64
- data/lib/{podfileDep → core_blur}/check/podspec.rb +1 -54
- data/lib/{podfileDep → core_blur}/check/project.rb +1 -73
- data/lib/{podfileDep → core_blur}/check/util.rb +1 -13
- data/lib/{podfileDep → core_blur}/check/xcodeproj.rb +1 -28
- data/lib/{podfileDep → core_blur}/command/all.rb +1 -8
- data/lib/{podfileDep → core_blur}/command/dep.rb +4 -9
- data/lib/{podfileDep → core_blur}/command/quick.rb +1 -8
- data/lib/{podfileDep → core_blur}/dep/find.rb +9 -48
- data/lib/{podfileDep → core_blur}/indirect/indirect.rb +1 -9
- data/lib/{podfileDep → core_blur}/modify/modify_code.rb +1 -10
- data/lib/{podfileDep → core_blur}/my_constants.rb +0 -3
- data/lib/{podfileDep → core_blur}/podfilelock.rb +1 -5
- data/lib/{podfileDep → core_blur}/reference/project.rb +1 -26
- data/lib/{podfileDep → core_blur}/reference/unused.rb +1 -8
- data/lib/{podfileDep → core_blur}/thin/installer.rb +1 -49
- data/lib/{podfileDep → core_blur}/thin/local.rb +1 -14
- data/lib/{podfileDep → core_blur}/thin/pod_target.rb +1 -13
- data/lib/{podfileDep → core_blur}/thin/shell.rb +1 -43
- data/lib/core_blur/variable.rb +1 -0
- data/lib/{podfileDep → core_blur}/yaml/yaml_dep.rb +2 -116
- data/lib/{podfileDep → core_blur}/yaml/yaml_pod.rb +1 -6
- data/lib/core_helper.rb +20 -0
- data/lib/podfileDep.rb +8 -21
- data/lib/{podfileDep/version.rb → version.rb} +1 -1
- metadata +34 -40
- data/CHANGELOG.md +0 -175
- data/Gemfile +0 -8
- data/README.md +0 -33
- data/Rakefile +0 -4
- data/docs/Gemfile +0 -9
- data/docs/debug/347/233/256/345/275/225.png +0 -0
- data/docs/debug/351/205/215/347/275/256.png +0 -0
- data/lib/podfileDep/variable.rb +0 -2
- data/podfileDep.gemspec +0 -45
- data/release.sh +0 -6
@@ -3,28 +3,13 @@ require 'colored2'
|
|
3
3
|
require 'cocoapods/downloader/request'
|
4
4
|
require_relative 'util'
|
5
5
|
require_relative 'item'
|
6
|
-
|
7
6
|
module Xcodeproj
|
8
|
-
|
9
7
|
class XCodeProject
|
10
|
-
|
11
|
-
# 壳工程xcodeproj对象
|
12
|
-
# @return Xcodeproj::Project
|
13
8
|
attr_accessor :shell_project
|
14
|
-
|
15
|
-
# Pods工程xcodeproj对象
|
16
|
-
# @return Xcodeproj::Project
|
17
9
|
attr_accessor :pod_project
|
18
|
-
|
19
|
-
# @return [Hash{String => ModuleItem}]
|
20
10
|
attr_accessor :module_items
|
21
|
-
|
22
|
-
# @return [Hash]
|
23
11
|
attr_accessor :lock_content
|
24
|
-
|
25
|
-
# @return [Hash]
|
26
12
|
attr_accessor :version_map
|
27
|
-
|
28
13
|
def initialize
|
29
14
|
@shell_project = nil
|
30
15
|
@pod_project = nil
|
@@ -38,7 +23,6 @@ module Xcodeproj
|
|
38
23
|
expand_module
|
39
24
|
init_vendor_frameworks
|
40
25
|
end
|
41
|
-
|
42
26
|
@private
|
43
27
|
def init_shell_project
|
44
28
|
xcodeproj_file = nil
|
@@ -48,41 +32,32 @@ module Xcodeproj
|
|
48
32
|
break
|
49
33
|
end
|
50
34
|
end
|
51
|
-
|
52
35
|
xcodeproj_path = "#{Dir.pwd}/#{xcodeproj_file}"
|
53
36
|
unless File.exist?(xcodeproj_path)
|
54
37
|
return nil
|
55
38
|
end
|
56
|
-
|
57
39
|
@shell_project = Xcodeproj::Project.open(xcodeproj_path)
|
58
40
|
end
|
59
|
-
|
60
41
|
def init_pod_project
|
61
42
|
xcodeproj_path = "#{Dir.pwd}/Pods/Pods.xcodeproj"
|
62
43
|
unless File.exist?(xcodeproj_path)
|
63
44
|
return nil
|
64
45
|
end
|
65
|
-
|
66
46
|
@pod_project = Xcodeproj::Project.open(xcodeproj_path)
|
67
47
|
end
|
68
|
-
|
69
48
|
def init_lockfile
|
70
49
|
lockfile_path = MyConstants::PODFILE_LOCK
|
71
|
-
|
72
50
|
unless File.exist?(lockfile_path)
|
73
51
|
return
|
74
52
|
end
|
75
|
-
|
76
53
|
@lock_content = YAML.load_file(lockfile_path)
|
77
54
|
end
|
78
55
|
def init_version_map
|
79
56
|
lock_content = @lock_content
|
80
|
-
|
81
57
|
remote_dependencies = lock_content["PODS"]
|
82
58
|
unless remote_dependencies
|
83
59
|
return
|
84
60
|
end
|
85
|
-
|
86
61
|
remote_dependencies.each do |dependency|
|
87
62
|
if dependency.class == Hash
|
88
63
|
dependency = dependency.keys.first
|
@@ -94,33 +69,23 @@ module Xcodeproj
|
|
94
69
|
@version_map[name] = version
|
95
70
|
end
|
96
71
|
end
|
97
|
-
|
98
|
-
# 展开模块
|
99
72
|
def expand_module
|
100
73
|
self.expand_with_module(pod_project.main_group, nil)
|
101
74
|
end
|
102
|
-
|
103
|
-
# 展开模块
|
104
75
|
def expand_with_module(group, module_name)
|
105
|
-
|
106
76
|
if group.class != Xcodeproj::Project::Object::PBXGroup
|
107
77
|
return
|
108
78
|
end
|
109
|
-
|
110
79
|
if not module_name and group.hierarchy_path
|
111
80
|
group_hierarchy_path_array = group.hierarchy_path.split("/")
|
112
81
|
module_name = group_hierarchy_path_array.size >= 3 ? group_hierarchy_path_array[2] : nil
|
113
82
|
end
|
114
|
-
|
115
|
-
# 创建 source_file_item
|
116
83
|
source_file_item = @module_items[module_name]
|
117
84
|
if module_name and not source_file_item
|
118
85
|
source_file_item = ModuleItem.new(module_name)
|
119
86
|
source_file_item.podspec_path = get_podspec_path(module_name)
|
120
87
|
@module_items[module_name] = source_file_item
|
121
88
|
end
|
122
|
-
|
123
|
-
# 更新module_path
|
124
89
|
if source_file_item and not source_file_item.module_path and group.hierarchy_path
|
125
90
|
group_hierarchy_path_array = group.hierarchy_path.split("/")
|
126
91
|
if group_hierarchy_path_array.size == 3
|
@@ -130,35 +95,24 @@ module Xcodeproj
|
|
130
95
|
source_file_item.is_development_module = true
|
131
96
|
end
|
132
97
|
end
|
133
|
-
|
134
|
-
# 文件引用
|
135
98
|
file_reference_class = Xcodeproj::Project::Object::PBXFileReference
|
136
|
-
|
137
99
|
not_child_names = ["Podfile","Frameworks", "Products","Targets Support Files","Support Files"]
|
138
100
|
source_file_extension = %w[.h .m .mm .pch .c .cc .cpp .hpp]
|
139
101
|
header_file_extension = %w[.h .hpp]
|
140
|
-
|
141
102
|
group.children.each {|child|
|
142
|
-
|
143
103
|
module_name = source_file_item ? source_file_item.module_name : nil
|
144
|
-
|
145
104
|
if not_child_names.include?(child.name)
|
146
|
-
# puts "不检查:#{child.name} #{child.real_path}"
|
147
105
|
next
|
148
106
|
end
|
149
|
-
|
150
107
|
if child.class != file_reference_class
|
151
|
-
# puts "不是文件引用:#{child.class} #{child.real_path}"
|
152
108
|
self.expand_with_module(child, module_name)
|
153
109
|
next
|
154
110
|
end
|
155
|
-
|
156
111
|
hierarchy_path_array = child.hierarchy_path.split("/")
|
157
112
|
if hierarchy_path_array.size < 3
|
158
113
|
self.expand_with_module(child, module_name)
|
159
114
|
next
|
160
115
|
end
|
161
|
-
|
162
116
|
if source_file_item
|
163
117
|
extend_name = child.real_path.basename.extname
|
164
118
|
basename = child.real_path.basename
|
@@ -170,17 +124,11 @@ module Xcodeproj
|
|
170
124
|
source_file_item.header_files[child.real_path.basename.to_s] = child.real_path
|
171
125
|
end
|
172
126
|
else
|
173
|
-
# puts child.real_path
|
174
127
|
end
|
175
128
|
end
|
176
|
-
|
177
|
-
# 递归展开
|
178
129
|
self.expand_with_module(child, module_name)
|
179
130
|
}
|
180
|
-
|
181
131
|
end
|
182
|
-
|
183
|
-
# 读取某个模块的podspec路径
|
184
132
|
def get_podspec_path(module_name)
|
185
133
|
check_options = lock_content["CHECKOUT OPTIONS"]
|
186
134
|
if check_options and check_options[module_name]
|
@@ -190,8 +138,6 @@ module Xcodeproj
|
|
190
138
|
cache_path = request.slug(**slug_opts)
|
191
139
|
return "~/Library/Caches/CocoaPods/Pods/Specs/#{cache_path}.podspec.json"
|
192
140
|
end
|
193
|
-
|
194
|
-
# :path: localPods/XX
|
195
141
|
local_spec = lock_content["EXTERNAL SOURCES"]
|
196
142
|
if local_spec and local_spec[module_name]
|
197
143
|
path = local_spec[module_name][:path]
|
@@ -205,8 +151,6 @@ module Xcodeproj
|
|
205
151
|
return nil
|
206
152
|
end
|
207
153
|
end
|
208
|
-
|
209
|
-
# 4.0.1-24ee2.podspec.json
|
210
154
|
version_spec = @lock_content["SPEC CHECKSUMS"]
|
211
155
|
md5_to5 = ""
|
212
156
|
if version_spec and version_spec[module_name]
|
@@ -219,29 +163,20 @@ module Xcodeproj
|
|
219
163
|
path = "~/Library/Caches/CocoaPods/Pods/Specs/Release/#{module_name}/#{podspec_json_name}"
|
220
164
|
return Pathname(path).expand_path
|
221
165
|
end
|
222
|
-
|
223
166
|
nil
|
224
167
|
end
|
225
|
-
|
226
|
-
|
227
|
-
# 初始化模块的vendor_frameworks
|
228
168
|
def init_vendor_frameworks
|
229
169
|
@module_items.each_value do |module_item|
|
230
170
|
module_item.frameworks << module_item.module_name
|
231
|
-
|
232
171
|
unless module_item.podspec_path
|
233
172
|
puts "⚠️ 读取#{module_item.module_name}的podspec路径为空,请发送Podfile.lock文件联系开发者修复"
|
234
173
|
next
|
235
174
|
end
|
236
|
-
|
237
175
|
podspec_content = Util.get_podspec_content(module_item.podspec_path)
|
238
|
-
|
239
176
|
unless podspec_content
|
240
177
|
next
|
241
178
|
end
|
242
|
-
|
243
179
|
update_dep_frameworks(module_item.frameworks, podspec_content)
|
244
|
-
|
245
180
|
subspec_content = podspec_content["subspecs"]
|
246
181
|
if subspec_content and subspec_content.class == Array
|
247
182
|
subspec_content.each { |json_content|
|
@@ -249,9 +184,7 @@ module Xcodeproj
|
|
249
184
|
}
|
250
185
|
end
|
251
186
|
end
|
252
|
-
|
253
187
|
end
|
254
|
-
|
255
188
|
def update_dep_frameworks(item_frameworks, json_content)
|
256
189
|
vendor_frameworks = json_content["vendored_frameworks"]
|
257
190
|
unless vendor_frameworks
|
@@ -260,7 +193,6 @@ module Xcodeproj
|
|
260
193
|
vendor_frameworks = ios["vendored_frameworks"]
|
261
194
|
end
|
262
195
|
end
|
263
|
-
|
264
196
|
if vendor_frameworks
|
265
197
|
if vendor_frameworks.class == Array
|
266
198
|
vendor_frameworks.each do |vendor_framework|
|
@@ -277,15 +209,11 @@ module Xcodeproj
|
|
277
209
|
end
|
278
210
|
end
|
279
211
|
end
|
280
|
-
|
281
212
|
def deal_frameworks(frameworks)
|
282
|
-
# "frameworks/WCDB/WCDB.framework",
|
283
|
-
# "openssl.xcframework"
|
284
213
|
temp_array = frameworks.split("/")
|
285
214
|
result = temp_array.last
|
286
215
|
result = result.gsub(".xcframework","")
|
287
216
|
result.gsub(".framework", "")
|
288
217
|
end
|
289
|
-
|
290
218
|
end
|
291
|
-
end
|
219
|
+
end
|
@@ -1,12 +1,7 @@
|
|
1
1
|
module Xcodeproj
|
2
2
|
class Util
|
3
|
-
#读取podspec内容
|
4
|
-
# @return [Hash]
|
5
|
-
# @param podspec_path::[Pathname]
|
6
3
|
def self.get_podspec_content(podspec_path)
|
7
|
-
|
8
4
|
podspec_json_path = podspec_path.to_s.end_with?(".podspec.json") ? podspec_path : nil
|
9
|
-
|
10
5
|
podspec_content = nil
|
11
6
|
if podspec_json_path and File.exist?(podspec_json_path)
|
12
7
|
json = File.read(podspec_json_path)
|
@@ -17,22 +12,15 @@ module Xcodeproj
|
|
17
12
|
end
|
18
13
|
podspec_content
|
19
14
|
end
|
20
|
-
|
21
15
|
@private
|
22
|
-
# 根据podspec路径把podspec转为json
|
23
16
|
def self.get_podspec_file_content(podspec_path)
|
24
|
-
|
25
17
|
spec_contents = File.open(podspec_path, 'r:utf-8', &:read)
|
26
|
-
|
27
18
|
if spec_contents.respond_to?(:encoding) && spec_contents.encoding.name != 'UTF-8'
|
28
19
|
spec_contents.encode!('UTF-8')
|
29
20
|
end
|
30
|
-
|
31
21
|
path = Pathname.new(podspec_path)
|
32
|
-
|
33
22
|
spec = ::Pod._eval_podspec(spec_contents, path)
|
34
|
-
|
35
23
|
spec.to_json
|
36
24
|
end
|
37
25
|
end
|
38
|
-
end
|
26
|
+
end
|
@@ -1,31 +1,17 @@
|
|
1
1
|
require 'xcodeproj'
|
2
2
|
require 'pathname'
|
3
|
-
|
4
3
|
module XCProject
|
5
|
-
|
6
4
|
class XcodeprojManager
|
7
|
-
|
8
|
-
# 缓存某个的依赖库
|
9
|
-
# {{"module_nameA":["module_nameA", module_nameB]},}
|
10
5
|
attr_reader :module_frameworks
|
11
|
-
|
12
6
|
def initialize
|
13
7
|
@module_frameworks = {}
|
14
8
|
end
|
15
|
-
|
16
|
-
# 单例方法
|
17
9
|
@@instance = XcodeprojManager.new
|
18
|
-
|
19
|
-
# 获取单例
|
20
10
|
def self.share_manager
|
21
11
|
@@instance
|
22
12
|
end
|
23
|
-
|
24
13
|
private_class_method :new
|
25
|
-
|
26
|
-
# 获取壳工程的project对象
|
27
14
|
def get_shell_project
|
28
|
-
|
29
15
|
xcodeproj_file = nil
|
30
16
|
Dir.foreach(Dir.pwd) do |file|
|
31
17
|
if file.end_with?(".xcodeproj")
|
@@ -33,17 +19,12 @@ module XCProject
|
|
33
19
|
break
|
34
20
|
end
|
35
21
|
end
|
36
|
-
|
37
22
|
xcodeproj_path = "#{Dir.pwd}/#{xcodeproj_file}"
|
38
23
|
unless File.exist?(xcodeproj_path)
|
39
24
|
return nil
|
40
25
|
end
|
41
|
-
|
42
26
|
Xcodeproj::Project.open(xcodeproj_path)
|
43
|
-
|
44
27
|
end
|
45
|
-
|
46
|
-
#获取主APP target列表 包含扩展
|
47
28
|
def get_shell_targets
|
48
29
|
results = []
|
49
30
|
project = self.get_shell_project
|
@@ -53,24 +34,16 @@ module XCProject
|
|
53
34
|
end
|
54
35
|
results
|
55
36
|
end
|
56
|
-
|
57
|
-
#获取主APP target列表 不包含扩展
|
58
37
|
def get_app_targets
|
59
38
|
project = self.get_shell_project
|
60
39
|
project.root_object.targets
|
61
40
|
end
|
62
|
-
|
63
|
-
# 获取Pods下project对象
|
64
41
|
def get_pods_project
|
65
|
-
|
66
42
|
xcodeproj_path = "#{Dir.pwd}/Pods/Pods.xcodeproj"
|
67
43
|
unless File.exist?(xcodeproj_path)
|
68
44
|
return nil
|
69
45
|
end
|
70
|
-
|
71
46
|
Xcodeproj::Project.open(xcodeproj_path)
|
72
|
-
|
73
47
|
end
|
74
|
-
|
75
48
|
end
|
76
|
-
end
|
49
|
+
end
|
@@ -1,24 +1,17 @@
|
|
1
1
|
require 'cocoapods'
|
2
2
|
require_relative '../variable'
|
3
|
-
|
4
3
|
module Pod
|
5
4
|
class Command
|
6
5
|
class All < Install
|
7
|
-
|
8
6
|
self.summary = '单次关闭编译优化'
|
9
|
-
|
10
7
|
self.description = <<-DESC
|
11
8
|
* 开启编译优化命令
|
12
9
|
* pod install all
|
13
10
|
DESC
|
14
|
-
|
15
|
-
|
16
11
|
def initialize(argv)
|
17
12
|
super
|
18
13
|
$quick_build = false
|
19
14
|
end
|
20
|
-
|
21
15
|
end
|
22
|
-
|
23
16
|
end
|
24
|
-
end
|
17
|
+
end
|
@@ -1,23 +1,19 @@
|
|
1
1
|
require_relative '../dep/find'
|
2
|
-
require_relative '
|
2
|
+
require_relative '../../version'
|
3
3
|
module Pod
|
4
4
|
class Command
|
5
5
|
class Dep < Command
|
6
|
-
|
7
6
|
self.summary = '从Podfile.lock文件里检索打印出组件的正向/反向依赖'
|
8
|
-
|
9
7
|
self.description = <<-DESC
|
10
8
|
从Podfile.lock文件里检索打印出组件的正向/反向依赖
|
11
9
|
DESC
|
12
|
-
|
13
10
|
def self.options
|
14
11
|
[
|
15
|
-
%w[
|
16
|
-
%w[
|
17
|
-
%w[
|
12
|
+
%w[--name=xx xx为要查询的组件的名字],
|
13
|
+
%w[--sort 输出依赖时按数量从小到大排序],
|
14
|
+
%w[--forward 输出正向依赖],
|
18
15
|
].concat(super).reject { |(name, _)| (name == '--no-ansi' or name == '--silent' or name == '--allow-root' or name == '--verbose') }
|
19
16
|
end
|
20
|
-
|
21
17
|
def initialize(argv)
|
22
18
|
super
|
23
19
|
puts "插件版本号: #{PodfileDep::VERSION}"
|
@@ -25,7 +21,6 @@ module Pod
|
|
25
21
|
@sort_count = argv.flag?('sort', false)
|
26
22
|
@forward = argv.flag?('forward', false)
|
27
23
|
end
|
28
|
-
|
29
24
|
def run
|
30
25
|
verify_lockfile_exists!
|
31
26
|
finder = Pod::DepFinder.new
|
@@ -1,24 +1,17 @@
|
|
1
1
|
require 'cocoapods'
|
2
2
|
require_relative '../variable'
|
3
|
-
|
4
3
|
module Pod
|
5
4
|
class Command
|
6
5
|
class Quick < Install
|
7
|
-
|
8
6
|
self.summary = '单次开启编译优化'
|
9
|
-
|
10
7
|
self.description = <<-DESC
|
11
8
|
* 开启编译优化命令
|
12
9
|
* pod install quick
|
13
10
|
DESC
|
14
|
-
|
15
|
-
|
16
11
|
def initialize(argv)
|
17
12
|
super
|
18
13
|
$quick_build = true
|
19
14
|
end
|
20
|
-
|
21
15
|
end
|
22
|
-
|
23
16
|
end
|
24
|
-
end
|
17
|
+
end
|
@@ -1,123 +1,88 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'colored2'
|
3
|
-
|
4
3
|
module Pod
|
5
4
|
class DepFinder
|
6
|
-
|
7
|
-
# @param [Hash] podfileLock内容
|
8
5
|
attr_accessor :lockfile_content
|
9
|
-
|
10
|
-
# @param [String] 要查询的组件名
|
11
6
|
attr_accessor :find_name
|
12
|
-
|
13
|
-
# @param [bool] 是否按数量从小到大排序
|
14
7
|
attr_accessor :sort_count
|
15
|
-
|
16
|
-
# @param [bool] 是否打印正向依赖
|
17
8
|
attr_accessor :forward
|
18
|
-
|
19
9
|
def initialize
|
20
10
|
super
|
21
11
|
init_lock
|
22
12
|
end
|
23
|
-
|
24
13
|
def init_lock
|
25
|
-
# 读取名为Podfile.lock的yaml文件, 并通过分析里面的PODS数组,输出依赖的第三方库的名字
|
26
14
|
unless File.exist?("Podfile.lock")
|
27
15
|
puts "Podfile.lock文件不存在,请先执行pod install或pod update".red
|
28
16
|
end
|
29
|
-
|
30
17
|
@sort_count = false
|
31
|
-
|
32
18
|
@lockfile_content = YAML.load_file('Podfile.lock')
|
33
|
-
|
34
19
|
end
|
35
|
-
|
36
|
-
# @api 反向依赖查询
|
37
20
|
def find
|
38
|
-
|
39
21
|
if @find_name
|
40
22
|
find_single_dep
|
41
23
|
else
|
42
24
|
find_all_dep
|
43
25
|
end
|
44
|
-
|
45
26
|
puts "\n基础命令(默认输出反向依赖):pod dep"
|
46
27
|
unless @forward
|
47
|
-
puts "==> 输出所有正向依赖,可加参数
|
28
|
+
puts "==> 输出所有正向依赖,可加参数 --forward".yellow
|
48
29
|
end
|
49
30
|
unless @sort_count
|
50
|
-
puts "==> 按数量从少到多排序,可加参数
|
31
|
+
puts "==> 按数量从少到多排序,可加参数 --sort".yellow
|
51
32
|
end
|
52
33
|
unless @find_name
|
53
|
-
puts "==> 查询单个依赖的情况,可使用参数
|
34
|
+
puts "==> 查询单个依赖的情况,可使用参数 --name=xx".yellow
|
54
35
|
end
|
55
|
-
|
56
36
|
end
|
57
|
-
|
58
37
|
def find_all_dep
|
59
|
-
|
60
38
|
result_map = Hash.new
|
61
|
-
# 循环遍历lockfile对象中的PODS数组
|
62
39
|
@lockfile_content['PODS'].each do |pod|
|
63
|
-
# 拿到所有的组件名
|
64
40
|
key = pod.is_a?(Hash) ? pod.keys[0] : pod
|
65
41
|
key = key.split(" (")[0]
|
66
|
-
|
67
42
|
if @forward
|
68
43
|
result_map[key] = pod.is_a?(Hash) ? pod.values[0] : Array.new
|
69
44
|
else
|
70
45
|
result_map[key] = find_reverse_with_name(key)
|
71
46
|
end
|
72
47
|
end
|
73
|
-
|
74
48
|
msg = @forward ? "正向依赖" : "反向依赖"
|
75
49
|
puts "打印#{msg}"
|
76
|
-
|
77
50
|
sorted_hash = result_map
|
78
51
|
if @sort_count
|
79
52
|
puts "数量从少到多"
|
80
53
|
sorted_hash = Hash[result_map.sort_by { |key, value| value.length }]
|
81
54
|
end
|
82
|
-
|
83
55
|
sorted_hash.each do |key, array|
|
84
56
|
if @forward
|
85
57
|
puts "组件#{key}的依赖有(#{array.length}个):".green
|
86
58
|
else
|
87
59
|
puts "依赖#{key}的组件有(#{array.length}个):".green
|
88
60
|
end
|
89
|
-
|
90
61
|
array.each do |obj|
|
91
62
|
puts obj
|
92
63
|
end
|
93
64
|
puts "\n"
|
94
65
|
end
|
95
66
|
end
|
96
|
-
|
97
67
|
def find_single_dep
|
98
|
-
|
99
|
-
# 反向依赖查询结果
|
100
68
|
results = find_reverse_with_name(@find_name)
|
101
69
|
puts "依赖#{@find_name}的组件有(#{results.length}个):".green
|
102
70
|
results.each do |res|
|
103
71
|
puts res
|
104
72
|
end
|
105
|
-
|
106
73
|
puts "\n"
|
107
|
-
|
108
|
-
# 正向依赖查询结果
|
109
74
|
forward_results = find_forward_with_name(@find_name)
|
110
75
|
puts "#{@find_name}依赖的组件有(#{forward_results.length}个):".green
|
111
76
|
forward_results.each do |res|
|
112
77
|
puts res
|
113
78
|
end
|
114
|
-
|
115
79
|
end
|
116
|
-
|
117
80
|
def find_forward_with_name(name)
|
81
|
+
if not @lockfile_content or not @lockfile_content['PODS']
|
82
|
+
return []
|
83
|
+
end
|
118
84
|
results = Array.new
|
119
85
|
@lockfile_content['PODS'].each do |pod|
|
120
|
-
# 拿到所有的组件名
|
121
86
|
key = pod.is_a?(Hash) ? pod.keys[0] : pod
|
122
87
|
key = key.split(" (")[0]
|
123
88
|
if key == name and pod.is_a?(Hash)
|
@@ -128,17 +93,16 @@ module Pod
|
|
128
93
|
end
|
129
94
|
results
|
130
95
|
end
|
131
|
-
|
132
96
|
def find_reverse_with_name(name)
|
97
|
+
if not @lockfile_content or not @lockfile_content['PODS']
|
98
|
+
return []
|
99
|
+
end
|
133
100
|
results = Array.new
|
134
|
-
# 循环遍历lockfile对象中的PODS数组
|
135
101
|
@lockfile_content['PODS'].each do |pod|
|
136
102
|
if pod.is_a?(Hash)
|
137
103
|
pod.values.each do |value|
|
138
|
-
# 如果value是一个数组,则判断数组中是否包含name
|
139
104
|
if value.is_a?(Array)
|
140
105
|
value.each { |sub_value|
|
141
|
-
# 这里的处理包含了子模块的情况
|
142
106
|
sub_module = sub_value.split(" (")[0]
|
143
107
|
if sub_module == name
|
144
108
|
results << pod.keys.first
|
@@ -148,10 +112,7 @@ module Pod
|
|
148
112
|
end
|
149
113
|
end
|
150
114
|
end
|
151
|
-
|
152
|
-
# 去重
|
153
115
|
results.uniq
|
154
116
|
end
|
155
117
|
end
|
156
118
|
end
|
157
|
-
|
@@ -1,30 +1,22 @@
|
|
1
1
|
require_relative '../podfilelock'
|
2
|
-
|
3
2
|
module PodfileLock
|
4
3
|
class Indirect
|
5
4
|
def log_indirect
|
6
|
-
|
7
|
-
# 内容读取
|
8
5
|
dependencies_lock = PodfileLock::PodfileLockManager.podfile_lock_content
|
9
|
-
|
10
6
|
dependencies = dependencies_lock['DEPENDENCIES']
|
11
7
|
unless dependencies
|
12
8
|
return
|
13
9
|
end
|
14
|
-
|
15
10
|
check_sums = dependencies_lock['SPEC CHECKSUMS']
|
16
11
|
unless check_sums
|
17
12
|
return
|
18
13
|
end
|
19
|
-
|
20
|
-
# 数组处理
|
21
14
|
check_values = dependencies.collect! {|item|
|
22
15
|
item.split(' (')[0]
|
23
16
|
}
|
24
17
|
check_values = dependencies.collect! {|item|
|
25
18
|
item.split('/')[0]
|
26
19
|
}
|
27
|
-
|
28
20
|
puts ''
|
29
21
|
check_sums.each{ |array|
|
30
22
|
be_check_value = array[0]
|
@@ -34,4 +26,4 @@ module PodfileLock
|
|
34
26
|
}
|
35
27
|
end
|
36
28
|
end
|
37
|
-
end
|
29
|
+
end
|
@@ -1,36 +1,28 @@
|
|
1
1
|
require 'pathname'
|
2
|
-
|
3
2
|
module ModifyCode
|
4
3
|
class Modify
|
5
4
|
def self.modify_fb
|
6
|
-
|
7
5
|
self.replace_str("Pods/FBRetainCycleDetector/FBRetainCycleDetector/Layout/Classes/FBClassStrongLayout.mm",
|
8
6
|
"layoutCache[currentClass] = ivars;",
|
9
7
|
"layoutCache[(id<NSCopying>)currentClass] = ivars;")
|
10
8
|
self.replace_str("Pods/FBRetainCycleDetector/fishhook/fishhook.c",
|
11
9
|
"indirect_symbol_bindings[i] = cur->rebindings[j].replacement;",
|
12
10
|
"if(i < (sizeof(indirect_symbol_bindings) /sizeof(indirect_symbol_bindings[0]))) {indirect_symbol_bindings[i]=cur->rebindings[j].replacement;}")
|
13
|
-
|
14
11
|
new_string = "#import <objc/runtime.h>
|
15
12
|
#import <malloc/malloc.h>"
|
16
13
|
self.replace_str("Pods/FBRetainCycleDetector/FBRetainCycleDetector/Graph/FBObjectiveCGraphElement.mm",
|
17
14
|
"#import <objc/runtime.h>",
|
18
15
|
new_string)
|
19
|
-
|
20
16
|
new_string = "malloc_zone_t *zone = malloc_zone_from_ptr((__bridge void *)object); if (zone) { Class aCls=object_getClass(object);"
|
21
17
|
self.replace_str("Pods/FBRetainCycleDetector/FBRetainCycleDetector/Graph/FBObjectiveCGraphElement.mm",
|
22
18
|
"Class aCls = object_getClass(object);",
|
23
19
|
new_string)
|
24
|
-
|
25
20
|
new_string = "}
|
26
21
|
# endif"
|
27
22
|
self.replace_str("Pods/FBRetainCycleDetector/FBRetainCycleDetector/Graph/FBObjectiveCGraphElement.mm",
|
28
23
|
"#endif",
|
29
24
|
new_string)
|
30
|
-
|
31
25
|
end
|
32
|
-
|
33
|
-
# 替换文件内的字符串
|
34
26
|
def self.replace_str(file_path, find, replace)
|
35
27
|
unless File.exist?(file_path)
|
36
28
|
return
|
@@ -47,6 +39,5 @@ module ModifyCode
|
|
47
39
|
puts "代码替换: #{file_name} (#{find} => #{replace_string})"
|
48
40
|
end
|
49
41
|
end
|
50
|
-
|
51
42
|
end
|
52
|
-
end
|
43
|
+
end
|