yptools 1.0.4 → 1.0.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0733003875644967a3c509aba882ca4943103073c7654a4261eeb8f5ba344539'
4
- data.tar.gz: 03205021d0ba02fe41f25c83d2282c6bfdb86b9484da8fabc7d099690f96ab48
3
+ metadata.gz: 7d9a36624bc18f1d519d0a1b5e24440eec56f05729f2bb997646518eef48130e
4
+ data.tar.gz: 5682539c004927df1bd3b4c8cb9ae8e0c327181311542370bdf42d4d82c46793
5
5
  SHA512:
6
- metadata.gz: 5a96eb5ad7af9f4b9b39cb4ca207bec5f5416ba71fcd81ea8422cbc5a48690f32bdb1d4854af02b1c83699af575a6efc5ca2b89fc13f0656681c172a5a8f077e
7
- data.tar.gz: 4022ddd23fb4a6d523e2bf4fba21ed7be57b6d175dd07206979c266fe53decbdca48e95030db135318a6e1ff9f0a4b6b0359304d1c32f0ecfd50ad392966ae32
6
+ metadata.gz: 5212b210a35eaef7c94b78e416847b4deb21a528f68db4173d0243966502268d0995d774090862b19c271dda78b45abd1def619bedd88c4134b2061adab950ce
7
+ data.tar.gz: 1645e155cd85a3adb1f02492bc17759e6e969cc82f9de10fef12ff993eafdd849e65ec942f89e161487fad4a54e66be5a33d437bd2e460861fcc01aaddefd872
@@ -0,0 +1,69 @@
1
+ require 'pathname'
2
+ require 'colored'
3
+ require_relative '../log/yp_log'
4
+ require_relative '../mgc/yp_makegarbagecode'
5
+
6
+ def yp_copy_ignoringFiles
7
+ return ".", "..", ".DS_Store"
8
+ end
9
+
10
+ def yp_updatereateDate (path)
11
+ yp_log_msg '#{path}'
12
+ # 筛选文件的正则
13
+ script = /(\.h|\.m)$/
14
+ # 配置忽略文件
15
+ ignoringFiles = yp_copy_ignoringFiles
16
+ # 获取符合条件的文件列表
17
+ fileList = yp_method_fileList path, script, ignoringFiles
18
+
19
+ yp_log_doing "正在准备更新当前目录下面文件后缀为.h|.m 的文件创建时间"
20
+
21
+ fileList.each { |fileDic|
22
+ fileDic.each { |key, value|
23
+ createTime = Time.new
24
+ fileName = File.basename(value,".*")
25
+ yp_log_success "已更新文件:#{key}"
26
+ yp_updateCreateDateWithPath value
27
+ }
28
+ }
29
+
30
+ yp_log_success "已更新完成,总共更新#{fileList.count}个文件"
31
+ end
32
+
33
+ # 重新生成文件(目的是为了重置创建时间)
34
+ def yp_updateCreateDateWithPath (path)
35
+
36
+ pathFile = File.open(path, "r")
37
+ fileName = File.basename(path,".*")
38
+ allLines = Array.new
39
+
40
+ createTime = Time.new
41
+ allLines.push('// YPTools Auto Update Create Date https://github.com/HansenCCC/YPTools')
42
+ allLines.push("\n")
43
+ allLines.push("// #{createTime}")
44
+ allLines.push("\n")
45
+
46
+ fileLine = 0
47
+ while textLine = pathFile.gets
48
+ fileLine += 1
49
+ allLines.push(textLine)
50
+ end
51
+
52
+ allLines.push("\n")
53
+ allLines.push("// #{createTime}")
54
+ allLines.push("\n")
55
+ allLines.push('// YPTools Auto Update Create Date https://github.com/HansenCCC/YPTools')
56
+
57
+ filePath = path
58
+
59
+ pathFile.close
60
+
61
+ File.delete(path)
62
+
63
+ createFile = File.new(filePath,"w+")
64
+ allLines.each {|lineTest|
65
+ createFile.syswrite(lineTest)
66
+ }
67
+
68
+ createFile.close
69
+ end
@@ -7,8 +7,14 @@ 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
+ ufct: use [yptools ufct] 更新当前目录下面文件后缀为.h|.m 的文件创建时间
11
13
 
14
+ xpj: use [yptools xpj ...] use xcodeproj api
15
+ use [yptools xpj check] 检查当前目录项目文件是否存在引用的问题
16
+
17
+ help: use [yptools help] 查看帮助
12
18
 
13
19
  }
14
20
  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,186 @@
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
+
20
+ end
21
+
22
+ def self.check
23
+
24
+ yp_log_doing "🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀";
25
+
26
+ yp_path = `pwd`
27
+ yp_path = yp_path.sub("\n","")
28
+
29
+ yp_log_doing "当前目录 #{yp_path}"
30
+
31
+ yp_isTruePath = 0
32
+
33
+ project_path = ''
34
+
35
+ Dir.entries(yp_path).each do |subFile|
36
+ if subFile.include?(".xcodeproj")
37
+ yp_isTruePath = 1
38
+ project_path = yp_path + "/" + subFile
39
+ break
40
+ end
41
+ end
42
+
43
+ if yp_isTruePath == 0
44
+ yp_log_fail "#{yp_path} " + "此目录没有工程,请切换到项目目录下再执行 'yptools xcj check' 命令"
45
+ return
46
+ end
47
+
48
+ yp_log_success "检查#{project_path}项目是否有异常文件"
49
+ project = Xcodeproj::Project.open(project_path)
50
+
51
+ target = project.targets.first
52
+
53
+ if project.targets.count == 0
54
+ yp_log_fail "解析失败,当前工程没有target"
55
+ return
56
+ elsif project.targets.count == 1
57
+ yp_log_doing "开始解析target:'#{target}'"
58
+ else
59
+ yp_log_success '发现以下 targets,需要分析哪个?'
60
+ index = 1
61
+ project.targets.to_a.each do |t|
62
+ yp_log_msg "#{index}、" + t.name
63
+ index += 1
64
+ end
65
+
66
+ input_target = $stdin.gets.chomp.strip
67
+ if input_target.empty?
68
+ yp_log_fail '请选一个 target'
69
+ return
70
+ end
71
+
72
+ target = nil
73
+
74
+ project.targets.to_a.each do |t|
75
+ if t.name == input_target
76
+ target = t
77
+ end
78
+ end
79
+
80
+ unless target
81
+ yp_log_fail "解析失败,输入terget名字与项目中不匹配"
82
+ return
83
+ end
84
+
85
+ end
86
+
87
+ not_exist_files = project.files.to_a.map do |file|
88
+ file.real_path.to_s
89
+ end.select do |path|
90
+ !File.exists?(path)
91
+ end
92
+
93
+ exist_files = project.files.to_a.map do |file|
94
+ file.real_path.to_s
95
+ end.select do |path|
96
+ File.exists?(path)
97
+ end
98
+
99
+ yp_log_doing "开始解析target:'#{target}'"
100
+ yp_log_success "正在检测项目引用的文件是否存在:"
101
+ if not_exist_files.count > 0
102
+ yp_log_fail "请注意,以下'#{not_exist_files.count}个'文件不存在:"
103
+ not_exist_files.to_a.map do |path|
104
+ yp_log_fail File.basename(path) + ' -> ' + path
105
+ end
106
+ else
107
+ yp_log_success "暂无异常"
108
+ end
109
+
110
+ subPath = yp_path
111
+ script = /^*(\.m)$/
112
+ ignoringFiles = ".", "..", ".DS_Store", "Pods"
113
+ file_list = yp_method_fileList subPath, script, ignoringFiles
114
+
115
+ all_file_list = Array.new
116
+ file_list.each { |fileDic|
117
+ fileDic.each { |key, value|
118
+ all_file_list.push(value)
119
+ }
120
+ }
121
+
122
+ target_files = target.source_build_phase.files.to_a.map do |pbx_build_file|
123
+ pbx_build_file.file_ref.real_path.to_s
124
+ end.select do |path|
125
+ path.end_with?(".m", ".mm", ".swift")
126
+ end.select do |path|
127
+ File.exists?(path)
128
+ end
129
+
130
+ not_imports = all_file_list - target_files
131
+
132
+ yp_log_success "正在检测'.m'文件引用问题:"
133
+ if not_imports.count > 0
134
+ yp_log_fail "请注意,以下'#{not_imports.count}个'文件没有被引用:"
135
+ not_imports.to_a.map do |path|
136
+ yp_log_fail File.basename(path) + ' -> ' + path
137
+ end
138
+ else
139
+ yp_log_success "暂无异常"
140
+ end
141
+
142
+ yp_log_doing "🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀";
143
+
144
+ end
145
+
146
+ end
147
+
148
+
149
+ #xcodeproj工程配置脚本化 https://www.jianshu.com/p/67ab2522daa7
150
+
151
+ ## puts project.main_group.path
152
+ # files_m = target.source_build_phase.files.to_a.map do |pbx_build_file|
153
+ # pbx_build_file.file_ref.real_path.to_s
154
+ # end.select do |path|
155
+ # path.end_with?(".m", ".mm", ".swift")
156
+ # end.select do |path|
157
+ # !File.exists?(path)
158
+ # end
159
+ #
160
+ ## files_h = target.headers_build_phase.files.to_a.map do |pbx_build_file|
161
+ ## puts pbx_build_file
162
+ ### pbx_build_file.file_ref.real_path.to_s
163
+ ## end.select do |path|
164
+ ## path.end_with?(".m", ".mm", ".swift")
165
+ ## end.select do |path|
166
+ ## File.exists?(path)
167
+ ## end
168
+ #
169
+ # project.groups.to_a.map do |group|
170
+ ## puts group.class
171
+ ## puts pbx_build_file.file_ref.real_path.to_s
172
+ # end
173
+ #
174
+ #
175
+ ## puts files_h
176
+ ## puts files_m
177
+ #
178
+ # # app_target = project.targets.first
179
+ # #
180
+ # # puts app_target
181
+ # # new_group = project.new_group("CHSS")
182
+ # #
183
+ # # header_ref = new_group.new_file('/Users/Hansen/Desktop/CHSS/CoverView+CHSS.h')
184
+ # # implm_ref = new_group.new_file('/Users/Hansen/Desktop/CHSS/CoverView+CHSS.m')
185
+ # # app_target.add_file_references([implm_ref])
186
+ # # project.save()
data/lib/yptools.rb CHANGED
@@ -2,14 +2,27 @@ 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'
7
+ require_relative 'yptools/file/yp_updatecreatedate'
5
8
 
6
9
  class YPTools
7
10
 
8
11
  def self.cmd_dispatch(argvs)
9
12
  cmd = argvs[0]
10
13
  case cmd
14
+ when 'install'
15
+ if argvs.size > 1
16
+ name = argvs[1]
17
+ self.install name
18
+ else
19
+ yp_log_fail "'yptools install ..' 参数缺失"
20
+ self.help
21
+ end
11
22
  when 'help'
12
23
  self.help
24
+ when 'ufct'
25
+ self.ufct
13
26
  when 'mgc'
14
27
  if argvs.size > 1
15
28
  suffix = argvs[1]
@@ -18,12 +31,14 @@ class YPTools
18
31
  yp_log_fail "'yptools mgc ..' 参数缺失"
19
32
  self.help
20
33
  end
21
- when 'install'
34
+ when 'update'
35
+ self.update
36
+ when 'xpj'
22
37
  if argvs.size > 1
23
- name = argvs[1]
24
- self.install name
38
+ cmd = argvs[1]
39
+ self.xpj cmd
25
40
  else
26
- yp_log_fail "'yptools install ..' 参数缺失"
41
+ yp_log_fail "'yptools xpj ..' 参数缺失"
27
42
  self.help
28
43
  end
29
44
  else
@@ -36,6 +51,12 @@ class YPTools
36
51
  YPHelp.message
37
52
  end
38
53
 
54
+ def self.ufct
55
+ path = `pwd`
56
+ path = path.sub("\n","")
57
+ yp_updatereateDate path
58
+ end
59
+
39
60
  def self.mgc(suffix)
40
61
  yp_tools_method_makeGarbage suffix
41
62
  end
@@ -44,8 +65,23 @@ class YPTools
44
65
  YPInstall.install(name)
45
66
  end
46
67
 
68
+ def self.update
69
+ YPUpdate.update
70
+ end
71
+
72
+ def self.xpj(cmd)
73
+ YPXcodeproj.xcodeproj(cmd)
74
+ end
75
+
47
76
  end
48
77
 
78
+
79
+ # xcode自动添加文件 > xcodeproj
80
+ # 自动生成xcode icon
81
+ # 垃圾代码自动添加
82
+ # 自动打包功能
83
+ # SDK自动生成
84
+
49
85
  #puts "🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀";
50
86
  #
51
87
  #path = "/Users/Hansen/Desktop/QMKKXProduct"
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.4
4
+ version: 1.0.7
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-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -90,10 +90,13 @@ extra_rdoc_files: []
90
90
  files:
91
91
  - bin/yptools
92
92
  - lib/yptools.rb
93
+ - lib/yptools/file/yp_updatecreatedate.rb
93
94
  - lib/yptools/help/yp_help.rb
94
95
  - lib/yptools/install/yp_install.rb
95
96
  - lib/yptools/log/yp_log.rb
96
97
  - lib/yptools/mgc/yp_makegarbagecode.rb
98
+ - lib/yptools/update/yp_update.rb
99
+ - lib/yptools/xcodeproj/yp_xcodeproj.rb
97
100
  homepage: https://github.com/HansenCCC/YPTools.git
98
101
  licenses:
99
102
  - MIT
@@ -113,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
116
  - !ruby/object:Gem::Version
114
117
  version: '0'
115
118
  requirements: []
116
- rubygems_version: 3.0.3.1
119
+ rubygems_version: 3.0.9
117
120
  signing_key:
118
121
  specification_version: 4
119
122
  summary: YPTools!