cocoapods-imy-hycan-bin 0.1.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 +22 -0
- data/README.md +44 -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 +61 -0
- data/lib/cocoapods-imy-bin/command/bin/archive.rb +229 -0
- data/lib/cocoapods-imy-bin/command/bin/auto.rb +199 -0
- data/lib/cocoapods-imy-bin/command/bin/code.rb +479 -0
- data/lib/cocoapods-imy-bin/command/bin/dup.rb +78 -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 +48 -0
- data/lib/cocoapods-imy-bin/command/bin/lib/lint.rb +69 -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 +154 -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 +216 -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 +5 -0
- data/lib/cocoapods-imy-bin/helpers/Info.plist +0 -0
- data/lib/cocoapods-imy-bin/helpers/build_helper.rb +158 -0
- data/lib/cocoapods-imy-bin/helpers/build_utils.rb +63 -0
- data/lib/cocoapods-imy-bin/helpers/framework.rb +85 -0
- data/lib/cocoapods-imy-bin/helpers/framework_builder.rb +444 -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/sources_helper.rb +36 -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 +228 -0
- data/lib/cocoapods-imy-bin/helpers/upload_helper.rb +89 -0
- data/lib/cocoapods-imy-bin/native.rb +23 -0
- data/lib/cocoapods-imy-bin/native/acknowledgements.rb +27 -0
- data/lib/cocoapods-imy-bin/native/analyzer.rb +55 -0
- data/lib/cocoapods-imy-bin/native/file_accessor.rb +28 -0
- data/lib/cocoapods-imy-bin/native/installation_options.rb +25 -0
- data/lib/cocoapods-imy-bin/native/installer.rb +135 -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/pod_target_installer.rb +94 -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 +199 -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/target_validator.rb +41 -0
- data/lib/cocoapods-imy-bin/native/validator.rb +40 -0
- data/lib/cocoapods-imy-bin/source_provider_hook.rb +66 -0
- data/lib/cocoapods/imy/hycan/bin.rb +12 -0
- data/lib/cocoapods/imy/hycan/bin/version.rb +9 -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
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b3bb7c27a7e29c6ab1b4feb4645f51cee49f736c76df95a1eac32f6a33e7f401
|
4
|
+
data.tar.gz: 7cf3f437e11e0226d32cb8e28a318567a894156de74b055e357f40115ea05daf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 44451c572c0fb9b1825c0ec82bb6c792b21641fb219cc8baa561e5fc6ddf544d8343ad73cc358744fc81e6fa109092017649b2d62b45ae43ba569ee764ce6703
|
7
|
+
data.tar.gz: 8be1fb1c21419c1f45327bec68e27145a8dab6e425d7f41c9692e158fc465286d39c2a9217f672aadbce1b31dfd957cac316970c9b2f2b8e9042745d916d415b
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2018 tripleCC <triplec.linux@gmail.com>
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# Cocoapods::Imy::Hycan::Bin
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/cocoapods/imy/hycan/bin`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'cocoapods-imy-hycan-bin'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install cocoapods-imy-hycan-bin
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/cocoapods-imy-hycan-bin. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/cocoapods-imy-hycan-bin/blob/master/CODE_OF_CONDUCT.md).
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
41
|
+
|
42
|
+
## Code of Conduct
|
43
|
+
|
44
|
+
Everyone interacting in the Cocoapods::Imy::Hycan::Bin project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/cocoapods-imy-hycan-bin/blob/master/CODE_OF_CONDUCT.md).
|
@@ -0,0 +1,61 @@
|
|
1
|
+
|
2
|
+
require 'cocoapods-imy-bin/command/bin/initHotKey'
|
3
|
+
require 'cocoapods-imy-bin/command/bin/init'
|
4
|
+
require 'cocoapods-imy-bin/command/bin/archive'
|
5
|
+
require 'cocoapods-imy-bin/command/bin/auto'
|
6
|
+
require 'cocoapods-imy-bin/command/bin/code'
|
7
|
+
require 'cocoapods-imy-bin/command/bin/update'
|
8
|
+
require 'cocoapods-imy-bin/command/bin/install'
|
9
|
+
require 'cocoapods-imy-bin/command/bin/imy'
|
10
|
+
|
11
|
+
require 'cocoapods-imy-bin/command/bin/spec/create'
|
12
|
+
|
13
|
+
require 'cocoapods-imy-bin/helpers'
|
14
|
+
|
15
|
+
module Pod
|
16
|
+
class Command
|
17
|
+
# This is an example of a cocoapods plugin adding a top-level subcommand
|
18
|
+
# to the 'pod' command.
|
19
|
+
#
|
20
|
+
# You can also create subcommands of existing or new commands. Say you
|
21
|
+
# wanted to add a subcommand to `list` to show newly deprecated pods,
|
22
|
+
# (e.g. `pod list deprecated`), there are a few things that would need
|
23
|
+
# to change.
|
24
|
+
#
|
25
|
+
# - move this file to `lib/pod/command/list/deprecated.rb` and update
|
26
|
+
# the class to exist in the the Pod::Command::List namespace
|
27
|
+
# - change this class to extend from `List` instead of `Command`. This
|
28
|
+
# tells the plugin system that it is a subcommand of `list`.
|
29
|
+
# - edit `lib/cocoapods_plugins.rb` to require this file
|
30
|
+
#
|
31
|
+
# @todo Create a PR to add your plugin to CocoaPods/cocoapods.org
|
32
|
+
# in the `plugins.json` file, once your plugin is released.
|
33
|
+
#
|
34
|
+
class Bin < Command
|
35
|
+
include CBin::SourcesHelper
|
36
|
+
include CBin::SpecFilesHelper
|
37
|
+
|
38
|
+
self.abstract_command = true
|
39
|
+
|
40
|
+
self.default_subcommand = 'open'
|
41
|
+
self.summary = '组件二进制化插件.'
|
42
|
+
self.description = <<-DESC
|
43
|
+
组件二进制化插件。利用源码私有源与二进制私有源实现对组件依赖类型的切换。
|
44
|
+
DESC
|
45
|
+
|
46
|
+
def initialize(argv)
|
47
|
+
require 'cocoapods-imy-bin/native'
|
48
|
+
|
49
|
+
@help = argv.flag?('help')
|
50
|
+
super
|
51
|
+
end
|
52
|
+
|
53
|
+
def validate!
|
54
|
+
super
|
55
|
+
# 这里由于 --help 是在 validate! 方法中提取的,会导致 --help 失效
|
56
|
+
# pod lib create 也有这个问题
|
57
|
+
banner! if @help
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,229 @@
|
|
1
|
+
require 'cocoapods-imy-bin/native/podfile'
|
2
|
+
require 'cocoapods/command/gen'
|
3
|
+
require 'cocoapods/generate'
|
4
|
+
require 'cocoapods-imy-bin/helpers/framework_builder'
|
5
|
+
require 'cocoapods-imy-bin/helpers/library_builder'
|
6
|
+
require 'cocoapods-imy-bin/helpers/build_helper'
|
7
|
+
require 'cocoapods-imy-bin/helpers/spec_source_creator'
|
8
|
+
require 'cocoapods-imy-bin/config/config_builder'
|
9
|
+
require 'cocoapods-imy-bin/command/bin/lib/lint'
|
10
|
+
require 'xcodeproj'
|
11
|
+
|
12
|
+
module Pod
|
13
|
+
class Command
|
14
|
+
class Bin < Command
|
15
|
+
class Archive < Bin
|
16
|
+
|
17
|
+
@@missing_binary_specs = []
|
18
|
+
|
19
|
+
self.summary = '将组件归档为静态库 .a.'
|
20
|
+
self.description = <<-DESC
|
21
|
+
将组件归档为静态库 framework,仅支持 iOS 平台
|
22
|
+
此静态 framework 不包含依赖组件的 symbol
|
23
|
+
DESC
|
24
|
+
|
25
|
+
def self.options
|
26
|
+
[
|
27
|
+
['--all-make', '对该组件的依赖库,全部制作为二进制组件'],
|
28
|
+
['--code-dependencies', '使用源码依赖'],
|
29
|
+
['--no-clean', '保留构建中间产物'],
|
30
|
+
['--sources', '私有源地址,多个用分号区分'],
|
31
|
+
['--framework-output', '输出framework文件'],
|
32
|
+
['--no-zip', '不压缩静态库 为 zip'],
|
33
|
+
['--configuration', 'Build the specified configuration (e.g. Debug). Defaults to Release'],
|
34
|
+
['--env', "该组件上传的环境 %w[dev debug_iphoneos release_iphoneos]"]
|
35
|
+
].concat(Pod::Command::Gen.options).concat(super).uniq
|
36
|
+
end
|
37
|
+
|
38
|
+
self.arguments = [
|
39
|
+
CLAide::Argument.new('NAME.podspec', false)
|
40
|
+
]
|
41
|
+
|
42
|
+
def initialize(argv)
|
43
|
+
@env = argv.option('env') || 'dev'
|
44
|
+
CBin.config.set_configuration_env(@env)
|
45
|
+
UI.warn "====== cocoapods-imy-bin #{CBin::VERSION} 版本 ======== \n "
|
46
|
+
UI.warn "====== #{@env} 环境 ======== \n "
|
47
|
+
|
48
|
+
@code_dependencies = argv.flag?('code-dependencies')
|
49
|
+
@framework_output = argv.flag?('framework-output', false )
|
50
|
+
@clean = argv.flag?('no-clean', false)
|
51
|
+
@zip = argv.flag?('zip', true)
|
52
|
+
@all_make = argv.flag?('all-make', false )
|
53
|
+
@sources = argv.option('sources') || []
|
54
|
+
@platform = Platform.new(:ios)
|
55
|
+
|
56
|
+
@config = argv.option('configuration', 'Release')
|
57
|
+
|
58
|
+
@framework_path
|
59
|
+
super
|
60
|
+
|
61
|
+
@additional_args = argv.remainder!
|
62
|
+
@build_finshed = false
|
63
|
+
end
|
64
|
+
|
65
|
+
def run
|
66
|
+
# 清除之前的缓存
|
67
|
+
CBin::Config::Builder.instance.clean
|
68
|
+
|
69
|
+
@spec = Specification.from_file(spec_file)
|
70
|
+
generate_project
|
71
|
+
|
72
|
+
swift_pods_buildsetting
|
73
|
+
|
74
|
+
build_root_spec
|
75
|
+
|
76
|
+
sources_sepc = Array.new
|
77
|
+
sources_sepc << @spec
|
78
|
+
sources_sepc.concat(build_dependencies) if @all_make
|
79
|
+
|
80
|
+
sources_sepc
|
81
|
+
end
|
82
|
+
|
83
|
+
def build_root_spec
|
84
|
+
builder = CBin::Build::Helper.new(@spec,
|
85
|
+
@platform,
|
86
|
+
@framework_output,
|
87
|
+
@zip,
|
88
|
+
@spec,
|
89
|
+
CBin::Config::Builder.instance.white_pod_list.include?(@spec.name),
|
90
|
+
@config)
|
91
|
+
builder.build
|
92
|
+
builder.clean_workspace if @clean && !@all_make
|
93
|
+
end
|
94
|
+
|
95
|
+
def build_dependencies
|
96
|
+
@build_finshed = true
|
97
|
+
#如果没要求,就清空依赖库数据
|
98
|
+
sources_sepc = []
|
99
|
+
@@missing_binary_specs.uniq.each do |spec|
|
100
|
+
next if spec.name.include?('/')
|
101
|
+
next if spec.name == @spec.name
|
102
|
+
#过滤白名单
|
103
|
+
next if CBin::Config::Builder.instance.white_pod_list.include?(spec.name)
|
104
|
+
#过滤 git
|
105
|
+
if spec.source[:git] && spec.source[:git]
|
106
|
+
spec_git = spec.source[:git]
|
107
|
+
spec_git_res = false
|
108
|
+
CBin::Config::Builder.instance.ignore_git_list.each do |ignore_git|
|
109
|
+
spec_git_res = spec_git.include?(ignore_git)
|
110
|
+
break if spec_git_res
|
111
|
+
end
|
112
|
+
next if spec_git_res
|
113
|
+
end
|
114
|
+
UI.warn "#{spec.name}.podspec 带有 vendored_frameworks 字段,请检查是否有效!!!" if spec.attributes_hash['vendored_frameworks']
|
115
|
+
next if spec.attributes_hash['vendored_frameworks'] && @spec.name != spec.name #过滤带有vendored_frameworks的
|
116
|
+
next if spec.attributes_hash['ios.vendored_frameworks'] && @spec.name != spec.name #过滤带有vendored_frameworks的
|
117
|
+
#获取没有制作二进制版本的spec集合
|
118
|
+
sources_sepc << spec
|
119
|
+
end
|
120
|
+
|
121
|
+
fail_build_specs = []
|
122
|
+
sources_sepc.uniq.each do |spec|
|
123
|
+
begin
|
124
|
+
builder = CBin::Build::Helper.new(spec,
|
125
|
+
@platform,
|
126
|
+
@framework_output,
|
127
|
+
@zip,
|
128
|
+
@spec,
|
129
|
+
false ,
|
130
|
+
@config)
|
131
|
+
builder.build
|
132
|
+
rescue Object => exception
|
133
|
+
UI.puts exception
|
134
|
+
fail_build_specs << spec
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
if fail_build_specs.any?
|
139
|
+
fail_build_specs.uniq.each do |spec|
|
140
|
+
UI.warn "【#{spec.name} | #{spec.version}】组件二进制版本编译失败 ."
|
141
|
+
end
|
142
|
+
end
|
143
|
+
sources_sepc - fail_build_specs
|
144
|
+
end
|
145
|
+
|
146
|
+
# 解析器传过来的
|
147
|
+
def Archive.missing_binary_specs(missing_binary_specs)
|
148
|
+
@@missing_binary_specs = missing_binary_specs unless @build_finshed
|
149
|
+
end
|
150
|
+
|
151
|
+
private
|
152
|
+
|
153
|
+
def generate_project
|
154
|
+
Podfile.execute_with_bin_plugin do
|
155
|
+
Podfile.execute_with_use_binaries(!@code_dependencies) do
|
156
|
+
argvs = [
|
157
|
+
"--sources=#{sources_option(@code_dependencies, @sources)}",
|
158
|
+
"--gen-directory=#{CBin::Config::Builder.instance.gen_dir}",
|
159
|
+
'--clean',
|
160
|
+
"--verbose",
|
161
|
+
*@additional_args
|
162
|
+
]
|
163
|
+
|
164
|
+
if File.exist?(Pod::Config.instance.podfile_path)
|
165
|
+
argvs += ['--use-podfile']
|
166
|
+
end
|
167
|
+
|
168
|
+
unless CBin::Build::Utils.uses_frameworks?
|
169
|
+
argvs += ['--use-libraries']
|
170
|
+
end
|
171
|
+
|
172
|
+
argvs << spec_file if spec_file
|
173
|
+
|
174
|
+
gen = Pod::Command::Gen.new(CLAide::ARGV.new(argvs))
|
175
|
+
gen.validate!
|
176
|
+
gen.run
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
def swift_pods_buildsetting
|
182
|
+
# swift_project_link_header
|
183
|
+
worksppace_path = File.expand_path("#{CBin::Config::Builder.instance.gen_dir}/#{@spec.name}")
|
184
|
+
path = File.join(worksppace_path, "Pods.xcodeproj")
|
185
|
+
path = File.join(worksppace_path, "Pods/Pods.xcodeproj") unless File.exist?(path)
|
186
|
+
raise Informative, "#{path} File no exist, please check" unless File.exist?(path)
|
187
|
+
project = Xcodeproj::Project.open(path)
|
188
|
+
project.build_configurations.each do |x|
|
189
|
+
x.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = true #设置生成swift inter
|
190
|
+
end
|
191
|
+
project.save
|
192
|
+
end
|
193
|
+
|
194
|
+
# def swift_project_link_header
|
195
|
+
# worksppace_path = Pod::Config.instance.installation_root
|
196
|
+
# Dir.chdir(worksppace_path) do
|
197
|
+
# shell_script = <<-'SH'.strip_heredoc
|
198
|
+
# ditto "${DERIVED_SOURCES_DIR}/${PRODUCT_MODULE_NAME}-Swift.h" "${CBin::Config::Builder.instance.gen_dir}"
|
199
|
+
# SH
|
200
|
+
# shell_script
|
201
|
+
#
|
202
|
+
# # project = Xcodeproj::Project.open(Dir.glob('*.xcodeproj').first)
|
203
|
+
# # project.build_configurations.each do |x|
|
204
|
+
# # x.build_settings['DERIVED_SOURCES_DIR']
|
205
|
+
# # end
|
206
|
+
# end
|
207
|
+
# end
|
208
|
+
|
209
|
+
def spec_file
|
210
|
+
@spec_file ||= begin
|
211
|
+
if @podspec
|
212
|
+
find_spec_file(@podspec)
|
213
|
+
else
|
214
|
+
if code_spec_files.empty?
|
215
|
+
raise Informative, '当前目录下没有找到可用源码 podspec.'
|
216
|
+
end
|
217
|
+
|
218
|
+
spec_file = code_spec_files.first
|
219
|
+
spec_file
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
@@ -0,0 +1,199 @@
|
|
1
|
+
|
2
|
+
require 'cocoapods-imy-bin/command/bin/auto'
|
3
|
+
require 'cocoapods-imy-bin/helpers/upload_helper'
|
4
|
+
|
5
|
+
module Pod
|
6
|
+
class Command
|
7
|
+
class Bin < Command
|
8
|
+
class Auto < Bin
|
9
|
+
self.summary = '打开 workspace 工程.'
|
10
|
+
|
11
|
+
self.arguments = [
|
12
|
+
CLAide::Argument.new('NAME.podspec', false)
|
13
|
+
]
|
14
|
+
def self.options
|
15
|
+
[
|
16
|
+
['--code-dependencies', '使用源码依赖'],
|
17
|
+
['--allow-prerelease', '允许使用 prerelease 的版本'],
|
18
|
+
['--no-clean', '保留构建中间产物'],
|
19
|
+
['--framework-output', '输出framework文件'],
|
20
|
+
['--no-zip', '不压缩静态 framework 为 zip'],
|
21
|
+
['--all-make', '对该组件的依赖库,全部制作为二进制组件'],
|
22
|
+
['--configuration', 'Build the specified configuration (e.g. Release ). Defaults to Debug'],
|
23
|
+
['--env', "该组件上传的环境 %w[dev debug_iphoneos release_iphoneos]"]
|
24
|
+
].concat(Pod::Command::Gen.options).concat(super).uniq
|
25
|
+
end
|
26
|
+
|
27
|
+
def initialize(argv)
|
28
|
+
|
29
|
+
@env = argv.option('env') || 'dev'
|
30
|
+
CBin.config.set_configuration_env(@env)
|
31
|
+
|
32
|
+
@podspec = argv.shift_argument || find_podspec
|
33
|
+
@specification = Specification.from_file(@podspec)
|
34
|
+
|
35
|
+
@code_dependencies = argv.flag?('code-dependencies')
|
36
|
+
@allow_prerelease = argv.flag?('allow-prerelease')
|
37
|
+
@framework_output = argv.flag?('framework-output', false )
|
38
|
+
@clean = argv.flag?('clean', true)
|
39
|
+
@zip = argv.flag?('zip', true)
|
40
|
+
@all_make = argv.flag?('all-make', false )
|
41
|
+
@verbose = argv.flag?('verbose',true)
|
42
|
+
|
43
|
+
@config = argv.option('configuration', 'Debug')
|
44
|
+
@additional_args = argv.remainder!
|
45
|
+
|
46
|
+
super
|
47
|
+
end
|
48
|
+
|
49
|
+
def validate!
|
50
|
+
help! "未找到 podspec文件" unless @podspec
|
51
|
+
super
|
52
|
+
end
|
53
|
+
|
54
|
+
def run
|
55
|
+
@specification = Specification.from_file(@podspec)
|
56
|
+
|
57
|
+
sources_sepc = run_archive
|
58
|
+
|
59
|
+
fail_push_specs = []
|
60
|
+
sources_sepc.uniq.each do |spec|
|
61
|
+
begin
|
62
|
+
fail_push_specs << spec unless CBin::Upload::Helper.new(spec,@code_dependencies,@sources).upload
|
63
|
+
rescue Object => exception
|
64
|
+
UI.puts exception
|
65
|
+
fail_push_specs << spec
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
if fail_push_specs.any?
|
70
|
+
fail_push_specs.uniq.each do |spec|
|
71
|
+
UI.warn "【#{spec.name} | #{spec.version}】组件spec push失败 ."
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
success_specs = sources_sepc - fail_push_specs
|
76
|
+
if success_specs.any?
|
77
|
+
auto_success = ""
|
78
|
+
success_specs.uniq.each do |spec|
|
79
|
+
auto_success += "#{spec.name} | #{spec.version}\n"
|
80
|
+
UI.warn "===【 #{spec.name} | #{spec.version} 】二进制组件制作完成 !!! "
|
81
|
+
end
|
82
|
+
puts "============== auto_success"
|
83
|
+
puts auto_success
|
84
|
+
ENV['auto_success'] = auto_success
|
85
|
+
end
|
86
|
+
#pod repo update
|
87
|
+
UI.section("\nUpdating Spec Repositories\n".yellow) do
|
88
|
+
Pod::Command::Bin::Repo::Update.new(CLAide::ARGV.new([])).run
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
#制作二进制包
|
94
|
+
|
95
|
+
def run_archive
|
96
|
+
argvs = [
|
97
|
+
"--sources=#{sources_option(@code_dependencies, @sources)},https:\/\/cdn.cocoapods.org",
|
98
|
+
@additional_args
|
99
|
+
]
|
100
|
+
|
101
|
+
argvs << spec_file if spec_file
|
102
|
+
argvs.delete(Array.new)
|
103
|
+
|
104
|
+
unless @clean
|
105
|
+
argvs += ['--no-clean']
|
106
|
+
end
|
107
|
+
if @code_dependencies
|
108
|
+
argvs += ['--code-dependencies']
|
109
|
+
end
|
110
|
+
if @verbose
|
111
|
+
argvs += ['--verbose']
|
112
|
+
end
|
113
|
+
if @allow_prerelease
|
114
|
+
argvs += ['--allow-prerelease']
|
115
|
+
end
|
116
|
+
if @framework_output
|
117
|
+
argvs += ['--framework-output']
|
118
|
+
end
|
119
|
+
if @all_make
|
120
|
+
argvs += ['--all-make']
|
121
|
+
end
|
122
|
+
if @env
|
123
|
+
argvs += ["--env=#{@env}"]
|
124
|
+
end
|
125
|
+
argvs += ["--configuration=#{@config}"]
|
126
|
+
|
127
|
+
archive = Pod::Command::Bin::Archive.new(CLAide::ARGV.new(argvs))
|
128
|
+
archive.validate!
|
129
|
+
sources_sepc = archive.run
|
130
|
+
sources_sepc
|
131
|
+
end
|
132
|
+
|
133
|
+
|
134
|
+
def code_podsepc_extname
|
135
|
+
'.podsepc'
|
136
|
+
end
|
137
|
+
|
138
|
+
def binary_podsepc_json
|
139
|
+
"#{@specification.name}.binary.podspec.json"
|
140
|
+
end
|
141
|
+
|
142
|
+
def binary_template_podsepc
|
143
|
+
"#{@specification.name}.binary-template.podspec"
|
144
|
+
end
|
145
|
+
|
146
|
+
def template_spec_file
|
147
|
+
@template_spec_file ||= begin
|
148
|
+
if @template_podspec
|
149
|
+
find_spec_file(@template_podspec)
|
150
|
+
else
|
151
|
+
binary_template_spec_file
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def spec_file
|
157
|
+
@spec_file ||= begin
|
158
|
+
if @podspec
|
159
|
+
find_spec_file(@podspec) || @podspec
|
160
|
+
else
|
161
|
+
if code_spec_files.empty?
|
162
|
+
raise Informative, '当前目录下没有找到可用源码 podspec.'
|
163
|
+
end
|
164
|
+
|
165
|
+
spec_file = if @binary
|
166
|
+
code_spec = Pod::Specification.from_file(code_spec_files.first)
|
167
|
+
if template_spec_file
|
168
|
+
template_spec = Pod::Specification.from_file(template_spec_file)
|
169
|
+
end
|
170
|
+
create_binary_spec_file(code_spec, template_spec)
|
171
|
+
else
|
172
|
+
code_spec_files.first
|
173
|
+
end
|
174
|
+
spec_file
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
#Dir.glob 可替代
|
180
|
+
def find_podspec
|
181
|
+
name = nil
|
182
|
+
Pathname.pwd.children.each do |child|
|
183
|
+
puts child
|
184
|
+
if File.file?(child)
|
185
|
+
if child.extname == '.podspec'
|
186
|
+
name = File.basename(child)
|
187
|
+
unless name.include?("binary-template")
|
188
|
+
return name
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
return name
|
194
|
+
end
|
195
|
+
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|