cocoapods-hllsource 0.0.1
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 +7 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +118 -0
- data/LICENSE.txt +22 -0
- data/README.md +11 -0
- data/Rakefile +13 -0
- data/cocoapods-hllsource.gemspec +23 -0
- data/lib/cocoapods-hllsource/command/hllsource.rb +501 -0
- data/lib/cocoapods-hllsource/command.rb +1 -0
- data/lib/cocoapods-hllsource/gem_version.rb +3 -0
- data/lib/cocoapods-hllsource.rb +1 -0
- data/lib/cocoapods_plugin.rb +1 -0
- data/spec/command/hllsource_spec.rb +12 -0
- data/spec/spec_helper.rb +50 -0
- metadata +86 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f72b3a9392838aba93e0af6ef67c8a461565727ae69ec37bd6085c398a91553c
|
4
|
+
data.tar.gz: feafdae37b37005825f5436a92827940d4bcf1a5d79948ab90b502b5b2a5b699
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 41946a176fd2401831702f760100b9fed982e0d5aa96bb5aca5768d749da1b1ea20b5eeac85b292a253e6855d91801e4b4c1b65c2463e3e161e0989acfae46e7
|
7
|
+
data.tar.gz: c995c046713d73e06d29f6af84fb7a8cf2764f377dce2b0a7ca9270828eeeaad3705d1e6f4d6be3c62ea40b5dc9f5ae9080c90764ba67842862c3c647275bc58
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
cocoapods-hllsource (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
CFPropertyList (3.0.5)
|
10
|
+
rexml
|
11
|
+
activesupport (6.1.4.4)
|
12
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
|
+
i18n (>= 1.6, < 2)
|
14
|
+
minitest (>= 5.1)
|
15
|
+
tzinfo (~> 2.0)
|
16
|
+
zeitwerk (~> 2.3)
|
17
|
+
addressable (2.8.0)
|
18
|
+
public_suffix (>= 2.0.2, < 5.0)
|
19
|
+
algoliasearch (1.27.5)
|
20
|
+
httpclient (~> 2.8, >= 2.8.3)
|
21
|
+
json (>= 1.5.1)
|
22
|
+
atomos (0.1.3)
|
23
|
+
bacon (1.2.0)
|
24
|
+
claide (1.0.3)
|
25
|
+
cocoapods (1.11.2)
|
26
|
+
addressable (~> 2.8)
|
27
|
+
claide (>= 1.0.2, < 2.0)
|
28
|
+
cocoapods-core (= 1.11.2)
|
29
|
+
cocoapods-deintegrate (>= 1.0.3, < 2.0)
|
30
|
+
cocoapods-downloader (>= 1.4.0, < 2.0)
|
31
|
+
cocoapods-plugins (>= 1.0.0, < 2.0)
|
32
|
+
cocoapods-search (>= 1.0.0, < 2.0)
|
33
|
+
cocoapods-trunk (>= 1.4.0, < 2.0)
|
34
|
+
cocoapods-try (>= 1.1.0, < 2.0)
|
35
|
+
colored2 (~> 3.1)
|
36
|
+
escape (~> 0.0.4)
|
37
|
+
fourflusher (>= 2.3.0, < 3.0)
|
38
|
+
gh_inspector (~> 1.0)
|
39
|
+
molinillo (~> 0.8.0)
|
40
|
+
nap (~> 1.0)
|
41
|
+
ruby-macho (>= 1.0, < 3.0)
|
42
|
+
xcodeproj (>= 1.21.0, < 2.0)
|
43
|
+
cocoapods-core (1.11.2)
|
44
|
+
activesupport (>= 5.0, < 7)
|
45
|
+
addressable (~> 2.8)
|
46
|
+
algoliasearch (~> 1.0)
|
47
|
+
concurrent-ruby (~> 1.1)
|
48
|
+
fuzzy_match (~> 2.0.4)
|
49
|
+
nap (~> 1.0)
|
50
|
+
netrc (~> 0.11)
|
51
|
+
public_suffix (~> 4.0)
|
52
|
+
typhoeus (~> 1.0)
|
53
|
+
cocoapods-deintegrate (1.0.5)
|
54
|
+
cocoapods-downloader (1.5.1)
|
55
|
+
cocoapods-plugins (1.0.0)
|
56
|
+
nap
|
57
|
+
cocoapods-search (1.0.1)
|
58
|
+
cocoapods-trunk (1.6.0)
|
59
|
+
nap (>= 0.8, < 2.0)
|
60
|
+
netrc (~> 0.11)
|
61
|
+
cocoapods-try (1.2.0)
|
62
|
+
colored2 (3.1.2)
|
63
|
+
concurrent-ruby (1.1.9)
|
64
|
+
escape (0.0.4)
|
65
|
+
ethon (0.15.0)
|
66
|
+
ffi (>= 1.15.0)
|
67
|
+
ffi (1.15.4)
|
68
|
+
fourflusher (2.3.1)
|
69
|
+
fuzzy_match (2.0.4)
|
70
|
+
gh_inspector (1.1.3)
|
71
|
+
httpclient (2.8.3)
|
72
|
+
i18n (1.8.11)
|
73
|
+
concurrent-ruby (~> 1.0)
|
74
|
+
json (2.6.1)
|
75
|
+
minitest (5.15.0)
|
76
|
+
mocha (1.13.0)
|
77
|
+
mocha-on-bacon (0.2.3)
|
78
|
+
mocha (>= 0.13.0)
|
79
|
+
molinillo (0.8.0)
|
80
|
+
nanaimo (0.3.0)
|
81
|
+
nap (1.1.0)
|
82
|
+
netrc (0.11.0)
|
83
|
+
prettybacon (0.0.2)
|
84
|
+
bacon (~> 1.2)
|
85
|
+
public_suffix (4.0.6)
|
86
|
+
rake (13.0.6)
|
87
|
+
rexml (3.2.5)
|
88
|
+
ruby-macho (2.5.1)
|
89
|
+
rubyzip (2.3.2)
|
90
|
+
typhoeus (1.4.0)
|
91
|
+
ethon (>= 0.9.0)
|
92
|
+
tzinfo (2.0.4)
|
93
|
+
concurrent-ruby (~> 1.0)
|
94
|
+
xcodeproj (1.21.0)
|
95
|
+
CFPropertyList (>= 2.3.3, < 4.0)
|
96
|
+
atomos (~> 0.1.3)
|
97
|
+
claide (>= 1.0.2, < 2.0)
|
98
|
+
colored2 (~> 3.1)
|
99
|
+
nanaimo (~> 0.3.0)
|
100
|
+
rexml (~> 3.2.4)
|
101
|
+
zeitwerk (2.5.1)
|
102
|
+
|
103
|
+
PLATFORMS
|
104
|
+
ruby
|
105
|
+
|
106
|
+
DEPENDENCIES
|
107
|
+
bacon
|
108
|
+
bundler (~> 1.3)
|
109
|
+
cocoapods
|
110
|
+
cocoapods-hllsource!
|
111
|
+
mocha
|
112
|
+
mocha-on-bacon
|
113
|
+
prettybacon
|
114
|
+
rake
|
115
|
+
rubyzip
|
116
|
+
|
117
|
+
BUNDLED WITH
|
118
|
+
1.17.3
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2021 lihao <ablelh@163.com>
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cocoapods-hllsource/gem_version.rb'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'cocoapods-hllsource'
|
8
|
+
spec.version = CocoapodsHllsource::VERSION
|
9
|
+
spec.authors = ['lihao']
|
10
|
+
spec.email = ['ablelh@163.com']
|
11
|
+
spec.description = %q{A short description of cocoapods-hllsource.}
|
12
|
+
spec.summary = %q{A longer description of cocoapods-hllsource.}
|
13
|
+
spec.homepage = 'https://github.com/EXAMPLE/cocoapods-hllsource'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
22
|
+
spec.add_development_dependency 'rake'
|
23
|
+
end
|
@@ -0,0 +1,501 @@
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
|
+
module Pod
|
3
|
+
class Command
|
4
|
+
# This is an example of a cocoapods plugin adding a top-level subcommand
|
5
|
+
# to the 'pod' command.
|
6
|
+
#
|
7
|
+
# You can also create subcommands of existing or new commands. Say you
|
8
|
+
# wanted to add a subcommand to `list` to show newly deprecated pods,
|
9
|
+
# (e.g. `pod list deprecated`), there are a few things that would need
|
10
|
+
# to change.
|
11
|
+
#
|
12
|
+
# - move this file to `lib/pod/command/list/deprecated.rb` and update
|
13
|
+
# the class to exist in the the Pod::Command::List namespace
|
14
|
+
# - change this class to extend from `List` instead of `Command`. This
|
15
|
+
# tells the plugin system that it is a subcommand of `list`.
|
16
|
+
# - edit `lib/cocoapods_plugins.rb` to require this file
|
17
|
+
#
|
18
|
+
# @todo Create a PR to add your plugin to CocoaPods/cocoapods.org
|
19
|
+
# in the `plugins.json` file, once your plugin is released.
|
20
|
+
#
|
21
|
+
require 'open-uri'
|
22
|
+
require 'net/http'
|
23
|
+
|
24
|
+
class Hllsource < Command
|
25
|
+
|
26
|
+
autoload :Analyzer, 'cocoapods/installer/analyzer'
|
27
|
+
|
28
|
+
self.summary = '二进制库源码映射工具'
|
29
|
+
|
30
|
+
self.description = <<-DESC
|
31
|
+
二进制库源码映射工具.
|
32
|
+
DESC
|
33
|
+
|
34
|
+
self.arguments = [
|
35
|
+
CLAide::Argument.new('LIB_NAME', false)
|
36
|
+
]
|
37
|
+
|
38
|
+
def self.options
|
39
|
+
[
|
40
|
+
['--list', '查询所有已映射源码库'],
|
41
|
+
['--remove', '删除源码映射(多个空格隔开)'],
|
42
|
+
['--remove-all', '删除所有源码映射'],
|
43
|
+
]
|
44
|
+
end
|
45
|
+
|
46
|
+
def initialize(argv)
|
47
|
+
|
48
|
+
@names = argv.arguments! unless argv.arguments.empty?
|
49
|
+
@list = argv.flag?('list', false)
|
50
|
+
@link = argv.flag?('link', false)
|
51
|
+
@remove = argv.flag?('remove', false)
|
52
|
+
@remove_all = argv.flag?('remove-all', false)
|
53
|
+
@lib_version = argv.flag?('lib-version', false)
|
54
|
+
|
55
|
+
@config = Pod::Config.instance
|
56
|
+
super
|
57
|
+
end
|
58
|
+
|
59
|
+
def validate!
|
60
|
+
super
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
def run
|
65
|
+
|
66
|
+
if @link && @list && @remove && @remove_all && @lib_version
|
67
|
+
UI.puts "[Error] 请选择合适的命令, 不支持同时多个Option\n".red
|
68
|
+
help!
|
69
|
+
return
|
70
|
+
end
|
71
|
+
|
72
|
+
if @list
|
73
|
+
# analyzerPodFileLock
|
74
|
+
linked_list
|
75
|
+
elsif @remove
|
76
|
+
# analyzerPodFileLock
|
77
|
+
linked_remove
|
78
|
+
elsif @remove_all
|
79
|
+
# analyzerPodFileLock
|
80
|
+
linked_remove_all
|
81
|
+
elsif @lib_version
|
82
|
+
# analyzerPodFileLock
|
83
|
+
read_podfile_lock_version
|
84
|
+
elsif @names
|
85
|
+
# analyzerPodFileLock
|
86
|
+
linkLibSource
|
87
|
+
else
|
88
|
+
help!
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def linkLibSource
|
93
|
+
|
94
|
+
if @names.nil?
|
95
|
+
UI.puts "[Error] 请输入需要映射的组件库. 示例: $ pod hllsource xxx foo\n".red
|
96
|
+
return
|
97
|
+
else
|
98
|
+
if @names.count > 1
|
99
|
+
UI.puts "[Error] 不支持一次映射多个源码. 示例: $ pod hllsource xxx foo\n".red
|
100
|
+
return
|
101
|
+
end
|
102
|
+
end
|
103
|
+
user_lib_name = @names.first.chomp.strip
|
104
|
+
|
105
|
+
is_contain_lib = linked_list_contain(user_lib_name)
|
106
|
+
if is_contain_lib
|
107
|
+
UI.puts "\n[Error] #{user_lib_name} 已映射, 如需重新映射,请先删除\n\n".red
|
108
|
+
return
|
109
|
+
else
|
110
|
+
# UI.puts "\n#{project_name} Using ".green "#{user_lib_name} )\n".green
|
111
|
+
end
|
112
|
+
|
113
|
+
config = config_with_asker
|
114
|
+
lib_path = config["libPath"]
|
115
|
+
sourcePath = config["sourcePath"]
|
116
|
+
lib_name = source_lib_name(lib_path)
|
117
|
+
lib_real_path = ""
|
118
|
+
if Pathname.new(lib_path).extname == ".framework"
|
119
|
+
lib_real_path = "#{lib_path}/#{lib_name}"
|
120
|
+
elsif Pathname.new(lib_path).extname == ".a"
|
121
|
+
lib_real_path = lib_path
|
122
|
+
end
|
123
|
+
#下载指定源码
|
124
|
+
pathAry = download_source_code(sourcePath)
|
125
|
+
sourcePath = pathAry.first
|
126
|
+
lib_name = pathAry.last
|
127
|
+
if lib_real_path == "" || !File.exist?(lib_real_path)
|
128
|
+
UI.puts "\n[Error] 二进制文件不存在, 请检查文件位置!\n".red
|
129
|
+
return
|
130
|
+
end
|
131
|
+
|
132
|
+
if sourcePath == "" || !File.exist?(sourcePath)
|
133
|
+
UI.puts "\n[Error] 源码文件不存在, 请检查文件位置!\n".red
|
134
|
+
return
|
135
|
+
end
|
136
|
+
|
137
|
+
if sourcePath == "" || !File.exist?(sourcePath)
|
138
|
+
UI.puts "\n[Error] 源码文件不存在, 请检查文件位置!\n".red
|
139
|
+
return
|
140
|
+
end
|
141
|
+
link_source_code(lib_real_path, sourcePath, lib_name)
|
142
|
+
end
|
143
|
+
|
144
|
+
def download_source_code(sourcePath)
|
145
|
+
|
146
|
+
oldFilePath = FileUtils.getwd
|
147
|
+
filePath = FileUtils.getwd + '/temp'
|
148
|
+
path = filePath + '/temp.zip'
|
149
|
+
FileUtils.mkdir_p(filePath)
|
150
|
+
Dir.chdir(filePath)
|
151
|
+
`curl -o temp.zip -L "#{sourcePath}"`
|
152
|
+
`unzip temp.zip`
|
153
|
+
`rm -rf "#{path}"`
|
154
|
+
|
155
|
+
files_name=Dir.entries(filePath)
|
156
|
+
targetPath = "#{filePath}" +'/'+ "#{files_name.last}"
|
157
|
+
Dir.chdir(oldFilePath)
|
158
|
+
return targetPath,files_name.last
|
159
|
+
|
160
|
+
end
|
161
|
+
|
162
|
+
|
163
|
+
def link_source_code(lib_path, sourcePath, lib_name)
|
164
|
+
|
165
|
+
comp_dir_path = `dwarfdump "#{lib_path}" | grep "AT_comp_dir" | head -1 | cut -d \\" -f2`
|
166
|
+
if comp_dir_path == nil || comp_dir_path == ""
|
167
|
+
UI.puts "\n[Error] #{lib_name} Generate Debug Symbols = NO 不支持映射源码 \n".red
|
168
|
+
return
|
169
|
+
end
|
170
|
+
|
171
|
+
lib_debug_path = comp_dir_path.chomp.strip.encode(Encoding.find('UTF-8'), {invalid: :replace, undef: :replace, replace: ''})
|
172
|
+
|
173
|
+
if File.exist?(lib_debug_path) || File.directory?(lib_debug_path)
|
174
|
+
if File.symlink?(lib_debug_path)
|
175
|
+
UI.puts "源码映射已存在, 无法重复映射,请删除后重新映射: #{lib_debug_path}"
|
176
|
+
else
|
177
|
+
UI.puts "源码映射目录已存在, 请检查 #{lib_debug_path} 目录(可能存在以下情况):"
|
178
|
+
UI.puts "\n1、开发源码(无需映射,即可调试) \n2、其他重复文件, 请手动移动/移除\n".red
|
179
|
+
end
|
180
|
+
else
|
181
|
+
|
182
|
+
begin
|
183
|
+
|
184
|
+
FileUtils.mkdir_p(lib_debug_path)
|
185
|
+
rescue SystemCallError
|
186
|
+
array = lib_debug_path.split('/')
|
187
|
+
if array.length > 3
|
188
|
+
root_path = '/' + array[1] + '/' + array[2]
|
189
|
+
unless File.exist?(root_path)
|
190
|
+
UI.puts "[Error] 无权限创建文件夹,请手动创建#{root_path}文件夹,再重试\n".red
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
FileUtils.rm_rf(lib_debug_path)
|
196
|
+
FileUtils.mv(sourcePath, lib_debug_path)
|
197
|
+
check_linked(lib_path, lib_debug_path, lib_name)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def check_linked(lib_path, sourcePath, lib_name)
|
202
|
+
|
203
|
+
if File.exist?(sourcePath)
|
204
|
+
UI.puts "🍺🍺🍺 Successfully! 源码映射成功\n".green
|
205
|
+
recordLinknSuccessLib(lib_name, lib_path, sourcePath)
|
206
|
+
#删除已下载的文件
|
207
|
+
FileUtils.remove_dir(FileUtils.getwd + '/temp')
|
208
|
+
else
|
209
|
+
UI.puts "[Error] 源码 #{source_path} 不存在, 请检查源码版本 或 存储位置\n".red
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
|
214
|
+
# 移除单个映射
|
215
|
+
def linked_remove
|
216
|
+
if @names.nil?
|
217
|
+
UI.puts "[Error] 请输入要删除的组件库. 实例: $ pod hllsource --remove xxx yyy zzz\n".red
|
218
|
+
return
|
219
|
+
end
|
220
|
+
|
221
|
+
@names.each do |name|
|
222
|
+
|
223
|
+
lib_linked_path = get_lib_linked_path(name)
|
224
|
+
if lib_linked_path.nil? || lib_linked_path == ""
|
225
|
+
UI.puts "[Error] #{name} 的映射不存在, 无需移除".red
|
226
|
+
else
|
227
|
+
if File.exist?(lib_linked_path) && File.symlink?(lib_linked_path)
|
228
|
+
FileUtils.rm_rf(lib_linked_path)
|
229
|
+
removeLinkedFileRecord(name)
|
230
|
+
UI.puts "#{name} 成功移除".green
|
231
|
+
else
|
232
|
+
UI.puts "[Error] #{name} 的映射不存在, 请手动核查: #{lib_linked_path}".red
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
print "\n"
|
237
|
+
end
|
238
|
+
|
239
|
+
|
240
|
+
# 移除所有映射
|
241
|
+
def linked_remove_all
|
242
|
+
|
243
|
+
if File.exist?(source_record_file_path)
|
244
|
+
records = JSON.parse(File.read(source_record_file_path))
|
245
|
+
|
246
|
+
if records.count > 0
|
247
|
+
records.each.with_index(0) do |record, index|
|
248
|
+
lib_linked_path = record["source_path"]
|
249
|
+
lib_name = record["lib_name"]
|
250
|
+
if File.exist?(lib_linked_path) && File.symlink?(lib_linked_path)
|
251
|
+
FileUtils.rm_rf(lib_linked_path)
|
252
|
+
removeLinkedFileRecord(lib_name)
|
253
|
+
UI.puts "#{lib_name} removing...".green
|
254
|
+
end
|
255
|
+
end
|
256
|
+
UI.puts "\n已全部移除\n".green
|
257
|
+
else
|
258
|
+
UI.puts "\n无记录\n".green
|
259
|
+
end
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
|
264
|
+
# 查询映射列表
|
265
|
+
def linked_list
|
266
|
+
|
267
|
+
if File.exist?(source_record_file_path)
|
268
|
+
records = JSON.parse(File.read(source_record_file_path))
|
269
|
+
if records.count > 0
|
270
|
+
records.each.with_index(1) do |record, index|
|
271
|
+
lib_version_s = record["lib_version"]
|
272
|
+
lib_version_s = (lib_version_s == nil || lib_version_s == '') ? "" : "(#{lib_version_s})"
|
273
|
+
UI.puts "#{index}. #{record["lib_name"]} #{lib_version_s} ".green "Source: #{record["source_path"]}".yellow
|
274
|
+
end
|
275
|
+
else
|
276
|
+
UI.puts "\n无记录".green
|
277
|
+
end
|
278
|
+
else
|
279
|
+
UI.puts "\n无记录".green
|
280
|
+
end
|
281
|
+
print "\n"
|
282
|
+
end
|
283
|
+
|
284
|
+
|
285
|
+
def linked_list_contain(lib_name)
|
286
|
+
|
287
|
+
is_contain_lib = false
|
288
|
+
if File.exist?(source_record_file_path)
|
289
|
+
records = JSON.parse(File.read(source_record_file_path))
|
290
|
+
records.each.with_index(1) do |record, index|
|
291
|
+
if record["lib_name"] == lib_name
|
292
|
+
is_contain_lib = true
|
293
|
+
break
|
294
|
+
end
|
295
|
+
end
|
296
|
+
end
|
297
|
+
is_contain_lib
|
298
|
+
end
|
299
|
+
|
300
|
+
def source_root
|
301
|
+
cache_root_dir_name = ".hllsource"
|
302
|
+
user_home_path = Dir.home
|
303
|
+
cache_root_path = File.join(user_home_path, cache_root_dir_name);
|
304
|
+
FileUtils.mkdir_p(cache_root_path) unless File.exist? cache_root_path
|
305
|
+
cache_root_path
|
306
|
+
end
|
307
|
+
|
308
|
+
def source_record_file_path
|
309
|
+
source_r_path = File.join(source_root.to_s, 'hll _source_links.json')
|
310
|
+
source_r_path
|
311
|
+
end
|
312
|
+
|
313
|
+
def source_lib_name(filePath)
|
314
|
+
file_name = ""
|
315
|
+
if Pathname.new(filePath).extname == ".framework"
|
316
|
+
file_name = File.basename(filePath, ".framework")
|
317
|
+
elsif Pathname.new(filePath).extname == ".a"
|
318
|
+
file_name = File.basename(filePath, ".a")
|
319
|
+
file_name = file_name[3..file_name.length]
|
320
|
+
end
|
321
|
+
file_name
|
322
|
+
end
|
323
|
+
|
324
|
+
def project_name
|
325
|
+
targets = @aggregate_targets.map(&:user_project_path).compact.uniq
|
326
|
+
project_name = ""
|
327
|
+
if targets.count == 1
|
328
|
+
project_name = targets.first.basename('.xcodeproj')
|
329
|
+
end
|
330
|
+
project_name
|
331
|
+
end
|
332
|
+
|
333
|
+
def recordLinknSuccessLib(lib_name, lib_path, sourcePath)
|
334
|
+
|
335
|
+
if File.exist?(source_record_file_path)
|
336
|
+
record = JSON.parse(File.read(source_record_file_path))
|
337
|
+
|
338
|
+
record_libNames = Array.new
|
339
|
+
record.each do |sub|
|
340
|
+
record_libNames.push(sub['lib_name'])
|
341
|
+
end
|
342
|
+
|
343
|
+
if record_libNames.include?(lib_name)
|
344
|
+
|
345
|
+
replace_index = record_libNames.index(lib_name)
|
346
|
+
record[replace_index] = generate_record_item(lib_name, lib_path, sourcePath)
|
347
|
+
record_item_json = JSON.generate(record)
|
348
|
+
|
349
|
+
FileUtils.rm_rf(source_record_file_path) if File.exist?(source_record_file_path)
|
350
|
+
File.open(source_record_file_path, 'w') { |file| file.write(record_item_json)}
|
351
|
+
else
|
352
|
+
|
353
|
+
record.push(generate_record_item(lib_name, lib_path, sourcePath))
|
354
|
+
record_item_json = JSON.generate(record)
|
355
|
+
|
356
|
+
FileUtils.rm_rf(source_record_file_path) if File.exist?(source_record_file_path)
|
357
|
+
File.open(source_record_file_path, 'w') { |file| file.write(record_item_json)}
|
358
|
+
end
|
359
|
+
else
|
360
|
+
record_items = Array.new
|
361
|
+
record_items.push(generate_record_item(lib_name, lib_path, sourcePath))
|
362
|
+
record_item_json = JSON.generate(record_items)
|
363
|
+
File.open(source_record_file_path, 'w') { |file| file.write(record_item_json)}
|
364
|
+
end
|
365
|
+
end
|
366
|
+
|
367
|
+
def generate_record_item(lib_name, lib_path, source_path)
|
368
|
+
lib_version = get_lib_version(lib_name.chomp.strip)
|
369
|
+
record_item = {:lib_name => lib_name, :lib_version => lib_version, :lib_path => lib_path, :source_path => source_path}
|
370
|
+
record_item
|
371
|
+
end
|
372
|
+
|
373
|
+
def removeLinkedFileRecord(lib_name)
|
374
|
+
|
375
|
+
if File.exist?(source_record_file_path)
|
376
|
+
records = JSON.parse(File.read(source_record_file_path))
|
377
|
+
|
378
|
+
lib_name_index = -1
|
379
|
+
records.each.with_index(0) do |record, index|
|
380
|
+
if record["lib_name"] == lib_name
|
381
|
+
lib_name_index = index
|
382
|
+
break
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
386
|
+
if lib_name_index >= 0
|
387
|
+
records.delete_at(lib_name_index)
|
388
|
+
record_item_json = JSON.generate(records)
|
389
|
+
|
390
|
+
FileUtils.rm_rf(source_record_file_path) if File.exist?(source_record_file_path)
|
391
|
+
File.open(source_record_file_path, 'w') { |file| file.write(record_item_json)}
|
392
|
+
end
|
393
|
+
end
|
394
|
+
end
|
395
|
+
|
396
|
+
def analyzerPodFileLock
|
397
|
+
|
398
|
+
podfile_lock = File.join(Pathname.pwd, "Podfile.lock")
|
399
|
+
if File.exist?(podfile_lock)
|
400
|
+
else
|
401
|
+
UI.puts "\n[!] 未匹配到 Podfile.lock 文件, 无法获取 Pod 管理信息\n".red
|
402
|
+
return
|
403
|
+
end
|
404
|
+
@lockfile ||= Lockfile.from_file(Pathname.new(podfile_lock))
|
405
|
+
|
406
|
+
UI.section "ybin analyzer" do
|
407
|
+
analyzer = Pod::Installer::Analyzer.new(config.sandbox, config.podfile, @lockfile)
|
408
|
+
@analysis_result = analyzer.analyze
|
409
|
+
@aggregate_targets = @analysis_result.targets
|
410
|
+
@pod_targets = @analysis_result.pod_targets
|
411
|
+
end
|
412
|
+
end
|
413
|
+
|
414
|
+
def read_podfile_lock_version
|
415
|
+
if @analysis_result.nil?
|
416
|
+
return
|
417
|
+
end
|
418
|
+
|
419
|
+
UI.section "#{project_name} 通过 Cocoapods 管理的依赖库(含 dependency)版本:".yellow do
|
420
|
+
root_specs = @analysis_result.specifications.map(&:root).uniq
|
421
|
+
pods_to_install = @analysis_result.sandbox_state.added | @analysis_result.sandbox_state.changed
|
422
|
+
root_specs.sort_by(&:name).each.with_index(1) do |spec, index|
|
423
|
+
if pods_to_install.include?(spec.name)
|
424
|
+
else
|
425
|
+
UI.puts "#{index}. #{spec}".green
|
426
|
+
end
|
427
|
+
end
|
428
|
+
print "\n"
|
429
|
+
end
|
430
|
+
end
|
431
|
+
|
432
|
+
def get_lib_version(lib_name)
|
433
|
+
if @analysis_result.nil?
|
434
|
+
return
|
435
|
+
end
|
436
|
+
|
437
|
+
lib_version = ''
|
438
|
+
root_specs = @analysis_result.specifications.map(&:root).uniq
|
439
|
+
pods_to_install = @analysis_result.sandbox_state.added | @analysis_result.sandbox_state.changed
|
440
|
+
root_specs.sort_by(&:name).each.with_index(1) do |spec, index|
|
441
|
+
if pods_to_install.include?(spec.name)
|
442
|
+
else
|
443
|
+
if spec.name == lib_name
|
444
|
+
lib_version = spec.version
|
445
|
+
break
|
446
|
+
end
|
447
|
+
end
|
448
|
+
end
|
449
|
+
lib_version
|
450
|
+
end
|
451
|
+
|
452
|
+
def get_lib_linked_path(lib_name)
|
453
|
+
|
454
|
+
lib_linked_path = ""
|
455
|
+
if File.exist?(source_record_file_path)
|
456
|
+
records = JSON.parse(File.read(source_record_file_path))
|
457
|
+
records.each do |record|
|
458
|
+
if record["lib_name"] == lib_name
|
459
|
+
lib_linked_path = record["source_path"]
|
460
|
+
break
|
461
|
+
end
|
462
|
+
end
|
463
|
+
end
|
464
|
+
lib_linked_path
|
465
|
+
end
|
466
|
+
|
467
|
+
def template_source
|
468
|
+
{
|
469
|
+
'libPath' => { question: '1/2 请输入静态二进制库的路径(如:/Users/xxx/Workspace/xxx.a 或 /Users/xxx/Workspace/xxx.framework)' },
|
470
|
+
'sourcePath' => { question: '2/2 源码下载地址(maven地址)' },
|
471
|
+
}
|
472
|
+
end
|
473
|
+
|
474
|
+
|
475
|
+
def config_with_asker
|
476
|
+
config = {}
|
477
|
+
template_source.each do |k, v|
|
478
|
+
config[k] = get_require_path(v[:question])
|
479
|
+
end
|
480
|
+
print "\n"
|
481
|
+
config
|
482
|
+
end
|
483
|
+
|
484
|
+
def get_require_path(question)
|
485
|
+
|
486
|
+
Pod::UI.puts "\n#{question}".yellow
|
487
|
+
answer = ''
|
488
|
+
loop do
|
489
|
+
print "->".green
|
490
|
+
answer = STDIN.gets.chomp.strip
|
491
|
+
next if answer.empty?
|
492
|
+
break
|
493
|
+
end
|
494
|
+
answer
|
495
|
+
end
|
496
|
+
|
497
|
+
end
|
498
|
+
|
499
|
+
|
500
|
+
end
|
501
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-hllsource/command/hllsource'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-hllsource/gem_version'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-hllsource/command'
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
describe Command::Hllsource do
|
5
|
+
describe 'CLAide' do
|
6
|
+
it 'registers it self' do
|
7
|
+
Command.parse(%w{ hllsource }).should.be.instance_of Command::Hllsource
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
ROOT = Pathname.new(File.expand_path('../../', __FILE__))
|
3
|
+
$:.unshift((ROOT + 'lib').to_s)
|
4
|
+
$:.unshift((ROOT + 'spec').to_s)
|
5
|
+
|
6
|
+
require 'bundler/setup'
|
7
|
+
require 'bacon'
|
8
|
+
require 'mocha-on-bacon'
|
9
|
+
require 'pretty_bacon'
|
10
|
+
require 'pathname'
|
11
|
+
require 'cocoapods'
|
12
|
+
|
13
|
+
Mocha::Configuration.prevent(:stubbing_non_existent_method)
|
14
|
+
|
15
|
+
require 'cocoapods_plugin'
|
16
|
+
|
17
|
+
#-----------------------------------------------------------------------------#
|
18
|
+
|
19
|
+
module Pod
|
20
|
+
|
21
|
+
# Disable the wrapping so the output is deterministic in the tests.
|
22
|
+
#
|
23
|
+
UI.disable_wrap = true
|
24
|
+
|
25
|
+
# Redirects the messages to an internal store.
|
26
|
+
#
|
27
|
+
module UI
|
28
|
+
@output = ''
|
29
|
+
@warnings = ''
|
30
|
+
|
31
|
+
class << self
|
32
|
+
attr_accessor :output
|
33
|
+
attr_accessor :warnings
|
34
|
+
|
35
|
+
def puts(message = '')
|
36
|
+
@output << "#{message}\n"
|
37
|
+
end
|
38
|
+
|
39
|
+
def warn(message = '', actions = [])
|
40
|
+
@warnings << "#{message}\n"
|
41
|
+
end
|
42
|
+
|
43
|
+
def print(message)
|
44
|
+
@output << message
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
#-----------------------------------------------------------------------------#
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cocoapods-hllsource
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- lihao
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-12-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: A short description of cocoapods-hllsource.
|
42
|
+
email:
|
43
|
+
- ablelh@163.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- Gemfile
|
49
|
+
- Gemfile.lock
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- cocoapods-hllsource.gemspec
|
54
|
+
- lib/cocoapods-hllsource.rb
|
55
|
+
- lib/cocoapods-hllsource/command.rb
|
56
|
+
- lib/cocoapods-hllsource/command/hllsource.rb
|
57
|
+
- lib/cocoapods-hllsource/gem_version.rb
|
58
|
+
- lib/cocoapods_plugin.rb
|
59
|
+
- spec/command/hllsource_spec.rb
|
60
|
+
- spec/spec_helper.rb
|
61
|
+
homepage: https://github.com/EXAMPLE/cocoapods-hllsource
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
metadata: {}
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubygems_version: 3.0.9
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: A longer description of cocoapods-hllsource.
|
84
|
+
test_files:
|
85
|
+
- spec/command/hllsource_spec.rb
|
86
|
+
- spec/spec_helper.rb
|