cocoapods-meitu-bin 1.1.5 → 1.2.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20e39980aef9bdfc449829f36825d3e494276a9c40dfeacc6315567c61aa54da
|
4
|
+
data.tar.gz: aee80d60a26a5938112fd2e26982d0ed5efa7d811c38bea89b06f3820c75165e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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'
|
@@ -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,24 +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
|
28
|
+
Pod::UI.puts "当前podfile文件的checksum:#{checksum}".green
|
27
29
|
# zip下载地址
|
28
30
|
curl = "https://xiuxiu-dl-meitu-com.obs.cn-north-4.myhuaweicloud.com/ios/binary/MTXX/#{checksum}/podfile.lock.zip"
|
29
|
-
|
30
31
|
# 判断服务端是否存在该podfile.lock
|
31
32
|
is_load_podfile_lock = false
|
32
33
|
if system("curl -o /dev/null -s -w %{http_code} #{curl} | grep 200 > /dev/null 2>&1")
|
34
|
+
Pod::UI.puts "匹配到精准podfile.lock文件,使用当前podfile文件的checksum:#{checksum}获取对应的podfile.lock文件".green
|
33
35
|
is_load_podfile_lock = true
|
34
36
|
end
|
35
|
-
|
36
|
-
if !is_load_podfile_lock
|
37
|
-
|
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"
|
38
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"
|
39
49
|
is_load_podfile_lock = true
|
40
50
|
end
|
41
51
|
end
|
42
52
|
# 判断是否需要下载podfile.lock文件
|
43
53
|
if is_load_podfile_lock
|
44
|
-
puts "获取服务端存储的podfile.lcok文件".green
|
54
|
+
Pod::UI.puts "获取服务端存储的podfile.lcok文件".green
|
45
55
|
#下载并解压的podfile.zip文件
|
46
56
|
if system("curl -O #{curl} > /dev/null 2>&1") && system("unzip -o podfile.lock.zip > /dev/null 2>&1")
|
47
57
|
Pod::UI.puts "下载并解压podfile.lcok文件成功".green
|
@@ -86,10 +96,9 @@ def upload_podfile_lock(checksum,upload = false)
|
|
86
96
|
curl = "https://xiuxiu-dl-meitu-com.obs.cn-north-4.myhuaweicloud.com/ios/binary/MTXX/#{checksum}/podfile.lock.zip"
|
87
97
|
# 服务端不存在该podfiel.lock文件才上传,避免频繁上报同一个文件
|
88
98
|
if upload || !system("curl -o /dev/null -s -w %{http_code} #{curl} | grep 200 > /dev/null 2>&1")
|
89
|
-
Pod::UI.puts "上报podfile.lcok文件到服务端".green
|
90
|
-
puts Pod::Config.instance.podfile.checksum
|
99
|
+
Pod::UI.puts "根据checksum:#{checksum}上报podfile.lcok文件到服务端".green
|
91
100
|
if upload
|
92
|
-
puts "mbox
|
101
|
+
puts "mbox工作目录/mtxx/MTXX/podfile 对应的checksum = #{checksum}"
|
93
102
|
end
|
94
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")
|
95
104
|
Pod::UI.puts "上报podfile.lcok文件到服务端成功".green
|
@@ -107,23 +116,23 @@ end
|
|
107
116
|
def upload_mbox_podfile_lock
|
108
117
|
begin
|
109
118
|
podfile_path = Pod::Config.instance.installation_root + 'mtxx/MTXX' + 'Podfile'
|
110
|
-
|
111
|
-
if
|
112
|
-
upload_podfile_lock(
|
119
|
+
checksum = get_checksum(podfile_path)
|
120
|
+
if checksum && checksum.is_a?(String) && checksum.length > 0
|
121
|
+
upload_podfile_lock(checksum,true )
|
113
122
|
end
|
114
123
|
rescue => error
|
115
124
|
puts "mbox podfile.lcok文件兼容处理失败,失败原因:#{error}"
|
116
125
|
end
|
117
126
|
end
|
118
|
-
def
|
127
|
+
def upload_branch_podfile_lock
|
119
128
|
begin
|
120
|
-
branch_value =
|
121
|
-
if branch_value && branch_value
|
122
|
-
if system("zip podfile.lock.zip Podfile.lock > /dev/null 2>&1") && system("curl -F \"name=MTXX\" -F \"version
|
123
|
-
Pod::UI.puts "上报podfile.lcok文件到服务端成功".green
|
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
|
124
133
|
`rm -rf podfile.lock.zip`
|
125
134
|
else
|
126
|
-
Pod::UI.puts "上报podfile.lcok文件到服务端失败".red
|
135
|
+
Pod::UI.puts "根据开发分支名:#{branch_value}上报podfile.lcok文件到服务端失败".red
|
127
136
|
`rm -rf podfile.lock.zip`
|
128
137
|
end
|
129
138
|
end
|
@@ -131,6 +140,33 @@ def upload_develop_podfile_lock
|
|
131
140
|
|
132
141
|
end
|
133
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
|
134
170
|
|
135
171
|
Pod::HooksManager.register('cocoapods-meitu-bin', :pre_install) do |_context|
|
136
172
|
start_time = Time.now
|
@@ -181,13 +217,19 @@ end
|
|
181
217
|
# 注册 pod install 钩子
|
182
218
|
Pod::HooksManager.register('cocoapods-meitu-bin', :post_install) do |context|
|
183
219
|
#基于podfile的checksum上报云端podfile.lock文件
|
184
|
-
|
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
|
185
227
|
#判断是否在 mbox 工作目录执行pod install
|
186
228
|
if system("mbox status > /dev/null 2>&1")
|
187
229
|
upload_mbox_podfile_lock
|
188
230
|
end
|
189
|
-
|
190
|
-
|
231
|
+
#基于分支,上报podfile.lock文件
|
232
|
+
upload_branch_podfile_lock
|
191
233
|
end
|
192
234
|
|
193
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.
|
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-08-
|
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
|