podfileDep 2.3.2 → 2.3.4
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/CHANGELOG.md +9 -2
- data/lib/cocoapods_plugin.rb +8 -2
- data/lib/podfileDep/check/import.rb +159 -159
- data/lib/podfileDep/check/project.rb +332 -0
- data/lib/podfileDep/version.rb +1 -1
- data/lib/podfileDep/yaml/yaml_dep.rb +45 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d0616ba675d61a7cb9f12f36c98e0b313c8f87e3ba17ded2f7dbcfde9265af4
|
4
|
+
data.tar.gz: df8fe42f9b709d4c31405b97ce26b4b7f2ae82f794cf58ceb4e0095b83fda21b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99ccba32f897f779b649f1c9c61377ecd882907f64cb05da41e10a80df074dae579904d49e1730e4ec18a1e81fa0fd79c88a2c380a6bf7c9fbda709d0ede0bdf
|
7
|
+
data.tar.gz: 5059a3d938a77b8bb479500c842ec903cabd6659a51b5b0d47cb0ea04e3e3be4dda89a46c88b21986245b1e275e4a2b42ee1804cc61a3e40f4f6af9ca4ad9ed8
|
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,18 @@
|
|
1
1
|
## [Released]
|
2
2
|
|
3
|
+
### [2.3.4] - 2023-7-24
|
4
|
+
- pod依赖打印排序
|
5
|
+
- pod依赖打印路径依赖时增加打印分支名
|
6
|
+
|
7
|
+
### [2.3.3] - 2023-7-24
|
8
|
+
- import规范检查逻辑优化
|
9
|
+
|
3
10
|
### [2.3.2] - 2023-7-6
|
4
11
|
- 修复编译优化引用计数导致的优化不彻底问题
|
5
|
-
|
12
|
+
|
6
13
|
### [2.3.1] - 2023-7-6
|
7
14
|
- 打印版本号
|
8
|
-
|
15
|
+
|
9
16
|
### [2.3.0] - 2023-7-6
|
10
17
|
- 去掉use_frameworks! 由外部自由实现
|
11
18
|
|
data/lib/cocoapods_plugin.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'cocoapods'
|
2
2
|
require_relative 'podfileDep/command/quick'
|
3
|
+
require_relative 'podfileDep/check/project'
|
3
4
|
require_relative 'podfileDep/check/dep'
|
4
|
-
require_relative 'podfileDep/check/import'
|
5
5
|
require_relative 'podfileDep/modify/modify_code'
|
6
6
|
require_relative 'podfileDep/reference/project'
|
7
7
|
require_relative 'podfileDep/indirect/indirect'
|
@@ -29,8 +29,10 @@ module CocoapodsPlugin
|
|
29
29
|
# 检查依赖库
|
30
30
|
# Dep::DepChecker.dep_check
|
31
31
|
|
32
|
+
project = Xcodeproj::XCodeProject.new
|
33
|
+
|
32
34
|
# 检查import
|
33
|
-
|
35
|
+
project.check_import
|
34
36
|
|
35
37
|
# 代码文件处理
|
36
38
|
ModifyCode::Modify.modify_fb
|
@@ -49,4 +51,8 @@ module CocoapodsPlugin
|
|
49
51
|
|
50
52
|
end
|
51
53
|
|
54
|
+
# Pod::HooksManager.register('podfileDep', :post_integrate) do |context|
|
55
|
+
# puts context
|
56
|
+
# end
|
57
|
+
|
52
58
|
end
|
@@ -1,159 +1,159 @@
|
|
1
|
-
require 'pathname'
|
2
|
-
require 'yaml'
|
3
|
-
require_relative '../constants'
|
4
|
-
require_relative 'module'
|
5
|
-
require_relative 'item'
|
6
|
-
require_relative 'xcodeproj'
|
7
|
-
|
8
|
-
module Import
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
end
|
1
|
+
# require 'pathname'
|
2
|
+
# require 'yaml'
|
3
|
+
# require_relative '../constants'
|
4
|
+
# require_relative 'module'
|
5
|
+
# require_relative 'item'
|
6
|
+
# require_relative 'xcodeproj'
|
7
|
+
#
|
8
|
+
# module Import
|
9
|
+
# class ImportManager
|
10
|
+
#
|
11
|
+
# # 检查import规范
|
12
|
+
# def self.import_check
|
13
|
+
# puts "\nimport规范检查中..."
|
14
|
+
# start = (Time.now.to_f * 1000).to_i
|
15
|
+
#
|
16
|
+
# project_manager = XCProject::XcodeprojManager.share_manager
|
17
|
+
#
|
18
|
+
# # 获取需要检查的模块名和路径
|
19
|
+
# modules = project_manager.get_development_module
|
20
|
+
#
|
21
|
+
# # 获取Pods和本地依赖库的 组件名和包含的头文件列表 map类型
|
22
|
+
# module_headers = project_manager.get_installed_headers_module
|
23
|
+
#
|
24
|
+
# # 计数
|
25
|
+
# check_count = 0
|
26
|
+
#
|
27
|
+
# # 遍历需要被检查的模块
|
28
|
+
# modules.each_value { |module_item|
|
29
|
+
#
|
30
|
+
# # 某个模块从代码文件里读取的双引号依赖库 #import "XX/XX.h"
|
31
|
+
# import_item_map = {}
|
32
|
+
#
|
33
|
+
# #头文件的文件名
|
34
|
+
# header_file_names = []
|
35
|
+
#
|
36
|
+
# module_item.source_files.each { |source_file|
|
37
|
+
#
|
38
|
+
# header_file_name = File.basename(source_file)
|
39
|
+
# if header_file_name.end_with?(".h") or header_file_name.end_with?(".hpp") or header_file_name.end_with?(".pch")
|
40
|
+
# header_file_names << header_file_name
|
41
|
+
# end
|
42
|
+
#
|
43
|
+
# self.update_import_dot_item_map(source_file, module_item, import_item_map)
|
44
|
+
#
|
45
|
+
# check_count += 1
|
46
|
+
# }
|
47
|
+
#
|
48
|
+
# if import_item_map.size == 0 and header_file_names.size == 0
|
49
|
+
# next
|
50
|
+
# end
|
51
|
+
#
|
52
|
+
# messages = []
|
53
|
+
# import_item_map.each {|key, value| #key是 xxx.h value是{ImportItem:}
|
54
|
+
#
|
55
|
+
# # 当前仓库的文件已包含
|
56
|
+
# if header_file_names.include?(key)
|
57
|
+
# next
|
58
|
+
# end
|
59
|
+
#
|
60
|
+
# # 是否是导入的系统lib
|
61
|
+
# if self.check_sys_libary(key)
|
62
|
+
# next
|
63
|
+
# end
|
64
|
+
#
|
65
|
+
# search_module_name = self.get_module_name(module_headers, key)
|
66
|
+
#
|
67
|
+
# unless search_module_name
|
68
|
+
# next
|
69
|
+
# end
|
70
|
+
#
|
71
|
+
# messages << "#{value.file_name} 第#{value.line_index}行 #{value.import_name} => #import <#{search_module_name}/#{value.pod}>"
|
72
|
+
#
|
73
|
+
# }
|
74
|
+
#
|
75
|
+
# if messages.size >0
|
76
|
+
# puts "⚠️ 组件#{module_item.module_name}存在以下情况, 请检查:"
|
77
|
+
# puts messages
|
78
|
+
# puts "\n"
|
79
|
+
# end
|
80
|
+
#
|
81
|
+
# }
|
82
|
+
#
|
83
|
+
# duration = ((Time.now.to_f * 1000).to_i - start)*0.001
|
84
|
+
# puts "import规范检查完毕! 共检查#{modules.size.to_s}个组件(#{check_count}个文件) 耗时:#{duration.round(2)}秒"
|
85
|
+
# end
|
86
|
+
#
|
87
|
+
# # 获取某个文件内对应类型的import "XXX.h"
|
88
|
+
# def self.update_import_dot_item_map(file_path, module_name, import_item_map)
|
89
|
+
# if File.directory?(file_path)
|
90
|
+
# return
|
91
|
+
# end
|
92
|
+
#
|
93
|
+
# line_array = IO.readlines(file_path)
|
94
|
+
# line_array.each_with_index { |line, index|
|
95
|
+
# line = line.gsub(" ", "")
|
96
|
+
# unless line.start_with?("#import\"")
|
97
|
+
# next
|
98
|
+
# end
|
99
|
+
#
|
100
|
+
# if line.start_with?("@implementation")
|
101
|
+
# break
|
102
|
+
# end
|
103
|
+
#
|
104
|
+
# line_split_array = line.split("\"")
|
105
|
+
# if line_split_array.size <= 1
|
106
|
+
# next
|
107
|
+
# end
|
108
|
+
#
|
109
|
+
# import_name = "#{line_split_array[0]}\"#{line_split_array[1]}\"" # import"XXX.h" 或import"XXX.AAA.h" 防止后边有其他内容
|
110
|
+
#
|
111
|
+
# # 特殊处理
|
112
|
+
# if import_name == "#import\"NBSAppAgent.h\""
|
113
|
+
# next
|
114
|
+
# end
|
115
|
+
#
|
116
|
+
# podfile = import_name
|
117
|
+
# podfile = podfile.gsub("#import\"", "")
|
118
|
+
# podfile = podfile.gsub("\"", "") # 变成 XX.h
|
119
|
+
#
|
120
|
+
# # 已经包含
|
121
|
+
# if import_item_map[podfile]
|
122
|
+
# next
|
123
|
+
# end
|
124
|
+
# pre_index = index-1 < 0 ? 0 : index-1
|
125
|
+
# pre_line = line_array[pre_index]
|
126
|
+
# pre_line = pre_line.gsub(" ", "").gsub("\n", "")
|
127
|
+
# if pre_line.start_with?("#if") or pre_line == "#else"
|
128
|
+
# next
|
129
|
+
# end
|
130
|
+
#
|
131
|
+
# file_name = File.basename(file_path)
|
132
|
+
# line_index = index+1
|
133
|
+
#
|
134
|
+
# import_item_map[podfile] = ImportItem.new(import_name, module_name, file_name, line_index, podfile)
|
135
|
+
#
|
136
|
+
# }
|
137
|
+
# end
|
138
|
+
#
|
139
|
+
# # 根据文件名反查出属于哪个组件
|
140
|
+
# def self.get_module_name(module_headers, file_name)
|
141
|
+
# module_headers.each do |module_name,module_item|
|
142
|
+
# module_item.source_files.each {|source_file|
|
143
|
+
# if source_file.basename.to_s == file_name
|
144
|
+
# return module_name
|
145
|
+
# end
|
146
|
+
# }
|
147
|
+
# end
|
148
|
+
# return nil
|
149
|
+
# end
|
150
|
+
#
|
151
|
+
# # 获取某库是否是系统级的依赖库
|
152
|
+
# def self.check_sys_libary(name)
|
153
|
+
# name = name.gsub(".h", "")
|
154
|
+
# libs = Constants::LIBLIBARYS
|
155
|
+
# return libs.include?(name)
|
156
|
+
# end
|
157
|
+
#
|
158
|
+
# end
|
159
|
+
# end
|
@@ -0,0 +1,332 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'colored2'
|
3
|
+
|
4
|
+
module Xcodeproj
|
5
|
+
|
6
|
+
class ImportItem
|
7
|
+
attr_accessor :import_name
|
8
|
+
attr_accessor :module_name
|
9
|
+
attr_accessor :file_path
|
10
|
+
attr_accessor :import_file_name
|
11
|
+
attr_accessor :line_index
|
12
|
+
def initialize
|
13
|
+
@import_name = nil
|
14
|
+
@module_name = nil
|
15
|
+
@file_path = nil
|
16
|
+
@import_file_name = nil
|
17
|
+
@line_index = nil
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
class ModuleItem
|
23
|
+
|
24
|
+
public
|
25
|
+
# 组名名
|
26
|
+
attr_accessor :module_name
|
27
|
+
|
28
|
+
# 组件路径
|
29
|
+
attr_accessor :module_path
|
30
|
+
|
31
|
+
# podspec路径
|
32
|
+
attr_accessor :podspec_path
|
33
|
+
|
34
|
+
# 组件目录的所有被引用的文件数组
|
35
|
+
attr_accessor :header_files
|
36
|
+
|
37
|
+
# 组件目录的所有被引用的文件数组
|
38
|
+
attr_accessor :source_files
|
39
|
+
|
40
|
+
# 是否是开发模块
|
41
|
+
attr_reader :is_development_module
|
42
|
+
|
43
|
+
# [Hash{String => ImportItem}]
|
44
|
+
attr_accessor :import_items
|
45
|
+
|
46
|
+
def initialize(module_name)
|
47
|
+
@module_name = module_name
|
48
|
+
@module_path = nil
|
49
|
+
@podspec_path = nil
|
50
|
+
@header_files = {}
|
51
|
+
@source_files = {}
|
52
|
+
@import_items = []
|
53
|
+
end
|
54
|
+
|
55
|
+
# 是否是开发模块
|
56
|
+
# @return bool
|
57
|
+
def is_development_module
|
58
|
+
!!(podspec_path)
|
59
|
+
end
|
60
|
+
|
61
|
+
# 生成 import "XXX.h"的信息
|
62
|
+
def init_import_info
|
63
|
+
source_files.each_value do |source_file_path|
|
64
|
+
if File.directory?(source_file_path)
|
65
|
+
next
|
66
|
+
end
|
67
|
+
|
68
|
+
line_array = IO.readlines(source_file_path)
|
69
|
+
line_array.each_with_index { |line, line_index|
|
70
|
+
line = line.gsub(" ", "")
|
71
|
+
|
72
|
+
unless line.start_with?("#import")
|
73
|
+
next
|
74
|
+
end
|
75
|
+
|
76
|
+
if line.start_with?("@implementation")
|
77
|
+
break
|
78
|
+
end
|
79
|
+
|
80
|
+
# 前一行的内容
|
81
|
+
pre_index = line_index-1 < 0 ? 0 : line_index-1
|
82
|
+
pre_line = line_array[pre_index]
|
83
|
+
|
84
|
+
if line.start_with?("#import\"") #本组件
|
85
|
+
import_item = own_module_import(line, source_file_path, line_index, @module_name, pre_line)
|
86
|
+
if import_item
|
87
|
+
import_items << import_item
|
88
|
+
end
|
89
|
+
elsif line.start_with?("#import<") #其他组件
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
}
|
94
|
+
end
|
95
|
+
|
96
|
+
import_items
|
97
|
+
end
|
98
|
+
|
99
|
+
private
|
100
|
+
# 生成自己模块的import item
|
101
|
+
# @param line 以 import" 开头
|
102
|
+
def own_module_import(line, file_path, line_index, module_name, pre_line)
|
103
|
+
line_split_array = line.split("\"")
|
104
|
+
if line_split_array.size <= 1
|
105
|
+
return nil
|
106
|
+
end
|
107
|
+
|
108
|
+
import_content = "#{line_split_array[0]}\"#{line_split_array[1]}\"" # import"XXX.h" 或import"XXX.AAA.h" 防止后边有其他内容
|
109
|
+
|
110
|
+
# 特殊处理
|
111
|
+
if import_content == "#import\"NBSAppAgent.h\""
|
112
|
+
return nil
|
113
|
+
end
|
114
|
+
|
115
|
+
pre_line = pre_line.gsub(" ", "").gsub("\n", "")
|
116
|
+
if pre_line.start_with?("#if") or pre_line == "#else"
|
117
|
+
return nil
|
118
|
+
end
|
119
|
+
|
120
|
+
import_file_name = import_content
|
121
|
+
import_file_name = import_file_name.gsub("#import\"", "")
|
122
|
+
import_file_name = import_file_name.gsub("\"", "") # 变成 XX.h
|
123
|
+
|
124
|
+
|
125
|
+
import_item = ImportItem.new # (import_name, module_name, file_name, line_index, podfile)
|
126
|
+
import_item.import_name = import_content.gsub("#import\"", "#import \"")
|
127
|
+
import_item.module_name = module_name
|
128
|
+
import_item.file_path = file_path
|
129
|
+
import_item.import_file_name = import_file_name
|
130
|
+
import_item.line_index = line_index + 1
|
131
|
+
|
132
|
+
import_item
|
133
|
+
end
|
134
|
+
|
135
|
+
|
136
|
+
def other_module_import(line)
|
137
|
+
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
class XCodeProject
|
142
|
+
|
143
|
+
# 壳工程xcodeproj对象
|
144
|
+
# @return Xcodeproj::Project
|
145
|
+
attr_accessor :shell_project
|
146
|
+
|
147
|
+
# Pods工程xcodeproj对象
|
148
|
+
# @return Xcodeproj::Project
|
149
|
+
attr_accessor :pod_project
|
150
|
+
|
151
|
+
# @return [Hash{String => ModuleItem}]
|
152
|
+
attr_accessor :module_items
|
153
|
+
|
154
|
+
|
155
|
+
def initialize
|
156
|
+
@shell_project = nil
|
157
|
+
@pod_project = nil
|
158
|
+
@module_items = {}
|
159
|
+
init_shell_project
|
160
|
+
init_pod_project
|
161
|
+
expand_module
|
162
|
+
end
|
163
|
+
|
164
|
+
def init_shell_project
|
165
|
+
xcodeproj_file = nil
|
166
|
+
Dir.foreach(Dir.pwd) do |file|
|
167
|
+
if file.end_with?(".xcodeproj")
|
168
|
+
xcodeproj_file = file
|
169
|
+
break
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
xcodeproj_path = "#{Dir.pwd}/#{xcodeproj_file}"
|
174
|
+
unless File.exist?(xcodeproj_path)
|
175
|
+
return nil
|
176
|
+
end
|
177
|
+
|
178
|
+
@shell_project = Xcodeproj::Project.open(xcodeproj_path)
|
179
|
+
end
|
180
|
+
|
181
|
+
def init_pod_project
|
182
|
+
xcodeproj_path = "#{Dir.pwd}/Pods/Pods.xcodeproj"
|
183
|
+
unless File.exist?(xcodeproj_path)
|
184
|
+
return nil
|
185
|
+
end
|
186
|
+
|
187
|
+
@pod_project = Xcodeproj::Project.open(xcodeproj_path)
|
188
|
+
end
|
189
|
+
|
190
|
+
# 展开模块
|
191
|
+
def expand_module
|
192
|
+
self.expand_with_module(pod_project.main_group, nil)
|
193
|
+
end
|
194
|
+
|
195
|
+
# 展开模块
|
196
|
+
def expand_with_module(group, module_name)
|
197
|
+
|
198
|
+
if group.class != Xcodeproj::Project::Object::PBXGroup
|
199
|
+
return
|
200
|
+
end
|
201
|
+
|
202
|
+
if not module_name and group.hierarchy_path
|
203
|
+
group_hierarchy_path_array = group.hierarchy_path.split("/")
|
204
|
+
module_name = group_hierarchy_path_array.size >= 3 ? group_hierarchy_path_array[2] : nil
|
205
|
+
end
|
206
|
+
|
207
|
+
# 创建 source_file_item
|
208
|
+
source_file_item = @module_items[module_name]
|
209
|
+
if module_name and not source_file_item
|
210
|
+
source_file_item = ModuleItem.new(module_name)
|
211
|
+
@module_items[module_name] = source_file_item
|
212
|
+
end
|
213
|
+
|
214
|
+
# 更新module_path
|
215
|
+
if source_file_item and not source_file_item.module_path and group.hierarchy_path
|
216
|
+
group_hierarchy_path_array = group.hierarchy_path.split("/")
|
217
|
+
if group_hierarchy_path_array.size == 3
|
218
|
+
source_file_item.module_path = group.real_path
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
# 文件引用
|
223
|
+
file_reference_class = Xcodeproj::Project::Object::PBXFileReference
|
224
|
+
|
225
|
+
not_child_names = ["Podfile","Frameworks", "Products","Targets Support Files","Support Files"]
|
226
|
+
source_file_extension = %w[.h .m .mm .pch .c .cc .cpp .hpp]
|
227
|
+
header_file_extension = %w[.h .hpp]
|
228
|
+
|
229
|
+
group.children.each {|child|
|
230
|
+
|
231
|
+
module_name = source_file_item ? source_file_item.module_name : nil
|
232
|
+
|
233
|
+
if not_child_names.include?(child.name)
|
234
|
+
# puts "不检查:#{child.name} #{child.real_path}"
|
235
|
+
next
|
236
|
+
end
|
237
|
+
|
238
|
+
if child.class != file_reference_class
|
239
|
+
# puts "不是文件引用:#{child.class} #{child.real_path}"
|
240
|
+
self.expand_with_module(child, module_name)
|
241
|
+
next
|
242
|
+
end
|
243
|
+
|
244
|
+
hierarchy_path_array = child.hierarchy_path.split("/")
|
245
|
+
if hierarchy_path_array.size < 3
|
246
|
+
self.expand_with_module(child, module_name)
|
247
|
+
next
|
248
|
+
end
|
249
|
+
|
250
|
+
if source_file_item
|
251
|
+
extend_name = child.real_path.basename.extname
|
252
|
+
if extend_name == ".podspec" or extend_name == ".podspec.json"
|
253
|
+
source_file_item.podspec_path = child.real_path
|
254
|
+
elsif source_file_extension.include?(extend_name)
|
255
|
+
source_file_item.source_files[child.real_path.basename.to_s] = child.real_path
|
256
|
+
if header_file_extension.include?(extend_name)
|
257
|
+
source_file_item.header_files[child.real_path.basename.to_s] = child.real_path
|
258
|
+
end
|
259
|
+
else
|
260
|
+
# puts child.real_path
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
# 递归展开
|
265
|
+
self.expand_with_module(child, module_name)
|
266
|
+
}
|
267
|
+
|
268
|
+
end
|
269
|
+
|
270
|
+
# 检查import规范
|
271
|
+
def check_import
|
272
|
+
puts "import检查中..."
|
273
|
+
start = (Time.now.to_f * 1000).to_i
|
274
|
+
module_count = 0
|
275
|
+
file_count = 0
|
276
|
+
|
277
|
+
module_items.each do |module_name, module_item|
|
278
|
+
unless module_item.is_development_module
|
279
|
+
next
|
280
|
+
end
|
281
|
+
module_count += 1
|
282
|
+
|
283
|
+
messages = []
|
284
|
+
|
285
|
+
did_check_imports = {}
|
286
|
+
module_item.init_import_info
|
287
|
+
|
288
|
+
module_item.import_items.each do |import_item|
|
289
|
+
file_count += 1
|
290
|
+
did_check_import = did_check_imports[import_item.import_file_name]
|
291
|
+
if did_check_import
|
292
|
+
next
|
293
|
+
end
|
294
|
+
need_module_item = module_items[import_item.module_name]
|
295
|
+
real_path = need_module_item.header_files[import_item.import_file_name]
|
296
|
+
did_check_imports[import_item.import_file_name] = !!(real_path)
|
297
|
+
unless real_path
|
298
|
+
# 去查找所属模块
|
299
|
+
expect_module_name = find_module_with_header_file(import_item.import_file_name)
|
300
|
+
if expect_module_name
|
301
|
+
messages << "#{import_item.file_path.basename} 第#{import_item.line_index}行 #{import_item.import_name} => #import <#{expect_module_name}/#{import_item.import_file_name}>"
|
302
|
+
end
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
if messages.size >0
|
307
|
+
puts "组件#{module_item.module_name}存在以下情况, 请检查:".yellow
|
308
|
+
puts messages
|
309
|
+
puts "\n"
|
310
|
+
end
|
311
|
+
|
312
|
+
end
|
313
|
+
|
314
|
+
duration = ((Time.now.to_f * 1000).to_i - start)*0.001
|
315
|
+
puts "import检查完毕! 共检查#{module_count}个组件(#{file_count}个import) 耗时:#{duration.round(2)}秒"
|
316
|
+
end
|
317
|
+
|
318
|
+
private
|
319
|
+
# 根据头文件名查找所属组件
|
320
|
+
# @return [String, nil]
|
321
|
+
def find_module_with_header_file(header_file_name)
|
322
|
+
module_items.each do |module_name, module_item|
|
323
|
+
file_path = module_item.header_files[header_file_name]
|
324
|
+
if file_path
|
325
|
+
return module_item.module_name
|
326
|
+
end
|
327
|
+
end
|
328
|
+
nil
|
329
|
+
end
|
330
|
+
|
331
|
+
end
|
332
|
+
end
|
data/lib/podfileDep/version.rb
CHANGED
@@ -333,12 +333,26 @@ module Pod
|
|
333
333
|
end
|
334
334
|
puts "➡️ 解析后依赖总数共计:#{all_deps.size}个\n"
|
335
335
|
|
336
|
+
sort_deps = all_deps.sort do |arr1, arr2|
|
337
|
+
dep1 = arr1[1]
|
338
|
+
dep2 = arr2[1]
|
339
|
+
if dep1.path and not dep2.path
|
340
|
+
1
|
341
|
+
elsif not dep1.path and dep2.path
|
342
|
+
-1
|
343
|
+
else
|
344
|
+
dep1.pod.downcase <=> dep2.pod.downcase
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
336
348
|
puts '⬇️ 打印依赖'
|
337
|
-
|
349
|
+
sort_deps.each { |sort_dep|
|
350
|
+
dependency = sort_dep[1]
|
338
351
|
puts_result = "pod '#{dependency.pod}'"
|
339
352
|
|
340
353
|
if dependency.path #路径引用
|
341
|
-
|
354
|
+
branch = repo_branch(dependency.path)
|
355
|
+
puts_result += ", :path => '#{dependency.path}'#{branch}"
|
342
356
|
elsif dependency.podspec #podspec引用
|
343
357
|
puts_result += ", :podspec => '#{dependency.podspec}'"
|
344
358
|
elsif dependency.version #版本号引用
|
@@ -457,6 +471,35 @@ module Pod
|
|
457
471
|
}
|
458
472
|
end
|
459
473
|
|
474
|
+
# 获取某个目录下的当前分支
|
475
|
+
def repo_branch(path)
|
476
|
+
full_path = File.expand_path(path)
|
477
|
+
git_path = "#{full_path}/.git"
|
478
|
+
unless Dir.exist?(git_path)
|
479
|
+
return ""
|
480
|
+
end
|
481
|
+
head_path = "#{git_path}/HEAD"
|
482
|
+
unless File.exist?(head_path)
|
483
|
+
return ""
|
484
|
+
end
|
485
|
+
|
486
|
+
content = File.read(head_path)
|
487
|
+
content = content.gsub("\n", "")
|
488
|
+
|
489
|
+
branch_key_word = "ref: refs/heads/"
|
490
|
+
if content.include?(branch_key_word)
|
491
|
+
branch = content.gsub(branch_key_word, "")
|
492
|
+
return "(#{branch})"
|
493
|
+
end
|
494
|
+
|
495
|
+
if content.size >= 8
|
496
|
+
short_sha = content.slice(0, 7)
|
497
|
+
return "(#{short_sha})"
|
498
|
+
end
|
499
|
+
|
500
|
+
"(#{content})"
|
501
|
+
end
|
502
|
+
|
460
503
|
# 读取主工程target列表
|
461
504
|
def init_main_targets
|
462
505
|
project_manager = XCProject::XcodeprojManager.share_manager
|
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.3.
|
4
|
+
version: 2.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 王帅朋
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cocoapods
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- lib/podfileDep/check/import.rb
|
70
70
|
- lib/podfileDep/check/item.rb
|
71
71
|
- lib/podfileDep/check/module.rb
|
72
|
+
- lib/podfileDep/check/project.rb
|
72
73
|
- lib/podfileDep/check/xcodeproj.rb
|
73
74
|
- lib/podfileDep/command/quick.rb
|
74
75
|
- lib/podfileDep/constants.rb
|