cocoapods-miBin 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -0
  3. data/.rakeTasks +7 -0
  4. data/Gemfile +13 -0
  5. data/Gemfile.lock +104 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +522 -0
  8. data/Rakefile +13 -0
  9. data/cocoapods-miBin.gemspec +27 -0
  10. data/lib/cocoapods-miBin.rb +4 -0
  11. data/lib/cocoapods-miBin/command.rb +3 -0
  12. data/lib/cocoapods-miBin/command/bin.rb +60 -0
  13. data/lib/cocoapods-miBin/command/bin/archive.rb +134 -0
  14. data/lib/cocoapods-miBin/command/bin/init.rb +71 -0
  15. data/lib/cocoapods-miBin/command/bin/lib.rb +14 -0
  16. data/lib/cocoapods-miBin/command/bin/lib/lint.rb +69 -0
  17. data/lib/cocoapods-miBin/command/bin/list.rb +50 -0
  18. data/lib/cocoapods-miBin/command/bin/open.rb +61 -0
  19. data/lib/cocoapods-miBin/command/bin/repo.rb +15 -0
  20. data/lib/cocoapods-miBin/command/bin/repo/push.rb +116 -0
  21. data/lib/cocoapods-miBin/command/bin/repo/update.rb +42 -0
  22. data/lib/cocoapods-miBin/command/bin/search.rb +69 -0
  23. data/lib/cocoapods-miBin/command/bin/spec.rb +15 -0
  24. data/lib/cocoapods-miBin/command/bin/spec/create.rb +75 -0
  25. data/lib/cocoapods-miBin/command/bin/spec/lint.rb +111 -0
  26. data/lib/cocoapods-miBin/command/bin/umbrella.rb +55 -0
  27. data/lib/cocoapods-miBin/config/config.rb +81 -0
  28. data/lib/cocoapods-miBin/config/config_asker.rb +58 -0
  29. data/lib/cocoapods-miBin/gem_version.rb +11 -0
  30. data/lib/cocoapods-miBin/helpers.rb +5 -0
  31. data/lib/cocoapods-miBin/helpers/framework.rb +64 -0
  32. data/lib/cocoapods-miBin/helpers/framework_builder.rb +227 -0
  33. data/lib/cocoapods-miBin/helpers/sources_helper.rb +33 -0
  34. data/lib/cocoapods-miBin/helpers/spec_creator.rb +159 -0
  35. data/lib/cocoapods-miBin/helpers/spec_files_helper.rb +77 -0
  36. data/lib/cocoapods-miBin/native.rb +21 -0
  37. data/lib/cocoapods-miBin/native/acknowledgements.rb +27 -0
  38. data/lib/cocoapods-miBin/native/analyzer.rb +53 -0
  39. data/lib/cocoapods-miBin/native/installation_options.rb +26 -0
  40. data/lib/cocoapods-miBin/native/installer.rb +116 -0
  41. data/lib/cocoapods-miBin/native/linter.rb +26 -0
  42. data/lib/cocoapods-miBin/native/path_source.rb +33 -0
  43. data/lib/cocoapods-miBin/native/pod_source_installer.rb +19 -0
  44. data/lib/cocoapods-miBin/native/pod_target.rb +8 -0
  45. data/lib/cocoapods-miBin/native/podfile.rb +79 -0
  46. data/lib/cocoapods-miBin/native/podfile_env.rb +36 -0
  47. data/lib/cocoapods-miBin/native/podspec_finder.rb +25 -0
  48. data/lib/cocoapods-miBin/native/resolver.rb +200 -0
  49. data/lib/cocoapods-miBin/native/sandbox_analyzer.rb +34 -0
  50. data/lib/cocoapods-miBin/native/source.rb +35 -0
  51. data/lib/cocoapods-miBin/native/sources_manager.rb +20 -0
  52. data/lib/cocoapods-miBin/native/specification.rb +31 -0
  53. data/lib/cocoapods-miBin/native/validator.rb +16 -0
  54. data/lib/cocoapods-miBin/source_provider_hook.rb +21 -0
  55. data/lib/cocoapods_plugin.rb +5 -0
  56. data/spec/command/bin_spec.rb +12 -0
  57. data/spec/spec_helper.rb +50 -0
  58. metadata +173 -0
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pod
4
+ class Command
5
+ class Bin < Command
6
+ class Open < Bin
7
+ self.summary = '打开 workspace 工程.'
8
+
9
+ def self.options
10
+ [
11
+ ['--install', '先执行 install, 再执行 open. 相当于 pod install && pod bin open'],
12
+ ['--update', '先执行 update, 再执行 open. 相当于 pod update && pod bin open'],
13
+ ['--deep=5', '查找深度.']
14
+ ]
15
+ end
16
+
17
+ def initialize(argv)
18
+ @install = argv.flag?('install')
19
+ @update = argv.flag?('update')
20
+ @deep = argv.option('deep').try(:to_i) || 3
21
+ super
22
+ end
23
+
24
+ def run
25
+ if @install || @update
26
+ command_class = Object.const_get("Pod::Command::#{@install ? 'Install' : 'Update'}")
27
+ command = command_class.new(CLAide::ARGV.new([]))
28
+ command.validate!
29
+ command.run
30
+ end
31
+
32
+ path = find_in_children(Pathname.pwd.children, @deep) ||
33
+ find_in_parent(Pathname.pwd.parent, @deep)
34
+ if path
35
+ `open #{path}`
36
+ else
37
+ UI.puts "#{Pathname.pwd} 目录, 搜索上下深度 #{@deep} , 无法找到 xcworkspace 文件.".red
38
+ end
39
+ end
40
+
41
+ def find_in_children(paths, deep)
42
+ deep -= 1
43
+ pathname = paths.find { |ph| ph.extname == '.xcworkspace' }
44
+
45
+ return pathname if pathname || paths.empty? || deep <= 0
46
+
47
+ find_in_children(paths.select(&:directory?).flat_map(&:children), deep)
48
+ end
49
+
50
+ def find_in_parent(path, deep)
51
+ deep -= 1
52
+ pathname = path.children.find { |fn| fn.extname == '.xcworkspace' }
53
+
54
+ return pathname if pathname || deep <= 0
55
+
56
+ find_in_parent(path.parent, deep)
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cocoapods-miBin/command/bin/repo/push'
4
+ require 'cocoapods-miBin/command/bin/repo/update'
5
+
6
+ module Pod
7
+ class Command
8
+ class Bin < Command
9
+ class Repo < Bin
10
+ self.abstract_command = true
11
+ self.summary = '管理 spec 仓库.'
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,116 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cocoapods-miBin/config/config'
4
+ require 'cocoapods-miBin/native/podfile'
5
+
6
+ module Pod
7
+ class Command
8
+ class Bin < Command
9
+ class Repo < Bin
10
+ class Push < Repo
11
+ self.summary = '发布组件.'
12
+ self.description = <<-DESC
13
+ 发布二进制组件 / 源码组件
14
+ DESC
15
+
16
+ self.arguments = [
17
+ CLAide::Argument.new('NAME.podspec', false)
18
+ ]
19
+
20
+ def self.options
21
+ [
22
+ ['--binary', '发布组件的二进制版本'],
23
+ ['--template-podspec=A.binary-template.podspec', '生成拥有 subspec 的二进制 spec 需要的模版 podspec, 插件会更改 version 和 source'],
24
+ ['--reserve-created-spec', '保留生成的二进制 spec 文件'],
25
+ ['--code-dependencies', '使用源码依赖进行 lint'],
26
+ ['--loose-options', '添加宽松的 options, 包括 --use-libraries (可能会造成 entry point (start) undefined)'],
27
+ ['--allow-prerelease', '允许使用 prerelease 的版本 lint']
28
+ ].concat(Pod::Command::Repo::Push.options).concat(super).uniq
29
+ end
30
+
31
+ def initialize(argv)
32
+ @podspec = argv.shift_argument
33
+ @binary = argv.flag?('binary')
34
+ @loose_options = argv.flag?('loose-options')
35
+ @code_dependencies = argv.flag?('code-dependencies')
36
+ @sources = argv.option('sources') || []
37
+ @reserve_created_spec = argv.flag?('reserve-created-spec')
38
+ @template_podspec = argv.option('template-podspec')
39
+ @allow_prerelease = argv.flag?('allow-prerelease')
40
+ super
41
+
42
+ @additional_args = argv.remainder!
43
+ end
44
+
45
+ def run
46
+ Podfile.execute_with_bin_plugin do
47
+ Podfile.execute_with_allow_prerelease(@allow_prerelease) do
48
+ Podfile.execute_with_use_binaries(!@code_dependencies) do
49
+ argvs = [
50
+ repo,
51
+ "--sources=#{sources_option(@code_dependencies, @sources)}",
52
+ *@additional_args
53
+ ]
54
+
55
+ argvs << spec_file if spec_file
56
+
57
+ if @loose_options
58
+ argvs += ['--allow-warnings', '--use-json']
59
+ if code_spec&.all_dependencies&.any?
60
+ argvs << '--use-libraries'
61
+ end
62
+ end
63
+
64
+ push = Pod::Command::Repo::Push.new(CLAide::ARGV.new(argvs))
65
+ push.validate!
66
+ push.run
67
+ end
68
+ end
69
+ end
70
+ ensure
71
+ clear_binary_spec_file_if_needed unless @reserve_created_spec
72
+ end
73
+
74
+ private
75
+
76
+ def template_spec_file
77
+ @template_spec_file ||= begin
78
+ if @template_podspec
79
+ find_spec_file(@template_podspec)
80
+ else
81
+ binary_template_spec_file
82
+ end
83
+ end
84
+ end
85
+
86
+ def spec_file
87
+ @spec_file ||= begin
88
+ if @podspec
89
+ find_spec_file(@podspec)
90
+ else
91
+ if code_spec_files.empty?
92
+ raise Informative, '当前目录下没有找到可用源码 podspec.'
93
+ end
94
+
95
+ spec_file = if @binary
96
+ code_spec = Pod::Specification.from_file(code_spec_files.first)
97
+ if template_spec_file
98
+ template_spec = Pod::Specification.from_file(template_spec_file)
99
+ end
100
+ create_binary_spec_file(code_spec, template_spec)
101
+ else
102
+ code_spec_files.first
103
+ end
104
+ spec_file
105
+ end
106
+ end
107
+ end
108
+
109
+ def repo
110
+ @binary ? binary_source.name : code_source.name
111
+ end
112
+ end
113
+ end
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'parallel'
4
+
5
+ module Pod
6
+ class Command
7
+ class Bin < Command
8
+ class Repo < Bin
9
+ class Update < Repo
10
+ self.summary = '更新私有源'
11
+
12
+ self.arguments = [
13
+ CLAide::Argument.new('NAME', false)
14
+ ]
15
+
16
+ def self.options
17
+ [
18
+ ['--all', '更新所有私有源,默认只更新二进制相关私有源']
19
+ ].concat(super)
20
+ end
21
+
22
+ def initialize(argv)
23
+ @all = argv.flag?('all')
24
+ @name = argv.shift_argument
25
+ super
26
+ end
27
+
28
+ def run
29
+ show_output = !config.silent?
30
+ if @name || @all
31
+ config.sources_manager.update(@name, show_output)
32
+ else
33
+ Parallel.each(valid_sources, in_threads: 4) do |source|
34
+ source.update(show_output)
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pod
4
+ class Command
5
+ class Bin < Command
6
+ class Search < Bin
7
+ self.summary = '查找二进制 spec.'
8
+
9
+ self.arguments = [
10
+ CLAide::Argument.new('QUERY', true)
11
+ ]
12
+
13
+ def self.options
14
+ [
15
+ ['--code', '查找源码 spec'],
16
+ ['--stats', '展示额外信息'],
17
+ ['--no-pager', '不以 pager 形式展示'],
18
+ ['--regex', '`QUERY` 视为正则']
19
+ ]
20
+ end
21
+
22
+ def initialize(argv)
23
+ @code = argv.flag?('code')
24
+ @stats = argv.flag?('stats')
25
+ @use_pager = argv.flag?('pager', true)
26
+ @use_regex = argv.flag?('regex')
27
+ @query = argv.arguments! unless argv.arguments.empty?
28
+ super
29
+ end
30
+
31
+ def validate!
32
+ super
33
+ help! '必须指定查找的组件.' unless @query
34
+ end
35
+
36
+ def run
37
+ query_regex = @query.reduce([]) do |result, q|
38
+ result << (@use_regex ? q : Regexp.escape(q))
39
+ end.join(' ').strip
40
+
41
+ source = @code ? code_source : binary_source
42
+
43
+ aggregate = Pod::Source::Aggregate.new([source])
44
+ sets = aggregate.search_by_name(query_regex, true)
45
+
46
+ if @use_pager
47
+ UI.with_pager { print_sets(sets) }
48
+ else
49
+ print_sets(sets)
50
+ end
51
+ end
52
+
53
+ def print_sets(sets)
54
+ sets.each do |set|
55
+ begin
56
+ if @stats
57
+ UI.pod(set, :stats)
58
+ else
59
+ UI.pod(set, :normal)
60
+ end
61
+ rescue DSLError
62
+ UI.warn "Skipping `#{set.name}` because the podspec contains errors."
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cocoapods-miBin/command/bin/spec/create'
4
+ require 'cocoapods-miBin/command/bin/spec/lint'
5
+
6
+ module Pod
7
+ class Command
8
+ class Bin < Command
9
+ class Spec < Bin
10
+ self.abstract_command = true
11
+ self.summary = '管理二进制 spec.'
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cocoapods-miBin/helpers'
4
+
5
+ module Pod
6
+ class Command
7
+ class Bin < Command
8
+ class Spec < Bin
9
+ class Create < Spec
10
+ self.summary = '创建二进制 spec.'
11
+ self.description = <<-DESC
12
+ 根据源码 podspec 文件,创建对应的二进制 podspec 文件.
13
+ DESC
14
+
15
+ def self.options
16
+ [
17
+ ['--platforms=ios', '生成二进制 spec 支持的平台'],
18
+ ['--template-podspec=A.binary-template.podspec', '生成拥有 subspec 的二进制 spec 需要的模版 podspec, 插件会更改 version 和 source'],
19
+ ['--no-overwrite', '不允许覆盖']
20
+ ].concat(super)
21
+ end
22
+
23
+ def initialize(argv)
24
+ @platforms = argv.option('platforms', 'ios')
25
+ @allow_overwrite = argv.flag?('overwrite', true)
26
+ @template_podspec = argv.option('template-podspec')
27
+ @podspec = argv.shift_argument
28
+ super
29
+ end
30
+
31
+ def run
32
+ UI.puts "开始读取 podspec 文件...\n"
33
+
34
+ code_spec = Pod::Specification.from_file(spec_file)
35
+ if template_spec_file
36
+ template_spec = Pod::Specification.from_file(template_spec_file)
37
+ end
38
+
39
+ if binary_spec && !@allow_overwrite
40
+ UI.warn "二进制 podspec 文件 #{binary_spec_files.first} 已存在.\n"
41
+ else
42
+ UI.puts "开始生成二进制 podspec 文件...\n"
43
+ spec_file = create_binary_spec_file(code_spec, template_spec)
44
+ UI.puts "创建二进制 podspec 文件 #{spec_file} 成功.\n".green
45
+ end
46
+ end
47
+
48
+ def template_spec_file
49
+ @template_spec_file ||= begin
50
+ if @template_podspec
51
+ find_spec_file(@template_podspec)
52
+ else
53
+ binary_template_spec_file
54
+ end
55
+ end
56
+ end
57
+
58
+ def spec_file
59
+ @spec_file ||= begin
60
+ if @podspec
61
+ find_spec_file(@podspec)
62
+ else
63
+ if code_spec_files.empty?
64
+ raise Informative, '当前目录下没有找到可用源码 podspec.'
65
+ end
66
+
67
+ code_spec_files.first
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,111 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cocoapods-miBin/config/config'
4
+ require 'cocoapods-miBin/native/podfile'
5
+
6
+ module Pod
7
+ class Command
8
+ class Bin < Command
9
+ class Spec < Bin
10
+ class Lint < Spec
11
+ self.summary = 'lint spec.'
12
+ self.description = <<-DESC
13
+ spec lint 二进制组件 / 源码组件
14
+ DESC
15
+
16
+ self.arguments = [
17
+ CLAide::Argument.new(%w[NAME.podspec DIRECTORY http://PATH/NAME.podspec], false, true)
18
+ ]
19
+
20
+ def self.options
21
+ [
22
+ ['--binary', 'lint 组件的二进制版本'],
23
+ ['--template-podspec=A.binary-template.podspec', '生成拥有 subspec 的二进制 spec 需要的模版 podspec, 插件会更改 version 和 source'],
24
+ ['--reserve-created-spec', '保留生成的二进制 spec 文件'],
25
+ ['--code-dependencies', '使用源码依赖进行 lint'],
26
+ ['--loose-options', '添加宽松的 options, 包括 --use-libraries (可能会造成 entry point (start) undefined)'],
27
+ ['--allow-prerelease', '允许使用 prerelease 的版本 lint']
28
+ ].concat(Pod::Command::Spec::Lint.options).concat(super).uniq
29
+ end
30
+
31
+ def initialize(argv)
32
+ @podspec = argv.shift_argument
33
+ @loose_options = argv.flag?('loose-options')
34
+ @code_dependencies = argv.flag?('code-dependencies')
35
+ @sources = argv.option('sources') || []
36
+ @binary = argv.flag?('binary')
37
+ @reserve_created_spec = argv.flag?('reserve-created-spec')
38
+ @template_podspec = argv.option('template-podspec')
39
+ @allow_prerelease = argv.flag?('allow-prerelease')
40
+ super
41
+
42
+ @additional_args = argv.remainder!
43
+ end
44
+
45
+ def run
46
+ Podfile.execute_with_bin_plugin do
47
+ Podfile.execute_with_allow_prerelease(@allow_prerelease) do
48
+ Podfile.execute_with_use_binaries(!@code_dependencies) do
49
+ argvs = [
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']
58
+ if code_spec&.all_dependencies&.any?
59
+ argvs << '--use-libraries'
60
+ end
61
+ end
62
+
63
+ lint = Pod::Command::Spec::Lint.new(CLAide::ARGV.new(argvs))
64
+ lint.validate!
65
+ lint.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) || @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
+ end
108
+ end
109
+ end
110
+ end
111
+ end