cocoapods-meitu-bin 1.1.1 → 1.1.2

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: 3ebf1cf1f2233bcb048f840eb09344b7f580085aa0b30ea8dcecd7826bb5e9a7
4
+ data.tar.gz: 067b9e8a1d16beb0877e5acdf79b0b903deedea1d602e7654973f7b96fe15dc4
5
5
  SHA512:
6
- metadata.gz: 4bbd6f7a386174614d960d826752381ed6d86cea458e2bb8d9c397a5e90b45abd3326da89be1420f9fe310b8749dc6954f02088533c1abd5911c3fdd1a560ded
7
- data.tar.gz: 5054ae8df4e179f558a9ebc3da56643c32e390a1f07b1c6fea015ad60db308df2d3e4b25dd9677314755d660a64a90a0a2dde4733be643012c399b91d45bc968
6
+ metadata.gz: b2c49f8e4b10995521e874878cde1e85f364d59c3d1d0f2f674dbc66d02b408d3cdd67c58cef3c30fe9d1a4207df025c50752d2c81727689735a9174c443be96
7
+ data.tar.gz: b92afc764eae7cfa72ec010b92692fc946aa30ca95d1a944fef6f8b0dc8089da2a36972860910b49227607e3b3b8fff9005321faaa65bf659d5649f7f92867a0
@@ -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,21 @@ 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
+ end
@@ -1,5 +1,5 @@
1
1
  module CBin
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
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,12 +3,107 @@ 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
+ if arg == 'update'
20
+ is_load_podfile_lock = false
21
+ end
22
+ end
23
+ # podfile.lock文件下载和使用逻辑
24
+ if is_load_podfile_lock
25
+ #获取 PODFILE CHECKSUM 用来判断服务端是否存在该podfile.lock
26
+ checksum = Pod::Config.instance.podfile.checksum
27
+ puts checksum
28
+ # zip下载地址
29
+ curl = "https://xiuxiu-dl-meitu-com.obs.cn-north-4.myhuaweicloud.com/ios/binary/MTXX/#{checksum}/podfile.lock.zip"
30
+ # 判断zip文件是否存在 存在下载并解压
31
+ if system("curl -o /dev/null -s -w %{http_code} #{curl} | grep 200")
32
+ puts "获取服务端存储的podfile.lcok文件".green
33
+ #下载并解压的podfile.zip文件
34
+ if system("curl -O #{curl}") && system("unzip -o podfile.lock.zip")
35
+ Pod::UI.puts "下载并解压podfile.lcok文件成功".green
36
+ `rm -rf podfile.lock.zip`
37
+ # 设置获取到的podfile.lock对象
38
+ PodUpdateConfig.set_lockfile( Pod::Config.instance.installation_root + 'Podfile.lock')
39
+ #获取analyzer
40
+ analyzer = Pod::Installer::Analyzer.new(
41
+ Pod::Config.instance.sandbox,
42
+ Pod::Config.instance.podfile,
43
+ PodUpdateConfig.lockfile
44
+ )
45
+ analyzer.analyze(true)
46
+
47
+ #获取analyzer中所有git 且branch 指向的pod
48
+ Pod::Config.instance.podfile.dependencies.map do |dependency|
49
+ if dependency.external_source && dependency.external_source[:git] && (dependency.external_source[:branch] || (dependency.external_source.size == 1))
50
+ #brash 指定的组件添加到全局PodUpdateConfig配置中,执行pod install 需要更新的分支最新提交
51
+ PodUpdateConfig.add_value(dependency.name)
52
+ end
53
+ end
54
+ else
55
+ puts "获取podfile.lcok文件失败"
56
+ `rm -rf podfile.lock.zip`
57
+ end
58
+ end
59
+ end
60
+ rescue => error
61
+ puts error
62
+ puts "podfile.lcok相关发生异常"
63
+ `rm -rf podfile.lock.zip`
64
+ `rm -rf podfile.lock`
65
+ end
66
+ end
67
+
68
+ # 上传podfile.lock文件到服务端
69
+ def upload_podfile_lock
70
+ begin
71
+ checksum = Pod::Config.instance.podfile.checksum
72
+ curl = "https://xiuxiu-dl-meitu-com.obs.cn-north-4.myhuaweicloud.com/ios/binary/MTXX/#{checksum}/podfile.lock.zip"
73
+ # 服务端不存在该podfiel.lock文件才上传,避免频繁上报同一个文件
74
+ if !system("curl -o /dev/null -s -w %{http_code} #{curl} | grep 200")
75
+ Pod::UI.puts "上报podfile.lcok文件到服务端".green
76
+ puts checksum
77
+ if system("zip podfile.lock.zip Podfile.lock") && system("curl -F \"name=MTXX\" -F \"version=#{checksum}\" -F \"file=@#{Pathname.pwd}/podfile.lock.zip\" http://nezha.community.cloud.meitu.com/file/upload.json")
78
+ Pod::UI.puts "上报podfile.lcok文件到服务端成功".green
79
+ `rm -rf podfile.lock.zip`
80
+ else
81
+ Pod::UI.puts "上报podfile.lcok文件到服务端失败".red
82
+ `rm -rf podfile.lock.zip`
83
+ end
84
+ end
85
+
86
+ rescue => error
87
+ puts "上传podfile.lcok文件失败".red
88
+ `rm -rf podfile.zip`
89
+ end
90
+ end
91
+
92
+ Pod::HooksManager.register('cocoapods-meitu-bin', :pre_install) do |_context|
8
93
  require 'cocoapods-meitu-bin/native'
9
94
  require 'cocoapods-meitu-bin/helpers/buildAll/bin_helper'
10
95
 
11
96
  Pod::UI.puts "当前configuration: `#{ENV['configuration'] || Pod::Config.instance.podfile.configuration}`".green
97
+ # checksum = Pod::Config.instance.podfile.checksum
98
+ # puts Pod::Config.instance
99
+ # installer = Installer.new(config.sandbox, config.podfile, config.lockfile)
100
+ # puts checksum
101
+ get_podfile_lock
102
+
103
+
104
+
105
+
106
+
12
107
 
13
108
  # pod bin repo update 更新二进制私有源
14
109
  Pod::Command::Bin::Repo::Update.new(CLAide::ARGV.new($ARGV)).run
@@ -23,6 +118,7 @@ Pod::HooksManager.register('cocoapods-meitu-bin', :pre_install) do |_context, _|
23
118
  $ARGV[1] != 'archive'
24
119
  _context.podfile.set_use_source_pods d.name
25
120
  end
121
+
26
122
  end
27
123
 
28
124
  # 同步 BinPodfile 文件
@@ -43,6 +139,13 @@ Pod::HooksManager.register('cocoapods-meitu-bin', :pre_install) do |_context, _|
43
139
  end
44
140
  end
45
141
 
142
+ # 注册 pod install 钩子
143
+ Pod::HooksManager.register('cocoapods-meitu-bin', :post_install) do |context|
144
+ # p "hello world! post_install"
145
+ upload_podfile_lock
146
+
147
+ end
148
+
46
149
  Pod::HooksManager.register('cocoapods-meitu-bin', :source_provider) do |context, _|
47
150
  sources_manager = Pod::Config.instance.sources_manager
48
151
  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.2
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-14 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