cocoapods-lhj-bin 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +22 -0
  3. data/README.md +11 -0
  4. data/lib/cocoapods-lhj-bin.rb +2 -0
  5. data/lib/cocoapods-lhj-bin/command.rb +1 -0
  6. data/lib/cocoapods-lhj-bin/command/bin.rb +59 -0
  7. data/lib/cocoapods-lhj-bin/command/bin/archive.rb +233 -0
  8. data/lib/cocoapods-lhj-bin/command/bin/auto.rb +198 -0
  9. data/lib/cocoapods-lhj-bin/command/bin/code.rb +232 -0
  10. data/lib/cocoapods-lhj-bin/command/bin/dup.rb +78 -0
  11. data/lib/cocoapods-lhj-bin/command/bin/init.rb +69 -0
  12. data/lib/cocoapods-lhj-bin/command/bin/initHotKey.rb +70 -0
  13. data/lib/cocoapods-lhj-bin/command/bin/install.rb +44 -0
  14. data/lib/cocoapods-lhj-bin/command/bin/lhj.rb +46 -0
  15. data/lib/cocoapods-lhj-bin/command/bin/lib/lint.rb +69 -0
  16. data/lib/cocoapods-lhj-bin/command/bin/repo/update.rb +43 -0
  17. data/lib/cocoapods-lhj-bin/command/bin/spec/create.rb +73 -0
  18. data/lib/cocoapods-lhj-bin/command/bin/spec/push.rb +115 -0
  19. data/lib/cocoapods-lhj-bin/command/bin/update.rb +153 -0
  20. data/lib/cocoapods-lhj-bin/config/config.rb +137 -0
  21. data/lib/cocoapods-lhj-bin/config/config_asker.rb +57 -0
  22. data/lib/cocoapods-lhj-bin/config/config_builder.rb +216 -0
  23. data/lib/cocoapods-lhj-bin/config/config_hot_key.rb +103 -0
  24. data/lib/cocoapods-lhj-bin/config/config_hot_key_asker.rb +57 -0
  25. data/lib/cocoapods-lhj-bin/gem_version.rb +9 -0
  26. data/lib/cocoapods-lhj-bin/helpers.rb +5 -0
  27. data/lib/cocoapods-lhj-bin/helpers/Info.plist +0 -0
  28. data/lib/cocoapods-lhj-bin/helpers/build_helper.rb +158 -0
  29. data/lib/cocoapods-lhj-bin/helpers/build_utils.rb +93 -0
  30. data/lib/cocoapods-lhj-bin/helpers/framework.rb +85 -0
  31. data/lib/cocoapods-lhj-bin/helpers/framework_builder.rb +444 -0
  32. data/lib/cocoapods-lhj-bin/helpers/library.rb +54 -0
  33. data/lib/cocoapods-lhj-bin/helpers/library_builder.rb +90 -0
  34. data/lib/cocoapods-lhj-bin/helpers/sources_helper.rb +36 -0
  35. data/lib/cocoapods-lhj-bin/helpers/spec_creator.rb +168 -0
  36. data/lib/cocoapods-lhj-bin/helpers/spec_files_helper.rb +75 -0
  37. data/lib/cocoapods-lhj-bin/helpers/spec_source_creator.rb +227 -0
  38. data/lib/cocoapods-lhj-bin/helpers/upload_helper.rb +87 -0
  39. data/lib/cocoapods-lhj-bin/native.rb +19 -0
  40. data/lib/cocoapods-lhj-bin/native/acknowledgements.rb +27 -0
  41. data/lib/cocoapods-lhj-bin/native/analyzer.rb +55 -0
  42. data/lib/cocoapods-lhj-bin/native/file_accessor.rb +28 -0
  43. data/lib/cocoapods-lhj-bin/native/installation_options.rb +25 -0
  44. data/lib/cocoapods-lhj-bin/native/installer.rb +135 -0
  45. data/lib/cocoapods-lhj-bin/native/linter.rb +26 -0
  46. data/lib/cocoapods-lhj-bin/native/path_source.rb +33 -0
  47. data/lib/cocoapods-lhj-bin/native/pod_source_installer.rb +19 -0
  48. data/lib/cocoapods-lhj-bin/native/pod_target_installer.rb +94 -0
  49. data/lib/cocoapods-lhj-bin/native/podfile.rb +91 -0
  50. data/lib/cocoapods-lhj-bin/native/podfile_env.rb +37 -0
  51. data/lib/cocoapods-lhj-bin/native/podfile_generator.rb +199 -0
  52. data/lib/cocoapods-lhj-bin/native/podspec_finder.rb +25 -0
  53. data/lib/cocoapods-lhj-bin/native/resolver.rb +230 -0
  54. data/lib/cocoapods-lhj-bin/native/sandbox_analyzer.rb +34 -0
  55. data/lib/cocoapods-lhj-bin/native/source.rb +35 -0
  56. data/lib/cocoapods-lhj-bin/native/sources_manager.rb +20 -0
  57. data/lib/cocoapods-lhj-bin/native/specification.rb +31 -0
  58. data/lib/cocoapods-lhj-bin/native/target_validator.rb +41 -0
  59. data/lib/cocoapods-lhj-bin/native/validator.rb +40 -0
  60. data/lib/cocoapods-lhj-bin/source_provider_hook.rb +66 -0
  61. data/lib/cocoapods_plugin.rb +2 -0
  62. data/spec/command/bin_spec.rb +12 -0
  63. data/spec/spec_helper.rb +50 -0
  64. metadata +177 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e7eaa3c9537113476ed06b8b7a98739f13b8e9f2b2d1914ddbe175e814c155e7
4
+ data.tar.gz: 28181dd881aa75a3ebe437e0eede3f5c819ab36518f1ad276389e1acb463ef87
5
+ SHA512:
6
+ metadata.gz: 15c4a4e57db73147d47977ed4b7aa3310e94227a82bdd0e06e780a157745c7bda5a08ee2596d16dac98577c4faca0738f2950a59a3957a18e16fa8a2eec08c07
7
+ data.tar.gz: 2a773563056fe2916e9433a4607490c40fb825aa472b4052a7452a15eaa57ee6ffdf2a14ac229f94b78382e660d5fd2fdc56878f9fee335b29b49df3730ca30c
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2021 lihaijian <sanan.li@qq.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,11 @@
1
+ # cocoapods-lhj-bin
2
+
3
+ A description of cocoapods-lhj-bin.
4
+
5
+ ## Installation
6
+
7
+ $ gem install cocoapods-lhj-bin
8
+
9
+ ## Usage
10
+
11
+ $ pod spec bin POD_NAME
@@ -0,0 +1,2 @@
1
+ require 'cocoapods-lhj-bin/gem_version'
2
+ require 'cocoapods-lhj-bin/native/sources_manager'
@@ -0,0 +1 @@
1
+ require 'cocoapods-lhj-bin/command/bin'
@@ -0,0 +1,59 @@
1
+
2
+ require 'cocoapods-lhj-bin/command/bin/initHotKey'
3
+ require 'cocoapods-lhj-bin/command/bin/init'
4
+ require 'cocoapods-lhj-bin/command/bin/archive'
5
+ require 'cocoapods-lhj-bin/command/bin/auto'
6
+ require 'cocoapods-lhj-bin/command/bin/code'
7
+ require 'cocoapods-lhj-bin/command/bin/update'
8
+ require 'cocoapods-lhj-bin/command/bin/install'
9
+ require 'cocoapods-lhj-bin/command/bin/lhj'
10
+
11
+ require 'cocoapods-lhj-bin/helpers'
12
+
13
+ module Pod
14
+ class Command
15
+ # This is an example of a cocoapods plugin adding a top-level subcommand
16
+ # to the 'pod' command.
17
+ #
18
+ # You can also create subcommands of existing or new commands. Say you
19
+ # wanted to add a subcommand to `list` to show newly deprecated pods,
20
+ # (e.g. `pod list deprecated`), there are a few things that would need
21
+ # to change.
22
+ #
23
+ # - move this file to `lib/pod/command/list/deprecated.rb` and update
24
+ # the class to exist in the the Pod::Command::List namespace
25
+ # - change this class to extend from `List` instead of `Command`. This
26
+ # tells the plugin system that it is a subcommand of `list`.
27
+ # - edit `lib/cocoapods_plugins.rb` to require this file
28
+ #
29
+ # @todo Create a PR to add your plugin to CocoaPods/cocoapods.org
30
+ # in the `plugins.json` file, once your plugin is released.
31
+ #
32
+ class Bin < Command
33
+ include CBin::SourcesHelper
34
+ include CBin::SpecFilesHelper
35
+
36
+ self.abstract_command = true
37
+
38
+ self.default_subcommand = 'open'
39
+ self.summary = '组件二进制化插件.'
40
+ self.description = <<-DESC
41
+ 组件二进制化插件。利用源码私有源与二进制私有源实现对组件依赖类型的切换。
42
+ DESC
43
+
44
+ def initialize(argv)
45
+ require 'cocoapods-lhj-bin/native'
46
+
47
+ @help = argv.flag?('help')
48
+ super
49
+ end
50
+
51
+ def validate!
52
+ super
53
+ # 这里由于 --help 是在 validate! 方法中提取的,会导致 --help 失效
54
+ # pod lib create 也有这个问题
55
+ banner! if @help
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,233 @@
1
+ require 'cocoapods-lhj-bin/native/podfile'
2
+ require 'cocoapods/command/gen'
3
+ require 'cocoapods/generate'
4
+ require 'cocoapods-lhj-bin/helpers/framework_builder'
5
+ require 'cocoapods-lhj-bin/helpers/library_builder'
6
+ require 'cocoapods-lhj-bin/helpers/build_helper'
7
+ require 'cocoapods-lhj-bin/helpers/spec_files_helper'
8
+ require 'cocoapods-lhj-bin/helpers/spec_source_creator'
9
+ require 'cocoapods-lhj-bin/config/config_builder'
10
+ require 'cocoapods-lhj-bin/command/bin/lib/lint'
11
+ require 'xcodeproj'
12
+
13
+ module Pod
14
+ class Command
15
+ class Bin < Command
16
+ class Archive < Bin
17
+
18
+ @@missing_binary_specs = []
19
+
20
+ self.summary = '将组件归档为静态库 .a.'
21
+ self.description = <<-DESC
22
+ 将组件归档为静态库 framework,仅支持 iOS 平台
23
+ 此静态 framework 不包含依赖组件的 symbol
24
+ DESC
25
+
26
+ def self.options
27
+ [
28
+ ['--all-make', '对该组件的依赖库,全部制作为二进制组件'],
29
+ ['--code-dependencies', '使用源码依赖'],
30
+ ['--no-clean', '保留构建中间产物'],
31
+ ['--sources', '私有源地址,多个用分号区分'],
32
+ ['--framework-output', '输出framework文件'],
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.warn "====== cocoapods-lhj-bin #{CBin::VERSION} 版本 ======== \n "
47
+ UI.warn "====== #{@env} 环境 ======== \n "
48
+
49
+ @code_dependencies = argv.flag?('code-dependencies')
50
+ @framework_output = argv.flag?('framework-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
+ @spec_file = @additional_args[0]
64
+ @build_finshed = false
65
+ end
66
+
67
+ def run
68
+ # 清除之前的缓存
69
+ CBin::Config::Builder.instance.clean
70
+
71
+ @spec = Specification.from_file(spec_file)
72
+ generate_project
73
+
74
+ swift_pods_buildsetting
75
+
76
+ build_root_spec
77
+
78
+ sources_sepc = Array.new
79
+ sources_sepc << @spec
80
+ sources_sepc.concat(build_dependencies) if @all_make
81
+
82
+ sources_sepc
83
+ end
84
+
85
+ def build_root_spec
86
+ builder = CBin::Build::Helper.new(@spec,
87
+ @platform,
88
+ @framework_output,
89
+ @zip,
90
+ @spec,
91
+ CBin::Config::Builder.instance.white_pod_list.include?(@spec.name),
92
+ @config)
93
+ builder.build
94
+ builder.clean_workspace if @clean && !@all_make
95
+ end
96
+
97
+ def build_dependencies
98
+ @build_finshed = true
99
+ #如果没要求,就清空依赖库数据
100
+ sources_sepc = []
101
+ @@missing_binary_specs.uniq.each do |spec|
102
+ next if spec.name.include?('/')
103
+ next if spec.name == @spec.name
104
+ #过滤白名单
105
+ next if CBin::Config::Builder.instance.white_pod_list.include?(spec.name)
106
+ #过滤 git
107
+ if spec.source[:git] && spec.source[:git]
108
+ spec_git = spec.source[:git]
109
+ spec_git_res = false
110
+ CBin::Config::Builder.instance.ignore_git_list.each do |ignore_git|
111
+ spec_git_res = spec_git.include?(ignore_git)
112
+ break if spec_git_res
113
+ end
114
+ next if spec_git_res
115
+ end
116
+ UI.warn "#{spec.name}.podspec 带有 vendored_frameworks 字段,请检查是否有效!!!" if spec.attributes_hash['vendored_frameworks']
117
+ next if spec.attributes_hash['vendored_frameworks'] && @spec.name != spec.name #过滤带有vendored_frameworks的
118
+ next if spec.attributes_hash['ios.vendored_frameworks'] && @spec.name != spec.name #过滤带有vendored_frameworks的
119
+ #获取没有制作二进制版本的spec集合
120
+ sources_sepc << spec
121
+ end
122
+
123
+ fail_build_specs = []
124
+ sources_sepc.uniq.each do |spec|
125
+ begin
126
+ builder = CBin::Build::Helper.new(spec,
127
+ @platform,
128
+ @framework_output,
129
+ @zip,
130
+ @spec,
131
+ false ,
132
+ @config)
133
+ builder.build
134
+ rescue Object => exception
135
+ UI.puts exception
136
+ fail_build_specs << spec
137
+ end
138
+ end
139
+
140
+ if fail_build_specs.any?
141
+ fail_build_specs.uniq.each do |spec|
142
+ UI.warn "【#{spec.name} | #{spec.version}】组件二进制版本编译失败 ."
143
+ end
144
+ end
145
+ sources_sepc - fail_build_specs
146
+ end
147
+
148
+ # 解析器传过来的
149
+ def Archive.missing_binary_specs(missing_binary_specs)
150
+ @@missing_binary_specs = missing_binary_specs unless @build_finshed
151
+ end
152
+
153
+ private
154
+
155
+ def generate_project
156
+ Podfile.execute_with_bin_plugin do
157
+ Podfile.execute_with_use_binaries(!@code_dependencies) do
158
+ argvs = [
159
+ "--sources=#{sources_option(@code_dependencies, @sources)}",
160
+ "--gen-directory=#{CBin::Config::Builder.instance.gen_dir}",
161
+ '--clean',
162
+ "--verbose",
163
+ *@additional_args
164
+ ]
165
+
166
+ podfile= File.join(Pathname.pwd, "Podfile")
167
+ if File.exist?(podfile)
168
+ argvs += ['--use-podfile']
169
+ end
170
+
171
+
172
+ unless CBin::Build::Utils.is_framework(@podspec)
173
+ argvs += ['--use-libraries']
174
+ end
175
+
176
+ argvs << spec_file if spec_file
177
+
178
+ gen = Pod::Command::Gen.new(CLAide::ARGV.new(argvs))
179
+ gen.validate!
180
+ gen.run
181
+ end
182
+ end
183
+ end
184
+
185
+ def swift_pods_buildsetting
186
+ # swift_project_link_header
187
+ worksppace_path = File.expand_path("#{CBin::Config::Builder.instance.gen_dir}/#{@spec.name}")
188
+ path = File.join(worksppace_path, "Pods.xcodeproj")
189
+ path = File.join(worksppace_path, "Pods/Pods.xcodeproj") unless File.exist?(path)
190
+ raise Informative, "#{path} File no exist, please check" unless File.exist?(path)
191
+ project = Xcodeproj::Project.open(path)
192
+ project.build_configurations.each do |x|
193
+ x.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = true #设置生成swift inter
194
+ end
195
+ project.save
196
+ end
197
+
198
+ # def swift_project_link_header
199
+ # worksppace_path = Pod::Config.instance.installation_root
200
+ # Dir.chdir(worksppace_path) do
201
+ # shell_script = <<-'SH'.strip_heredoc
202
+ # ditto "${DERIVED_SOURCES_DIR}/${PRODUCT_MODULE_NAME}-Swift.h" "${CBin::Config::Builder.instance.gen_dir}"
203
+ # SH
204
+ # shell_script
205
+ #
206
+ # # project = Xcodeproj::Project.open(Dir.glob('*.xcodeproj').first)
207
+ # # project.build_configurations.each do |x|
208
+ # # x.build_settings['DERIVED_SOURCES_DIR']
209
+ # # end
210
+ # end
211
+ # end
212
+
213
+ def spec_file
214
+ @spec_file ||= begin
215
+ if @podspec
216
+ find_spec_file(@podspec)
217
+ else
218
+ if code_spec_files.empty?
219
+ raise Informative, '当前目录下没有找到可用源码 podspec.'
220
+ end
221
+
222
+ spec_file = code_spec_files.first
223
+ spec_file
224
+ end
225
+ end
226
+ end
227
+
228
+
229
+
230
+ end
231
+ end
232
+ end
233
+ end
@@ -0,0 +1,198 @@
1
+ require 'cocoapods-lhj-bin/command/bin/auto'
2
+ require 'cocoapods-lhj-bin/helpers/upload_helper'
3
+
4
+ module Pod
5
+ class Command
6
+ class Bin < Command
7
+ class Auto < Bin
8
+ self.summary = '打开 workspace 工程.'
9
+
10
+ self.arguments = [
11
+ CLAide::Argument.new('NAME.podspec', false)
12
+ ]
13
+ def self.options
14
+ [
15
+ ['--code-dependencies', '使用源码依赖'],
16
+ ['--allow-prerelease', '允许使用 prerelease 的版本'],
17
+ ['--no-clean', '保留构建中间产物'],
18
+ ['--framework-output', '输出framework文件'],
19
+ ['--no-zip', '不压缩静态 framework 为 zip'],
20
+ ['--all-make', '对该组件的依赖库,全部制作为二进制组件'],
21
+ ['--configuration', 'Build the specified configuration (e.g. Release ). Defaults to Debug'],
22
+ ['--env', "该组件上传的环境 %w[dev debug_iphoneos release_iphoneos]"]
23
+ ].concat(Pod::Command::Gen.options).concat(super).uniq
24
+ end
25
+
26
+ def initialize(argv)
27
+
28
+ @env = argv.option('env') || 'dev'
29
+ CBin.config.set_configuration_env(@env)
30
+
31
+ @podspec = argv.shift_argument || find_podspec
32
+ @specification = Specification.from_file(@podspec)
33
+
34
+ @code_dependencies = argv.flag?('code-dependencies')
35
+ @allow_prerelease = argv.flag?('allow-prerelease')
36
+ @framework_output = argv.flag?('framework-output', false)
37
+ @clean = argv.flag?('clean', true)
38
+ @zip = argv.flag?('zip', true)
39
+ @all_make = argv.flag?('all-make', false)
40
+ @verbose = argv.flag?('verbose', true)
41
+
42
+ @config = argv.option('configuration', 'Debug')
43
+ @additional_args = argv.remainder!
44
+
45
+ super
46
+ end
47
+
48
+ def validate!
49
+ help! "未找到 podspec文件" unless @podspec
50
+ super
51
+ end
52
+
53
+ def run
54
+ @specification = Specification.from_file(@podspec)
55
+
56
+ source_specs = run_archive
57
+
58
+ fail_push_specs = []
59
+ source_specs.uniq.each do |spec|
60
+ begin
61
+ fail_push_specs << spec unless CBin::Upload::Helper.new(spec, @code_dependencies, @sources).upload
62
+ rescue Object => exception
63
+ UI.puts exception
64
+ fail_push_specs << spec
65
+ end
66
+ end
67
+
68
+ if fail_push_specs.any?
69
+ fail_push_specs.uniq.each do |spec|
70
+ UI.warn "【#{spec.name} | #{spec.version}】组件spec push失败 ."
71
+ end
72
+ end
73
+
74
+ success_specs = source_specs - fail_push_specs
75
+ if success_specs.any?
76
+ auto_success = ""
77
+ success_specs.uniq.each do |spec|
78
+ auto_success += "#{spec.name} | #{spec.version}\n"
79
+ UI.warn "===【 #{spec.name} | #{spec.version} 】二进制组件制作完成 !!! "
80
+ end
81
+ puts "============== auto_success"
82
+ puts auto_success
83
+ ENV['auto_success'] = auto_success
84
+ end
85
+ #pod repo update
86
+ UI.section("\nUpdating Spec Repositories\n".yellow) do
87
+ Pod::Command::Bin::Repo::Update.new(CLAide::ARGV.new([])).run
88
+ end
89
+
90
+ end
91
+
92
+ #制作二进制包
93
+
94
+ def run_archive
95
+ argvs = [
96
+ "--sources=#{sources_option(@code_dependencies, @sources)},https:\/\/cdn.cocoapods.org",
97
+ @additional_args
98
+ ]
99
+
100
+ argvs << spec_file if spec_file
101
+ argvs.delete(Array.new)
102
+
103
+ unless @clean
104
+ argvs += ['--no-clean']
105
+ end
106
+ if @code_dependencies
107
+ argvs += ['--code-dependencies']
108
+ end
109
+ if @verbose
110
+ argvs += ['--verbose']
111
+ end
112
+ if @allow_prerelease
113
+ argvs += ['--allow-prerelease']
114
+ end
115
+ if @framework_output
116
+ argvs += ['--framework-output']
117
+ end
118
+ if @all_make
119
+ argvs += ['--all-make']
120
+ end
121
+ if @env
122
+ argvs += ["--env=#{@env}"]
123
+ end
124
+ argvs += ["--configuration=#{@config}"]
125
+
126
+ archive = Pod::Command::Bin::Archive.new(CLAide::ARGV.new(argvs))
127
+ archive.validate!
128
+ source_specs = archive.run
129
+ source_specs
130
+ end
131
+
132
+
133
+ def code_podsepc_extname
134
+ '.podsepc'
135
+ end
136
+
137
+ def binary_podsepc_json
138
+ "#{@specification.name}.binary.podspec.json"
139
+ end
140
+
141
+ def binary_template_podsepc
142
+ "#{@specification.name}.binary-template.podspec"
143
+ end
144
+
145
+ def template_spec_file
146
+ @template_spec_file ||= begin
147
+ if @template_podspec
148
+ find_spec_file(@template_podspec)
149
+ else
150
+ binary_template_spec_file
151
+ end
152
+ end
153
+ end
154
+
155
+ def spec_file
156
+ @spec_file ||= begin
157
+ if @podspec
158
+ find_spec_file(@podspec) || @podspec
159
+ else
160
+ if code_spec_files.empty?
161
+ raise Informative, '当前目录下没有找到可用源码 podspec.'
162
+ end
163
+
164
+ spec_file = if @binary
165
+ code_spec = Pod::Specification.from_file(code_spec_files.first)
166
+ if template_spec_file
167
+ template_spec = Pod::Specification.from_file(template_spec_file)
168
+ end
169
+ create_binary_spec_file(code_spec, template_spec)
170
+ else
171
+ code_spec_files.first
172
+ end
173
+ spec_file
174
+ end
175
+ end
176
+ end
177
+
178
+ #Dir.glob 可替代
179
+ def find_podspec
180
+ name = nil
181
+ Pathname.pwd.children.each do |child|
182
+ puts child
183
+ if File.file?(child)
184
+ if child.extname == '.podspec'
185
+ name = File.basename(child)
186
+ unless name.include?("binary-template")
187
+ return name
188
+ end
189
+ end
190
+ end
191
+ end
192
+ return name
193
+ end
194
+
195
+ end
196
+ end
197
+ end
198
+ end