cocoapods-pahealth-bin 0.0.3
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-pahealth-bin/command/bin/init.rb +70 -0
- data/lib/cocoapods-pahealth-bin/command/bin/spec/lint.rb +110 -0
- data/lib/cocoapods-pahealth-bin/command/bin/spec.rb +14 -0
- data/lib/cocoapods-pahealth-bin/command/bin.rb +51 -0
- data/lib/cocoapods-pahealth-bin/command.rb +1 -0
- data/lib/cocoapods-pahealth-bin/config/config.rb +79 -0
- data/lib/cocoapods-pahealth-bin/config/config_asker.rb +61 -0
- data/lib/cocoapods-pahealth-bin/gem_version.rb +3 -0
- data/lib/cocoapods-pahealth-bin/helpers/sources_helper.rb +38 -0
- data/lib/cocoapods-pahealth-bin/helpers/spec_creator.rb +132 -0
- data/lib/cocoapods-pahealth-bin/helpers/spec_files_helper.rb +78 -0
- data/lib/cocoapods-pahealth-bin/helpers.rb +3 -0
- data/lib/cocoapods-pahealth-bin/native/podfile.rb +78 -0
- data/lib/cocoapods-pahealth-bin/native/podfile_env.rb +35 -0
- data/lib/cocoapods-pahealth-bin/native/sources_manager.rb +22 -0
- data/lib/cocoapods-pahealth-bin/native.rb +2 -0
- data/lib/cocoapods-pahealth-bin.rb +1 -0
- data/lib/cocoapods_plugin.rb +1 -0
- metadata +131 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 289d20bfac5def5a0989035912a4414e76572be944e4d0dded1fdacebc027e5d
|
4
|
+
data.tar.gz: 87a9ebdce164352588eccc39c080a767f568c0f2cd66a0ca1c10db15d9941571
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d97649ac7523edee63b653f6696f67e71f9fcd5ea14a383f8beddd817aa7076aa9d60dce08db0f66168a27bc6baa98cd3cc041a2d6994a72c56a27b97c413762
|
7
|
+
data.tar.gz: f64d47d0516025c0f7decbe2c1b6a7c4f32354c264b813e41d811e5e05a2144dc3b86838e0822c0a9b2fb13ad67b7751564e40b2854e09c34a41633cec5c8a57
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'cocoapods-pahealth-bin/config/config_asker'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Bin < Command
|
6
|
+
class Init < Bin
|
7
|
+
self.summary = '初始化插件.'
|
8
|
+
self.description = <<-DESC
|
9
|
+
创建 #{CBin.config.config_file} 文件,在其中保存插件需要的配置信息,
|
10
|
+
如二进制私有源地址、源码私有源地址等。
|
11
|
+
DESC
|
12
|
+
|
13
|
+
def self.options
|
14
|
+
[
|
15
|
+
['--bin-url=URL', '配置文件地址,直接从此地址下载配置文件']
|
16
|
+
].concat(super)
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize(argv)
|
20
|
+
@bin_url = argv.option('bin-url')
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
def run
|
25
|
+
if @bin_url.nil?
|
26
|
+
config_with_asker
|
27
|
+
else
|
28
|
+
config_with_url(@bin_url)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def config_with_url(url)
|
35
|
+
require 'open-uri'
|
36
|
+
|
37
|
+
UI.puts "开始下载配置文件...\n"
|
38
|
+
file = open(url)
|
39
|
+
contents = YAML.safe_load(file.read)
|
40
|
+
|
41
|
+
UI.puts "开始同步配置文件...\n"
|
42
|
+
CBin.config.sync_config(contents.to_hash)
|
43
|
+
UI.puts "设置完成.\n".green
|
44
|
+
rescue Errno::ENOENT => e
|
45
|
+
raise Informative, "配置文件路径 #{url} 无效,请确认后重试."
|
46
|
+
end
|
47
|
+
|
48
|
+
def config_with_asker
|
49
|
+
asker = CBin::Config::Asker.new
|
50
|
+
asker.wellcome_message
|
51
|
+
|
52
|
+
config = {}
|
53
|
+
template_hash = CBin.config.template_hash
|
54
|
+
template_hash.each do |k, v|
|
55
|
+
default = begin
|
56
|
+
CBin.config.send(k)
|
57
|
+
rescue StandardError
|
58
|
+
nil
|
59
|
+
end
|
60
|
+
config[k] = asker.ask_with_answer(v[:description], default, v[:selection])
|
61
|
+
end
|
62
|
+
|
63
|
+
CBin.config.sync_config(config)
|
64
|
+
asker.done_message
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'cocoapods-pahealth-bin/config/config'
|
2
|
+
require 'cocoapods-pahealth-bin/native/podfile'
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
class Command
|
6
|
+
class Bin < Command
|
7
|
+
class Spec < Bin
|
8
|
+
class Lint < Spec
|
9
|
+
self.summary = 'lint spec.'
|
10
|
+
self.description = <<-DESC
|
11
|
+
spec lint 组件
|
12
|
+
DESC
|
13
|
+
|
14
|
+
self.arguments = [
|
15
|
+
CLAide::Argument.new(%w[NAME.podspec DIRECTORY http://PATH/NAME.podspec], false, true)
|
16
|
+
]
|
17
|
+
|
18
|
+
def self.options
|
19
|
+
[
|
20
|
+
['--binary', 'lint 组件的二进制版本'],
|
21
|
+
['--template-podspec=A.binary-template.podspec', '生成拥有 subspec 的二进制 spec 需要的模版 podspec, 插件会更改 version 和 source'],
|
22
|
+
['--reserve-created-spec', '保留生成的二进制 spec 文件'],
|
23
|
+
['--code-dependencies', '使用源码依赖进行 lint'],
|
24
|
+
['--loose-options', '添加宽松的 options, 包括 --use-libraries (可能会造成 entry point (start) undefined)'],
|
25
|
+
['--allow-prerelease', '允许使用 prerelease 的版本 lint']
|
26
|
+
].concat(Pod::Command::Spec::Lint.options).concat(super).uniq
|
27
|
+
end
|
28
|
+
|
29
|
+
def initialize(argv)
|
30
|
+
@podspec = argv.shift_argument
|
31
|
+
@loose_options = argv.flag?('loose-options')
|
32
|
+
@code_dependencies = argv.flag?('code-dependencies')
|
33
|
+
@sources = argv.option('sources') || []
|
34
|
+
@binary = argv.flag?('binary')
|
35
|
+
@reserve_created_spec = argv.flag?('reserve-created-spec')
|
36
|
+
@template_podspec = argv.option('template-podspec')
|
37
|
+
@allow_prerelease = argv.flag?('allow-prerelease')
|
38
|
+
super
|
39
|
+
|
40
|
+
@additional_args = argv.remainder!
|
41
|
+
end
|
42
|
+
|
43
|
+
def run
|
44
|
+
Podfile.execute_with_bin_plugin do
|
45
|
+
Podfile.execute_with_allow_prerelease(@allow_prerelease) do
|
46
|
+
Podfile.execute_with_use_binaries(!@code_dependencies) do
|
47
|
+
argvs = [
|
48
|
+
"--sources=#{sources_option(@code_dependencies, @sources)}",
|
49
|
+
*@additional_args
|
50
|
+
]
|
51
|
+
|
52
|
+
argvs << spec_file if spec_file
|
53
|
+
|
54
|
+
if @loose_options
|
55
|
+
argvs += ['--allow-warnings']
|
56
|
+
if code_spec&.all_dependencies&.any?
|
57
|
+
argvs << '--use-libraries'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
lint = Pod::Command::Spec::Lint.new(CLAide::ARGV.new(argvs))
|
62
|
+
lint.validate!
|
63
|
+
lint.run
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
ensure
|
68
|
+
clear_binary_spec_file_if_needed unless @reserve_created_spec
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
def template_spec_file
|
74
|
+
@template_spec_file ||= begin
|
75
|
+
if @template_podspec
|
76
|
+
find_spec_file(@template_podspec)
|
77
|
+
else
|
78
|
+
binary_template_spec_file
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def spec_file
|
84
|
+
@spec_file ||= begin
|
85
|
+
if @podspec
|
86
|
+
find_spec_file(@podspec) || @podspec
|
87
|
+
else
|
88
|
+
if code_spec_files.empty?
|
89
|
+
raise Informative, '当前目录下没有找到可用源码 podspec.'
|
90
|
+
end
|
91
|
+
|
92
|
+
spec_file = if @binary
|
93
|
+
code_spec = Pod::Specification.from_file(code_spec_files.first)
|
94
|
+
if template_spec_file
|
95
|
+
template_spec = Pod::Specification.from_file(template_spec_file)
|
96
|
+
end
|
97
|
+
create_binary_spec_file(code_spec, template_spec)
|
98
|
+
else
|
99
|
+
code_spec_files.first
|
100
|
+
end
|
101
|
+
spec_file
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# require 'cocoapods-pahealth-bin/command/bin/spec/create'
|
2
|
+
require 'cocoapods-pahealth-bin/command/bin/spec/lint'
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
class Command
|
6
|
+
class Bin < Command
|
7
|
+
class Spec < Bin
|
8
|
+
self.abstract_command = true
|
9
|
+
self.summary = '管理 spec.'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'cocoapods-pahealth-bin/command/bin/init'
|
2
|
+
require 'cocoapods-pahealth-bin/command/bin/spec'
|
3
|
+
require 'cocoapods-pahealth-bin/helpers'
|
4
|
+
|
5
|
+
module Pod
|
6
|
+
class Command
|
7
|
+
# This is an example of a cocoapods plugin adding a top-level subcommand
|
8
|
+
# to the 'pod' command.
|
9
|
+
#
|
10
|
+
# You can also create subcommands of existing or new commands. Say you
|
11
|
+
# wanted to add a subcommand to `list` to show newly deprecated pods,
|
12
|
+
# (e.g. `pod list deprecsated`), there are a few things that would need
|
13
|
+
# to change.
|
14
|
+
#
|
15
|
+
# - move this file to `lib/pod/command/list/deprecated.rb` and update
|
16
|
+
# the class to exist in the the Pod::Command::List namespace
|
17
|
+
# - change this class to extend from `List` instead of `Command`. This
|
18
|
+
# tells the plugin system that it is a subcommand of `list`.
|
19
|
+
# - edit `lib/cocoapods_plugins.rb` to require this file
|
20
|
+
#
|
21
|
+
# @todo Create a PR to add your plugin to CocoaPods/cocoapods.org
|
22
|
+
# in the `plugins.json` file, once your plugin is released.
|
23
|
+
#
|
24
|
+
class Bin < Command
|
25
|
+
include CBin::SourcesHelper
|
26
|
+
include CBin::SpecFilesHelper
|
27
|
+
|
28
|
+
self.abstract_command = true
|
29
|
+
|
30
|
+
self.default_subcommand = 'open'
|
31
|
+
self.summary = '组件远程私有化插件.'
|
32
|
+
self.description = <<-DESC
|
33
|
+
组件远程私有化插件,组件发布,组件更新。
|
34
|
+
DESC
|
35
|
+
|
36
|
+
|
37
|
+
def initialize(argv)
|
38
|
+
require 'cocoapods-pahealth-bin/native'
|
39
|
+
@help = argv.flag?('help')
|
40
|
+
super
|
41
|
+
end
|
42
|
+
|
43
|
+
def validate!
|
44
|
+
super
|
45
|
+
# 这里由于 --help 是在 validate! 方法中提取的,会导致 --help 失效
|
46
|
+
# pod lib create 也有这个问题
|
47
|
+
banner! if @help
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-pahealth-bin/command/bin'
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module CBin
|
4
|
+
class Config
|
5
|
+
def config_file
|
6
|
+
File.expand_path("#{Pod::Config.instance.home_dir}/bin.yml")
|
7
|
+
end
|
8
|
+
|
9
|
+
def template_hash
|
10
|
+
{
|
11
|
+
'code_repo_url' => { description: '私有源 Git 地址', default: 'http://domain/git/pahealth_private_repo.git' },
|
12
|
+
#'binary_repo_url' => { description: '二进制私有源 Git 地址', default: 'git@git.2dfire.net:ios/cocoapods-spec-binary.git' },
|
13
|
+
#'binary_download_url' => { description: '二进制下载地址,内部会依次传入组件名称与版本,替换字符串中的 %s ', default: 'http://iosframeworkserver-shopkeeperclient.app.2dfire.com/download/%s/%s.zip' },
|
14
|
+
# 'binary_type' => { description: '二进制打包类型', default: 'framework', selection: %w[framework library] },
|
15
|
+
#'download_file_type' => { description: '下载二进制文件类型', default: 'zip', selection: %w[zip tgz tar tbz txz dmg] }
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def sync_config(config)
|
20
|
+
File.open(config_file, 'w+') do |f|
|
21
|
+
f.write(config.to_yaml)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def default_config
|
26
|
+
@default_config ||= Hash[template_hash.map { |k, v| [k, v[:default]] }]
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def load_config
|
32
|
+
if File.exist?(config_file)
|
33
|
+
YAML.load_file(config_file)
|
34
|
+
else
|
35
|
+
default_config
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def config
|
40
|
+
@config ||= begin
|
41
|
+
@config = OpenStruct.new load_config
|
42
|
+
validate!
|
43
|
+
@config
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def validate!
|
48
|
+
template_hash.each do |k, v|
|
49
|
+
selection = v[:selection]
|
50
|
+
next if !selection || selection.empty?
|
51
|
+
|
52
|
+
config_value = @config.send(k)
|
53
|
+
next unless config_value
|
54
|
+
unless selection.include?(config_value)
|
55
|
+
raise Pod::Informative, "#{k} 字段的值必须限定在可选值 [ #{selection.join(' / ')} ] 内".red
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def respond_to_missing?(method, include_private = false)
|
61
|
+
config.respond_to?(method) || super
|
62
|
+
end
|
63
|
+
|
64
|
+
def method_missing(method, *args, &block)
|
65
|
+
if config.respond_to?(method)
|
66
|
+
config.send(method, *args)
|
67
|
+
elsif template_hash.keys.include?(method.to_s)
|
68
|
+
raise Pod::Informative, "#{method} 字段必须在配置文件 #{config_file} 中设置, 请执行 init 命令配置或手动修改配置文件".red
|
69
|
+
else
|
70
|
+
super
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.config
|
76
|
+
@config ||= Config.new
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'cocoapods-pahealth-bin/config/config'
|
3
|
+
|
4
|
+
module CBin
|
5
|
+
class Config
|
6
|
+
class Asker
|
7
|
+
def show_prompt
|
8
|
+
print ' > '.green
|
9
|
+
end
|
10
|
+
|
11
|
+
def ask_with_answer(question, pre_answer, selection)
|
12
|
+
print "\n#{question}\n"
|
13
|
+
|
14
|
+
print_selection_info = lambda {
|
15
|
+
print "可选值:[ #{selection.join(' / ')} ]\n" if selection
|
16
|
+
}
|
17
|
+
print_selection_info.call
|
18
|
+
print "旧值:#{pre_answer}\n" unless pre_answer.nil?
|
19
|
+
|
20
|
+
answer = ''
|
21
|
+
loop do
|
22
|
+
show_prompt
|
23
|
+
answer = STDIN.gets.chomp.strip
|
24
|
+
|
25
|
+
if answer == '' && !pre_answer.nil?
|
26
|
+
answer = pre_answer
|
27
|
+
print answer.yellow
|
28
|
+
print "\n"
|
29
|
+
end
|
30
|
+
|
31
|
+
next if answer.empty?
|
32
|
+
break if !selection || selection.include?(answer)
|
33
|
+
|
34
|
+
print_selection_info.call
|
35
|
+
end
|
36
|
+
|
37
|
+
answer
|
38
|
+
end
|
39
|
+
|
40
|
+
def wellcome_message
|
41
|
+
print <<~EOF
|
42
|
+
|
43
|
+
开始设置二进制化初始信息.
|
44
|
+
所有的信息都会保存在 #{CBin.config.config_file} 文件中.
|
45
|
+
你可以在对应目录下手动添加编辑该文件. 文件包含的配置信息样式如下:
|
46
|
+
|
47
|
+
#{CBin.config.default_config.to_yaml}
|
48
|
+
EOF
|
49
|
+
end
|
50
|
+
|
51
|
+
def done_message
|
52
|
+
print "\n设置完成.\n".green
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def binary_repo_url
|
57
|
+
# code here
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'cocoapods-pahealth-bin/native/sources_manager.rb'
|
2
|
+
|
3
|
+
module CBin
|
4
|
+
module SourcesHelper
|
5
|
+
def sources_manager
|
6
|
+
Pod::Config.instance.sources_manager
|
7
|
+
end
|
8
|
+
|
9
|
+
def binary_source
|
10
|
+
sources_manager.binary_source
|
11
|
+
end
|
12
|
+
|
13
|
+
def code_source
|
14
|
+
sources_manager.code_source
|
15
|
+
end
|
16
|
+
|
17
|
+
def trunk_source
|
18
|
+
sources_manager.trunk_source
|
19
|
+
end
|
20
|
+
|
21
|
+
# 优先采用对应依赖的 source
|
22
|
+
# cocoapods 内部会先匹配前面符合的 specification
|
23
|
+
# 只允许二进制的 specification subspec 比源码的 specification subspec 多
|
24
|
+
#
|
25
|
+
def valid_sources(code_dependencies = false)
|
26
|
+
sources = [code_source,trunk_source]
|
27
|
+
# unless code_dependencies
|
28
|
+
# sources << binary_source
|
29
|
+
# sources.reverse!
|
30
|
+
# end
|
31
|
+
sources
|
32
|
+
end
|
33
|
+
|
34
|
+
def sources_option(code_dependencies, additional_sources)
|
35
|
+
(valid_sources(code_dependencies).map(&:url) + Array(additional_sources)).join(',')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'cocoapods'
|
4
|
+
require 'cocoapods-pahealth-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
|
+
vendored_libraries = spec_hash.delete('vendored_libraries')
|
96
|
+
vendored_libraries = Array(vendored_libraries).reject { |l| l.end_with?('.a') }
|
97
|
+
if vendored_libraries.any?
|
98
|
+
spec_hash['vendored_libraries'] = vendored_libraries
|
99
|
+
end
|
100
|
+
|
101
|
+
# Filter platforms
|
102
|
+
platforms = spec_hash['platforms']
|
103
|
+
selected_platforms = platforms.select { |k, _v| @platforms.include?(k) }
|
104
|
+
spec_hash['platforms'] = selected_platforms.empty? ? platforms : selected_platforms
|
105
|
+
|
106
|
+
@spec = Pod::Specification.from_hash(spec_hash)
|
107
|
+
@spec
|
108
|
+
end
|
109
|
+
|
110
|
+
def create_from_code_spec_and_template_spec
|
111
|
+
@spec = template_spec.dup
|
112
|
+
|
113
|
+
@spec.version = code_spec.version
|
114
|
+
@spec.source = binary_source
|
115
|
+
@spec
|
116
|
+
end
|
117
|
+
|
118
|
+
def binary_source
|
119
|
+
{ http: format(CBin.config.binary_download_url, code_spec.root.name, code_spec.version), type: CBin.config.download_file_type }
|
120
|
+
end
|
121
|
+
|
122
|
+
def code_spec_consumer(_platform = :ios)
|
123
|
+
code_spec.consumer(:ios)
|
124
|
+
end
|
125
|
+
|
126
|
+
def framework_contents(name)
|
127
|
+
["#{code_spec.root.name}.framework", "#{code_spec.root.name}.framework/Versions/A"].map { |path| "#{path}/#{name}" }
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'cocoapods-pahealth-bin/native/sources_manager.rb'
|
4
|
+
require 'cocoapods-pahealth-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
|
78
|
+
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'cocoapods'
|
2
|
+
require 'cocoapods-pahealth-bin/native/podfile_env'
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
class Podfile
|
6
|
+
# TREAT_DEVELOPMENTS_AS_NORMAL = 'treat_developments_as_normal'.freeze
|
7
|
+
|
8
|
+
module DSL
|
9
|
+
def allow_prerelease!
|
10
|
+
set_internal_hash_value(ALLOW_PRERELEASE, true)
|
11
|
+
end
|
12
|
+
|
13
|
+
def use_binaries!(flag = true)
|
14
|
+
set_internal_hash_value(USE_BINARIES, flag)
|
15
|
+
end
|
16
|
+
|
17
|
+
def use_binaries_with_spec_selector!(&block)
|
18
|
+
raise Informative, '必须提供选择需要二进制组件的 block !' unless block_given?
|
19
|
+
|
20
|
+
set_internal_hash_value(USE_BINARIES_SELECTOR, block)
|
21
|
+
end
|
22
|
+
|
23
|
+
def set_use_source_pods(pods)
|
24
|
+
hash_pods_use_source = get_internal_hash_value(USE_SOURCE_PODS) || []
|
25
|
+
hash_pods_use_source += Array(pods)
|
26
|
+
set_internal_hash_value(USE_SOURCE_PODS, hash_pods_use_source)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
alias old_plugins plugins
|
31
|
+
def plugins
|
32
|
+
if ENV[USE_PLUGINS]
|
33
|
+
env_plugins = ENV[USE_PLUGINS].split(',').each_with_object({}) do |name, result|
|
34
|
+
result[name] = {}
|
35
|
+
end
|
36
|
+
env_plugins.merge!(old_plugins)
|
37
|
+
else
|
38
|
+
old_plugins
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def use_binaries_selector
|
43
|
+
get_internal_hash_value(USE_BINARIES_SELECTOR, nil)
|
44
|
+
end
|
45
|
+
|
46
|
+
def allow_prerelease?
|
47
|
+
get_internal_hash_value(ALLOW_PRERELEASE, false) || ENV[ALLOW_PRERELEASE] == 'true'
|
48
|
+
end
|
49
|
+
|
50
|
+
def use_binaries?
|
51
|
+
get_internal_hash_value(USE_BINARIES, false) || ENV[USE_BINARIES] == 'true'
|
52
|
+
end
|
53
|
+
|
54
|
+
def use_source_pods
|
55
|
+
get_internal_hash_value(USE_SOURCE_PODS, []) + String(ENV[USE_SOURCE_PODS]).split('|').uniq
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def valid_bin_plugin
|
61
|
+
unless plugins.keys.include?('cocoapods-bin')
|
62
|
+
raise Pod::Informative, 'You should add `plugin \'cocoapods-bin\'` before using its DSL'
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# set_hash_value 有 key 限制
|
67
|
+
def set_internal_hash_value(key, value)
|
68
|
+
valid_bin_plugin
|
69
|
+
|
70
|
+
internal_hash[key] = value
|
71
|
+
end
|
72
|
+
|
73
|
+
def get_internal_hash_value(key, default = nil)
|
74
|
+
internal_hash.fetch(key, default)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Pod
|
2
|
+
class Podfile
|
3
|
+
USE_BINARIES = 'use_binaries'
|
4
|
+
USE_SOURCE_PODS = 'use_source_pods'
|
5
|
+
USE_BINARIES_SELECTOR = 'use_binaries_selector'
|
6
|
+
ALLOW_PRERELEASE = 'allow_prerelease'
|
7
|
+
USE_PLUGINS = 'use_plugins'
|
8
|
+
|
9
|
+
module ENVExecutor
|
10
|
+
def execute_with_bin_plugin(&block)
|
11
|
+
execute_with_key(USE_PLUGINS, -> { 'cocoapods-pahealth-bin' }, &block)
|
12
|
+
end
|
13
|
+
|
14
|
+
def execute_with_allow_prerelease(allow_prerelease, &block)
|
15
|
+
execute_with_key(ALLOW_PRERELEASE, -> { allow_prerelease ? 'true' : 'false' }, &block)
|
16
|
+
end
|
17
|
+
|
18
|
+
def execute_with_use_binaries(use_binaries, &block)
|
19
|
+
execute_with_key(USE_BINARIES, -> { use_binaries ? 'true' : 'false' }, &block)
|
20
|
+
end
|
21
|
+
|
22
|
+
def execute_with_key(key, value_returner)
|
23
|
+
origin_value = ENV[key]
|
24
|
+
ENV[key] = value_returner.call
|
25
|
+
|
26
|
+
yield if block_given?
|
27
|
+
|
28
|
+
ENV[key] = origin_value
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
extend ENVExecutor
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'cocoapods'
|
2
|
+
require 'cocoapods-pahealth-bin/config/config'
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
class Source
|
6
|
+
class Manager
|
7
|
+
# 源码 source
|
8
|
+
def code_source
|
9
|
+
source_with_name_or_url(CBin.config.code_repo_url)
|
10
|
+
end
|
11
|
+
|
12
|
+
# 二进制 source
|
13
|
+
def binary_source
|
14
|
+
source_with_name_or_url(CBin.config.binary_repo_url)
|
15
|
+
end
|
16
|
+
|
17
|
+
def trunk_source
|
18
|
+
source_with_name_or_url('https://github.com/CocoaPods/Specs.git')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-pahealth-bin/gem_version'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-pahealth-bin/command'
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cocoapods-pahealth-bin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- GitWangKai
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-09-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: parallel
|
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
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.9.3
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.9.3
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: cocoapods-generate
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.0.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.0.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: A short description of cocoapods-pahealth-bin.
|
84
|
+
email:
|
85
|
+
- 18500052382@163.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- lib/cocoapods-pahealth-bin.rb
|
91
|
+
- lib/cocoapods-pahealth-bin/command.rb
|
92
|
+
- lib/cocoapods-pahealth-bin/command/bin.rb
|
93
|
+
- lib/cocoapods-pahealth-bin/command/bin/init.rb
|
94
|
+
- lib/cocoapods-pahealth-bin/command/bin/spec.rb
|
95
|
+
- lib/cocoapods-pahealth-bin/command/bin/spec/lint.rb
|
96
|
+
- lib/cocoapods-pahealth-bin/config/config.rb
|
97
|
+
- lib/cocoapods-pahealth-bin/config/config_asker.rb
|
98
|
+
- lib/cocoapods-pahealth-bin/gem_version.rb
|
99
|
+
- lib/cocoapods-pahealth-bin/helpers.rb
|
100
|
+
- lib/cocoapods-pahealth-bin/helpers/sources_helper.rb
|
101
|
+
- lib/cocoapods-pahealth-bin/helpers/spec_creator.rb
|
102
|
+
- lib/cocoapods-pahealth-bin/helpers/spec_files_helper.rb
|
103
|
+
- lib/cocoapods-pahealth-bin/native.rb
|
104
|
+
- lib/cocoapods-pahealth-bin/native/podfile.rb
|
105
|
+
- lib/cocoapods-pahealth-bin/native/podfile_env.rb
|
106
|
+
- lib/cocoapods-pahealth-bin/native/sources_manager.rb
|
107
|
+
- lib/cocoapods_plugin.rb
|
108
|
+
homepage: https://github.com/EXAMPLE/cocoapods-pahealth-bin
|
109
|
+
licenses:
|
110
|
+
- MIT
|
111
|
+
metadata: {}
|
112
|
+
post_install_message:
|
113
|
+
rdoc_options: []
|
114
|
+
require_paths:
|
115
|
+
- lib
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
requirements: []
|
127
|
+
rubygems_version: 3.0.3
|
128
|
+
signing_key:
|
129
|
+
specification_version: 4
|
130
|
+
summary: A longer description of cocoapods-pahealth-bin.
|
131
|
+
test_files: []
|