pindo 5.11.4 → 5.12.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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pindo/command/android/autobuild.rb +111 -184
  3. data/lib/pindo/command/android/build.rb +10 -2
  4. data/lib/pindo/command/ios/autobuild.rb +115 -210
  5. data/lib/pindo/command/ios/build.rb +12 -3
  6. data/lib/pindo/command/jps/upload.rb +257 -117
  7. data/lib/pindo/command/unity/autobuild.rb +308 -220
  8. data/lib/pindo/command/unity.rb +0 -3
  9. data/lib/pindo/command/utils/boss.rb +18 -15
  10. data/lib/pindo/command/utils/clearcert.rb +26 -18
  11. data/lib/pindo/command/utils/device.rb +28 -19
  12. data/lib/pindo/command/utils/feishu.rb +11 -4
  13. data/lib/pindo/command/utils/icon.rb +26 -20
  14. data/lib/pindo/command/utils/renewcert.rb +35 -29
  15. data/lib/pindo/command/utils/renewproj.rb +32 -25
  16. data/lib/pindo/command/utils/repoinit.rb +1 -1
  17. data/lib/pindo/command/utils/tag.rb +6 -180
  18. data/lib/pindo/command/utils/tgate.rb +34 -28
  19. data/lib/pindo/command/utils/xcassets.rb +30 -20
  20. data/lib/pindo/command/web/autobuild.rb +148 -128
  21. data/lib/pindo/module/android/android_build_helper.rb +0 -6
  22. data/lib/pindo/module/android/android_config_helper.rb +4 -26
  23. data/lib/pindo/module/build/build_helper.rb +18 -294
  24. data/lib/pindo/module/build/git_repo_helper.rb +519 -0
  25. data/lib/pindo/module/build/icon_downloader.rb +85 -0
  26. data/lib/pindo/module/pgyer/pgyerhelper.rb +16 -11
  27. data/lib/pindo/module/task/model/build/android_dev_build_task.rb +209 -0
  28. data/lib/pindo/module/task/model/build/android_release_build_task.rb +29 -0
  29. data/lib/pindo/module/task/model/build/ios_adhoc_build_task.rb +53 -0
  30. data/lib/pindo/module/task/model/build/ios_dev_build_task.rb +251 -0
  31. data/lib/pindo/module/task/model/build/ios_release_build_task.rb +53 -0
  32. data/lib/pindo/module/task/model/build/web_dev_build_task.rb +43 -0
  33. data/lib/pindo/module/task/model/build_task.rb +125 -301
  34. data/lib/pindo/module/task/model/git_tag_task.rb +80 -0
  35. data/lib/pindo/module/task/model/unity_export_task.rb +53 -41
  36. data/lib/pindo/module/task/model/upload_task.rb +149 -208
  37. data/lib/pindo/module/task/pindo_task.rb +135 -95
  38. data/lib/pindo/module/task/task_manager.rb +202 -352
  39. data/lib/pindo/module/unity/unity_helper.rb +7 -3
  40. data/lib/pindo/module/xcode/xcode_build_config.rb +4 -10
  41. data/lib/pindo/module/xcode/xcode_build_helper.rb +19 -0
  42. data/lib/pindo/version.rb +1 -1
  43. metadata +10 -4
  44. data/lib/pindo/command/unity/apk.rb +0 -185
  45. data/lib/pindo/command/unity/ipa.rb +0 -198
  46. data/lib/pindo/command/unity/web.rb +0 -163
@@ -10,26 +10,36 @@ module Pindo
10
10
  self.summary = '获取Assets.xcassets中所有图片,并检查是否有缺失图片'
11
11
 
12
12
  self.description = <<-DESC
13
- 获取Assets.xcassets中所有图片资源,并检查是否有缺失图片的工具。
14
-
15
- 支持功能:
16
- - 扫描当前目录下Assets.xcassets文件
17
- - 检查所有图片资源的完整性
18
- - 识别缺失的@2x、@3x等分辨率图片
19
- - 检查AppIcon和LaunchImage的完整性
20
- - 生成详细的检查报告
21
- - 列出所有图片资源的使用情况
22
-
23
- 使用示例:
24
- # 检查当前工程的图片资源
25
- pindo utils xcassets
26
-
27
- 输出内容:
28
- - 所有图片资源列表
29
- - 缺失的图片文件提示
30
- - 图片资源使用统计
31
- - 建议的优化方案
32
- DESC
13
+ 获取Assets.xcassets中所有图片资源,并检查是否有缺失图片的工具。
14
+
15
+ 支持功能:
16
+
17
+ * 扫描当前目录下Assets.xcassets文件
18
+
19
+ * 检查所有图片资源的完整性
20
+
21
+ * 识别缺失的@2x、@3x等分辨率图片
22
+
23
+ * 检查AppIcon和LaunchImage的完整性
24
+
25
+ * 生成详细的检查报告
26
+
27
+ * 列出所有图片资源的使用情况
28
+
29
+ 使用示例:
30
+
31
+ $ pindo utils xcassets # 检查当前工程的图片资源
32
+
33
+ 输出内容:
34
+
35
+ * 所有图片资源列表
36
+
37
+ * 缺失的图片文件提示
38
+
39
+ * 图片资源使用统计
40
+
41
+ * 建议的优化方案
42
+ DESC
33
43
 
34
44
 
35
45
  self.arguments = [
@@ -1,10 +1,15 @@
1
1
  require 'highline/import'
2
2
  require 'xcodeproj'
3
- require 'find'
3
+ require 'find'
4
4
  require 'fileutils'
5
5
  require 'pindo/base/executable'
6
6
  require 'pindo/module/unity/unity_helper'
7
7
  require 'pindo/module/build/build_helper'
8
+ require 'pindo/module/task/task_manager'
9
+ require 'pindo/module/task/model/git_tag_task'
10
+ require 'pindo/module/task/model/unity_export_task'
11
+ require 'pindo/module/task/model/build_task'
12
+ require 'pindo/module/task/model/upload_task'
8
13
 
9
14
  module Pindo
10
15
  class Command
@@ -93,146 +98,161 @@ module Pindo
93
98
  # 加载 JPS 配置(如果存在)
94
99
  context = Pindo::PindoContext.instance
95
100
  context.load_and_apply_jps_config(pindo_project_dir)
96
-
97
101
  # 确认并应用缓存(如果有)
98
102
  context.confirm_and_apply_cache
99
103
 
100
- build_helper = Pindo::BuildHelper.share_instance
101
- project_type = build_helper.project_type(pindo_project_dir)
102
-
103
- args_temp = []
104
- args_temp << "--proj=#{@args_proj_name}" if @args_proj_name
105
- args_temp << "--upload" if @args_upload_flag
106
- args_temp << "--send" if @args_send_flag
107
- case project_type
108
- when :ios
109
- puts "iOS 工程, 请使用 pindo ios autobuild"
110
- when :android
111
- puts "Android 工程, 请使用 pindo and build"
112
-
113
- when :unity
114
- web_autobuild
115
- else
116
- raise Informative, "当前目录不是工程目录,不能编译"
117
- end
118
- end
104
+ # 准备配置
105
+ config = prepare_web_config(pindo_project_dir)
119
106
 
120
- def web_autobuild
121
- pindo_project_dir = Dir.pwd
122
- build_helper = Pindo::BuildHelper.share_instance
123
-
124
- if @args_upload_flag
125
- is_need_add_tag,tag_action_parms = build_helper.check_is_need_add_tag?(pindo_project_dir)
126
- if is_need_add_tag
127
- Pindo::Command::Utils::Tag::run(tag_action_parms)
128
- end
129
- end
107
+ # 创建并执行任务
108
+ tasks = make_build_task(config)
130
109
 
131
- unity_helper = Pindo::Client::UnityHelper.share_instance
132
- project_unity_version = unity_helper.get_unity_version(pindo_project_dir)
133
- puts
134
- puts "工程的Unity版本: #{project_unity_version}"
135
- unity_exe_path = unity_helper.find_unity_path(project_unity_version:project_unity_version, force_change_version: @force_select_unity)
136
- puts "选择的Unity路径: #{unity_exe_path}"
137
- puts
138
-
139
- app_info_obj = nil
140
- workflow_info = nil
141
- proj_name = @args_proj_name
142
- # 传入 package_type 获取 workflow_info
143
- app_info_obj, workflow_info = PgyerHelper.share_instace.prepare_upload(
144
- working_directory: Dir.pwd,
145
- proj_name: proj_name,
146
- package_type: 'zip'
147
- )
110
+ # 添加到任务管理器并执行
111
+ task_manager = Pindo::TaskSystem::TaskManager.instance
112
+ task_manager.clear_all
113
+ tasks.each { |task| task_manager.add_task(task) }
114
+ task_manager.start
148
115
 
149
- web_export_dir = File.join(pindo_project_dir, "GoodPlatform/WebGL")
150
-
151
- # 获取 zipCount 用于传递给 Unity 构建
152
- # 根据 workflow_info 的 package_name 从 JPS API 获取 WebGL 包的 indexNo
153
- zip_count = -1
154
- if workflow_info && workflow_info[:package_name]
155
- begin
156
- jps_client = JPSClient::Client.share_client
157
- project_id = jps_client.get_project_id
158
-
159
- # 根据 workflow_info 的 package_name 获取 WebGL 包列表
160
- result = jps_client.project_package.get_project_package_list(
161
- projectId: project_id,
162
- params: {
163
- pageNo: 1,
164
- pageSize: 1,
165
- nativePackageType: 'zip',
166
- packageName: workflow_info[:package_name]
167
- }
168
- )
169
-
170
- # 从返回结果中获取 indexNo
171
- if result && result['data'] && !result['data'].empty?
172
- latest_package = result['data'].first
173
- zip_count = latest_package['indexNo'] || 0
174
- puts " ✓ 获取到WebGL包序号: #{zip_count}"
175
- else
176
- puts " ⚠ 未找到WebGL包,使用初始序号: 0"
177
- zip_count = 0
178
- end
179
- rescue => e
180
- puts " ⚠ 获取WebGL包序号失败: #{e.message},使用默认值: -1"
181
- zip_count = -1
182
- end
183
- end
116
+ system "open #{pindo_project_dir}"
117
+
118
+ # 可选运行 WebGL
119
+ Pindo::Command::Web::Run.run([]) if @args_run_flag
120
+ end
121
+
122
+ private
123
+
124
+ # 准备 Web 配置
125
+ def prepare_web_config(pindo_project_dir)
126
+ # 获取 JPS 配置
127
+ app_info_obj, workflow_info = PgyerHelper.share_instace.prepare_upload(
128
+ working_directory: pindo_project_dir,
129
+ proj_name: @args_proj_name,
130
+ package_type: 'zip'
131
+ )
132
+
133
+ # 获取 WebGL 包序号
134
+ index_count = fetch_webgl_index_no(app_info_obj, workflow_info)
135
+
136
+ {
137
+ project_path: pindo_project_dir,
138
+ app_info_obj: app_info_obj,
139
+ workflow_info: workflow_info,
140
+ index_count: index_count
141
+ }
142
+ end
143
+
144
+ # 获取 WebGL 包序号
145
+ def fetch_webgl_index_no(app_info_obj, workflow_info)
146
+ index_count = -1
184
147
 
148
+ if workflow_info && workflow_info[:package_name] && app_info_obj
185
149
  begin
186
- unity_helper.build_project(unity_exe_full_path:unity_exe_path, project_path:pindo_project_dir, platform:'WebGL', indexNo:zip_count)
150
+ pgyer_helper = PgyerHelper.share_instace
151
+
152
+ result = pgyer_helper.instance_variable_get(:@pgyer_client).get_project_package_list(
153
+ projectId: app_info_obj["id"],
154
+ params: {
155
+ pageNo: 1,
156
+ pageSize: 1,
157
+ nativePackageType: 'zip',
158
+ packageName: workflow_info[:package_name]
159
+ }
160
+ )
161
+
162
+ if result && result['data'] && !result['data'].empty?
163
+ latest_package = result['data'].first
164
+ index_count = latest_package['indexNo'] || 0
165
+ else
166
+ index_count = 0
167
+ end
187
168
  rescue => e
188
- Funlog.instance.fancyinfo_error("调用GoodUnityBuild导出工程失败!")
189
- Funlog.instance.fancyinfo_error("错误信息: #{e.message}")
190
- raise e
169
+ puts " ⚠ 获取WebGL包序号失败: #{e.message}"
170
+ index_count = -1
191
171
  end
192
-
193
- build_path = File.join(web_export_dir, "build", "index.{html}")
194
- html_file_upload = Dir.glob(build_path).max_by {|f| File.mtime(f)}
195
- # 调试输出已移除,保持界面简洁
196
- # puts "html_file_upload: #{html_file_upload}"
197
- # puts "app_info_obj: #{app_info_obj}"
198
-
199
- if !html_file_upload.nil? && !app_info_obj.nil? && @args_upload_flag
200
- description = nil
201
- result_data = PgyerHelper.share_instace.start_upload(
202
- app_info_obj: app_info_obj,
203
- ipa_file_upload: html_file_upload,
204
- description: description,
205
- workflow_info: workflow_info
206
- )
207
- if !result_data.nil? && !result_data["data"].nil? && !result_data["data"]["id"].nil?
208
- PgyerHelper.share_instace.print_app_version_info(
209
- app_info_obj: app_info_obj,
210
- app_version_info_obj: result_data["data"]
211
- )
212
- if @args_send_flag
213
- # 始终发送给自己
214
- PgyerHelper.share_instace.send_apptest_msg(
215
- app_info_obj: app_info_obj,
216
- app_version_info_obj: result_data["data"],
217
- receiveType: "self"
218
- )
219
-
220
- # 额外发送到测试群
221
- PgyerHelper.share_instace.send_apptest_msg(
222
- app_info_obj: app_info_obj,
223
- app_version_info_obj: result_data["data"],
224
- chatEnv: "DevTest",
225
- receiveType: "chat"
226
- )
227
- end
228
- end
172
+ end
173
+
174
+ index_count
175
+ end
176
+
177
+ # 创建构建任务
178
+ def make_build_task(config)
179
+ # 检测项目类型
180
+ build_helper = Pindo::BuildHelper.share_instance
181
+ project_type = build_helper.project_type(config[:project_path])
182
+
183
+ case project_type
184
+ when :ios
185
+ raise Informative, "iOS 工程, 请使用 pindo ios autobuild"
186
+ when :android
187
+ raise Informative, "Android 工程, 请使用 pindo android autobuild"
188
+ when :unity
189
+ # Web 只支持 Unity 工程
190
+ tasks = []
191
+
192
+ # 1. Git 标签任务(如果需要上传)
193
+ if @args_upload_flag
194
+ git_tag_task = Pindo::TaskSystem::GitTagTask.new(
195
+ config[:project_path]
196
+ )
197
+ tasks << git_tag_task
229
198
  end
230
-
231
- system "open #{pindo_project_dir}"
232
199
 
233
- if @args_run_flag
234
- Pindo::Command::Web::Run.run([])
200
+ # 2. Unity 导出任务
201
+ # Web 平台导出路径
202
+ web_export_path = File.join(config[:project_path], "GoodPlatform", "WebGL")
203
+
204
+ unity_context = {}
205
+ unity_context[:project_name] = @args_proj_name if @args_proj_name
206
+ unity_context[:index_count] = config[:index_count]
207
+
208
+ unity_task = Pindo::TaskSystem::UnityExportTask.new(
209
+ 'web',
210
+ project_path: config[:project_path],
211
+ export_path: web_export_path,
212
+ context: unity_context
213
+ )
214
+ unity_task.dependencies << tasks.first.id if tasks.any?
215
+ tasks << unity_task
216
+
217
+ # 3. 构建任务(Web 只需要检查输出)
218
+ build_task = Pindo::TaskSystem::BuildTask.create_task(
219
+ platform: :web,
220
+ mode: :dev,
221
+ options: {
222
+ project_path: config[:project_path],
223
+ proj_name: @args_proj_name,
224
+ upload: @args_upload_flag,
225
+ send: @args_send_flag,
226
+ app_info_obj: config[:app_info_obj],
227
+ workflow_info: config[:workflow_info]
228
+ }
229
+ )
230
+ build_task.dependencies << unity_task.id
231
+ tasks << build_task
232
+
233
+ # 4. 上传任务(如果需要)
234
+ if @args_upload_flag
235
+ # WebGL 输出路径: GoodPlatform/WebGL/build
236
+ webgl_build_path = File.join(config[:project_path], 'GoodPlatform', 'WebGL', 'build')
237
+ upload_task = Pindo::TaskSystem::UploadTask.new(
238
+ 'html',
239
+ webgl_build_path,
240
+ nil,
241
+ app_info_obj: config[:app_info_obj],
242
+ workflow_info: config[:workflow_info],
243
+ project_name: @args_proj_name,
244
+ context: {
245
+ send_to_chat: @args_send_flag
246
+ },
247
+ dependencies: [build_task.id]
248
+ )
249
+ tasks << upload_task
235
250
  end
251
+
252
+ tasks
253
+ else
254
+ raise Informative, "Web 编译只支持 Unity 工程"
255
+ end
236
256
  end
237
257
 
238
258
 
@@ -69,9 +69,7 @@ module Pindo
69
69
  copy_so_files(unity_dir, project_dir)
70
70
 
71
71
  # SO 库拷贝完成后,重新配置主工程的 Java Home 和 Gradle 环境
72
- puts "\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
73
72
  puts "Unity SO库编译完成,切换到主工程编译环境"
74
- puts "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n"
75
73
  Pindo::JavaEnvHelper.setup_java_home_from_project(project_dir, use_main: true)
76
74
  Pindo::GradleHelper.check_gradle_with_project(project_dir, configure_main: true)
77
75
 
@@ -93,10 +91,6 @@ module Pindo
93
91
 
94
92
  # 配置 Keystore 签名
95
93
  build_type = debug ? "debug" : "release"
96
- puts "\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
97
- puts "配置 Keystore 签名 (#{build_type})"
98
- puts "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n"
99
-
100
94
  if Pindo::KeystoreHelper.apply_keystore_config(project_dir, build_type)
101
95
  puts "✓ Keystore 签名配置成功"
102
96
  else
@@ -4,6 +4,7 @@ require_relative '../../base/funlog'
4
4
  require_relative 'android_project_helper'
5
5
  require_relative '../../base/executable'
6
6
  require_relative 'android_res_helper'
7
+ require 'pindo/module/build/icon_downloader'
7
8
 
8
9
  module Pindo
9
10
 
@@ -931,32 +932,9 @@ module Pindo
931
932
  FileUtils.mkdir_p(temp_icon_dir) unless File.exist?(temp_icon_dir)
932
933
  icon_download_path = File.join(temp_icon_dir, "downloaded_icon.png")
933
934
 
934
- # 下载 icon
935
- Funlog.instance.fancyinfo_start("正在从 JPS 下载项目 Icon...")
936
-
937
- begin
938
- require 'open-uri'
939
- require 'openssl'
940
-
941
- options = {
942
- :read_timeout => 30,
943
- :open_timeout => 10,
944
- :redirect => true,
945
- :ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE
946
- }
947
-
948
- URI.open(icon_url, options) do |file|
949
- File.binwrite(icon_download_path, file.read)
950
- end
951
-
952
- Funlog.instance.fancyinfo_success("Icon 下载成功!")
953
- rescue => download_error
954
- raise Informative, "Icon 下载失败: #{download_error.message}"
955
- end
956
-
957
- # 验证文件已下载
958
- unless File.exist?(icon_download_path)
959
- Funlog.instance.fancyinfo_error("Icon 下载失败: 文件未创建")
935
+ # 使用带重试机制的下载
936
+ unless IconDownloader.download_icon_with_retry(icon_url: icon_url, save_path: icon_download_path, max_retries: 3)
937
+ Funlog.instance.fancyinfo_error("Icon 下载失败: 已重试3次")
960
938
  return false
961
939
  end
962
940