cocoapods-bb-bin 0.1.0
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 +19 -0
- data/README.md +68 -0
- data/lib/cocoapods-bb-bin/command/bin/archive.rb +234 -0
- data/lib/cocoapods-bb-bin/command/bin/auto.rb +226 -0
- data/lib/cocoapods-bb-bin/command/bin/code.rb +295 -0
- data/lib/cocoapods-bb-bin/command/bin/dup.rb +78 -0
- data/lib/cocoapods-bb-bin/command/bin/imy.rb +46 -0
- data/lib/cocoapods-bb-bin/command/bin/init.rb +69 -0
- data/lib/cocoapods-bb-bin/command/bin/initHotKey.rb +70 -0
- data/lib/cocoapods-bb-bin/command/bin/install.rb +44 -0
- data/lib/cocoapods-bb-bin/command/bin/lib/lint.rb +69 -0
- data/lib/cocoapods-bb-bin/command/bin/repo/update.rb +43 -0
- data/lib/cocoapods-bb-bin/command/bin/spec/create.rb +73 -0
- data/lib/cocoapods-bb-bin/command/bin/spec/push.rb +114 -0
- data/lib/cocoapods-bb-bin/command/bin/update.rb +154 -0
- data/lib/cocoapods-bb-bin/command/bin.rb +59 -0
- data/lib/cocoapods-bb-bin/command.rb +2 -0
- data/lib/cocoapods-bb-bin/config/config.rb +136 -0
- data/lib/cocoapods-bb-bin/config/config_asker.rb +57 -0
- data/lib/cocoapods-bb-bin/config/config_builder.rb +234 -0
- data/lib/cocoapods-bb-bin/config/config_hot_key.rb +102 -0
- data/lib/cocoapods-bb-bin/config/config_hot_key_asker.rb +57 -0
- data/lib/cocoapods-bb-bin/gem_version.rb +10 -0
- data/lib/cocoapods-bb-bin/helpers/Info.plist +0 -0
- data/lib/cocoapods-bb-bin/helpers/build_helper.rb +217 -0
- data/lib/cocoapods-bb-bin/helpers/build_utils.rb +63 -0
- data/lib/cocoapods-bb-bin/helpers/framework.rb +85 -0
- data/lib/cocoapods-bb-bin/helpers/framework_builder.rb +446 -0
- data/lib/cocoapods-bb-bin/helpers/library.rb +54 -0
- data/lib/cocoapods-bb-bin/helpers/library_builder.rb +90 -0
- data/lib/cocoapods-bb-bin/helpers/sources_helper.rb +36 -0
- data/lib/cocoapods-bb-bin/helpers/spec_creator.rb +170 -0
- data/lib/cocoapods-bb-bin/helpers/spec_files_helper.rb +77 -0
- data/lib/cocoapods-bb-bin/helpers/spec_source_creator.rb +227 -0
- data/lib/cocoapods-bb-bin/helpers/upload_helper.rb +96 -0
- data/lib/cocoapods-bb-bin/helpers/xcframework_builder.rb +77 -0
- data/lib/cocoapods-bb-bin/helpers.rb +5 -0
- data/lib/cocoapods-bb-bin/native/acknowledgements.rb +27 -0
- data/lib/cocoapods-bb-bin/native/analyzer.rb +55 -0
- data/lib/cocoapods-bb-bin/native/file_accessor.rb +28 -0
- data/lib/cocoapods-bb-bin/native/installation_options.rb +25 -0
- data/lib/cocoapods-bb-bin/native/installer.rb +135 -0
- data/lib/cocoapods-bb-bin/native/linter.rb +26 -0
- data/lib/cocoapods-bb-bin/native/path_source.rb +33 -0
- data/lib/cocoapods-bb-bin/native/pod_source_installer.rb +19 -0
- data/lib/cocoapods-bb-bin/native/pod_target_installer.rb +94 -0
- data/lib/cocoapods-bb-bin/native/podfile.rb +91 -0
- data/lib/cocoapods-bb-bin/native/podfile_env.rb +37 -0
- data/lib/cocoapods-bb-bin/native/podfile_generator.rb +199 -0
- data/lib/cocoapods-bb-bin/native/podspec_finder.rb +25 -0
- data/lib/cocoapods-bb-bin/native/resolver.rb +230 -0
- data/lib/cocoapods-bb-bin/native/sandbox_analyzer.rb +34 -0
- data/lib/cocoapods-bb-bin/native/source.rb +35 -0
- data/lib/cocoapods-bb-bin/native/sources_manager.rb +20 -0
- data/lib/cocoapods-bb-bin/native/specification.rb +31 -0
- data/lib/cocoapods-bb-bin/native/target_validator.rb +41 -0
- data/lib/cocoapods-bb-bin/native/validator.rb +40 -0
- data/lib/cocoapods-bb-bin/native.rb +23 -0
- data/lib/cocoapods-bb-bin/source_provider_hook.rb +66 -0
- data/lib/cocoapods-bb-bin.rb +2 -0
- data/lib/cocoapods_plugin.rb +3 -0
- data/spec/command/bin_spec.rb +12 -0
- data/spec/spec_helper.rb +51 -0
- metadata +200 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b30a04e912b87aa25398b4560ff1fdae7c03592486dc8dabb09dee1af0e0b8ca
|
4
|
+
data.tar.gz: 7b95c7b683c05776c6daab5fc46289a4f1922c0c09c39662b1c21e5257f44353
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 320fff33dc1ed13e1c557818cbf751db6343de672dcb679eeabc1b68ed9e014035170024816ad3edf23776ba9de80d9ce0fe98c89fce4aa3c44821460f6a7d8b
|
7
|
+
data.tar.gz: 3746950eff6456298216505a3a3ee0d59560dcd1153a1f6e507ea0cf90eb406785ec14cbde344208593998f4c822ab3defa8eec8db084e1e64336cbf7c7e2a60
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2021 humin <humin1102@126.com>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
# cocoapods-bb-bin
|
4
|
+
|
5
|
+
- 你是不是发现 `Xcode13` 更新后编译速度越来越慢?
|
6
|
+
- 你是不是发现 `OC`/`Swift` 混编越来越慢?
|
7
|
+
- 你是不是发现 `源码`/`二进制` 调试起来非常麻烦?
|
8
|
+
- 那你不妨试试我们这个插件~,美滋滋哦~
|
9
|
+
本插件可以帮助开发者快速的构建二进制方案,便可提升10倍以上编译速度。
|
10
|
+
|
11
|
+
|
12
|
+
## 特色
|
13
|
+
|
14
|
+
1. **无入侵、无感知、不影响现有业务,不影响现有代码框架、完全绿色产品~**
|
15
|
+
2. **轻量级,只要项目能编译通过就能使用,无视组件化、无视耦合**
|
16
|
+
3. **完全自动化,一键使用、无需手动操作**
|
17
|
+
4. **一步步教你使用,新手也能欢乐玩转**
|
18
|
+
5. **提供几个特色服务**
|
19
|
+
6. **支持 使用与不使用 use_frameworks!**
|
20
|
+
7. **少数支持swift项目二进制化编译的开源项目之一**
|
21
|
+
8. 静态库支持.a、.framework、.xcframework
|
22
|
+
|
23
|
+
|
24
|
+
关于 插件具体的架构部署实践和更详细的资源,可以参考
|
25
|
+
|
26
|
+
> [iOS编译速度如何稳定提高10倍以上](https://juejin.cn/post/6903407900006449160)
|
27
|
+
>
|
28
|
+
> [iOS美团同款"ZSource"二进制调试实现](https://juejin.im/post/5f066cfa5188252e893a136e)
|
29
|
+
>
|
30
|
+
> [iOS教你如何像RN一样实时编译](https://juejin.im/post/6850037272415813645)
|
31
|
+
>
|
32
|
+
> [Swift编译慢?请看这里,全套开源](https://juejin.im/post/6890419459639476237)
|
33
|
+
>
|
34
|
+
> [OC-Demo](https://github.com/su350380433/cocoapods-imy-bin-demo)
|
35
|
+
>
|
36
|
+
> [Swift-OC-Demo](https://github.com/su350380433/Swift-OC-Demo)
|
37
|
+
|
38
|
+
|
39
|
+
</br>
|
40
|
+
|
41
|
+
## Installation
|
42
|
+
|
43
|
+
$ gem install cocoapods-bb-bin
|
44
|
+
|
45
|
+
> ruby 3.x版本暂时不支持(plugin:cocoapods-generate)
|
46
|
+
|
47
|
+
## Usage
|
48
|
+
$ pod bin auto [NAME.podspec] # 根据use_frameworks判断生成.a还是.framework
|
49
|
+
$ pod bin auto [NAME.podspec] --framework-output # 生成framework文件
|
50
|
+
$ pod bin auto [NAME.podspec] --xcframework-output # 生成xcframework文件
|
51
|
+
更多请看
|
52
|
+
$pod bin auto --help
|
53
|
+
|
54
|
+
## 更新记录
|
55
|
+
|
56
|
+
- 2021-10-15
|
57
|
+
|
58
|
+
v0.1.0 支持纯Swift、纯Object-C、Swift-OC混编
|
59
|
+
|
60
|
+
## 感谢
|
61
|
+
|
62
|
+
**[cocoapods-bin](https://github.com/tripleCC/cocoapods-bin)**
|
63
|
+
|
64
|
+
**[cocoapods-imy-bin](https://github.com/MeetYouDevs/cocoapods-imy-bin)**
|
65
|
+
|
66
|
+
[美团 iOS 工程 zsource 命令背后的那些事儿](https://tech.meituan.com/2019/08/08/the-things-behind-the-ios-project-zsource-command.html)
|
67
|
+
|
68
|
+
#### 您有什么更好的想法,可以提出来,我们一起来实现,共创一个强大的工具平台,同时也欢迎给我们提PR。
|
@@ -0,0 +1,234 @@
|
|
1
|
+
require 'cocoapods-bb-bin/native/podfile'
|
2
|
+
require 'cocoapods/command/gen'
|
3
|
+
require 'cocoapods/generate'
|
4
|
+
require 'cocoapods-bb-bin/helpers/framework_builder'
|
5
|
+
require 'cocoapods-bb-bin/helpers/library_builder'
|
6
|
+
require 'cocoapods-bb-bin/helpers/build_helper'
|
7
|
+
require 'cocoapods-bb-bin/helpers/spec_source_creator'
|
8
|
+
require 'cocoapods-bb-bin/config/config_builder'
|
9
|
+
require 'cocoapods-bb-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
|
+
['--xcframework-output', '输出xcframework文件'],
|
33
|
+
['--no-zip', '不压缩静态库 为 zip'],
|
34
|
+
['--configuration', 'Build the specified configuration (e.g. Debug). Defaults to Release'],
|
35
|
+
['--env', "该组件上传的环境 %w[dev debug_iphoneos release_iphoneos]"]
|
36
|
+
].concat(Pod::Command::Gen.options).concat(super).uniq
|
37
|
+
end
|
38
|
+
|
39
|
+
self.arguments = [
|
40
|
+
CLAide::Argument.new('NAME.podspec', false)
|
41
|
+
]
|
42
|
+
|
43
|
+
def initialize(argv)
|
44
|
+
@env = argv.option('env') || 'dev'
|
45
|
+
CBin.config.set_configuration_env(@env)
|
46
|
+
UI.puts "====== cocoapods-bb-bin #{CBin::VERSION} 版本 #{@env} 环境 ========".yellow
|
47
|
+
|
48
|
+
@code_dependencies = argv.flag?('code-dependencies')
|
49
|
+
@framework_output = argv.flag?('framework-output', false )
|
50
|
+
@xcframework_output = argv.flag?('xcframework-output', false )
|
51
|
+
@clean = argv.flag?('no-clean', false)
|
52
|
+
@zip = argv.flag?('zip', true)
|
53
|
+
@all_make = argv.flag?('all-make', false )
|
54
|
+
@sources = argv.option('sources') || []
|
55
|
+
@platform = Platform.new(:ios)
|
56
|
+
|
57
|
+
@config = argv.option('configuration', 'Release')
|
58
|
+
|
59
|
+
@framework_path
|
60
|
+
super
|
61
|
+
|
62
|
+
@additional_args = argv.remainder!
|
63
|
+
@build_finshed = false
|
64
|
+
end
|
65
|
+
|
66
|
+
def run
|
67
|
+
# 清除之前的缓存
|
68
|
+
CBin::Config::Builder.instance.clean
|
69
|
+
|
70
|
+
@spec = Specification.from_file(spec_file)
|
71
|
+
generate_project
|
72
|
+
|
73
|
+
swift_pods_buildsetting
|
74
|
+
|
75
|
+
build_root_spec
|
76
|
+
# 生成podspec
|
77
|
+
sources_sepc = Array.new
|
78
|
+
sources_sepc << @spec
|
79
|
+
sources_sepc.concat(build_dependencies) if @all_make
|
80
|
+
|
81
|
+
return sources_sepc
|
82
|
+
end
|
83
|
+
|
84
|
+
def build_root_spec
|
85
|
+
builder = CBin::Build::Helper.new(@spec,
|
86
|
+
@platform,
|
87
|
+
@framework_output,
|
88
|
+
@xcframework_output,
|
89
|
+
@sources,
|
90
|
+
@zip,
|
91
|
+
@spec,
|
92
|
+
CBin::Config::Builder.instance.white_pod_list.include?(@spec.name),
|
93
|
+
@config)
|
94
|
+
builder.build
|
95
|
+
builder.clean_workspace if @clean && !@all_make
|
96
|
+
end
|
97
|
+
|
98
|
+
def build_dependencies
|
99
|
+
@build_finshed = true
|
100
|
+
#如果没要求,就清空依赖库数据
|
101
|
+
sources_sepc = []
|
102
|
+
@@missing_binary_specs.uniq.each do |spec|
|
103
|
+
next if spec.name.include?('/')
|
104
|
+
next if spec.name == @spec.name
|
105
|
+
#过滤白名单
|
106
|
+
next if CBin::Config::Builder.instance.white_pod_list.include?(spec.name)
|
107
|
+
#过滤 git
|
108
|
+
if spec.source[:git] && spec.source[:git]
|
109
|
+
spec_git = spec.source[:git]
|
110
|
+
spec_git_res = false
|
111
|
+
CBin::Config::Builder.instance.ignore_git_list.each do |ignore_git|
|
112
|
+
spec_git_res = spec_git.include?(ignore_git)
|
113
|
+
break if spec_git_res
|
114
|
+
end
|
115
|
+
next if spec_git_res
|
116
|
+
end
|
117
|
+
UI.warn "#{spec.name}.podspec 带有 vendored_frameworks 字段,请检查是否有效!!!" if spec.attributes_hash['vendored_frameworks']
|
118
|
+
next if spec.attributes_hash['vendored_frameworks'] && @spec.name != spec.name #过滤带有vendored_frameworks的
|
119
|
+
next if spec.attributes_hash['ios.vendored_frameworks'] && @spec.name != spec.name #过滤带有vendored_frameworks的
|
120
|
+
#获取没有制作二进制版本的spec集合
|
121
|
+
sources_sepc << spec
|
122
|
+
end
|
123
|
+
|
124
|
+
fail_build_specs = []
|
125
|
+
sources_sepc.uniq.each do |spec|
|
126
|
+
begin
|
127
|
+
builder = CBin::Build::Helper.new(spec,
|
128
|
+
@platform,
|
129
|
+
@framework_output,
|
130
|
+
@xcframework_output,
|
131
|
+
@sources,
|
132
|
+
@zip,
|
133
|
+
@spec,
|
134
|
+
false ,
|
135
|
+
@config)
|
136
|
+
builder.build
|
137
|
+
rescue Object => exception
|
138
|
+
UI.puts exception
|
139
|
+
fail_build_specs << spec
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
if fail_build_specs.any?
|
144
|
+
fail_build_specs.uniq.each do |spec|
|
145
|
+
UI.warn "【#{spec.name} | #{spec.version}】组件二进制版本编译失败 ."
|
146
|
+
end
|
147
|
+
end
|
148
|
+
sources_sepc - fail_build_specs
|
149
|
+
end
|
150
|
+
|
151
|
+
# 解析器传过来的
|
152
|
+
def Archive.missing_binary_specs(missing_binary_specs)
|
153
|
+
@@missing_binary_specs = missing_binary_specs unless @build_finshed
|
154
|
+
end
|
155
|
+
|
156
|
+
private
|
157
|
+
|
158
|
+
def generate_project
|
159
|
+
Podfile.execute_with_bin_plugin do
|
160
|
+
Podfile.execute_with_use_binaries(!@code_dependencies) do
|
161
|
+
argvs = [
|
162
|
+
"--sources=#{sources_option(@code_dependencies, @sources)}",
|
163
|
+
"--gen-directory=#{CBin::Config::Builder.instance.gen_dir}",
|
164
|
+
'--clean',
|
165
|
+
"--verbose",
|
166
|
+
*@additional_args
|
167
|
+
]
|
168
|
+
|
169
|
+
if File.exist?(Pod::Config.instance.podfile_path)
|
170
|
+
argvs += ['--use-podfile']
|
171
|
+
end
|
172
|
+
|
173
|
+
unless CBin::Build::Utils.uses_frameworks?
|
174
|
+
argvs += ['--use-libraries']
|
175
|
+
end
|
176
|
+
|
177
|
+
argvs << spec_file if spec_file
|
178
|
+
|
179
|
+
gen = Pod::Command::Gen.new(CLAide::ARGV.new(argvs))
|
180
|
+
gen.validate!
|
181
|
+
gen.run
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
def swift_pods_buildsetting
|
187
|
+
# swift_project_link_header
|
188
|
+
worksppace_path = File.expand_path("#{CBin::Config::Builder.instance.gen_dir}/#{@spec.name}")
|
189
|
+
path = File.join(worksppace_path, "Pods.xcodeproj")
|
190
|
+
path = File.join(worksppace_path, "Pods/Pods.xcodeproj") unless File.exist?(path)
|
191
|
+
raise Informative, "#{path} File no exist, please check" unless File.exist?(path)
|
192
|
+
project = Xcodeproj::Project.open(path)
|
193
|
+
project.build_configurations.each do |x|
|
194
|
+
x.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = true #设置生成swift inter
|
195
|
+
end
|
196
|
+
project.save
|
197
|
+
end
|
198
|
+
|
199
|
+
# def swift_project_link_header
|
200
|
+
# worksppace_path = Pod::Config.instance.installation_root
|
201
|
+
# Dir.chdir(worksppace_path) do
|
202
|
+
# shell_script = <<-'SH'.strip_heredoc
|
203
|
+
# ditto "${DERIVED_SOURCES_DIR}/${PRODUCT_MODULE_NAME}-Swift.h" "${CBin::Config::Builder.instance.gen_dir}"
|
204
|
+
# SH
|
205
|
+
# shell_script
|
206
|
+
#
|
207
|
+
# # project = Xcodeproj::Project.open(Dir.glob('*.xcodeproj').first)
|
208
|
+
# # project.build_configurations.each do |x|
|
209
|
+
# # x.build_settings['DERIVED_SOURCES_DIR']
|
210
|
+
# # end
|
211
|
+
# end
|
212
|
+
# end
|
213
|
+
|
214
|
+
def spec_file
|
215
|
+
@spec_file ||= begin
|
216
|
+
if @podspec
|
217
|
+
find_spec_file(@podspec)
|
218
|
+
else
|
219
|
+
if code_spec_files.empty?
|
220
|
+
raise Informative, '当前目录下没有找到可用源码 podspec.'
|
221
|
+
end
|
222
|
+
|
223
|
+
spec_file = code_spec_files.first
|
224
|
+
spec_file
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
@@ -0,0 +1,226 @@
|
|
1
|
+
|
2
|
+
require 'cocoapods-bb-bin/command/bin/auto'
|
3
|
+
require 'cocoapods-bb-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
|
+
['--xcframework-output', '输出xcframework文件'],
|
21
|
+
['--no-zip', '不压缩静态 framework 为 zip'],
|
22
|
+
['--all-make', '对该组件的依赖库,全部制作为二进制组件'],
|
23
|
+
['--configuration', 'Build the specified configuration (e.g. Release ). Defaults to Debug'],
|
24
|
+
['--env', "该组件上传的环境 %w[dev debug_iphoneos release_iphoneos]"]
|
25
|
+
].concat(Pod::Command::Gen.options).concat(super).uniq
|
26
|
+
end
|
27
|
+
|
28
|
+
def initialize(argv)
|
29
|
+
@help = argv.flag?('help', false )
|
30
|
+
if @help
|
31
|
+
else
|
32
|
+
puts "开始执行自动推送操作,"
|
33
|
+
podfile_path = link_podfile # 创建软链接
|
34
|
+
|
35
|
+
@env = argv.option('env') || 'dev'
|
36
|
+
CBin.config.set_configuration_env(@env)
|
37
|
+
|
38
|
+
@podspec = argv.shift_argument || find_podspec
|
39
|
+
@specification = Specification.from_file(@podspec)
|
40
|
+
|
41
|
+
@code_dependencies = argv.flag?('code-dependencies')
|
42
|
+
@allow_prerelease = argv.flag?('allow-prerelease')
|
43
|
+
@framework_output = argv.flag?('framework-output', false )
|
44
|
+
@xcframework_output = argv.flag?('xcframework-output', false )
|
45
|
+
@clean = argv.flag?('clean', true)
|
46
|
+
@zip = argv.flag?('zip', true)
|
47
|
+
@all_make = argv.flag?('all-make', false )
|
48
|
+
@verbose = argv.flag?('verbose',true)
|
49
|
+
|
50
|
+
@config = argv.option('configuration', 'Debug')
|
51
|
+
@additional_args = argv.remainder!
|
52
|
+
end
|
53
|
+
super
|
54
|
+
end
|
55
|
+
|
56
|
+
def validate!
|
57
|
+
help! "未找到 podspec文件" unless @podspec
|
58
|
+
super
|
59
|
+
end
|
60
|
+
|
61
|
+
def run
|
62
|
+
@specification = Specification.from_file(@podspec)
|
63
|
+
|
64
|
+
sources_sepc = run_archive
|
65
|
+
|
66
|
+
fail_push_specs = []
|
67
|
+
sources_sepc.uniq.each do |spec|
|
68
|
+
begin
|
69
|
+
fail_push_specs << spec unless CBin::Upload::Helper.new(spec,@code_dependencies,@sources).upload
|
70
|
+
rescue Object => exception
|
71
|
+
UI.puts exception
|
72
|
+
fail_push_specs << spec
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
if fail_push_specs.any?
|
77
|
+
fail_push_specs.uniq.each do |spec|
|
78
|
+
UI.warn "【#{spec.name} | #{spec.version}】组件spec push失败 ."
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
success_specs = sources_sepc - fail_push_specs
|
83
|
+
if success_specs.any?
|
84
|
+
auto_success = ""
|
85
|
+
success_specs.uniq.each do |spec|
|
86
|
+
auto_success += "#{spec.name} | #{spec.version}\n"
|
87
|
+
UI.warn "===【 #{spec.name} | #{spec.version} 】二进制组件制作完成 !!! "
|
88
|
+
end
|
89
|
+
puts "============== auto_success"
|
90
|
+
puts auto_success
|
91
|
+
ENV['auto_success'] = auto_success
|
92
|
+
end
|
93
|
+
#pod repo update
|
94
|
+
UI.section("\nUpdating Spec Repositories\n".yellow) do
|
95
|
+
Pod::Command::Bin::Repo::Update.new(CLAide::ARGV.new([])).run
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
#制作二进制包
|
101
|
+
|
102
|
+
def run_archive
|
103
|
+
argvs = [
|
104
|
+
"--sources=#{sources_option(@code_dependencies, @sources)},https:\/\/cdn.cocoapods.org",
|
105
|
+
@additional_args
|
106
|
+
]
|
107
|
+
|
108
|
+
argvs << spec_file if spec_file
|
109
|
+
argvs.delete(Array.new)
|
110
|
+
|
111
|
+
unless @clean
|
112
|
+
argvs += ['--no-clean']
|
113
|
+
end
|
114
|
+
if @code_dependencies
|
115
|
+
argvs += ['--code-dependencies']
|
116
|
+
end
|
117
|
+
if @verbose
|
118
|
+
argvs += ['--verbose']
|
119
|
+
end
|
120
|
+
if @allow_prerelease
|
121
|
+
argvs += ['--allow-prerelease']
|
122
|
+
end
|
123
|
+
if @framework_output
|
124
|
+
argvs += ['--framework-output']
|
125
|
+
end
|
126
|
+
if @xcframework_output
|
127
|
+
argvs += ['--xcframework-output']
|
128
|
+
end
|
129
|
+
if @all_make
|
130
|
+
argvs += ['--all-make']
|
131
|
+
end
|
132
|
+
if @env
|
133
|
+
argvs += ["--env=#{@env}"]
|
134
|
+
end
|
135
|
+
argvs += ["--configuration=#{@config}"]
|
136
|
+
puts "===auto argvs: #{argvs}"
|
137
|
+
archive = Pod::Command::Bin::Archive.new(CLAide::ARGV.new(argvs))
|
138
|
+
archive.validate!
|
139
|
+
sources_sepc = archive.run
|
140
|
+
return sources_sepc
|
141
|
+
end
|
142
|
+
|
143
|
+
|
144
|
+
def code_podsepc_extname
|
145
|
+
'.podsepc'
|
146
|
+
end
|
147
|
+
|
148
|
+
def binary_podsepc_json
|
149
|
+
"#{@specification.name}.binary.podspec.json"
|
150
|
+
end
|
151
|
+
|
152
|
+
def binary_template_podsepc
|
153
|
+
"#{@specification.name}.binary-template.podspec"
|
154
|
+
end
|
155
|
+
|
156
|
+
def template_spec_file
|
157
|
+
@template_spec_file ||= begin
|
158
|
+
if @template_podspec
|
159
|
+
find_spec_file(@template_podspec)
|
160
|
+
else
|
161
|
+
binary_template_spec_file
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
def spec_file
|
167
|
+
@spec_file ||= begin
|
168
|
+
if @podspec
|
169
|
+
find_spec_file(@podspec) || @podspec
|
170
|
+
else
|
171
|
+
if code_spec_files.empty?
|
172
|
+
raise Informative, '当前目录下没有找到可用源码 podspec.'
|
173
|
+
end
|
174
|
+
|
175
|
+
spec_file = if @binary
|
176
|
+
code_spec = Pod::Specification.from_file(code_spec_files.first)
|
177
|
+
if template_spec_file
|
178
|
+
template_spec = Pod::Specification.from_file(template_spec_file)
|
179
|
+
end
|
180
|
+
create_binary_spec_file(code_spec, template_spec)
|
181
|
+
else
|
182
|
+
code_spec_files.first
|
183
|
+
end
|
184
|
+
spec_file
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
#Dir.glob 可替代
|
190
|
+
def find_podspec
|
191
|
+
name = nil
|
192
|
+
Pathname.pwd.children.each do |child|
|
193
|
+
puts child
|
194
|
+
if File.file?(child)
|
195
|
+
if child.extname == '.podspec'
|
196
|
+
name = File.basename(child)
|
197
|
+
unless name.include?("binary-template")
|
198
|
+
return name
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
return name
|
204
|
+
end
|
205
|
+
|
206
|
+
# podfile创建软链接
|
207
|
+
def link_podfile
|
208
|
+
current_path = Pathname.pwd
|
209
|
+
Dir.foreach(current_path) do |filename|
|
210
|
+
if filename == 'Podfile'
|
211
|
+
filepath = File.join(current_path,"#{filename}")
|
212
|
+
return filepath
|
213
|
+
end
|
214
|
+
end
|
215
|
+
# 没有找到podfile(小组件)
|
216
|
+
podfile_path = File.join(current_path,"Example/Podfile")
|
217
|
+
if File.file?(podfile_path)
|
218
|
+
system("ln -s #{podfile_path} #{current_path}")
|
219
|
+
UI.warn "创建软链接 podfile:#{podfile_path} link:#{current_path}"
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|