cocoapods-tj 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +1 -0
- data/lib/cocoapods-tj/command/bin/archive.rb +203 -0
- data/lib/cocoapods-tj/command/bin/auto.rb +189 -0
- data/lib/cocoapods-tj/command/bin/code.rb +198 -0
- data/lib/cocoapods-tj/command/bin/imy.rb +45 -0
- data/lib/cocoapods-tj/command/bin/init.rb +65 -0
- data/lib/cocoapods-tj/command/bin/initHotKey.rb +66 -0
- data/lib/cocoapods-tj/command/bin/install.rb +41 -0
- data/lib/cocoapods-tj/command/bin/lib/lint.rb +66 -0
- data/lib/cocoapods-tj/command/bin/local.rb +142 -0
- data/lib/cocoapods-tj/command/bin/repo/update.rb +42 -0
- data/lib/cocoapods-tj/command/bin/spec/create.rb +68 -0
- data/lib/cocoapods-tj/command/bin/spec/push.rb +114 -0
- data/lib/cocoapods-tj/command/bin/update.rb +144 -0
- data/lib/cocoapods-tj/command/bin.rb +42 -0
- data/lib/cocoapods-tj/command.rb +2 -0
- data/lib/cocoapods-tj/config/config.rb +129 -0
- data/lib/cocoapods-tj/config/config_asker.rb +49 -0
- data/lib/cocoapods-tj/config/config_builder.rb +201 -0
- data/lib/cocoapods-tj/config/config_hot_key.rb +102 -0
- data/lib/cocoapods-tj/config/config_hot_key_asker.rb +48 -0
- data/lib/cocoapods-tj/gem_version.rb +10 -0
- data/lib/cocoapods-tj/helpers/Info.plist +0 -0
- data/lib/cocoapods-tj/helpers/build_helper.rb +154 -0
- data/lib/cocoapods-tj/helpers/build_utils.rb +62 -0
- data/lib/cocoapods-tj/helpers/framework.rb +79 -0
- data/lib/cocoapods-tj/helpers/framework_builder.rb +391 -0
- data/lib/cocoapods-tj/helpers/library.rb +54 -0
- data/lib/cocoapods-tj/helpers/library_builder.rb +89 -0
- data/lib/cocoapods-tj/helpers/local/loca_llibrary.rb +57 -0
- data/lib/cocoapods-tj/helpers/local/local_build_helper.rb +177 -0
- data/lib/cocoapods-tj/helpers/local/local_framework.rb +85 -0
- data/lib/cocoapods-tj/helpers/local/local_framework_builder.rb +226 -0
- data/lib/cocoapods-tj/helpers/local/local_library_builder.rb +91 -0
- data/lib/cocoapods-tj/helpers/sources_helper.rb +32 -0
- data/lib/cocoapods-tj/helpers/spec_creator.rb +150 -0
- data/lib/cocoapods-tj/helpers/spec_files_helper.rb +73 -0
- data/lib/cocoapods-tj/helpers/spec_source_creator.rb +189 -0
- data/lib/cocoapods-tj/helpers/upload_helper.rb +81 -0
- data/lib/cocoapods-tj/helpers.rb +5 -0
- data/lib/cocoapods-tj/native/acknowledgements.rb +26 -0
- data/lib/cocoapods-tj/native/analyzer.rb +29 -0
- data/lib/cocoapods-tj/native/file_accessor.rb +20 -0
- data/lib/cocoapods-tj/native/installation_options.rb +21 -0
- data/lib/cocoapods-tj/native/installer.rb +106 -0
- data/lib/cocoapods-tj/native/linter.rb +26 -0
- data/lib/cocoapods-tj/native/path_source.rb +29 -0
- data/lib/cocoapods-tj/native/pod_source_installer.rb +18 -0
- data/lib/cocoapods-tj/native/pod_target_installer.rb +81 -0
- data/lib/cocoapods-tj/native/podfile.rb +91 -0
- data/lib/cocoapods-tj/native/podfile_env.rb +37 -0
- data/lib/cocoapods-tj/native/podfile_generator.rb +135 -0
- data/lib/cocoapods-tj/native/podspec_finder.rb +23 -0
- data/lib/cocoapods-tj/native/resolver.rb +202 -0
- data/lib/cocoapods-tj/native/sandbox_analyzer.rb +11 -0
- data/lib/cocoapods-tj/native/source.rb +35 -0
- data/lib/cocoapods-tj/native/sources_manager.rb +18 -0
- data/lib/cocoapods-tj/native/specification.rb +10 -0
- data/lib/cocoapods-tj/native/target_validator.rb +41 -0
- data/lib/cocoapods-tj/native/validator.rb +40 -0
- data/lib/cocoapods-tj/native.rb +23 -0
- data/lib/cocoapods-tj/source_provider_hook.rb +50 -0
- data/lib/cocoapods-tj.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 +182 -0
@@ -0,0 +1,144 @@
|
|
1
|
+
|
2
|
+
require 'cocoapods'
|
3
|
+
require 'cocoapods-tj/native/podfile_env'
|
4
|
+
require 'cocoapods-tj/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 = ''
|
14
|
+
|
15
|
+
self.description = <<-DESC
|
16
|
+
DESC
|
17
|
+
def self.options
|
18
|
+
[
|
19
|
+
["--sources=#{Pod::TrunkSource::TRUNK_REPO_URL}", 'The sources from which to update dependent pods. ' \
|
20
|
+
'Multiple sources must be comma-delimited'],
|
21
|
+
['--exclude-pods=podName', 'Pods to exclude during update. Multiple pods must be comma-delimited'],
|
22
|
+
['--clean-install', 'Ignore the contents of the project cache and force a full pod installation. This only ' \
|
23
|
+
'applies to projects that have enabled incremental installation'],
|
24
|
+
['--project-directory=/project/dir/', 'The path to the root of the project directory'],
|
25
|
+
['--no-repo-update', 'Skip running `pod repo update` before install']
|
26
|
+
].concat(super)
|
27
|
+
end
|
28
|
+
|
29
|
+
def initialize(argv)
|
30
|
+
@update = argv.flag?('update')
|
31
|
+
super
|
32
|
+
@additional_args = argv.remainder!
|
33
|
+
end
|
34
|
+
|
35
|
+
def run
|
36
|
+
Update.load_local_podfile
|
37
|
+
|
38
|
+
argvs = [
|
39
|
+
*@additional_args
|
40
|
+
]
|
41
|
+
|
42
|
+
gen = Pod::Command::Update.new(CLAide::ARGV.new(argvs))
|
43
|
+
gen.validate!
|
44
|
+
gen.run
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.load_local_podfile
|
48
|
+
|
49
|
+
project_root = Pod::Config.instance.project_root
|
50
|
+
path = File.join(project_root.to_s, 'Podfile_TJ')
|
51
|
+
unless File.exist?(path)
|
52
|
+
path = File.join(project_root.to_s, 'Podfile_TJ')
|
53
|
+
end
|
54
|
+
|
55
|
+
if File.exist?(path)
|
56
|
+
contents = File.open(path, 'r:utf-8', &:read)
|
57
|
+
|
58
|
+
podfile = Pod::Config.instance.podfile
|
59
|
+
local_podfile = Podfile.from_file(path)
|
60
|
+
|
61
|
+
if local_podfile
|
62
|
+
local_pre_install_callback = nil
|
63
|
+
local_post_install_callback = nil
|
64
|
+
local_podfile.instance_eval do
|
65
|
+
local_pre_install_callback = @pre_install_callback
|
66
|
+
local_post_install_callback = @post_install_callback
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
podfile.instance_eval do
|
71
|
+
begin
|
72
|
+
|
73
|
+
if local_podfile.plugins.any?
|
74
|
+
hash_plugins = podfile.plugins || {}
|
75
|
+
hash_plugins = hash_plugins.merge(local_podfile.plugins)
|
76
|
+
set_hash_value(%w[plugins].first, hash_plugins)
|
77
|
+
|
78
|
+
podfile.set_use_source_pods(local_podfile.use_source_pods) if local_podfile.use_source_pods
|
79
|
+
podfile.use_binaries!(local_podfile.use_binaries?)
|
80
|
+
end
|
81
|
+
|
82
|
+
local_podfile&.target_definition_list&.each do |local_target|
|
83
|
+
next if local_target.name == 'Pods'
|
84
|
+
|
85
|
+
target_definition_list.each do |target|
|
86
|
+
|
87
|
+
unless target.name == local_target.name &&
|
88
|
+
(local_target.to_hash['dependencies'] &&local_target.to_hash['dependencies'].any?)
|
89
|
+
next
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
target.instance_exec do
|
95
|
+
|
96
|
+
local_dependencies = local_target.to_hash['dependencies']
|
97
|
+
target_dependencies = target.to_hash['dependencies']
|
98
|
+
|
99
|
+
local_dependencies.each do |local_dependency|
|
100
|
+
unless local_dependency.is_a?(Hash) && local_dependency.keys.first
|
101
|
+
next
|
102
|
+
end
|
103
|
+
|
104
|
+
target_dependencies.each do |target_dependency|
|
105
|
+
next unless target_dependency.is_a?(Hash) &&
|
106
|
+
target_dependency.keys.first &&
|
107
|
+
target_dependency.keys.first == local_dependency.keys.first
|
108
|
+
|
109
|
+
target_dependencies.delete target_dependency
|
110
|
+
break
|
111
|
+
end
|
112
|
+
end
|
113
|
+
local_dependencies.each do |d|
|
114
|
+
UI.message "Development Pod #{d.to_yaml}"
|
115
|
+
if podfile.plugins.keys.include?('cocoapods-tj')
|
116
|
+
podfile.set_use_source_pods(d.keys.first) if (d.is_a?(Hash) && d.keys.first)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
new_dependencies = target_dependencies + local_dependencies
|
120
|
+
set_hash_value(%w[dependencies].first, new_dependencies)
|
121
|
+
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
if local_pre_install_callback
|
128
|
+
@pre_install_callback = local_pre_install_callback
|
129
|
+
end
|
130
|
+
if local_post_install_callback
|
131
|
+
@post_install_callback = local_post_install_callback
|
132
|
+
end
|
133
|
+
rescue Exception => e
|
134
|
+
message = "Invalid `#{path}` file: #{e.message}"
|
135
|
+
raise Pod::DSLError.new(message, path, e, contents)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
|
2
|
+
require 'cocoapods-tj/command/bin/initHotKey'
|
3
|
+
require 'cocoapods-tj/command/bin/init'
|
4
|
+
require 'cocoapods-tj/command/bin/archive'
|
5
|
+
require 'cocoapods-tj/command/bin/auto'
|
6
|
+
require 'cocoapods-tj/command/bin/code'
|
7
|
+
require 'cocoapods-tj/command/bin/local'
|
8
|
+
require 'cocoapods-tj/command/bin/update'
|
9
|
+
require 'cocoapods-tj/command/bin/install'
|
10
|
+
require 'cocoapods-tj/command/bin/imy'
|
11
|
+
|
12
|
+
require 'cocoapods-tj/helpers'
|
13
|
+
|
14
|
+
module Pod
|
15
|
+
class Command
|
16
|
+
class Bin < Command
|
17
|
+
include CBin::SourcesHelper
|
18
|
+
include CBin::SpecFilesHelper
|
19
|
+
|
20
|
+
self.abstract_command = true
|
21
|
+
|
22
|
+
self.default_subcommand = 'open'
|
23
|
+
self.summary = '组件二进制化插件.'
|
24
|
+
self.description = <<-DESC
|
25
|
+
|
26
|
+
DESC
|
27
|
+
|
28
|
+
def initialize(argv)
|
29
|
+
require 'cocoapods-tj/native'
|
30
|
+
|
31
|
+
@help = argv.flag?('help')
|
32
|
+
super
|
33
|
+
end
|
34
|
+
|
35
|
+
def validate!
|
36
|
+
super
|
37
|
+
|
38
|
+
banner! if @help
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'cocoapods-tj/native/podfile'
|
3
|
+
require 'cocoapods-tj/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:songpanfei/spf_code_specs.git' },
|
16
|
+
'binary_repo_url' => { description: '二进制私有源 Git 地址', default: 'git@github.com:songpanfei/spf_bin_specs.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
|
+
elsif configuration_env == "debug_iphoneos"
|
28
|
+
file = config_debug_iphoneos_file
|
29
|
+
elsif configuration_env == "dev"
|
30
|
+
else
|
31
|
+
raise "\n===== #{configuration_env} 参数有误,请检查%w[dev debug_iphoneos release_iphoneos]===="
|
32
|
+
end
|
33
|
+
File.expand_path("#{Pod::Config.instance.installation_root}/#{file}")
|
34
|
+
end
|
35
|
+
|
36
|
+
def configuration_env
|
37
|
+
if @configuration_env == "dev" || @configuration_env == nil
|
38
|
+
if Pod::Config.instance.podfile
|
39
|
+
configuration_env ||= Pod::Config.instance.podfile.configuration_env
|
40
|
+
end
|
41
|
+
configuration_env ||= "dev"
|
42
|
+
@configuration_env = configuration_env
|
43
|
+
end
|
44
|
+
@configuration_env
|
45
|
+
end
|
46
|
+
|
47
|
+
def binary_upload_url
|
48
|
+
cut_string = "/%s/%s/zip"
|
49
|
+
binary_download_url[0,binary_download_url.length - cut_string.length]
|
50
|
+
end
|
51
|
+
|
52
|
+
def set_configuration_env(env)
|
53
|
+
@configuration_env = env
|
54
|
+
end
|
55
|
+
|
56
|
+
def config_debug_iphoneos_file
|
57
|
+
"bin_debug_iphoneos.yml"
|
58
|
+
end
|
59
|
+
|
60
|
+
def config_release_iphoneos_file
|
61
|
+
"bin_release_iphoneos.yml"
|
62
|
+
end
|
63
|
+
|
64
|
+
def config_dev_file
|
65
|
+
"bin.yml"
|
66
|
+
end
|
67
|
+
|
68
|
+
def sync_config(config)
|
69
|
+
File.open(config_file_with_configuration_env(config['configuration_env']), 'w+') do |f|
|
70
|
+
f.write(config.to_yaml)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def default_config
|
75
|
+
@default_config ||= Hash[template_hash.map { |k, v| [k, v[:default]] }]
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def load_config
|
81
|
+
if File.exist?(config_file)
|
82
|
+
YAML.load_file(config_file)
|
83
|
+
else
|
84
|
+
default_config
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def config
|
89
|
+
@config ||= begin
|
90
|
+
@config = OpenStruct.new load_config
|
91
|
+
validate!
|
92
|
+
@config
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def validate!
|
97
|
+
template_hash.each do |k, v|
|
98
|
+
selection = v[:selection]
|
99
|
+
next if !selection || selection.empty?
|
100
|
+
|
101
|
+
config_value = @config.send(k)
|
102
|
+
next unless config_value
|
103
|
+
unless selection.include?(config_value)
|
104
|
+
raise Pod::Informative, "#{k} 字段的值必须限定在可选值 [ #{selection.join(' / ')} ] 内".red
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def respond_to_missing?(method, include_private = false)
|
110
|
+
config.respond_to?(method) || super
|
111
|
+
end
|
112
|
+
|
113
|
+
def method_missing(method, *args, &block)
|
114
|
+
if config.respond_to?(method)
|
115
|
+
config.send(method, *args)
|
116
|
+
elsif template_hash.keys.include?(method.to_s)
|
117
|
+
raise Pod::Informative, "#{method} 字段必须在配置文件 #{config_file} 中设置, 请执行 init 命令配置或手动修改配置文件".red
|
118
|
+
else
|
119
|
+
super
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def self.config
|
125
|
+
@config ||= Config.new
|
126
|
+
end
|
127
|
+
|
128
|
+
|
129
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'cocoapods-tj/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
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
def done_message
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,201 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module CBin
|
4
|
+
class Config
|
5
|
+
class Builder
|
6
|
+
|
7
|
+
include Pod
|
8
|
+
|
9
|
+
def self.instance
|
10
|
+
@instance ||= new
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
load_build_config
|
15
|
+
# clean
|
16
|
+
end
|
17
|
+
|
18
|
+
# 加载配置项
|
19
|
+
def load_build_config
|
20
|
+
@white_pod_list = []
|
21
|
+
@ignore_git_list = []
|
22
|
+
project_root = Pod::Config.instance.project_root
|
23
|
+
path = File.join(project_root.to_s, 'BinArchive.json')
|
24
|
+
|
25
|
+
if File.exist?(path)
|
26
|
+
config = JSON.parse(File.read(path))
|
27
|
+
@white_pod_list = config['archive-white-pod-list']
|
28
|
+
UI.warn "====== archive-white-pod-list = #{@white_pod_list}" if @white_pod_list
|
29
|
+
@ignore_git_list = config['ignore-git-list']
|
30
|
+
UI.warn "====== ignore_git_list = #{@ignore_git_list}" if @ignore_git_list
|
31
|
+
@ignore_http_list = config['ignore-http-list']
|
32
|
+
|
33
|
+
@xcode_build_name = config['xcode_build_path']
|
34
|
+
@root_dir = config['root_dir'] unless config['root_dir'].nil?
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
def clean
|
40
|
+
#清除之前的缓存
|
41
|
+
FileUtils.rm_rf(Dir.glob("#{zip_dir}/*")) if File.exist?(zip_dir)
|
42
|
+
FileUtils.rm_rf(Dir.glob("#{binary_json_dir}/*")) if File.exist?(binary_json_dir)
|
43
|
+
FileUtils.rm_rf(Dir.glob("#{local_psec_dir}/*")) if File.exist?(local_psec_dir)
|
44
|
+
end
|
45
|
+
|
46
|
+
def gen_name
|
47
|
+
'bin-archive'
|
48
|
+
end
|
49
|
+
|
50
|
+
def gen_dir
|
51
|
+
@gen_dir ||= begin
|
52
|
+
dir = File.join(root_dir,gen_name)
|
53
|
+
Dir.mkdir(dir) unless File.exist?dir
|
54
|
+
Pathname.new(dir)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
def framework_name(spec)
|
60
|
+
"#{spec.name}.framework"
|
61
|
+
end
|
62
|
+
|
63
|
+
def framework_name_version(spec)
|
64
|
+
"#{spec.name}.framework_#{spec.version}"
|
65
|
+
end
|
66
|
+
|
67
|
+
def framework_zip_file(spec)
|
68
|
+
File.join(zip_dir_name, framework_name_version(spec))
|
69
|
+
end
|
70
|
+
|
71
|
+
def framework_file(spec)
|
72
|
+
File.join(zip_dir_name, framework_name(spec))
|
73
|
+
end
|
74
|
+
|
75
|
+
def library_name(spec)
|
76
|
+
library_name_version(spec.name, spec.version)
|
77
|
+
end
|
78
|
+
|
79
|
+
def library_name_version(name,version)
|
80
|
+
"bin_#{name}_#{version}"
|
81
|
+
end
|
82
|
+
def library_file(spec)
|
83
|
+
File.join(zip_dir_name, library_name(spec))
|
84
|
+
end
|
85
|
+
|
86
|
+
def zip_dir_name
|
87
|
+
"bin-zip"
|
88
|
+
end
|
89
|
+
|
90
|
+
def zip_dir
|
91
|
+
@zip_dir ||= begin
|
92
|
+
dir = File.join(root_dir,zip_dir_name)
|
93
|
+
Dir.mkdir(dir) unless File.exist?dir
|
94
|
+
Pathname.new(dir)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def local_spec_dir_name
|
99
|
+
"bin-spec"
|
100
|
+
end
|
101
|
+
|
102
|
+
def local_psec_dir
|
103
|
+
@local_psec_dir ||= begin
|
104
|
+
dir = File.join(root_dir,local_spec_dir_name)
|
105
|
+
Dir.mkdir(dir) unless File.exist?dir
|
106
|
+
Pathname.new(dir)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def binary_json_dir_name
|
111
|
+
"bin-json"
|
112
|
+
end
|
113
|
+
|
114
|
+
def binary_json_dir
|
115
|
+
@binary_json_dir ||= begin
|
116
|
+
dir = File.join(root_dir,binary_json_dir_name)
|
117
|
+
Dir.mkdir(dir) unless File.exist?dir
|
118
|
+
Pathname.new(dir)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
|
123
|
+
def target_name
|
124
|
+
@target_name ||= begin
|
125
|
+
target_name_str = Pod::Config.instance.podfile.root_target_definitions.first.children.first.to_s
|
126
|
+
target_name_str[5,target_name_str.length]
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def xcode_build_name
|
131
|
+
@xcode_build_name ||= begin
|
132
|
+
project_root = Pod::Config.instance.project_root
|
133
|
+
path = File.join(project_root.to_s, 'BinArchive.json')
|
134
|
+
|
135
|
+
if File.exist?(path)
|
136
|
+
config = JSON.parse(File.read(path))
|
137
|
+
@xcode_build_name = config['xcode_build_path']
|
138
|
+
end
|
139
|
+
if @xcode_build_name.nil? || Dir.exist?(@xcode_build_name)
|
140
|
+
@xcode_build_name = "xcode-build/Build/Intermediates.noindex/ArchiveIntermediates/#{target_name}/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/"
|
141
|
+
end
|
142
|
+
puts @xcode_build_name
|
143
|
+
@xcode_build_name
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
def xcode_build_dir
|
148
|
+
@xcode_build_dir ||= begin
|
149
|
+
temp_xcode_build_name = xcode_build_name
|
150
|
+
if File.exist?(temp_xcode_build_name)
|
151
|
+
Pathname.new(temp_xcode_build_name)
|
152
|
+
else
|
153
|
+
dir = File.join(root_dir,xcode_build_name)
|
154
|
+
Pathname.new(dir)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def xcode_BuildProductsPath_dir
|
160
|
+
@xcode_BuildProductsPath_dir ||= begin
|
161
|
+
temp_xcode_BuildProductsPath_dir = "xcode-build/Build/Intermediates.noindex/ArchiveIntermediates/#{target_name}/BuildProductsPath/"
|
162
|
+
full_path = File.join(root_dir, temp_xcode_BuildProductsPath_dir)
|
163
|
+
|
164
|
+
if (File.exist?(full_path))
|
165
|
+
Dir.chdir(full_path) do
|
166
|
+
iphoneos = Dir.glob('*-iphoneos')
|
167
|
+
if iphoneos.length > 0
|
168
|
+
full_path = File.join(full_path,iphoneos.first)
|
169
|
+
else
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
Pathname.new(full_path)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def root_dir
|
178
|
+
@root_dir ||= begin
|
179
|
+
basename = File.basename(Pod::Config.instance.installation_root)
|
180
|
+
parent_dir = File.dirname(Pod::Config.instance.installation_root)
|
181
|
+
root_name = File.join(parent_dir,"#{basename}-build-temp")
|
182
|
+
Dir.mkdir(root_name) unless File.exist?root_name
|
183
|
+
Pathname.new(root_name)
|
184
|
+
end
|
185
|
+
|
186
|
+
end
|
187
|
+
|
188
|
+
def white_pod_list
|
189
|
+
@white_pod_list
|
190
|
+
end
|
191
|
+
def ignore_git_list
|
192
|
+
@ignore_git_list
|
193
|
+
end
|
194
|
+
|
195
|
+
def ignore_http_list
|
196
|
+
@ignore_http_list
|
197
|
+
end
|
198
|
+
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'cocoapods-tj/native/podfile'
|
3
|
+
require 'cocoapods-tj/native/podfile_env'
|
4
|
+
require 'cocoapods/generate'
|
5
|
+
|
6
|
+
module CBin
|
7
|
+
class Config_Hot_Key
|
8
|
+
|
9
|
+
def config_file
|
10
|
+
config_file_with_hot_key_index(hot_key_index)
|
11
|
+
end
|
12
|
+
|
13
|
+
def template_hash
|
14
|
+
{
|
15
|
+
'hot_key_index' => { description: '快捷键', default: '1', selection: %w[1 2 3...] },
|
16
|
+
'hot_key_dir' => { description: '快捷键执行目录', default: '' },
|
17
|
+
'hot_key_cmd' => { description: '快捷键执行命令', default: 'pod bin update --no-repo-update' }
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
def config_file_with_hot_key_index(hot_key_index)
|
22
|
+
file = config_file_whith_hot_key_index(hot_key_index)
|
23
|
+
raise "\n===== #{hot_key_index} 参数有误,请检查%w[1 2 3...]===" unless (hot_key_index.to_i).is_a?(Integer)
|
24
|
+
File.expand_path("#{Pod::Config.instance.home_dir}/#{file}")
|
25
|
+
end
|
26
|
+
|
27
|
+
def hot_key_index
|
28
|
+
@hot_key_index = 1 if @hot_key_index.is_a?(NilClass)
|
29
|
+
@hot_key_index
|
30
|
+
end
|
31
|
+
|
32
|
+
def set_hot_key_index(hot_key_index)
|
33
|
+
@hot_key_index = hot_key_index
|
34
|
+
end
|
35
|
+
|
36
|
+
def config_file_whith_hot_key_index(hot_key_index)
|
37
|
+
"hot_key_#{hot_key_index}.yml"
|
38
|
+
end
|
39
|
+
|
40
|
+
def sync_config(config)
|
41
|
+
File.open(config_file_with_hot_key_index(config['hot_key_index']), 'w+') do |f|
|
42
|
+
f.write(config.to_yaml)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def default_config
|
47
|
+
@default_config ||= Hash[template_hash.map { |k, v| [k, v[:default]] }]
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def load_config
|
53
|
+
file = config_file
|
54
|
+
if (!file.nil?) && File.exist?(config_file)
|
55
|
+
YAML.load_file(config_file)
|
56
|
+
else
|
57
|
+
default_config
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def config
|
62
|
+
@config ||= begin
|
63
|
+
@config = OpenStruct.new load_config
|
64
|
+
validate!
|
65
|
+
@config
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def validate!
|
70
|
+
template_hash.each do |k, v|
|
71
|
+
selection = v[:selection]
|
72
|
+
next if !selection || selection.empty?
|
73
|
+
|
74
|
+
config_value = @config.send(k)
|
75
|
+
next unless config_value
|
76
|
+
unless selection.include?(config_value)
|
77
|
+
raise Pod::Informative, "#{k} 字段的值必须限定在可选值 [ #{selection.join(' / ')} ] 内".red
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def respond_to_missing?(method, include_private = false)
|
83
|
+
config.respond_to?(method) || super
|
84
|
+
end
|
85
|
+
|
86
|
+
def method_missing(method, *args, &block)
|
87
|
+
if config.respond_to?(method)
|
88
|
+
config.send(method, *args)
|
89
|
+
elsif template_hash.keys.include?(method.to_s)
|
90
|
+
raise Pod::Informative, "#{method} 字段必须在配置文件 #{config_file} 中设置, 请执行 init 命令配置或手动修改配置文件".red
|
91
|
+
else
|
92
|
+
super
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.config_hot_key
|
98
|
+
@config_hot_key ||= Config_Hot_Key.new
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|