cocoapods-bin 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +35 -14
- data/cocoapods-bin.gemspec +3 -3
- data/lib/cocoapods-bin/command/bin/list.rb +26 -26
- data/lib/cocoapods-bin/command/bin/open.rb +46 -46
- data/lib/cocoapods-bin/command/bin/repo/update.rb +24 -24
- data/lib/cocoapods-bin/command/bin/search.rb +47 -47
- data/lib/cocoapods-bin/config/config.rb +59 -59
- data/lib/cocoapods-bin/gem_version.rb +4 -4
- data/lib/cocoapods-bin/helpers/spec_creator.rb +107 -107
- data/lib/cocoapods-bin/native/analyzer.rb +19 -19
- data/lib/cocoapods-bin/native/podfile.rb +49 -49
- data/lib/cocoapods-bin/native/resolver.rb +95 -95
- data/lib/cocoapods-bin/native/source_provider_hook.rb +6 -6
- data/lib/cocoapods-bin/native/specification.rb +3 -3
- metadata +6 -5
@@ -1,9 +1,9 @@
|
|
1
1
|
module CBin
|
2
|
-
VERSION = "0.1.
|
2
|
+
VERSION = "0.1.2"
|
3
3
|
end
|
4
4
|
|
5
5
|
module Pod
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
def self.match_version?(*version)
|
7
|
+
Gem::Dependency.new("", *version).match?('', Pod::VERSION)
|
8
|
+
end
|
9
9
|
end
|
@@ -2,111 +2,111 @@ require 'cocoapods'
|
|
2
2
|
require 'cocoapods-bin/config/config'
|
3
3
|
|
4
4
|
module CBin
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
5
|
+
class Specification
|
6
|
+
class Creator
|
7
|
+
attr_reader :code_spec
|
8
|
+
attr_reader :template_spec
|
9
|
+
attr_reader :spec
|
10
|
+
|
11
|
+
def initialize(code_spec, template_spec, platforms = 'ios')
|
12
|
+
@code_spec = code_spec
|
13
|
+
@template_spec = template_spec
|
14
|
+
@platforms = Array(platforms)
|
15
|
+
validate!
|
16
|
+
end
|
17
|
+
|
18
|
+
def validate!
|
19
|
+
raise Pod::Informative, "源码 podspec 不能为空 ." unless code_spec
|
20
|
+
raise Pod::Informative, "不支持自动生成存在 subspec 的二进制 podspec , 需要提供模版文件 #{code_spec.name}.binary.podspec.template ." if code_spec.subspecs.any? && template_spec.nil?
|
21
|
+
end
|
22
|
+
|
23
|
+
def create
|
24
|
+
spec = template_spec ? create_from_code_spec_and_template_spec : create_from_code_spec
|
25
|
+
|
26
|
+
Pod::UI.message "生成二进制 podspec 内容: "
|
27
|
+
spec.to_pretty_json.split("\n").each do |text|
|
28
|
+
Pod::UI.message text
|
29
|
+
end
|
30
|
+
|
31
|
+
spec
|
32
|
+
end
|
33
|
+
|
34
|
+
def write_spec_file(file = filename)
|
35
|
+
create unless spec
|
36
|
+
|
37
|
+
File.open(file, 'w+') do |f|
|
38
|
+
f.write(spec.to_pretty_json)
|
39
|
+
end
|
40
|
+
|
41
|
+
@filename = file
|
42
|
+
end
|
43
|
+
|
44
|
+
def clear_spec_file
|
45
|
+
File.delete(filename) if File.exist?(filename)
|
46
|
+
end
|
47
|
+
|
48
|
+
def filename
|
49
|
+
@filename ||= "#{spec.name}.binary.podspec.json"
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def create_from_code_spec
|
55
|
+
@spec = code_spec.dup
|
56
|
+
# vendored_frameworks | resources | source | source_files | public_header_files
|
57
|
+
# license | resource_bundles
|
58
|
+
|
59
|
+
# Project Linkin
|
60
|
+
@spec.vendored_frameworks = "#{code_spec.root.name}.framework"
|
61
|
+
|
62
|
+
# Resources
|
63
|
+
extnames = []
|
64
|
+
extnames << '*.bundle' if code_spec_consumer.resource_bundles.any?
|
65
|
+
extnames += code_spec_consumer.resources.map { |r| File.basename(r) } if code_spec_consumer.resources.any?
|
66
|
+
@spec.resources = framework_contents('Resources').flat_map { |r| extnames.map { |e| "#{r}/#{e}" } } if extnames.any?
|
67
|
+
|
68
|
+
# Source Location
|
69
|
+
@spec.source = binary_source
|
70
|
+
|
71
|
+
# Source Code
|
72
|
+
@spec.source_files = framework_contents('Headers/*')
|
73
|
+
@spec.public_header_files = framework_contents('Headers/*')
|
74
|
+
|
75
|
+
# Unused for binary
|
76
|
+
spec_hash = @spec.to_hash
|
77
|
+
# spec_hash.delete('license')
|
78
|
+
spec_hash.delete('resource_bundles')
|
79
|
+
spec_hash.delete('exclude_files')
|
80
|
+
spec_hash.delete('preserve_paths')
|
81
|
+
|
82
|
+
# Filter platforms
|
83
|
+
platforms = spec_hash['platforms']
|
84
|
+
selected_platforms = platforms.select { |k, v| @platforms.include?(k) }
|
85
|
+
spec_hash['platforms'] = selected_platforms.empty? ? platforms : selected_platforms
|
86
|
+
|
87
|
+
@spec = Pod::Specification.from_hash(spec_hash)
|
88
|
+
@spec
|
89
|
+
end
|
90
|
+
|
91
|
+
def create_from_code_spec_and_template_spec
|
92
|
+
@spec = template_spec.dup
|
93
|
+
|
94
|
+
@spec.version = code_spec.version
|
95
|
+
@spec.source = binary_source
|
96
|
+
@spec
|
97
|
+
end
|
98
|
+
|
99
|
+
def binary_source
|
100
|
+
{ http: CBin.config.binary_download_url % [code_spec.root.name, code_spec.version], type: CBin.config.download_file_type }
|
101
|
+
end
|
102
|
+
|
103
|
+
def code_spec_consumer(platform = :ios)
|
104
|
+
code_spec.consumer(:ios)
|
105
|
+
end
|
106
|
+
|
107
|
+
def framework_contents(name)
|
108
|
+
["#{code_spec.root.name}.framework", "#{code_spec.root.name}.framework/Versions/A"].map { |path| "#{path}/#{name}" }
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
112
|
end
|
@@ -4,26 +4,26 @@ require 'cocoapods'
|
|
4
4
|
module Pod
|
5
5
|
class Installer
|
6
6
|
class Analyzer
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
# > 1.5.3 版本
|
8
|
+
# rewrite update_repositories
|
9
|
+
#
|
10
|
+
alias_method :old_update_repositories, :update_repositories
|
11
11
|
def update_repositories
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
12
|
+
if installation_options.update_source_with_multi_processes
|
13
|
+
# 并发更新私有源
|
14
|
+
# 这里多线程会导致 pod update 额外输出 --verbose 的内容
|
15
|
+
# 不知道为什么?
|
16
|
+
Parallel.each(sources, in_processes: 4) do |source|
|
17
|
+
if source.git?
|
18
|
+
config.sources_manager.update(source.name, true)
|
19
|
+
else
|
20
|
+
UI.message "Skipping `#{source.name}` update because the repository is not a git source repository."
|
21
|
+
end
|
22
|
+
end
|
23
|
+
@specs_updated = true
|
24
|
+
else
|
25
|
+
old_update_repositories
|
26
|
+
end
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -1,67 +1,67 @@
|
|
1
1
|
require 'cocoapods'
|
2
2
|
|
3
3
|
module Pod
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
class Podfile
|
5
|
+
USE_BINARIES = 'use_binaries'.freeze
|
6
|
+
USE_SOURCE_PODS = 'use_source_pods'.freeze
|
7
|
+
USE_BINARIES_SELECTOR = 'use_binaries_selector'.freeze
|
8
|
+
# TREAT_DEVELOPMENTS_AS_NORMAL = 'treat_developments_as_normal'.freeze
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
module DSL
|
11
|
+
def use_binaries!(flag = true)
|
12
|
+
set_internal_hash_value(USE_BINARIES, flag)
|
13
|
+
end
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
def use_binaries_with_spec_selector!(&block)
|
16
|
+
raise Informative, '必须提供选择需要二进制组件的 block !' unless block_given?
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
set_internal_hash_value(USE_BINARIES_SELECTOR, block)
|
19
|
+
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
def set_use_source_pods(pods)
|
22
|
+
hash_pods_use_source = get_internal_hash_value(USE_SOURCE_PODS) || []
|
23
|
+
hash_pods_use_source += Array(pods)
|
24
|
+
set_internal_hash_value(USE_SOURCE_PODS, hash_pods_use_source)
|
25
|
+
end
|
26
|
+
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
module ENVExecutor
|
29
|
+
def execute_with_use_binaries(use_binaries, &block)
|
30
|
+
execute_with_key(USE_BINARIES, -> { use_binaries ? 'true' : 'false' }, &block)
|
31
|
+
end
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
def execute_with_key(key, value_returner, &block)
|
34
|
+
origin_value = ENV[key]
|
35
|
+
ENV[key] = value_returner.call
|
36
36
|
|
37
|
-
|
37
|
+
yield if block_given?
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
ENV[key] = origin_value
|
40
|
+
end
|
41
|
+
end
|
42
42
|
|
43
|
-
|
43
|
+
extend ENVExecutor
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
def use_binaries_selector
|
46
|
+
get_internal_hash_value(USE_BINARIES_SELECTOR, nil)
|
47
|
+
end
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
def use_binaries?
|
50
|
+
get_internal_hash_value(USE_BINARIES, false) || ENV[USE_BINARIES] == 'true'
|
51
|
+
end
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
def use_source_pods
|
54
|
+
get_internal_hash_value(USE_SOURCE_PODS, []) + String(ENV[USE_SOURCE_PODS]).split('|').uniq
|
55
|
+
end
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
57
|
+
private
|
58
|
+
# set_hash_value 有 key 限制
|
59
|
+
def set_internal_hash_value(key, value)
|
60
|
+
internal_hash[key] = value
|
61
|
+
end
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
63
|
+
def get_internal_hash_value(key, default = nil)
|
64
|
+
internal_hash.fetch(key, default)
|
65
|
+
end
|
66
|
+
end
|
67
67
|
end
|
@@ -6,100 +6,100 @@ require 'cocoapods-bin/native/installation_options'
|
|
6
6
|
require 'cocoapods-bin/gem_version'
|
7
7
|
|
8
8
|
module Pod
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
9
|
+
class Resolver
|
10
|
+
# >= 1.4.0 才有 resolver_specs_by_target 以及 ResolverSpecification
|
11
|
+
# >= 1.5.0 ResolverSpecification 才有 source,供 install 或者其他操作时,输入 source 变更
|
12
|
+
#
|
13
|
+
if Pod.match_version?('~> 1.4')
|
14
|
+
old_resolver_specs_by_target = instance_method(:resolver_specs_by_target)
|
15
|
+
define_method(:resolver_specs_by_target) do
|
16
|
+
specs_by_target = old_resolver_specs_by_target.bind(self).call()
|
17
|
+
|
18
|
+
sources_manager = Config.instance.sources_manager
|
19
|
+
use_source_pods = podfile.use_source_pods
|
20
|
+
|
21
|
+
missing_binary_specs = []
|
22
|
+
specs_by_target.each do |target, rspecs|
|
23
|
+
# use_binaries 并且 use_source_pods 不包含
|
24
|
+
use_binary_rspecs = if podfile.use_binaries? || podfile.use_binaries_selector
|
25
|
+
rspecs.select do |rspec|
|
26
|
+
([rspec.name, rspec.root.name] & use_source_pods).empty? &&
|
27
|
+
(podfile.use_binaries_selector.nil? || podfile.use_binaries_selector.call(rspec.spec))
|
28
|
+
end
|
29
|
+
else
|
30
|
+
[]
|
31
|
+
end
|
32
|
+
|
33
|
+
# Parallel.map(rspecs, in_threads: 8) do |rspec|
|
34
|
+
specs_by_target[target] = rspecs.map do |rspec|
|
35
|
+
# 含有 subspecs 的组件暂不处理
|
36
|
+
# next rspec if rspec.spec.subspec? || rspec.spec.subspecs.any?
|
37
|
+
|
38
|
+
# developments 组件采用默认输入的 spec (development pods 的 source 为 nil)
|
39
|
+
next rspec unless rspec.spec.respond_to?(:spec_source) && rspec.spec.spec_source
|
40
|
+
|
41
|
+
# 采用二进制依赖并且不为开发组件
|
42
|
+
use_binary = use_binary_rspecs.include?(rspec)
|
43
|
+
source = use_binary ? sources_manager.binary_source : sources_manager.code_source
|
44
|
+
|
45
|
+
spec_version = rspec.spec.version
|
46
|
+
begin
|
47
|
+
# 从新 source 中获取 spec
|
48
|
+
specification = source.specification(rspec.root.name, spec_version)
|
49
|
+
|
50
|
+
# 组件是 subspec
|
51
|
+
specification = specification.subspec_by_name(rspec.name, false, true) if rspec.spec.subspec?
|
52
|
+
# 这里可能出现分析依赖的 source 和切换后的 source 对应 specification 的 subspec 对应不上
|
53
|
+
# 造成 subspec_by_name 返回 nil,这个是正常现象
|
54
|
+
next unless specification
|
55
|
+
|
56
|
+
# 组装新的 rspec ,替换原 rspec
|
57
|
+
rspec = if Pod.match_version?('~> 1.4.0')
|
58
|
+
ResolverSpecification.new(specification, rspec.used_by_tests_only)
|
59
|
+
else
|
60
|
+
ResolverSpecification.new(specification, rspec.used_by_tests_only, source)
|
61
|
+
end
|
62
|
+
rspec
|
63
|
+
rescue Pod::StandardError => error
|
64
|
+
# 没有从新的 source 找到对应版本组件,直接返回原 rspec
|
65
|
+
missing_binary_specs << rspec.spec if use_binary
|
66
|
+
rspec
|
67
|
+
end
|
68
|
+
|
69
|
+
rspec
|
70
|
+
end.compact
|
71
|
+
end
|
72
|
+
|
73
|
+
missing_binary_specs.uniq.each do |spec|
|
74
|
+
UI.message "【#{spec.name} | #{spec.version}】组件无对应二进制版本 , 将采用源码依赖."
|
75
|
+
end if missing_binary_specs.any?
|
76
|
+
|
77
|
+
specs_by_target
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
if Pod.match_version?('~> 1.4.0')
|
83
|
+
# 1.4.0 没有 spec_source
|
84
|
+
class Specification
|
85
|
+
class Set
|
86
|
+
class LazySpecification < BasicObject
|
87
|
+
attr_reader :spec_source
|
88
|
+
|
89
|
+
old_initialize = instance_method(:initialize)
|
90
|
+
define_method(:initialize) do |name, version, source|
|
91
|
+
old_initialize.bind(self).call(name, version, source)
|
92
|
+
|
93
|
+
@spec_source = source
|
94
|
+
end
|
95
|
+
|
96
|
+
def respond_to?(method, include_all = false)
|
97
|
+
return super unless method == :spec_source
|
98
|
+
true
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
104
|
end
|
105
105
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'cocoapods-bin/native/sources_manager'
|
2
2
|
|
3
3
|
Pod::HooksManager.register('cocoapods-bin', :source_provider) do |context, _|
|
4
|
-
|
5
|
-
|
4
|
+
sources_manager = Pod::Config.instance.sources_manager
|
5
|
+
podfile = Pod::Config.instance.podfile
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
# 添加二进制私有源 && 源码私有源
|
8
|
+
added_sources = [sources_manager.code_source, sources_manager.binary_source]
|
9
|
+
added_sources.reverse! if podfile.use_binaries? || podfile.use_binaries_selector
|
10
|
+
added_sources.each { |source| context.add_source(source) }
|
11
11
|
end
|