cocoapods-meitu-bin 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +20 -0
  3. data/README.md +56 -0
  4. data/lib/cocoapods-meitu-bin/command/bin/archive.rb +206 -0
  5. data/lib/cocoapods-meitu-bin/command/bin/auto.rb +212 -0
  6. data/lib/cocoapods-meitu-bin/command/bin/build_all.rb +345 -0
  7. data/lib/cocoapods-meitu-bin/command/bin/header_files_specifications.rb +262 -0
  8. data/lib/cocoapods-meitu-bin/command/bin/init.rb +72 -0
  9. data/lib/cocoapods-meitu-bin/command/bin/install.rb +44 -0
  10. data/lib/cocoapods-meitu-bin/command/bin/lib/lint.rb +67 -0
  11. data/lib/cocoapods-meitu-bin/command/bin/lock/dependency.rb +89 -0
  12. data/lib/cocoapods-meitu-bin/command/bin/lock/spec_repo.rb +105 -0
  13. data/lib/cocoapods-meitu-bin/command/bin/lock/version.rb +68 -0
  14. data/lib/cocoapods-meitu-bin/command/bin/lock.rb +36 -0
  15. data/lib/cocoapods-meitu-bin/command/bin/output_source.rb +146 -0
  16. data/lib/cocoapods-meitu-bin/command/bin/repo/push.rb +88 -0
  17. data/lib/cocoapods-meitu-bin/command/bin/repo/update.rb +42 -0
  18. data/lib/cocoapods-meitu-bin/command/bin/repo.rb +14 -0
  19. data/lib/cocoapods-meitu-bin/command/bin/source/add.rb +148 -0
  20. data/lib/cocoapods-meitu-bin/command/bin/source/delete.rb +59 -0
  21. data/lib/cocoapods-meitu-bin/command/bin/source/list.rb +46 -0
  22. data/lib/cocoapods-meitu-bin/command/bin/source.rb +30 -0
  23. data/lib/cocoapods-meitu-bin/command/bin/spec/create.rb +73 -0
  24. data/lib/cocoapods-meitu-bin/command/bin/spec/lint.rb +109 -0
  25. data/lib/cocoapods-meitu-bin/command/bin/spec.rb +13 -0
  26. data/lib/cocoapods-meitu-bin/command/bin/update.rb +154 -0
  27. data/lib/cocoapods-meitu-bin/command/bin/upload.rb +175 -0
  28. data/lib/cocoapods-meitu-bin/command/bin.rb +69 -0
  29. data/lib/cocoapods-meitu-bin/command.rb +1 -0
  30. data/lib/cocoapods-meitu-bin/config/config.rb +149 -0
  31. data/lib/cocoapods-meitu-bin/config/config_asker.rb +57 -0
  32. data/lib/cocoapods-meitu-bin/config/config_builder.rb +216 -0
  33. data/lib/cocoapods-meitu-bin/gem_version.rb +9 -0
  34. data/lib/cocoapods-meitu-bin/helpers/Info.plist +0 -0
  35. data/lib/cocoapods-meitu-bin/helpers/buildAll/bin_helper.rb +97 -0
  36. data/lib/cocoapods-meitu-bin/helpers/buildAll/builder.rb +434 -0
  37. data/lib/cocoapods-meitu-bin/helpers/buildAll/podspec_util.rb +140 -0
  38. data/lib/cocoapods-meitu-bin/helpers/buildAll/zip_file_helper.rb +87 -0
  39. data/lib/cocoapods-meitu-bin/helpers/build_helper.rb +167 -0
  40. data/lib/cocoapods-meitu-bin/helpers/build_utils.rb +64 -0
  41. data/lib/cocoapods-meitu-bin/helpers/framework.rb +86 -0
  42. data/lib/cocoapods-meitu-bin/helpers/framework_builder.rb +551 -0
  43. data/lib/cocoapods-meitu-bin/helpers/library.rb +54 -0
  44. data/lib/cocoapods-meitu-bin/helpers/library_builder.rb +90 -0
  45. data/lib/cocoapods-meitu-bin/helpers/pod_size_helper.rb +54 -0
  46. data/lib/cocoapods-meitu-bin/helpers/sources_helper.rb +35 -0
  47. data/lib/cocoapods-meitu-bin/helpers/spec_creator.rb +170 -0
  48. data/lib/cocoapods-meitu-bin/helpers/spec_files_helper.rb +80 -0
  49. data/lib/cocoapods-meitu-bin/helpers/spec_source_creator.rb +304 -0
  50. data/lib/cocoapods-meitu-bin/helpers/upload_helper.rb +104 -0
  51. data/lib/cocoapods-meitu-bin/helpers.rb +5 -0
  52. data/lib/cocoapods-meitu-bin/native/acknowledgements.rb +27 -0
  53. data/lib/cocoapods-meitu-bin/native/analyzer.rb +109 -0
  54. data/lib/cocoapods-meitu-bin/native/file_accessor.rb +28 -0
  55. data/lib/cocoapods-meitu-bin/native/gen.rb +79 -0
  56. data/lib/cocoapods-meitu-bin/native/installation_options.rb +28 -0
  57. data/lib/cocoapods-meitu-bin/native/installer.rb +259 -0
  58. data/lib/cocoapods-meitu-bin/native/linter.rb +26 -0
  59. data/lib/cocoapods-meitu-bin/native/lockfile.rb +85 -0
  60. data/lib/cocoapods-meitu-bin/native/path_source.rb +33 -0
  61. data/lib/cocoapods-meitu-bin/native/pod_source_installer.rb +19 -0
  62. data/lib/cocoapods-meitu-bin/native/pod_target_installer.rb +87 -0
  63. data/lib/cocoapods-meitu-bin/native/podfile.rb +99 -0
  64. data/lib/cocoapods-meitu-bin/native/podfile_env.rb +38 -0
  65. data/lib/cocoapods-meitu-bin/native/podfile_generator.rb +201 -0
  66. data/lib/cocoapods-meitu-bin/native/podspec_finder.rb +25 -0
  67. data/lib/cocoapods-meitu-bin/native/resolver.rb +299 -0
  68. data/lib/cocoapods-meitu-bin/native/sandbox_analyzer.rb +34 -0
  69. data/lib/cocoapods-meitu-bin/native/source.rb +35 -0
  70. data/lib/cocoapods-meitu-bin/native/sources_manager.rb +21 -0
  71. data/lib/cocoapods-meitu-bin/native/specification.rb +31 -0
  72. data/lib/cocoapods-meitu-bin/native/target_validator.rb +41 -0
  73. data/lib/cocoapods-meitu-bin/native/validator.rb +40 -0
  74. data/lib/cocoapods-meitu-bin/native.rb +26 -0
  75. data/lib/cocoapods-meitu-bin/source_provider_hook.rb +68 -0
  76. data/lib/cocoapods-meitu-bin.rb +2 -0
  77. data/lib/cocoapods_plugin.rb +11 -0
  78. data/spec/command/bin_spec.rb +12 -0
  79. data/spec/spec_helper.rb +50 -0
  80. metadata +201 -0
@@ -0,0 +1,14 @@
1
+
2
+ require 'cocoapods-meitu-bin/command/bin/repo/push'
3
+ require 'cocoapods-meitu-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,148 @@
1
+
2
+ module Pod
3
+ class Command
4
+ class Bin < Command
5
+ class Source < Bin
6
+ class Add < Source
7
+
8
+ self.summary = '添加二进制对应源码'
9
+ self.description = <<-DESC
10
+ #{self.summary}
11
+ DESC
12
+
13
+ self.arguments = [
14
+ CLAide::Argument.new('NAMES', true )
15
+ ]
16
+
17
+ def initialize(argv)
18
+ @names = argv.shift_argument
19
+ super
20
+ end
21
+
22
+ def run
23
+ raise Informative, "请输入要添加的Pod库名,多个库中间用逗号隔开" if @names.nil?
24
+ # 依赖分析
25
+ @results = analyse
26
+ # 遍历下载
27
+ @names.split(',').each do |name|
28
+ # 查找二进制spec
29
+ bin_spec = find_specification(name)
30
+ if bin_spec.nil?
31
+ UI.puts "未查找到`#{name}`的二进制spec".red
32
+ next
33
+ end
34
+ # 只有版本号最后一位带`bin`的才有源码
35
+ bin_version = bin_spec.version.to_s
36
+ unless has_source?(bin_version)
37
+ UI.puts "`#{name} (#{bin_version})`已经是源码或无法查看源码".red
38
+ next
39
+ end
40
+ # 查找源码spec
41
+ source_spec = find_source_specification(name, bin_version)
42
+ if source_spec.nil?
43
+ UI.puts "未查找到`#{name}`的源码spec".red
44
+ next
45
+ end
46
+ # 下载源码
47
+ download_source(source_spec)
48
+ end
49
+ end
50
+
51
+ private
52
+
53
+ # 检查版本号最后一位是否是以`bin`开头的
54
+ def has_source?(version)
55
+ version.split('.').last.include?('bin')
56
+ end
57
+
58
+ # 查找二进制spec
59
+ def find_specification(name)
60
+ find_spec = nil
61
+ @results.specifications.each do |spec|
62
+ if spec.root.name.downcase == name.downcase
63
+ find_spec = spec
64
+ break
65
+ end
66
+ end
67
+ find_spec.nil? ? nil : find_spec.root
68
+ end
69
+
70
+ # 查找源码spec
71
+ def find_source_specification(name, version)
72
+ source_version = get_source_version(version)
73
+ # 根据 pod_name + version 查找spec
74
+ podfile_sources = config.podfile.sources.uniq.map { |source| config.sources_manager.source_with_name_or_url(source) }
75
+ sources = podfile_sources.select { |s| s.search(name) }
76
+ source_spec = nil
77
+ sources.each do |source|
78
+ begin
79
+ source_spec = source.specification(name, source_version)
80
+ break
81
+ rescue Pod::StandardError => e
82
+ next
83
+ end
84
+ end
85
+ source_spec.nil? ? nil : source_spec.root
86
+ end
87
+
88
+ # 下载源码
89
+ def download_source(source_spec)
90
+ UI.title "下载源码:#{source_spec.name} (#{source_spec.version})".green do
91
+ target = target_path(source_spec)
92
+ if exist?(source_spec)
93
+ UI.puts "#{source_spec.name} (#{source_spec.version})源码已经存在".yellow
94
+ return
95
+ end
96
+ download_request = Downloader::Request.new(
97
+ :spec => source_spec,
98
+ :released => true
99
+ )
100
+ FileUtils.mkdir_p(target) unless File.exist?(target)
101
+ Downloader.download(download_request, target, :can_cache => true)
102
+ UI.puts "#{source_spec.name} (#{source_spec.version})源码下载完成!".green
103
+ end
104
+ end
105
+
106
+ # 二进制文件路径
107
+ def binary_file(name)
108
+ "#{config.sandbox_root}/#{name}/#{name}.framework/#{name}"
109
+ end
110
+
111
+ # 依赖分析
112
+ def analyse
113
+ UI.title 'Analyze dependencies'.green do
114
+ analyzer = Pod::Installer::Analyzer.new(
115
+ config.sandbox,
116
+ config.podfile,
117
+ config.lockfile
118
+ )
119
+ analyzer.analyze(true)
120
+ end
121
+ end
122
+
123
+ # 获取源码版本号
124
+ def get_source_version(version)
125
+ source_version = version
126
+ version_arr = version.split('.')
127
+ if version_arr.last.include?('bin')
128
+ version_arr.delete_at(version_arr.size - 1)
129
+ source_version = version_arr.join('.')
130
+ end
131
+ source_version
132
+ end
133
+
134
+ # 是否存在对应源码
135
+ def exist?(source_spec)
136
+ target = target_path(source_spec)
137
+ return false unless File.exist?(target)
138
+ entries = Dir.entries(target).reject { |dir| dir == '.' || dir == '..' }
139
+ return false if entries.empty?
140
+ true
141
+ end
142
+
143
+ end
144
+ end
145
+ end
146
+ end
147
+ end
148
+
@@ -0,0 +1,59 @@
1
+
2
+ module Pod
3
+ class Command
4
+ class Bin < Command
5
+ class Source < Bin
6
+ class Delete < Source
7
+
8
+ self.summary = '删除二进制对应的源码'
9
+ self.description = <<-DESC
10
+ #{self.summary}
11
+ DESC
12
+
13
+ self.arguments = [
14
+ CLAide::Argument.new('NAMES', true )
15
+ ]
16
+
17
+ def self.options
18
+ [
19
+ %w[--all 删除所有二进制对应的源码]
20
+ ].concat(super).uniq
21
+ end
22
+
23
+ def initialize(argv)
24
+ @names = argv.shift_argument
25
+ @all = argv.flag?('all', false)
26
+ super
27
+ end
28
+
29
+ def run
30
+ if @names.nil? && !@all
31
+ raise Informative, "请输入要删除的Pod库名(多个库中间用逗号分开)或者添加`--all`删除全部的源码"
32
+ end
33
+ if @all
34
+ UI.puts "删除全部源码".yellow
35
+ FileUtils.rm_rf(source_dir)
36
+ UI.puts "删除完成".green
37
+ return
38
+ end
39
+ unless @names.nil?
40
+ name_arr = @names.split(',')
41
+ name_arr.each do |name|
42
+ UI.puts "删除`#{name}`".yellow
43
+ dir = "#{source_dir}/#{name}"
44
+ unless File.exist?(dir)
45
+ UI.puts "`#{name}`不存在".red
46
+ next
47
+ end
48
+ FileUtils.rm_rf(dir)
49
+ UI.puts "删除`#{name}`成功".green
50
+ end
51
+ end
52
+ end
53
+
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+
@@ -0,0 +1,46 @@
1
+
2
+ module Pod
3
+ class Command
4
+ class Bin < Command
5
+ class Source < Bin
6
+ class List < Source
7
+
8
+ SPECIAL_DIRS = %w[. .. .DS_Store].freeze
9
+
10
+ self.summary = '打印二进制对应的源码'
11
+ self.description = <<-DESC
12
+ #{self.summary}
13
+ DESC
14
+
15
+ self.arguments = [
16
+ CLAide::Argument.new('NAMES', true )
17
+ ]
18
+
19
+ def initialize(argv)
20
+ @names = argv.shift_argument
21
+ super
22
+ end
23
+
24
+ def run
25
+ entries = Dir.entries(source_dir).reject { |dir| SPECIAL_DIRS.include?(dir) }
26
+ unless @names.nil?
27
+ name_arr = @names.split(',').map(&:downcase)
28
+ entries.select! { |entry| name_arr.include?(entry.downcase) }
29
+ end
30
+ if entries.empty?
31
+ UI.puts "无对应的源码".red
32
+ return
33
+ end
34
+ entries.map do |entry|
35
+ UI.puts "#{entry}".green
36
+ sub_dir = "#{source_dir}/#{entry}"
37
+ sub_entries = Dir.entries(sub_dir).reject { |dir| SPECIAL_DIRS.include?(dir) }
38
+ sub_entries.map { |sub_entry| UI.puts " - #{sub_entry}".yellow }
39
+ end
40
+ end
41
+
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,30 @@
1
+ require 'cocoapods-meitu-bin/command/bin/source/add'
2
+ require 'cocoapods-meitu-bin/command/bin/source/list'
3
+ require 'cocoapods-meitu-bin/command/bin/source/delete'
4
+
5
+ module Pod
6
+ class Command
7
+ class Bin < Command
8
+ class Source < Bin
9
+ self.abstract_command = true
10
+ self.summary = '管理二进制对应的源码'
11
+ self.default_subcommand = 'list'
12
+
13
+ # 目标路径
14
+ def target_path(source_spec)
15
+ "#{source_dir}/#{source_spec.name}/#{source_spec.version}"
16
+ end
17
+
18
+ # 存放源码的根目录
19
+ def source_dir
20
+ @source_dir ||= begin
21
+ dir = "#{Dir.home}/LLDB_Sources"
22
+ FileUtils.mkdir_p(dir) unless File.exist?(dir)
23
+ dir
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+
@@ -0,0 +1,73 @@
1
+ require 'cocoapods-meitu-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-meitu-bin/config/config'
2
+ require 'cocoapods-meitu-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-meitu-bin/command/bin/spec/create'
2
+ require 'cocoapods-meitu-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
@@ -0,0 +1,154 @@
1
+
2
+ require 'cocoapods'
3
+ require 'cocoapods-meitu-bin/native/podfile_env'
4
+ require 'cocoapods-meitu-bin/native/podfile'
5
+
6
+ module Pod
7
+ class Command
8
+ class Bin < Command
9
+ class Update < Bin
10
+ include Pod
11
+ include Pod::Podfile::DSL
12
+
13
+ self.summary = 'pod update 拦截器'
14
+
15
+ self.description = <<-DESC
16
+ pod update 拦截器,会加载本地Podfile_local文件
17
+ 会通过DSL加载到原始Podfile文件中
18
+ 支持 pod 'xxx' 各种写法
19
+ 支持 post_install/pre_install钩子,采用覆盖做法
20
+ DESC
21
+ def self.options
22
+ [
23
+ ["--sources=#{Pod::TrunkSource::TRUNK_REPO_URL}", 'The sources from which to update dependent pods. ' \
24
+ 'Multiple sources must be comma-delimited'],
25
+ ['--exclude-pods=podName', 'Pods to exclude during update. Multiple pods must be comma-delimited'],
26
+ ['--clean-install', 'Ignore the contents of the project cache and force a full pod installation. This only ' \
27
+ 'applies to projects that have enabled incremental installation'],
28
+ ['--project-directory=/project/dir/', 'The path to the root of the project directory'],
29
+ ['--no-repo-update', 'Skip running `pod repo update` before install']
30
+ ].concat(super)
31
+ end
32
+
33
+ def initialize(argv)
34
+ @update = argv.flag?('update')
35
+ super
36
+ @additional_args = argv.remainder!
37
+ end
38
+
39
+ def run
40
+ Update.load_local_podfile
41
+
42
+ argvs = [
43
+ *@additional_args
44
+ ]
45
+
46
+ gen = Pod::Command::Update.new(CLAide::ARGV.new(argvs))
47
+ gen.validate!
48
+ gen.run
49
+ end
50
+
51
+ def self.load_local_podfile
52
+ # 同步 Podfile_local 文件
53
+ project_root = Pod::Config.instance.project_root
54
+ path = File.join(project_root.to_s, 'Podfile_local')
55
+ unless File.exist?(path)
56
+ path = File.join(project_root.to_s, 'Podfile_local')
57
+ end
58
+
59
+ if File.exist?(path)
60
+ contents = File.open(path, 'r:utf-8', &:read)
61
+
62
+ podfile = Pod::Config.instance.podfile
63
+ local_podfile = Podfile.from_file(path)
64
+
65
+ if local_podfile
66
+ local_pre_install_callback = nil
67
+ local_post_install_callback = nil
68
+ local_podfile.instance_eval do
69
+ local_pre_install_callback = @pre_install_callback
70
+ local_post_install_callback = @post_install_callback
71
+ end
72
+ end
73
+
74
+ podfile.instance_eval do
75
+ begin
76
+
77
+ # podfile HASH_KEYS才有plugins字段,否则会被限制
78
+ if local_podfile.plugins.any?
79
+ hash_plugins = podfile.plugins || {}
80
+ hash_plugins = hash_plugins.merge(local_podfile.plugins)
81
+ set_hash_value(%w[plugins].first, hash_plugins)
82
+
83
+ # 加入源码白名单,避免本地库被二进制了
84
+ podfile.set_use_source_pods(local_podfile.use_source_pods) if local_podfile.use_source_pods
85
+ podfile.use_binaries!(local_podfile.use_binaries?)
86
+ end
87
+
88
+ # 在target把local-target中到dependencies值删除了,再设置
89
+ # 把本地和原始到dependencies 合并,设置dependencies
90
+ local_podfile&.target_definition_list&.each do |local_target|
91
+ next if local_target.name == 'Pods'
92
+
93
+ target_definition_list.each do |target|
94
+
95
+ unless target.name == local_target.name &&
96
+ (local_target.to_hash['dependencies'] &&local_target.to_hash['dependencies'].any?)
97
+ next
98
+ end
99
+
100
+
101
+
102
+ target.instance_exec do
103
+ # 在target把local-target中到dependencies值删除了,再设置
104
+
105
+ local_dependencies = local_target.to_hash['dependencies']
106
+ target_dependencies = target.to_hash['dependencies']
107
+
108
+ local_dependencies.each do |local_dependency|
109
+ unless local_dependency.is_a?(Hash) && local_dependency.keys.first
110
+ next
111
+ end
112
+
113
+ target_dependencies.each do |target_dependency|
114
+ next unless target_dependency.is_a?(Hash) &&
115
+ target_dependency.keys.first &&
116
+ target_dependency.keys.first == local_dependency.keys.first
117
+
118
+ target_dependencies.delete target_dependency
119
+ break
120
+ end
121
+ end
122
+ # 把本地和原始到dependencies 合并,设置dependencies
123
+ local_dependencies.each do |d|
124
+ UI.message "Development Pod #{d.to_yaml}"
125
+ if podfile.plugins.keys.include?('cocoapods-meitu-bin')
126
+ podfile.set_use_source_pods(d.keys.first) if (d.is_a?(Hash) && d.keys.first)
127
+ end
128
+ end
129
+ new_dependencies = target_dependencies + local_dependencies
130
+ set_hash_value(%w[dependencies].first, new_dependencies)
131
+
132
+ end
133
+ end
134
+
135
+ end
136
+
137
+ if local_pre_install_callback
138
+ @pre_install_callback = local_pre_install_callback
139
+ end
140
+ if local_post_install_callback
141
+ @post_install_callback = local_post_install_callback
142
+ end
143
+ rescue Exception => e
144
+ message = "Invalid `#{path}` file: #{e.message}"
145
+ raise Pod::DSLError.new(message, path, e, contents)
146
+ end
147
+ end
148
+
149
+ end
150
+ end
151
+ end
152
+ end
153
+ end
154
+ end