cocoapods-bin 0.0.1 → 0.0.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/lib/cocoapods-bin/command/bin/lib/lint.rb +26 -22
- data/lib/cocoapods-bin/command/bin/open.rb +0 -1
- data/lib/cocoapods-bin/command/bin/repo/push.rb +25 -21
- data/lib/cocoapods-bin/command/bin/spec/create.rb +25 -25
- data/lib/cocoapods-bin/gem_version.rb +1 -1
- data/lib/cocoapods-bin/helpers/spec_creator.rb +110 -0
- data/lib/cocoapods-bin/helpers/spec_files_helper.rb +42 -0
- data/lib/cocoapods-bin/helpers.rb +1 -1
- data/lib/cocoapods-bin/native/acknowledgements.rb +24 -0
- data/lib/cocoapods-bin/native/installer.rb +68 -33
- data/lib/cocoapods-bin/native.rb +1 -0
- metadata +4 -3
- data/lib/cocoapods-bin/helpers/spec_generator.rb +0 -86
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 560ddbfb4258324c1e3dbcf1c35fa58fcd238b7e
|
4
|
+
data.tar.gz: b02c0f9c578eed09d6cb850593beded52b7c6f82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5ebe970aeca3cc85adbe7615783406569d98dcc4de4eadb658cf6e2c05a43fc5b8fa2d7bd9a2cf6917b0a51160afe4992243b534835716d4798b99796f6c227
|
7
|
+
data.tar.gz: 50f193d2d9c6f37a5d1201c7fac572800f968671f970e2afc5ff3a65e0bd646000dfc8ef242f7f4eabb8adf5479495d21877a6d0668729a528c4135b63cad9bf
|
data/Gemfile.lock
CHANGED
@@ -18,6 +18,7 @@ module Pod
|
|
18
18
|
def self.options
|
19
19
|
[
|
20
20
|
['--binary', 'lint 组件的二进制版本'],
|
21
|
+
['--template-podspec=A.binary-template.podspec', '生成拥有 subspec 的二进制 spec 需要的模版 podspec, 插件会更改 version 和 source'],
|
21
22
|
['--code-dependencies', '使用源码依赖进行 lint'],
|
22
23
|
['--loose-options', '添加宽松的 options, 可能包括 --use-libraries (可能会造成 entry point (start) undefined)'],
|
23
24
|
['--reserve-created-spec', '保留生成的二进制 spec 文件'],
|
@@ -31,6 +32,7 @@ module Pod
|
|
31
32
|
@code_dependencies = argv.flag?('code-dependencies')
|
32
33
|
@sources = argv.option('sources') || []
|
33
34
|
@reserve_created_spec = argv.flag?('reserve-created-spec')
|
35
|
+
@template_podspec = argv.option('template-podspec')
|
34
36
|
super
|
35
37
|
|
36
38
|
@additional_args = argv.remainder!
|
@@ -39,54 +41,56 @@ module Pod
|
|
39
41
|
def run
|
40
42
|
Podfile.execute_with_use_binaries(!@code_dependencies) do
|
41
43
|
argvs = [
|
42
|
-
spec_file,
|
43
44
|
"--sources=#{sources_option(@code_dependencies, @sources)}",
|
44
45
|
*@additional_args
|
45
46
|
]
|
47
|
+
|
48
|
+
argvs << spec_file if spec_file
|
46
49
|
|
47
50
|
if @loose_options
|
48
51
|
argvs << '--allow-warnings'
|
49
|
-
argvs << '--use-libraries' if
|
52
|
+
argvs << '--use-libraries' if code_spec.all_dependencies.any?
|
50
53
|
end
|
51
54
|
|
52
|
-
|
53
55
|
lint = Pod::Command::Lib::Lint.new(CLAide::ARGV.new(argvs))
|
54
56
|
lint.validate!
|
55
57
|
lint.run
|
56
58
|
end
|
57
59
|
ensure
|
58
|
-
|
60
|
+
clear_binary_spec_file_if_needed
|
59
61
|
end
|
60
62
|
|
61
63
|
private
|
62
64
|
|
63
|
-
|
64
|
-
|
65
|
+
|
66
|
+
def template_spec_file
|
67
|
+
@template_spec_file ||= begin
|
68
|
+
if @template_podspec
|
69
|
+
find_spec_file(@template_podspec)
|
70
|
+
else
|
71
|
+
binary_template_spec_file
|
72
|
+
end
|
73
|
+
end
|
65
74
|
end
|
66
75
|
|
67
76
|
def spec_file
|
68
77
|
@spec_file ||= begin
|
69
78
|
if @podspec
|
70
|
-
|
71
|
-
raise Informative, "Couldn't find #{@podspec}" unless path.exist?
|
72
|
-
path
|
79
|
+
find_spec_file(@podspec)
|
73
80
|
else
|
74
|
-
raise Informative, "
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
81
|
+
raise Informative, "当前目录下没有找到可用源码 podspec." if code_spec_files.empty?
|
82
|
+
|
83
|
+
spec_file = if @binary
|
84
|
+
code_spec = Pod::Specification.from_file(code_spec_files.first)
|
85
|
+
template_spec = Pod::Specification.from_file(template_spec_file) if template_spec_file
|
86
|
+
create_binary_spec_file(code_spec, template_spec)
|
87
|
+
else
|
88
|
+
code_spec_files.first
|
89
|
+
end
|
90
|
+
spec_file
|
79
91
|
end
|
80
92
|
end
|
81
93
|
end
|
82
|
-
|
83
|
-
def generate_binary_spec_file(code_spec_path)
|
84
|
-
spec = Pod::Specification.from_file(code_spec_path)
|
85
|
-
@spec_generator = CBin::SpecGenerator.new(spec)
|
86
|
-
@spec_generator.generate
|
87
|
-
@spec_generator.write_to_spec_file
|
88
|
-
@spec_generator.filename
|
89
|
-
end
|
90
94
|
end
|
91
95
|
end
|
92
96
|
end
|
@@ -18,6 +18,7 @@ module Pod
|
|
18
18
|
def self.options
|
19
19
|
[
|
20
20
|
['--binary', '发布组件的二进制版本'],
|
21
|
+
['--template-podspec=A.binary-template.podspec', '生成拥有 subspec 的二进制 spec 需要的模版 podspec, 插件会更改 version 和 source'],
|
21
22
|
['--code-dependencies', '使用源码依赖进行 lint'],
|
22
23
|
['--loose-options', '添加宽松的 options, 可能包括 --use-libraries (可能会造成 entry point (start) undefined)'],
|
23
24
|
['--reserve-created-spec', '保留生成的二进制 spec 文件'],
|
@@ -31,6 +32,7 @@ module Pod
|
|
31
32
|
@code_dependencies = argv.flag?('code-dependencies')
|
32
33
|
@sources = argv.option('sources') || []
|
33
34
|
@reserve_created_spec = argv.flag?('reserve-created-spec')
|
35
|
+
@template_podspec = argv.option('template-podspec')
|
34
36
|
super
|
35
37
|
|
36
38
|
@additional_args = argv.remainder!
|
@@ -40,14 +42,15 @@ module Pod
|
|
40
42
|
Podfile.execute_with_use_binaries(!@code_dependencies) do
|
41
43
|
argvs = [
|
42
44
|
repo,
|
43
|
-
spec_file,
|
44
45
|
"--sources=#{sources_option(@code_dependencies, @sources)}",
|
45
46
|
*@additional_args
|
46
47
|
]
|
47
48
|
|
49
|
+
argvs << spec_file if spec_file
|
50
|
+
|
48
51
|
if @loose_options
|
49
52
|
argvs += ['--allow-warnings', '--use-json']
|
50
|
-
argvs << '--use-libraries' if
|
53
|
+
argvs << '--use-libraries' if code_spec.all_dependencies.any?
|
51
54
|
end
|
52
55
|
|
53
56
|
push = Pod::Command::Repo::Push.new(CLAide::ARGV.new(argvs))
|
@@ -55,39 +58,40 @@ module Pod
|
|
55
58
|
push.run
|
56
59
|
end
|
57
60
|
ensure
|
58
|
-
|
61
|
+
clear_binary_spec_file_if_needed
|
59
62
|
end
|
60
63
|
|
61
64
|
private
|
62
65
|
|
63
|
-
def
|
64
|
-
|
66
|
+
def template_spec_file
|
67
|
+
@template_spec_file ||= begin
|
68
|
+
if @template_podspec
|
69
|
+
find_spec_file(@template_podspec)
|
70
|
+
else
|
71
|
+
binary_template_spec_file
|
72
|
+
end
|
73
|
+
end
|
65
74
|
end
|
66
75
|
|
67
76
|
def spec_file
|
68
77
|
@spec_file ||= begin
|
69
78
|
if @podspec
|
70
|
-
|
71
|
-
raise Informative, "Couldn't find #{@podspec}" unless path.exist?
|
72
|
-
path
|
79
|
+
find_spec_file(@podspec)
|
73
80
|
else
|
74
|
-
raise Informative, "
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
81
|
+
raise Informative, "当前目录下没有找到可用源码 podspec." if code_spec_files.empty?
|
82
|
+
|
83
|
+
spec_file = if @binary
|
84
|
+
code_spec = Pod::Specification.from_file(code_spec_files.first)
|
85
|
+
template_spec = Pod::Specification.from_file(template_spec_file) if template_spec_file
|
86
|
+
create_binary_spec_file(code_spec, template_spec)
|
87
|
+
else
|
88
|
+
code_spec_files.first
|
89
|
+
end
|
90
|
+
spec_file
|
79
91
|
end
|
80
92
|
end
|
81
93
|
end
|
82
94
|
|
83
|
-
def generate_binary_spec_file(code_spec_path)
|
84
|
-
spec = Pod::Specification.from_file(code_spec_path)
|
85
|
-
@spec_generator = CBin::SpecGenerator.new(spec)
|
86
|
-
@spec_generator.generate
|
87
|
-
@spec_generator.write_to_spec_file
|
88
|
-
@spec_generator.filename
|
89
|
-
end
|
90
|
-
|
91
95
|
def repo
|
92
96
|
@binary ? binary_source.name : code_source.name
|
93
97
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'cocoapods-bin/helpers
|
1
|
+
require 'cocoapods-bin/helpers'
|
2
2
|
|
3
3
|
module Pod
|
4
4
|
class Command
|
@@ -10,53 +10,53 @@ module Pod
|
|
10
10
|
根据源码 podspec 文件,创建对应的二进制 podspec 文件.
|
11
11
|
DESC
|
12
12
|
|
13
|
-
self.arguments = [
|
14
|
-
CLAide::Argument.new('NAME.podspec', false),
|
15
|
-
]
|
16
|
-
|
17
13
|
def self.options
|
18
14
|
[
|
19
15
|
['--platforms=ios', '生成二进制 spec 支持的平台'],
|
16
|
+
['--template-podspec=A.binary-template.podspec', '生成拥有 subspec 的二进制 spec 需要的模版 podspec, 插件会更改 version 和 source'],
|
20
17
|
['--no-overwrite', '不允许覆盖']
|
21
18
|
].concat(super)
|
22
19
|
end
|
23
20
|
|
24
21
|
def initialize(argv)
|
25
|
-
@platforms = argv.option('platforms'
|
22
|
+
@platforms = argv.option('platforms', 'ios')
|
26
23
|
@allow_overwrite = argv.flag?('overwrite', true)
|
24
|
+
@template_podspec = argv.option('template-podspec')
|
27
25
|
@podspec = argv.shift_argument
|
28
26
|
super
|
29
27
|
end
|
30
28
|
|
31
29
|
def run
|
30
|
+
UI.puts "开始读取 podspec 文件...\n"
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
UI.puts "开始生成二进制 podspec 文件...\n"
|
37
|
-
spec_generator = CBin::SpecGenerator.new(spec, @platforms)
|
38
|
-
spec_generator.generate
|
39
|
-
|
40
|
-
UI.puts "开始保存 #{spec_generator.filename} 文件至当前目录...\n"
|
32
|
+
code_spec = Pod::Specification.from_file(spec_file)
|
33
|
+
template_spec = Pod::Specification.from_file(template_spec_file) if template_spec_file
|
41
34
|
|
42
|
-
if
|
43
|
-
UI.warn "二进制 podspec 文件 #{
|
35
|
+
if binary_spec && !@allow_overwrite
|
36
|
+
UI.warn "二进制 podspec 文件 #{binary_spec_files.first} 已存在.\n"
|
44
37
|
else
|
45
|
-
|
46
|
-
|
38
|
+
UI.puts "开始生成二进制 podspec 文件...\n"
|
39
|
+
spec_file = create_binary_spec_file(code_spec, template_spec)
|
40
|
+
UI.puts "创建二进制 podspec 文件 #{spec_file} 成功.\n".green
|
47
41
|
end
|
48
42
|
end
|
49
43
|
|
50
|
-
|
44
|
+
def template_spec_file
|
45
|
+
@template_spec_file ||= begin
|
46
|
+
if @template_podspec
|
47
|
+
find_spec_file(@template_podspec)
|
48
|
+
else
|
49
|
+
binary_template_spec_file
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
51
53
|
|
52
|
-
def
|
53
|
-
@
|
54
|
+
def spec_file
|
55
|
+
@spec_file ||= begin
|
54
56
|
if @podspec
|
55
|
-
|
56
|
-
raise Informative, "Couldn't find #{@podspec}" unless path.exist?
|
57
|
-
path
|
57
|
+
find_spec_file(@podspec)
|
58
58
|
else
|
59
|
-
raise Informative, "
|
59
|
+
raise Informative, "当前目录下没有找到可用源码 podspec." if code_spec_files.empty?
|
60
60
|
code_spec_files.first
|
61
61
|
end
|
62
62
|
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'cocoapods'
|
2
|
+
require 'cocoapods-bin/config/config'
|
3
|
+
|
4
|
+
module CBin
|
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
|
+
|
80
|
+
# Filter platforms
|
81
|
+
platforms = spec_hash['platforms']
|
82
|
+
selected_platforms = platforms.select { |k, v| @platforms.include?(k) }
|
83
|
+
spec_hash['platforms'] = selected_platforms.empty? ? platforms : selected_platforms
|
84
|
+
|
85
|
+
@spec = Pod::Specification.from_hash(spec_hash)
|
86
|
+
@spec
|
87
|
+
end
|
88
|
+
|
89
|
+
def create_from_code_spec_and_template_spec
|
90
|
+
@spec = template_spec.dup
|
91
|
+
|
92
|
+
@spec.version = code_spec.version
|
93
|
+
@spec.source = binary_source
|
94
|
+
@spec
|
95
|
+
end
|
96
|
+
|
97
|
+
def binary_source
|
98
|
+
{ http: CBin.config.binary_download_url % [code_spec.root.name, code_spec.version] }
|
99
|
+
end
|
100
|
+
|
101
|
+
def code_spec_consumer(platform = :ios)
|
102
|
+
code_spec.consumer(:ios)
|
103
|
+
end
|
104
|
+
|
105
|
+
def framework_contents(name)
|
106
|
+
["#{code_spec.root.name}.framework", "#{code_spec.root.name}.framework/Versions/A"].map { |path| "#{path}/#{name}" }
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -10,8 +10,50 @@ module CBin
|
|
10
10
|
@binary_spec_files ||= Pathname.glob('*.binary.podspec{,.json}')
|
11
11
|
end
|
12
12
|
|
13
|
+
def binary_template_spec_file
|
14
|
+
@binary_spec_template_file ||= Pathname.glob('*.binary-template.podspec{,.json}').first
|
15
|
+
end
|
16
|
+
|
13
17
|
def code_spec_files
|
14
18
|
@code_spec_files ||= spec_files - binary_spec_files
|
15
19
|
end
|
20
|
+
|
21
|
+
def code_spec
|
22
|
+
Pod::Specification.from_file(code_spec_files.first) if code_spec_files.first
|
23
|
+
end
|
24
|
+
|
25
|
+
def binary_spec
|
26
|
+
Pod::Specification.from_file(binary_spec_files.first) if binary_spec_files.first
|
27
|
+
end
|
28
|
+
|
29
|
+
def binary_template_spec
|
30
|
+
Pod::Specification.from_file(binary_template_spec_file) if binary_template_spec_file
|
31
|
+
end
|
32
|
+
|
33
|
+
def find_spec_file(podspec)
|
34
|
+
path = Pathname(podspec)
|
35
|
+
raise Pod::Informative, "无法找到 #{podspec}" unless path.exist?
|
36
|
+
path
|
37
|
+
end
|
38
|
+
|
39
|
+
def create_binary_spec_file(code_spec, template_spec)
|
40
|
+
# 1. code spec 是否有 subpsec
|
41
|
+
# 1.1 有,查找 template spec,并生成
|
42
|
+
# 1.2 没有,是否有 template spec
|
43
|
+
# 1.2.1 有,根据 template spec 生成
|
44
|
+
# 1.2.2 没有,根据 code spec 生成
|
45
|
+
|
46
|
+
raise Pod::Informative, "没有二进制 podspec 的情况下,必须要提供源码 podspec." unless code_spec
|
47
|
+
raise Pod::Informative, "拥有 subspec 的组件,在生成二进制 podspec 时,必须要提供模版 podspec." if code_spec.subspecs.any? && template_spec.nil?
|
48
|
+
|
49
|
+
@spec_creator = CBin::Specification::Creator.new(code_spec, template_spec)
|
50
|
+
@spec_creator.create
|
51
|
+
@spec_creator.write_spec_file
|
52
|
+
@spec_creator.filename
|
53
|
+
end
|
54
|
+
|
55
|
+
def clear_binary_spec_file_if_needed
|
56
|
+
@spec_creator.clear_spec_file if @spec_creator
|
57
|
+
end
|
16
58
|
end
|
17
59
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Pod
|
2
|
+
module Generator
|
3
|
+
class Acknowledgements
|
4
|
+
def license_text(spec)
|
5
|
+
return nil unless spec.license
|
6
|
+
text = spec.license[:text]
|
7
|
+
unless text
|
8
|
+
if license_file = spec.license[:file]
|
9
|
+
license_path = file_accessor(spec).root + license_file
|
10
|
+
if File.exist?(license_path)
|
11
|
+
text = IO.read(license_path)
|
12
|
+
else
|
13
|
+
# UI.warn "Unable to read the license file `#{license_file}` " \
|
14
|
+
# "for the spec `#{spec}`"
|
15
|
+
end
|
16
|
+
elsif license_file = file_accessor(spec).license
|
17
|
+
text = IO.read(license_file)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
text
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -11,45 +11,80 @@ module Pod
|
|
11
11
|
installer
|
12
12
|
end
|
13
13
|
|
14
|
-
# rewrite install_pod_sources
|
15
14
|
alias_method :old_install_pod_sources, :install_pod_sources
|
16
15
|
def install_pod_sources
|
17
16
|
if installation_options.install_with_multi_processes
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
current_version = spec.version
|
27
|
-
previous_version = sandbox.manifest.version(spec.name)
|
28
|
-
has_changed_version = current_version != previous_version
|
29
|
-
current_repo = analysis_result.specs_by_source.detect { |key, values| break key if values.map(&:name).include?(spec.name) }
|
30
|
-
current_repo &&= current_repo.url || current_repo.name
|
31
|
-
previous_spec_repo = sandbox.manifest.spec_repo(spec.name)
|
32
|
-
has_changed_repo = !previous_spec_repo.nil? && current_repo && (current_repo != previous_spec_repo)
|
33
|
-
title = "Installing #{spec.name} #{spec.version}"
|
34
|
-
title << " (was #{previous_version} and source changed to `#{current_repo}` from `#{previous_spec_repo}`)" if has_changed_version && has_changed_repo
|
35
|
-
title << " (was #{previous_version})" if has_changed_version && !has_changed_repo
|
36
|
-
title << " (source changed to `#{current_repo}` from `#{previous_spec_repo}`)" if !has_changed_version && has_changed_repo
|
37
|
-
else
|
38
|
-
title = "Installing #{spec}"
|
39
|
-
end
|
40
|
-
UI.titled_section(title.green, title_options) do
|
41
|
-
install_source_of_pod(spec.name)
|
42
|
-
end
|
43
|
-
else
|
44
|
-
UI.titled_section("Using #{spec}", title_options) do
|
45
|
-
create_pod_installer(spec.name)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
else
|
17
|
+
if Pod.match_version?('~> 1.4.0')
|
18
|
+
install_pod_sources_for_version_in_1_4_0
|
19
|
+
elsif Pod.match_version?('~> 1.5')
|
20
|
+
install_pod_sources_for_version_above_1_5_0
|
21
|
+
else
|
22
|
+
old_install_pod_sources
|
23
|
+
end
|
24
|
+
else
|
50
25
|
old_install_pod_sources
|
51
26
|
end
|
52
27
|
end
|
28
|
+
|
29
|
+
|
30
|
+
# rewrite install_pod_sources
|
31
|
+
def install_pod_sources_for_version_in_1_4_0
|
32
|
+
@installed_specs = []
|
33
|
+
pods_to_install = sandbox_state.added | sandbox_state.changed
|
34
|
+
title_options = { :verbose_prefix => '-> '.green }
|
35
|
+
Parallel.each(root_specs.sort_by(&:name), in_threads: 10) do |spec|
|
36
|
+
if pods_to_install.include?(spec.name)
|
37
|
+
if sandbox_state.changed.include?(spec.name) && sandbox.manifest
|
38
|
+
previous = sandbox.manifest.version(spec.name)
|
39
|
+
title = "Installing #{spec.name} #{spec.version} (was #{previous})"
|
40
|
+
else
|
41
|
+
title = "Installing #{spec}"
|
42
|
+
end
|
43
|
+
UI.titled_section(title.green, title_options) do
|
44
|
+
install_source_of_pod(spec.name)
|
45
|
+
end
|
46
|
+
else
|
47
|
+
UI.titled_section("Using #{spec}", title_options) do
|
48
|
+
create_pod_installer(spec.name)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def install_pod_sources_for_version_above_1_5_0
|
55
|
+
@installed_specs = []
|
56
|
+
pods_to_install = sandbox_state.added | sandbox_state.changed
|
57
|
+
title_options = { :verbose_prefix => '-> '.green }
|
58
|
+
# 多进程下载,多线程时 log 会显著交叉,多进程好点,但是多进程需要利用文件锁对 cache 进行保护
|
59
|
+
# in_processes: 10
|
60
|
+
Parallel.each(root_specs.sort_by(&:name), in_threads: 10) do |spec|
|
61
|
+
if pods_to_install.include?(spec.name)
|
62
|
+
if sandbox_state.changed.include?(spec.name) && sandbox.manifest
|
63
|
+
current_version = spec.version
|
64
|
+
previous_version = sandbox.manifest.version(spec.name)
|
65
|
+
has_changed_version = current_version != previous_version
|
66
|
+
current_repo = analysis_result.specs_by_source.detect { |key, values| break key if values.map(&:name).include?(spec.name) }
|
67
|
+
current_repo &&= current_repo.url || current_repo.name
|
68
|
+
previous_spec_repo = sandbox.manifest.spec_repo(spec.name)
|
69
|
+
has_changed_repo = !previous_spec_repo.nil? && current_repo && (current_repo != previous_spec_repo)
|
70
|
+
title = "Installing #{spec.name} #{spec.version}"
|
71
|
+
title << " (was #{previous_version} and source changed to `#{current_repo}` from `#{previous_spec_repo}`)" if has_changed_version && has_changed_repo
|
72
|
+
title << " (was #{previous_version})" if has_changed_version && !has_changed_repo
|
73
|
+
title << " (source changed to `#{current_repo}` from `#{previous_spec_repo}`)" if !has_changed_version && has_changed_repo
|
74
|
+
else
|
75
|
+
title = "Installing #{spec}"
|
76
|
+
end
|
77
|
+
UI.titled_section(title.green, title_options) do
|
78
|
+
install_source_of_pod(spec.name)
|
79
|
+
end
|
80
|
+
else
|
81
|
+
UI.titled_section("Using #{spec}", title_options) do
|
82
|
+
create_pod_installer(spec.name)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
53
88
|
end
|
54
89
|
|
55
90
|
module Downloader
|
data/lib/cocoapods-bin/native.rb
CHANGED
@@ -8,6 +8,7 @@ if Pod.match_version?('~> 1.4')
|
|
8
8
|
require 'cocoapods-bin/native/resolver'
|
9
9
|
require 'cocoapods-bin/native/source'
|
10
10
|
require 'cocoapods-bin/native/validator'
|
11
|
+
require 'cocoapods-bin/native/acknowledgements'
|
11
12
|
end
|
12
13
|
|
13
14
|
require 'cocoapods-bin/native/source_provider_hook'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-bin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tripleCC
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parallel
|
@@ -97,9 +97,10 @@ files:
|
|
97
97
|
- lib/cocoapods-bin/gem_version.rb
|
98
98
|
- lib/cocoapods-bin/helpers.rb
|
99
99
|
- lib/cocoapods-bin/helpers/sources_helper.rb
|
100
|
+
- lib/cocoapods-bin/helpers/spec_creator.rb
|
100
101
|
- lib/cocoapods-bin/helpers/spec_files_helper.rb
|
101
|
-
- lib/cocoapods-bin/helpers/spec_generator.rb
|
102
102
|
- lib/cocoapods-bin/native.rb
|
103
|
+
- lib/cocoapods-bin/native/acknowledgements.rb
|
103
104
|
- lib/cocoapods-bin/native/analyzer.rb
|
104
105
|
- lib/cocoapods-bin/native/installation_options.rb
|
105
106
|
- lib/cocoapods-bin/native/installer.rb
|
@@ -1,86 +0,0 @@
|
|
1
|
-
require 'cocoapods'
|
2
|
-
require 'cocoapods-bin/config/config'
|
3
|
-
|
4
|
-
module CBin
|
5
|
-
class SpecGenerator
|
6
|
-
attr_reader :ref_spec
|
7
|
-
attr_reader :spec
|
8
|
-
|
9
|
-
def initialize(ref_spec, platforms = 'ios')
|
10
|
-
@ref_spec = ref_spec
|
11
|
-
@platforms = Array(platforms)
|
12
|
-
validate!
|
13
|
-
end
|
14
|
-
|
15
|
-
def validate!
|
16
|
-
raise StandardError, '不支持自动生成存在 subspec 的二进制 podspec .' if ref_spec.subspecs.any?
|
17
|
-
end
|
18
|
-
|
19
|
-
def generate
|
20
|
-
@spec = @ref_spec.dup
|
21
|
-
# vendored_frameworks | resources | source | source_files | public_header_files
|
22
|
-
# license | resource_bundles
|
23
|
-
|
24
|
-
# Project Linkin
|
25
|
-
@spec.vendored_frameworks = "#{ref_spec.root.name}.framework"
|
26
|
-
|
27
|
-
# Resources
|
28
|
-
extnames = []
|
29
|
-
extnames << '*.bundle' if ref_spec_consumer.resource_bundles.any?
|
30
|
-
extnames += ref_spec_consumer.resources.map { |r| File.basename(r) } if ref_spec_consumer.resources.any?
|
31
|
-
@spec.resources = framework_contents('Resources').flat_map { |r| extnames.map { |e| "#{r}/#{e}" } } if extnames.any?
|
32
|
-
|
33
|
-
# Source Location
|
34
|
-
@spec.source = { http: CBin.config.binary_download_url % [ref_spec.root.name, ref_spec.version] }
|
35
|
-
|
36
|
-
# Source Code
|
37
|
-
@spec.source_files = framework_contents('Headers/*')
|
38
|
-
@spec.public_header_files = framework_contents('Headers/*')
|
39
|
-
|
40
|
-
# Unused for binary
|
41
|
-
spec_hash = @spec.to_hash
|
42
|
-
# spec_hash.delete('license')
|
43
|
-
spec_hash.delete('resource_bundles')
|
44
|
-
|
45
|
-
# Filter platforms
|
46
|
-
platforms = spec_hash['platforms']
|
47
|
-
selected_platforms = platforms.select { |k, v| @platforms.include?(k) }
|
48
|
-
spec_hash['platforms'] = selected_platforms.empty? ? platforms : selected_platforms
|
49
|
-
|
50
|
-
@spec = Pod::Specification.from_hash(spec_hash)
|
51
|
-
|
52
|
-
Pod::UI.message "生成二进制 podspec 内容: "
|
53
|
-
@spec.to_pretty_json.split("\n").each do |text|
|
54
|
-
Pod::UI.message text
|
55
|
-
end
|
56
|
-
|
57
|
-
@spec
|
58
|
-
end
|
59
|
-
|
60
|
-
def write_to_spec_file(file = filename)
|
61
|
-
File.open(file, 'w+') do |f|
|
62
|
-
f.write(spec.to_pretty_json)
|
63
|
-
end
|
64
|
-
|
65
|
-
@filename = file
|
66
|
-
end
|
67
|
-
|
68
|
-
def clear_spec_file
|
69
|
-
File.delete(@filename) if File.exist?(@filename)
|
70
|
-
end
|
71
|
-
|
72
|
-
def filename
|
73
|
-
@filename ||= "#{spec.name}.binary.podspec.json"
|
74
|
-
end
|
75
|
-
|
76
|
-
private
|
77
|
-
|
78
|
-
def ref_spec_consumer(platform = :ios)
|
79
|
-
ref_spec.consumer(:ios)
|
80
|
-
end
|
81
|
-
|
82
|
-
def framework_contents(name)
|
83
|
-
["#{ref_spec.root.name}.framework", "#{ref_spec.root.name}.framework/Versions/A"].map { |path| "#{path}/#{name}" }
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|