cocoapods-meitu-bin 1.1.5 → 1.2.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 +4 -4
- data/lib/cocoapods-meitu-bin/command/bin/build_all.rb +9 -9
- data/lib/cocoapods-meitu-bin/command/bin/get_checksum.rb +52 -0
- data/lib/cocoapods-meitu-bin/command/bin.rb +1 -0
- data/lib/cocoapods-meitu-bin/config/config.rb +23 -0
- data/lib/cocoapods-meitu-bin/gem_version.rb +1 -1
- data/lib/cocoapods-meitu-bin/helpers/buildAll/builder.rb +2 -2
- data/lib/cocoapods-meitu-bin/helpers/buildAll/podspec_util.rb +1 -1
- data/lib/cocoapods-meitu-bin/helpers/pod_size_helper.rb +4 -0
- data/lib/cocoapods-meitu-bin/native/installer.rb +75 -14
- data/lib/cocoapods-meitu-bin/source_provider_hook.rb +90 -26
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 159c257b8856aad76bd63ed408f8693d644a4798f040b68471e0591bbeb5d80b
|
4
|
+
data.tar.gz: 999806ccf28ed97b0e2e9180a372e668a026657e4e59c8ba89bad59e97b468cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffd23b947bb5f41b041d867727fe88c519b8fd4b8b6b996fa5acce3a0daff88d527b30010159d3b622786c3e0f18d4dd639c01dbcdbd4f838c049d6f6b01cb25
|
7
|
+
data.tar.gz: 3780e408c04ef40e5f7dd4f46bd1bff10b2ffa5c47354b7a763229eb5aed4d15536cf5c4025dd1dc03b87ca2aec890a4b77a3968bb7d5087c69e9e6508a4fd4b
|
@@ -250,25 +250,25 @@ module Pod
|
|
250
250
|
end
|
251
251
|
# 构建产物
|
252
252
|
builder = Builder.new(pod_target, @sandbox.checkout_sources, @skip_simulator, @configuration)
|
253
|
-
result = builder.build
|
254
|
-
fail_pods << pod_target.pod_name unless result
|
255
|
-
next unless result
|
253
|
+
# result = builder.build
|
254
|
+
# fail_pods << pod_target.pod_name unless result
|
255
|
+
# next unless result
|
256
256
|
builder.create_binary
|
257
257
|
# 压缩并上传zip
|
258
258
|
zip_helper = ZipFileHelper.new(pod_target, version, builder.product_dir, builder.build_as_framework?, @configuration)
|
259
259
|
result = zip_helper.zip_lib
|
260
260
|
fail_pods << pod_target.pod_name unless result
|
261
261
|
next unless result
|
262
|
-
result = zip_helper.upload_zip_lib
|
263
|
-
fail_pods << pod_target.pod_name unless result
|
264
|
-
next unless result
|
262
|
+
# result = zip_helper.upload_zip_lib
|
263
|
+
# fail_pods << pod_target.pod_name unless result
|
264
|
+
# next unless result
|
265
265
|
# 生成二进制podspec并上传
|
266
266
|
podspec_creator = PodspecUtil.new(pod_target, version, builder.build_as_framework?, @configuration)
|
267
267
|
bin_spec = podspec_creator.create_binary_podspec
|
268
268
|
bin_spec_file = podspec_creator.write_binary_podspec(bin_spec)
|
269
|
-
result = podspec_creator.push_binary_podspec(bin_spec_file)
|
270
|
-
fail_pods << pod_target.pod_name unless result
|
271
|
-
success_pods << pod_target.pod_name if result
|
269
|
+
# result = podspec_creator.push_binary_podspec(bin_spec_file)
|
270
|
+
# fail_pods << pod_target.pod_name unless result
|
271
|
+
# success_pods << pod_target.pod_name if result
|
272
272
|
rescue Pod::StandardError => e
|
273
273
|
UI.info "`#{pod_target}`编译失败,原因:#{e}".red
|
274
274
|
fail_pods << pod_target.pod_name
|
@@ -0,0 +1,52 @@
|
|
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 = ""
|
29
|
+
lines = []
|
30
|
+
#过滤出实际使用pod
|
31
|
+
File.open(file_path, 'r') do |file|
|
32
|
+
file.each_line do |line|
|
33
|
+
new_line = line.strip
|
34
|
+
if new_line.start_with?("pod")
|
35
|
+
lines << new_line
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
#给获取的pod list 排序,排除因组件顺序调整导致获取SHA1值不一样
|
40
|
+
lines = lines.sort
|
41
|
+
lines.each do |line|
|
42
|
+
content << line
|
43
|
+
end
|
44
|
+
checksum = Digest::SHA1.hexdigest(content)
|
45
|
+
checksum = checksum.encode('UTF-8') if checksum.respond_to?(:encode)
|
46
|
+
return checksum
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
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'
|
@@ -153,15 +153,38 @@ class PodUpdateConfig
|
|
153
153
|
@@lockfile = nil
|
154
154
|
@@repo_update = true
|
155
155
|
@@prepare_time = 0
|
156
|
+
@@checksum = nil
|
157
|
+
@@large_pod_hash = {}
|
158
|
+
@@is_mtxx = false
|
159
|
+
|
156
160
|
def self.add_value(value)
|
157
161
|
@@pods << value
|
158
162
|
end
|
163
|
+
def self.set_is_mtxx(value)
|
164
|
+
@@is_mtxx = value
|
165
|
+
end
|
166
|
+
def self.is_mtxx()
|
167
|
+
@@is_mtxx
|
168
|
+
end
|
159
169
|
def self.set_lockfile(path)
|
160
170
|
@@lockfile = Pod::Lockfile.from_file(path) if path
|
161
171
|
end
|
162
172
|
def self.lockfile()
|
163
173
|
@@lockfile
|
164
174
|
end
|
175
|
+
def self.set_checksum(checksum)
|
176
|
+
@@checksum = checksum
|
177
|
+
end
|
178
|
+
def self.checksum
|
179
|
+
@@checksum
|
180
|
+
end
|
181
|
+
def self.add_pod_hash(name,size)
|
182
|
+
@@large_pod_hash[name]=size
|
183
|
+
end
|
184
|
+
def self.large_pod_hash
|
185
|
+
@@large_pod_hash
|
186
|
+
end
|
187
|
+
|
165
188
|
# 一个类方法,用于显示数组中的值
|
166
189
|
def self.repo_update
|
167
190
|
@@repo_update
|
@@ -10,7 +10,7 @@ module CBin
|
|
10
10
|
@skip_simulator = skip_simulator
|
11
11
|
@configuration = configuration
|
12
12
|
@file_accessors = pod_target.file_accessors unless pod_target.nil?
|
13
|
-
@base_dir = "#{Pathname.pwd}/
|
13
|
+
@base_dir = "#{Pathname.pwd}/all_build/Build"
|
14
14
|
end
|
15
15
|
|
16
16
|
# 构建
|
@@ -92,7 +92,7 @@ module CBin
|
|
92
92
|
|
93
93
|
# xxx.framework 所在目录
|
94
94
|
def product_dir
|
95
|
-
@product_dir = "#{@base_dir}
|
95
|
+
@product_dir = "#{@base_dir}/Products"
|
96
96
|
@product_dir
|
97
97
|
end
|
98
98
|
|
@@ -48,7 +48,7 @@ module CBin
|
|
48
48
|
# podspec写入文件
|
49
49
|
def write_binary_podspec(spec)
|
50
50
|
UI.info "写入podspec:`#{@pod_target}`".yellow
|
51
|
-
podspec_dir = "#{Pathname.pwd}/
|
51
|
+
podspec_dir = "#{Pathname.pwd}/all_build/Build/Products/podspec"
|
52
52
|
FileUtils.mkdir(podspec_dir) unless File.exist?(podspec_dir)
|
53
53
|
file = "#{podspec_dir}/#{@pod_target.pod_name}.podspec.json"
|
54
54
|
FileUtils.rm_rf(file) if File.exist?(file)
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'cocoapods-meitu-bin/config/config'
|
1
2
|
module CBin
|
2
3
|
class PodSize
|
3
4
|
include Pod
|
@@ -15,6 +16,9 @@ module CBin
|
|
15
16
|
return
|
16
17
|
end
|
17
18
|
@@lock.synchronize do
|
19
|
+
size = pod[:size].to_i
|
20
|
+
size = ('%.0f' % (size / 1024)).to_f
|
21
|
+
PodUpdateConfig.add_pod_hash(pod[:name],size)
|
18
22
|
File.open(@@tmp_file_path, "a") do |f|
|
19
23
|
f.write(format_pod_size(pod))
|
20
24
|
end
|
@@ -2,6 +2,9 @@ require 'cocoapods/installer/project_cache/target_metadata.rb'
|
|
2
2
|
require 'parallel'
|
3
3
|
require 'cocoapods'
|
4
4
|
require 'xcodeproj'
|
5
|
+
require 'json'
|
6
|
+
require 'timeout'
|
7
|
+
require 'net/http'
|
5
8
|
require 'cocoapods-meitu-bin/native/pod_source_installer'
|
6
9
|
require 'cocoapods-meitu-bin/helpers/pod_size_helper'
|
7
10
|
require 'cocoapods-meitu-bin/config/config'
|
@@ -114,17 +117,6 @@ module Pod
|
|
114
117
|
def perform_post_install_actions
|
115
118
|
start_time = Time.now
|
116
119
|
old_perform_post_install_actions
|
117
|
-
cost_time_hash['perform_post_install_actions'] = Time.now - start_time
|
118
|
-
# 打印有多少个源码库,多少二进制库
|
119
|
-
print_source_bin_statistics
|
120
|
-
# 打印耗时
|
121
|
-
print_cost_time
|
122
|
-
# 打印大小大于阈值的库
|
123
|
-
CBin::PodSize.print_pods
|
124
|
-
end
|
125
|
-
|
126
|
-
# 打印有多少个源码库,多少二进制库
|
127
|
-
def print_source_bin_statistics
|
128
120
|
source_pods = []
|
129
121
|
bin_pods = []
|
130
122
|
@pod_targets.map do |target|
|
@@ -134,16 +126,85 @@ module Pod
|
|
134
126
|
bin_pods << target
|
135
127
|
end
|
136
128
|
end
|
137
|
-
|
129
|
+
cost_time_hash['perform_post_install_actions'] = Time.now - start_time
|
130
|
+
|
131
|
+
# 打印有多少个源码库,多少二进制库
|
132
|
+
print_source_bin_statistics(source_pods,bin_pods)
|
133
|
+
# 打印耗时
|
134
|
+
print_cost_time
|
135
|
+
# 打印大小大于阈值的库
|
136
|
+
CBin::PodSize.print_pods
|
137
|
+
if PodUpdateConfig.is_mtxx
|
138
|
+
begin
|
139
|
+
data = {
|
140
|
+
"meitu_bin_version" => CBin::VERSION,
|
141
|
+
"large_pod_hash" => PodUpdateConfig.large_pod_hash
|
142
|
+
}
|
143
|
+
all_time = 0
|
144
|
+
cost_time_hash.each do |key, value|
|
145
|
+
time = ('%.1f' % value).to_f
|
146
|
+
data[key] = time
|
147
|
+
all_time = all_time + time
|
148
|
+
end
|
149
|
+
data["pod_time"] = all_time
|
150
|
+
binary_rate = bin_pods.size.to_f / @pod_targets.size.to_f
|
151
|
+
data["binary_rate"] = ('%.2f' % binary_rate).to_f
|
152
|
+
data["source_count"] = source_pods.size
|
153
|
+
data["binary_count"] = bin_pods.size
|
154
|
+
data["targets_count"] = @pod_targets.size
|
155
|
+
source = "unknown user"
|
156
|
+
if ENV['NODE_NAME']
|
157
|
+
source = ENV['NODE_NAME']
|
158
|
+
else
|
159
|
+
source = `git config user.email`
|
160
|
+
source = source.gsub("\n", "")
|
161
|
+
end
|
162
|
+
data_json = {
|
163
|
+
"subject" => "MTXX pod time profiler",
|
164
|
+
"type" => "pod_time_profiler",
|
165
|
+
"source" => source,
|
166
|
+
"data" => data
|
167
|
+
}
|
168
|
+
begin
|
169
|
+
timeout(3) do
|
170
|
+
json_data = [data_json].to_json
|
171
|
+
api_url = "http://event-adapter-internal.prism.cloud.meitu-int.com/api/v1/http/send/batch"
|
172
|
+
headers = { "Content-Type" => "application/json" }
|
173
|
+
uri = URI(api_url)
|
174
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
175
|
+
request = Net::HTTP::Post.new(uri.path, headers)
|
176
|
+
request.body = json_data
|
177
|
+
response = http.request(request)
|
178
|
+
if ENV['MEITU_USE_POD_SOURCE'] == '1'
|
179
|
+
puts "pod_time_profiler: Response code: #{response.code}"
|
180
|
+
puts "pod_time_profiler: data_json: #{data_json}"
|
181
|
+
end
|
182
|
+
end
|
183
|
+
rescue Timeout::Error
|
184
|
+
puts "pod_time_profiler: 上报pod操作操作已超时"
|
185
|
+
end
|
186
|
+
rescue => error
|
187
|
+
puts "pod_time_profiler: 上报pod 耗时统计失败,失败原因:#{error}"
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
end
|
192
|
+
|
193
|
+
# 打印有多少个源码库,多少二进制库
|
194
|
+
def print_source_bin_statistics(source_pods,bin_pods)
|
195
|
+
|
196
|
+
UI.puts "\npod_time_profiler: 总共有 #{@pod_targets.size} 个Pod库,二进制有 #{bin_pods.size} 个,源码有 #{source_pods.size} 个".green
|
138
197
|
# 打印二进制库
|
139
198
|
if ENV['statistics_bin'] == '1'
|
140
199
|
UI.puts "二进制库:".green
|
141
200
|
UI.puts bin_pods
|
142
201
|
end
|
143
202
|
# 打印源码库
|
144
|
-
if ENV['
|
203
|
+
if ENV['MEITU_USE_POD_SOURCE'] == '1'
|
145
204
|
UI.puts "源码库:".green
|
146
|
-
|
205
|
+
source_pods.each do |pod|
|
206
|
+
UI.puts "pod_time_profiler: #{pod.name}"
|
207
|
+
end
|
147
208
|
end
|
148
209
|
end
|
149
210
|
|
@@ -2,46 +2,69 @@ 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
|
+
require 'json'
|
9
|
+
require 'net/http'
|
8
10
|
#获取服务端podfile.lock文件
|
9
11
|
def get_podfile_lock
|
10
12
|
begin
|
11
13
|
# 默认是获取要获取服务端podfile.lock文件
|
12
14
|
is_load_podfile_lock = true
|
15
|
+
#目前只支持MTXX target "MTXX" 项目 #想要支持其他项目可以添加对应 target "xxx"
|
16
|
+
content = File.read(Pod::Config.instance.podfile_path)
|
17
|
+
if content
|
18
|
+
if content.include?("target \"MTXX\"")
|
19
|
+
is_load_podfile_lock = true
|
20
|
+
PodUpdateConfig.set_is_mtxx(true)
|
21
|
+
else
|
22
|
+
is_load_podfile_lock = false
|
23
|
+
PodUpdateConfig.set_is_mtxx(false)
|
24
|
+
end
|
25
|
+
end
|
13
26
|
# MEITU_LOAD_CACHE_PODFILE_LOCK 为false时不获取服务端podfile.lock文件
|
14
27
|
if ENV['MEITU_LOAD_CACHE_PODFILE_LOCK'] && ENV['MEITU_LOAD_CACHE_PODFILE_LOCK'] == 'false'
|
15
28
|
is_load_podfile_lock = false
|
16
29
|
end
|
17
30
|
# 判断是否有update参数 时不获取服务端podfile.lock文件
|
18
31
|
ARGV.each do |arg|
|
19
|
-
if arg == 'update'
|
32
|
+
if arg == 'update' || arg == '--no-cloud'
|
20
33
|
is_load_podfile_lock = false
|
21
34
|
end
|
22
35
|
end
|
23
36
|
# podfile.lock文件下载和使用逻辑
|
24
37
|
if is_load_podfile_lock
|
25
38
|
#获取 PODFILE CHECKSUM 用来判断服务端是否存在该podfile.lock
|
26
|
-
checksum = Pod::Config.instance.
|
39
|
+
checksum = get_checksum(Pod::Config.instance.podfile_path)
|
40
|
+
PodUpdateConfig.set_checksum(checksum)
|
41
|
+
Pod::UI.puts "当前podfile文件的checksum:#{checksum}".green
|
27
42
|
# zip下载地址
|
28
43
|
curl = "https://xiuxiu-dl-meitu-com.obs.cn-north-4.myhuaweicloud.com/ios/binary/MTXX/#{checksum}/podfile.lock.zip"
|
29
|
-
|
30
44
|
# 判断服务端是否存在该podfile.lock
|
31
45
|
is_load_podfile_lock = false
|
32
46
|
if system("curl -o /dev/null -s -w %{http_code} #{curl} | grep 200 > /dev/null 2>&1")
|
47
|
+
Pod::UI.puts "匹配到精准podfile.lock文件,使用当前podfile文件的checksum:#{checksum}获取对应的podfile.lock文件".green
|
33
48
|
is_load_podfile_lock = true
|
34
49
|
end
|
35
|
-
|
36
|
-
if !is_load_podfile_lock
|
37
|
-
|
50
|
+
|
51
|
+
if !is_load_podfile_lock
|
52
|
+
branch_value = get_branch_name
|
53
|
+
curl = "https://xiuxiu-dl-meitu-com.obs.cn-north-4.myhuaweicloud.com/ios/binary/MTXX/#{branch_value}/podfile.lock.zip"
|
38
54
|
if system("curl -o /dev/null -s -w %{http_code} #{curl} | grep 200 > /dev/null 2>&1")
|
55
|
+
Pod::UI.puts "无法匹配到精准podfile.lock文件,使用当前分支:#{branch_value} 对应的podfile.lock文件".green
|
56
|
+
is_load_podfile_lock = true
|
57
|
+
end
|
58
|
+
#兜底使用develop的podfile.lock
|
59
|
+
if !is_load_podfile_lock
|
60
|
+
Pod::UI.puts "服务端不存在该podfile.lock文件,使用develop分支的podfile.lock文件兜底".green
|
61
|
+
curl = "https://xiuxiu-dl-meitu-com.obs.cn-north-4.myhuaweicloud.com/ios/binary/MTXX/develop/podfile.lock.zip"
|
39
62
|
is_load_podfile_lock = true
|
40
63
|
end
|
41
64
|
end
|
42
65
|
# 判断是否需要下载podfile.lock文件
|
43
66
|
if is_load_podfile_lock
|
44
|
-
puts "获取服务端存储的podfile.lcok文件".green
|
67
|
+
Pod::UI.puts "获取服务端存储的podfile.lcok文件".green
|
45
68
|
#下载并解压的podfile.zip文件
|
46
69
|
if system("curl -O #{curl} > /dev/null 2>&1") && system("unzip -o podfile.lock.zip > /dev/null 2>&1")
|
47
70
|
Pod::UI.puts "下载并解压podfile.lcok文件成功".green
|
@@ -86,10 +109,9 @@ def upload_podfile_lock(checksum,upload = false)
|
|
86
109
|
curl = "https://xiuxiu-dl-meitu-com.obs.cn-north-4.myhuaweicloud.com/ios/binary/MTXX/#{checksum}/podfile.lock.zip"
|
87
110
|
# 服务端不存在该podfiel.lock文件才上传,避免频繁上报同一个文件
|
88
111
|
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
|
112
|
+
Pod::UI.puts "根据checksum:#{checksum}上报podfile.lcok文件到服务端".green
|
91
113
|
if upload
|
92
|
-
puts "mbox
|
114
|
+
puts "mbox工作目录/mtxx/MTXX/podfile 对应的checksum = #{checksum}"
|
93
115
|
end
|
94
116
|
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
117
|
Pod::UI.puts "上报podfile.lcok文件到服务端成功".green
|
@@ -107,23 +129,23 @@ end
|
|
107
129
|
def upload_mbox_podfile_lock
|
108
130
|
begin
|
109
131
|
podfile_path = Pod::Config.instance.installation_root + 'mtxx/MTXX' + 'Podfile'
|
110
|
-
|
111
|
-
if
|
112
|
-
upload_podfile_lock(
|
132
|
+
checksum = get_checksum(podfile_path)
|
133
|
+
if checksum && checksum.is_a?(String) && checksum.length > 0
|
134
|
+
upload_podfile_lock(checksum,true )
|
113
135
|
end
|
114
136
|
rescue => error
|
115
137
|
puts "mbox podfile.lcok文件兼容处理失败,失败原因:#{error}"
|
116
138
|
end
|
117
139
|
end
|
118
|
-
def
|
140
|
+
def upload_branch_podfile_lock
|
119
141
|
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
|
142
|
+
branch_value = get_branch_name
|
143
|
+
if branch_value && branch_value.is_a?(String) && branch_value.length > 0
|
144
|
+
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")
|
145
|
+
Pod::UI.puts "根据开发分支名:#{branch_value}上报podfile.lcok文件到服务端成功".green
|
124
146
|
`rm -rf podfile.lock.zip`
|
125
147
|
else
|
126
|
-
Pod::UI.puts "上报podfile.lcok文件到服务端失败".red
|
148
|
+
Pod::UI.puts "根据开发分支名:#{branch_value}上报podfile.lcok文件到服务端失败".red
|
127
149
|
`rm -rf podfile.lock.zip`
|
128
150
|
end
|
129
151
|
end
|
@@ -131,6 +153,48 @@ def upload_develop_podfile_lock
|
|
131
153
|
|
132
154
|
end
|
133
155
|
end
|
156
|
+
def get_branch_name
|
157
|
+
branch_value = ENV['branch']
|
158
|
+
if !branch_value
|
159
|
+
mtxx_path = Pod::Config.instance.installation_root + 'mtxx/MTXX'
|
160
|
+
#判读podfile文件是否存在
|
161
|
+
if File.exist?(mtxx_path)
|
162
|
+
Dir.chdir(mtxx_path) do
|
163
|
+
branch_value = `git symbolic-ref --short -q HEAD`
|
164
|
+
if branch_value == 'develop'
|
165
|
+
branch_value = ""
|
166
|
+
end
|
167
|
+
end
|
168
|
+
else
|
169
|
+
branch_value = `git symbolic-ref --short -q HEAD`
|
170
|
+
end
|
171
|
+
end
|
172
|
+
branch_value = branch_value.gsub("\n", "")
|
173
|
+
branch_value
|
174
|
+
end
|
175
|
+
#过滤出来podfile中实际有效每行内容,拼接成字符串在SHA1 后UTF-8编码下 用来当做依赖缓存文件的key
|
176
|
+
def get_checksum(file_path)
|
177
|
+
return nil unless File.exist?(file_path)
|
178
|
+
content = ""
|
179
|
+
lines = []
|
180
|
+
#过滤出实际使用pod
|
181
|
+
File.open(file_path, 'r') do |file|
|
182
|
+
file.each_line do |line|
|
183
|
+
new_line = line.strip
|
184
|
+
if new_line.start_with?("pod")
|
185
|
+
lines << new_line
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
#给获取的pod list 排序,排除因组件顺序调整导致获取SHA1值不一样
|
190
|
+
lines = lines.sort
|
191
|
+
lines.each do |line|
|
192
|
+
content << line
|
193
|
+
end
|
194
|
+
checksum = Digest::SHA1.hexdigest(content)
|
195
|
+
checksum = checksum.encode('UTF-8') if checksum.respond_to?(:encode)
|
196
|
+
return checksum
|
197
|
+
end
|
134
198
|
|
135
199
|
Pod::HooksManager.register('cocoapods-meitu-bin', :pre_install) do |_context|
|
136
200
|
start_time = Time.now
|
@@ -181,13 +245,13 @@ end
|
|
181
245
|
# 注册 pod install 钩子
|
182
246
|
Pod::HooksManager.register('cocoapods-meitu-bin', :post_install) do |context|
|
183
247
|
#基于podfile的checksum上报云端podfile.lock文件
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
248
|
+
if PodUpdateConfig.is_mtxx
|
249
|
+
if PodUpdateConfig.checksum
|
250
|
+
upload_podfile_lock(PodUpdateConfig.checksum)
|
251
|
+
end
|
252
|
+
upload_branch_podfile_lock
|
188
253
|
end
|
189
|
-
|
190
|
-
upload_develop_podfile_lock
|
254
|
+
|
191
255
|
end
|
192
256
|
|
193
257
|
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
|
+
version: 1.2.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-
|
11
|
+
date: 2023-09-02 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
|