yptools 1.0.5 → 1.0.6
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/lib/yptools/help/yp_help.rb +3 -0
- data/lib/yptools/log/yp_log.rb +5 -0
- data/lib/yptools/update/yp_update.rb +1 -0
- data/lib/yptools/xcodeproj/yp_xcodeproj.rb +224 -0
- data/lib/yptools.rb +20 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0077bd48738b9e68825ffeeafc22e984abf32df190609b7b6cceed822ca5311d
|
4
|
+
data.tar.gz: 8a653f1f78714d8fbf992aab66fbafe4931f2ce6d0d3c89b12bc83cc998d4efb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ceeb4096543a91b7a9c68a1a86b90cd9dcc2a64fba743536f6dfd44247a4446170377c2a9c251ef8e715dfcef460a7ffe909e0b0e4ca282cb1db77062589b36
|
7
|
+
data.tar.gz: 6d8aee0caba72e0479a574d8c75876279f71e91734542df9e49b8a3a9f54cf0fc159ccb95f21ebcfb9ef2b036c9055711000a005bdae4d805d5e224b93823839
|
data/lib/yptools/help/yp_help.rb
CHANGED
data/lib/yptools/log/yp_log.rb
CHANGED
@@ -0,0 +1,224 @@
|
|
1
|
+
require 'xcodeproj'
|
2
|
+
require_relative '../log/yp_log'
|
3
|
+
require_relative '../mgc/yp_makegarbagecode'
|
4
|
+
|
5
|
+
class YPXcodeproj
|
6
|
+
|
7
|
+
def self.xcodeproj(cmd)
|
8
|
+
case cmd
|
9
|
+
when 'check'
|
10
|
+
self.check
|
11
|
+
when 'message'
|
12
|
+
self.message
|
13
|
+
else
|
14
|
+
yp_log_fail "'yptools xcp #{name}' 暂无,敬请期待"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.message
|
19
|
+
# yp_log_doing "🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀"
|
20
|
+
# project_path = '/Users/Hansen/Desktop/lehuo/PrivateDiary.xcodeproj'
|
21
|
+
# project = Xcodeproj::Project.open(project_path)
|
22
|
+
#
|
23
|
+
# project.targets.each do |target|
|
24
|
+
# puts target.name
|
25
|
+
# end
|
26
|
+
|
27
|
+
# target = project.targets.first
|
28
|
+
# files = target.source_build_phase.files.to_a.map do |pbx_build_file|
|
29
|
+
# pbx_build_file.file_ref.real_path.to_s
|
30
|
+
# end.select do |path|
|
31
|
+
# path.end_with?(".m", ".mm", ".swift")
|
32
|
+
# end.select do |path|
|
33
|
+
# !File.exists?(path)
|
34
|
+
# end
|
35
|
+
#
|
36
|
+
# files = target.source_build_phase.files.to_a.map do |pbx_build_file|
|
37
|
+
# pbx_build_file.file_ref.real_path.to_s
|
38
|
+
# end.select do |path|
|
39
|
+
# path.end_with?(".m", ".mm", ".swift")
|
40
|
+
# end.select do |path|
|
41
|
+
# !File.exists?(path)
|
42
|
+
# end
|
43
|
+
#
|
44
|
+
# puts files
|
45
|
+
|
46
|
+
# app_target = project.targets.first
|
47
|
+
#
|
48
|
+
# puts app_target
|
49
|
+
# new_group = project.new_group("CHSS")
|
50
|
+
#
|
51
|
+
# header_ref = new_group.new_file('/Users/Hansen/Desktop/CHSS/CoverView+CHSS.h')
|
52
|
+
# implm_ref = new_group.new_file('/Users/Hansen/Desktop/CHSS/CoverView+CHSS.m')
|
53
|
+
# app_target.add_file_references([implm_ref])
|
54
|
+
# project.save()
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
def self.check
|
60
|
+
|
61
|
+
yp_log_doing "🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀";
|
62
|
+
|
63
|
+
yp_path = `pwd`
|
64
|
+
yp_path = yp_path.sub("\n","")
|
65
|
+
|
66
|
+
yp_log_doing "当前目录 #{yp_path}"
|
67
|
+
|
68
|
+
yp_isTruePath = 0
|
69
|
+
|
70
|
+
project_path = ''
|
71
|
+
|
72
|
+
Dir.entries(yp_path).each do |subFile|
|
73
|
+
if subFile.include?(".xcodeproj")
|
74
|
+
yp_isTruePath = 1
|
75
|
+
project_path = yp_path + "/" + subFile
|
76
|
+
break
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
if yp_isTruePath == 0
|
81
|
+
yp_log_fail "#{yp_path} " + "此目录没有工程,请切换到项目目录下再执行 'yptools xcj check' 命令"
|
82
|
+
return
|
83
|
+
end
|
84
|
+
|
85
|
+
yp_log_success "检查#{project_path}项目是否有异常文件"
|
86
|
+
project = Xcodeproj::Project.open(project_path)
|
87
|
+
|
88
|
+
target = project.targets.first
|
89
|
+
|
90
|
+
if project.targets.count == 0
|
91
|
+
yp_log_fail "解析失败,当前工程没有target"
|
92
|
+
return
|
93
|
+
elsif project.targets.count == 1
|
94
|
+
yp_log_doing "开始解析target:'#{target}'"
|
95
|
+
else
|
96
|
+
yp_log_success '发现以下 targets,需要分析哪个?'
|
97
|
+
index = 1
|
98
|
+
project.targets.to_a.each do |t|
|
99
|
+
yp_log_msg "#{index}、" + t.name
|
100
|
+
index += 1
|
101
|
+
end
|
102
|
+
|
103
|
+
input_target = $stdin.gets.chomp.strip
|
104
|
+
if input_target.empty?
|
105
|
+
yp_log_fail '请选一个 target'
|
106
|
+
return
|
107
|
+
end
|
108
|
+
|
109
|
+
target = nil
|
110
|
+
|
111
|
+
project.targets.to_a.each do |t|
|
112
|
+
if t.name == input_target
|
113
|
+
target = t
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
unless target
|
118
|
+
yp_log_fail "解析失败,输入terget名字与项目中不匹配"
|
119
|
+
return
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
not_exist_files = project.files.to_a.map do |file|
|
125
|
+
file.real_path.to_s
|
126
|
+
end.select do |path|
|
127
|
+
!File.exists?(path)
|
128
|
+
end
|
129
|
+
|
130
|
+
exist_files = project.files.to_a.map do |file|
|
131
|
+
file.real_path.to_s
|
132
|
+
end.select do |path|
|
133
|
+
File.exists?(path)
|
134
|
+
end
|
135
|
+
|
136
|
+
yp_log_doing "开始解析target:'#{target}'"
|
137
|
+
yp_log_success "正在检测项目引用的文件是否存在:"
|
138
|
+
if not_exist_files.count > 0
|
139
|
+
yp_log_fail "请注意,以下'#{not_exist_files.count}个'文件不存在:"
|
140
|
+
not_exist_files.to_a.map do |path|
|
141
|
+
yp_log_fail File.basename(path) + ' -> ' + path
|
142
|
+
end
|
143
|
+
else
|
144
|
+
yp_log_success "暂无异常"
|
145
|
+
end
|
146
|
+
|
147
|
+
subPath = yp_path
|
148
|
+
script = /^*(\.m)$/
|
149
|
+
ignoringFiles = ".", "..", ".DS_Store", "Pods"
|
150
|
+
file_list = yp_method_fileList subPath, script, ignoringFiles
|
151
|
+
|
152
|
+
all_file_list = Array.new
|
153
|
+
file_list.each { |fileDic|
|
154
|
+
fileDic.each { |key, value|
|
155
|
+
all_file_list.push(value)
|
156
|
+
}
|
157
|
+
}
|
158
|
+
|
159
|
+
target_files = target.source_build_phase.files.to_a.map do |pbx_build_file|
|
160
|
+
pbx_build_file.file_ref.real_path.to_s
|
161
|
+
end.select do |path|
|
162
|
+
path.end_with?(".m", ".mm", ".swift")
|
163
|
+
end.select do |path|
|
164
|
+
File.exists?(path)
|
165
|
+
end
|
166
|
+
|
167
|
+
not_imports = all_file_list - target_files
|
168
|
+
|
169
|
+
yp_log_success "正在检测'.m'文件引用问题:"
|
170
|
+
if not_imports.count > 0
|
171
|
+
yp_log_fail "请注意,以下'#{not_imports.count}个'文件没有被引用:"
|
172
|
+
not_imports.to_a.map do |path|
|
173
|
+
yp_log_fail File.basename(path) + ' -> ' + path
|
174
|
+
end
|
175
|
+
else
|
176
|
+
yp_log_success "暂无异常"
|
177
|
+
end
|
178
|
+
|
179
|
+
yp_log_doing "🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀";
|
180
|
+
|
181
|
+
end
|
182
|
+
|
183
|
+
end
|
184
|
+
|
185
|
+
|
186
|
+
#xcodeproj工程配置脚本化 https://www.jianshu.com/p/67ab2522daa7
|
187
|
+
|
188
|
+
|
189
|
+
## puts project.main_group.path
|
190
|
+
# files_m = target.source_build_phase.files.to_a.map do |pbx_build_file|
|
191
|
+
# pbx_build_file.file_ref.real_path.to_s
|
192
|
+
# end.select do |path|
|
193
|
+
# path.end_with?(".m", ".mm", ".swift")
|
194
|
+
# end.select do |path|
|
195
|
+
# !File.exists?(path)
|
196
|
+
# end
|
197
|
+
#
|
198
|
+
## files_h = target.headers_build_phase.files.to_a.map do |pbx_build_file|
|
199
|
+
## puts pbx_build_file
|
200
|
+
### pbx_build_file.file_ref.real_path.to_s
|
201
|
+
## end.select do |path|
|
202
|
+
## path.end_with?(".m", ".mm", ".swift")
|
203
|
+
## end.select do |path|
|
204
|
+
## File.exists?(path)
|
205
|
+
## end
|
206
|
+
#
|
207
|
+
# project.groups.to_a.map do |group|
|
208
|
+
## puts group.class
|
209
|
+
## puts pbx_build_file.file_ref.real_path.to_s
|
210
|
+
# end
|
211
|
+
#
|
212
|
+
#
|
213
|
+
## puts files_h
|
214
|
+
## puts files_m
|
215
|
+
#
|
216
|
+
# # app_target = project.targets.first
|
217
|
+
# #
|
218
|
+
# # puts app_target
|
219
|
+
# # new_group = project.new_group("CHSS")
|
220
|
+
# #
|
221
|
+
# # header_ref = new_group.new_file('/Users/Hansen/Desktop/CHSS/CoverView+CHSS.h')
|
222
|
+
# # implm_ref = new_group.new_file('/Users/Hansen/Desktop/CHSS/CoverView+CHSS.m')
|
223
|
+
# # app_target.add_file_references([implm_ref])
|
224
|
+
# # project.save()
|
data/lib/yptools.rb
CHANGED
@@ -3,6 +3,7 @@ require_relative 'yptools/help/yp_help'
|
|
3
3
|
require_relative 'yptools/log/yp_log'
|
4
4
|
require_relative 'yptools/install/yp_install'
|
5
5
|
require_relative 'yptools/update/yp_update'
|
6
|
+
require_relative 'yptools/xcodeproj/yp_xcodeproj'
|
6
7
|
|
7
8
|
class YPTools
|
8
9
|
|
@@ -29,6 +30,14 @@ class YPTools
|
|
29
30
|
end
|
30
31
|
when 'update'
|
31
32
|
self.update
|
33
|
+
when 'xpj'
|
34
|
+
if argvs.size > 1
|
35
|
+
cmd = argvs[1]
|
36
|
+
self.xpj cmd
|
37
|
+
else
|
38
|
+
yp_log_fail "'yptools xpj ..' 参数缺失"
|
39
|
+
self.help
|
40
|
+
end
|
32
41
|
else
|
33
42
|
self.help
|
34
43
|
end
|
@@ -51,8 +60,19 @@ class YPTools
|
|
51
60
|
YPUpdate.update
|
52
61
|
end
|
53
62
|
|
63
|
+
def self.xpj(cmd)
|
64
|
+
YPXcodeproj.xcodeproj(cmd)
|
65
|
+
end
|
66
|
+
|
54
67
|
end
|
55
68
|
|
69
|
+
|
70
|
+
# xcode自动添加文件 > xcodeproj
|
71
|
+
# 自动生成xcode icon
|
72
|
+
# 垃圾代码自动添加
|
73
|
+
# 自动打包功能
|
74
|
+
# SDK自动生成
|
75
|
+
|
56
76
|
#puts "🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀";
|
57
77
|
#
|
58
78
|
#path = "/Users/Hansen/Desktop/QMKKXProduct"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yptools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- chenghengsheng
|
@@ -95,6 +95,7 @@ files:
|
|
95
95
|
- lib/yptools/log/yp_log.rb
|
96
96
|
- lib/yptools/mgc/yp_makegarbagecode.rb
|
97
97
|
- lib/yptools/update/yp_update.rb
|
98
|
+
- lib/yptools/xcodeproj/yp_xcodeproj.rb
|
98
99
|
homepage: https://github.com/HansenCCC/YPTools.git
|
99
100
|
licenses:
|
100
101
|
- MIT
|