pindo 5.20.6 → 5.20.8
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: 1f5a6e7629e145e28daaf6e8bd9f5ef838a47a5eb064f02828a158eb9483b283
|
|
4
|
+
data.tar.gz: 320e0f2169ca80df136fdf09ca6ac21da7368405c39e763f7f5e92fe2717a7a4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c216eeacfa2afc59bb33b1195459acbdebe880c9aee6d59c07b52fa080c564861786a17bccef0f23c1f17976e92f892fe6b94a97fdcdd519e51a927220bc3108
|
|
7
|
+
data.tar.gz: dcead01b8d154b1ec138dcc489b509307e5cef5ce090fb34c214c32ba2af8d6f76e0665bac5a6eece1b307090621842c45b79955b74d72b621b8d0545844ec71
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
require 'fastimage'
|
|
2
|
+
require 'open3'
|
|
3
|
+
|
|
4
|
+
module Pindo
|
|
5
|
+
module MediaUrlHelper
|
|
6
|
+
module_function
|
|
7
|
+
|
|
8
|
+
def decorated_success_urls(upload_result)
|
|
9
|
+
upload_results = upload_result["results"]
|
|
10
|
+
if upload_results.is_a?(Array) && upload_results.any?
|
|
11
|
+
return upload_results.select { |item| item["success"] && item["url"] }.map do |item|
|
|
12
|
+
decorate_media_url(item["url"], item["file_path"])
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
upload_result["success_urls"] || []
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def decorate_media_url(url, file_path)
|
|
20
|
+
return url if url.to_s.empty? || file_path.to_s.empty?
|
|
21
|
+
|
|
22
|
+
params = []
|
|
23
|
+
params << ["x-oss-process", "image/snapshot"] if video_file?(file_path)
|
|
24
|
+
|
|
25
|
+
dimensions = media_dimensions(file_path)
|
|
26
|
+
if dimensions
|
|
27
|
+
width, height = dimensions
|
|
28
|
+
params << ["width", width]
|
|
29
|
+
params << ["height", height]
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
return url if params.empty?
|
|
33
|
+
|
|
34
|
+
append_query_params(url, params)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def media_dimensions(file_path)
|
|
38
|
+
return image_dimensions(file_path) if image_file?(file_path)
|
|
39
|
+
return video_dimensions(file_path) if video_file?(file_path)
|
|
40
|
+
|
|
41
|
+
nil
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def image_dimensions(file_path)
|
|
45
|
+
size = FastImage.size(file_path)
|
|
46
|
+
return nil unless size && size.size == 2
|
|
47
|
+
|
|
48
|
+
size.map(&:to_i)
|
|
49
|
+
rescue => e
|
|
50
|
+
puts "[PINDO_DEBUG] 读取图片尺寸失败 #{file_path}: #{e.message}" if ENV['PINDO_DEBUG']
|
|
51
|
+
nil
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def video_dimensions(file_path)
|
|
55
|
+
return nil unless executable_available?("ffprobe")
|
|
56
|
+
|
|
57
|
+
stdout, _stderr, status = Open3.capture3(
|
|
58
|
+
"ffprobe",
|
|
59
|
+
"-v", "error",
|
|
60
|
+
"-select_streams", "v:0",
|
|
61
|
+
"-show_entries", "stream=width,height",
|
|
62
|
+
"-of", "csv=p=0:s=x",
|
|
63
|
+
file_path
|
|
64
|
+
)
|
|
65
|
+
return nil unless status.success?
|
|
66
|
+
|
|
67
|
+
match = stdout.to_s.strip.match(/\A(\d+)x(\d+)\z/)
|
|
68
|
+
return nil unless match
|
|
69
|
+
|
|
70
|
+
[match[1].to_i, match[2].to_i]
|
|
71
|
+
rescue => e
|
|
72
|
+
puts "[PINDO_DEBUG] 读取视频尺寸失败 #{file_path}: #{e.message}" if ENV['PINDO_DEBUG']
|
|
73
|
+
nil
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def append_query_params(url, params)
|
|
77
|
+
base_url, fragment = url.to_s.split('#', 2)
|
|
78
|
+
separator = base_url.include?('?') ? '&' : '?'
|
|
79
|
+
query = params.map { |key, value| "#{key}=#{value}" }.join('&')
|
|
80
|
+
decorated_url = "#{base_url}#{separator}#{query}"
|
|
81
|
+
fragment ? "#{decorated_url}##{fragment}" : decorated_url
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def image_file?(file_path)
|
|
85
|
+
%w[.png .jpg .jpeg .gif .bmp .webp].include?(File.extname(file_path).downcase)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def video_file?(file_path)
|
|
89
|
+
%w[.mp4 .mov .avi .mkv .webm].include?(File.extname(file_path).downcase)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def executable_available?(command_name)
|
|
93
|
+
ENV.fetch('PATH', '').split(File::PATH_SEPARATOR).any? do |dir|
|
|
94
|
+
path = File.join(dir, command_name)
|
|
95
|
+
File.file?(path) && File.executable?(path)
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
@@ -10,6 +10,7 @@ require 'pindo/config/pindouserlocalconfig'
|
|
|
10
10
|
require 'pindo/base/funlog'
|
|
11
11
|
require 'pindo/base/git_handler'
|
|
12
12
|
require 'pindo/module/build/build_helper'
|
|
13
|
+
require 'pindo/module/pgyer/media_url_helper'
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
module Pindo
|
|
@@ -1057,8 +1058,8 @@ module Pindo
|
|
|
1057
1058
|
end
|
|
1058
1059
|
end
|
|
1059
1060
|
|
|
1060
|
-
# 6.
|
|
1061
|
-
result[:success_urls] = upload_result
|
|
1061
|
+
# 6. 提取上传结果,并在写入 JPS 前追加渲染参数
|
|
1062
|
+
result[:success_urls] = MediaUrlHelper.decorated_success_urls(upload_result)
|
|
1062
1063
|
result[:failed_files] = upload_result["failed_files"]
|
|
1063
1064
|
|
|
1064
1065
|
# 显示上传结果
|
|
@@ -6,6 +6,8 @@ module Pindo
|
|
|
6
6
|
module TaskSystem
|
|
7
7
|
class NugetUploadTask < NugetTask
|
|
8
8
|
|
|
9
|
+
DEFAULT_NUGET_BUCKET_NAME = 'nuget-resource'.freeze
|
|
10
|
+
|
|
9
11
|
attr_reader :nupkg_file
|
|
10
12
|
|
|
11
13
|
def self.task_key
|
|
@@ -130,17 +132,20 @@ module Pindo
|
|
|
130
132
|
puts "✅ 登录成功"
|
|
131
133
|
puts
|
|
132
134
|
|
|
133
|
-
# 2.
|
|
134
|
-
# nuget_project = find_nuget_project(jps_client)
|
|
135
|
+
# 2. 使用固定的 Nuget 组件库项目 ID
|
|
135
136
|
nuget_project_id = '5e6b36f61b614ed88086373ef874616c'
|
|
136
137
|
puts
|
|
137
138
|
|
|
138
139
|
# 3. 上传文件到存储
|
|
139
140
|
puts "📤 上传文件到存储..."
|
|
140
141
|
|
|
141
|
-
#
|
|
142
|
+
# Nuget 包默认上传到专用 bucket;如服务端迁移,可通过 PINDO_NUGET_BUCKET 临时覆盖。
|
|
142
143
|
config_json = jps_client.config_json
|
|
143
|
-
config_json['upload_config']
|
|
144
|
+
config_json['upload_config'] ||= {}
|
|
145
|
+
config_json['upload_config']['bucket_name'] = nuget_bucket_name
|
|
146
|
+
config_json['upload_config']['upload_type'] = 's3'
|
|
147
|
+
puts "使用存储桶: #{config_json['upload_config']['bucket_name']}"
|
|
148
|
+
puts "上传类型: #{config_json['upload_config']['upload_type']}"
|
|
144
149
|
|
|
145
150
|
# 开始上传,记录时间
|
|
146
151
|
file_size_mb = File.size(nupkg_file) / (1024.0 * 1024.0)
|
|
@@ -182,7 +187,6 @@ module Pindo
|
|
|
182
187
|
puts "[DEBUG] 附件URLs: #{request_params[:attachFileUrls].inspect}"
|
|
183
188
|
end
|
|
184
189
|
|
|
185
|
-
puts "++++++ 1 upload_nuget_package" if ENV['PINDO_DEBUG']
|
|
186
190
|
result = jps_client.upload_nuget_package(
|
|
187
191
|
projectId: nuget_project_id,
|
|
188
192
|
params: request_params
|
|
@@ -193,56 +197,42 @@ module Pindo
|
|
|
193
197
|
puts "[DEBUG] #{result.inspect}"
|
|
194
198
|
end
|
|
195
199
|
|
|
196
|
-
|
|
200
|
+
response_code = response_code(result)
|
|
201
|
+
|
|
202
|
+
if result && (response_code == 0 || response_code == 200)
|
|
197
203
|
puts "✅ 提交成功"
|
|
198
204
|
print_upload_result(result)
|
|
199
205
|
else
|
|
200
|
-
error_msg = result
|
|
201
|
-
error_code = result['code']
|
|
206
|
+
error_msg = response_message(result)
|
|
202
207
|
|
|
203
208
|
puts "[ERROR] 提交失败详情:"
|
|
204
|
-
puts "[ERROR] 错误代码: #{
|
|
209
|
+
puts "[ERROR] 错误代码: #{response_code || '未知'}"
|
|
205
210
|
puts "[ERROR] 错误消息: #{error_msg}"
|
|
211
|
+
puts "[ERROR] 已上传文件: #{file_url}"
|
|
206
212
|
|
|
207
213
|
if ENV['PINDO_DEBUG']
|
|
208
214
|
puts "[DEBUG] 完整响应内容:"
|
|
209
215
|
puts "[DEBUG] #{JSON.pretty_generate(result)}" rescue puts "[DEBUG] #{result.inspect}"
|
|
210
216
|
end
|
|
211
217
|
|
|
212
|
-
raise Informative, "
|
|
218
|
+
raise Informative, "Nuget 文件已上传但登记失败: #{error_msg},packageUrl: #{file_url}"
|
|
213
219
|
end
|
|
214
220
|
end
|
|
215
221
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
target_project_id = '5e6b36f61b614ed88086373ef874616c'
|
|
221
|
-
page_no = 1
|
|
222
|
-
page_size = 40
|
|
223
|
-
|
|
224
|
-
loop do
|
|
225
|
-
result = jps_client.get_project_list(params: { pageNo: page_no, pageSize: page_size })
|
|
226
|
-
|
|
227
|
-
unless result && (result['code'] == 0 || result['code'] == 200)
|
|
228
|
-
raise Informative, "获取项目列表失败"
|
|
229
|
-
end
|
|
230
|
-
|
|
231
|
-
projects = result['data'] || []
|
|
232
|
-
|
|
233
|
-
nuget_project = projects.find { |p| p['id'] == target_project_id }
|
|
234
|
-
if nuget_project
|
|
235
|
-
puts "✅ 找到 Nuget 组件库项目: #{nuget_project['projectName']} (ID: #{nuget_project['id']})"
|
|
236
|
-
return nuget_project
|
|
237
|
-
end
|
|
238
|
-
|
|
239
|
-
# 当前页不足一页,说明已是最后一页
|
|
240
|
-
break if projects.size < page_size
|
|
222
|
+
def nuget_bucket_name
|
|
223
|
+
ENV['PINDO_NUGET_BUCKET'].to_s.strip.empty? ? DEFAULT_NUGET_BUCKET_NAME : ENV['PINDO_NUGET_BUCKET'].to_s.strip
|
|
224
|
+
end
|
|
241
225
|
|
|
242
|
-
|
|
243
|
-
|
|
226
|
+
def response_code(result)
|
|
227
|
+
result&.dig('code') || result&.dig('meta', 'code')
|
|
228
|
+
end
|
|
244
229
|
|
|
245
|
-
|
|
230
|
+
def response_message(result)
|
|
231
|
+
result&.dig('message') ||
|
|
232
|
+
result&.dig('msg') ||
|
|
233
|
+
result&.dig('meta', 'message') ||
|
|
234
|
+
result&.dig('meta', 'msg') ||
|
|
235
|
+
'未知错误'
|
|
246
236
|
end
|
|
247
237
|
|
|
248
238
|
# 打印上传结果
|
data/lib/pindo/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pindo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.20.
|
|
4
|
+
version: 5.20.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- wade
|
|
@@ -112,7 +112,7 @@ dependencies:
|
|
|
112
112
|
version: '2.7'
|
|
113
113
|
- - ">="
|
|
114
114
|
- !ruby/object:Gem::Version
|
|
115
|
-
version: 2.7.
|
|
115
|
+
version: 2.7.5
|
|
116
116
|
type: :runtime
|
|
117
117
|
prerelease: false
|
|
118
118
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -122,7 +122,7 @@ dependencies:
|
|
|
122
122
|
version: '2.7'
|
|
123
123
|
- - ">="
|
|
124
124
|
- !ruby/object:Gem::Version
|
|
125
|
-
version: 2.7.
|
|
125
|
+
version: 2.7.5
|
|
126
126
|
- !ruby/object:Gem::Dependency
|
|
127
127
|
name: rqrcode
|
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -406,6 +406,7 @@ files:
|
|
|
406
406
|
- lib/pindo/module/cert/mode/match_git_cert_operator.rb
|
|
407
407
|
- lib/pindo/module/cert/pem_helper.rb
|
|
408
408
|
- lib/pindo/module/cert/provisioning_helper.rb
|
|
409
|
+
- lib/pindo/module/pgyer/media_url_helper.rb
|
|
409
410
|
- lib/pindo/module/pgyer/pgyerhelper.rb
|
|
410
411
|
- lib/pindo/module/resign/ipa_resign_adapter.rb
|
|
411
412
|
- lib/pindo/module/resign/mac_app_resign_adapter.rb
|