podfileDep 2.7.7 → 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 +1 -6
- data/lib/{podfileDep → core_blur}/command/quick.rb +1 -8
- data/lib/{podfileDep → core_blur}/dep/find.rb +6 -45
- 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 -178
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49fd966b98cf7165f6f2ad7826470708407a839b8d5ec85aaa13545e3d660759
|
4
|
+
data.tar.gz: a17d98c94b524dbbdb3d8a3d09c98b795219c273f2d8106ec28f5cb52ffbe251
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b956684f3cd3a87f2650b6a160e3387fd9024c41e6a87b85164d90ed0b77adcc4f0702bbd62531ddd212a97d18445b9f9481ae5a81915cfea7c3e14376cd7175
|
7
|
+
data.tar.gz: e78dc8f4a0b61c11e184f539ba6f9def7a76808a48783190170c7db280e625b5aca865e3566b36ac393ded3e5168d60b419a47bc3a2ae28661fb112c9bdb84af
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "podfileDep"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/cocoapods_plugin.rb
CHANGED
@@ -1,14 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'core_helper'
|
4
|
+
core_path = Core::CoreHelper.core_path
|
5
|
+
|
1
6
|
require 'cocoapods'
|
2
|
-
require_relative
|
3
|
-
require_relative
|
4
|
-
require_relative
|
5
|
-
require_relative
|
6
|
-
require_relative
|
7
|
-
require_relative
|
8
|
-
require_relative
|
9
|
-
require_relative
|
10
|
-
require_relative
|
11
|
-
require_relative
|
7
|
+
require_relative "#{core_path}/command/dep"
|
8
|
+
require_relative "#{core_path}/command/all"
|
9
|
+
require_relative "#{core_path}/command/quick"
|
10
|
+
require_relative "#{core_path}/check/project"
|
11
|
+
require_relative "#{core_path}/check/podspec"
|
12
|
+
require_relative "#{core_path}/modify/modify_code"
|
13
|
+
require_relative "#{core_path}/reference/project"
|
14
|
+
require_relative "#{core_path}/indirect/indirect"
|
15
|
+
require_relative "#{core_path}/reference/unused"
|
16
|
+
require_relative "#{core_path}/check/import"
|
12
17
|
|
13
18
|
# 注册插件
|
14
19
|
module CocoapodsPlugin
|
@@ -1,34 +1,23 @@
|
|
1
1
|
require_relative 'project'
|
2
|
-
|
3
2
|
module Xcodeproj
|
4
3
|
class ImportChecker
|
5
|
-
|
6
|
-
# @return [XCodeProject]
|
7
4
|
attr_accessor :project
|
8
|
-
|
9
|
-
# @param project::[XCodeProject]
|
10
5
|
def initialize(project)
|
11
6
|
@project = project
|
12
7
|
end
|
13
|
-
|
14
|
-
# 检查import规范
|
15
8
|
def check_import
|
16
9
|
puts "import检查中..."
|
17
10
|
start = (Time.now.to_f * 1000).to_i
|
18
11
|
module_count = 0
|
19
12
|
file_count = 0
|
20
|
-
|
21
13
|
project.module_items.each do |module_name, module_item|
|
22
14
|
unless module_item.is_development_module
|
23
15
|
next
|
24
16
|
end
|
25
17
|
module_count += 1
|
26
|
-
|
27
18
|
messages = []
|
28
|
-
|
29
19
|
did_check_imports = {}
|
30
20
|
module_item.init_import_info
|
31
|
-
|
32
21
|
module_item.import_items.each do |import_item|
|
33
22
|
file_count += 1
|
34
23
|
did_check_import = did_check_imports[import_item.import_file_name]
|
@@ -39,29 +28,22 @@ module Xcodeproj
|
|
39
28
|
real_path = need_module_item.header_files[import_item.import_file_name]
|
40
29
|
did_check_imports[import_item.import_file_name] = !!(real_path)
|
41
30
|
unless real_path
|
42
|
-
# 去查找所属模块
|
43
31
|
expect_module_name = find_module_with_header_file(import_item.import_file_name)
|
44
32
|
if expect_module_name
|
45
33
|
messages << "#{import_item.file_path.basename} 第#{import_item.line_index}行 #{import_item.import_name} => #import <#{expect_module_name}/#{import_item.import_file_name}>"
|
46
34
|
end
|
47
35
|
end
|
48
36
|
end
|
49
|
-
|
50
37
|
if messages.size >0
|
51
38
|
puts "组件#{module_item.module_name}存在以下情况, 请检查:".yellow
|
52
39
|
puts messages
|
53
40
|
puts "\n"
|
54
41
|
end
|
55
|
-
|
56
42
|
end
|
57
|
-
|
58
43
|
duration = ((Time.now.to_f * 1000).to_i - start)*0.001
|
59
44
|
puts "import检查完毕! 共检查#{module_count}个组件(#{file_count}个import) 耗时:#{duration.round(2)}秒"
|
60
45
|
end
|
61
|
-
|
62
46
|
private
|
63
|
-
# 根据头文件名查找所属组件
|
64
|
-
# @return [String, nil]
|
65
47
|
def find_module_with_header_file(header_file_name)
|
66
48
|
project.module_items.each do |module_name, module_item|
|
67
49
|
file_path = module_item.header_files[header_file_name]
|
@@ -71,6 +53,5 @@ module Xcodeproj
|
|
71
53
|
end
|
72
54
|
nil
|
73
55
|
end
|
74
|
-
|
75
56
|
end
|
76
|
-
end
|
57
|
+
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
module Xcodeproj
|
3
2
|
class ImportItem
|
4
3
|
attr_accessor :import_name
|
@@ -15,39 +14,18 @@ module Xcodeproj
|
|
15
14
|
@line_index = nil
|
16
15
|
@belong_module = nil
|
17
16
|
end
|
18
|
-
|
19
17
|
end
|
20
|
-
|
21
18
|
class ModuleItem
|
22
|
-
|
23
19
|
public
|
24
|
-
# 组名名
|
25
20
|
attr_accessor :module_name
|
26
|
-
|
27
|
-
# 组件路径
|
28
21
|
attr_accessor :module_path
|
29
|
-
|
30
|
-
# podspec路径
|
31
22
|
attr_accessor :podspec_path
|
32
|
-
|
33
|
-
# 组件目录的所有被引用的文件数组
|
34
23
|
attr_accessor :header_files
|
35
|
-
|
36
|
-
# 组件目录的所有被引用的文件数组
|
37
24
|
attr_accessor :source_files
|
38
|
-
|
39
|
-
# 是否是开发模块
|
40
25
|
attr_accessor :is_development_module
|
41
|
-
|
42
|
-
# [ImportItem]
|
43
26
|
attr_accessor :import_items
|
44
|
-
|
45
|
-
# [ImportItem]
|
46
27
|
attr_accessor :absolute_import_items
|
47
|
-
|
48
|
-
# [String]
|
49
28
|
attr_accessor :frameworks
|
50
|
-
|
51
29
|
def initialize(module_name)
|
52
30
|
@module_name = module_name
|
53
31
|
@module_path = nil
|
@@ -59,136 +37,97 @@ module Xcodeproj
|
|
59
37
|
@is_development_module = false
|
60
38
|
@frameworks = []
|
61
39
|
end
|
62
|
-
|
63
|
-
# 生成 import <XX/YY.h>的信息
|
64
|
-
# 生成 include <XX/YY.h>的信息
|
65
40
|
def init_absolute_import_info
|
66
41
|
source_files.each_value do |source_file_path|
|
67
42
|
if File.directory?(source_file_path)
|
68
43
|
next
|
69
44
|
end
|
70
|
-
|
71
45
|
line_array = IO.readlines(source_file_path)
|
72
46
|
line_array.each_with_index { |line, line_index|
|
73
47
|
line = line.gsub(" ", "")
|
74
|
-
|
75
|
-
# 处理特殊情况
|
76
48
|
if line.start_with?("#import\"NBSAppAgent.h\"")
|
77
49
|
line = "#import<tingyunApp/NBSAppAgent.h>"
|
78
50
|
end
|
79
|
-
|
80
51
|
if not line.start_with?("#import<") and not line.start_with?("#include<")
|
81
52
|
next
|
82
53
|
end
|
83
|
-
|
84
54
|
if line.start_with?("@implementation")
|
85
55
|
break
|
86
56
|
end
|
87
|
-
|
88
|
-
# 前一行的内容 这里不是检测,则不需要
|
89
57
|
pre_line = ""
|
90
|
-
|
91
58
|
import_item = other_module_import(line, source_file_path, line_index, @module_name, pre_line)
|
92
59
|
if import_item
|
93
60
|
absolute_import_items << import_item
|
94
61
|
end
|
95
62
|
}
|
96
63
|
end
|
97
|
-
|
98
64
|
absolute_import_items
|
99
65
|
end
|
100
|
-
|
101
|
-
# 生成 import "XXX.h"的信息
|
102
66
|
def init_import_info
|
103
67
|
source_files.each_value do |source_file_path|
|
104
68
|
if File.directory?(source_file_path)
|
105
69
|
next
|
106
70
|
end
|
107
|
-
|
108
71
|
line_array = IO.readlines(source_file_path)
|
109
72
|
line_array.each_with_index { |line, line_index|
|
110
73
|
line = line.gsub(" ", "")
|
111
|
-
|
112
74
|
unless line.start_with?("#import")
|
113
75
|
next
|
114
76
|
end
|
115
|
-
|
116
77
|
if line.start_with?("@implementation")
|
117
78
|
break
|
118
79
|
end
|
119
|
-
|
120
|
-
# 前一行的内容
|
121
80
|
pre_index = line_index-1 < 0 ? 0 : line_index-1
|
122
81
|
pre_line = line_array[pre_index]
|
123
|
-
|
124
82
|
if line.start_with?("#import\"") #本组件
|
125
83
|
import_item = own_module_import(line, source_file_path, line_index, @module_name, pre_line)
|
126
84
|
if import_item
|
127
85
|
import_items << import_item
|
128
86
|
end
|
129
87
|
elsif line.start_with?("#import<") #其他组件
|
130
|
-
|
131
88
|
end
|
132
|
-
|
133
89
|
}
|
134
90
|
end
|
135
|
-
|
136
91
|
import_items
|
137
92
|
end
|
138
|
-
|
139
93
|
private
|
140
|
-
# 生成自己模块的import item
|
141
|
-
# @param line 以 import" 开头
|
142
94
|
def own_module_import(line, file_path, line_index, module_name, pre_line)
|
143
95
|
line_split_array = line.split("\"")
|
144
96
|
if line_split_array.size <= 1
|
145
97
|
return nil
|
146
98
|
end
|
147
|
-
|
148
99
|
import_content = "#{line_split_array[0]}\"#{line_split_array[1]}\"" # import"XXX.h" 或import"XXX.AAA.h" 防止后边有其他内容
|
149
|
-
|
150
|
-
# 特殊处理
|
151
100
|
if import_content == "#import\"NBSAppAgent.h\""
|
152
101
|
return nil
|
153
102
|
end
|
154
|
-
|
155
103
|
pre_line = pre_line.gsub(" ", "").gsub("\n", "")
|
156
104
|
if pre_line.start_with?("#if") or pre_line == "#else"
|
157
105
|
return nil
|
158
106
|
end
|
159
|
-
|
160
107
|
import_file_name = import_content
|
161
108
|
import_file_name = import_file_name.gsub("#import\"", "")
|
162
109
|
import_file_name = import_file_name.gsub("\"", "") # 变成 XX.h
|
163
|
-
|
164
|
-
|
165
110
|
import_item = ImportItem.new # (import_name, module_name, file_name, line_index, podfile)
|
166
111
|
import_item.import_name = import_content.gsub("#import\"", "#import \"")
|
167
112
|
import_item.module_name = module_name
|
168
113
|
import_item.file_path = file_path
|
169
114
|
import_item.import_file_name = import_file_name
|
170
115
|
import_item.line_index = line_index + 1
|
171
|
-
|
172
116
|
import_item
|
173
117
|
end
|
174
|
-
|
175
|
-
|
176
118
|
def other_module_import(line, file_path, line_index, module_name, pre_line)
|
177
119
|
line = line.gsub("\n","")
|
178
120
|
line_split_array = line.split("/") #import<XX/YY.h> 或 #import<XX/YY/ZZ.h>
|
179
121
|
if line_split_array.size <= 1
|
180
122
|
return nil
|
181
123
|
end
|
182
|
-
|
183
124
|
pre_line = pre_line.gsub(" ", "").gsub("\n", "")
|
184
125
|
if pre_line.start_with?("#if") or pre_line == "#else"
|
185
126
|
return nil
|
186
127
|
end
|
187
|
-
|
188
128
|
import_file_name = line_split_array[line_split_array.size-1].gsub(">", "")
|
189
129
|
belong_module = line_split_array[0].gsub("#import<", "").gsub("#include<", "")
|
190
130
|
import_name = line.gsub("#import<", "#import <").gsub("#include<", "#include <")
|
191
|
-
|
192
131
|
import_item = ImportItem.new # (import_name, module_name, file_name, line_index, podfile)
|
193
132
|
import_item.import_name = import_name
|
194
133
|
import_item.module_name = module_name
|
@@ -196,9 +135,7 @@ module Xcodeproj
|
|
196
135
|
import_item.import_file_name = import_file_name
|
197
136
|
import_item.line_index = line_index + 1
|
198
137
|
import_item.belong_module = belong_module
|
199
|
-
|
200
138
|
import_item
|
201
|
-
|
202
139
|
end
|
203
140
|
end
|
204
|
-
end
|
141
|
+
end
|
@@ -1,30 +1,20 @@
|
|
1
1
|
require_relative 'project'
|
2
2
|
require_relative 'util'
|
3
3
|
require_relative '../my_constants'
|
4
|
-
|
5
4
|
module Xcodeproj
|
6
5
|
class PodspecChecker
|
7
|
-
|
8
|
-
# @return [XCodeProject]
|
9
6
|
attr_accessor :project
|
10
|
-
|
11
|
-
# @param project::[XCodeProject]
|
12
7
|
def initialize(project)
|
13
8
|
@project = project
|
14
9
|
end
|
15
|
-
|
16
|
-
# 检查podspec文件
|
17
10
|
def check_podspec
|
18
|
-
|
19
11
|
yaml_dep = Pod::YamlDep.new
|
20
12
|
if yaml_dep.disable_check_podspec
|
21
13
|
return
|
22
14
|
end
|
23
|
-
|
24
15
|
puts "podspec文件检查中..."
|
25
16
|
start = (Time.now.to_f * 1000).to_i
|
26
17
|
module_count = 0
|
27
|
-
|
28
18
|
project.module_items.each do |module_name, module_item|
|
29
19
|
unless module_item.is_development_module
|
30
20
|
next
|
@@ -33,65 +23,43 @@ module Xcodeproj
|
|
33
23
|
next
|
34
24
|
end
|
35
25
|
module_count += 1
|
36
|
-
|
37
26
|
module_item.init_absolute_import_info
|
38
|
-
|
39
|
-
# 代码里需要的模块
|
40
27
|
need_modules = get_code_need_modules(module_item)
|
41
|
-
|
42
|
-
# podspec直接依赖
|
43
28
|
podspec_modules = get_podspec_modules(module_item)
|
44
|
-
|
45
29
|
loss = loss_modules(need_modules, podspec_modules)
|
46
30
|
unused = unused_modules(need_modules, podspec_modules, module_item)
|
47
|
-
|
48
31
|
if loss.size >0
|
49
32
|
puts "组件#{module_item.module_name}可能缺少以下依赖(#{loss.size}个), 请检查:".yellow
|
50
33
|
loss.sort.each do |name|
|
51
34
|
puts " s.dependency '#{name}'"
|
52
35
|
end
|
53
36
|
end
|
54
|
-
|
55
37
|
if unused.size >0
|
56
38
|
puts "组件#{module_item.module_name}可能未使用以下依赖(#{unused.size}个), 请检查:".yellow
|
57
39
|
puts unused.sort
|
58
40
|
end
|
59
|
-
|
60
41
|
end
|
61
|
-
|
62
42
|
duration = ((Time.now.to_f * 1000).to_i - start)*0.001
|
63
43
|
puts "podspec检查完毕! 共检查#{module_count}个组件 耗时:#{duration.round(2)}秒"
|
64
44
|
end
|
65
|
-
|
66
45
|
private
|
67
|
-
|
68
|
-
# 获取缺失的模块
|
69
|
-
# @param need_modules::[String]
|
70
|
-
# @param podspec_modules::[Hash{String => [String]}]
|
71
46
|
def loss_modules(need_modules, podspec_modules)
|
72
|
-
# 展开
|
73
47
|
temp_array = []
|
74
48
|
podspec_modules.each do |podspec_module|
|
75
49
|
podspec_modules.values.each do |array|
|
76
50
|
temp_array = temp_array | array
|
77
51
|
end
|
78
52
|
end
|
79
|
-
|
80
53
|
res = []
|
81
54
|
need_modules.each do |name|
|
82
55
|
unless temp_array.include?(name)
|
83
56
|
if module_is_installed(name)
|
84
57
|
res << name
|
85
58
|
end
|
86
|
-
|
87
59
|
end
|
88
60
|
end
|
89
61
|
res
|
90
62
|
end
|
91
|
-
|
92
|
-
# 获取多余的模块
|
93
|
-
# @param need_modules::[String]
|
94
|
-
# @param podspec_modules::[Hash{String => [String]}]
|
95
63
|
def unused_modules(need_modules, podspec_modules, module_item)
|
96
64
|
res = []
|
97
65
|
podspec_modules.each do |dep_name, array|
|
@@ -101,43 +69,29 @@ module Xcodeproj
|
|
101
69
|
contain = true
|
102
70
|
end
|
103
71
|
end
|
104
|
-
|
105
72
|
if not contain and module_item.module_name != dep_name
|
106
73
|
res << dep_name
|
107
74
|
end
|
108
75
|
end
|
109
76
|
res
|
110
77
|
end
|
111
|
-
|
112
|
-
# @note 获取代码里需要的模块
|
113
78
|
def get_code_need_modules(module_item)
|
114
79
|
import_items = module_item.absolute_import_items
|
115
80
|
result_dic = {}
|
116
81
|
import_items.each do |import_item|
|
117
|
-
# 过滤系统库
|
118
82
|
if system_modules.include?(import_item.belong_module)
|
119
83
|
next
|
120
84
|
end
|
121
|
-
|
122
|
-
# 过滤当前库
|
123
85
|
if module_item.module_name == import_item.belong_module
|
124
86
|
next
|
125
87
|
end
|
126
|
-
|
127
88
|
result_dic[import_item.belong_module] = import_item
|
128
89
|
end
|
129
90
|
result_dic.keys
|
130
91
|
end
|
131
|
-
|
132
|
-
# 获取podspec文件里写的模块 直接依赖
|
133
|
-
# @return [Hash{String => [String]}]
|
134
92
|
def get_podspec_modules(module_item)
|
135
|
-
|
136
93
|
podspec_content = Util.get_podspec_content(module_item.podspec_path)
|
137
|
-
|
138
94
|
podspec_dependencies = podspec_content["dependencies"] ? podspec_content["dependencies"].keys : []
|
139
|
-
|
140
|
-
# 子模块
|
141
95
|
subspecs = podspec_content["subspecs"]
|
142
96
|
if subspecs and subspecs.class == Array
|
143
97
|
subspecs.each do |subspec|
|
@@ -145,8 +99,6 @@ module Xcodeproj
|
|
145
99
|
podspec_dependencies = podspec_dependencies + subspec_deps
|
146
100
|
end
|
147
101
|
end
|
148
|
-
|
149
|
-
# 转成map
|
150
102
|
result = {}
|
151
103
|
podspec_dependencies.each do |podspec_dependency|
|
152
104
|
podspec_dependency = podspec_dependency.split("/")[0] #如果podspec里写的依赖是带/的,取/前第一个, 例如:s.dependency 'UMCShare/Social/ReducedQQ'
|
@@ -161,11 +113,8 @@ module Xcodeproj
|
|
161
113
|
result[podspec_dependency] = frameworks
|
162
114
|
end
|
163
115
|
end
|
164
|
-
|
165
116
|
result
|
166
117
|
end
|
167
|
-
|
168
|
-
# 判断某个库是否被安装
|
169
118
|
def module_is_installed(module_name)
|
170
119
|
all = project.lock_content["DEPENDENCIES"]
|
171
120
|
unless all
|
@@ -176,10 +125,8 @@ module Xcodeproj
|
|
176
125
|
end
|
177
126
|
all.include?(module_name)
|
178
127
|
end
|
179
|
-
# 系统级的依赖库
|
180
|
-
# @return [String]
|
181
128
|
def system_modules
|
182
129
|
MyConstants::LIBLIBARYS + MyConstants::FRAMEWORKS
|
183
130
|
end
|
184
131
|
end
|
185
|
-
end
|
132
|
+
end
|