cocoapods-mtxx-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 (67) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +22 -0
  3. data/README.md +11 -0
  4. data/lib/cocoapods-mtxx-bin/command/bin/archive.rb +206 -0
  5. data/lib/cocoapods-mtxx-bin/command/bin/auto.rb +212 -0
  6. data/lib/cocoapods-mtxx-bin/command/bin/code.rb +232 -0
  7. data/lib/cocoapods-mtxx-bin/command/bin/imy.rb +45 -0
  8. data/lib/cocoapods-mtxx-bin/command/bin/init.rb +94 -0
  9. data/lib/cocoapods-mtxx-bin/command/bin/initHotKey.rb +70 -0
  10. data/lib/cocoapods-mtxx-bin/command/bin/install.rb +44 -0
  11. data/lib/cocoapods-mtxx-bin/command/bin/lib/lint.rb +67 -0
  12. data/lib/cocoapods-mtxx-bin/command/bin/repo/push.rb +115 -0
  13. data/lib/cocoapods-mtxx-bin/command/bin/repo/update.rb +42 -0
  14. data/lib/cocoapods-mtxx-bin/command/bin/repo.rb +14 -0
  15. data/lib/cocoapods-mtxx-bin/command/bin/spec/create.rb +73 -0
  16. data/lib/cocoapods-mtxx-bin/command/bin/spec/lint.rb +109 -0
  17. data/lib/cocoapods-mtxx-bin/command/bin/spec.rb +13 -0
  18. data/lib/cocoapods-mtxx-bin/command/bin/update.rb +154 -0
  19. data/lib/cocoapods-mtxx-bin/command/bin.rb +65 -0
  20. data/lib/cocoapods-mtxx-bin/command.rb +1 -0
  21. data/lib/cocoapods-mtxx-bin/config/config.rb +166 -0
  22. data/lib/cocoapods-mtxx-bin/config/config_asker.rb +60 -0
  23. data/lib/cocoapods-mtxx-bin/config/config_builder.rb +216 -0
  24. data/lib/cocoapods-mtxx-bin/config/config_hot_key.rb +103 -0
  25. data/lib/cocoapods-mtxx-bin/config/config_hot_key_asker.rb +57 -0
  26. data/lib/cocoapods-mtxx-bin/gem_version.rb +9 -0
  27. data/lib/cocoapods-mtxx-bin/helpers/Info.plist +0 -0
  28. data/lib/cocoapods-mtxx-bin/helpers/build_helper.rb +167 -0
  29. data/lib/cocoapods-mtxx-bin/helpers/build_utils.rb +64 -0
  30. data/lib/cocoapods-mtxx-bin/helpers/framework.rb +86 -0
  31. data/lib/cocoapods-mtxx-bin/helpers/framework_builder.rb +551 -0
  32. data/lib/cocoapods-mtxx-bin/helpers/library.rb +54 -0
  33. data/lib/cocoapods-mtxx-bin/helpers/library_builder.rb +90 -0
  34. data/lib/cocoapods-mtxx-bin/helpers/sources_helper.rb +35 -0
  35. data/lib/cocoapods-mtxx-bin/helpers/spec_creator.rb +170 -0
  36. data/lib/cocoapods-mtxx-bin/helpers/spec_files_helper.rb +80 -0
  37. data/lib/cocoapods-mtxx-bin/helpers/spec_source_creator.rb +304 -0
  38. data/lib/cocoapods-mtxx-bin/helpers/upload_helper.rb +104 -0
  39. data/lib/cocoapods-mtxx-bin/helpers.rb +5 -0
  40. data/lib/cocoapods-mtxx-bin/native/acknowledgements.rb +27 -0
  41. data/lib/cocoapods-mtxx-bin/native/analyzer.rb +85 -0
  42. data/lib/cocoapods-mtxx-bin/native/file_accessor.rb +28 -0
  43. data/lib/cocoapods-mtxx-bin/native/gen.rb +79 -0
  44. data/lib/cocoapods-mtxx-bin/native/installation_options.rb +25 -0
  45. data/lib/cocoapods-mtxx-bin/native/installer.rb +135 -0
  46. data/lib/cocoapods-mtxx-bin/native/linter.rb +26 -0
  47. data/lib/cocoapods-mtxx-bin/native/path_source.rb +33 -0
  48. data/lib/cocoapods-mtxx-bin/native/pod_source_installer.rb +19 -0
  49. data/lib/cocoapods-mtxx-bin/native/pod_target_installer.rb +94 -0
  50. data/lib/cocoapods-mtxx-bin/native/podfile.rb +91 -0
  51. data/lib/cocoapods-mtxx-bin/native/podfile_env.rb +37 -0
  52. data/lib/cocoapods-mtxx-bin/native/podfile_generator.rb +201 -0
  53. data/lib/cocoapods-mtxx-bin/native/podspec_finder.rb +25 -0
  54. data/lib/cocoapods-mtxx-bin/native/resolver.rb +238 -0
  55. data/lib/cocoapods-mtxx-bin/native/sandbox_analyzer.rb +34 -0
  56. data/lib/cocoapods-mtxx-bin/native/source.rb +35 -0
  57. data/lib/cocoapods-mtxx-bin/native/sources_manager.rb +19 -0
  58. data/lib/cocoapods-mtxx-bin/native/specification.rb +31 -0
  59. data/lib/cocoapods-mtxx-bin/native/target_validator.rb +41 -0
  60. data/lib/cocoapods-mtxx-bin/native/validator.rb +40 -0
  61. data/lib/cocoapods-mtxx-bin/native.rb +25 -0
  62. data/lib/cocoapods-mtxx-bin/source_provider_hook.rb +53 -0
  63. data/lib/cocoapods-mtxx-bin.rb +2 -0
  64. data/lib/cocoapods_plugin.rb +2 -0
  65. data/spec/command/bin_spec.rb +12 -0
  66. data/spec/spec_helper.rb +50 -0
  67. metadata +182 -0
@@ -0,0 +1,45 @@
1
+ require 'cocoapods-mtxx-bin/config/config_hot_key_asker'
2
+
3
+ module Pod
4
+ class Command
5
+ class Bin < Command
6
+ class Imy < Bin
7
+ self.summary = '设置快捷键'
8
+ self.description = <<-DESC
9
+ 设置快捷键
10
+ DESC
11
+
12
+ self.arguments = [
13
+ CLAide::Argument.new('1', false)
14
+ ]
15
+
16
+ def self.options
17
+ [
18
+ ].concat(super)
19
+ end
20
+
21
+ def initialize(argv)
22
+ @hot_key = argv.shift_argument || '1'
23
+ super
24
+ end
25
+
26
+ def run
27
+ CBin.config_hot_key.set_hot_key_index(@hot_key)
28
+ UI.puts "cd #{CBin.config_hot_key.hot_key_dir}".yellow
29
+
30
+ if Dir.exist?(CBin.config_hot_key.hot_key_dir)
31
+ Dir.chdir(CBin.config_hot_key.hot_key_dir) do
32
+ UI.puts " #{CBin.config_hot_key.hot_key_cmd}".yellow
33
+ system CBin.config_hot_key.hot_key_cmd
34
+ end
35
+ else
36
+ raise "配置项中文件目录不存在 #{CBin.config_hot_key.hot_key_dir}"
37
+ end
38
+
39
+
40
+ end
41
+
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,94 @@
1
+ require 'cocoapods-mtxx-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
+ 创建yml配置文件,保存插件需要的配置信息,如源码podspec仓库、二进制下载地址等
10
+ DESC
11
+
12
+ def self.options
13
+ [
14
+ ['--bin-url=URL', '配置文件地址,直接从此地址下载配置文件'],
15
+ ['--update-sources', '更新源码私有源配置 bin_dev.yml 中的 code_repo_url_list 配置,支持多私有源,多个私有源用分号区分 example:git@techgit.meitu.com:iMeituPic/mtsourcespecs.git;git@techgit.meitu.com:iosmodules/specs.git;https://github.com/CocoaPods/Specs.git']
16
+ ].concat(super)
17
+ end
18
+
19
+ def initialize(argv)
20
+ @bin_url = argv.option('bin-url')
21
+ @update_sources = argv.flag?('update-sources')
22
+ super
23
+ end
24
+
25
+ def run
26
+ if @update_sources
27
+ update_code_repo_url_list
28
+ else
29
+ if @bin_url.nil?
30
+ config_with_asker
31
+ else
32
+ config_with_url(@bin_url)
33
+ end
34
+ end
35
+
36
+ end
37
+
38
+ private
39
+
40
+ def config_with_url(url)
41
+ require 'open-uri'
42
+
43
+ UI.puts "开始下载配置文件...\n"
44
+ file = open(url)
45
+ contents = YAML.safe_load(file.read)
46
+
47
+ UI.puts "开始同步配置文件...\n"
48
+ CBin.config.sync_config(contents.to_hash)
49
+ UI.puts "设置完成.\n".green
50
+ rescue Errno::ENOENT => e
51
+ raise Informative, "配置文件路径 #{url} 无效,请确认后重试."
52
+ end
53
+
54
+ def config_with_asker
55
+ asker = CBin::Config::Asker.new
56
+ asker.wellcome_message
57
+
58
+ config = {}
59
+ template_hash = CBin.config.template_hash
60
+ template_hash.each do |k, v|
61
+ default = begin
62
+ CBin.config.send(k)
63
+ rescue StandardError
64
+ nil
65
+ end
66
+ config[k] = asker.ask_with_answer(v[:description], default, v[:selection])
67
+ end
68
+
69
+ CBin.config.sync_config(config)
70
+ asker.done_message
71
+ end
72
+ def update_code_repo_url_list
73
+ asker = CBin::Config::Asker.new
74
+ config = {}
75
+ template_hash = CBin.config.template_hash
76
+ template_hash.each do |k, v|
77
+ if k == "code_repo_url_list"
78
+ default = begin
79
+ CBin.config.send(k)
80
+ rescue StandardError
81
+ nil
82
+ end
83
+ config[k] = asker.ask_with_answer(v[:description], default, v[:selection])
84
+ else
85
+ config[k] = CBin.config.config_old[k]
86
+ end
87
+ end
88
+ CBin.config.sync_config_code_repo_url_list(config)
89
+ asker.done_message_update
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,70 @@
1
+
2
+ require 'cocoapods-mtxx-bin/config/config_hot_key_asker'
3
+
4
+ module Pod
5
+ class Command
6
+ class Bin < Command
7
+ class Inithk < Bin
8
+ self.summary = '初始化快捷键配置'
9
+ self.description = <<-DESC
10
+ 创建 文件,在其中保存插件需要的配置信息,
11
+ 如二进制私有源地址、源码私有源地址等。
12
+ DESC
13
+
14
+ def self.options
15
+ [
16
+ ['--bin-url=URL', '配置文件地址,直接从此地址下载配置文件']
17
+ ].concat(super)
18
+ end
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.safe_load(file.read)
41
+
42
+ UI.puts "开始同步配置文件...\n"
43
+ CBin.config_hot_key.sync_config(contents.to_hash)
44
+ UI.puts "设置完成.\n".green
45
+ rescue Errno::ENOENT => e
46
+ raise Informative, "配置文件路径 #{url} 无效,请确认后重试."
47
+ end
48
+
49
+ def config_with_asker
50
+ asker = CBin::Config_Hot_Key::Asker.new
51
+ asker.wellcome_message
52
+
53
+ config = {}
54
+ template_hash = CBin.config_hot_key.template_hash
55
+ template_hash.each do |k, v|
56
+ default = begin
57
+ CBin.config_hot_key.send(k)
58
+ rescue StandardError
59
+ nil
60
+ end
61
+ config[k] = asker.ask_with_answer(v[:description], default, v[:selection])
62
+ end
63
+
64
+ CBin.config_hot_key.sync_config(config)
65
+ asker.done_message
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,44 @@
1
+
2
+ require 'cocoapods-mtxx-bin/command/bin/update'
3
+ module Pod
4
+ class Command
5
+ class Bin < Command
6
+ class Install < Bin
7
+ include Pod
8
+
9
+ self.summary = 'pod install 拦截器'
10
+
11
+ self.description = <<-DESC
12
+ pod install 拦截器,会加载本地Podfile_local文件
13
+ 会通过DSL加载到原始Podfile文件中
14
+ 支持 pod 'xxx' 各种写法
15
+ 支持 post_install/pre_install钩子,采用覆盖做法
16
+ DESC
17
+ def self.options
18
+ [
19
+ ['--repo-update', 'Force running `pod repo update` before install'],
20
+ ['--deployment', 'Disallow any changes to the Podfile or the Podfile.lock during installation'],
21
+ ['--clean-install', 'Ignore the contents of the project cache and force a full pod installation. This only ' \
22
+ 'applies to projects that have enabled incremental installation']
23
+ ].concat(super).reject { |(name, _)| name == '--no-repo-update' }
24
+ end
25
+
26
+ def initialize(argv)
27
+ @update = argv.flag?('update')
28
+ super
29
+ @additional_args = argv.remainder!
30
+ end
31
+
32
+ def run
33
+ Update.load_local_podfile
34
+ argvs = [
35
+ *@additional_args
36
+ ]
37
+ gen = Pod::Command::Install.new(CLAide::ARGV.new(argvs))
38
+ gen.validate!
39
+ gen.run
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,67 @@
1
+ require 'cocoapods-mtxx-bin/config/config'
2
+ require 'cocoapods-mtxx-bin/native/podfile'
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
+ # lib lint 不会下载 source,所以不能进行二进制 lint
19
+ # 要 lint 二进制版本,需要进行 spec lint,此 lint 会去下载 source
20
+ def self.options
21
+ [
22
+ ['--code-dependencies', '使用源码依赖进行 lint'],
23
+ ['--loose-options', '添加宽松的 options, 包括 --use-libraries (可能会造成 entry point (start) undefined)'],
24
+ ['--allow-prerelease', '允许使用 prerelease 的版本 lint']
25
+ ].concat(Pod::Command::Lib::Lint.options).concat(super).uniq
26
+ end
27
+
28
+ def initialize(argv)
29
+ @loose_options = argv.flag?('loose-options')
30
+ @code_dependencies = argv.flag?('code-dependencies')
31
+ @sources = argv.option('sources') || []
32
+ @allow_prerelease = argv.flag?('allow-prerelease')
33
+ @podspec = argv.shift_argument
34
+ super
35
+
36
+ @additional_args = argv.remainder!
37
+ end
38
+
39
+ def run
40
+ Podfile.execute_with_bin_plugin do
41
+ Podfile.execute_with_allow_prerelease(@allow_prerelease) do
42
+ Podfile.execute_with_use_binaries(!@code_dependencies) do
43
+ argvs = [
44
+ @podspec || code_spec_files.first,
45
+ "--sources=#{sources_option(@code_dependencies, @sources)}",
46
+ *@additional_args
47
+ ]
48
+
49
+ if @loose_options
50
+ argvs << '--allow-warnings'
51
+ if code_spec&.all_dependencies&.any?
52
+ argvs << '--use-libraries'
53
+ end
54
+ end
55
+
56
+ lint = Pod::Command::Lib::Lint.new(CLAide::ARGV.new(argvs))
57
+ lint.validate!
58
+ lint.run
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,115 @@
1
+
2
+ require 'cocoapods-mtxx-bin/config/config'
3
+ require 'cocoapods-mtxx-bin/native/podfile'
4
+
5
+ module Pod
6
+ class Command
7
+ class Bin < Command
8
+ class Repo < Bin
9
+ class Push < Repo
10
+ self.summary = '发布组件'
11
+ self.description = <<-DESC
12
+ 发布二进制组件 / 源码组件
13
+ DESC
14
+
15
+ self.arguments = [
16
+ CLAide::Argument.new('NAME.podspec', false )
17
+ ]
18
+
19
+ def self.options
20
+ [
21
+ ['--binary', '发布组件的二进制版本'],
22
+ ['--template-podspec=A.binary-template.podspec', '生成拥有 subspec 的二进制 spec 需要的模版 podspec, 插件会更改 version 和 source'],
23
+ ['--reserve-created-spec', '保留生成的二进制 spec 文件'],
24
+ ['--code-dependencies', '使用源码依赖进行 lint'],
25
+ ['--loose-options', '添加宽松的 options, 包括 --use-libraries (可能会造成 entry point (start) undefined)'],
26
+ ['--allow-prerelease', '允许使用 prerelease 的版本 lint']
27
+ ].concat(Pod::Command::Repo::Push.options).concat(super).uniq
28
+ end
29
+
30
+ def initialize(argv)
31
+ @podspec = argv.shift_argument
32
+ @binary = argv.flag?('binary')
33
+ @loose_options = argv.flag?('loose-options')
34
+ @code_dependencies = argv.flag?('code-dependencies')
35
+ @sources = argv.option('sources') || []
36
+ @reserve_created_spec = argv.flag?('reserve-created-spec')
37
+ @template_podspec = argv.option('template-podspec')
38
+ @allow_prerelease = argv.flag?('allow-prerelease')
39
+ super
40
+
41
+ @additional_args = argv.remainder!
42
+ end
43
+
44
+ def run
45
+ Podfile.execute_with_bin_plugin do
46
+ Podfile.execute_with_allow_prerelease(@allow_prerelease) do
47
+ Podfile.execute_with_use_binaries(!@code_dependencies) do
48
+ argvs = [
49
+ repo,
50
+ "--sources=#{sources_option(@code_dependencies, @sources)}",
51
+ *@additional_args
52
+ ]
53
+
54
+ argvs << spec_file if spec_file
55
+
56
+ if @loose_options
57
+ argvs += ['--allow-warnings', '--use-json']
58
+ # if code_spec&.all_dependencies&.any?
59
+ # argvs << '--use-libraries'
60
+ # end
61
+ end
62
+
63
+ push = Pod::Command::Repo::Push.new(CLAide::ARGV.new(argvs))
64
+ push.validate!
65
+ push.run
66
+ end
67
+ end
68
+ end
69
+ ensure
70
+ clear_binary_spec_file_if_needed unless @reserve_created_spec
71
+ end
72
+
73
+ private
74
+
75
+ def template_spec_file
76
+ @template_spec_file ||= begin
77
+ if @template_podspec
78
+ find_spec_file(@template_podspec)
79
+ else
80
+ binary_template_spec_file
81
+ end
82
+ end
83
+ end
84
+
85
+ def spec_file
86
+ @spec_file ||= begin
87
+ if @podspec
88
+ find_spec_file(@podspec)
89
+ else
90
+ if code_spec_files.empty?
91
+ raise Informative, '当前目录下没有找到可用源码 podspec.'
92
+ end
93
+
94
+ spec_file = if @binary
95
+ code_spec = Pod::Specification.from_file(code_spec_files.first)
96
+ if template_spec_file
97
+ template_spec = Pod::Specification.from_file(template_spec_file)
98
+ end
99
+ create_binary_spec_file(code_spec, template_spec)
100
+ else
101
+ code_spec_files.first
102
+ end
103
+ spec_file
104
+ end
105
+ end
106
+ end
107
+
108
+ def repo
109
+ @binary ? binary_source.name : code_source_list.first.name
110
+ end
111
+ end
112
+ end
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,42 @@
1
+ require 'parallel'
2
+
3
+ module Pod
4
+ class Command
5
+ class Bin < Command
6
+ class Repo < Bin
7
+ class Update < Repo
8
+ self.summary = '更新私有源'
9
+
10
+ self.arguments = [
11
+ CLAide::Argument.new('NAME', false)
12
+ ]
13
+
14
+ def self.options
15
+ [
16
+ ['--all', '更新所有私有源,默认只更新二进制相关私有源']
17
+ ].concat(super)
18
+ end
19
+
20
+ def initialize(argv)
21
+ @all = argv.flag?('all')
22
+ @name = argv.shift_argument
23
+ super
24
+ end
25
+
26
+ def run
27
+ if @all
28
+ config.sources_manager.update()
29
+ else
30
+ valid_sources.map { |source|
31
+ UI.puts "更新私有源仓库 #{source.to_s}"
32
+ source.update(false)
33
+ }
34
+ end
35
+ end
36
+
37
+
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,14 @@
1
+
2
+ require 'cocoapods-mtxx-bin/command/bin/repo/push'
3
+ require 'cocoapods-mtxx-bin/command/bin/repo/update'
4
+
5
+ module Pod
6
+ class Command
7
+ class Bin < Command
8
+ class Repo < Bin
9
+ self.abstract_command = true
10
+ self.summary = '管理 spec 仓库'
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,73 @@
1
+ require 'cocoapods-mtxx-bin/helpers'
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
+ def self.options
14
+ [
15
+ ['--platforms=ios', '生成二进制 spec 支持的平台'],
16
+ ['--template-podspec=A.binary-template.podspec', '生成拥有 subspec 的二进制 spec 需要的模版 podspec, 插件会更改 version 和 source'],
17
+ ['--no-overwrite', '不允许覆盖']
18
+ ].concat(super)
19
+ end
20
+
21
+ def initialize(argv)
22
+ @platforms = argv.option('platforms', 'ios')
23
+ @allow_overwrite = argv.flag?('overwrite', true)
24
+ @template_podspec = argv.option('template-podspec')
25
+ @podspec = argv.shift_argument
26
+ super
27
+ end
28
+
29
+ def run
30
+ UI.puts "开始读取 podspec 文件...\n"
31
+
32
+ code_spec = Pod::Specification.from_file(spec_file)
33
+ if template_spec_file
34
+ template_spec = Pod::Specification.from_file(template_spec_file)
35
+ end
36
+
37
+ if binary_spec && !@allow_overwrite
38
+ UI.warn "二进制 podspec 文件 #{binary_spec_files.first} 已存在.\n"
39
+ else
40
+ UI.puts "开始生成二进制 podspec 文件...\n"
41
+ spec_file = create_binary_spec_file(code_spec, template_spec)
42
+ UI.puts "创建二进制 podspec 文件 #{spec_file} 成功.\n".green
43
+ end
44
+ end
45
+
46
+ def template_spec_file
47
+ @template_spec_file ||= begin
48
+ if @template_podspec
49
+ find_spec_file(@template_podspec)
50
+ else
51
+ binary_template_spec_file
52
+ end
53
+ end
54
+ end
55
+
56
+ def spec_file
57
+ @spec_file ||= begin
58
+ if @podspec
59
+ find_spec_file(@podspec)
60
+ else
61
+ if code_spec_files.empty?
62
+ raise Informative, '当前目录下没有找到可用源码 podspec.'
63
+ end
64
+
65
+ code_spec_files.first
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,109 @@
1
+ require 'cocoapods-mtxx-bin/config/config'
2
+ require 'cocoapods-mtxx-bin/native/podfile'
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
+ ['--binary', 'lint 组件的二进制版本'],
21
+ ['--template-podspec=A.binary-template.podspec', '生成拥有 subspec 的二进制 spec 需要的模版 podspec, 插件会更改 version 和 source'],
22
+ ['--reserve-created-spec', '保留生成的二进制 spec 文件'],
23
+ ['--code-dependencies', '使用源码依赖进行 lint'],
24
+ ['--loose-options', '添加宽松的 options, 包括 --use-libraries (可能会造成 entry point (start) undefined)'],
25
+ ['--allow-prerelease', '允许使用 prerelease 的版本 lint']
26
+ ].concat(Pod::Command::Spec::Lint.options).concat(super).uniq
27
+ end
28
+
29
+ def initialize(argv)
30
+ @podspec = argv.shift_argument
31
+ @loose_options = argv.flag?('loose-options')
32
+ @code_dependencies = argv.flag?('code-dependencies')
33
+ @sources = argv.option('sources') || []
34
+ @binary = argv.flag?('binary')
35
+ @reserve_created_spec = argv.flag?('reserve-created-spec')
36
+ @template_podspec = argv.option('template-podspec')
37
+ @allow_prerelease = argv.flag?('allow-prerelease')
38
+ super
39
+
40
+ @additional_args = argv.remainder!
41
+ end
42
+
43
+ def run
44
+ Podfile.execute_with_bin_plugin do
45
+ Podfile.execute_with_allow_prerelease(@allow_prerelease) do
46
+ Podfile.execute_with_use_binaries(!@code_dependencies) do
47
+ argvs = [
48
+ "--sources=#{sources_option(@code_dependencies, @sources)}",
49
+ *@additional_args
50
+ ]
51
+
52
+ argvs << spec_file if spec_file
53
+
54
+ if @loose_options
55
+ argvs += ['--allow-warnings']
56
+ if code_spec&.all_dependencies&.any?
57
+ argvs << '--use-libraries'
58
+ end
59
+ end
60
+
61
+ lint = Pod::Command::Spec::Lint.new(CLAide::ARGV.new(argvs))
62
+ lint.validate!
63
+ lint.run
64
+ end
65
+ end
66
+ end
67
+ ensure
68
+ clear_binary_spec_file_if_needed unless @reserve_created_spec
69
+ end
70
+
71
+ private
72
+
73
+ def template_spec_file
74
+ @template_spec_file ||= begin
75
+ if @template_podspec
76
+ find_spec_file(@template_podspec)
77
+ else
78
+ binary_template_spec_file
79
+ end
80
+ end
81
+ end
82
+
83
+ def spec_file
84
+ @spec_file ||= begin
85
+ if @podspec
86
+ find_spec_file(@podspec) || @podspec
87
+ else
88
+ if code_spec_files.empty?
89
+ raise Informative, '当前目录下没有找到可用源码 podspec.'
90
+ end
91
+
92
+ spec_file = if @binary
93
+ code_spec = Pod::Specification.from_file(code_spec_files.first)
94
+ if template_spec_file
95
+ template_spec = Pod::Specification.from_file(template_spec_file)
96
+ end
97
+ create_binary_spec_file(code_spec, template_spec)
98
+ else
99
+ code_spec_files.first
100
+ end
101
+ spec_file
102
+ end
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,13 @@
1
+ require 'cocoapods-mtxx-bin/command/bin/spec/create'
2
+ require 'cocoapods-mtxx-bin/command/bin/spec/lint'
3
+
4
+ module Pod
5
+ class Command
6
+ class Bin < Command
7
+ class Spec < Bin
8
+ self.abstract_command = true
9
+ self.summary = '管理二进制 spec'
10
+ end
11
+ end
12
+ end
13
+ end