cocoapods-jsource 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +98 -0
- data/LICENSE.txt +22 -0
- data/README.md +11 -0
- data/Rakefile +13 -0
- data/cocoapods-jsource.gemspec +23 -0
- data/lib/cocoapods-jsource.rb +1 -0
- data/lib/cocoapods-jsource/command.rb +1 -0
- data/lib/cocoapods-jsource/command/jsource.rb +81 -0
- data/lib/cocoapods-jsource/command/jsource/add.rb +131 -0
- data/lib/cocoapods-jsource/command/jsource/clean.rb +109 -0
- data/lib/cocoapods-jsource/command/jsource/list.rb +50 -0
- data/lib/cocoapods-jsource/gem_version.rb +3 -0
- data/lib/cocoapods_plugin.rb +1 -0
- data/spec/command/jsource_spec.rb +12 -0
- data/spec/spec_helper.rb +50 -0
- data/test.rb +7 -0
- metadata +106 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 84f411236d55c44d8e5ded06d8c13833fb30b2012357041dba72ad0d4abea1e5
|
4
|
+
data.tar.gz: fe0c3f61fde6e36456b6e87d52169a33ad0cf11846f19d4d587b1b1d8e43a396
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0a7d9681ba01c2f683f137c22d70a69b4c917419e7d106d4013b8a6f4067260779f3d6432425c5ed811e3a958c48f2e0a160dae4dcc3f8e13a1037b40458960c
|
7
|
+
data.tar.gz: 32feba2d0eaebbc6e2624412bba5cb950f26b649d06a35f39f08e9fafa081b0d2e8c5d66d1a66601502733b216083fa9043d64869efc0065d99ae928041d817c
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
cocoapods-jsource (0.0.1)
|
5
|
+
cocoapods
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
CFPropertyList (3.0.0)
|
11
|
+
activesupport (4.2.11.1)
|
12
|
+
i18n (~> 0.7)
|
13
|
+
minitest (~> 5.1)
|
14
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
15
|
+
tzinfo (~> 1.1)
|
16
|
+
atomos (0.1.3)
|
17
|
+
bacon (1.2.0)
|
18
|
+
claide (1.0.2)
|
19
|
+
cocoapods (1.7.5)
|
20
|
+
activesupport (>= 4.0.2, < 5)
|
21
|
+
claide (>= 1.0.2, < 2.0)
|
22
|
+
cocoapods-core (= 1.7.5)
|
23
|
+
cocoapods-deintegrate (>= 1.0.3, < 2.0)
|
24
|
+
cocoapods-downloader (>= 1.2.2, < 2.0)
|
25
|
+
cocoapods-plugins (>= 1.0.0, < 2.0)
|
26
|
+
cocoapods-search (>= 1.0.0, < 2.0)
|
27
|
+
cocoapods-stats (>= 1.0.0, < 2.0)
|
28
|
+
cocoapods-trunk (>= 1.3.1, < 2.0)
|
29
|
+
cocoapods-try (>= 1.1.0, < 2.0)
|
30
|
+
colored2 (~> 3.1)
|
31
|
+
escape (~> 0.0.4)
|
32
|
+
fourflusher (>= 2.3.0, < 3.0)
|
33
|
+
gh_inspector (~> 1.0)
|
34
|
+
molinillo (~> 0.6.6)
|
35
|
+
nap (~> 1.0)
|
36
|
+
ruby-macho (~> 1.4)
|
37
|
+
xcodeproj (>= 1.10.0, < 2.0)
|
38
|
+
cocoapods-core (1.7.5)
|
39
|
+
activesupport (>= 4.0.2, < 6)
|
40
|
+
fuzzy_match (~> 2.0.4)
|
41
|
+
nap (~> 1.0)
|
42
|
+
cocoapods-deintegrate (1.0.4)
|
43
|
+
cocoapods-downloader (1.2.2)
|
44
|
+
cocoapods-plugins (1.0.0)
|
45
|
+
nap
|
46
|
+
cocoapods-search (1.0.0)
|
47
|
+
cocoapods-stats (1.0.0)
|
48
|
+
cocoapods-trunk (1.3.1)
|
49
|
+
nap (>= 0.8, < 2.0)
|
50
|
+
netrc (~> 0.11)
|
51
|
+
cocoapods-try (1.1.0)
|
52
|
+
colored2 (3.1.2)
|
53
|
+
concurrent-ruby (1.1.5)
|
54
|
+
escape (0.0.4)
|
55
|
+
fourflusher (2.3.1)
|
56
|
+
fuzzy_match (2.0.4)
|
57
|
+
gh_inspector (1.1.3)
|
58
|
+
i18n (0.9.5)
|
59
|
+
concurrent-ruby (~> 1.0)
|
60
|
+
metaclass (0.0.4)
|
61
|
+
minitest (5.11.3)
|
62
|
+
mocha (1.9.0)
|
63
|
+
metaclass (~> 0.0.1)
|
64
|
+
mocha-on-bacon (0.2.3)
|
65
|
+
mocha (>= 0.13.0)
|
66
|
+
molinillo (0.6.6)
|
67
|
+
nanaimo (0.2.6)
|
68
|
+
nap (1.1.0)
|
69
|
+
netrc (0.11.0)
|
70
|
+
prettybacon (0.0.2)
|
71
|
+
bacon (~> 1.2)
|
72
|
+
rake (12.3.2)
|
73
|
+
ruby-macho (1.4.0)
|
74
|
+
thread_safe (0.3.6)
|
75
|
+
tzinfo (1.2.5)
|
76
|
+
thread_safe (~> 0.1)
|
77
|
+
xcodeproj (1.11.0)
|
78
|
+
CFPropertyList (>= 2.3.3, < 4.0)
|
79
|
+
atomos (~> 0.1.3)
|
80
|
+
claide (>= 1.0.2, < 2.0)
|
81
|
+
colored2 (~> 3.1)
|
82
|
+
nanaimo (~> 0.2.6)
|
83
|
+
|
84
|
+
PLATFORMS
|
85
|
+
ruby
|
86
|
+
|
87
|
+
DEPENDENCIES
|
88
|
+
bacon
|
89
|
+
bundler (~> 1.3)
|
90
|
+
cocoapods
|
91
|
+
cocoapods-jsource!
|
92
|
+
mocha
|
93
|
+
mocha-on-bacon
|
94
|
+
prettybacon
|
95
|
+
rake
|
96
|
+
|
97
|
+
BUNDLED WITH
|
98
|
+
1.16.3
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2019 handa <794363716@qq.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-jsource/gem_version.rb'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'cocoapods-jsource'
|
8
|
+
spec.version = CocoapodsJsource::VERSION
|
9
|
+
spec.authors = ['handa']
|
10
|
+
spec.email = ['794363716@qq.com']
|
11
|
+
spec.description = %q{ Add source code debugging capabilities to binary.}
|
12
|
+
spec.summary = %q{ Add source code debugging capabilities to binary.}
|
13
|
+
spec.homepage = 'https://github.com/wendstation/cocoapods-jsource'
|
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
|
+
spec.add_dependency 'cocoapods'
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
22
|
+
spec.add_development_dependency 'rake'
|
23
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-jsource/gem_version'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-jsource/command/jsource'
|
@@ -0,0 +1,81 @@
|
|
1
|
+
|
2
|
+
require 'cocoapods-jsource/command/jsource/add'
|
3
|
+
require 'cocoapods-jsource/command/jsource/clean'
|
4
|
+
require 'cocoapods-jsource/command/jsource/list'
|
5
|
+
|
6
|
+
module Pod
|
7
|
+
class Command
|
8
|
+
# This is an example of a cocoapods plugin adding a top-level subcommand
|
9
|
+
# to the 'pod' command.
|
10
|
+
#
|
11
|
+
# You can also create subcommands of existing or new commands. Say you
|
12
|
+
# wanted to add a subcommand to `list` to show newly deprecated pods,
|
13
|
+
# (e.g. `pod list deprecated`), there are a few things that would need
|
14
|
+
# to change.
|
15
|
+
#
|
16
|
+
# - move this file to `lib/pod/command/list/deprecated.rb` and update
|
17
|
+
# the class to exist in the the Pod::Command::List namespace
|
18
|
+
# - change this class to extend from `List` instead of `Command`. This
|
19
|
+
# tells the plugin system that it is a subcommand of `list`.
|
20
|
+
# - edit `lib/cocoapods_plugins.rb` to require this file
|
21
|
+
#
|
22
|
+
# @todo Create a PR to add your plugin to CocoaPods/cocoapods.org
|
23
|
+
# in the `plugins.json` file, once your plugin is released.
|
24
|
+
#
|
25
|
+
class Jsource < Command
|
26
|
+
self.abstract_command = true
|
27
|
+
self.summary = 'Manage source debugging'
|
28
|
+
|
29
|
+
# self.description = <<-DESC
|
30
|
+
# Longer description of cocoapods-jsource.
|
31
|
+
# DESC
|
32
|
+
private
|
33
|
+
|
34
|
+
def cache_dir
|
35
|
+
path = "/Users/#{`whoami`.strip}/Library/Caches/CocoaPods/jsource/"
|
36
|
+
if not Dir.exist? path
|
37
|
+
`mkdir -p #{path}`
|
38
|
+
end
|
39
|
+
path
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
def cache_file
|
44
|
+
cache_path = cache_dir
|
45
|
+
return cache_path + "jsource.yaml"
|
46
|
+
end
|
47
|
+
|
48
|
+
def cache_object
|
49
|
+
require 'yaml'
|
50
|
+
cache_file_path = cache_file
|
51
|
+
cache_dict = {}
|
52
|
+
if File.exist? cache_file_path
|
53
|
+
cache_dict = YAML.load(File.open(cache_file_path))
|
54
|
+
end
|
55
|
+
cache_dict
|
56
|
+
end
|
57
|
+
|
58
|
+
def dump_to_yaml(hash)
|
59
|
+
File.open(cache_file, "wb+") {|f| YAML.dump(hash, f) }
|
60
|
+
end
|
61
|
+
|
62
|
+
def output_pipe
|
63
|
+
STDOUT
|
64
|
+
end
|
65
|
+
|
66
|
+
# def initialize(argv)
|
67
|
+
# @name = argv.shift_argument
|
68
|
+
# super
|
69
|
+
# end
|
70
|
+
|
71
|
+
# def validate!
|
72
|
+
# super
|
73
|
+
# help! 'A Pod name is required.' unless @name
|
74
|
+
# end
|
75
|
+
|
76
|
+
# def run
|
77
|
+
# UI.puts "Add your implementation for the cocoapods-jsource plugin in #{__FILE__}"
|
78
|
+
# end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
|
2
|
+
require "cocoapods-core/lockfile"
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
module Pod
|
6
|
+
class Command
|
7
|
+
class Jsource < Command
|
8
|
+
class Add < Jsource
|
9
|
+
self.summary = 'Add source debugging function'
|
10
|
+
|
11
|
+
self.description = <<-DESC
|
12
|
+
Add source code debugging capabilities to binary.
|
13
|
+
DESC
|
14
|
+
|
15
|
+
def self.options
|
16
|
+
[
|
17
|
+
['--names', 'component names to be added'],
|
18
|
+
['--gits', 'component git url to be added'],
|
19
|
+
].concat(super)
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize(argv)
|
23
|
+
@namesString = argv.option('names')
|
24
|
+
@names = @namesString.split(',') unless @namesString.nil?
|
25
|
+
@gitsString = argv.option('gits')
|
26
|
+
@gits = @gitsString.split(',') unless @gitsString.nil?
|
27
|
+
super
|
28
|
+
end
|
29
|
+
|
30
|
+
def validate!
|
31
|
+
super
|
32
|
+
help! 'component name is required.' unless @names.length > 0
|
33
|
+
help! 'component git url is required.' unless @gits.length > 0
|
34
|
+
help! 'names number must be equal to gits number' unless @names.length == @gits.length
|
35
|
+
help! 'podfile.lock file is required. you need pod install/update' unless File.exist? config.lockfile_path
|
36
|
+
end
|
37
|
+
|
38
|
+
def run
|
39
|
+
# 获取当前目录
|
40
|
+
index = 0
|
41
|
+
cache_dict = cache_object
|
42
|
+
@names.each do |component_name|
|
43
|
+
pod_cache_dict = {}
|
44
|
+
if cache_dict.has_key? component_name
|
45
|
+
pod_cache_dict = cache_dict[component_name]
|
46
|
+
end
|
47
|
+
version = component_version component_name
|
48
|
+
if pod_cache_dict.has_key? version
|
49
|
+
UI.puts "#{component_name} #{version} 已经存在,缓存为 #{pod_cache_dict[version][:source]}"
|
50
|
+
next
|
51
|
+
end
|
52
|
+
git = @gits[index]
|
53
|
+
source_path = get_source_path_from_binary component_name
|
54
|
+
if source_path.length >0 and version
|
55
|
+
create_working_directory source_path
|
56
|
+
cmd ="git clone -b #{component_name}-#{version} --depth 1 #{git} #{source_path}/#{component_name} >/dev/null 2>&1"
|
57
|
+
# UI.puts "执行:#{cmd}"
|
58
|
+
`#{cmd}`
|
59
|
+
pod_cache_dict[version] = {"git":git,"source":source_path,"version":version}
|
60
|
+
cache_dict[component_name] = pod_cache_dict
|
61
|
+
UI.puts "#{component_name} 源码创建成功,目录为 #{source_path}"
|
62
|
+
else
|
63
|
+
UI.puts "#{component_name} 找不到二进制组件或者找不到对应的版本信息,不做任何处理"
|
64
|
+
end
|
65
|
+
index = index + 1
|
66
|
+
end
|
67
|
+
dump_to_yaml cache_dict
|
68
|
+
end
|
69
|
+
|
70
|
+
def component_version(component_name)
|
71
|
+
return unless File.exist? config.lockfile_path
|
72
|
+
version=""
|
73
|
+
lockfile = Lockfile.from_file config.lockfile_path
|
74
|
+
dependencies = lockfile.internal_data["DEPENDENCIES"]
|
75
|
+
dependencies.each do |dependency|
|
76
|
+
list = dependency.split(" (")
|
77
|
+
name = list[0]
|
78
|
+
next unless name == component_name
|
79
|
+
version = list[-1].sub(")", "").sub("=", "").sub(" ", "")
|
80
|
+
end
|
81
|
+
version
|
82
|
+
end
|
83
|
+
|
84
|
+
# 根据组件名获取组件的源码调试地址
|
85
|
+
def get_source_path_from_binary(component_name)
|
86
|
+
source_path = ""
|
87
|
+
component_pod_path = config.sandbox_root + component_name
|
88
|
+
binary_path_list = `find #{component_pod_path} -name "#{component_name}" -type f`.strip.split("\n").sort
|
89
|
+
if binary_path_list.length > 0
|
90
|
+
binary_file = binary_path_list[0]
|
91
|
+
source_path_list = `dwarfdump -arch x86_64 #{binary_file} | grep 'DW_AT_name.*#{component_name}'`.strip.split("\n").sort
|
92
|
+
source_path_list.each do |tmp_source_path|
|
93
|
+
if tmp_source_path.include?("Pods/#{component_name}")
|
94
|
+
source_path = tmp_source_path.strip.split("(\"")[-1].split(component_name)[0]
|
95
|
+
break
|
96
|
+
end
|
97
|
+
end
|
98
|
+
else
|
99
|
+
# 可能是.a
|
100
|
+
binary_file_name = "lib#{component_name}.a"
|
101
|
+
binary_path_list = `find #{component_pod_path} -name "#{binary_file_name}" -type f`.strip.split("\n").sort
|
102
|
+
if binary_file_name.length > 0
|
103
|
+
binary_file = binary_path_list[0]
|
104
|
+
source_path_list = `dwarfdump -arch x86_64 #{binary_file} | grep 'AT_name.*#{component_name}'`.strip.split("\n").sort
|
105
|
+
source_path_list.each do |tmp_source_path|
|
106
|
+
if tmp_source_path.include?("Pods/#{component_name}")
|
107
|
+
source_path = tmp_source_path.strip.split("(\"")[-1].split("component_name")[0]
|
108
|
+
break
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
source_path
|
114
|
+
end
|
115
|
+
|
116
|
+
# 创建源码的存放的目录,可能需要root权限
|
117
|
+
def create_working_directory(source_path)
|
118
|
+
parent = source_path.split("T")[0]
|
119
|
+
parent = File.expand_path(parent)
|
120
|
+
return unless parent.length >0
|
121
|
+
return if Dir.exist? parent
|
122
|
+
UI.puts "检测到没有源码目录,即将创建#{parent}目录"
|
123
|
+
`sudo -S mkdir -p #{parent}`
|
124
|
+
user = `whoami`.strip
|
125
|
+
`sudo -S chown #{user}:staff #{parent}`
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
@@ -0,0 +1,109 @@
|
|
1
|
+
|
2
|
+
require "cocoapods-core/lockfile"
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
module Pod
|
6
|
+
class Command
|
7
|
+
class Jsource < Command
|
8
|
+
class Clean < Jsource
|
9
|
+
self.summary = 'Add source debugging function'
|
10
|
+
|
11
|
+
self.description = <<-DESC
|
12
|
+
Clean the cache of the jsource(s) whose name matches `NAME`.
|
13
|
+
DESC
|
14
|
+
|
15
|
+
self.arguments = [
|
16
|
+
CLAide::Argument.new('NAME', false),
|
17
|
+
]
|
18
|
+
|
19
|
+
def self.options
|
20
|
+
[
|
21
|
+
['--all', 'Remove all the cached pods without asking'],
|
22
|
+
].concat(super)
|
23
|
+
end
|
24
|
+
|
25
|
+
def initialize(argv)
|
26
|
+
@pod_name = argv.shift_argument
|
27
|
+
@wipe_all = argv.flag?('all')
|
28
|
+
@cache_dict = cache_object
|
29
|
+
super
|
30
|
+
end
|
31
|
+
|
32
|
+
def validate!
|
33
|
+
super
|
34
|
+
if @pod_name.nil? && !@wipe_all
|
35
|
+
# Security measure, to avoid removing the pod cache too agressively by mistake
|
36
|
+
help! 'You should either specify a pod name or use the --all flag'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def run
|
41
|
+
if @pod_name.nil?
|
42
|
+
# Note: at that point, @wipe_all is always true (thanks to `validate!`)
|
43
|
+
# Remove all
|
44
|
+
clear_cache
|
45
|
+
else
|
46
|
+
# Remove only cache for this pod
|
47
|
+
cache_descriptors = @cache_dict[@pod_name].values
|
48
|
+
if cache_descriptors.nil?
|
49
|
+
UI.notice("No cache for pod named #{@pod_name} found")
|
50
|
+
elsif cache_descriptors.count > 1 && !@wipe_all
|
51
|
+
# Ask which to remove
|
52
|
+
choices = cache_descriptors.map { |c| "#{@pod_name} v#{c[:version]}" }
|
53
|
+
index = UI.choose_from_array(choices, 'Which pod cache do you want to remove?')
|
54
|
+
remove_caches([cache_descriptors[index]])
|
55
|
+
else
|
56
|
+
# Remove all found cache of this pod
|
57
|
+
remove_caches(cache_descriptors)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
dump_to_yaml @cache_dict
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
# Removes the specified cache
|
66
|
+
#
|
67
|
+
# @param [Array<Hash>] cache_descriptors
|
68
|
+
# An array of caches to remove, each specified with the same
|
69
|
+
# hash as cache_descriptors_per_pod especially :source and :version
|
70
|
+
#
|
71
|
+
def remove_caches(cache_descriptors)
|
72
|
+
cache_descriptors.each do |desc|
|
73
|
+
UI.puts "Removing cache #{desc[:source]} (#{desc[:version]})"
|
74
|
+
if @cache_dict[@pod_name].has_key? desc[:version]
|
75
|
+
if @cache_dict[@pod_name].length == 1
|
76
|
+
@cache_dict.delete @pod_name
|
77
|
+
else
|
78
|
+
@cache_dict[@pod_name].delete (desc[:version]) if @cache_dict[@pod_name].has_key? desc[:version]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
parent = File.dirname desc[:source]
|
82
|
+
FileUtils.rm_rf(parent) if File.exist? parent
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def clear_cache
|
87
|
+
@cache_dict.each do |pod_name, version_dict|
|
88
|
+
version_dict.each do |version, pod_dict|
|
89
|
+
git=""
|
90
|
+
source=""
|
91
|
+
git=pod_dict[:git] if pod_dict.has_key? :git
|
92
|
+
source=pod_dict[:source] if pod_dict.has_key? :source
|
93
|
+
UI.message("Removing the #{pod_name} jsource cache dir #{cache_dir}") do
|
94
|
+
parent = File.dirname source
|
95
|
+
FileUtils.rm_rf(parent) if File.exist? parent
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
UI.message("Removing the jsource configuration dir #{cache_file}") do
|
100
|
+
FileUtils.rm_rf(cache_file)
|
101
|
+
@cache_dict = {}
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
|
2
|
+
require "cocoapods-core/lockfile"
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
module Pod
|
6
|
+
class Command
|
7
|
+
class Jsource < Command
|
8
|
+
class List < Jsource
|
9
|
+
self.summary = 'list all source info'
|
10
|
+
|
11
|
+
self.description = <<-DESC
|
12
|
+
Prints the content of the jsource(s) whose name matches `QUERY` to standard output.
|
13
|
+
DESC
|
14
|
+
|
15
|
+
self.arguments = [
|
16
|
+
CLAide::Argument.new('QUERY', false),
|
17
|
+
]
|
18
|
+
|
19
|
+
def self.options
|
20
|
+
[[
|
21
|
+
'--short', 'Only print the path relative to the cache root'
|
22
|
+
]].concat(super)
|
23
|
+
end
|
24
|
+
|
25
|
+
def initialize(argv)
|
26
|
+
@pod_name = argv.shift_argument
|
27
|
+
@short_output = argv.flag?('short')
|
28
|
+
@cache_dict = cache_object
|
29
|
+
super
|
30
|
+
end
|
31
|
+
|
32
|
+
def run
|
33
|
+
return if @cache_dict.nil?
|
34
|
+
result = ""
|
35
|
+
if @pod_name
|
36
|
+
result = @cache_dict[@pod_name] if @cache_dict.has_key? @pod_name
|
37
|
+
else
|
38
|
+
result = @cache_dict
|
39
|
+
end
|
40
|
+
if @short_output
|
41
|
+
result = result.keys
|
42
|
+
end
|
43
|
+
output_pipe.puts result.to_yaml unless result.nil? or result.length == 0
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-jsource/command'
|
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
|
+
#-----------------------------------------------------------------------------#
|
data/test.rb
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
|
2
|
+
`cd /Users/handa/Documents/test/testZSource;pod jsource add --names=LJCache --gits=http://gerrit.lianjia.com/mobile_ios/LJCache`
|
3
|
+
|
4
|
+
|
5
|
+
# `cd /Users/handa/Documents/test/testZSource;pod jsource list`
|
6
|
+
|
7
|
+
# `cd /Users/handa/Documents/test/testZSource;pod jsource clean LJCache`
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cocoapods-jsource
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- handa
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-08-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: cocoapods
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: " Add source code debugging capabilities to binary."
|
56
|
+
email:
|
57
|
+
- 794363716@qq.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- Gemfile.lock
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- cocoapods-jsource.gemspec
|
69
|
+
- lib/cocoapods-jsource.rb
|
70
|
+
- lib/cocoapods-jsource/command.rb
|
71
|
+
- lib/cocoapods-jsource/command/jsource.rb
|
72
|
+
- lib/cocoapods-jsource/command/jsource/add.rb
|
73
|
+
- lib/cocoapods-jsource/command/jsource/clean.rb
|
74
|
+
- lib/cocoapods-jsource/command/jsource/list.rb
|
75
|
+
- lib/cocoapods-jsource/gem_version.rb
|
76
|
+
- lib/cocoapods_plugin.rb
|
77
|
+
- spec/command/jsource_spec.rb
|
78
|
+
- spec/spec_helper.rb
|
79
|
+
- test.rb
|
80
|
+
homepage: https://github.com/wendstation/cocoapods-jsource
|
81
|
+
licenses:
|
82
|
+
- MIT
|
83
|
+
metadata: {}
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubyforge_project:
|
100
|
+
rubygems_version: 2.7.7
|
101
|
+
signing_key:
|
102
|
+
specification_version: 4
|
103
|
+
summary: Add source code debugging capabilities to binary.
|
104
|
+
test_files:
|
105
|
+
- spec/command/jsource_spec.rb
|
106
|
+
- spec/spec_helper.rb
|