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,84 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
# copy from https://github.com/CocoaPods/cocoapods-packager
|
4
|
+
|
5
|
+
require 'cocoapods-imy-bin/native/podfile'
|
6
|
+
require 'cocoapods/command/gen'
|
7
|
+
require 'cocoapods/generate'
|
8
|
+
require 'cocoapods-imy-bin/helpers/framework_builder'
|
9
|
+
require 'cocoapods-imy-bin/helpers/library_builder'
|
10
|
+
require 'cocoapods-imy-bin/helpers/sources_helper'
|
11
|
+
require 'cocoapods-imy-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
|
+
Dir.chdir(CBin::Config::Builder.instance.root_dir) do
|
26
|
+
# 创建binary-template.podsepc
|
27
|
+
# 上传二进制文件
|
28
|
+
# 上传二进制 podspec
|
29
|
+
res_zip = curl_zip
|
30
|
+
if res_zip
|
31
|
+
filename = spec_creator
|
32
|
+
push_binary_repo(filename)
|
33
|
+
end
|
34
|
+
res_zip
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def spec_creator
|
39
|
+
spec_creator = CBin::SpecificationSource::Creator.new(@spec)
|
40
|
+
spec_creator.create
|
41
|
+
spec_creator.write_spec_file
|
42
|
+
spec_creator.filename
|
43
|
+
end
|
44
|
+
|
45
|
+
#推送二进制
|
46
|
+
# 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"
|
47
|
+
def curl_zip
|
48
|
+
zip_file = "#{CBin::Config::Builder.instance.library_file(@spec)}.zip"
|
49
|
+
res = File.exist?(zip_file)
|
50
|
+
print <<EOF
|
51
|
+
上传二进制文件
|
52
|
+
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}"
|
53
|
+
EOF
|
54
|
+
`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
|
55
|
+
|
56
|
+
res
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
# 上传二进制 podspec
|
62
|
+
def push_binary_repo(binary_podsepc_json)
|
63
|
+
argvs = [
|
64
|
+
"#{binary_podsepc_json}",
|
65
|
+
"--binary",
|
66
|
+
"--sources=#{sources_option(@code_dependencies, @sources)},https:\/\/cdn.cocoapods.org",
|
67
|
+
"--skip-import-validation",
|
68
|
+
"--use-libraries",
|
69
|
+
"--allow-warnings",
|
70
|
+
"--verbose",
|
71
|
+
"--code-dependencies"
|
72
|
+
]
|
73
|
+
if @verbose
|
74
|
+
argvs += ['--verbose']
|
75
|
+
end
|
76
|
+
|
77
|
+
push = Pod::Command::Bin::Repo::Push.new(CLAide::ARGV.new(argvs))
|
78
|
+
push.validate!
|
79
|
+
push.run
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'cocoapods'
|
2
|
+
|
3
|
+
if Pod.match_version?('~> 1.4')
|
4
|
+
require 'cocoapods-imy-bin/native/podfile'
|
5
|
+
require 'cocoapods-imy-bin/native/installation_options'
|
6
|
+
require 'cocoapods-imy-bin/native/specification'
|
7
|
+
require 'cocoapods-imy-bin/native/path_source'
|
8
|
+
require 'cocoapods-imy-bin/native/analyzer'
|
9
|
+
require 'cocoapods-imy-bin/native/installer'
|
10
|
+
require 'cocoapods-imy-bin/native/podfile_generator'
|
11
|
+
require 'cocoapods-imy-bin/native/pod_source_installer'
|
12
|
+
require 'cocoapods-imy-bin/native/linter'
|
13
|
+
require 'cocoapods-imy-bin/native/resolver'
|
14
|
+
require 'cocoapods-imy-bin/native/source'
|
15
|
+
require 'cocoapods-imy-bin/native/validator'
|
16
|
+
require 'cocoapods-imy-bin/native/acknowledgements'
|
17
|
+
require 'cocoapods-imy-bin/native/sandbox_analyzer'
|
18
|
+
require 'cocoapods-imy-bin/native/podspec_finder'
|
19
|
+
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,53 @@
|
|
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
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
require 'cocoapods'
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
class Installer
|
6
|
+
class InstallationOptions
|
7
|
+
def self.env_option(key, default = true)
|
8
|
+
option key, ENV[key.to_s].nil? ? default : ENV[key.to_s] == 'true'
|
9
|
+
end
|
10
|
+
|
11
|
+
# 不同 source 存在相同 spec 名时,默认不警告
|
12
|
+
defaults.delete('warn_for_multiple_pod_sources')
|
13
|
+
env_option :warn_for_multiple_pod_sources, false
|
14
|
+
|
15
|
+
# 是否警告不安全 source (如 http )
|
16
|
+
env_option :warn_for_unsecure_source, false
|
17
|
+
|
18
|
+
# 是否多线程执行 install_pod_sources
|
19
|
+
env_option :install_with_multi_threads, true
|
20
|
+
|
21
|
+
# 是否多进程执行 update_repositories
|
22
|
+
env_option :update_source_with_multi_processes, true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require 'parallel'
|
4
|
+
require 'cocoapods'
|
5
|
+
require 'cocoapods-imy-bin/native/pod_source_installer'
|
6
|
+
|
7
|
+
module Pod
|
8
|
+
class Installer
|
9
|
+
alias old_create_pod_installer create_pod_installer
|
10
|
+
def create_pod_installer(pod_name)
|
11
|
+
installer = old_create_pod_installer(pod_name)
|
12
|
+
installer.installation_options = installation_options
|
13
|
+
installer
|
14
|
+
end
|
15
|
+
|
16
|
+
alias old_install_pod_sources install_pod_sources
|
17
|
+
def install_pod_sources
|
18
|
+
if installation_options.install_with_multi_threads
|
19
|
+
if Pod.match_version?('~> 1.4.0')
|
20
|
+
install_pod_sources_for_version_in_1_4_0
|
21
|
+
elsif Pod.match_version?('~> 1.5')
|
22
|
+
install_pod_sources_for_version_above_1_5_0
|
23
|
+
else
|
24
|
+
old_install_pod_sources
|
25
|
+
end
|
26
|
+
else
|
27
|
+
old_install_pod_sources
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# rewrite install_pod_sources
|
32
|
+
def install_pod_sources_for_version_in_1_4_0
|
33
|
+
@installed_specs = []
|
34
|
+
pods_to_install = sandbox_state.added | sandbox_state.changed
|
35
|
+
title_options = { verbose_prefix: '-> '.green }
|
36
|
+
Parallel.each(root_specs.sort_by(&:name), in_threads: 4) do |spec|
|
37
|
+
if pods_to_install.include?(spec.name)
|
38
|
+
if sandbox_state.changed.include?(spec.name) && sandbox.manifest
|
39
|
+
previous = sandbox.manifest.version(spec.name)
|
40
|
+
title = "Installing #{spec.name} #{spec.version} (was #{previous})"
|
41
|
+
else
|
42
|
+
title = "Installing #{spec}"
|
43
|
+
end
|
44
|
+
UI.titled_section(title.green, title_options) do
|
45
|
+
install_source_of_pod(spec.name)
|
46
|
+
end
|
47
|
+
else
|
48
|
+
UI.titled_section("Using #{spec}", title_options) do
|
49
|
+
create_pod_installer(spec.name)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def install_pod_sources_for_version_above_1_5_0
|
56
|
+
@installed_specs = []
|
57
|
+
pods_to_install = sandbox_state.added | sandbox_state.changed
|
58
|
+
title_options = { verbose_prefix: '-> '.green }
|
59
|
+
# 多进程下载,多线程时 log 会显著交叉,多进程好点,但是多进程需要利用文件锁对 cache 进行保护
|
60
|
+
# in_processes: 10
|
61
|
+
Parallel.each(root_specs.sort_by(&:name), in_threads: 4) do |spec|
|
62
|
+
if pods_to_install.include?(spec.name)
|
63
|
+
if sandbox_state.changed.include?(spec.name) && sandbox.manifest
|
64
|
+
current_version = spec.version
|
65
|
+
previous_version = sandbox.manifest.version(spec.name)
|
66
|
+
has_changed_version = current_version != previous_version
|
67
|
+
current_repo = analysis_result.specs_by_source.detect do |key, values|
|
68
|
+
break key if values.map(&:name).include?(spec.name)
|
69
|
+
end
|
70
|
+
current_repo &&= current_repo.url || current_repo.name
|
71
|
+
previous_spec_repo = sandbox.manifest.spec_repo(spec.name)
|
72
|
+
has_changed_repo = !previous_spec_repo.nil? && current_repo && (current_repo != previous_spec_repo)
|
73
|
+
title = "Installing #{spec.name} #{spec.version}"
|
74
|
+
if has_changed_version && has_changed_repo
|
75
|
+
title += " (was #{previous_version} and source changed to `#{current_repo}` from `#{previous_spec_repo}`)"
|
76
|
+
end
|
77
|
+
if has_changed_version && !has_changed_repo
|
78
|
+
title += " (was #{previous_version})"
|
79
|
+
end
|
80
|
+
if !has_changed_version && has_changed_repo
|
81
|
+
title += " (source changed to `#{current_repo}` from `#{previous_spec_repo}`)"
|
82
|
+
end
|
83
|
+
else
|
84
|
+
title = "Installing #{spec}"
|
85
|
+
end
|
86
|
+
UI.titled_section(title.green, title_options) do
|
87
|
+
install_source_of_pod(spec.name)
|
88
|
+
end
|
89
|
+
else
|
90
|
+
UI.titled_section("Using #{spec}", title_options) do
|
91
|
+
create_pod_installer(spec.name)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
module Downloader
|
99
|
+
class Cache
|
100
|
+
# 多线程锁
|
101
|
+
@@lock = Mutex.new
|
102
|
+
|
103
|
+
# 后面如果要切到进程的话,可以在 cache root 里面新建一个文件
|
104
|
+
# 利用这个文件 lock
|
105
|
+
# https://stackoverflow.com/questions/23748648/using-fileflock-as-ruby-global-lock-mutex-for-processes
|
106
|
+
|
107
|
+
# rmtree 在多进程情况下可能 Directory not empty @ dir_s_rmdir 错误
|
108
|
+
# old_ensure_matching_version 会移除不是同一个 CocoaPods 版本的组件缓存
|
109
|
+
alias old_ensure_matching_version ensure_matching_version
|
110
|
+
def ensure_matching_version
|
111
|
+
@@lock.synchronize { old_ensure_matching_version }
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require 'cocoapods-imy-bin/native/specification'
|
4
|
+
|
5
|
+
module Pod
|
6
|
+
class Specification
|
7
|
+
class Linter
|
8
|
+
# !@group Lint steps
|
9
|
+
|
10
|
+
# Checks that the spec's root name matches the filename.
|
11
|
+
#
|
12
|
+
# @return [void]
|
13
|
+
#
|
14
|
+
def validate_root_name
|
15
|
+
if spec.root.name && file
|
16
|
+
acceptable_names = Specification::VALID_EXTNAME.map { |extname| "#{spec.root.name}#{extname}" }
|
17
|
+
names_match = acceptable_names.include?(file.basename.to_s)
|
18
|
+
unless names_match
|
19
|
+
results.add_error('name', 'The name of the spec should match the ' \
|
20
|
+
'name of the file.')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require 'cocoapods-imy-bin/native/specification'
|
4
|
+
|
5
|
+
module Pod
|
6
|
+
module ExternalSources
|
7
|
+
# Provides support for fetching a specification file from a path local to
|
8
|
+
# the machine running the installation.
|
9
|
+
#
|
10
|
+
class PathSource < AbstractExternalSource
|
11
|
+
def normalized_podspec_path(declared_path)
|
12
|
+
extension = File.extname(declared_path)
|
13
|
+
|
14
|
+
if extension == '.podspec' || extension == '.json'
|
15
|
+
path_with_ext = declared_path
|
16
|
+
else
|
17
|
+
# 默认先从 binary podspec 找起,因为 binary podspec 的 subspec 可能比 code podspec 多
|
18
|
+
# 这里可能出现 code subspec 和 binary subspec 对应不上的情况,导致 lint 失败
|
19
|
+
# 所以不要在 code podspec 同一目录下保留 binary podspec
|
20
|
+
path_with_ext = Specification::VALID_EXTNAME
|
21
|
+
.map { |extname| "#{declared_path}/#{name}#{extname}" }
|
22
|
+
.find { |file| File.exist?(file) } || "#{declared_path}/#{name}.podspec"
|
23
|
+
end
|
24
|
+
|
25
|
+
UI.message "获取的 podspec 路径为 `#{path_with_ext}`"
|
26
|
+
|
27
|
+
podfile_dir = File.dirname(podfile_path || '')
|
28
|
+
|
29
|
+
File.expand_path(path_with_ext, podfile_dir)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require 'cocoapods-imy-bin/native/installation_options'
|
4
|
+
|
5
|
+
module Pod
|
6
|
+
class Installer
|
7
|
+
class PodSourceInstaller
|
8
|
+
attr_accessor :installation_options
|
9
|
+
|
10
|
+
alias old_verify_source_is_secure verify_source_is_secure
|
11
|
+
def verify_source_is_secure(root_spec)
|
12
|
+
# http source 默认不警告
|
13
|
+
if installation_options.warn_for_unsecure_source?
|
14
|
+
old_verify_source_is_secure(root_spec)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require 'cocoapods'
|
4
|
+
require 'cocoapods-imy-bin/native/podfile_env'
|
5
|
+
|
6
|
+
module Pod
|
7
|
+
class Podfile
|
8
|
+
# TREAT_DEVELOPMENTS_AS_NORMAL = 'treat_developments_as_normal'.freeze
|
9
|
+
|
10
|
+
module DSL
|
11
|
+
def allow_prerelease!
|
12
|
+
set_internal_hash_value(ALLOW_PRERELEASE, true)
|
13
|
+
end
|
14
|
+
|
15
|
+
def use_binaries!(flag = true)
|
16
|
+
set_internal_hash_value(USE_BINARIES, flag)
|
17
|
+
end
|
18
|
+
|
19
|
+
def use_binaries_with_spec_selector!(&block)
|
20
|
+
raise Informative, '必须提供选择需要二进制组件的 block !' unless block_given?
|
21
|
+
|
22
|
+
set_internal_hash_value(USE_BINARIES_SELECTOR, block)
|
23
|
+
end
|
24
|
+
|
25
|
+
def set_use_source_pods(pods)
|
26
|
+
hash_pods_use_source = get_internal_hash_value(USE_SOURCE_PODS) || []
|
27
|
+
hash_pods_use_source += Array(pods)
|
28
|
+
set_internal_hash_value(USE_SOURCE_PODS, hash_pods_use_source)
|
29
|
+
end
|
30
|
+
|
31
|
+
# 0 dev
|
32
|
+
# 1 debug_iphoneos
|
33
|
+
# 2 release_iphoneos
|
34
|
+
# 需要在podfile_env 先定义 CONFIGURATION_ENV
|
35
|
+
def set_configuration_env(env = "dev")
|
36
|
+
set_internal_hash_value(CONFIGURATION_ENV, env)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
alias old_plugins plugins
|
41
|
+
def plugins
|
42
|
+
if ENV[USE_PLUGINS]
|
43
|
+
env_plugins = ENV[USE_PLUGINS].split(',').each_with_object({}) do |name, result|
|
44
|
+
result[name] = {}
|
45
|
+
end
|
46
|
+
env_plugins.merge!(old_plugins)
|
47
|
+
else
|
48
|
+
old_plugins
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def use_binaries_selector
|
53
|
+
get_internal_hash_value(USE_BINARIES_SELECTOR, nil)
|
54
|
+
end
|
55
|
+
|
56
|
+
def allow_prerelease?
|
57
|
+
get_internal_hash_value(ALLOW_PRERELEASE, false) || ENV[ALLOW_PRERELEASE] == 'true'
|
58
|
+
end
|
59
|
+
|
60
|
+
def use_binaries?
|
61
|
+
get_internal_hash_value(USE_BINARIES, false) || ENV[USE_BINARIES] == 'true'
|
62
|
+
end
|
63
|
+
|
64
|
+
def use_source_pods
|
65
|
+
get_internal_hash_value(USE_SOURCE_PODS, []) + String(ENV[USE_SOURCE_PODS]).split('|').uniq
|
66
|
+
end
|
67
|
+
|
68
|
+
def configuration_env
|
69
|
+
get_internal_hash_value(CONFIGURATION_ENV, "dev") || ENV[CONFIGURATION_ENV] == "dev"
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
def valid_bin_plugin
|
75
|
+
unless plugins.keys.include?('cocoapods-imy-bin')
|
76
|
+
raise Pod::Informative, 'You should add `plugin \'cocoapods-imy-bin\'` before using its DSL'
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# set_hash_value 有 key 限制
|
81
|
+
def set_internal_hash_value(key, value)
|
82
|
+
valid_bin_plugin
|
83
|
+
|
84
|
+
internal_hash[key] = value
|
85
|
+
end
|
86
|
+
|
87
|
+
def get_internal_hash_value(key, default = nil)
|
88
|
+
internal_hash.fetch(key, default)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|