cocoapods-meitu-bin 1.1.4 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 73b976c903602c05d082f8e8cc8c0c886e831b786aebc4a7a32696caeba4fe6d
4
- data.tar.gz: 6f2d1a869d95fa1a99a1ccc2a8bae5d6bcc24c67b92d0baf0d22c9d9b9feb291
3
+ metadata.gz: 20e39980aef9bdfc449829f36825d3e494276a9c40dfeacc6315567c61aa54da
4
+ data.tar.gz: aee80d60a26a5938112fd2e26982d0ed5efa7d811c38bea89b06f3820c75165e
5
5
  SHA512:
6
- metadata.gz: 2e2b1fe99071023e22bcefe5364b62b00f0baa495091a4e4663bd2b0caea510cdc8de77a29b66afc8111deeb915ca3e0f42aece646451a1ad04f66146656edbd
7
- data.tar.gz: 44611af9f2e3fcbe147012cb55999ac48696e05c5dfde4bce29ce9f2280e19d02aaf26cc63e6d04c43d2f20359e0f12248f5de94bd431791dc9b005c04675bca
6
+ metadata.gz: 4520ca7be915df41b5918edcfacf04231d6962c20d9186925f382c45968f98af2c023d92d15d35f5d40c67ec5a3e3d1e88033c14415975f5383274e56a5fd14a
7
+ data.tar.gz: d00fab77b0354c225e06c425d90e6b7601a99c4e7c315c498f5ff28484ea882cc54b085ac3382ec2bca87cae9d4184c97de0c7ef2655cc4bdc39705a7a2af6ee
@@ -0,0 +1,37 @@
1
+ require 'digest'
2
+ module Pod
3
+ class Command
4
+ class Bin < Command
5
+ class GetChecksum < Bin
6
+ self.summary = '根据输入的podfile路径返回该podfile对应checksum(类似文件MD5值)'
7
+ self.description = <<-DESC
8
+ #{summary}
9
+ DESC
10
+
11
+ def self.options
12
+ [
13
+ %w[--path=podfile路径]
14
+ ].concat(super).uniq
15
+ end
16
+
17
+ def initialize(argv)
18
+ @path = argv.option('path', "")
19
+ super
20
+ end
21
+
22
+ def run
23
+ puts calculate_checksum(@path)
24
+ end
25
+ # 计算checksum值
26
+ def calculate_checksum(file_path)
27
+ return "" unless File.exist?(file_path)
28
+ content = File.read(file_path)
29
+ checksum = Digest::SHA1.hexdigest(content)
30
+ checksum = checksum.encode('UTF-8') if checksum.respond_to?(:encode)
31
+ return checksum
32
+ end
33
+
34
+ end
35
+ end
36
+ end
37
+ end
@@ -8,6 +8,7 @@ require 'cocoapods-meitu-bin/command/bin/repo'
8
8
  require 'cocoapods-meitu-bin/command/bin/spec'
9
9
  require 'cocoapods-meitu-bin/command/bin/build_all'
10
10
  require 'cocoapods-meitu-bin/command/bin/output_source'
11
+ require 'cocoapods-meitu-bin/command/bin/get_checksum.rb'
11
12
  require 'cocoapods-meitu-bin/command/bin/header_files_specifications'
12
13
  require 'cocoapods-meitu-bin/command/bin/upload'
13
14
  require 'cocoapods-meitu-bin/command/bin/lock'
@@ -151,6 +151,8 @@ end
151
151
  class PodUpdateConfig
152
152
  @@pods = []
153
153
  @@lockfile = nil
154
+ @@repo_update = true
155
+ @@prepare_time = 0
154
156
  def self.add_value(value)
155
157
  @@pods << value
156
158
  end
@@ -161,6 +163,19 @@ class PodUpdateConfig
161
163
  @@lockfile
162
164
  end
163
165
  # 一个类方法,用于显示数组中的值
166
+ def self.repo_update
167
+ @@repo_update
168
+ end
169
+ def self.set_repo_update
170
+ @@repo_update = false
171
+ end
172
+ def self.set_prepare_time(time)
173
+ @@prepare_time = time
174
+ end
175
+ def self.prepare_time
176
+ @@prepare_time
177
+ end
178
+
164
179
  def self.pods
165
180
  @@pods
166
181
  end
@@ -1,5 +1,5 @@
1
1
  module CBin
2
- VERSION = "1.1.4"
2
+ VERSION = "1.2.0"
3
3
  end
4
4
 
5
5
  module Pod
@@ -348,8 +348,22 @@ ibtool \
348
348
  fwks_dir = "#{result_product_dir}/fwks"
349
349
  FileUtils.mkdir(fwks_dir) unless File.exist?(fwks_dir)
350
350
  fwks.map do |fwk|
351
- `rsync -av #{fwk} #{fwks_dir}`
351
+ new_fwk = get_XCFrameworkIntermediates_path(fwk)
352
+ if new_fwk && File.exist?(new_fwk)
353
+ `rsync -av #{new_fwk} #{fwks_dir}`
354
+ else
355
+ `rsync -av #{fwk} #{fwks_dir}`
356
+ end
357
+ end
358
+ end
359
+ def get_XCFrameworkIntermediates_path(path)
360
+ # 使用正则表达式匹配并提取 AdsFramework
361
+ match = path.to_s.match(/\/([^\/]+)\.xcframework/)
362
+ if match
363
+ framework_path = "#{product_dir}/#{iphoneos}/XCFrameworkIntermediates/#{match[1]}/#{match[1]}.framework"
364
+ return framework_path
352
365
  end
366
+ return nil
353
367
  end
354
368
 
355
369
  # 拷贝 framework
@@ -27,7 +27,7 @@ module CBin
27
27
  # 处理vendored_libraries和vendored_frameworks
28
28
  spec['vendored_libraries'] = "#{root_dir}/libs/*.a"
29
29
  #兼容.xcframework
30
- spec['vendored_frameworks'] = %W[#{root_dir} #{root_dir}/fwks/*.framework #{root_dir}/fwks/*.xcframework]
30
+ spec['vendored_frameworks'] = %W[#{root_dir} #{root_dir}/fwks/*.framework]
31
31
  # 处理资源
32
32
  resources = %W[#{root_dir}/*.{#{special_resource_exts.join(',')}} #{root_dir}/resources/*]
33
33
  spec['resources'] = resources
@@ -66,7 +66,6 @@ module CBin
66
66
  repo_name = Pod::Config.instance.sources_manager.binary_source.name
67
67
  # repo_name = 'example-private-spec-bin'
68
68
  argvs = %W[#{repo_name} #{binary_podsepc_json} --skip-import-validation --use-libraries --allow-warnings --verbose]
69
-
70
69
  begin
71
70
  push = Pod::Command::Repo::Push.new(CLAide::ARGV.new(argvs))
72
71
  push.validate!
@@ -35,6 +35,7 @@ module Pod
35
35
  # 依赖分析
36
36
  alias old_resolve_dependencies resolve_dependencies
37
37
  def resolve_dependencies
38
+ start_time = Time.now
38
39
  list = PodUpdateConfig.pods
39
40
  # 判断 PodUpdateConfig.pods 是否为空,且数组大于0
40
41
  if list && !list.empty?
@@ -43,8 +44,24 @@ module Pod
43
44
  if PodUpdateConfig.lockfile
44
45
  self.instance_variable_set("@lockfile",PodUpdateConfig.lockfile)
45
46
  end
46
- start_time = Time.now
47
- analyzer = old_resolve_dependencies
47
+
48
+ plugin_sources = run_source_provider_hooks
49
+ analyzer = create_analyzer(plugin_sources)
50
+
51
+ UI.section 'Updating local specs repositories' do
52
+ analyzer.update_repositories
53
+ end if repo_update? && PodUpdateConfig.repo_update
54
+
55
+ UI.section 'Analyzing dependencies' do
56
+ analyze(analyzer)
57
+ validate_build_configurations
58
+ end
59
+
60
+ UI.section 'Verifying no changes' do
61
+ verify_no_podfile_changes!
62
+ verify_no_lockfile_changes!
63
+ end if deployment?
64
+ cost_time_hash['prepare'] = PodUpdateConfig.prepare_time
48
65
  cost_time_hash['resolve_dependencies'] = Time.now - start_time
49
66
  analyzer
50
67
  end
@@ -2,6 +2,7 @@ require 'cocoapods-meitu-bin/native/sources_manager'
2
2
  require 'cocoapods-meitu-bin/command/bin/repo/update'
3
3
  require 'cocoapods-meitu-bin/config/config'
4
4
  require 'cocoapods/user_interface'
5
+ require 'digest'
5
6
  require 'yaml'
6
7
  require 'cocoapods'
7
8
 
@@ -24,20 +25,33 @@ def get_podfile_lock
24
25
  if is_load_podfile_lock
25
26
  #获取 PODFILE CHECKSUM 用来判断服务端是否存在该podfile.lock
26
27
  checksum = Pod::Config.instance.podfile.checksum
27
- puts checksum
28
- # lock = Pod::Config.instance.lockfile
29
- # list = lock.internal_data['SPEC REPOS']['https://github.com/CocoaPods/Specs.git']
30
- # #遍历 list
31
- # name_list = []
32
- # list.each do |item|
33
- # name_list << item
34
- # # `echo #{item} >> /Users/sunxianglong/Desktop/work/data.txt`
35
- # end
28
+ Pod::UI.puts "当前podfile文件的checksum:#{checksum}".green
36
29
  # zip下载地址
37
30
  curl = "https://xiuxiu-dl-meitu-com.obs.cn-north-4.myhuaweicloud.com/ios/binary/MTXX/#{checksum}/podfile.lock.zip"
38
- # 判断zip文件是否存在 存在下载并解压
31
+ # 判断服务端是否存在该podfile.lock
32
+ is_load_podfile_lock = false
39
33
  if system("curl -o /dev/null -s -w %{http_code} #{curl} | grep 200 > /dev/null 2>&1")
40
- puts "获取服务端存储的podfile.lcok文件".green
34
+ Pod::UI.puts "匹配到精准podfile.lock文件,使用当前podfile文件的checksum:#{checksum}获取对应的podfile.lock文件".green
35
+ is_load_podfile_lock = true
36
+ end
37
+
38
+ if !is_load_podfile_lock
39
+ branch_value = get_branch_name
40
+ curl = "https://xiuxiu-dl-meitu-com.obs.cn-north-4.myhuaweicloud.com/ios/binary/MTXX/#{branch_value}/podfile.lock.zip"
41
+ if system("curl -o /dev/null -s -w %{http_code} #{curl} | grep 200 > /dev/null 2>&1")
42
+ Pod::UI.puts "无法匹配到精准podfile.lock文件,使用当前分支:#{branch_value} 对应的podfile.lock文件".green
43
+ is_load_podfile_lock = true
44
+ end
45
+ #兜底使用develop的podfile.lock
46
+ if !is_load_podfile_lock
47
+ Pod::UI.puts "服务端不存在该podfile.lock文件,使用develop分支的podfile.lock文件兜底".green
48
+ curl = "https://xiuxiu-dl-meitu-com.obs.cn-north-4.myhuaweicloud.com/ios/binary/MTXX/develop/podfile.lock.zip"
49
+ is_load_podfile_lock = true
50
+ end
51
+ end
52
+ # 判断是否需要下载podfile.lock文件
53
+ if is_load_podfile_lock
54
+ Pod::UI.puts "获取服务端存储的podfile.lcok文件".green
41
55
  #下载并解压的podfile.zip文件
42
56
  if system("curl -O #{curl} > /dev/null 2>&1") && system("unzip -o podfile.lock.zip > /dev/null 2>&1")
43
57
  Pod::UI.puts "下载并解压podfile.lcok文件成功".green
@@ -52,14 +66,8 @@ def get_podfile_lock
52
66
  PodUpdateConfig.lockfile
53
67
  )
54
68
  analyzer.update_repositories
69
+ PodUpdateConfig.set_repo_update
55
70
  analyzer.analyze(true)
56
-
57
- # analyzer.instance_variable_get("@result").pod_targets.each do |pod_target|
58
- # if name_list.include?(pod_target.name)
59
- # # "#{SPEC_NAME}/#{VERSION}/#{SPEC_NAME}.podspec"
60
- # end
61
- # end
62
-
63
71
  #获取analyzer中所有git 且branch 指向的pod
64
72
  Pod::Config.instance.podfile.dependencies.map do |dependency|
65
73
  if dependency.external_source && dependency.external_source[:git] && (dependency.external_source[:branch] || (dependency.external_source.size == 1))
@@ -88,10 +96,9 @@ def upload_podfile_lock(checksum,upload = false)
88
96
  curl = "https://xiuxiu-dl-meitu-com.obs.cn-north-4.myhuaweicloud.com/ios/binary/MTXX/#{checksum}/podfile.lock.zip"
89
97
  # 服务端不存在该podfiel.lock文件才上传,避免频繁上报同一个文件
90
98
  if upload || !system("curl -o /dev/null -s -w %{http_code} #{curl} | grep 200 > /dev/null 2>&1")
91
- Pod::UI.puts "上报podfile.lcok文件到服务端".green
92
- puts Pod::Config.instance.podfile.checksum
99
+ Pod::UI.puts "根据checksum:#{checksum}上报podfile.lcok文件到服务端".green
93
100
  if upload
94
- puts "mbox podfile.checksum = #{checksum}"
101
+ puts "mbox工作目录/mtxx/MTXX/podfile 对应的checksum = #{checksum}"
95
102
  end
96
103
  if system("zip podfile.lock.zip Podfile.lock > /dev/null 2>&1") && system("curl -F \"name=MTXX\" -F \"version=#{checksum}\" -F \"file=@#{Pathname.pwd}/podfile.lock.zip\" http://nezha.community.cloud.meitu.com/file/upload.json > /dev/null 2>&1")
97
104
  Pod::UI.puts "上报podfile.lcok文件到服务端成功".green
@@ -109,18 +116,62 @@ end
109
116
  def upload_mbox_podfile_lock
110
117
  begin
111
118
  podfile_path = Pod::Config.instance.installation_root + 'mtxx/MTXX' + 'Podfile'
112
- podfile = Pod::Podfile.from_file(podfile_path) if podfile_path
113
- if podfile
114
- upload_podfile_lock(podfile.checksum,true )
119
+ checksum = get_checksum(podfile_path)
120
+ if checksum && checksum.is_a?(String) && checksum.length > 0
121
+ upload_podfile_lock(checksum,true )
115
122
  end
116
123
  rescue => error
117
124
  puts "mbox podfile.lcok文件兼容处理失败,失败原因:#{error}"
118
125
  end
119
126
  end
127
+ def upload_branch_podfile_lock
128
+ begin
129
+ branch_value = get_branch_name
130
+ if branch_value && branch_value.is_a?(String) && branch_value.length > 0
131
+ if system("zip podfile.lock.zip Podfile.lock > /dev/null 2>&1") && system("curl -F \"name=MTXX\" -F \"version=#{branch_value}\" -F \"file=@#{Pathname.pwd}/podfile.lock.zip\" http://nezha.community.cloud.meitu.com/file/upload.json > /dev/null 2>&1")
132
+ Pod::UI.puts "根据开发分支名:#{branch_value}上报podfile.lcok文件到服务端成功".green
133
+ `rm -rf podfile.lock.zip`
134
+ else
135
+ Pod::UI.puts "根据开发分支名:#{branch_value}上报podfile.lcok文件到服务端失败".red
136
+ `rm -rf podfile.lock.zip`
137
+ end
138
+ end
139
+ rescue => error
140
+
141
+ end
142
+ end
143
+ def get_branch_name
144
+ branch_value = ENV['branch']
145
+ if !branch_value
146
+ mtxx_path = Pod::Config.instance.installation_root + 'mtxx/MTXX'
147
+ #判读podfile文件是否存在
148
+ if File.exist?(mtxx_path)
149
+ Dir.chdir(mtxx_path) do
150
+ branch_value = `git symbolic-ref --short -q HEAD`
151
+ if branch_value == 'develop'
152
+ branch_value = ""
153
+ end
154
+ end
155
+ else
156
+ branch_value = `git symbolic-ref --short -q HEAD`
157
+ end
158
+ end
159
+ branch_value = branch_value.gsub("\n", "")
160
+ branch_value
161
+ end
162
+
163
+ def get_checksum(file_path)
164
+ return nil unless File.exist?(file_path)
165
+ content = File.read(file_path)
166
+ checksum = Digest::SHA1.hexdigest(content)
167
+ checksum = checksum.encode('UTF-8') if checksum.respond_to?(:encode)
168
+ return checksum
169
+ end
170
+
120
171
  Pod::HooksManager.register('cocoapods-meitu-bin', :pre_install) do |_context|
172
+ start_time = Time.now
121
173
  require 'cocoapods-meitu-bin/native'
122
174
  require 'cocoapods-meitu-bin/helpers/buildAll/bin_helper'
123
-
124
175
  Pod::UI.puts "当前configuration: `#{ENV['configuration'] || Pod::Config.instance.podfile.configuration}`".green
125
176
  # checksum = Pod::Config.instance.podfile.checksum
126
177
  # puts Pod::Config.instance
@@ -143,7 +194,7 @@ Pod::HooksManager.register('cocoapods-meitu-bin', :pre_install) do |_context|
143
194
  end
144
195
 
145
196
  end
146
-
197
+ PodUpdateConfig.set_prepare_time(Time.now - start_time)
147
198
  # 同步 BinPodfile 文件
148
199
  project_root = Pod::Config.instance.project_root
149
200
  path = File.join(project_root.to_s, 'BinPodfile')
@@ -160,16 +211,25 @@ Pod::HooksManager.register('cocoapods-meitu-bin', :pre_install) do |_context|
160
211
  raise Pod::DSLError.new(message, path, e, contents)
161
212
  end
162
213
  end
214
+ PodUpdateConfig.set_prepare_time(Time.now - start_time)
163
215
  end
164
216
 
165
217
  # 注册 pod install 钩子
166
218
  Pod::HooksManager.register('cocoapods-meitu-bin', :post_install) do |context|
167
- # p "hello world! post_install"
168
- upload_podfile_lock(Pod::Config.instance.podfile.checksum)
219
+ #基于podfile的checksum上报云端podfile.lock文件
220
+ podfile_path = Pod::Config.instance.installation_root + 'podfile'
221
+ # puts "#{podfile_path}".green
222
+ checksum = get_checksum(podfile_path)
223
+ # puts "#{checksum}".green
224
+ if checksum
225
+ upload_podfile_lock(checksum)
226
+ end
169
227
  #判断是否在 mbox 工作目录执行pod install
170
228
  if system("mbox status > /dev/null 2>&1")
171
229
  upload_mbox_podfile_lock
172
230
  end
231
+ #基于分支,上报podfile.lock文件
232
+ upload_branch_podfile_lock
173
233
  end
174
234
 
175
235
  Pod::HooksManager.register('cocoapods-meitu-bin', :source_provider) do |context, _|
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.1.4
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jensen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-20 00:00:00.000000000 Z
11
+ date: 2023-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel
@@ -102,6 +102,7 @@ files:
102
102
  - lib/cocoapods-meitu-bin/command/bin/archive.rb
103
103
  - lib/cocoapods-meitu-bin/command/bin/auto.rb
104
104
  - lib/cocoapods-meitu-bin/command/bin/build_all.rb
105
+ - lib/cocoapods-meitu-bin/command/bin/get_checksum.rb
105
106
  - lib/cocoapods-meitu-bin/command/bin/header_files_specifications.rb
106
107
  - lib/cocoapods-meitu-bin/command/bin/init.rb
107
108
  - lib/cocoapods-meitu-bin/command/bin/install.rb