cocoapods-meitu-bin 1.3.2 → 1.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf922746db89582b7329cf9c703a49ea506e2d1384507e7752587d3b9de4123b
4
- data.tar.gz: ebdb54496afee8b0e0e57bf6e31358b743e204a895c2d0c45fead0813ac0c102
3
+ metadata.gz: d866fcda4827c97d86810fa175e8f2e94ba8b9b7cb5fddba738168a39de9e209
4
+ data.tar.gz: 1ba573957dfc51fa2cc2b4f42ab483864b78d4f57c59280be20d31b758950d9a
5
5
  SHA512:
6
- metadata.gz: ab9245d4c070947805daae07dc13c7376e104ffe405aaa2dbaaaa84a1970cdb90262b0219a518e309c96df2f9ca94ec0d708fc227f1fc1dd7c8bed438bad22eb
7
- data.tar.gz: e98017a256e5c3e56e27054019654bc12b3b45c4e21d18d1274d7333132fe7cd332c857d1048406a632a3cdaeacb822e20918d41450575c2b953350898f8d0d2
6
+ metadata.gz: 828c4415a0cb11b9d920a804e59285e1b41d215d96804917e641e8c0438165c565c519ea715bbccc4381aaf1a90c63067166bc9777548f954cd7c00116270866
7
+ data.tar.gz: 1ad302d1311dca387411bd59ba4333a17ffcd81f59bed55059dfee8d70b9f74d53679394fe94696c7fd9b30261ac9b03a98bdf6fcffe5e31eb031135d16b7f47
@@ -118,35 +118,17 @@ module Pod
118
118
 
119
119
  # 获取 podfile
120
120
  def podfile
121
- @podfile ||= begin
122
- podfile_path = File.join(Pathname.pwd, 'Podfile')
123
- raise 'Podfile不存在' unless File.exist?(podfile_path)
124
- sources_manager = Pod::Config.instance.sources_manager
125
- podfile = Podfile.from_file(Pathname.new(podfile_path))
126
- podfile_hash = podfile.to_hash
127
- podfile_hash['sources'] = (podfile_hash['sources'] || []).concat(sources_manager.code_source_list.map(&:url))
128
- podfile_hash['sources'] << sources_manager.binary_source.url
129
- podfile_hash['sources'].uniq!
130
- Podfile.from_hash(podfile_hash)
131
- end
121
+ @podfile ||= Pod::Config.instance.podfile
132
122
  end
133
123
 
134
124
  # 获取 podfile.lock
135
125
  def lockfile
136
- @lockfile ||= begin
137
- lock_path = File.join(Pathname.pwd, 'Podfile.lock')
138
- raise 'Podfile.lock不存在,请执行pod install' unless File.exist?(lock_path)
139
- Lockfile.from_file(Pathname.new(lock_path))
140
- end
126
+ @lockfile ||= Pod::Config.instance.lockfile
141
127
  end
142
128
 
143
129
  # 获取 sandbox
144
130
  def sandbox
145
- @sandbox ||= begin
146
- sandbox_path = File.join(Pathname.pwd, 'Pods')
147
- raise 'Pods文件夹不存在,请执行pod install' unless File.exist?(sandbox_path)
148
- Pod::Sandbox.new(sandbox_path)
149
- end
131
+ @sandbox ||= Pod::Config.instance.sandbox
150
132
  end
151
133
 
152
134
  # 根据podfile和podfile.lock分析依赖
@@ -15,7 +15,8 @@ require 'cocoapods-meitu-bin/command/bin/lock'
15
15
  require 'cocoapods-meitu-bin/command/bin/source'
16
16
  require 'cocoapods-meitu-bin/helpers'
17
17
  require 'cocoapods-meitu-bin/helpers/framework_builder'
18
-
18
+ require 'cocoapods-meitu-bin/native/clean'
19
+ require 'cocoapods-meitu-bin/native/verify'
19
20
  module Pod
20
21
  class Command
21
22
  # This is an example of a cocoapods plugin adding a top-level subcommand
@@ -12,6 +12,9 @@ module CBin
12
12
  def template_hash
13
13
  {
14
14
  'configuration_env' => { description: '编译环境', default: 'dev', selection: %w[dev debug_iphoneos release_iphoneos] },
15
+ 'minimum_deployment_target' => { description: '最低部署目标,参与二进制版本生成', default: 'iOS12.0'},
16
+ 'bundle_identifier' => { description: '捆绑标识符,参与二进制版本生成', default: 'com.xxx.www' },
17
+ 'random_value' => { description: '随机值,参与二进制版本生成', default: 'a1b2c3d4f5' },
15
18
  'binary_repo_url' => { description: '二进制podspec私有源地址', default: 'git@github.com:Zhangyanshen/example-private-spec-bin.git' },
16
19
  'binary_upload_url' => { description: '二进制文件上传地址', default: 'http://localhost:8080/frameworks' },
17
20
  'binary_download_url' => { description: '二进制文件下载地址,后面会依次传入Xcode版本、configuration、组件名称与组件版本', default: 'http://localhost:8080/frameworks' },
@@ -56,6 +59,8 @@ module CBin
56
59
  CBin.config.binary_download_url
57
60
  end
58
61
 
62
+
63
+
59
64
  def set_configuration_env(env)
60
65
  @configuration_env = env
61
66
  end
@@ -158,8 +163,34 @@ class PodUpdateConfig
158
163
  @@is_mtxx = false
159
164
  @@is_clear = false
160
165
  @@shell_project = false
161
-
162
-
166
+ @@external_source_commit = {}
167
+
168
+
169
+
170
+ def self.set_external_source_commit
171
+ podfile_obj = Pod::Config.instance.podfile
172
+ # 遍历 Podfile 中的目标定义
173
+ podfile_obj.target_definitions.each do |target_name, target_definition|
174
+ target_definition.dependencies.each do |dependency|
175
+ if dependency.external_source
176
+ # if dependency.name == "MTBusinessBaseKit"
177
+ # puts dependency.external_source
178
+ # end
179
+ if dependency.external_source[:commit]
180
+ git_commit = dependency.external_source[:commit]
181
+ # puts "Git Commit for #{dependency}: #{git_commit}"
182
+ if @@external_source_commit[dependency.name].nil?
183
+ @@external_source_commit[dependency.name] = git_commit
184
+ end
185
+ end
186
+ end
187
+ end
188
+ end
189
+ puts "#{@@external_source_commit}" if ENV['p_bin_d'] == '1'
190
+ end
191
+ def self.external_source_commit
192
+ @@external_source_commit
193
+ end
163
194
  def self.set_shell_project
164
195
  @@shell_project = true
165
196
  end
@@ -1,5 +1,5 @@
1
1
  module CBin
2
- VERSION = "1.3.2"
2
+ VERSION = "1.4.1"
3
3
  end
4
4
 
5
5
  module Pod
@@ -1,5 +1,5 @@
1
1
  require 'digest'
2
-
2
+ require 'cocoapods-meitu-bin/config/config'
3
3
  module CBin
4
4
  module BuildAll
5
5
  class BinHelper
@@ -20,7 +20,14 @@ module CBin
20
20
  # puts "#{pod_name}:#{include_dependencies}"
21
21
  if include_dependencies
22
22
  specs << dependencies_str(pod_name, specifications)
23
+ else
24
+ if !ENV['MEITU_USE_OPEN_COMMIT']
25
+ specs << dependencies_commit_str(pod_name, specifications)
26
+ end
23
27
  end
28
+ specs << minimum_deployment_target_str
29
+ specs << bundle_identifier_str
30
+ specs << random_value_str
24
31
  specs << xcode_version
25
32
  specs << (configuration.nil? ? 'Debug' : configuration)
26
33
  specs_str = specs.join('')
@@ -35,6 +42,20 @@ module CBin
35
42
  "#{original_version}.bin#{specs_str_md5}"
36
43
  end
37
44
 
45
+ #最低部署目标,参与二进制版本生成
46
+ def minimum_deployment_target_str
47
+ CBin.config.minimum_deployment_target
48
+ end
49
+
50
+ # 捆绑标识符,参与二进制版本生成
51
+ def bundle_identifier_str
52
+ CBin.config.bundle_identifier
53
+ end
54
+ # 随机值,参与二进制版本生成
55
+ def random_value_str
56
+ CBin.config.random_value
57
+ end
58
+
38
59
  def xcode_version
39
60
  @xcode_version ||= begin
40
61
  `xcodebuild -version`.split(' ').join('')
@@ -49,11 +70,13 @@ module CBin
49
70
  # 将当前 Pod 库的依赖库拼接成字符串(格式:pod1_name(pod1_version),pod2_name(pod2_version),...)
50
71
  def dependencies_str(pod_name, specifications)
51
72
  deps = []
73
+
52
74
  specifications.map do |spec|
53
75
  if spec.root.name == pod_name
54
76
  deps.concat(spec.dependencies)
55
77
  end
56
78
  end
79
+
57
80
  if deps.empty?
58
81
  UI.puts "`#{pod_name}`无依赖库".red if ENV['p_bin_d'] == '1'
59
82
  return ''
@@ -64,6 +87,11 @@ module CBin
64
87
  next
65
88
  end
66
89
  version = dep_version(dep, specifications)
90
+ if !ENV['MEITU_USE_OPEN_COMMIT']
91
+ if PodUpdateConfig.external_source_commit[dep.name]
92
+ version = PodUpdateConfig.external_source_commit[dep.name]
93
+ end
94
+ end
67
95
  result << "#{dep.name}(#{version})"
68
96
  end
69
97
  if ENV['p_bin_d'] == '1'
@@ -76,6 +104,29 @@ module CBin
76
104
  end
77
105
  result.join(',')
78
106
  end
107
+ def dependencies_commit_str(pod_name, specifications)
108
+ deps = []
109
+ specifications.map do |spec|
110
+ if spec.root.name == pod_name
111
+ deps.concat(spec.dependencies)
112
+ end
113
+ end
114
+
115
+ if deps.empty?
116
+ UI.puts "`#{pod_name}`无依赖库".red if ENV['p_bin_d'] == '1'
117
+ return ''
118
+ end
119
+ result = []
120
+ deps.uniq.map do |dep|
121
+ if dep.root_name == pod_name
122
+ next
123
+ end
124
+ if PodUpdateConfig.external_source_commit[dep.name]
125
+ result << "#{dep.name}(#{PodUpdateConfig.external_source_commit[dep.name]})"
126
+ end
127
+ end
128
+ result.join(',')
129
+ end
79
130
 
80
131
  # 获取依赖库版本号
81
132
  def dep_version(dep, specifications)
@@ -0,0 +1,95 @@
1
+ require 'cocoapods/downloader'
2
+
3
+ module Pod
4
+ class Command
5
+ class Bin < Command
6
+ class Clean < Bin
7
+ # self.abstract_command = true
8
+ self.summary = '删除二进制组件版本pod缓存'
9
+ self.description = <<-DESC
10
+ #{summary},--all 移除全部二进制版本缓存
11
+ DESC
12
+
13
+ def self.options
14
+ [
15
+ %w[--all 移除全部二进制版本缓存],
16
+ # %w[--no-need 移除除了当前需要的版本外的其他版本二进制版本缓存]
17
+ ].concat(super).uniq
18
+ end
19
+
20
+ def initialize(argv)
21
+ @all = argv.flag?('all', false)
22
+ # @no_need = argv.flag?('no-need', false)
23
+ super
24
+ end
25
+
26
+ def run
27
+ cache = Downloader::Cache.new(Pod::Config.instance.cache_root + 'Pods')
28
+ all_del_cache_size=0
29
+ cache.cache_descriptors_per_pod.each do |pod_name, cache_descriptors|
30
+ del_cache_descriptors = []
31
+ del_cache_versions = []
32
+ current_pod_name_del_cache_size=0
33
+ cache_descriptors.each do |desc|
34
+ # version 包含 bin
35
+ if desc[:version].to_s.include?('bin')
36
+ if @all
37
+ current_pod_name_del_cache_size += folder_size(desc[:slug])
38
+ del_cache_descriptors << desc
39
+ del_cache_versions << desc[:version]
40
+ end
41
+ end
42
+ end
43
+ all_del_cache_size+=current_pod_name_del_cache_size
44
+ size = format_size(current_pod_name_del_cache_size)
45
+ Pod::UI.puts "#{pod_name}删除#{del_cache_versions}共#{size}"
46
+ remove_caches(del_cache_descriptors)
47
+ end
48
+ size = format_size(all_del_cache_size)
49
+ Pod::UI.puts "共删除#{size}二进制版本pod缓存".red
50
+ end
51
+
52
+ private
53
+ def remove_caches(cache_descriptors)
54
+ cache_descriptors.each do |desc|
55
+ UI.message("Removing spec #{desc[:spec_file]} (v#{desc[:version]})") do
56
+ FileUtils.rm(desc[:spec_file])
57
+ end
58
+ UI.message("Removing cache #{desc[:slug]}") do
59
+ FileUtils.rm_rf(desc[:slug])
60
+ end
61
+ end
62
+ end
63
+ def folder_size(path)
64
+ return 0 unless File.directory?(path)
65
+
66
+ total_size = 0
67
+ Dir.foreach(path) do |entry|
68
+ next if entry == '.' || entry == '..'
69
+
70
+ full_path = File.join(path, entry)
71
+ if File.file?(full_path)
72
+ total_size += File.size(full_path)
73
+ elsif File.directory?(full_path)
74
+ total_size += folder_size(full_path)
75
+ end
76
+ end
77
+
78
+ total_size
79
+ end
80
+ def format_size(size)
81
+ units = %w[bytes KB MB GB TB]
82
+ return '0 bytes' if size.zero?
83
+
84
+ exp = (Math.log(size) / Math.log(1024)).to_i
85
+ exp = units.size - 1 if exp > units.size - 1
86
+ format('%.2f %s', size / (1024 ** exp).to_f, units[exp])
87
+ end
88
+ def clean_all_binary
89
+ # Your method implementation here
90
+
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
@@ -133,6 +133,8 @@ module Pod
133
133
  start_time = Time.now
134
134
  @activated = Molinillo::Resolver.new(self, self).resolve(dependencies, locked_dependencies)
135
135
  UI.puts "pod_time_profiler: Molinillo resolve耗时:#{'%.1f' % (Time.now - start_time)}s".green
136
+ #记录podfile 中commit 使用的组件map,提供后面二进制版本生成使用
137
+ PodUpdateConfig.set_external_source_commit
136
138
  resolver_specs_by_target
137
139
  rescue Molinillo::ResolverError => e
138
140
  handle_resolver_error(e)
@@ -0,0 +1,107 @@
1
+ # 用于效验podfile相关准确性
2
+ module Pod
3
+ class Command
4
+ class Bin < Command
5
+ class Verify < Bin
6
+ # self.abstract_command = true
7
+ self.summary = '效验podfile相关准确性'
8
+ self.description = <<-DESC
9
+ #{summary},效验podfile相关准确性
10
+ DESC
11
+
12
+ def self.options
13
+ [
14
+ %w[--verify-podfile podfile是否正确且相关依赖正常],
15
+ %w[--verify-podfile-branch 效验podfile是否包含:branch=>'xxx'语法],
16
+ ].concat(super).uniq
17
+ end
18
+
19
+ def initialize(argv)
20
+ @verify_podfile = argv.flag?('verify-podfile', false)
21
+ @verify_podfile_branch = argv.flag?('verify-podfile-branch', false)
22
+ super
23
+ end
24
+
25
+ def run
26
+ # Pod::UI.puts "共删除#{size}二进制版本pod缓存".red
27
+
28
+ if @verify_podfile
29
+ analyzing_dependencies
30
+ end
31
+ if @verify_podfile_branch
32
+ verify_podfile_branch
33
+ end
34
+ end
35
+
36
+ private
37
+ def verify_podfile
38
+ begin
39
+ podfile
40
+ rescue Pod::DSLError => error
41
+ info ="podfile文件效验失败:#{error}"
42
+ raise Pod::DSLError.new(info, path, error, contents)
43
+ end
44
+ begin
45
+ analyzing_dependencies
46
+ rescue Pod::DSLError => error
47
+ # puts "podfile依赖分析失败:#{error}"
48
+ info = "podfile依赖分析失败:#{error}"
49
+ raise Pod::DSLError.new(info, path, error, contents)
50
+ end
51
+ end
52
+ def verify_podfile_branch
53
+ begin
54
+ podfile
55
+ rescue Pod::DSLError => error
56
+ info = "podfile文件效验失败:#{error.message}"
57
+ raise Pod::DSLError.new(info, path, error, contents)
58
+ end
59
+ podfile_obj = podfile
60
+ branch_list = []
61
+ podfile_obj.target_definitions.each do |target_name, target_definition|
62
+ target_definition.dependencies.each do |dependency|
63
+ if dependency.external_source
64
+ if dependency.external_source[:branch]
65
+ branch = dependency.external_source[:branch]
66
+ branch_list << "#{dependency.name}:#{branch}"
67
+ end
68
+ end
69
+ end
70
+ end
71
+ if branch_list.count > 0
72
+ Pod::UI.puts "podfile包含以下branch:#{branch_list}".red
73
+ Pod::UI.puts "请检查podfile是否包含 :branch => 'xxx' 语法".red
74
+
75
+ raise Pod::DSLError.new("合入develop分支不能使用branch,podfile包含branch,请检查:#{branch_list}", nil, nil, nil)
76
+ end
77
+ end
78
+ def analyzing_dependencies
79
+ analyzer = Pod::Installer::Analyzer.new(
80
+ sandbox,
81
+ podfile,
82
+ lockfile
83
+ )
84
+ analyzer.update_repositories
85
+ analyzer.analyze(true)
86
+ end
87
+ def podfile
88
+ @podfile ||= Pod::Config.instance.podfile
89
+ end
90
+
91
+ # 获取 podfile.lock
92
+ def lockfile
93
+ @lockfile ||= Pod::Config.instance.lockfile
94
+ end
95
+
96
+ # 获取 sandbox
97
+ def sandbox
98
+ @sandbox ||= Pod::Config.instance.sandbox
99
+ end
100
+ def clean_all_binary
101
+ # Your method implementation here
102
+
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
@@ -203,6 +203,13 @@ Pod::HooksManager.register('cocoapods-meitu-bin', :pre_install) do |_context|
203
203
  Pod::UI.puts "当前configuration: `#{ENV['configuration'] || Pod::Config.instance.podfile.configuration}`".green
204
204
  # pod bin repo update 更新二进制私有源
205
205
  Pod::Command::Bin::Repo::Update.new(CLAide::ARGV.new($ARGV)).run
206
+ #获取analyzer中所有git 且branch 指向的pod
207
+ Pod::Config.instance.podfile.dependencies.map do |dependency|
208
+ if dependency.external_source && dependency.external_source[:git] && (dependency.external_source[:branch] || (dependency.external_source.size == 1))
209
+ #brash 指定的组件添加到全局PodUpdateConfig配置中,执行pod install 需要更新的分支最新提交
210
+ PodUpdateConfig.add_value(dependency.name)
211
+ end
212
+ end
206
213
  content = File.read(Pod::Config.instance.podfile_path)
207
214
  if content
208
215
  if content.include?("target \"MTXX\"")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-meitu-bin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jensen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-21 00:00:00.000000000 Z
11
+ date: 2023-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel
@@ -143,6 +143,7 @@ files:
143
143
  - lib/cocoapods-meitu-bin/native.rb
144
144
  - lib/cocoapods-meitu-bin/native/acknowledgements.rb
145
145
  - lib/cocoapods-meitu-bin/native/analyzer.rb
146
+ - lib/cocoapods-meitu-bin/native/clean.rb
146
147
  - lib/cocoapods-meitu-bin/native/file_accessor.rb
147
148
  - lib/cocoapods-meitu-bin/native/gen.rb
148
149
  - lib/cocoapods-meitu-bin/native/installation_options.rb
@@ -163,6 +164,7 @@ files:
163
164
  - lib/cocoapods-meitu-bin/native/specification.rb
164
165
  - lib/cocoapods-meitu-bin/native/target_validator.rb
165
166
  - lib/cocoapods-meitu-bin/native/validator.rb
167
+ - lib/cocoapods-meitu-bin/native/verify.rb
166
168
  - lib/cocoapods-meitu-bin/source_provider_hook.rb
167
169
  - lib/cocoapods_plugin.rb
168
170
  - spec/command/bin_spec.rb