cocoapods-fy-bin 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/LICENSE.txt +22 -0
- data/README.md +1 -0
- data/lib/cocoapods-fy-bin/command/bin/archive.rb +202 -0
- data/lib/cocoapods-fy-bin/command/bin/auto.rb +204 -0
- data/lib/cocoapods-fy-bin/command/bin/code.rb +232 -0
- data/lib/cocoapods-fy-bin/command/bin/imy.rb +46 -0
- data/lib/cocoapods-fy-bin/command/bin/init.rb +69 -0
- data/lib/cocoapods-fy-bin/command/bin/initHotKey.rb +70 -0
- data/lib/cocoapods-fy-bin/command/bin/install.rb +44 -0
- data/lib/cocoapods-fy-bin/command/bin/lib/lint.rb +69 -0
- data/lib/cocoapods-fy-bin/command/bin/repo/update.rb +43 -0
- data/lib/cocoapods-fy-bin/command/bin/spec/create.rb +73 -0
- data/lib/cocoapods-fy-bin/command/bin/spec/push.rb +114 -0
- data/lib/cocoapods-fy-bin/command/bin/update.rb +154 -0
- data/lib/cocoapods-fy-bin/command/bin.rb +59 -0
- data/lib/cocoapods-fy-bin/command.rb +2 -0
- data/lib/cocoapods-fy-bin/config/config.rb +137 -0
- data/lib/cocoapods-fy-bin/config/config_asker.rb +57 -0
- data/lib/cocoapods-fy-bin/config/config_builder.rb +228 -0
- data/lib/cocoapods-fy-bin/config/config_hot_key.rb +103 -0
- data/lib/cocoapods-fy-bin/config/config_hot_key_asker.rb +57 -0
- data/lib/cocoapods-fy-bin/gem_version.rb +10 -0
- data/lib/cocoapods-fy-bin/helpers/build_helper.rb +164 -0
- data/lib/cocoapods-fy-bin/helpers/build_utils.rb +63 -0
- data/lib/cocoapods-fy-bin/helpers/framework.rb +94 -0
- data/lib/cocoapods-fy-bin/helpers/framework_builder.rb +419 -0
- data/lib/cocoapods-fy-bin/helpers/library.rb +54 -0
- data/lib/cocoapods-fy-bin/helpers/library_builder.rb +91 -0
- data/lib/cocoapods-fy-bin/helpers/sources_helper.rb +36 -0
- data/lib/cocoapods-fy-bin/helpers/spec_creator.rb +170 -0
- data/lib/cocoapods-fy-bin/helpers/spec_files_helper.rb +77 -0
- data/lib/cocoapods-fy-bin/helpers/spec_source_creator.rb +229 -0
- data/lib/cocoapods-fy-bin/helpers/upload_helper.rb +97 -0
- data/lib/cocoapods-fy-bin/helpers.rb +5 -0
- data/lib/cocoapods-fy-bin/native/acknowledgements.rb +27 -0
- data/lib/cocoapods-fy-bin/native/analyzer.rb +55 -0
- data/lib/cocoapods-fy-bin/native/file_accessor.rb +28 -0
- data/lib/cocoapods-fy-bin/native/installation_options.rb +25 -0
- data/lib/cocoapods-fy-bin/native/installer.rb +204 -0
- data/lib/cocoapods-fy-bin/native/linter.rb +26 -0
- data/lib/cocoapods-fy-bin/native/path_source.rb +33 -0
- data/lib/cocoapods-fy-bin/native/pod_source_installer.rb +19 -0
- data/lib/cocoapods-fy-bin/native/pod_target_installer.rb +94 -0
- data/lib/cocoapods-fy-bin/native/podfile.rb +91 -0
- data/lib/cocoapods-fy-bin/native/podfile_env.rb +37 -0
- data/lib/cocoapods-fy-bin/native/podfile_generator.rb +199 -0
- data/lib/cocoapods-fy-bin/native/podspec_finder.rb +25 -0
- data/lib/cocoapods-fy-bin/native/resolver.rb +238 -0
- data/lib/cocoapods-fy-bin/native/sandbox_analyzer.rb +34 -0
- data/lib/cocoapods-fy-bin/native/source.rb +35 -0
- data/lib/cocoapods-fy-bin/native/sources_manager.rb +20 -0
- data/lib/cocoapods-fy-bin/native/specification.rb +31 -0
- data/lib/cocoapods-fy-bin/native/target_validator.rb +41 -0
- data/lib/cocoapods-fy-bin/native/validator.rb +40 -0
- data/lib/cocoapods-fy-bin/native.rb +23 -0
- data/lib/cocoapods-fy-bin/source_provider_hook.rb +55 -0
- data/lib/cocoapods-fy-bin.rb +2 -0
- data/lib/cocoapods_plugin.rb +3 -0
- data/spec/command/bin_spec.rb +12 -0
- data/spec/spec_helper.rb +50 -0
- metadata +177 -0
@@ -0,0 +1,170 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require 'cocoapods'
|
4
|
+
require 'cocoapods-fy-bin/config/config'
|
5
|
+
|
6
|
+
module CBin
|
7
|
+
class Specification
|
8
|
+
class Creator
|
9
|
+
attr_reader :code_spec
|
10
|
+
attr_reader :template_spec
|
11
|
+
attr_reader :spec
|
12
|
+
|
13
|
+
def initialize(code_spec, template_spec, platforms = 'ios')
|
14
|
+
@code_spec = code_spec
|
15
|
+
@template_spec = template_spec
|
16
|
+
@platforms = Array(platforms)
|
17
|
+
validate!
|
18
|
+
end
|
19
|
+
|
20
|
+
def validate!
|
21
|
+
raise Pod::Informative, '源码 podspec 不能为空 .' unless code_spec
|
22
|
+
if code_spec.subspecs.any? && template_spec.nil?
|
23
|
+
raise Pod::Informative, "不支持自动生成存在 subspec 的二进制 podspec , 需要提供模版文件 #{code_spec.name}.binary.podspec.template ."
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def create
|
28
|
+
spec = template_spec ? create_from_code_spec_and_template_spec : create_from_code_spec
|
29
|
+
|
30
|
+
Pod::UI.message '生成二进制 podspec 内容: '
|
31
|
+
spec.to_pretty_json.split("\n").each do |text|
|
32
|
+
Pod::UI.message text
|
33
|
+
end
|
34
|
+
|
35
|
+
spec
|
36
|
+
end
|
37
|
+
|
38
|
+
def write_spec_file(file = filename)
|
39
|
+
create unless spec
|
40
|
+
|
41
|
+
File.open(file, 'w+') do |f|
|
42
|
+
f.write(spec.to_pretty_json)
|
43
|
+
end
|
44
|
+
|
45
|
+
@filename = file
|
46
|
+
end
|
47
|
+
|
48
|
+
def clear_spec_file
|
49
|
+
File.delete(filename) if File.exist?(filename)
|
50
|
+
end
|
51
|
+
|
52
|
+
def filename
|
53
|
+
@filename ||= "#{spec.name}.binary.podspec.json"
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def create_from_code_spec
|
59
|
+
@spec = code_spec.dup
|
60
|
+
# vendored_frameworks | resources | source | source_files | public_header_files
|
61
|
+
# license | resource_bundles | vendored_libraries
|
62
|
+
|
63
|
+
# Project Linkin
|
64
|
+
@spec.vendored_frameworks = "#{code_spec.root.name}.framework"
|
65
|
+
|
66
|
+
# Resources
|
67
|
+
extnames = []
|
68
|
+
extnames << '*.bundle' if code_spec_consumer.resource_bundles.any?
|
69
|
+
if code_spec_consumer.resources.any?
|
70
|
+
extnames += code_spec_consumer.resources.map { |r| File.basename(r) }
|
71
|
+
end
|
72
|
+
if extnames.any?
|
73
|
+
@spec.resources = framework_contents('Resources').flat_map { |r| extnames.map { |e| "#{r}/#{e}" } }
|
74
|
+
end
|
75
|
+
|
76
|
+
# Source Location
|
77
|
+
@spec.source = binary_source
|
78
|
+
|
79
|
+
# Source Code
|
80
|
+
@spec.source_files = framework_contents('Headers/*')
|
81
|
+
@spec.public_header_files = framework_contents('Headers/*')
|
82
|
+
|
83
|
+
# Unused for binary
|
84
|
+
spec_hash = @spec.to_hash
|
85
|
+
# spec_hash.delete('license')
|
86
|
+
spec_hash.delete('resource_bundles')
|
87
|
+
spec_hash.delete('exclude_files')
|
88
|
+
spec_hash.delete('preserve_paths')
|
89
|
+
# 这里不确定 vendored_libraries 指定的时动态/静态库
|
90
|
+
# 如果是静态库的话,需要移除,否则就不移除
|
91
|
+
# 最好是静态库都独立成 Pod ,cocoapods-package 打静态库去 collect 目标文件时好做过滤
|
92
|
+
# 这里统一只对命名后缀 .a 文件做处理
|
93
|
+
# spec_hash.delete('vendored_libraries')
|
94
|
+
# libraries 只能假设为动态库不做处理了,如果有例外,需要开发者自行处理
|
95
|
+
spec_hash.delete('vendored_libraries')
|
96
|
+
spec_hash['vendored_libraries'] = binary_vendored_libraries
|
97
|
+
|
98
|
+
# vendored_libraries = Array(vendored_libraries).reject { |l| l.end_with?('.a') }
|
99
|
+
# if vendored_libraries.any?
|
100
|
+
# spec_hash['vendored_libraries'] = vendored_libraries
|
101
|
+
# end
|
102
|
+
|
103
|
+
# Filter platforms
|
104
|
+
platforms = spec_hash['platforms']
|
105
|
+
selected_platforms = platforms.select { |k, _v| @platforms.include?(k) }
|
106
|
+
spec_hash['platforms'] = selected_platforms.empty? ? platforms : selected_platforms
|
107
|
+
|
108
|
+
@spec = Pod::Specification.from_hash(spec_hash)
|
109
|
+
@spec
|
110
|
+
end
|
111
|
+
|
112
|
+
def create_from_code_spec_and_template_spec
|
113
|
+
@spec = template_spec.dup
|
114
|
+
|
115
|
+
@spec.version = code_spec.version
|
116
|
+
@spec.source = binary_source
|
117
|
+
|
118
|
+
@spec.source_files = binary_source_files
|
119
|
+
@spec.public_header_files = binary_public_header_files
|
120
|
+
@spec.vendored_libraries = binary_vendored_libraries
|
121
|
+
|
122
|
+
@spec.resources = binary_resources if @spec.attributes_hash.keys.include?("resources")
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
@spec
|
127
|
+
end
|
128
|
+
|
129
|
+
def binary_source
|
130
|
+
{ http: format(CBin.config.binary_download_url, code_spec.root.name, code_spec.version), type: CBin.config.download_file_type }
|
131
|
+
end
|
132
|
+
|
133
|
+
def code_spec_consumer(_platform = :ios)
|
134
|
+
code_spec.consumer(:ios)
|
135
|
+
end
|
136
|
+
|
137
|
+
def framework_contents(name)
|
138
|
+
["#{code_spec.root.name}.framework", "#{code_spec.root.name}.framework/Versions/A"].map { |path| "#{path}/#{name}" }
|
139
|
+
end
|
140
|
+
|
141
|
+
def binary_source_files
|
142
|
+
{ http: format(CBin.config.binary_download_url, code_spec.root.name, code_spec.version), type: CBin.config.download_file_type }
|
143
|
+
end
|
144
|
+
|
145
|
+
def binary_source_files
|
146
|
+
"bin_#{code_spec.name}_#{code_spec.version}/Headers/*"
|
147
|
+
end
|
148
|
+
|
149
|
+
def binary_public_header_files
|
150
|
+
"bin_#{code_spec.name}_#{code_spec.version}/Headers/*.h"
|
151
|
+
end
|
152
|
+
|
153
|
+
def binary_vendored_libraries
|
154
|
+
"bin_#{code_spec.name}_#{code_spec.version}/*.a"
|
155
|
+
end
|
156
|
+
|
157
|
+
def binary_resources
|
158
|
+
"bin_#{code_spec.name}_#{code_spec.version}/Resources/*"
|
159
|
+
end
|
160
|
+
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
#模板框架begin
|
165
|
+
# s.source_files = "bin_#{s.name}_#{s.version}/Headers/*"
|
166
|
+
# s.public_header_files = "bin_#{s.name}_#{s.version}/Headers/*.h"
|
167
|
+
# s.vendored_libraries = "bin_#{s.name}_#{s.version}/*.a"
|
168
|
+
#有图片资源的,要带上
|
169
|
+
#s.resources = 'bin_#{s.name}_#{s.version}/Resources/*.{json,png,jpg,gif,js,xib,eot,svg,ttf,woff,db,sqlite,mp3,bundle}'
|
170
|
+
#模板框架end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require 'cocoapods-fy-bin/native/sources_manager.rb'
|
4
|
+
require 'cocoapods-fy-bin/helpers/spec_creator'
|
5
|
+
|
6
|
+
module CBin
|
7
|
+
module SpecFilesHelper
|
8
|
+
def spec_files
|
9
|
+
@spec_files ||= Pathname.glob('*.podspec{,.json}')
|
10
|
+
end
|
11
|
+
|
12
|
+
def binary_spec_files
|
13
|
+
@binary_spec_files ||= Pathname.glob('*.binary.podspec{,.json}')
|
14
|
+
end
|
15
|
+
|
16
|
+
def binary_template_spec_files
|
17
|
+
@binary_spec_template_files ||= Pathname.glob('*.binary-template.podspec{,.json}')
|
18
|
+
end
|
19
|
+
|
20
|
+
def binary_template_spec_file
|
21
|
+
@binary_spec_template_file ||= binary_template_spec_files.first
|
22
|
+
end
|
23
|
+
|
24
|
+
def code_spec_files
|
25
|
+
@code_spec_files ||= spec_files - binary_spec_files - binary_template_spec_files
|
26
|
+
end
|
27
|
+
|
28
|
+
def code_spec
|
29
|
+
if code_spec_files.first
|
30
|
+
Pod::Specification.from_file(code_spec_files.first)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def binary_spec
|
35
|
+
if binary_spec_files.first
|
36
|
+
Pod::Specification.from_file(binary_spec_files.first)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def binary_template_spec
|
41
|
+
if binary_template_spec_file
|
42
|
+
Pod::Specification.from_file(binary_template_spec_file)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def find_spec_file(podspec)
|
47
|
+
path = Pathname(podspec)
|
48
|
+
raise Pod::Informative, "无法找到 #{podspec}" unless path.exist?
|
49
|
+
|
50
|
+
path
|
51
|
+
end
|
52
|
+
|
53
|
+
def create_binary_spec_file(code_spec, template_spec)
|
54
|
+
# 1. code spec 是否有 subpsec
|
55
|
+
# 1.1 有,查找 template spec,并生成
|
56
|
+
# 1.2 没有,是否有 template spec
|
57
|
+
# 1.2.1 有,根据 template spec 生成
|
58
|
+
# 1.2.2 没有,根据 code spec 生成
|
59
|
+
|
60
|
+
unless code_spec
|
61
|
+
raise Pod::Informative, '没有二进制 podspec 的情况下,必须要提供源码 podspec.'
|
62
|
+
end
|
63
|
+
if code_spec.subspecs.any? && template_spec.nil?
|
64
|
+
raise Pod::Informative, '拥有 subspec 的组件,在生成二进制 podspec 时,必须要提供模版 podspec.'
|
65
|
+
end
|
66
|
+
|
67
|
+
@spec_creator = CBin::Specification::Creator.new(code_spec, template_spec)
|
68
|
+
@spec_creator.create
|
69
|
+
@spec_creator.write_spec_file
|
70
|
+
@spec_creator.filename
|
71
|
+
end
|
72
|
+
|
73
|
+
def clear_binary_spec_file_if_needed
|
74
|
+
@spec_creator&.clear_spec_file
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,229 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require 'cocoapods'
|
4
|
+
require 'cocoapods-fy-bin/config/config'
|
5
|
+
|
6
|
+
module CBin
|
7
|
+
class SpecificationSource
|
8
|
+
class Creator
|
9
|
+
attr_reader :code_spec
|
10
|
+
attr_reader :spec
|
11
|
+
|
12
|
+
def initialize(code_spec, platforms = 'ios')
|
13
|
+
@code_spec = code_spec
|
14
|
+
@platforms = Array(platforms)
|
15
|
+
validate!
|
16
|
+
end
|
17
|
+
|
18
|
+
def validate!
|
19
|
+
raise Pod::Informative, '源码 podspec 不能为空 .' unless code_spec
|
20
|
+
end
|
21
|
+
|
22
|
+
def create
|
23
|
+
# spec = nil
|
24
|
+
if CBin::Build::Utils.is_framework(@code_spec)
|
25
|
+
spec = create_framework_from_code_spec
|
26
|
+
else
|
27
|
+
spec = create_from_code_spec
|
28
|
+
end
|
29
|
+
|
30
|
+
spec
|
31
|
+
end
|
32
|
+
|
33
|
+
def write_spec_file(file = filename)
|
34
|
+
create unless spec
|
35
|
+
|
36
|
+
FileUtils.mkdir_p(CBin::Config::Builder.instance.binary_json_dir) unless File.exist?(CBin::Config::Builder.instance.binary_json_dir)
|
37
|
+
FileUtils.rm_rf(file) if File.exist?(file)
|
38
|
+
|
39
|
+
File.open(file, 'w+') do |f|
|
40
|
+
# f.write("# MARK: converted automatically by plugin cocoapods-fy-bin @slj \r\n")
|
41
|
+
f.write(spec.to_pretty_json)
|
42
|
+
end
|
43
|
+
|
44
|
+
@filename = file
|
45
|
+
end
|
46
|
+
|
47
|
+
def clear_spec_file
|
48
|
+
File.delete(filename) if File.exist?(filename)
|
49
|
+
end
|
50
|
+
|
51
|
+
def filename
|
52
|
+
@filename ||= "#{CBin::Config::Builder.instance.binary_json_dir_name}/#{spec.name}.binary.podspec.json"
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def create_from_code_spec
|
58
|
+
@spec = code_spec.dup
|
59
|
+
# vendored_frameworks | resources | source | source_files | public_header_files
|
60
|
+
# license | resource_bundles | vendored_libraries
|
61
|
+
|
62
|
+
# Project Linkin
|
63
|
+
# @spec.vendored_frameworks = "#{code_spec.root.name}.framework"
|
64
|
+
|
65
|
+
# Resources
|
66
|
+
extnames = []
|
67
|
+
extnames << '*.bundle' if code_spec_consumer.resource_bundles.any?
|
68
|
+
if code_spec_consumer.resources.any?
|
69
|
+
extnames += code_spec_consumer.resources.map { |r| File.basename(r) }
|
70
|
+
end
|
71
|
+
if extnames.any?
|
72
|
+
@spec.resources = framework_contents('Resources').flat_map { |r| extnames.map { |e| "#{r}/#{e}" } }
|
73
|
+
end
|
74
|
+
|
75
|
+
# Source Location
|
76
|
+
@spec.source = binary_source
|
77
|
+
|
78
|
+
# Source Code
|
79
|
+
# @spec.source_files = framework_contents('Headers/*')
|
80
|
+
# @spec.public_header_files = framework_contents('Headers/*')
|
81
|
+
|
82
|
+
# Unused for binary
|
83
|
+
spec_hash = @spec.to_hash
|
84
|
+
# spec_hash.delete('license')
|
85
|
+
spec_hash.delete('resource_bundles')
|
86
|
+
spec_hash.delete('exclude_files')
|
87
|
+
spec_hash.delete('preserve_paths')
|
88
|
+
|
89
|
+
spec_hash.delete('subspecs')
|
90
|
+
spec_hash.delete('default_subspecs')
|
91
|
+
spec_hash.delete('default_subspec')
|
92
|
+
spec_hash.delete('vendored_frameworks')
|
93
|
+
spec_hash.delete('vendored_framework')
|
94
|
+
|
95
|
+
# 这里不确定 vendored_libraries 指定的时动态/静态库
|
96
|
+
# 如果是静态库的话,需要移除,否则就不移除
|
97
|
+
# 最好是静态库都独立成 Pod ,cocoapods-package 打静态库去 collect 目标文件时好做过滤
|
98
|
+
# 这里统一只对命名后缀 .a 文件做处理
|
99
|
+
# spec_hash.delete('vendored_libraries')
|
100
|
+
# libraries 只能假设为动态库不做处理了,如果有例外,需要开发者自行处理
|
101
|
+
spec_hash.delete('vendored_libraries')
|
102
|
+
|
103
|
+
# vendored_libraries = Array(vendored_libraries).reject { |l| l.end_with?('.a') }
|
104
|
+
# if vendored_libraries.any?
|
105
|
+
# spec_hash['vendored_libraries'] = vendored_libraries
|
106
|
+
# end
|
107
|
+
|
108
|
+
# Filter platforms
|
109
|
+
platforms = spec_hash['platforms']
|
110
|
+
selected_platforms = platforms.select { |k, _v| @platforms.include?(k) }
|
111
|
+
spec_hash['platforms'] = selected_platforms.empty? ? platforms : selected_platforms
|
112
|
+
|
113
|
+
@spec = Pod::Specification.from_hash(spec_hash)
|
114
|
+
|
115
|
+
#把命令 prepare_command 移除掉,如ReactiveCocoa会执行修改重命令的脚步
|
116
|
+
@spec.prepare_command = "" if @spec.prepare_command
|
117
|
+
@spec.version = code_spec.version
|
118
|
+
@spec.source = binary_source
|
119
|
+
@spec.source_files = binary_source_files
|
120
|
+
@spec.public_header_files = binary_public_header_files
|
121
|
+
@spec.vendored_libraries = binary_vendored_libraries
|
122
|
+
@spec.resources = binary_resources if @spec.attributes_hash.keys.include?("resources")
|
123
|
+
@spec.description = <<-EOF
|
124
|
+
「 converted automatically by plugin cocoapods-fy-bin @厦门美柚 - slj 」
|
125
|
+
#{@spec.description}
|
126
|
+
EOF
|
127
|
+
@spec
|
128
|
+
end
|
129
|
+
|
130
|
+
def create_framework_from_code_spec
|
131
|
+
@spec = code_spec.dup
|
132
|
+
# vendored_frameworks | resources | source | source_files | public_header_files
|
133
|
+
# license | resource_bundles | vendored_libraries
|
134
|
+
|
135
|
+
# Project Linkin
|
136
|
+
framework_name = CBin::Config::Builder.instance.treated_framework_name(@spec)
|
137
|
+
@spec.vendored_frameworks = "#{framework_name}.framework"
|
138
|
+
|
139
|
+
# Resources
|
140
|
+
extnames = []
|
141
|
+
extnames << '*.bundle' if code_spec_consumer.resource_bundles.any?
|
142
|
+
if code_spec_consumer.resources.any?
|
143
|
+
extnames += code_spec_consumer.resources.map { |r| File.basename(r) }
|
144
|
+
end
|
145
|
+
if extnames.any?
|
146
|
+
@spec.resources = framework_contents('Resources').flat_map { |r| extnames.map { |e| "#{r}/#{e}" } }
|
147
|
+
end
|
148
|
+
|
149
|
+
# Source Location
|
150
|
+
@spec.source = binary_source
|
151
|
+
|
152
|
+
# Source Code
|
153
|
+
# @spec.source_files = framework_contents('Headers/*')
|
154
|
+
# @spec.public_header_files = framework_contents('Headers/*')
|
155
|
+
|
156
|
+
# Unused for binary
|
157
|
+
spec_hash = @spec.to_hash
|
158
|
+
# spec_hash.delete('license')
|
159
|
+
spec_hash.delete('resource_bundles')
|
160
|
+
spec_hash.delete('exclude_files')
|
161
|
+
spec_hash.delete('preserve_paths')
|
162
|
+
# 这里不确定 vendored_libraries 指定的时动态/静态库
|
163
|
+
# 如果是静态库的话,需要移除,否则就不移除
|
164
|
+
# 最好是静态库都独立成 Pod ,cocoapods-package 打静态库去 collect 目标文件时好做过滤
|
165
|
+
# 这里统一只对命名后缀 .a 文件做处理
|
166
|
+
# spec_hash.delete('vendored_libraries')
|
167
|
+
# libraries 只能假设为动态库不做处理了,如果有例外,需要开发者自行处理
|
168
|
+
vendored_libraries = spec_hash.delete('vendored_libraries')
|
169
|
+
vendored_libraries = Array(vendored_libraries).reject { |l| l.end_with?('.a') }
|
170
|
+
if vendored_libraries.any?
|
171
|
+
spec_hash['vendored_libraries'] = vendored_libraries
|
172
|
+
end
|
173
|
+
|
174
|
+
# Filter platforms
|
175
|
+
platforms = spec_hash['platforms']
|
176
|
+
selected_platforms = platforms.select { |k, _v| @platforms.include?(k) }
|
177
|
+
spec_hash['platforms'] = selected_platforms.empty? ? platforms : selected_platforms
|
178
|
+
|
179
|
+
@spec = Pod::Specification.from_hash(spec_hash)
|
180
|
+
@spec.description = <<-EOF
|
181
|
+
「 converted automatically by plugin cocoapods-fy-bin @厦门美柚 - slj 」
|
182
|
+
#{@spec.description}
|
183
|
+
EOF
|
184
|
+
@spec
|
185
|
+
end
|
186
|
+
|
187
|
+
|
188
|
+
def binary_source
|
189
|
+
{ http: format(CBin.config.binary_download_url, code_spec.root.name, code_spec.version), type: CBin.config.download_file_type }
|
190
|
+
end
|
191
|
+
|
192
|
+
def code_spec_consumer(_platform = :ios)
|
193
|
+
code_spec.consumer(:ios)
|
194
|
+
end
|
195
|
+
|
196
|
+
def framework_contents(name)
|
197
|
+
["#{code_spec.root.name}.framework", "#{code_spec.root.name}.framework/Versions/A"].map { |path| "#{path}/#{name}" }
|
198
|
+
end
|
199
|
+
|
200
|
+
def binary_source_files
|
201
|
+
{ http: format(CBin.config.binary_download_url, code_spec.root.name, code_spec.version), type: CBin.config.download_file_type }
|
202
|
+
end
|
203
|
+
|
204
|
+
def binary_source_files
|
205
|
+
"bin_#{code_spec.name}_#{code_spec.version}/Headers/*"
|
206
|
+
end
|
207
|
+
|
208
|
+
def binary_public_header_files
|
209
|
+
"bin_#{code_spec.name}_#{code_spec.version}/Headers/*.h"
|
210
|
+
end
|
211
|
+
|
212
|
+
def binary_vendored_libraries
|
213
|
+
"bin_#{code_spec.name}_#{code_spec.version}/*.a"
|
214
|
+
end
|
215
|
+
|
216
|
+
def binary_resources
|
217
|
+
"bin_#{code_spec.name}_#{code_spec.version}/Resources/*"
|
218
|
+
end
|
219
|
+
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
#模板框架begin
|
224
|
+
# s.source_files = "bin_#{s.name}_#{s.version}/Headers/*"
|
225
|
+
# s.public_header_files = "bin_#{s.name}_#{s.version}/Headers/*.h"
|
226
|
+
# s.vendored_libraries = "bin_#{s.name}_#{s.version}/*.a"
|
227
|
+
#有图片资源的,要带上
|
228
|
+
#s.resources = 'bin_#{s.name}_#{s.version}/Resources/*.{json,png,jpg,gif,js,xib,eot,svg,ttf,woff,db,sqlite,mp3,bundle}'
|
229
|
+
#模板框架end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
# copy from https://github.com/CocoaPods/cocoapods-packager
|
4
|
+
|
5
|
+
require 'cocoapods-fy-bin/native/podfile'
|
6
|
+
require 'cocoapods/command/gen'
|
7
|
+
require 'cocoapods/generate'
|
8
|
+
require 'cocoapods-fy-bin/helpers/framework_builder'
|
9
|
+
require 'cocoapods-fy-bin/helpers/library_builder'
|
10
|
+
require 'cocoapods-fy-bin/helpers/sources_helper'
|
11
|
+
require 'cocoapods-fy-bin/command/bin/spec/push'
|
12
|
+
|
13
|
+
module CBin
|
14
|
+
class Upload
|
15
|
+
class Helper
|
16
|
+
include CBin::SourcesHelper
|
17
|
+
|
18
|
+
def initialize(spec,code_dependencies,sources)
|
19
|
+
@spec = spec
|
20
|
+
@code_dependencies = code_dependencies
|
21
|
+
@sources = sources
|
22
|
+
end
|
23
|
+
|
24
|
+
def upload
|
25
|
+
# curl_del_zip
|
26
|
+
Dir.chdir(CBin::Config::Builder.instance.root_dir) do
|
27
|
+
# 创建binary-template.podsepc
|
28
|
+
# 上传二进制文件
|
29
|
+
# 上传二进制 podspec
|
30
|
+
res_zip = curl_zip
|
31
|
+
if res_zip
|
32
|
+
filename = spec_creator
|
33
|
+
push_binary_repo(filename)
|
34
|
+
end
|
35
|
+
res_zip
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def spec_creator
|
40
|
+
spec_creator = CBin::SpecificationSource::Creator.new(@spec)
|
41
|
+
spec_creator.create
|
42
|
+
spec_creator.write_spec_file
|
43
|
+
spec_creator.filename
|
44
|
+
end
|
45
|
+
|
46
|
+
def curl_del_zip
|
47
|
+
print <<EOF
|
48
|
+
删除已上传的二进制文件
|
49
|
+
curl -v -X DELETE "#{CBin.config.binary_upload_url}/#{@spec.name}/#{@spec.version}"
|
50
|
+
EOF
|
51
|
+
`curl -v -X DELETE "#{CBin.config.binary_upload_url}/#{@spec.name}/#{@spec.version}"`
|
52
|
+
end
|
53
|
+
#推送二进制
|
54
|
+
# curl http://ci.xxx:9192/frameworks -F "name=IMYFoundation" -F "version=7.7.4.2" -F "annotate=IMYFoundation_7.7.4.2_log" -F "file=@bin_zip/bin_IMYFoundation_7.7.4.2.zip"
|
55
|
+
def curl_zip
|
56
|
+
zip_file = "#{CBin::Config::Builder.instance.library_file(@spec)}.zip"
|
57
|
+
res = File.exist?(zip_file)
|
58
|
+
unless res
|
59
|
+
zip_file = CBin::Config::Builder.instance.framework_zip_file(@spec) + ".zip"
|
60
|
+
res = File.exist?(zip_file)
|
61
|
+
end
|
62
|
+
if res
|
63
|
+
print <<EOF
|
64
|
+
上传二进制文件
|
65
|
+
curl #{CBin.config.binary_upload_url} -F "name=#{@spec.name}" -F "version=#{@spec.version}" -F "annotate=#{@spec.name}_#{@spec.version}_log" -F "file=@#{zip_file}"
|
66
|
+
EOF
|
67
|
+
`curl #{CBin.config.binary_upload_url} -F "name=#{@spec.name}" -F "version=#{@spec.version}" -F "annotate=#{@spec.name}_#{@spec.version}_log" -F "file=@#{zip_file}"` if res
|
68
|
+
end
|
69
|
+
|
70
|
+
res
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
# 上传二进制 podspec
|
75
|
+
def push_binary_repo(binary_podsepc_json)
|
76
|
+
argvs = [
|
77
|
+
"#{binary_podsepc_json}",
|
78
|
+
"--binary",
|
79
|
+
"--sources=#{sources_option(@code_dependencies, @sources)}",
|
80
|
+
"--skip-import-validation",
|
81
|
+
"--use-libraries",
|
82
|
+
"--allow-warnings",
|
83
|
+
"--verbose",
|
84
|
+
"--code-dependencies"
|
85
|
+
]
|
86
|
+
if @verbose
|
87
|
+
argvs += ['--verbose']
|
88
|
+
end
|
89
|
+
|
90
|
+
push = Pod::Command::Bin::Repo::Push.new(CLAide::ARGV.new(argvs))
|
91
|
+
push.validate!
|
92
|
+
push.run
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
module Generator
|
5
|
+
class Acknowledgements
|
6
|
+
def license_text(spec)
|
7
|
+
return nil unless spec.license
|
8
|
+
|
9
|
+
text = spec.license[:text]
|
10
|
+
unless text
|
11
|
+
if license_file = spec.license[:file]
|
12
|
+
license_path = file_accessor(spec).root + license_file
|
13
|
+
if File.exist?(license_path)
|
14
|
+
text = IO.read(license_path)
|
15
|
+
else
|
16
|
+
# UI.warn "Unable to read the license file `#{license_file}` " \
|
17
|
+
# "for the spec `#{spec}`"
|
18
|
+
end
|
19
|
+
elsif license_file = file_accessor(spec).license
|
20
|
+
text = IO.read(license_file)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
text
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require 'parallel'
|
4
|
+
require 'cocoapods'
|
5
|
+
|
6
|
+
module Pod
|
7
|
+
class Installer
|
8
|
+
class Analyzer
|
9
|
+
# > 1.6.0
|
10
|
+
# all_specs[dep.name] 为 nil 会崩溃
|
11
|
+
# 主要原因是 all_specs 分析错误
|
12
|
+
# 查看 source 是否正确
|
13
|
+
#
|
14
|
+
# def dependencies_for_specs(specs, platform, all_specs)
|
15
|
+
# return [] if specs.empty? || all_specs.empty?
|
16
|
+
|
17
|
+
# dependent_specs = Set.new
|
18
|
+
|
19
|
+
# specs.each do |s|
|
20
|
+
# s.dependencies(platform).each do |dep|
|
21
|
+
# all_specs[dep.name].each do |spec|
|
22
|
+
# dependent_specs << spec
|
23
|
+
# end
|
24
|
+
# end
|
25
|
+
# end
|
26
|
+
|
27
|
+
# dependent_specs - specs
|
28
|
+
# end
|
29
|
+
|
30
|
+
# > 1.5.3 版本
|
31
|
+
# rewrite update_repositories
|
32
|
+
#
|
33
|
+
alias old_update_repositories update_repositories
|
34
|
+
def update_repositories
|
35
|
+
if installation_options.update_source_with_multi_processes
|
36
|
+
# 并发更新私有源
|
37
|
+
# 这里多线程会导致 pod update 额外输出 --verbose 的内容
|
38
|
+
# 不知道为什么?
|
39
|
+
Parallel.each(sources.uniq(&:url), in_processes: 4) do |source|
|
40
|
+
if source.git?
|
41
|
+
config.sources_manager.update(source.name, true)
|
42
|
+
else
|
43
|
+
UI.message "Skipping `#{source.name}` update because the repository is not a git source repository."
|
44
|
+
end
|
45
|
+
end
|
46
|
+
@specs_updated = true
|
47
|
+
else
|
48
|
+
old_update_repositories
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'macho'
|
2
|
+
require 'cocoapods'
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
class Sandbox
|
6
|
+
class FileAccessor
|
7
|
+
|
8
|
+
# swift动态库 需要设置为true
|
9
|
+
def dynamic_binary?(binary)
|
10
|
+
@cached_dynamic_binary_results ||= {}
|
11
|
+
return @cached_dynamic_binary_results[binary] unless @cached_dynamic_binary_results[binary].nil?
|
12
|
+
return false unless binary.file?
|
13
|
+
|
14
|
+
@cached_dynamic_binary_results[binary] = MachO.open(binary).dylib?
|
15
|
+
rescue MachO::MachOError
|
16
|
+
@cached_dynamic_binary_results[binary] = true
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
# def expanded_paths(patterns, options = {})
|
21
|
+
# return [] if patterns.empty?
|
22
|
+
# path_list.glob(patterns, options).flatten.compact.uniq
|
23
|
+
# end
|
24
|
+
|
25
|
+
#-----------------------------------------------------------------------#
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|