cocoapods-bin 0.0.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.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -0
  3. data/Gemfile +13 -0
  4. data/Gemfile.lock +100 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +15 -0
  7. data/Rakefile +13 -0
  8. data/cocoapods-bin.gemspec +26 -0
  9. data/lib/cocoapods-bin/command/bin/init.rb +66 -0
  10. data/lib/cocoapods-bin/command/bin/lib/lint.rb +94 -0
  11. data/lib/cocoapods-bin/command/bin/lib.rb +12 -0
  12. data/lib/cocoapods-bin/command/bin/open.rb +60 -0
  13. data/lib/cocoapods-bin/command/bin/repo/push.rb +98 -0
  14. data/lib/cocoapods-bin/command/bin/repo.rb +12 -0
  15. data/lib/cocoapods-bin/command/bin/spec/create.rb +68 -0
  16. data/lib/cocoapods-bin/command/bin/spec/lint.rb +52 -0
  17. data/lib/cocoapods-bin/command/bin/spec.rb +13 -0
  18. data/lib/cocoapods-bin/command/bin.rb +52 -0
  19. data/lib/cocoapods-bin/command.rb +1 -0
  20. data/lib/cocoapods-bin/config/config.rb +52 -0
  21. data/lib/cocoapods-bin/config/config_asker.rb +50 -0
  22. data/lib/cocoapods-bin/gem_version.rb +9 -0
  23. data/lib/cocoapods-bin/helpers/sources_helper.rb +31 -0
  24. data/lib/cocoapods-bin/helpers/spec_files_helper.rb +17 -0
  25. data/lib/cocoapods-bin/helpers/spec_generator.rb +86 -0
  26. data/lib/cocoapods-bin/helpers.rb +3 -0
  27. data/lib/cocoapods-bin/native/analyzer.rb +28 -0
  28. data/lib/cocoapods-bin/native/installation_options.rb +24 -0
  29. data/lib/cocoapods-bin/native/installer.rb +73 -0
  30. data/lib/cocoapods-bin/native/linter.rb +29 -0
  31. data/lib/cocoapods-bin/native/pod_source_installer.rb +15 -0
  32. data/lib/cocoapods-bin/native/podfile.rb +67 -0
  33. data/lib/cocoapods-bin/native/resolver.rb +103 -0
  34. data/lib/cocoapods-bin/native/source.rb +35 -0
  35. data/lib/cocoapods-bin/native/source_provider_hook.rb +11 -0
  36. data/lib/cocoapods-bin/native/sources_manager.rb +18 -0
  37. data/lib/cocoapods-bin/native/validator.rb +16 -0
  38. data/lib/cocoapods-bin/native.rb +13 -0
  39. data/lib/cocoapods-bin.rb +1 -0
  40. data/lib/cocoapods_plugin.rb +3 -0
  41. data/spec/command/bin_spec.rb +12 -0
  42. data/spec/spec_helper.rb +50 -0
  43. metadata +143 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 397354181f9f9ab4ce7e462c4583f8d87ece5d7c
4
+ data.tar.gz: 21c9a9409b99972a592567df8e60e97d5b5b7da1
5
+ SHA512:
6
+ metadata.gz: deaea76a36d15e7a706b15f8b575ca2efc2d65bc8ae67e27799514928439ee6529637e232dd9efd28797794b1f1735f32c6e9e04d385fe05076149e81142247f
7
+ data.tar.gz: 7f0a12aad14d315d5bc67dfadacab6bd89d33dd1ff52dd04d253c9fa2343d26fc71944cecb5409fc8da81bc7195f508680b0d79dfdb35715c7fa25aec8b2cb8b
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .DS_Store
2
+ pkg
3
+ .idea/
4
+ example/
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cocoapods-bin.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem 'cocoapods'
8
+
9
+ gem 'mocha'
10
+ gem 'bacon'
11
+ gem 'mocha-on-bacon'
12
+ gem 'prettybacon'
13
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,100 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cocoapods-bin (0.0.1)
5
+ cocoapods (~> 1.4)
6
+ parallel
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ CFPropertyList (3.0.0)
12
+ activesupport (4.2.11)
13
+ i18n (~> 0.7)
14
+ minitest (~> 5.1)
15
+ thread_safe (~> 0.3, >= 0.3.4)
16
+ tzinfo (~> 1.1)
17
+ atomos (0.1.3)
18
+ bacon (1.2.0)
19
+ claide (1.0.2)
20
+ cocoapods (1.5.3)
21
+ activesupport (>= 4.0.2, < 5)
22
+ claide (>= 1.0.2, < 2.0)
23
+ cocoapods-core (= 1.5.3)
24
+ cocoapods-deintegrate (>= 1.0.2, < 2.0)
25
+ cocoapods-downloader (>= 1.2.0, < 2.0)
26
+ cocoapods-plugins (>= 1.0.0, < 2.0)
27
+ cocoapods-search (>= 1.0.0, < 2.0)
28
+ cocoapods-stats (>= 1.0.0, < 2.0)
29
+ cocoapods-trunk (>= 1.3.0, < 2.0)
30
+ cocoapods-try (>= 1.1.0, < 2.0)
31
+ colored2 (~> 3.1)
32
+ escape (~> 0.0.4)
33
+ fourflusher (~> 2.0.1)
34
+ gh_inspector (~> 1.0)
35
+ molinillo (~> 0.6.5)
36
+ nap (~> 1.0)
37
+ ruby-macho (~> 1.1)
38
+ xcodeproj (>= 1.5.7, < 2.0)
39
+ cocoapods-core (1.5.3)
40
+ activesupport (>= 4.0.2, < 6)
41
+ fuzzy_match (~> 2.0.4)
42
+ nap (~> 1.0)
43
+ cocoapods-deintegrate (1.0.2)
44
+ cocoapods-downloader (1.2.2)
45
+ cocoapods-plugins (1.0.0)
46
+ nap
47
+ cocoapods-search (1.0.0)
48
+ cocoapods-stats (1.0.0)
49
+ cocoapods-trunk (1.3.1)
50
+ nap (>= 0.8, < 2.0)
51
+ netrc (~> 0.11)
52
+ cocoapods-try (1.1.0)
53
+ colored2 (3.1.2)
54
+ concurrent-ruby (1.1.4)
55
+ escape (0.0.4)
56
+ fourflusher (2.0.1)
57
+ fuzzy_match (2.0.4)
58
+ gh_inspector (1.1.3)
59
+ i18n (0.9.5)
60
+ concurrent-ruby (~> 1.0)
61
+ metaclass (0.0.4)
62
+ minitest (5.11.3)
63
+ mocha (1.7.0)
64
+ metaclass (~> 0.0.1)
65
+ mocha-on-bacon (0.2.3)
66
+ mocha (>= 0.13.0)
67
+ molinillo (0.6.6)
68
+ nanaimo (0.2.6)
69
+ nap (1.1.0)
70
+ netrc (0.11.0)
71
+ parallel (1.12.1)
72
+ prettybacon (0.0.2)
73
+ bacon (~> 1.2)
74
+ rake (12.3.2)
75
+ ruby-macho (1.3.1)
76
+ thread_safe (0.3.6)
77
+ tzinfo (1.2.5)
78
+ thread_safe (~> 0.1)
79
+ xcodeproj (1.7.0)
80
+ CFPropertyList (>= 2.3.3, < 4.0)
81
+ atomos (~> 0.1.3)
82
+ claide (>= 1.0.2, < 2.0)
83
+ colored2 (~> 3.1)
84
+ nanaimo (~> 0.2.6)
85
+
86
+ PLATFORMS
87
+ ruby
88
+
89
+ DEPENDENCIES
90
+ bacon
91
+ bundler (~> 1.3)
92
+ cocoapods
93
+ cocoapods-bin!
94
+ mocha
95
+ mocha-on-bacon
96
+ prettybacon
97
+ rake
98
+
99
+ BUNDLED WITH
100
+ 1.16.1
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,15 @@
1
+ # cocoapods-bin
2
+
3
+ 组件二进制化插件。
4
+
5
+ 利用源码私有源与二进制私有源,实现的组件二进制化插件。可通过在 Podfile 中设置 use_binaries!,指定所有组件使用二进制依赖,设置 set_use_source_pods ,指定需要使用源码依赖的组件。
6
+
7
+ 为了兼容源码依赖 subspec 的情况,二进制 specification 的 subspec 需要和源码 specifcation 匹配,二进制的 subspec 比源码 subspec 多也是允许的。
8
+
9
+ ## Installation
10
+
11
+ $ gem install cocoapods-bin
12
+
13
+ ## Usage
14
+
15
+ $ pod spec bin POD_NAME
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ def specs(dir)
4
+ FileList["spec/#{dir}/*_spec.rb"].shuffle.join(' ')
5
+ end
6
+
7
+ desc 'Runs all the specs'
8
+ task :specs do
9
+ sh "bundle exec bacon #{specs('**')}"
10
+ end
11
+
12
+ task :default => :specs
13
+
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cocoapods-bin/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cocoapods-bin'
8
+ spec.version = CBin::VERSION
9
+ spec.authors = ['tripleCC']
10
+ spec.email = ['triplec.linux@gmail.com']
11
+ spec.description = %q{组件二进制化插件.}
12
+ spec.summary = %q{组件二进制化插件。利用源码私有源与二进制私有源实现对组件依赖类型的切换.}
13
+ spec.homepage = 'https://github.com/EXAMPLE/cocoapods-bin'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'parallel'
22
+ spec.add_dependency 'cocoapods', '~> 1.4'
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.3'
25
+ spec.add_development_dependency 'rake'
26
+ end
@@ -0,0 +1,66 @@
1
+ require 'cocoapods-bin/config/config_asker'
2
+
3
+ module Pod
4
+ class Command
5
+ class Bin < Command
6
+ class Init < Bin
7
+ self.summary = '初始化插件.'
8
+ self.description = <<-DESC
9
+ 创建 #{CBin.config.config_file} 文件,在其中保存插件需要的配置信息,
10
+ 如二进制私有源地址、源码私有源地址等。
11
+ DESC
12
+
13
+ def self.options
14
+ [
15
+ ['--bin-url=URL', '配置文件地址,直接从此地址下载配置文件'],
16
+ ].concat(super)
17
+ end
18
+
19
+
20
+ def initialize(argv)
21
+ @bin_url = argv.option('bin-url')
22
+ super
23
+ end
24
+
25
+ def run
26
+ if @bin_url.nil?
27
+ config_with_asker
28
+ else
29
+ config_with_url(@bin_url)
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ def config_with_url(url)
36
+ require 'open-uri'
37
+
38
+ UI.puts "开始下载配置文件...\n"
39
+ file = open(url)
40
+ contents = YAML.load(file.read)
41
+
42
+ UI.puts "开始同步配置文件...\n"
43
+ CBin.config.sync_config(contents.to_hash)
44
+ UI.puts "设置完成.\n".green
45
+ rescue Errno::ENOENT => error
46
+ raise Informative, "配置文件路径 #{url} 无效,请确认后重试."
47
+ end
48
+
49
+ def config_with_asker
50
+ asker = CBin::Config::Asker.new
51
+ asker.wellcome_message
52
+
53
+ config = {}
54
+ template_hash = CBin.config.template_hash
55
+ template_hash.each do |k, v|
56
+ default = CBin.config.send(k) rescue nil
57
+ config[k] = asker.ask_with_answer(v, default)
58
+ end
59
+
60
+ CBin.config.sync_config(config)
61
+ asker.done_message
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,94 @@
1
+ require 'cocoapods-bin/config/config'
2
+ require 'cocoapods-bin/native'
3
+
4
+ module Pod
5
+ class Command
6
+ class Bin < Command
7
+ class Lib < Bin
8
+ class Lint < Lib
9
+ self.summary = 'lint 组件.'
10
+ self.description = <<-DESC
11
+ lint 二进制组件 / 源码组件
12
+ DESC
13
+
14
+ self.arguments = [
15
+ CLAide::Argument.new('NAME.podspec', false),
16
+ ]
17
+
18
+ def self.options
19
+ [
20
+ ['--binary', 'lint 组件的二进制版本'],
21
+ ['--code-dependencies', '使用源码依赖进行 lint'],
22
+ ['--loose-options', '添加宽松的 options, 可能包括 --use-libraries (可能会造成 entry point (start) undefined)'],
23
+ ['--reserve-created-spec', '保留生成的二进制 spec 文件'],
24
+ ].concat(Pod::Command::Lib::Lint.options).concat(super).uniq
25
+ end
26
+
27
+ def initialize(argv)
28
+ @podspec = argv.shift_argument
29
+ @binary = argv.flag?('binary')
30
+ @loose_options = argv.flag?('loose-options')
31
+ @code_dependencies = argv.flag?('code-dependencies')
32
+ @sources = argv.option('sources') || []
33
+ @reserve_created_spec = argv.flag?('reserve-created-spec')
34
+ super
35
+
36
+ @additional_args = argv.remainder!
37
+ end
38
+
39
+ def run
40
+ Podfile.execute_with_use_binaries(!@code_dependencies) do
41
+ argvs = [
42
+ spec_file,
43
+ "--sources=#{sources_option(@code_dependencies, @sources)}",
44
+ *@additional_args
45
+ ]
46
+
47
+ if @loose_options
48
+ argvs << '--allow-warnings'
49
+ argvs << '--use-libraries' if spec.all_dependencies.any?
50
+ end
51
+
52
+
53
+ lint = Pod::Command::Lib::Lint.new(CLAide::ARGV.new(argvs))
54
+ lint.validate!
55
+ lint.run
56
+ end
57
+ ensure
58
+ @spec_generator.clear_spec_file if @spec_generator && !@reserve_created_spec
59
+ end
60
+
61
+ private
62
+
63
+ def spec
64
+ Pod::Specification.from_file(spec_file)
65
+ end
66
+
67
+ def spec_file
68
+ @spec_file ||= begin
69
+ if @podspec
70
+ path = Pathname(@podspec)
71
+ raise Informative, "Couldn't find #{@podspec}" unless path.exist?
72
+ path
73
+ else
74
+ raise Informative, "Couldn't find any podspec files in current directory" if spec_files.empty?
75
+ raise Informative, "Couldn't find any code podspec files in current directory" if code_spec_files.empty? && !@binary
76
+ path = code_spec_files.first
77
+ path = binary_spec_files.first || generate_binary_spec_file(path) if @binary
78
+ path
79
+ end
80
+ end
81
+ end
82
+
83
+ def generate_binary_spec_file(code_spec_path)
84
+ spec = Pod::Specification.from_file(code_spec_path)
85
+ @spec_generator = CBin::SpecGenerator.new(spec)
86
+ @spec_generator.generate
87
+ @spec_generator.write_to_spec_file
88
+ @spec_generator.filename
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,12 @@
1
+ require 'cocoapods-bin/command/bin/lib/lint'
2
+
3
+ module Pod
4
+ class Command
5
+ class Bin < Command
6
+ class Lib < Bin
7
+ self.abstract_command = true
8
+ self.summary = '管理二进制 pod.'
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,60 @@
1
+ module Pod
2
+ class Command
3
+ class Bin < Command
4
+ class Open < Bin
5
+ self.summary = '打开 workspace 工程.'
6
+
7
+ def self.options
8
+ [
9
+ ['--install', '先执行 install, 再执行 open. 相当于 pod install && pod bin open'],
10
+ ['--update', '先执行 update, 再执行 open. 相当于 pod update && pod bin open'],
11
+ ['--deep=5', '查找深度.'],
12
+ ]
13
+ end
14
+
15
+ def initialize(argv)
16
+ @install = argv.flag?('install')
17
+ @update = argv.flag?('update')
18
+ @deep = argv.option('deep').try(:to_i) || 3
19
+ super
20
+ end
21
+
22
+ def run
23
+ if @install || @update
24
+ command_class = Object.const_get("Pod::Command::#{@install ? 'Install' : 'Update'}")
25
+ command = command_class.new(CLAide::ARGV.new([]))
26
+ command.validate!
27
+ command.run
28
+ end
29
+
30
+
31
+ path = find_in_children(Pathname.pwd.children, @deep) ||
32
+ find_in_parent(Pathname.pwd.parent, @deep)
33
+ if path
34
+ `open #{path}`
35
+ else
36
+ UI.puts "#{Pathname.pwd} 目录, 搜索上下深度 #{@deep} , 无法找到 xcworkspace 文件.".red
37
+ end
38
+ end
39
+
40
+ def find_in_children(paths, deep)
41
+ deep -= 1
42
+ pathname = paths.find { |ph| ph.extname == '.xcworkspace' }
43
+
44
+ return pathname if pathname || paths.empty? || deep <= 0
45
+
46
+ find_in_children(paths.select(&:directory?).flat_map(&:children), deep)
47
+ end
48
+
49
+ def find_in_parent(path, deep)
50
+ deep -= 1
51
+ pathname = path.children.find {|fn| fn.extname == '.xcworkspace'}
52
+
53
+ return pathname if pathname || deep <= 0
54
+
55
+ find_in_parent(path.parent, deep)
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,98 @@
1
+ require 'cocoapods-bin/config/config'
2
+ require 'cocoapods-bin/native'
3
+
4
+ module Pod
5
+ class Command
6
+ class Bin < Command
7
+ class Repo < Bin
8
+ class Push < Repo
9
+ self.summary = '发布组件.'
10
+ self.description = <<-DESC
11
+ 发布二进制组件 / 源码组件
12
+ DESC
13
+
14
+ self.arguments = [
15
+ CLAide::Argument.new('NAME.podspec', false),
16
+ ]
17
+
18
+ def self.options
19
+ [
20
+ ['--binary', '发布组件的二进制版本'],
21
+ ['--code-dependencies', '使用源码依赖进行 lint'],
22
+ ['--loose-options', '添加宽松的 options, 可能包括 --use-libraries (可能会造成 entry point (start) undefined)'],
23
+ ['--reserve-created-spec', '保留生成的二进制 spec 文件'],
24
+ ].concat(Pod::Command::Repo::Push.options).concat(super).uniq
25
+ end
26
+
27
+ def initialize(argv)
28
+ @podspec = argv.shift_argument
29
+ @binary = argv.flag?('binary')
30
+ @loose_options = argv.flag?('loose-options')
31
+ @code_dependencies = argv.flag?('code-dependencies')
32
+ @sources = argv.option('sources') || []
33
+ @reserve_created_spec = argv.flag?('reserve-created-spec')
34
+ super
35
+
36
+ @additional_args = argv.remainder!
37
+ end
38
+
39
+ def run
40
+ Podfile.execute_with_use_binaries(!@code_dependencies) do
41
+ argvs = [
42
+ repo,
43
+ spec_file,
44
+ "--sources=#{sources_option(@code_dependencies, @sources)}",
45
+ *@additional_args
46
+ ]
47
+
48
+ if @loose_options
49
+ argvs += ['--allow-warnings', '--use-json']
50
+ argvs << '--use-libraries' if spec.all_dependencies.any?
51
+ end
52
+
53
+ push = Pod::Command::Repo::Push.new(CLAide::ARGV.new(argvs))
54
+ push.validate!
55
+ push.run
56
+ end
57
+ ensure
58
+ @spec_generator.clear_spec_file if @spec_generator && !@reserve_created_spec
59
+ end
60
+
61
+ private
62
+
63
+ def spec
64
+ Pod::Specification.from_file(spec_file)
65
+ end
66
+
67
+ def spec_file
68
+ @spec_file ||= begin
69
+ if @podspec
70
+ path = Pathname(@podspec)
71
+ raise Informative, "Couldn't find #{@podspec}" unless path.exist?
72
+ path
73
+ else
74
+ raise Informative, "Couldn't find any podspec files in current directory" if spec_files.empty?
75
+ raise Informative, "Couldn't find any code podspec files in current directory" if code_spec_files.empty? && !@binary
76
+ path = code_spec_files.first
77
+ path = binary_spec_files.first || generate_binary_spec_file(path) if @binary
78
+ path
79
+ end
80
+ end
81
+ end
82
+
83
+ def generate_binary_spec_file(code_spec_path)
84
+ spec = Pod::Specification.from_file(code_spec_path)
85
+ @spec_generator = CBin::SpecGenerator.new(spec)
86
+ @spec_generator.generate
87
+ @spec_generator.write_to_spec_file
88
+ @spec_generator.filename
89
+ end
90
+
91
+ def repo
92
+ @binary ? binary_source.name : code_source.name
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,12 @@
1
+ require 'cocoapods-bin/command/bin/repo/push'
2
+
3
+ module Pod
4
+ class Command
5
+ class Bin < Command
6
+ class Repo < Bin
7
+ self.abstract_command = true
8
+ self.summary = '管理 spec 仓库.'
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,68 @@
1
+ require 'cocoapods-bin/helpers/spec_generator'
2
+
3
+ module Pod
4
+ class Command
5
+ class Bin < Command
6
+ class Spec < Bin
7
+ class Create < Spec
8
+ self.summary = '创建二进制 spec.'
9
+ self.description = <<-DESC
10
+ 根据源码 podspec 文件,创建对应的二进制 podspec 文件.
11
+ DESC
12
+
13
+ self.arguments = [
14
+ CLAide::Argument.new('NAME.podspec', false),
15
+ ]
16
+
17
+ def self.options
18
+ [
19
+ ['--platforms=ios', '生成二进制 spec 支持的平台'],
20
+ ['--no-overwrite', '不允许覆盖']
21
+ ].concat(super)
22
+ end
23
+
24
+ def initialize(argv)
25
+ @platforms = argv.option('platforms') || 'ios'
26
+ @allow_overwrite = argv.flag?('overwrite', true)
27
+ @podspec = argv.shift_argument
28
+ super
29
+ end
30
+
31
+ def run
32
+
33
+ UI.puts "开始读取 #{podspec_file} 文件...\n"
34
+ spec = Pod::Specification.from_file(podspec_file)
35
+
36
+ UI.puts "开始生成二进制 podspec 文件...\n"
37
+ spec_generator = CBin::SpecGenerator.new(spec, @platforms)
38
+ spec_generator.generate
39
+
40
+ UI.puts "开始保存 #{spec_generator.filename} 文件至当前目录...\n"
41
+
42
+ if File.exist?(spec_generator.filename) && !@allow_overwrite
43
+ UI.warn "二进制 podspec 文件 #{spec_generator.filename} 已存在.\n"
44
+ else
45
+ spec_generator.write_to_spec_file
46
+ UI.puts "创建二进制 podspec 文件成功.\n".green
47
+ end
48
+ end
49
+
50
+ private
51
+
52
+ def podspec_file
53
+ @podspec_file ||= begin
54
+ if @podspec
55
+ path = Pathname(@podspec)
56
+ raise Informative, "Couldn't find #{@podspec}" unless path.exist?
57
+ path
58
+ else
59
+ raise Informative, "Couldn't find any valid podspec files in current directory" if code_spec_files.empty?
60
+ code_spec_files.first
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,52 @@
1
+ require 'cocoapods-bin/config/config'
2
+ require 'cocoapods-bin/native'
3
+
4
+ module Pod
5
+ class Command
6
+ class Bin < Command
7
+ class Spec < Bin
8
+ class Lint < Spec
9
+ self.summary = 'lint spec.'
10
+ self.description = <<-DESC
11
+ spec lint 二进制组件 / 源码组件
12
+ DESC
13
+
14
+ self.arguments = [
15
+ CLAide::Argument.new(%w(NAME.podspec DIRECTORY http://PATH/NAME.podspec), false, true)
16
+ ]
17
+
18
+ def self.options
19
+ [
20
+ ['--code-dependencies', '使用源码依赖进行 lint'],
21
+ ['--loose-options', '添加宽松的 options'],
22
+ ].concat(Pod::Command::Lib::Spec.options).concat(super).uniq
23
+ end
24
+
25
+ def initialize(argv)
26
+ @loose_options = argv.flag?('loose-options')
27
+ @code_dependencies = argv.flag?('code-dependencies')
28
+ @sources = argv.option('sources') || []
29
+ super
30
+
31
+ @additional_args = argv.remainder!
32
+ end
33
+
34
+ def run
35
+ Podfile.execute_with_use_binaries(!@code_dependencies) do
36
+ argvs = [
37
+ "--sources=#{sources_option(@code_dependencies, @sources)}",
38
+ *@additional_args
39
+ ]
40
+
41
+ argvs += ['--allow-warnings', '--use-libraries'] if @loose_options
42
+
43
+ lint = Pod::Command::Spec::Lint.new(CLAide::ARGV.new(argvs))
44
+ lint.validate!
45
+ lint.run
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end