cocoapods-meitu-bin 1.1.1 → 1.1.3

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: 16fe8864cb3d9496d9c5920bc907be66aa5232cc9e5990a077ecb05394434f9b
4
- data.tar.gz: b9f6a4336698f14e91501324dc6deeecccfde310cdb3e588af0c421e7d9861e7
3
+ metadata.gz: 56df1ca5fc20d16f6cdbc2aaada6d1118af7b0cb95867057da93ef80af119c85
4
+ data.tar.gz: d0bd9f61753c5131fbb49ab175295b7de30fc88a568827199cda409fa4105ed6
5
5
  SHA512:
6
- metadata.gz: 4bbd6f7a386174614d960d826752381ed6d86cea458e2bb8d9c397a5e90b45abd3326da89be1420f9fe310b8749dc6954f02088533c1abd5911c3fdd1a560ded
7
- data.tar.gz: 5054ae8df4e179f558a9ebc3da56643c32e390a1f07b1c6fea015ad60db308df2d3e4b25dd9677314755d660a64a90a0a2dde4733be643012c399b91d45bc968
6
+ metadata.gz: 3b9c119faaf7a735b139d8bf84f277d603e035456e9e8bf0c437a331c8ce27c7685e4d7b10181170ec4e44692c01e77e033401673681098f1bd38fad5b8d70bf
7
+ data.tar.gz: 7eea023f3c6fc7dbf97968fb08d7d8234d3acfb49e989cf722bc57cc851035868da1dda2f066ae56e61c252a82c3501a31322fe09ee13159da19cd463b800d09
@@ -2,7 +2,7 @@ require 'yaml'
2
2
  require 'cocoapods-meitu-bin/native/podfile'
3
3
  require 'cocoapods-meitu-bin/native/podfile_env'
4
4
  require 'cocoapods/generate'
5
-
5
+ require 'cocoapods'
6
6
  module CBin
7
7
  class Config
8
8
  def config_file
@@ -147,3 +147,25 @@ module CBin
147
147
  @config ||= Config.new
148
148
  end
149
149
  end
150
+
151
+ class PodUpdateConfig
152
+ @@pods = []
153
+ @@lockfile = nil
154
+ def self.add_value(value)
155
+ @@pods << value
156
+ end
157
+ def self.set_lockfile(path)
158
+ @@lockfile = Pod::Lockfile.from_file(path) if path
159
+ end
160
+ def self.lockfile()
161
+ @@lockfile
162
+ end
163
+ # 一个类方法,用于显示数组中的值
164
+ def self.pods
165
+ @@pods
166
+ end
167
+ def self.clear
168
+ @@pods = []
169
+ @@lockfile = nil
170
+ end
171
+ end
@@ -1,5 +1,5 @@
1
1
  module CBin
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.3"
3
3
  end
4
4
 
5
5
  module Pod
@@ -26,7 +26,8 @@ module CBin
26
26
  spec['private_header_files'] = "#{root_dir}/PrivateHeaders/*.h"
27
27
  # 处理vendored_libraries和vendored_frameworks
28
28
  spec['vendored_libraries'] = "#{root_dir}/libs/*.a"
29
- spec['vendored_frameworks'] = %W[#{root_dir} #{root_dir}/fwks/*.framework]
29
+ #兼容.xcframework
30
+ spec['vendored_frameworks'] = %W[#{root_dir} #{root_dir}/fwks/*.framework #{root_dir}/fwks/*.xcframework]
30
31
  # 处理资源
31
32
  resources = %W[#{root_dir}/*.{#{special_resource_exts.join(',')}} #{root_dir}/resources/*]
32
33
  spec['resources'] = resources
@@ -4,6 +4,7 @@ require 'cocoapods'
4
4
  require 'xcodeproj'
5
5
  require 'cocoapods-meitu-bin/native/pod_source_installer'
6
6
  require 'cocoapods-meitu-bin/helpers/pod_size_helper'
7
+ require 'cocoapods-meitu-bin/config/config'
7
8
 
8
9
  module Pod
9
10
  class Installer
@@ -34,6 +35,14 @@ module Pod
34
35
  # 依赖分析
35
36
  alias old_resolve_dependencies resolve_dependencies
36
37
  def resolve_dependencies
38
+ list = PodUpdateConfig.pods
39
+ # 判断 PodUpdateConfig.pods 是否为空,且数组大于0
40
+ if list && !list.empty?
41
+ self.update = { :pods => list }
42
+ end
43
+ if PodUpdateConfig.lockfile
44
+ self.instance_variable_set("@lockfile",PodUpdateConfig.lockfile)
45
+ end
37
46
  start_time = Time.now
38
47
  analyzer = old_resolve_dependencies
39
48
  cost_time_hash['resolve_dependencies'] = Time.now - start_time
@@ -3,13 +3,116 @@ require 'cocoapods-meitu-bin/command/bin/repo/update'
3
3
  require 'cocoapods-meitu-bin/config/config'
4
4
  require 'cocoapods/user_interface'
5
5
  require 'yaml'
6
+ require 'cocoapods'
6
7
 
7
- Pod::HooksManager.register('cocoapods-meitu-bin', :pre_install) do |_context, _|
8
+ #获取服务端podfile.lock文件
9
+ def get_podfile_lock
10
+ begin
11
+ # 默认是获取要获取服务端podfile.lock文件
12
+ is_load_podfile_lock = true
13
+ # MEITU_LOAD_CACHE_PODFILE_LOCK 为false时不获取服务端podfile.lock文件
14
+ if ENV['MEITU_LOAD_CACHE_PODFILE_LOCK'] && ENV['MEITU_LOAD_CACHE_PODFILE_LOCK'] == 'false'
15
+ is_load_podfile_lock = false
16
+ end
17
+ # 判断是否有update参数 时不获取服务端podfile.lock文件
18
+ ARGV.each do |arg|
19
+ puts "pod 执行 #{arg}"
20
+ if arg == 'update'
21
+ is_load_podfile_lock = false
22
+ end
23
+ end
24
+ # podfile.lock文件下载和使用逻辑
25
+ if is_load_podfile_lock
26
+ #获取 PODFILE CHECKSUM 用来判断服务端是否存在该podfile.lock
27
+ checksum = Pod::Config.instance.podfile.checksum
28
+ puts checksum
29
+ # zip下载地址
30
+ curl = "https://xiuxiu-dl-meitu-com.obs.cn-north-4.myhuaweicloud.com/ios/binary/MTXX/#{checksum}/podfile.lock.zip"
31
+ # 判断zip文件是否存在 存在下载并解压
32
+ if system("curl -o /dev/null -s -w %{http_code} #{curl} | grep 200 > /dev/null 2>&1")
33
+ puts "获取服务端存储的podfile.lcok文件".green
34
+ #下载并解压的podfile.zip文件
35
+ if system("curl -O #{curl} > /dev/null 2>&1") && system("unzip -o podfile.lock.zip > /dev/null 2>&1")
36
+ Pod::UI.puts "下载并解压podfile.lcok文件成功".green
37
+ `rm -rf podfile.lock.zip`
38
+ # 设置获取到的podfile.lock对象
39
+ PodUpdateConfig.set_lockfile(Pod::Config.instance.installation_root + 'Podfile.lock')
40
+ #获取analyzer
41
+ Pod::UI.puts "提前根据checksum命中podfile.lcok进行依赖分析".green
42
+ analyzer = Pod::Installer::Analyzer.new(
43
+ Pod::Config.instance.sandbox,
44
+ Pod::Config.instance.podfile,
45
+ PodUpdateConfig.lockfile
46
+ )
47
+ analyzer.analyze(true)
48
+
49
+ #获取analyzer中所有git 且branch 指向的pod
50
+ Pod::Config.instance.podfile.dependencies.map do |dependency|
51
+ if dependency.external_source && dependency.external_source[:git] && (dependency.external_source[:branch] || (dependency.external_source.size == 1))
52
+ #brash 指定的组件添加到全局PodUpdateConfig配置中,执行pod install 需要更新的分支最新提交
53
+ PodUpdateConfig.add_value(dependency.name)
54
+ end
55
+ end
56
+ else
57
+ puts "获取podfile.lcok文件失败"
58
+ `rm -rf podfile.lock.zip`
59
+ end
60
+ end
61
+ end
62
+ rescue => error
63
+ puts "podfile.lcok相关处理发生异常,报错原因:#{error}"
64
+ PodUpdateConfig.clear
65
+ `rm -rf podfile.lock.zip`
66
+ `rm -rf podfile.lock`
67
+ end
68
+ end
69
+
70
+
71
+ # 上传podfile.lock文件到服务端
72
+ def upload_podfile_lock(checksum,upload = false)
73
+ begin
74
+ curl = "https://xiuxiu-dl-meitu-com.obs.cn-north-4.myhuaweicloud.com/ios/binary/MTXX/#{checksum}/podfile.lock.zip"
75
+ # 服务端不存在该podfiel.lock文件才上传,避免频繁上报同一个文件
76
+ if upload || !system("curl -o /dev/null -s -w %{http_code} #{curl} | grep 200 > /dev/null 2>&1")
77
+ Pod::UI.puts "上报podfile.lcok文件到服务端".green
78
+ puts Pod::Config.instance.podfile.checksum
79
+ if upload
80
+ puts "mbox podfile.checksum = #{checksum}"
81
+ end
82
+ 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")
83
+ Pod::UI.puts "上报podfile.lcok文件到服务端成功".green
84
+ `rm -rf podfile.lock.zip`
85
+ else
86
+ Pod::UI.puts "上报podfile.lcok文件到服务端失败".red
87
+ `rm -rf podfile.lock.zip`
88
+ end
89
+ end
90
+ rescue => error
91
+ puts "上传podfile.lcok文件失败,失败原因:#{error}"
92
+ `rm -rf podfile.zip`
93
+ end
94
+ end
95
+ def upload_mbox_podfile_lock
96
+ begin
97
+ podfile_path = Pod::Config.instance.installation_root + 'mtxx/MTXX' + 'Podfile'
98
+ podfile = Pod::Podfile.from_file(podfile_path) if podfile_path
99
+ if podfile
100
+ upload_podfile_lock(podfile.checksum,true )
101
+ end
102
+ rescue => error
103
+ puts "mbox podfile.lcok文件兼容处理失败,失败原因:#{error}"
104
+ end
105
+ end
106
+ Pod::HooksManager.register('cocoapods-meitu-bin', :pre_install) do |_context|
8
107
  require 'cocoapods-meitu-bin/native'
9
108
  require 'cocoapods-meitu-bin/helpers/buildAll/bin_helper'
10
109
 
11
110
  Pod::UI.puts "当前configuration: `#{ENV['configuration'] || Pod::Config.instance.podfile.configuration}`".green
12
-
111
+ # checksum = Pod::Config.instance.podfile.checksum
112
+ # puts Pod::Config.instance
113
+ # installer = Installer.new(config.sandbox, config.podfile, config.lockfile)
114
+ # puts checksum
115
+ get_podfile_lock
13
116
  # pod bin repo update 更新二进制私有源
14
117
  Pod::Command::Bin::Repo::Update.new(CLAide::ARGV.new($ARGV)).run
15
118
 
@@ -23,6 +126,7 @@ Pod::HooksManager.register('cocoapods-meitu-bin', :pre_install) do |_context, _|
23
126
  $ARGV[1] != 'archive'
24
127
  _context.podfile.set_use_source_pods d.name
25
128
  end
129
+
26
130
  end
27
131
 
28
132
  # 同步 BinPodfile 文件
@@ -43,6 +147,16 @@ Pod::HooksManager.register('cocoapods-meitu-bin', :pre_install) do |_context, _|
43
147
  end
44
148
  end
45
149
 
150
+ # 注册 pod install 钩子
151
+ Pod::HooksManager.register('cocoapods-meitu-bin', :post_install) do |context|
152
+ # p "hello world! post_install"
153
+ upload_podfile_lock(Pod::Config.instance.podfile.checksum)
154
+ #判断是否在 mbox 工作目录执行pod install
155
+ if system("mbox status > /dev/null 2>&1")
156
+ upload_mbox_podfile_lock
157
+ end
158
+ end
159
+
46
160
  Pod::HooksManager.register('cocoapods-meitu-bin', :source_provider) do |context, _|
47
161
  sources_manager = Pod::Config.instance.sources_manager
48
162
  podfile = Pod::Config.instance.podfile
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.1
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jensen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-15 00:00:00.000000000 Z
11
+ date: 2023-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel
@@ -191,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
191
  - !ruby/object:Gem::Version
192
192
  version: '0'
193
193
  requirements: []
194
- rubygems_version: 3.1.2
194
+ rubygems_version: 3.4.16
195
195
  signing_key:
196
196
  specification_version: 4
197
197
  summary: cocoapods-meitu-bin is a plugin which helps develpers switching pods between