pindo 5.20.5 → 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: e05f84df2bd17ab7420a8975c8a6811f24080b11a4080391aff016f6f010b18f
4
- data.tar.gz: 16c2db8376e2ec3e3f38ef5e0bd45eddaffb8434c65df25a95c27cdd265db469
3
+ metadata.gz: 1f5a6e7629e145e28daaf6e8bd9f5ef838a47a5eb064f02828a158eb9483b283
4
+ data.tar.gz: 320e0f2169ca80df136fdf09ca6ac21da7368405c39e763f7f5e92fe2717a7a4
5
5
  SHA512:
6
- metadata.gz: 14c3dd4dad433a639f118211ff83a2aed05b9ce63155c45c9f3293c1f52a6b39d1161ca1b1b175f1104fd51af54466e17d36c39c5fbafed8e6bfa0783827d143
7
- data.tar.gz: d3675cbbfb84617cf00c13284c7450d69b4edf7bea3159c477d45cdb4db4327515bb50fba9c3b2fa4d31a9513f6222661f3652b9193350acfb959ada39bc9e5c
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["success_urls"]
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
  # 显示上传结果
@@ -1125,10 +1126,11 @@ module Pindo
1125
1126
  # @param git_commit_id [String] Git commit SHA
1126
1127
  # @param workflow_id [Integer] 工作流ID(可选)
1127
1128
  # @return [Hash, nil] commit_log 记录或 nil
1128
- def find_commit_log_by_git_commit_id(git_commit_id, workflow_id = nil)
1129
+ def find_commit_log_by_git_commit_id(git_commit_id, workflow_id = nil, branch = nil)
1129
1130
  params = {
1130
1131
  pageNo: 1,
1131
- pageSize: 50 # 查询最近的 50 条记录
1132
+ pageSize: 50, # 查询最近的 50 条记录
1133
+ onlyCliff: false
1132
1134
  }
1133
1135
 
1134
1136
  # 如果指定了 workflow_id,添加到筛选条件
@@ -1140,26 +1142,16 @@ module Pindo
1140
1142
  if list_result && list_result["data"] && list_result["data"]["details"]
1141
1143
  details = list_result["data"]["details"]
1142
1144
 
1143
- # 遍历查找匹配的 commitId
1144
- # 支持完整匹配或前缀匹配(git SHA)
1145
- commit_log = details.find do |item|
1146
- item_commit_id = item["commitId"]
1147
- next false unless item_commit_id
1148
-
1149
- # 完整匹配
1150
- if item_commit_id == git_commit_id
1151
- true
1152
- # 前缀匹配(支持 git 短 SHA,如 9e959ffd)
1153
- elsif git_commit_id.length >= 7 && item_commit_id.start_with?(git_commit_id)
1154
- true
1155
- elsif git_commit_id.length >= 7 && git_commit_id.start_with?(item_commit_id)
1156
- true
1157
- else
1158
- false
1159
- end
1145
+ matched_logs = details.select { |item| same_commit?(item["commitId"], git_commit_id) }
1146
+ return nil if matched_logs.empty?
1147
+
1148
+ if !branch.nil?
1149
+ branch_text = branch.to_s
1150
+ branch_matched = matched_logs.find { |item| item["branch"].to_s == branch_text }
1151
+ return branch_matched if branch_matched
1160
1152
  end
1161
1153
 
1162
- return commit_log
1154
+ return matched_logs.first
1163
1155
  end
1164
1156
  rescue => e
1165
1157
  Funlog.instance.warning("查询 commit_log 列表失败: #{e.message}")
@@ -1168,6 +1160,30 @@ module Pindo
1168
1160
  nil
1169
1161
  end
1170
1162
 
1163
+ # 从 commit_log 记录中提取发送消息需要的 indexNo。
1164
+ #
1165
+ # commit_log/list 的真实响应里 indexNo 不在根节点,而在 bindVersions 的各平台包里。
1166
+ # 同一 commit 可能绑定多个平台,send_message 实测使用其中一个包的 indexNo;
1167
+ # 取最大值可匹配当前线上请求数据,并稳定指向最近生成的包序号。
1168
+ #
1169
+ # @param commit_log [Hash, nil] commit_log/list 的单条记录
1170
+ # @return [Integer, nil] indexNo
1171
+ def commit_log_message_index_no(commit_log)
1172
+ return nil unless commit_log.is_a?(Hash)
1173
+
1174
+ root_index_no = commit_log["indexNo"]
1175
+ return root_index_no if root_index_no
1176
+
1177
+ bind_versions = commit_log["bindVersions"]
1178
+ return nil unless bind_versions.is_a?(Hash)
1179
+
1180
+ bind_versions.values.map do |version_info|
1181
+ next nil unless version_info.is_a?(Hash)
1182
+
1183
+ version_info["indexNo"]
1184
+ end.compact.max
1185
+ end
1186
+
1171
1187
  def get_user_local_wechat_url( )
1172
1188
 
1173
1189
  wechat_msg_url = nil
@@ -1799,24 +1815,21 @@ module Pindo
1799
1815
 
1800
1816
  # 获取特定 commit 已绑定的包 ID
1801
1817
  #
1802
- # 数据源是 commit_log/preview 的 bindVersions。
1818
+ # 数据源是 commit_log/list 的 bindVersions。
1803
1819
  #
1804
1820
  # 不能用 project_package/bind_list:它按 projectId 查、作用域看似更宽,
1805
1821
  # 但实测(项目 930 条记录)每条的 commitId、branch、workflowId、commitLogs
1806
1822
  # 全部为 nil——该接口只返回包本身,不携带 commit 绑定关系,
1807
1823
  # 按 commitId 过滤会恒得空列表,进而让覆盖式写入误删该 commit 的已有绑定。
1808
1824
  #
1809
- # preview 需要传 workflowId,但实测同项目下不同 workflowId(3457 / 2650)
1810
- # 返回的 bindVersions 完全一致——绑定按 commitId 全局记录,
1811
- # 不存在"按工作流查漏、覆盖时被删掉"的问题。
1812
- #
1813
1825
  # 绑定接口是覆盖式写入,调用方需要把已绑定的包一起提交,因此必须区分
1814
1826
  # 「确认没有绑定过」和「查不出来」——后者返回空数组会导致已有绑定被静默覆盖丢失。
1815
1827
  #
1816
1828
  # @param commit_id [String] Git commit SHA(必需)
1817
1829
  # @param workflow_id [Integer, String] 工作流 ID(必需,接口入参)
1830
+ # @param excluded_package_types [Array<String>] 要排除的平台类型(本次新包会替换这些旧绑定)
1818
1831
  # @return [Array<String>, nil] 已绑定的包 ID 数组;查询失败或结构异常时返回 nil
1819
- def get_commit_bound_package_ids(commit_id:, workflow_id:)
1832
+ def get_commit_bound_package_ids(commit_id:, workflow_id:, excluded_package_types: [])
1820
1833
  if commit_id.nil? || commit_id.empty?
1821
1834
  Funlog.instance.fancyinfo_warning("commit_id 为空,无法查询已绑定的包")
1822
1835
  return nil
@@ -1828,10 +1841,13 @@ module Pindo
1828
1841
  end
1829
1842
 
1830
1843
  begin
1831
- result = @pgyer_client.get_commit_log_preview(
1832
- workflowId: workflow_id,
1833
- commitIds: [commit_id],
1834
- params: { onlyCliff: false }
1844
+ result = @pgyer_client.get_commit_log_list(
1845
+ params: {
1846
+ workflowIds: [workflow_id],
1847
+ pageNo: 1,
1848
+ pageSize: 50,
1849
+ onlyCliff: false
1850
+ }
1835
1851
  )
1836
1852
 
1837
1853
  # 兼容两种响应格式
@@ -1839,22 +1855,26 @@ module Pindo
1839
1855
 
1840
1856
  unless result && (response_code == 0 || response_code == 200)
1841
1857
  error_msg = result&.dig("msg") || result&.dig("meta", "message") || "未知错误"
1842
- Funlog.instance.fancyinfo_warning("查询 Commit #{commit_id[0..7]} 的绑定信息失败: #{error_msg}")
1858
+ Funlog.instance.fancyinfo_warning("查询 Commit #{commit_id[0..7]} 的提交记录失败: #{error_msg}")
1843
1859
  return nil
1844
1860
  end
1845
1861
 
1846
- data = result&.dig("data")
1862
+ details = result&.dig("data", "details")
1847
1863
 
1848
- # code=0 且 data=nil 是接口表达「没有这条 commit」的正常响应(实测确认),
1864
+ # code=0 且 details=nil 是接口表达「没有这条 commit」的正常响应(实测确认),
1849
1865
  # 不是畸形响应。此时该 commit 还没进 commit log,不可能有已记录的绑定。
1850
1866
  # 若误判为 nil,首次绑定(commit log 尚未生成)会被整体阻断。
1851
- if data.nil?
1867
+ if details.nil?
1852
1868
  puts "[PINDO_DEBUG] Commit #{commit_id[0..7]} 不在 commit log 中,视为未绑定" if ENV['PINDO_DEBUG']
1853
1869
  return []
1854
1870
  end
1855
1871
 
1856
- list = data.is_a?(Array) ? data : [data]
1857
- matched = list.select { |item| item.is_a?(Hash) && same_commit?(item["commitId"], commit_id) }
1872
+ unless details.is_a?(Array)
1873
+ Funlog.instance.fancyinfo_warning("commit_log/list details 结构异常(#{details.class}),无法确认已有绑定")
1874
+ return nil
1875
+ end
1876
+
1877
+ matched = details.select { |item| item.is_a?(Hash) && same_commit?(item["commitId"], commit_id) }
1858
1878
 
1859
1879
  # 接口正常返回但没有这条 commit:该 commit 还没进 commit log,
1860
1880
  # 也就不可能有已记录的绑定
@@ -1867,8 +1887,14 @@ module Pindo
1867
1887
  # 实测 commit_log/list 可见),哪条带 bindVersions 没有契约保证。
1868
1888
  # 只取第一条匹配会漏读绑定,进而让覆盖式写入删掉已有绑定,
1869
1889
  # 因此合并所有匹配记录的绑定。
1890
+ excluded_types = excluded_package_types.map { |item| normalize_package_type(item) }.compact
1870
1891
  package_ids = []
1871
1892
  matched.each do |commit_info|
1893
+ unless commit_info.key?("bindVersions")
1894
+ Funlog.instance.fancyinfo_warning("commit_log/list 缺少 bindVersions 字段,无法确认已有绑定")
1895
+ return nil
1896
+ end
1897
+
1872
1898
  bind_versions = commit_info["bindVersions"]
1873
1899
 
1874
1900
  # 该记录没有绑定信息:未绑定的 commit 就是 null,属正常情况
@@ -1882,6 +1908,7 @@ module Pindo
1882
1908
  # bindVersions 形如 { "ipa" => { "projectPackageId" => "..." }, ... },
1883
1909
  # 每个平台一个包
1884
1910
  bind_versions.each do |platform, version_info|
1911
+ next if excluded_types.include?(normalize_package_type(platform))
1885
1912
  next if version_info.nil?
1886
1913
 
1887
1914
  unless version_info.is_a?(Hash)
@@ -1910,6 +1937,21 @@ module Pindo
1910
1937
  end
1911
1938
  end
1912
1939
 
1940
+ # 归一化包平台类型,用于比较上传包类型和 bindVersions 平台 key。
1941
+ #
1942
+ # 服务端不同接口可能返回 "ipa"、"IPA" 或 "ipa#packageName" 这类变体。
1943
+ # 绑定接口是覆盖式写入,若同类型旧包没被排除,会出现 ipa 新旧包一起提交,
1944
+ # 最终回读仍是旧 ipa,导致校验缺失新包。
1945
+ #
1946
+ # @param package_type [Object] 平台类型
1947
+ # @return [String, nil] 归一化后的平台类型
1948
+ def normalize_package_type(package_type)
1949
+ value = package_type.to_s.strip.downcase
1950
+ return nil if value.empty?
1951
+
1952
+ value.split('#', 2).first
1953
+ end
1954
+
1913
1955
  # 判断两个 commit SHA 是否指向同一个提交
1914
1956
  #
1915
1957
  # 一端是全长 40 位 SHA、另一端是短 SHA(或大小写不同)时,严格 == 会永不命中。
@@ -2070,8 +2112,7 @@ module Pindo
2070
2112
  # @param project_id [String] 项目 ID
2071
2113
  # @param workflow_id [Integer] 工作流 ID
2072
2114
  # @param commit_id [String] Git commit SHA
2073
- # @param branch [String, nil] 分支名(可选,nil 时不发送分支字段——传错的分支名
2074
- # 会让 commit 与分支错误关联,比不传更糟)
2115
+ # @param branch [String, nil] 分支名(可选,空值时按接口真实参数传空字符串)
2075
2116
  # @param single [Boolean] 是否单个提交(可选,默认 true)
2076
2117
  # @return [Hash] 发送结果
2077
2118
  def send_workflow_message(project_id:, workflow_id:, commit_id:, branch: nil, single: true)
@@ -2091,15 +2132,22 @@ module Pindo
2091
2132
  end
2092
2133
 
2093
2134
  begin
2135
+ commit_log = find_commit_log_by_git_commit_id(commit_id, workflow_id, branch)
2136
+ commit_log_id = commit_log && commit_log["id"]
2137
+ index_no = commit_log_message_index_no(commit_log)
2138
+
2139
+ body_params = {
2140
+ single: single,
2141
+ ids: commit_log_id ? [commit_log_id] : nil,
2142
+ commitIds: [commit_id],
2143
+ branch: branch.to_s,
2144
+ indexNo: index_no
2145
+ }.compact
2146
+
2094
2147
  result = @pgyer_client.send_commit_log_message(
2095
2148
  projectId: project_id,
2096
2149
  workflowId: workflow_id,
2097
- params: {
2098
- single: single,
2099
- # jpsclient 内部归一化为服务端要求的 branches 数组;nil 时不带该字段
2100
- branch: branch,
2101
- commitIds: [commit_id]
2102
- }.compact
2150
+ params: body_params
2103
2151
  )
2104
2152
 
2105
2153
  # 兼容两种响应格式
@@ -118,6 +118,7 @@ module Pindo
118
118
  if project_package_ids.empty?
119
119
  raise "app_version_list 中的包都缺少 id 字段"
120
120
  end
121
+ package_types = @app_version_list.map { |pkg| package_type_from(pkg) }.compact.uniq
121
122
 
122
123
  # 4. 打印绑定信息
123
124
  puts ""
@@ -125,7 +126,7 @@ module Pindo
125
126
  puts " Git Commit: #{@git_commit_id[0..7]}"
126
127
  puts " 包数量: #{project_package_ids.size} 个"
127
128
  @app_version_list.each do |pkg|
128
- package_type = pkg['nativePackageType'] || pkg['originalType'] || 'unknown'
129
+ package_type = raw_package_type_from(pkg) || 'unknown'
129
130
  puts " [#{package_type}] ID: #{pkg['id']}, Version: #{pkg['projectVersion']}, Build: #{pkg['build']}"
130
131
  end
131
132
  if @git_commit_desc
@@ -153,7 +154,8 @@ module Pindo
153
154
  # 7. 获取当前 commit 已绑定的包 ID
154
155
  existing_bound_ids = pgyer_helper.get_commit_bound_package_ids(
155
156
  commit_id: @git_commit_id,
156
- workflow_id: workflow_id
157
+ workflow_id: workflow_id,
158
+ excluded_package_types: package_types
157
159
  )
158
160
 
159
161
  # 查询失败(nil)时中止:绑定接口是覆盖式写入,带着不完整的列表提交
@@ -166,8 +168,8 @@ module Pindo
166
168
  puts " 📋 当前 Commit 已绑定的包: #{existing_bound_ids.size} 个"
167
169
  end
168
170
 
169
- # 8. 合并当前 commit 已绑定的 ID 和新上传的包 ID(去重)
170
- merged_package_ids = (existing_bound_ids + project_package_ids).uniq
171
+ # 8. 合并新上传的包 ID 和其它平台已绑定的 ID(同平台旧包已在查询时排除)
172
+ merged_package_ids = (project_package_ids + existing_bound_ids).uniq
171
173
 
172
174
  puts " 📦 合并后的包 ID 数量: #{merged_package_ids.size} 个"
173
175
  if merged_package_ids.size > project_package_ids.size
@@ -221,6 +223,28 @@ module Pindo
221
223
 
222
224
  private
223
225
 
226
+ def package_type_from(pkg)
227
+ normalize_package_type(raw_package_type_from(pkg))
228
+ end
229
+
230
+ def raw_package_type_from(pkg)
231
+ return nil unless pkg.respond_to?(:[])
232
+
233
+ pkg['nativePackageType'] || pkg[:nativePackageType] ||
234
+ pkg['originalType'] || pkg[:originalType] ||
235
+ pkg['packageType'] || pkg[:packageType] ||
236
+ pkg['native_package_type'] || pkg[:native_package_type] ||
237
+ pkg['original_type'] || pkg[:original_type] ||
238
+ pkg['type'] || pkg[:type]
239
+ end
240
+
241
+ def normalize_package_type(package_type)
242
+ value = package_type.to_s.strip.downcase
243
+ return nil if value.empty?
244
+
245
+ value.split('#', 2).first
246
+ end
247
+
224
248
  # 写后回读校验:确认期望绑定的包都在服务端的绑定列表里
225
249
  #
226
250
  # 查询失败时只告警不失败——包已经写进去了,回读失败不代表绑定失败。
@@ -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. 查询 Nuget 项目(已注释:直接使用硬编码项目 ID,无需查询列表)
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
- # 使用 nuget-resource bucket
142
+ # Nuget 包默认上传到专用 bucket;如服务端迁移,可通过 PINDO_NUGET_BUCKET 临时覆盖。
142
143
  config_json = jps_client.config_json
143
- config_json['upload_config']['bucket_name'] = 'nuget-resource'
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
- if result && (result['code'] == 0 || result['code'] == 200)
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['message'] || result['msg'] || '未知错误'
201
- error_code = result['code']
206
+ error_msg = response_message(result)
202
207
 
203
208
  puts "[ERROR] 提交失败详情:"
204
- puts "[ERROR] 错误代码: #{error_code}"
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, "提交失败: #{error_msg}"
218
+ raise Informative, "Nuget 文件已上传但登记失败: #{error_msg},packageUrl: #{file_url}"
213
219
  end
214
220
  end
215
221
 
216
- # 查找 Nuget 项目
217
- def find_nuget_project(jps_client)
218
- puts "🔍 查询 Nuget 项目..."
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
- page_no += 1
243
- end
226
+ def response_code(result)
227
+ result&.dig('code') || result&.dig('meta', 'code')
228
+ end
244
229
 
245
- raise Informative, "未找到默认 Nuget 组件库项目 (ID: #{target_project_id}),请联系管理员"
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
@@ -6,7 +6,7 @@ require 'time'
6
6
 
7
7
  module Pindo
8
8
 
9
- VERSION = "5.20.5"
9
+ VERSION = "5.20.8"
10
10
 
11
11
  class VersionCheck
12
12
  RUBYGEMS_API = 'https://rubygems.org/api/v1/gems/pindo.json'
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.5
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.2
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.2
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