cocoapods-bb-bin 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +19 -0
- data/README.md +68 -0
- data/lib/cocoapods-bb-bin/command/bin/archive.rb +234 -0
- data/lib/cocoapods-bb-bin/command/bin/auto.rb +226 -0
- data/lib/cocoapods-bb-bin/command/bin/code.rb +295 -0
- data/lib/cocoapods-bb-bin/command/bin/dup.rb +78 -0
- data/lib/cocoapods-bb-bin/command/bin/imy.rb +46 -0
- data/lib/cocoapods-bb-bin/command/bin/init.rb +69 -0
- data/lib/cocoapods-bb-bin/command/bin/initHotKey.rb +70 -0
- data/lib/cocoapods-bb-bin/command/bin/install.rb +44 -0
- data/lib/cocoapods-bb-bin/command/bin/lib/lint.rb +69 -0
- data/lib/cocoapods-bb-bin/command/bin/repo/update.rb +43 -0
- data/lib/cocoapods-bb-bin/command/bin/spec/create.rb +73 -0
- data/lib/cocoapods-bb-bin/command/bin/spec/push.rb +114 -0
- data/lib/cocoapods-bb-bin/command/bin/update.rb +154 -0
- data/lib/cocoapods-bb-bin/command/bin.rb +59 -0
- data/lib/cocoapods-bb-bin/command.rb +2 -0
- data/lib/cocoapods-bb-bin/config/config.rb +136 -0
- data/lib/cocoapods-bb-bin/config/config_asker.rb +57 -0
- data/lib/cocoapods-bb-bin/config/config_builder.rb +234 -0
- data/lib/cocoapods-bb-bin/config/config_hot_key.rb +102 -0
- data/lib/cocoapods-bb-bin/config/config_hot_key_asker.rb +57 -0
- data/lib/cocoapods-bb-bin/gem_version.rb +10 -0
- data/lib/cocoapods-bb-bin/helpers/Info.plist +0 -0
- data/lib/cocoapods-bb-bin/helpers/build_helper.rb +217 -0
- data/lib/cocoapods-bb-bin/helpers/build_utils.rb +63 -0
- data/lib/cocoapods-bb-bin/helpers/framework.rb +85 -0
- data/lib/cocoapods-bb-bin/helpers/framework_builder.rb +446 -0
- data/lib/cocoapods-bb-bin/helpers/library.rb +54 -0
- data/lib/cocoapods-bb-bin/helpers/library_builder.rb +90 -0
- data/lib/cocoapods-bb-bin/helpers/sources_helper.rb +36 -0
- data/lib/cocoapods-bb-bin/helpers/spec_creator.rb +170 -0
- data/lib/cocoapods-bb-bin/helpers/spec_files_helper.rb +77 -0
- data/lib/cocoapods-bb-bin/helpers/spec_source_creator.rb +227 -0
- data/lib/cocoapods-bb-bin/helpers/upload_helper.rb +96 -0
- data/lib/cocoapods-bb-bin/helpers/xcframework_builder.rb +77 -0
- data/lib/cocoapods-bb-bin/helpers.rb +5 -0
- data/lib/cocoapods-bb-bin/native/acknowledgements.rb +27 -0
- data/lib/cocoapods-bb-bin/native/analyzer.rb +55 -0
- data/lib/cocoapods-bb-bin/native/file_accessor.rb +28 -0
- data/lib/cocoapods-bb-bin/native/installation_options.rb +25 -0
- data/lib/cocoapods-bb-bin/native/installer.rb +135 -0
- data/lib/cocoapods-bb-bin/native/linter.rb +26 -0
- data/lib/cocoapods-bb-bin/native/path_source.rb +33 -0
- data/lib/cocoapods-bb-bin/native/pod_source_installer.rb +19 -0
- data/lib/cocoapods-bb-bin/native/pod_target_installer.rb +94 -0
- data/lib/cocoapods-bb-bin/native/podfile.rb +91 -0
- data/lib/cocoapods-bb-bin/native/podfile_env.rb +37 -0
- data/lib/cocoapods-bb-bin/native/podfile_generator.rb +199 -0
- data/lib/cocoapods-bb-bin/native/podspec_finder.rb +25 -0
- data/lib/cocoapods-bb-bin/native/resolver.rb +230 -0
- data/lib/cocoapods-bb-bin/native/sandbox_analyzer.rb +34 -0
- data/lib/cocoapods-bb-bin/native/source.rb +35 -0
- data/lib/cocoapods-bb-bin/native/sources_manager.rb +20 -0
- data/lib/cocoapods-bb-bin/native/specification.rb +31 -0
- data/lib/cocoapods-bb-bin/native/target_validator.rb +41 -0
- data/lib/cocoapods-bb-bin/native/validator.rb +40 -0
- data/lib/cocoapods-bb-bin/native.rb +23 -0
- data/lib/cocoapods-bb-bin/source_provider_hook.rb +66 -0
- data/lib/cocoapods-bb-bin.rb +2 -0
- data/lib/cocoapods_plugin.rb +3 -0
- data/spec/command/bin_spec.rb +12 -0
- data/spec/spec_helper.rb +51 -0
- metadata +200 -0
@@ -0,0 +1,295 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Bin < Command
|
6
|
+
class Code < Bin
|
7
|
+
self.summary = '通过将二进制对应源码放置在临时目录中,让二进制出现断点时可以跳到对应的源码,方便调试。'
|
8
|
+
|
9
|
+
self.description = <<-DESC
|
10
|
+
通过将二进制对应源码放置在临时目录中,让二进制出现断点时可以跳到对应的源码,方便调试。
|
11
|
+
在不删除二进制的情况下为某个组件添加源码调试能力,多个组件名称用空格分隔
|
12
|
+
DESC
|
13
|
+
|
14
|
+
self.arguments = [
|
15
|
+
CLAide::Argument.new('NAME', false)
|
16
|
+
]
|
17
|
+
def self.options
|
18
|
+
[
|
19
|
+
['--all-clean', '删除所有已经下载的源码'],
|
20
|
+
['--clean', '删除所有指定下载的源码'],
|
21
|
+
['--list', '展示所有一级下载的源码以及其大小'],
|
22
|
+
['--source', '源码路径,本地路径,会去自动链接本地源码'],
|
23
|
+
['--simulator', '是否模拟器架构,xcframework需要'],# 是否模拟器,默认NO,xcframework需要使用
|
24
|
+
]
|
25
|
+
end
|
26
|
+
|
27
|
+
def initialize(argv)
|
28
|
+
@codeSource = argv.option('source') || nil
|
29
|
+
@names = argv.arguments! unless argv.arguments.empty?
|
30
|
+
@list = argv.flag?('list', false )
|
31
|
+
@all_clean = argv.flag?('all-clean', false )
|
32
|
+
@clean = argv.flag?('clean', false )
|
33
|
+
@simulator = argv.flag?('simulator', false )
|
34
|
+
|
35
|
+
@config = Pod::Config.instance
|
36
|
+
|
37
|
+
super
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
def run
|
42
|
+
|
43
|
+
podfile_lock = File.join(Pathname.pwd,"Podfile.lock")
|
44
|
+
raise "podfile.lock,不存在,请先pod install/update" unless File.exist?(podfile_lock)
|
45
|
+
@lockfile ||= Lockfile.from_file(Pathname.new(podfile_lock) )
|
46
|
+
|
47
|
+
if @list
|
48
|
+
list
|
49
|
+
elsif @clean
|
50
|
+
clean
|
51
|
+
elsif @all_clean
|
52
|
+
all_clean
|
53
|
+
elsif @names
|
54
|
+
add
|
55
|
+
end
|
56
|
+
|
57
|
+
if @list && @clean && @names
|
58
|
+
raise "请选择您要执行的命令。"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
#==========================begin add ==============
|
63
|
+
|
64
|
+
def add
|
65
|
+
if @names == nil
|
66
|
+
raise "请输入要调试组件名,多个组件名称用空格分隔"
|
67
|
+
end
|
68
|
+
|
69
|
+
@names.each do |name|
|
70
|
+
lib_file = get_lib_path(name)
|
71
|
+
unless File.exist?(lib_file)
|
72
|
+
raise "找不到 #{lib_file}"
|
73
|
+
end
|
74
|
+
UI.puts "#{lib_file}"
|
75
|
+
|
76
|
+
target_path = @codeSource || download_source(name)
|
77
|
+
puts "====add lib_file: #{lib_file} target_path: #{target_path} name: #{name}"
|
78
|
+
link(lib_file,target_path,name)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
#下载源码到本地
|
83
|
+
def download_source(name)
|
84
|
+
target_path = File.join(source_root, name)
|
85
|
+
UI.puts target_path
|
86
|
+
FileUtils.rm_rf(target_path)
|
87
|
+
|
88
|
+
find_dependency = find_dependency(name)
|
89
|
+
|
90
|
+
spec = fetch_external_source(find_dependency, @config.podfile,@config.lockfile, @config.sandbox,true )
|
91
|
+
|
92
|
+
download_request = Pod::Downloader::Request.new(:name => name, :spec => spec)
|
93
|
+
Downloader.download(download_request, Pathname.new(target_path), :can_cache => true)
|
94
|
+
|
95
|
+
target_path
|
96
|
+
end
|
97
|
+
|
98
|
+
#找出依赖
|
99
|
+
def find_dependency (name)
|
100
|
+
find_dependency = nil
|
101
|
+
@config.podfile.dependencies.each do |dependency|
|
102
|
+
if dependency.root_name.downcase == name.downcase
|
103
|
+
find_dependency = dependency
|
104
|
+
break
|
105
|
+
end
|
106
|
+
end
|
107
|
+
find_dependency
|
108
|
+
end
|
109
|
+
|
110
|
+
# 获取external_source 下的仓库
|
111
|
+
# @return spec
|
112
|
+
def fetch_external_source(dependency ,podfile , lockfile, sandbox,use_lockfile_options)
|
113
|
+
source = ExternalSources.from_dependency(dependency, podfile.defined_in_file, true)
|
114
|
+
source.fetch(sandbox)
|
115
|
+
end
|
116
|
+
|
117
|
+
|
118
|
+
#==========================link begin ==============
|
119
|
+
|
120
|
+
#链接,.a文件位置, 源码目录,工程名=IMYFoundation
|
121
|
+
def link(lib_file,target_path,basename)
|
122
|
+
print <<EOF
|
123
|
+
link 源码
|
124
|
+
`dwarfdump "#{lib_file}" | grep "AT_comp_dir" | head -1 | cut -d \\" -f2 `
|
125
|
+
EOF
|
126
|
+
dir = (`dwarfdump "#{lib_file}" | grep "AT_comp_dir" | head -1 | cut -d \\" -f2 `)
|
127
|
+
UI.puts "dwarfdump dir = #{dir}"
|
128
|
+
# if Pathname.new(lib_file).extname == ".a"
|
129
|
+
# sub_path = "#{basename}/bin-archive/#{basename}"
|
130
|
+
# else
|
131
|
+
# sub_path = "#{basename}"
|
132
|
+
# end
|
133
|
+
sub_path = "#{basename}/bin-archive/#{basename}"
|
134
|
+
dir = dir.gsub(sub_path, "").chomp
|
135
|
+
UI.puts "Binary dir = #{dir}"
|
136
|
+
|
137
|
+
unless File.exist?(dir)
|
138
|
+
# UI.puts "不存在 = #{dir}"
|
139
|
+
begin
|
140
|
+
FileUtils.mkdir_p(dir) unless File.exists?(dir) # require 'fileutils'
|
141
|
+
rescue SystemCallError
|
142
|
+
# mkdir: _fzzfm3x4y17bm6psx9yhbs00000gn: Permission denied
|
143
|
+
unless File.exist?(dir)
|
144
|
+
user_name_array = Dir.home.split('/') # Dir.home = /Users/xx,xx表示当前用户名称
|
145
|
+
user_name = "501"
|
146
|
+
user_name_array.each do |name|
|
147
|
+
user_name = name
|
148
|
+
end
|
149
|
+
UI.puts "user_name = #{user_name}".yellow
|
150
|
+
`sudo mkdir -p #{dir} && sudo chown -R #{user_name}:wheel #{dir}`
|
151
|
+
end
|
152
|
+
#判断用户目录是否存在
|
153
|
+
array = dir.split('/')
|
154
|
+
if array.length > 5
|
155
|
+
root_path = '/' + array[1] + '/' + array[2] + '/' + array[3] + '/' + array[4]
|
156
|
+
UI.puts "root_path = #{root_path}"
|
157
|
+
unless File.exist?(root_path)
|
158
|
+
raise "由于权限不足,请手动创建#{root_path} 后重试"
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
unless File.exist?(dir)
|
164
|
+
raise Informative, "【切换源码】由于权限不足,请手动创建目录: #{dir} 授权mobile权限后重试"
|
165
|
+
end
|
166
|
+
|
167
|
+
if Pathname.new(lib_file).extname == ".a"
|
168
|
+
FileUtils.rm_rf(File.join(dir,basename))
|
169
|
+
`ln -s #{target_path} #{dir}`
|
170
|
+
else
|
171
|
+
FileUtils.rm_rf(File.join(dir,basename))
|
172
|
+
`ln -s #{target_path} #{dir}/#{basename}`
|
173
|
+
end
|
174
|
+
|
175
|
+
check(lib_file,dir,basename)
|
176
|
+
end
|
177
|
+
|
178
|
+
def check(lib_file,dir,basename)
|
179
|
+
print <<EOF
|
180
|
+
check 源码
|
181
|
+
`dwarfdump "#{lib_file}" | grep -E "DW_AT_decl_file.*#{basename}.*\\.m|\\.c" | head -1 | cut -d \\" -f2`
|
182
|
+
EOF
|
183
|
+
file = `dwarfdump "#{lib_file}" | grep -E "DW_AT_decl_file.*#{basename}.*\\.m|\\.c" | head -1 | cut -d \\" -f2`
|
184
|
+
if File.exist?(file)
|
185
|
+
raise Informative, "#{file} 不存在 请检测代码源是否正确~"
|
186
|
+
end
|
187
|
+
UI.puts "library file: #{lib_file} dwarfdump file: #{file}"
|
188
|
+
UI.puts "link successfully!".yellow
|
189
|
+
UI.puts "view linked source at path: #{dir}".yellow
|
190
|
+
end
|
191
|
+
|
192
|
+
def get_lib_path(name)
|
193
|
+
dir = Pathname.new(File.join(Pathname.pwd,"Pods",name))
|
194
|
+
# 遍历组件目录判断
|
195
|
+
Dir.foreach(dir) do |filename|
|
196
|
+
if filename != "." and filename != ".."
|
197
|
+
filepath = File.join(dir,"#{filename}")
|
198
|
+
if File.file?(filepath)
|
199
|
+
if File.extname(filepath) == '.a' # .a库
|
200
|
+
return filepath
|
201
|
+
end
|
202
|
+
else
|
203
|
+
if File.extname(filepath) == '.framework' # .framework库
|
204
|
+
return File.join(filepath,name)
|
205
|
+
end
|
206
|
+
if File.extname(filepath) == '.xcframework' # .xcframework库
|
207
|
+
|
208
|
+
print <<EOF
|
209
|
+
获取xcframework架构 ls -al "#{filepath}"
|
210
|
+
EOF
|
211
|
+
# 构建xcframework架构需要根据实际二进制文件进行条件判断
|
212
|
+
arm_name = ""
|
213
|
+
if @simulator
|
214
|
+
arm_name = "ios-arm64_i386_x86_64-simulator"
|
215
|
+
else
|
216
|
+
arm_name = "ios-arm64_armv7"
|
217
|
+
end
|
218
|
+
temp_name = "#{arm_name}/#{name}.framework/#{name}"
|
219
|
+
return File.join(filepath,temp_name) # TYSecKit.xcframework/ios-arm64_armv7/TYSecKit.framework/TYSecKit
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
# 兼容作者代码,默认取.a文件
|
225
|
+
lib_name = "lib#{name}.a"
|
226
|
+
lib_path = File.join(dir,lib_name)
|
227
|
+
|
228
|
+
unless File.exist?(lib_path)
|
229
|
+
lib_path = File.join(dir.children.first,lib_name)
|
230
|
+
end
|
231
|
+
|
232
|
+
lib_path
|
233
|
+
end
|
234
|
+
|
235
|
+
#源码地址
|
236
|
+
# def get_gitlib_iOS_path(name)
|
237
|
+
# "git@gitlab.xxx.com:iOS/#{name}.git"
|
238
|
+
# end
|
239
|
+
#要转换的地址,Github-iOS默认都是静态库
|
240
|
+
# def git_gitlib_iOS_path
|
241
|
+
# 'git@gitlab.xxx.com:Github-iOS/'
|
242
|
+
# end
|
243
|
+
|
244
|
+
|
245
|
+
#要转换的地址,Github-iOS默认都是静态库
|
246
|
+
# def http_gitlib_GitHub_iOS_path
|
247
|
+
# 'https://gitlab.xxx.com/Github-iOS/'
|
248
|
+
# end
|
249
|
+
|
250
|
+
#要转换的地址,iOS默认都是静态库
|
251
|
+
# def http_gitlib_iOS_path
|
252
|
+
# 'https://gitlab.xxx.com/iOS/'
|
253
|
+
# end
|
254
|
+
|
255
|
+
#==========================list begin ==============
|
256
|
+
|
257
|
+
def list
|
258
|
+
Dir.entries(source_root).each do |sub|
|
259
|
+
UI.puts "- #{sub}" unless sub.include?('.')
|
260
|
+
end
|
261
|
+
UI.puts "加载完成"
|
262
|
+
end
|
263
|
+
|
264
|
+
|
265
|
+
#==========================clean begin ==============
|
266
|
+
def all_clean
|
267
|
+
FileUtils.rm_rf(source_root) if File.directory?(source_root)
|
268
|
+
UI.puts "清理完成 #{source_root}"
|
269
|
+
end
|
270
|
+
|
271
|
+
def clean
|
272
|
+
raise "请输入要删除的组件库" if @names.nil?
|
273
|
+
@names.each do |name|
|
274
|
+
full_path = File.join(source_root,name)
|
275
|
+
if File.directory?(full_path)
|
276
|
+
FileUtils.rm_rf(full_path)
|
277
|
+
else
|
278
|
+
UI.puts "找不到 #{full_path}".yellow
|
279
|
+
end
|
280
|
+
end
|
281
|
+
UI.puts "清理完成 #{@names.to_s}"
|
282
|
+
end
|
283
|
+
|
284
|
+
private
|
285
|
+
|
286
|
+
def source_root
|
287
|
+
dir = File.join(@config.cache_root,"Source")
|
288
|
+
FileUtils.mkdir_p(dir) unless File.exist? dir
|
289
|
+
dir
|
290
|
+
end
|
291
|
+
|
292
|
+
end
|
293
|
+
end
|
294
|
+
end
|
295
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'cocoapods'
|
2
|
+
require 'cocoapods/target/pod_target'
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
class Command
|
6
|
+
class Bin < Command
|
7
|
+
class Dup < Bin
|
8
|
+
self.summary = '在Podfile目录下,查找Pods下同名资源名'
|
9
|
+
|
10
|
+
self.description = <<-DESC
|
11
|
+
在Podfile目录下,查找Pods下同名资源名
|
12
|
+
DESC
|
13
|
+
|
14
|
+
self.arguments = [
|
15
|
+
CLAide::Argument.new('NAME', false)
|
16
|
+
]
|
17
|
+
def self.options
|
18
|
+
[
|
19
|
+
['--all-clean', '删除所有已经下载的源码'],
|
20
|
+
['--clean', '删除所有指定下载的源码'],
|
21
|
+
['--list', '展示所有一级下载的源码以及其大小'],
|
22
|
+
['--source', '源码路径,本地路径,会去自动链接本地源码']
|
23
|
+
]
|
24
|
+
end
|
25
|
+
|
26
|
+
def initialize(argv)
|
27
|
+
@codeSource = argv.option('source') || nil
|
28
|
+
|
29
|
+
@config = Pod::Config.instance
|
30
|
+
|
31
|
+
super
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
def run
|
36
|
+
target_definition = Pod::Config.instance.podfile.target_definition_list[1]
|
37
|
+
|
38
|
+
user_build_configurations = target_definition.build_configurations || Target::DEFAULT_BUILD_CONFIGURATIONS
|
39
|
+
aggregateTarget = AggregateTarget.new(Pod::Config.instance.sandbox,
|
40
|
+
target_definition.uses_frameworks?,
|
41
|
+
user_build_configurations ,
|
42
|
+
nil,
|
43
|
+
target_definition.platform,
|
44
|
+
target_definition,
|
45
|
+
Pod::Config.instance.installation_root,
|
46
|
+
nil,
|
47
|
+
nil ,
|
48
|
+
user_build_configurations)
|
49
|
+
input_file = aggregateTarget.copy_resources_script_path
|
50
|
+
output_pods_suffix_txt = File.join(Pod::Config.instance.project_root,"output_pods_suffix.txt")
|
51
|
+
output_pods_uniq_txt = File.join(Pod::Config.instance.project_root,"output_pods_uniq.txt")
|
52
|
+
ignore_array = ["bundle","mp3"]
|
53
|
+
resources_path = File.join(File.dirname(File.dirname(File.dirname(__FILE__))),"resources")
|
54
|
+
shell_file = File.join(resources_path,"Pods-check-deduplication-resources.sh")
|
55
|
+
#ruby 调用shell 文件、命令传入
|
56
|
+
# stdout shell 脚本输出的文本
|
57
|
+
# status 退出的状态
|
58
|
+
stdout, status = Open3.capture2('/bin/sh',
|
59
|
+
"#{shell_file}",
|
60
|
+
"#{input_file}",
|
61
|
+
"#{output_pods_suffix_txt}",
|
62
|
+
"#{output_pods_uniq_txt}",
|
63
|
+
"#{ignore_array}")
|
64
|
+
|
65
|
+
#重复资源 抛出异常
|
66
|
+
if status.to_i != 0
|
67
|
+
raise "由于权限不足,请手动创建 后重试"
|
68
|
+
else #重复资源,警告
|
69
|
+
raise "由于权限不足,请手动创建 后重试"
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'cocoapods-bb-bin/config/config_hot_key_asker'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Bin < Command
|
6
|
+
class Imy < Bin
|
7
|
+
self.summary = '快捷键'
|
8
|
+
self.description = <<-DESC
|
9
|
+
创建 文件,在其中保存插件需要的配置信息,
|
10
|
+
如二进制私有源地址、源码私有源地址等。
|
11
|
+
DESC
|
12
|
+
|
13
|
+
self.arguments = [
|
14
|
+
CLAide::Argument.new('1', false)
|
15
|
+
]
|
16
|
+
|
17
|
+
def self.options
|
18
|
+
[
|
19
|
+
].concat(super)
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize(argv)
|
23
|
+
@hot_key = argv.shift_argument || '1'
|
24
|
+
super
|
25
|
+
end
|
26
|
+
|
27
|
+
def run
|
28
|
+
CBin.config_hot_key.set_hot_key_index(@hot_key)
|
29
|
+
UI.puts "cd #{CBin.config_hot_key.hot_key_dir}".yellow
|
30
|
+
|
31
|
+
if Dir.exist?(CBin.config_hot_key.hot_key_dir)
|
32
|
+
Dir.chdir(CBin.config_hot_key.hot_key_dir) do
|
33
|
+
UI.puts " #{CBin.config_hot_key.hot_key_cmd}".yellow
|
34
|
+
system CBin.config_hot_key.hot_key_cmd
|
35
|
+
end
|
36
|
+
else
|
37
|
+
raise "配置项中文件目录不存在 #{CBin.config_hot_key.hot_key_dir}"
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'cocoapods-bb-bin/config/config_asker'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Bin < Command
|
6
|
+
class Init < Bin
|
7
|
+
self.summary = '初始化插件的快捷键.'
|
8
|
+
self.description = <<-DESC
|
9
|
+
创建 文件,在其中保存插件需要的配置信息,
|
10
|
+
如快捷键1 快捷键2 所对应执行的命令
|
11
|
+
DESC
|
12
|
+
|
13
|
+
def self.options
|
14
|
+
[
|
15
|
+
['--bin-url=URL', '配置文件地址,直接从此地址下载配置文件']
|
16
|
+
].concat(super)
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize(argv)
|
20
|
+
@bin_url = argv.option('bin-url')
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
def run
|
25
|
+
if @bin_url.nil?
|
26
|
+
config_with_asker
|
27
|
+
else
|
28
|
+
config_with_url(@bin_url)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def config_with_url(url)
|
35
|
+
require 'open-uri'
|
36
|
+
|
37
|
+
UI.puts "开始下载配置文件...\n"
|
38
|
+
file = open(url)
|
39
|
+
contents = YAML.safe_load(file.read)
|
40
|
+
|
41
|
+
UI.puts "开始同步配置文件...\n"
|
42
|
+
CBin.config.sync_config(contents.to_hash)
|
43
|
+
UI.puts "设置完成.\n".green
|
44
|
+
rescue Errno::ENOENT => e
|
45
|
+
raise Informative, "配置文件路径 #{url} 无效,请确认后重试."
|
46
|
+
end
|
47
|
+
|
48
|
+
def config_with_asker
|
49
|
+
asker = CBin::Config::Asker.new
|
50
|
+
asker.wellcome_message
|
51
|
+
|
52
|
+
config = {}
|
53
|
+
template_hash = CBin.config.template_hash
|
54
|
+
template_hash.each do |k, v|
|
55
|
+
default = begin
|
56
|
+
CBin.config.send(k)
|
57
|
+
rescue StandardError
|
58
|
+
nil
|
59
|
+
end
|
60
|
+
config[k] = asker.ask_with_answer(v[:description], default, v[:selection])
|
61
|
+
end
|
62
|
+
|
63
|
+
CBin.config.sync_config(config)
|
64
|
+
asker.done_message
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
|
2
|
+
require 'cocoapods-bb-bin/config/config_hot_key_asker'
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
class Command
|
6
|
+
class Bin < Command
|
7
|
+
class Inithk < Bin
|
8
|
+
self.summary = '初始化快捷键配置.'
|
9
|
+
self.description = <<-DESC
|
10
|
+
创建 文件,在其中保存插件需要的配置信息,
|
11
|
+
如二进制私有源地址、源码私有源地址等。
|
12
|
+
DESC
|
13
|
+
|
14
|
+
def self.options
|
15
|
+
[
|
16
|
+
['--bin-url=URL', '配置文件地址,直接从此地址下载配置文件']
|
17
|
+
].concat(super)
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(argv)
|
21
|
+
@bin_url = argv.option('bin-url')
|
22
|
+
super
|
23
|
+
end
|
24
|
+
|
25
|
+
def run
|
26
|
+
if @bin_url.nil?
|
27
|
+
config_with_asker
|
28
|
+
else
|
29
|
+
config_with_url(@bin_url)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def config_with_url(url)
|
36
|
+
require 'open-uri'
|
37
|
+
|
38
|
+
UI.puts "开始下载配置文件...\n"
|
39
|
+
file = open(url)
|
40
|
+
contents = YAML.safe_load(file.read)
|
41
|
+
|
42
|
+
UI.puts "开始同步配置文件...\n"
|
43
|
+
CBin.config_hot_key.sync_config(contents.to_hash)
|
44
|
+
UI.puts "设置完成.\n".green
|
45
|
+
rescue Errno::ENOENT => e
|
46
|
+
raise Informative, "配置文件路径 #{url} 无效,请确认后重试."
|
47
|
+
end
|
48
|
+
|
49
|
+
def config_with_asker
|
50
|
+
asker = CBin::Config_Hot_Key::Asker.new
|
51
|
+
asker.wellcome_message
|
52
|
+
|
53
|
+
config = {}
|
54
|
+
template_hash = CBin.config_hot_key.template_hash
|
55
|
+
template_hash.each do |k, v|
|
56
|
+
default = begin
|
57
|
+
CBin.config_hot_key.send(k)
|
58
|
+
rescue StandardError
|
59
|
+
nil
|
60
|
+
end
|
61
|
+
config[k] = asker.ask_with_answer(v[:description], default, v[:selection])
|
62
|
+
end
|
63
|
+
|
64
|
+
CBin.config_hot_key.sync_config(config)
|
65
|
+
asker.done_message
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
|
2
|
+
require 'cocoapods-bb-bin/command/bin/update'
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Bin < Command
|
6
|
+
class Install < Bin
|
7
|
+
include Pod
|
8
|
+
|
9
|
+
self.summary = 'pod install 拦截器,会加载本地Podfile_local文件,DSL加载到原始Podfile文件中。'
|
10
|
+
|
11
|
+
self.description = <<-DESC
|
12
|
+
pod install 拦截器,会加载本地Podfile_local文件
|
13
|
+
会通过DSL加载到原始Podfile文件中
|
14
|
+
支持 pod 'xxx' 各种写法
|
15
|
+
支持 post_install/pre_install钩子,采用覆盖做法
|
16
|
+
DESC
|
17
|
+
def self.options
|
18
|
+
[
|
19
|
+
['--repo-update', 'Force running `pod repo update` before install'],
|
20
|
+
['--deployment', 'Disallow any changes to the Podfile or the Podfile.lock during installation'],
|
21
|
+
['--clean-install', 'Ignore the contents of the project cache and force a full pod installation. This only ' \
|
22
|
+
'applies to projects that have enabled incremental installation']
|
23
|
+
].concat(super).reject { |(name, _)| name == '--no-repo-update' }
|
24
|
+
end
|
25
|
+
|
26
|
+
def initialize(argv)
|
27
|
+
@update = argv.flag?('update')
|
28
|
+
super
|
29
|
+
@additional_args = argv.remainder!
|
30
|
+
end
|
31
|
+
|
32
|
+
def run
|
33
|
+
Update.load_local_podfile
|
34
|
+
argvs = [
|
35
|
+
*@additional_args
|
36
|
+
]
|
37
|
+
gen = Pod::Command::Install.new(CLAide::ARGV.new(argvs))
|
38
|
+
gen.validate!
|
39
|
+
gen.run
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'cocoapods-bb-bin/config/config'
|
2
|
+
require 'cocoapods-bb-bin/native/podfile'
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
class Command
|
6
|
+
class Bin < Command
|
7
|
+
class Lib < Bin
|
8
|
+
class Lint < Lib
|
9
|
+
self.summary = 'lint 组件.'
|
10
|
+
self.description = <<-DESC
|
11
|
+
lint 二进制组件 / 源码组件
|
12
|
+
DESC
|
13
|
+
|
14
|
+
self.arguments = [
|
15
|
+
CLAide::Argument.new('NAME.podspec', false)
|
16
|
+
]
|
17
|
+
|
18
|
+
# lib lint 不会下载 source,所以不能进行二进制 lint
|
19
|
+
# 要 lint 二进制版本,需要进行 spec lint,此 lint 会去下载 source
|
20
|
+
def self.options
|
21
|
+
[
|
22
|
+
['--code-dependencies', '使用源码依赖进行 lint'],
|
23
|
+
['--loose-options', '添加宽松的 options, 包括 --use-libraries (可能会造成 entry point (start) undefined)'],
|
24
|
+
['--allow-prerelease', '允许使用 prerelease 的版本 lint']
|
25
|
+
].concat(Pod::Command::Lib::Lint.options).concat(super).uniq
|
26
|
+
end
|
27
|
+
|
28
|
+
def initialize(argv)
|
29
|
+
@loose_options = argv.flag?('loose-options')
|
30
|
+
@code_dependencies = argv.flag?('code-dependencies')
|
31
|
+
@sources = argv.option('sources') || []
|
32
|
+
@allow_prerelease = argv.flag?('allow-prerelease')
|
33
|
+
@podspec = argv.shift_argument
|
34
|
+
super
|
35
|
+
|
36
|
+
@additional_args = argv.remainder!
|
37
|
+
end
|
38
|
+
|
39
|
+
def run
|
40
|
+
Podfile.execute_with_bin_plugin do
|
41
|
+
Podfile.execute_with_allow_prerelease(@allow_prerelease) do
|
42
|
+
Podfile.execute_with_use_binaries(!@code_dependencies) do
|
43
|
+
argvs = [
|
44
|
+
@podspec || code_spec_files.first,
|
45
|
+
"--sources=#{sources_option(@code_dependencies, @sources)}",
|
46
|
+
*@additional_args
|
47
|
+
]
|
48
|
+
|
49
|
+
if @loose_options
|
50
|
+
argvs << '--allow-warnings'
|
51
|
+
if code_spec&.all_dependencies&.any?
|
52
|
+
argvs << '--use-libraries'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
lint = Pod::Command::Lib::Lint.new(CLAide::ARGV.new(argvs))
|
57
|
+
lint.validate!
|
58
|
+
lint.run
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|