yptools 1.0.3 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 80cfb296536ceed1f676ce004a319bfd15a6c01313301d4c0a62e46b7f33f6e6
4
- data.tar.gz: 8f669a0c977a92602af1ea92322a90eb7a399e77a23261ba22dda32db341e00e
3
+ metadata.gz: 0077bd48738b9e68825ffeeafc22e984abf32df190609b7b6cceed822ca5311d
4
+ data.tar.gz: 8a653f1f78714d8fbf992aab66fbafe4931f2ce6d0d3c89b12bc83cc998d4efb
5
5
  SHA512:
6
- metadata.gz: '08ac954936254dabf088095beead682d2bb60124493b9486bad8b6569aaaff09bb55f90391261abdbf7198ba0d2834b8f6b0ac55e4b7f11682a53cefc1722cc7'
7
- data.tar.gz: 93ffd2002a9f7668c93ebb40bd5fc076886b6e4378c37f7f9dc5f009d2a015efed96658c58f32a2c32d61ace3c57aaff8655e23a3676d6f217d08b3d9b7460aa
6
+ metadata.gz: 9ceeb4096543a91b7a9c68a1a86b90cd9dcc2a64fba743536f6dfd44247a4446170377c2a9c251ef8e715dfcef460a7ffe909e0b0e4ca282cb1db77062589b36
7
+ data.tar.gz: 6d8aee0caba72e0479a574d8c75876279f71e91734542df9e49b8a3a9f54cf0fc159ccb95f21ebcfb9ef2b036c9055711000a005bdae4d805d5e224b93823839
@@ -7,8 +7,12 @@ class YPHelp
7
7
 
8
8
  mgc: use [yptools mgc suffix] 在当前目录生成垃圾代码(当前目录需要有.xcworkspace或者.xcodeproj目录)
9
9
 
10
- help: use [yptools help] 查看帮助
10
+ update: use [yptools update] 更新yptools
11
+
12
+ xpj: use [yptools xpj ...] use xcodeproj api
13
+ use [yptools xpj check] 检查当前目录项目文件是否存在引用的问题
11
14
 
15
+ help: use [yptools help] 查看帮助
12
16
 
13
17
  }
14
18
  end
@@ -9,3 +9,8 @@ end
9
9
  def yp_log_doing (log)
10
10
  puts log.yellow
11
11
  end
12
+
13
+ def yp_log_msg (log)
14
+ puts log.white
15
+ end
16
+
@@ -0,0 +1,20 @@
1
+ require 'colored'
2
+ require 'fileutils'
3
+ require_relative '../mgc/yp_makegarbagecode'
4
+ require_relative '../log/yp_log'
5
+
6
+ class YPUpdate
7
+ def self.update
8
+ yp_log_doing '准备更新...'
9
+
10
+ system("gem install colored")
11
+ system("gem install bundler")
12
+ system("gem install rake")
13
+ system("gem install xcodeproj")
14
+ system("gem install yptools")
15
+
16
+ yp_log_success "更新YPTools完成"
17
+
18
+ end
19
+
20
+ end
@@ -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
@@ -2,6 +2,8 @@ require_relative 'yptools/mgc/yp_makegarbagecode'
2
2
  require_relative 'yptools/help/yp_help'
3
3
  require_relative 'yptools/log/yp_log'
4
4
  require_relative 'yptools/install/yp_install'
5
+ require_relative 'yptools/update/yp_update'
6
+ require_relative 'yptools/xcodeproj/yp_xcodeproj'
5
7
 
6
8
  class YPTools
7
9
 
@@ -26,6 +28,16 @@ class YPTools
26
28
  yp_log_fail "'yptools install ..' 参数缺失"
27
29
  self.help
28
30
  end
31
+ when 'update'
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
29
41
  else
30
42
  self.help
31
43
  end
@@ -44,8 +56,23 @@ class YPTools
44
56
  YPInstall.install(name)
45
57
  end
46
58
 
59
+ def self.update
60
+ YPUpdate.update
61
+ end
62
+
63
+ def self.xpj(cmd)
64
+ YPXcodeproj.xcodeproj(cmd)
65
+ end
66
+
47
67
  end
48
68
 
69
+
70
+ # xcode自动添加文件 > xcodeproj
71
+ # 自动生成xcode icon
72
+ # 垃圾代码自动添加
73
+ # 自动打包功能
74
+ # SDK自动生成
75
+
49
76
  #puts "🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀";
50
77
  #
51
78
  #path = "/Users/Hansen/Desktop/QMKKXProduct"
@@ -62,5 +89,5 @@ end
62
89
  #
63
90
 
64
91
 
65
- YPTools.cmd_dispatch(ARGV)
92
+ #YPTools.cmd_dispatch(ARGV)
66
93
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yptools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - chenghengsheng
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-08 00:00:00.000000000 Z
11
+ date: 2022-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,6 +94,8 @@ files:
94
94
  - lib/yptools/install/yp_install.rb
95
95
  - lib/yptools/log/yp_log.rb
96
96
  - lib/yptools/mgc/yp_makegarbagecode.rb
97
+ - lib/yptools/update/yp_update.rb
98
+ - lib/yptools/xcodeproj/yp_xcodeproj.rb
97
99
  homepage: https://github.com/HansenCCC/YPTools.git
98
100
  licenses:
99
101
  - MIT
@@ -113,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
115
  - !ruby/object:Gem::Version
114
116
  version: '0'
115
117
  requirements: []
116
- rubygems_version: 3.0.3.1
118
+ rubygems_version: 3.0.9
117
119
  signing_key:
118
120
  specification_version: 4
119
121
  summary: YPTools!