cocoapods-imy-bin 0.2.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 +541 -0
- data/lib/cocoapods-imy-bin.rb +2 -0
- data/lib/cocoapods-imy-bin/command.rb +2 -0
- data/lib/cocoapods-imy-bin/command/bin.rb +60 -0
- data/lib/cocoapods-imy-bin/command/bin/archive.rb +184 -0
- data/lib/cocoapods-imy-bin/command/bin/auto.rb +188 -0
- data/lib/cocoapods-imy-bin/command/bin/code.rb +237 -0
- data/lib/cocoapods-imy-bin/command/bin/imy.rb +46 -0
- data/lib/cocoapods-imy-bin/command/bin/init.rb +69 -0
- data/lib/cocoapods-imy-bin/command/bin/initHotKey.rb +70 -0
- data/lib/cocoapods-imy-bin/command/bin/install.rb +44 -0
- data/lib/cocoapods-imy-bin/command/bin/lib/lint.rb +69 -0
- data/lib/cocoapods-imy-bin/command/bin/local.rb +156 -0
- data/lib/cocoapods-imy-bin/command/bin/repo/update.rb +43 -0
- data/lib/cocoapods-imy-bin/command/bin/spec/create.rb +73 -0
- data/lib/cocoapods-imy-bin/command/bin/spec/push.rb +114 -0
- data/lib/cocoapods-imy-bin/command/bin/update.rb +148 -0
- data/lib/cocoapods-imy-bin/config/config.rb +137 -0
- data/lib/cocoapods-imy-bin/config/config_asker.rb +57 -0
- data/lib/cocoapods-imy-bin/config/config_builder.rb +179 -0
- data/lib/cocoapods-imy-bin/config/config_hot_key.rb +103 -0
- data/lib/cocoapods-imy-bin/config/config_hot_key_asker.rb +57 -0
- data/lib/cocoapods-imy-bin/gem_version.rb +10 -0
- data/lib/cocoapods-imy-bin/helpers.rb +4 -0
- data/lib/cocoapods-imy-bin/helpers/build_helper.rb +150 -0
- data/lib/cocoapods-imy-bin/helpers/framework.rb +62 -0
- data/lib/cocoapods-imy-bin/helpers/framework_builder.rb +307 -0
- data/lib/cocoapods-imy-bin/helpers/library.rb +54 -0
- data/lib/cocoapods-imy-bin/helpers/library_builder.rb +90 -0
- data/lib/cocoapods-imy-bin/helpers/local/loca_llibrary.rb +57 -0
- data/lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb +146 -0
- data/lib/cocoapods-imy-bin/helpers/local/local_framework.rb +65 -0
- data/lib/cocoapods-imy-bin/helpers/local/local_framework_builder.rb +174 -0
- data/lib/cocoapods-imy-bin/helpers/local/local_library_builder.rb +92 -0
- data/lib/cocoapods-imy-bin/helpers/sources_helper.rb +33 -0
- data/lib/cocoapods-imy-bin/helpers/spec_creator.rb +170 -0
- data/lib/cocoapods-imy-bin/helpers/spec_files_helper.rb +77 -0
- data/lib/cocoapods-imy-bin/helpers/spec_source_creator.rb +171 -0
- data/lib/cocoapods-imy-bin/helpers/upload_helper.rb +84 -0
- data/lib/cocoapods-imy-bin/native.rb +19 -0
- data/lib/cocoapods-imy-bin/native/acknowledgements.rb +27 -0
- data/lib/cocoapods-imy-bin/native/analyzer.rb +53 -0
- data/lib/cocoapods-imy-bin/native/installation_options.rb +25 -0
- data/lib/cocoapods-imy-bin/native/installer.rb +115 -0
- data/lib/cocoapods-imy-bin/native/linter.rb +26 -0
- data/lib/cocoapods-imy-bin/native/path_source.rb +33 -0
- data/lib/cocoapods-imy-bin/native/pod_source_installer.rb +19 -0
- data/lib/cocoapods-imy-bin/native/podfile.rb +91 -0
- data/lib/cocoapods-imy-bin/native/podfile_env.rb +37 -0
- data/lib/cocoapods-imy-bin/native/podfile_generator.rb +190 -0
- data/lib/cocoapods-imy-bin/native/podspec_finder.rb +25 -0
- data/lib/cocoapods-imy-bin/native/resolver.rb +230 -0
- data/lib/cocoapods-imy-bin/native/sandbox_analyzer.rb +34 -0
- data/lib/cocoapods-imy-bin/native/source.rb +35 -0
- data/lib/cocoapods-imy-bin/native/sources_manager.rb +20 -0
- data/lib/cocoapods-imy-bin/native/specification.rb +31 -0
- data/lib/cocoapods-imy-bin/native/validator.rb +77 -0
- data/lib/cocoapods-imy-bin/source_provider_hook.rb +54 -0
- data/lib/cocoapods_plugin.rb +3 -0
- data/spec/command/bin_spec.rb +12 -0
- data/spec/spec_helper.rb +50 -0
- metadata +180 -0
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'parallel'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Bin < Command
|
6
|
+
class Repo < Bin
|
7
|
+
class Update < Repo
|
8
|
+
self.summary = '更新私有源'
|
9
|
+
|
10
|
+
self.arguments = [
|
11
|
+
CLAide::Argument.new('NAME', false)
|
12
|
+
]
|
13
|
+
|
14
|
+
def self.options
|
15
|
+
[
|
16
|
+
['--all', '更新所有私有源,默认只更新二进制相关私有源']
|
17
|
+
].concat(super)
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(argv)
|
21
|
+
@all = argv.flag?('all')
|
22
|
+
@name = argv.shift_argument
|
23
|
+
super
|
24
|
+
end
|
25
|
+
|
26
|
+
def run
|
27
|
+
show_output = !config.silent?
|
28
|
+
if @name || @all
|
29
|
+
config.sources_manager.update(@name, show_output)
|
30
|
+
else
|
31
|
+
Parallel.each(valid_sources, in_threads: 4) do |source|
|
32
|
+
UI.puts "更新私有源仓库 #{source.to_s}".yellow
|
33
|
+
source.update(show_output)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'cocoapods-imy-bin/helpers'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Bin < Command
|
6
|
+
class Spec < Bin
|
7
|
+
class Create < Spec
|
8
|
+
self.summary = '创建二进制 spec.'
|
9
|
+
self.description = <<-DESC
|
10
|
+
根据源码 podspec 文件,创建对应的二进制 podspec 文件.
|
11
|
+
DESC
|
12
|
+
|
13
|
+
def self.options
|
14
|
+
[
|
15
|
+
['--platforms=ios', '生成二进制 spec 支持的平台'],
|
16
|
+
['--template-podspec=A.binary-template.podspec', '生成拥有 subspec 的二进制 spec 需要的模版 podspec, 插件会更改 version 和 source'],
|
17
|
+
['--no-overwrite', '不允许覆盖']
|
18
|
+
].concat(super)
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(argv)
|
22
|
+
@platforms = argv.option('platforms', 'ios')
|
23
|
+
@allow_overwrite = argv.flag?('overwrite', true)
|
24
|
+
@template_podspec = argv.option('template-podspec')
|
25
|
+
@podspec = argv.shift_argument
|
26
|
+
super
|
27
|
+
end
|
28
|
+
|
29
|
+
def run
|
30
|
+
UI.puts "开始读取 podspec 文件...\n"
|
31
|
+
|
32
|
+
code_spec = Pod::Specification.from_file(spec_file)
|
33
|
+
if template_spec_file
|
34
|
+
template_spec = Pod::Specification.from_file(template_spec_file)
|
35
|
+
end
|
36
|
+
|
37
|
+
if binary_spec && !@allow_overwrite
|
38
|
+
UI.warn "二进制 podspec 文件 #{binary_spec_files.first} 已存在.\n"
|
39
|
+
else
|
40
|
+
UI.puts "开始生成二进制 podspec 文件...\n"
|
41
|
+
spec_file = create_binary_spec_file(code_spec, template_spec)
|
42
|
+
UI.puts "创建二进制 podspec 文件 #{spec_file} 成功.\n".green
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def template_spec_file
|
47
|
+
@template_spec_file ||= begin
|
48
|
+
if @template_podspec
|
49
|
+
find_spec_file(@template_podspec)
|
50
|
+
else
|
51
|
+
binary_template_spec_file
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def spec_file
|
57
|
+
@spec_file ||= begin
|
58
|
+
if @podspec
|
59
|
+
find_spec_file(@podspec)
|
60
|
+
else
|
61
|
+
if code_spec_files.empty?
|
62
|
+
raise Informative, '当前目录下没有找到可用源码 podspec.'
|
63
|
+
end
|
64
|
+
|
65
|
+
code_spec_files.first
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
require 'cocoapods-imy-bin/config/config'
|
2
|
+
require 'cocoapods-imy-bin/native/podfile'
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
class Command
|
6
|
+
class Bin < Command
|
7
|
+
class Repo < Bin
|
8
|
+
class Push < Repo
|
9
|
+
self.summary = '发布组件.'
|
10
|
+
self.description = <<-DESC
|
11
|
+
发布二进制组件 / 源码组件
|
12
|
+
DESC
|
13
|
+
|
14
|
+
self.arguments = [
|
15
|
+
CLAide::Argument.new('NAME.podspec', false)
|
16
|
+
]
|
17
|
+
|
18
|
+
def self.options
|
19
|
+
[
|
20
|
+
['--binary', '发布组件的二进制版本'],
|
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::Repo::Push.options).concat(super).uniq
|
27
|
+
end
|
28
|
+
|
29
|
+
def initialize(argv)
|
30
|
+
@podspec = argv.shift_argument
|
31
|
+
@binary = argv.flag?('binary')
|
32
|
+
@loose_options = argv.flag?('loose-options')
|
33
|
+
@code_dependencies = argv.flag?('code-dependencies')
|
34
|
+
@sources = argv.option('sources') || []
|
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
|
+
repo,
|
49
|
+
"--sources=#{sources_option(@code_dependencies, @sources)}",
|
50
|
+
*@additional_args
|
51
|
+
]
|
52
|
+
|
53
|
+
argvs << spec_file if spec_file
|
54
|
+
|
55
|
+
if @loose_options
|
56
|
+
argvs += ['--allow-warnings', '--use-json']
|
57
|
+
if code_spec&.all_dependencies&.any?
|
58
|
+
argvs << '--use-libraries'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
push = Pod::Command::Repo::Push.new(CLAide::ARGV.new(argvs))
|
63
|
+
push.validate!
|
64
|
+
push.run
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
ensure
|
69
|
+
clear_binary_spec_file_if_needed unless @reserve_created_spec
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
def template_spec_file
|
75
|
+
@template_spec_file ||= begin
|
76
|
+
if @template_podspec
|
77
|
+
find_spec_file(@template_podspec)
|
78
|
+
else
|
79
|
+
binary_template_spec_file
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def spec_file
|
85
|
+
@spec_file ||= begin
|
86
|
+
if @podspec
|
87
|
+
find_spec_file(@podspec)
|
88
|
+
else
|
89
|
+
if code_spec_files.empty?
|
90
|
+
raise Informative, '当前目录下没有找到可用源码 podspec.'
|
91
|
+
end
|
92
|
+
|
93
|
+
spec_file = if @binary
|
94
|
+
code_spec = Pod::Specification.from_file(code_spec_files.first)
|
95
|
+
if template_spec_file
|
96
|
+
template_spec = Pod::Specification.from_file(template_spec_file)
|
97
|
+
end
|
98
|
+
create_binary_spec_file(code_spec, template_spec)
|
99
|
+
else
|
100
|
+
code_spec_files.first
|
101
|
+
end
|
102
|
+
spec_file
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def repo
|
108
|
+
@binary ? binary_source.name : code_source.name
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,148 @@
|
|
1
|
+
|
2
|
+
require 'cocoapods'
|
3
|
+
require 'cocoapods-imy-bin/native/podfile_env'
|
4
|
+
require 'cocoapods-imy-bin/native/podfile'
|
5
|
+
|
6
|
+
module Pod
|
7
|
+
class Command
|
8
|
+
class Bin < Command
|
9
|
+
class Update < Bin
|
10
|
+
include Pod
|
11
|
+
include Pod::Podfile::DSL
|
12
|
+
|
13
|
+
self.summary = 'pod update 拦截器,会加载本地Podfile_local文件,DSL加载到原始Podfile文件中。'
|
14
|
+
|
15
|
+
self.description = <<-DESC
|
16
|
+
pod update 拦截器,会加载本地Podfile_local文件
|
17
|
+
会通过DSL加载到原始Podfile文件中
|
18
|
+
支持 pod 'xxx' 各种写法
|
19
|
+
支持 post_install/pre_install钩子,采用覆盖做法
|
20
|
+
DESC
|
21
|
+
def self.options
|
22
|
+
[
|
23
|
+
["--sources=#{Pod::TrunkSource::TRUNK_REPO_URL}", 'The sources from which to update dependent pods. ' \
|
24
|
+
'Multiple sources must be comma-delimited'],
|
25
|
+
['--exclude-pods=podName', 'Pods to exclude during update. Multiple pods must be comma-delimited'],
|
26
|
+
['--clean-install', 'Ignore the contents of the project cache and force a full pod installation. This only ' \
|
27
|
+
'applies to projects that have enabled incremental installation'],
|
28
|
+
['--project-directory=/project/dir/', 'The path to the root of the project directory'],
|
29
|
+
['--no-repo-update', 'Skip running `pod repo update` before install']
|
30
|
+
].concat(super)
|
31
|
+
end
|
32
|
+
|
33
|
+
def initialize(argv)
|
34
|
+
@update = argv.flag?('update')
|
35
|
+
super
|
36
|
+
@additional_args = argv.remainder!
|
37
|
+
end
|
38
|
+
|
39
|
+
def run
|
40
|
+
Update.load_local_podfile
|
41
|
+
|
42
|
+
argvs = [
|
43
|
+
*@additional_args
|
44
|
+
]
|
45
|
+
|
46
|
+
gen = Pod::Command::Update.new(CLAide::ARGV.new(argvs))
|
47
|
+
gen.validate!
|
48
|
+
gen.run
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.load_local_podfile
|
52
|
+
# 同步 Podfile_local 文件
|
53
|
+
project_root = Pod::Config.instance.project_root
|
54
|
+
path = File.join(project_root.to_s, 'Podfile_local')
|
55
|
+
unless File.exist?(path)
|
56
|
+
path = File.join(project_root.to_s, 'Podfile_local')
|
57
|
+
end
|
58
|
+
|
59
|
+
if File.exist?(path)
|
60
|
+
contents = File.open(path, 'r:utf-8', &:read)
|
61
|
+
|
62
|
+
podfile = Pod::Config.instance.podfile
|
63
|
+
local_podfile = Podfile.from_file(path)
|
64
|
+
|
65
|
+
if local_podfile
|
66
|
+
local_pre_install_callback = nil
|
67
|
+
local_post_install_callback = nil
|
68
|
+
local_podfile.instance_eval do
|
69
|
+
local_pre_install_callback = @pre_install_callback
|
70
|
+
local_post_install_callback = @post_install_callback
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
podfile.instance_eval do
|
75
|
+
begin
|
76
|
+
# 在target把local-target中到dependencies值删除了,再设置
|
77
|
+
# 把本地和原始到dependencies 合并,设置dependencies
|
78
|
+
local_podfile&.target_definition_list&.each do |local_target|
|
79
|
+
next if local_target.name == 'Pods'
|
80
|
+
|
81
|
+
target_definition_list.each do |target|
|
82
|
+
unless target.name == local_target.name &&
|
83
|
+
(local_target.to_hash['dependencies'] &&local_target.to_hash['dependencies'].any?)
|
84
|
+
next
|
85
|
+
end
|
86
|
+
|
87
|
+
# podfile HASH_KEYS才有plugins字段,否则会被限制
|
88
|
+
if local_podfile.plugins.any?
|
89
|
+
hash_plugins = podfile.plugins || {}
|
90
|
+
hash_plugins = hash_plugins.merge(local_podfile.plugins)
|
91
|
+
set_hash_value(%w[plugins].first, hash_plugins)
|
92
|
+
end
|
93
|
+
# 加入源码白名单,避免本地库被二进制了
|
94
|
+
podfile.set_use_source_pods(local_podfile.use_source_pods) if local_podfile.use_source_pods
|
95
|
+
podfile.use_binaries!(local_podfile.use_binaries?)
|
96
|
+
|
97
|
+
target.instance_exec do
|
98
|
+
# 在target把local-target中到dependencies值删除了,再设置
|
99
|
+
|
100
|
+
local_dependencies = local_target.to_hash['dependencies']
|
101
|
+
target_dependencies = target.to_hash['dependencies']
|
102
|
+
|
103
|
+
local_dependencies.each do |local_dependency|
|
104
|
+
unless local_dependency.is_a?(Hash) && local_dependency.keys.first
|
105
|
+
next
|
106
|
+
end
|
107
|
+
|
108
|
+
target_dependencies.each do |target_dependency|
|
109
|
+
next unless target_dependency.is_a?(Hash) &&
|
110
|
+
target_dependency.keys.first &&
|
111
|
+
target_dependency.keys.first == local_dependency.keys.first
|
112
|
+
|
113
|
+
target_dependencies.delete target_dependency
|
114
|
+
break
|
115
|
+
end
|
116
|
+
end
|
117
|
+
# 把本地和原始到dependencies 合并,设置dependencies
|
118
|
+
local_dependencies.each do |d|
|
119
|
+
UI.message "Development Pod #{d.to_yaml}"
|
120
|
+
if podfile.plugins.keys.include?('cocoapods-imy-bin')
|
121
|
+
podfile.set_use_source_pods(d.keys.first) if (d.is_a?(Hash) && d.keys.first)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
new_dependencies = target_dependencies + local_dependencies
|
125
|
+
set_hash_value(%w[dependencies].first, new_dependencies)
|
126
|
+
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
if local_pre_install_callback
|
132
|
+
@pre_install_callback = local_pre_install_callback
|
133
|
+
end
|
134
|
+
if local_post_install_callback
|
135
|
+
@post_install_callback = local_post_install_callback
|
136
|
+
end
|
137
|
+
rescue Exception => e
|
138
|
+
message = "Invalid `#{path}` file: #{e.message}"
|
139
|
+
raise Pod::DSLError.new(message, path, e, contents)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'cocoapods-imy-bin/native/podfile'
|
3
|
+
require 'cocoapods-imy-bin/native/podfile_env'
|
4
|
+
require 'cocoapods/generate'
|
5
|
+
|
6
|
+
module CBin
|
7
|
+
class Config
|
8
|
+
def config_file
|
9
|
+
config_file_with_configuration_env(configuration_env)
|
10
|
+
end
|
11
|
+
|
12
|
+
def template_hash
|
13
|
+
{
|
14
|
+
'configuration_env' => { description: '编译环境', default: 'dev', selection: %w[dev debug_iphoneos release_iphoneos] },
|
15
|
+
'code_repo_url' => { description: '源码私有源 Git 地址', default: 'git@github.com:su350380433/example_spec_source.git' },
|
16
|
+
'binary_repo_url' => { description: '二进制私有源 Git 地址', default: 'git@github.com:su350380433/example_spec_bin_dev.git' },
|
17
|
+
'binary_download_url' => { description: '二进制下载地址,内部会依次传入组件名称与版本,替换字符串中的 %s ', default: 'http://localhost:8080/frameworks/%s/%s.zip' },
|
18
|
+
# 'binary_type' => { description: '二进制打包类型', default: 'framework', selection: %w[framework library] },
|
19
|
+
'download_file_type' => { description: '下载二进制文件类型', default: 'zip', selection: %w[zip tgz tar tbz txz dmg] }
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
def config_file_with_configuration_env(configuration_env)
|
24
|
+
file = config_dev_file
|
25
|
+
if configuration_env == "release_iphoneos"
|
26
|
+
file = config_release_iphoneos_file
|
27
|
+
puts "\n====== #{configuration_env} 环境 ========"
|
28
|
+
elsif configuration_env == "debug_iphoneos"
|
29
|
+
file = config_debug_iphoneos_file
|
30
|
+
puts "\n====== #{configuration_env} 环境 ========"
|
31
|
+
elsif configuration_env == "dev"
|
32
|
+
puts "\n====== #{configuration_env} 环境 ========"
|
33
|
+
else
|
34
|
+
raise "\n===== #{configuration_env} 参数有误,请检查%w[dev debug_iphoneos release_iphoneos]===="
|
35
|
+
end
|
36
|
+
|
37
|
+
File.expand_path("#{Pod::Config.instance.home_dir}/#{file}")
|
38
|
+
end
|
39
|
+
|
40
|
+
def configuration_env
|
41
|
+
#如果是dev 再去 podfile的配置文件中获取,确保是正确的, pod update时会用到
|
42
|
+
if @configuration_env == "dev" || @configuration_env == nil
|
43
|
+
if Pod::Config.instance.podfile
|
44
|
+
configuration_env ||= Pod::Config.instance.podfile.configuration_env
|
45
|
+
end
|
46
|
+
configuration_env ||= "dev"
|
47
|
+
@configuration_env = configuration_env
|
48
|
+
end
|
49
|
+
@configuration_env
|
50
|
+
end
|
51
|
+
|
52
|
+
#上传的url
|
53
|
+
def binary_upload_url
|
54
|
+
cut_string = "/%s/%s/zip"
|
55
|
+
binary_download_url[0,binary_download_url.length - cut_string.length]
|
56
|
+
end
|
57
|
+
|
58
|
+
def set_configuration_env(env)
|
59
|
+
@configuration_env = env
|
60
|
+
end
|
61
|
+
|
62
|
+
#包含arm64 armv7架构,xcodebuild 是Debug模式
|
63
|
+
def config_debug_iphoneos_file
|
64
|
+
"bin_debug_iphoneos.yml"
|
65
|
+
end
|
66
|
+
#包含arm64 armv7架构,xcodebuild 是Release模式
|
67
|
+
def config_release_iphoneos_file
|
68
|
+
"bin_release_iphoneos.yml"
|
69
|
+
end
|
70
|
+
#包含x86 arm64 armv7架构,xcodebuild 是Release模式
|
71
|
+
def config_dev_file
|
72
|
+
"bin_dev.yml"
|
73
|
+
end
|
74
|
+
|
75
|
+
def sync_config(config)
|
76
|
+
File.open(config_file_with_configuration_env(config['configuration_env']), 'w+') do |f|
|
77
|
+
f.write(config.to_yaml)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def default_config
|
82
|
+
@default_config ||= Hash[template_hash.map { |k, v| [k, v[:default]] }]
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
def load_config
|
88
|
+
if File.exist?(config_file)
|
89
|
+
YAML.load_file(config_file)
|
90
|
+
else
|
91
|
+
default_config
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def config
|
96
|
+
@config ||= begin
|
97
|
+
puts "====== cocoapods-imy-bin #{CBin::VERSION} 版本 ======== \n"
|
98
|
+
@config = OpenStruct.new load_config
|
99
|
+
validate!
|
100
|
+
@config
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def validate!
|
105
|
+
template_hash.each do |k, v|
|
106
|
+
selection = v[:selection]
|
107
|
+
next if !selection || selection.empty?
|
108
|
+
|
109
|
+
config_value = @config.send(k)
|
110
|
+
next unless config_value
|
111
|
+
unless selection.include?(config_value)
|
112
|
+
raise Pod::Informative, "#{k} 字段的值必须限定在可选值 [ #{selection.join(' / ')} ] 内".red
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def respond_to_missing?(method, include_private = false)
|
118
|
+
config.respond_to?(method) || super
|
119
|
+
end
|
120
|
+
|
121
|
+
def method_missing(method, *args, &block)
|
122
|
+
if config.respond_to?(method)
|
123
|
+
config.send(method, *args)
|
124
|
+
elsif template_hash.keys.include?(method.to_s)
|
125
|
+
raise Pod::Informative, "#{method} 字段必须在配置文件 #{config_file} 中设置, 请执行 init 命令配置或手动修改配置文件".red
|
126
|
+
else
|
127
|
+
super
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def self.config
|
133
|
+
@config ||= Config.new
|
134
|
+
end
|
135
|
+
|
136
|
+
|
137
|
+
end
|