cocoapods-cache-proxy 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/lib/cocoapods-cache-proxy.rb +1 -0
- data/lib/cocoapods-cache-proxy/command.rb +1 -0
- data/lib/cocoapods-cache-proxy/command/cache_proxy.rb +29 -0
- data/lib/cocoapods-cache-proxy/command/cache_proxy/add.rb +48 -0
- data/lib/cocoapods-cache-proxy/command/cache_proxy/list.rb +52 -0
- data/lib/cocoapods-cache-proxy/command/cache_proxy/remove.rb +43 -0
- data/lib/cocoapods-cache-proxy/command/cache_proxy/update.rb +47 -0
- data/lib/cocoapods-cache-proxy/gem_version.rb +9 -0
- data/lib/cocoapods-cache-proxy/helper/cache_proxy_source_helper.rb +111 -0
- data/lib/cocoapods-cache-proxy/helper/helper.rb +3 -0
- data/lib/cocoapods-cache-proxy/native/cache_proxy_source.rb +34 -0
- data/lib/cocoapods-cache-proxy/native/config.rb +28 -0
- data/lib/cocoapods-cache-proxy/native/downloader.rb +59 -0
- data/lib/cocoapods-cache-proxy/native/installer.rb +20 -0
- data/lib/cocoapods-cache-proxy/native/native.rb +6 -0
- data/lib/cocoapods-cache-proxy/native/podfile_dsl.rb +64 -0
- data/lib/cocoapods-cache-proxy/native/resolver.rb +41 -0
- data/lib/cocoapods_plugin.rb +3 -0
- data/lib/hook.rb +17 -0
- metadata +119 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 314ee2e85d24d3f0cdb7decd9b1507a810b715197d095ed9b8bb522a5e14d561
|
4
|
+
data.tar.gz: 74015ad447d10595a45bfa2fdd939c0eb9495acd67e90fff57e320acd193e915
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: '049e7d8f29245475de4808681557ca09dc94b19c2e1fd1dc0d1febd6f846aadf9c9640f64c79cc12a87928b12fcdd197c0f57891ab43be034e337e4e6a84eec3'
|
7
|
+
data.tar.gz: c089b4c51f24d2e6e4b830e9058394b117008c931d11010890708193c682b428f11ef9a7fa441dcde51817323b1df5b0a1c0687deee2d8199a8f00a6cc67ea15
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-cache-proxy/gem_version'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-cache-proxy/command/cache_proxy'
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'cocoapods-cache-proxy/gem_version'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Cache < Command
|
6
|
+
class Proxy < Cache
|
7
|
+
|
8
|
+
require 'cocoapods-cache-proxy/command/cache_proxy/add'
|
9
|
+
require 'cocoapods-cache-proxy/command/cache_proxy/remove'
|
10
|
+
# require 'cocoapods-cache-proxy/command/cache_proxy/update'
|
11
|
+
require 'cocoapods-cache-proxy/command/cache_proxy/list'
|
12
|
+
|
13
|
+
self.abstract_command = true
|
14
|
+
self.version = CocoapodsCacheProxy::VERSION
|
15
|
+
self.description = '代理缓存服务'\
|
16
|
+
"\n v#{CocoapodsCacheProxy::VERSION}\n"
|
17
|
+
self.summary = <<-SUMMARY
|
18
|
+
代理缓存
|
19
|
+
SUMMARY
|
20
|
+
|
21
|
+
self.default_subcommand = 'list'
|
22
|
+
|
23
|
+
def init
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'cocoapods-cache-proxy/helper/helper'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Cache < Command
|
6
|
+
class Proxy
|
7
|
+
class Add < Proxy
|
8
|
+
self.summary = '添加缓存代理'
|
9
|
+
|
10
|
+
self.description = <<-DESC
|
11
|
+
添加缓存代理
|
12
|
+
DESC
|
13
|
+
|
14
|
+
self.arguments = [
|
15
|
+
CLAide::Argument.new('NAME', true),
|
16
|
+
CLAide::Argument.new('URL', true),
|
17
|
+
CLAide::Argument.new('USER', false),
|
18
|
+
CLAide::Argument.new('PASSWORD', false)
|
19
|
+
]
|
20
|
+
|
21
|
+
def initialize(argv)
|
22
|
+
init
|
23
|
+
@name, @url, @user, @password = argv.shift_argument, argv.shift_argument, argv.shift_argument, argv.shift_argument
|
24
|
+
@silent = argv.flag?('silent', false)
|
25
|
+
super
|
26
|
+
end
|
27
|
+
|
28
|
+
def validate!
|
29
|
+
super
|
30
|
+
help! 'This command requires both a repo name.' unless @name
|
31
|
+
help! 'This command requires both a repo url.' unless @url
|
32
|
+
help! 'This command requires both a repo user.' unless @user
|
33
|
+
help! 'This command requires both a repo password.' unless @password
|
34
|
+
end
|
35
|
+
|
36
|
+
def run
|
37
|
+
raise Pod::Informative.exception "`#{@name}` 已经存在" if CPSH.check_cache_proxy_source_conf_exists(@name)
|
38
|
+
raise Pod::Informative.exception "官方源不存在, 请先添加官方源" unless Pod::Config.instance.sources_manager.master_repo_functional?
|
39
|
+
|
40
|
+
UI.section("Add proxy server config `#{@url}` into local spec repo `#{@name}`") do
|
41
|
+
CPSH.init_cache_proxy_source(@name, @url, @user, @password)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'cocoapods-cache-proxy/helper/helper'
|
2
|
+
require 'cocoapods-cache-proxy/native/cache_proxy_source'
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
class Command
|
6
|
+
class Cache < Command
|
7
|
+
class Proxy
|
8
|
+
class List < Proxy
|
9
|
+
self.summary = '列出缓存代理'
|
10
|
+
|
11
|
+
self.description = <<-DESC
|
12
|
+
列出缓存代理
|
13
|
+
DESC
|
14
|
+
|
15
|
+
def initialize(argv)
|
16
|
+
init
|
17
|
+
@silent = argv.flag?('silent', false)
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
def validate!
|
22
|
+
super
|
23
|
+
end
|
24
|
+
|
25
|
+
def run
|
26
|
+
sources = CPSH.get_all_cache_proxy_source_conf()
|
27
|
+
print_sources(sources)
|
28
|
+
end
|
29
|
+
|
30
|
+
def print_source(source)
|
31
|
+
if source.is_a?(Pod::CacheProxySource)
|
32
|
+
UI.puts "- URL: #{source.baseURL}"
|
33
|
+
UI.puts "- Path: #{CPSH.get_cache_proxy_source_root_dir(source.name)}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def print_sources(sources)
|
38
|
+
sources.each do |source|
|
39
|
+
if source.is_a?(Pod::CacheProxySource)
|
40
|
+
UI.title source.name do
|
41
|
+
UI.puts "- URL: #{source.baseURL}"
|
42
|
+
UI.puts "- Path: #{CPSH.get_cache_proxy_source_root_dir(source.name)}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
UI.puts "\n"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'cocoapods-cache-proxy/helper/helper'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Cache < Command
|
6
|
+
class Proxy
|
7
|
+
class Remove < Proxy
|
8
|
+
self.summary = '移除缓存代理'
|
9
|
+
|
10
|
+
self.description = <<-DESC
|
11
|
+
移除缓存代理
|
12
|
+
DESC
|
13
|
+
|
14
|
+
self.arguments = [
|
15
|
+
CLAide::Argument.new('NAME', true),
|
16
|
+
]
|
17
|
+
|
18
|
+
def initialize(argv)
|
19
|
+
init
|
20
|
+
@name = argv.shift_argument
|
21
|
+
@silent = argv.flag?('silent', false)
|
22
|
+
super
|
23
|
+
end
|
24
|
+
|
25
|
+
def validate!
|
26
|
+
super
|
27
|
+
unless @name
|
28
|
+
help! 'This command requires both a repo name.'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def run
|
33
|
+
raise Pod::Informative.exception "`#{@name}` 不存在" unless CPSH.check_cache_proxy_source_conf_exists(@name)
|
34
|
+
|
35
|
+
UI.section("remove cache proxy repo `#{@name}`") do
|
36
|
+
CPSH.remove_cache_proxy_source(@name)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'cocoapods-cache-proxy/helper/helper'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Cache < Command
|
6
|
+
class Proxy
|
7
|
+
class Update < Proxy
|
8
|
+
self.summary = '更新缓存代理'
|
9
|
+
|
10
|
+
self.description = <<-DESC
|
11
|
+
更新缓存代理
|
12
|
+
DESC
|
13
|
+
|
14
|
+
self.arguments = [
|
15
|
+
CLAide::Argument.new('NAME', true),
|
16
|
+
CLAide::Argument.new('URL', true),
|
17
|
+
CLAide::Argument.new('USER', false),
|
18
|
+
CLAide::Argument.new('PASSWORD', false)
|
19
|
+
]
|
20
|
+
|
21
|
+
def initialize(argv)
|
22
|
+
init
|
23
|
+
@name, @url, @user, @password = argv.shift_argument, argv.shift_argument, argv.shift_argument, argv.shift_argument
|
24
|
+
@silent = argv.flag?('silent', false)
|
25
|
+
super
|
26
|
+
end
|
27
|
+
|
28
|
+
def validate!
|
29
|
+
super
|
30
|
+
help! 'This command requires both a repo name.' unless @name
|
31
|
+
help! 'This command requires both a repo url.' unless @url
|
32
|
+
help! 'This command requires both a repo user.' unless @user
|
33
|
+
help! 'This command requires both a repo password.' unless @password
|
34
|
+
end
|
35
|
+
|
36
|
+
def run
|
37
|
+
raise Pod::Informative.exception "`#{@name}` 不存在" unless CPSH.check_cache_proxy_source_conf_exists(@name)
|
38
|
+
|
39
|
+
UI.section("update cache proxy repo `#{@name}`") do
|
40
|
+
CPSH.init_cache_proxy_source(@name, @url, @user, @password)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'find'
|
3
|
+
require 'json'
|
4
|
+
require 'cocoapods'
|
5
|
+
require 'yaml'
|
6
|
+
require 'uri'
|
7
|
+
require 'pathname'
|
8
|
+
require 'cocoapods-cache-proxy/native/cache_proxy_source'
|
9
|
+
|
10
|
+
module Pod
|
11
|
+
class CacheProxySource
|
12
|
+
class CacheProxySourceHelper
|
13
|
+
|
14
|
+
def self.get_cache_proxy_root_dir()
|
15
|
+
"#{Pod::Config.instance.home_dir}/cache-proxy"
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.get_cache_proxy_source_root_dir(source_name)
|
19
|
+
"#{Pod::Config.instance.home_dir}/cache-proxy/#{source_name}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.get_cache_proxy_source_conf_file_name()
|
23
|
+
".cache_proxy_conf.yml"
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.get_cache_proxy_source_conf_path(source_name)
|
27
|
+
"#{get_cache_proxy_source_root_dir(source_name)}/#{get_cache_proxy_source_conf_file_name()}"
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.check_cache_proxy_source_conf_exists(source_name)
|
31
|
+
File.exist?(get_cache_proxy_source_conf_path(source_name))
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.load_conf(source_name)
|
35
|
+
path = get_cache_proxy_source_conf_path(source_name)
|
36
|
+
if File.exist?(path)
|
37
|
+
YAML.load_file(path)
|
38
|
+
else
|
39
|
+
nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.create_cache_proxy_source_conf(source_name, url, user, password)
|
44
|
+
path = get_cache_proxy_source_conf_path(source_name)
|
45
|
+
info = {
|
46
|
+
'name' => source_name,
|
47
|
+
'url' => url,
|
48
|
+
}
|
49
|
+
|
50
|
+
info['user'] = user unless user.blank?
|
51
|
+
info['password'] = password unless password.blank?
|
52
|
+
|
53
|
+
conf = File.new(path, "wb")
|
54
|
+
conf << info.to_yaml
|
55
|
+
conf.close
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
def self.init_cache_proxy_source(cache_source_name, cache_source_url, user, password)
|
61
|
+
begin
|
62
|
+
show_output = Pod::Config.instance.verbose?
|
63
|
+
|
64
|
+
cache_source_root_path = "#{get_cache_proxy_source_root_dir(cache_source_name)}"
|
65
|
+
|
66
|
+
FileUtils.rm_rf(cache_source_root_path) if Dir.exist?(cache_source_root_path)
|
67
|
+
|
68
|
+
FileUtils.mkdir_p(cache_source_root_path)
|
69
|
+
|
70
|
+
Pod::UI.message "Generating source conf .....".yellow if show_output
|
71
|
+
create_cache_proxy_source_conf(cache_source_name, cache_source_url, user, password)
|
72
|
+
Pod::UI.message "Successfully added repo #{cache_source_name}".green if show_output
|
73
|
+
|
74
|
+
rescue Exception => e
|
75
|
+
Pod::UI.message "发生异常,清理文件 .....".yellow if show_output
|
76
|
+
FileUtils.rm_rf(cache_source_root_path) if Dir.exist?(cache_source_root_path)
|
77
|
+
Pod::UI.message e.message.yellow if show_output
|
78
|
+
Pod::UI.message e.backtrace.inspect.yellow if show_output
|
79
|
+
raise e
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.remove_cache_proxy_source(cache_source_name)
|
84
|
+
show_output = Pod::Config.instance.verbose?
|
85
|
+
|
86
|
+
cache_source_root_path = "#{get_cache_proxy_source_root_dir(cache_source_name)}"
|
87
|
+
FileUtils.rm_rf(cache_source_root_path) if Dir.exist?(cache_source_root_path)
|
88
|
+
|
89
|
+
Pod::UI.message "Successfully remove repo #{cache_source_name}".green if show_output
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.get_cache_proxy_source_conf(cache_source_name)
|
93
|
+
return nil unless (hash = load_conf(cache_source_name))
|
94
|
+
Pod::CacheProxySource.new(hash['name'], hash['url'], hash['user'], hash['password'])
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.get_all_cache_proxy_source_conf()
|
98
|
+
return [] unless Dir.exist?(get_cache_proxy_root_dir())
|
99
|
+
confs = []
|
100
|
+
Find.find(get_cache_proxy_root_dir()) do |path|
|
101
|
+
next unless File.file?(path) && path.end_with?(".cache_proxy_conf.yml")
|
102
|
+
pn = Pathname.new(path)
|
103
|
+
source_name = pn.dirname.basename
|
104
|
+
next unless (conf = get_cache_proxy_source_conf(source_name))
|
105
|
+
confs << conf
|
106
|
+
end
|
107
|
+
confs
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Pod
|
2
|
+
class CacheProxySource
|
3
|
+
# @param [String] proxy_source The name of the repository
|
4
|
+
#
|
5
|
+
# @param [String] url see {#url}
|
6
|
+
#
|
7
|
+
def initialize(name, baseURL, user, password)
|
8
|
+
@name = name
|
9
|
+
@baseURL = baseURL
|
10
|
+
@user = user
|
11
|
+
@password = password
|
12
|
+
end
|
13
|
+
|
14
|
+
def name
|
15
|
+
@name
|
16
|
+
end
|
17
|
+
|
18
|
+
def baseURL
|
19
|
+
@baseURL
|
20
|
+
end
|
21
|
+
|
22
|
+
def user
|
23
|
+
@user
|
24
|
+
end
|
25
|
+
|
26
|
+
def password
|
27
|
+
@password
|
28
|
+
end
|
29
|
+
|
30
|
+
def build_proxy_source(pod, git, tag, submodules = false)
|
31
|
+
"#{@baseURL}/#{pod}?git=#{git}&tag=#{tag}&submodules=#{submodules}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'cocoapods-cache-proxy/native/cache_proxy_source'
|
2
|
+
require 'cocoapods-cache-proxy/helper/helper'
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
class Config
|
6
|
+
attr_reader :cache_proxy_source
|
7
|
+
|
8
|
+
def set_cache_proxy_source(name)
|
9
|
+
return if name.blank?
|
10
|
+
return unless (cnf = CPSH.get_cache_proxy_source_conf(name))
|
11
|
+
@cache_proxy_source = cnf
|
12
|
+
end
|
13
|
+
|
14
|
+
def cache_proxy_source()
|
15
|
+
@cache_proxy_source
|
16
|
+
end
|
17
|
+
|
18
|
+
# def remove_cache_proxy_source(name)
|
19
|
+
# return if name.blank? || @cache_proxy_source.nil? || @cache_proxy_source.empty?
|
20
|
+
# @cache_proxy_source.delete_if { |cnf| cnf.name == name }
|
21
|
+
# end
|
22
|
+
|
23
|
+
# def get_all_cache_proxy_sources()
|
24
|
+
# return [] if @cache_proxy_source.nil?
|
25
|
+
# @cache_proxy_source
|
26
|
+
# end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'cocoapods-downloader'
|
2
|
+
require 'cocoapods'
|
3
|
+
|
4
|
+
# module Pod
|
5
|
+
# module Downloader
|
6
|
+
# class Cache
|
7
|
+
# alias_method :orig_copy_and_clean, :copy_and_clean
|
8
|
+
# def copy_and_clean(source, destination, spec)
|
9
|
+
# # specs_by_platform = group_subspecs_by_platform(spec)
|
10
|
+
# # destination.parent.mkpath
|
11
|
+
# # FileUtils.rm_rf(destination)
|
12
|
+
# # FileUtils.cp_r(source, destination)
|
13
|
+
# # Pod::Installer::PodSourcePreparer.new(spec, destination).prepare!
|
14
|
+
# # Sandbox::PodDirCleaner.new(destination, specs_by_platform).clean!
|
15
|
+
# Pod::UI.message "copy_and_clean: \n"
|
16
|
+
# Pod::UI.message "spec: #{spec.class}"
|
17
|
+
# Pod::UI.message "source: #{source}"
|
18
|
+
# Pod::UI.message "destination: #{destination}"
|
19
|
+
# Pod::UI.message "destination parent: #{destination.parent}"
|
20
|
+
# Pod::UI.message "destination parent basename: #{destination.basename}"
|
21
|
+
# p = "/Users/king/Desktop/#{source.basename}"
|
22
|
+
# FileUtils.rm_rf(p)
|
23
|
+
# FileUtils.cp_r(source, p)
|
24
|
+
# # exit 0
|
25
|
+
# orig_copy_and_clean(source, destination, spec)
|
26
|
+
# # exit 0
|
27
|
+
# end
|
28
|
+
# end
|
29
|
+
# end
|
30
|
+
# end
|
31
|
+
|
32
|
+
module Pod
|
33
|
+
module Downloader
|
34
|
+
class Http
|
35
|
+
|
36
|
+
alias_method :orig_download_file, :download_file
|
37
|
+
|
38
|
+
def download_file(full_filename)
|
39
|
+
Pod::UI.message "full_filename: #{full_filename}" if Pod::Config.instance.verbose?
|
40
|
+
|
41
|
+
proxy_source = Pod::Config.instance.cache_proxy_source
|
42
|
+
download_uri = URI(url)
|
43
|
+
proxy_source_uri = URI(proxy_source.baseURL)
|
44
|
+
|
45
|
+
Pod::UI.message "url: #{download_uri.path}" if Pod::Config.instance.verbose?
|
46
|
+
Pod::UI.message "proxy_source baseURL: #{proxy_source.baseURL}" if Pod::Config.instance.verbose?
|
47
|
+
if download_uri.path.start_with?(proxy_source_uri.path)
|
48
|
+
curl_options = []
|
49
|
+
curl_options.concat(["-u", "#{proxy_source.user}:#{proxy_source.password}"]) unless proxy_source.user.blank? && proxy_source.password.blank?
|
50
|
+
curl_options.concat(["-f", "-L", "-o", full_filename, url, "--create-dirs"])
|
51
|
+
Pod::UI.message "curl_options: #{curl_options.join(" ")}" if Pod::Config.instance.verbose?
|
52
|
+
curl! curl_options
|
53
|
+
else
|
54
|
+
orig_download_file(full_filename)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
# module Pod
|
3
|
+
# class Installer
|
4
|
+
|
5
|
+
# # alias_method :old_specs_for_pod, :specs_for_pod
|
6
|
+
# # def specs_for_pod(pod_name)
|
7
|
+
# # specs_by_platform = old_specs_for_pod(pod_name)
|
8
|
+
# # specs = specs_by_platform.values.flatten
|
9
|
+
# # root_spec = specs.first.root
|
10
|
+
# # UI.message "specs_by_platform values name: #{specs}"
|
11
|
+
# # UI.message "specs_by_platform root_spec name: #{root_spec.name}"
|
12
|
+
# # UI.message "specs_by_platform root_spec version: #{root_spec.version}"
|
13
|
+
# # UI.message "specs_by_platform origin source: #{root_spec.source}"
|
14
|
+
# # root_spec.source = { :http => 'http://127.0.0.1:9898/static/AFNetworking.zip'}
|
15
|
+
# # UI.message "specs_by_platform proxy source: #{root_spec.source}"
|
16
|
+
# # # exit 0
|
17
|
+
# # specs_by_platform
|
18
|
+
# # end
|
19
|
+
# end
|
20
|
+
# end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
require 'cocoapods-cache-proxy/native/downloader'
|
2
|
+
require 'cocoapods-cache-proxy/native/resolver'
|
3
|
+
require 'cocoapods-cache-proxy/native/podfile_dsl'
|
4
|
+
require 'cocoapods-cache-proxy/native/cache_proxy_source'
|
5
|
+
require 'cocoapods-cache-proxy/native/config'
|
6
|
+
# require 'cocoapods-cache-proxy/native/installer'
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'cocoapods-core'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Podfile
|
5
|
+
module DSL
|
6
|
+
|
7
|
+
def ignore_cache_proxy_pods!(pods = [])
|
8
|
+
Pod::UI.puts "current_target_definition: #{current_target_definition}" if Pod::Config.instance.verbose?
|
9
|
+
current_target_definition.set_ignore_cache_proxy_pods(pods) if !pods.blank? && !current_target_definition.nil?
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
module Pod
|
17
|
+
class Podfile
|
18
|
+
class TargetDefinition
|
19
|
+
attr_reader :ignore_cache_proxy
|
20
|
+
|
21
|
+
alias_method :orig_store_pod, :store_pod
|
22
|
+
def store_pod(name, *requirements)
|
23
|
+
Pod::UI.message "store_pod requirements: #{requirements}" if Pod::Config.instance.verbose?
|
24
|
+
parse_ignore_cache_proxy(name, requirements)
|
25
|
+
orig_store_pod(name, *requirements)
|
26
|
+
end
|
27
|
+
|
28
|
+
def parse_ignore_cache_proxy(name, requirements)
|
29
|
+
requirements.each do |options|
|
30
|
+
next unless options.is_a?(Hash)
|
31
|
+
Pod::UI.message "parse_ignore_cache_proxy: #{options}" if Pod::Config.instance.verbose?
|
32
|
+
set_ignore_cache_proxy_pods([name]) if options.has_key?(:git)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def set_ignore_cache_proxy_pods(pods)
|
37
|
+
return if pods.blank?
|
38
|
+
@ignore_cache_proxy = [] if @ignore_cache_proxy.nil?
|
39
|
+
pods.uniq.each do |pod|
|
40
|
+
@ignore_cache_proxy << pod unless @ignore_cache_proxy.include?(pod)
|
41
|
+
end
|
42
|
+
Pod::UI.message "set_ignore_cache_proxy_pods name: #{@ignore_cache_proxy}" if Pod::Config.instance.verbose?
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_ignore_cache_proxy_pods()
|
46
|
+
if @ignore_cache_proxy.nil?
|
47
|
+
[]
|
48
|
+
else
|
49
|
+
@ignore_cache_proxy.uniq
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def check_ignore_cache_proxy_pod(pod)
|
54
|
+
return false if pod.blank?
|
55
|
+
ignores = []
|
56
|
+
ignores.concat(get_ignore_cache_proxy_pods())
|
57
|
+
ignores.concat(root.get_ignore_cache_proxy_pods()) if !root?
|
58
|
+
ignores.concat(parent.get_ignore_cache_proxy_pods()) unless parent.nil?
|
59
|
+
Pod::UI.message "check_ignore_cache_proxy_pod #{name}: #{ignores} #{ignores.uniq.include?(pod)}" if Pod::Config.instance.verbose?
|
60
|
+
return ignores.uniq.include?(pod)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'cocoapods'
|
2
|
+
require 'cocoapods-cache-proxy/native/config'
|
3
|
+
require 'cocoapods-cache-proxy/native/podfile_dsl'
|
4
|
+
require 'cocoapods-cache-proxy/gem_version'
|
5
|
+
|
6
|
+
module Pod
|
7
|
+
class Resolver
|
8
|
+
|
9
|
+
alias_method :orig_resolver_specs_by_target, :resolver_specs_by_target
|
10
|
+
def resolver_specs_by_target()
|
11
|
+
specs_by_target = orig_resolver_specs_by_target()
|
12
|
+
proxy_source = Pod::Config.instance.cache_proxy_source
|
13
|
+
return specs_by_target if proxy_source.nil?
|
14
|
+
|
15
|
+
show_output = Pod::Config.instance.verbose?
|
16
|
+
specs_by_target.each do |target, rspecs|
|
17
|
+
rspecs.each do |spec|
|
18
|
+
root_spec = spec.spec.root
|
19
|
+
source = root_spec.source
|
20
|
+
UI.message "spec name: #{root_spec.name}" if show_output
|
21
|
+
UI.message "spec source: #{source}" if show_output
|
22
|
+
UI.message "spec version: #{root_spec.version}" if show_output
|
23
|
+
next unless !source.blank? && source.has_key?(:git) && source.has_key?(:tag)
|
24
|
+
UI.message "ignore_cache_proxy_pod: #{target.name} #{root_spec.name}" if show_output; next if target.check_ignore_cache_proxy_pod(root_spec.name)
|
25
|
+
|
26
|
+
git = source[:git]
|
27
|
+
tag = source[:tag]
|
28
|
+
submodules = source.has_key?(:submodules) ? source[:submodules] : false
|
29
|
+
new_url = proxy_source.build_proxy_source(root_spec.name, git, tag, submodules)
|
30
|
+
source = {
|
31
|
+
:http => new_url,
|
32
|
+
:type => "tgz",
|
33
|
+
}
|
34
|
+
UI.message "spec new source: #{source}" if show_output
|
35
|
+
root_spec.source = source
|
36
|
+
end
|
37
|
+
end
|
38
|
+
specs_by_target
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/hook.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'cocoapods'
|
2
|
+
require 'cocoapods-downloader'
|
3
|
+
require 'cocoapods-cache-proxy/native/native'
|
4
|
+
require 'cocoapods-cache-proxy/helper/helper'
|
5
|
+
require 'yaml'
|
6
|
+
require 'uri'
|
7
|
+
|
8
|
+
|
9
|
+
Pod::HooksManager.register('cocoapods-cache-proxy', :source_provider) do |context, options|
|
10
|
+
show_output = Pod::Config.instance.verbose?
|
11
|
+
Pod::UI.message 'cocoapods-cache-proxy received source_provider hook' if show_output
|
12
|
+
|
13
|
+
return unless (proxy_name = options['proxy'])
|
14
|
+
raise Pod::Informative.exception "cache proxy source: `#{proxy_name}` does not exist." unless CPSH.check_cache_proxy_source_conf_exists(proxy_name)
|
15
|
+
Pod::UI.message "proxy_name: #{proxy_name}" if show_output
|
16
|
+
Pod::Config.instance.set_cache_proxy_source(proxy_name)
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cocoapods-cache-proxy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- '0x1306a94'
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-01-07 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: cocoapods-core
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
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
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: A short description of cocoapods-cache-proxy.
|
70
|
+
email:
|
71
|
+
- 0x1306a94@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- lib/cocoapods-cache-proxy.rb
|
77
|
+
- lib/cocoapods-cache-proxy/command.rb
|
78
|
+
- lib/cocoapods-cache-proxy/command/cache_proxy.rb
|
79
|
+
- lib/cocoapods-cache-proxy/command/cache_proxy/add.rb
|
80
|
+
- lib/cocoapods-cache-proxy/command/cache_proxy/list.rb
|
81
|
+
- lib/cocoapods-cache-proxy/command/cache_proxy/remove.rb
|
82
|
+
- lib/cocoapods-cache-proxy/command/cache_proxy/update.rb
|
83
|
+
- lib/cocoapods-cache-proxy/gem_version.rb
|
84
|
+
- lib/cocoapods-cache-proxy/helper/cache_proxy_source_helper.rb
|
85
|
+
- lib/cocoapods-cache-proxy/helper/helper.rb
|
86
|
+
- lib/cocoapods-cache-proxy/native/cache_proxy_source.rb
|
87
|
+
- lib/cocoapods-cache-proxy/native/config.rb
|
88
|
+
- lib/cocoapods-cache-proxy/native/downloader.rb
|
89
|
+
- lib/cocoapods-cache-proxy/native/installer.rb
|
90
|
+
- lib/cocoapods-cache-proxy/native/native.rb
|
91
|
+
- lib/cocoapods-cache-proxy/native/podfile_dsl.rb
|
92
|
+
- lib/cocoapods-cache-proxy/native/resolver.rb
|
93
|
+
- lib/cocoapods_plugin.rb
|
94
|
+
- lib/hook.rb
|
95
|
+
homepage: https://github.com/0x1306a94/cocoapods-cache-proxy
|
96
|
+
licenses:
|
97
|
+
- MIT
|
98
|
+
metadata: {}
|
99
|
+
post_install_message:
|
100
|
+
rdoc_options: []
|
101
|
+
require_paths:
|
102
|
+
- lib
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
requirements: []
|
114
|
+
rubyforge_project:
|
115
|
+
rubygems_version: 2.7.9
|
116
|
+
signing_key:
|
117
|
+
specification_version: 4
|
118
|
+
summary: A longer description of cocoapods-cache-proxy.
|
119
|
+
test_files: []
|