pindo 5.11.3 → 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
@@ -5,6 +5,7 @@ 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/build/git_repo_helper'
8
9
  require 'pindo/module/task/pindo_task'
9
10
  require 'pindo/module/task/task_manager'
10
11
  require 'pindo/module/task/model/build_task'
@@ -20,11 +21,11 @@ module Pindo
20
21
 
21
22
  include Pindo::Githelper
22
23
  # Unity 多平台编译和上传命令
23
- self.summary = '编译Unity工程生成iOS/Android/WebGL并支持上传到测试平台'
24
+ self.summary = '编译Unity工程,生成IPA、APK、Html文件(默认编译三个平台的包)并支持上传到JPS平台'
24
25
 
25
26
  # 详细说明
26
27
  self.description = <<-DESC
27
- 编译Unity工程并生成iOS IPA、Android APK和WebGL包,支持上传到JPS测试平台。
28
+ 编译Unity工程,生成IPA、APK、Html文件(默认编译三个平台的包)并支持上传到JPS平台。
28
29
 
29
30
  支持功能:
30
31
 
@@ -55,8 +56,6 @@ module Pindo
55
56
  $ pindo unity autobuild --upload # 编译所有类型并上传到JPS
56
57
 
57
58
  $ pindo unity autobuild --proj="My App" # 指定项目名称
58
-
59
- $ pindo unity autobuild --base # Unity lib模式
60
59
  DESC
61
60
 
62
61
  # 命令参数
@@ -72,7 +71,10 @@ DESC
72
71
  ['--proj=NAME', '指定上传到测试平台的项目名称'],
73
72
  ['--types=TYPES', '指定要构建的类型,逗号分隔(如:ipa,apk,html),默认全部类型'],
74
73
  ['--upload', '上传编译后的IPA/APK到测试平台'],
75
- ['--base', 'Unity工程编译lib模式(生成库而非完整应用)'],
74
+ ['--send', '发送通知到测试群组(同时也会发送给自己)'],
75
+ ['--adhoc', '使用AdHoc证书打包iOS(默认使用Dev证书)'],
76
+ ['--deploy', '使用发布证书打包iOS'],
77
+ ['--release', '使用Release模式构建Android(默认使用Debug)'],
76
78
  ].concat(super)
77
79
  end
78
80
 
@@ -81,11 +83,18 @@ DESC
81
83
 
82
84
  @args_proj_name = argv.option('proj')
83
85
  @args_upload_flag = argv.flag?('upload', false)
84
- @args_base_flag = argv.flag?('base', false)
86
+ @args_send_flag = argv.flag?('send', false)
87
+ @args_adhoc_flag = argv.flag?('adhoc', false)
88
+ @args_deploy_flag = argv.flag?('deploy', false)
89
+ @args_release_flag = argv.flag?('release', false)
85
90
  @args_bundle_id = argv.option('bundleid')
86
91
  @args_bundle_name = argv.option('bundle_name')
87
92
  @args_types = argv.option('types')
88
93
 
94
+ # 如果开启 send,自动开启 upload
95
+ if @args_send_flag
96
+ @args_upload_flag = true
97
+ end
89
98
 
90
99
  super
91
100
  end
@@ -131,277 +140,356 @@ DESC
131
140
  end
132
141
 
133
142
  if @args_upload_flag
134
- build_helper = Pindo::BuildHelper.share_instance
135
- is_need_add_tag,tag_action_parms = build_helper.check_is_need_add_tag?(pindo_project_dir)
143
+ git_repo_helper = Pindo::GitRepoHelper.share_instance
144
+ is_need_add_tag, tag_action_parms = git_repo_helper.check_is_need_add_tag?(pindo_project_dir)
136
145
  if is_need_add_tag
137
- Pindo::Command::Utils::Tag::run(tag_action_parms)
146
+ git_repo_helper.create_and_push_tag(
147
+ project_dir: pindo_project_dir,
148
+ mode: 'minor',
149
+ force_retag: tag_action_parms&.include?('--retag') || false,
150
+ custom_tag: nil,
151
+ release_branch: 'master'
152
+ )
138
153
  end
139
154
  end
140
155
 
141
- project_unity_version = unity_helper.get_unity_version(pindo_project_dir)
142
- unity_exe_path = unity_helper.find_unity_path(project_unity_version:project_unity_version, force_change_version: @force_select_unity)
143
- puts
144
- puts "工程的Unity版本: #{project_unity_version}"
145
- puts "选择的Unity路径: #{unity_exe_path}"
146
- puts
147
-
148
- proj_name = @args_proj_name
149
- @app_info_obj = PgyerHelper.share_instace.prepare_upload(working_directory:Dir.pwd, proj_name:proj_name)
150
-
151
- # 获取要构建的类型列表
156
+ # 1. 获取要构建的类型列表
152
157
  selected_platforms = get_selected_build_types()
153
158
 
154
- # 使用任务系统执行构建
155
- execute_with_task_system(selected_platforms, unity_helper, unity_exe_path)
156
- end
159
+ # 2. 按平台顺序准备所有配置(iOS → Android → Web)
160
+ all_platform_configs = prepare_all_platform_configs(selected_platforms)
157
161
 
158
- def execute_with_task_system(selected_platforms, unity_helper, unity_exe_path)
159
- # 初始化任务管理器
162
+ # 3. 按平台顺序创建所有任务
163
+ all_tasks = make_task_with_config(selected_platforms, all_platform_configs)
164
+
165
+ # 4. 统一添加到任务管理器并执行
160
166
  task_manager = Pindo::TaskSystem::TaskManager.instance
161
167
  task_manager.clear_all # 清空之前的任务
162
168
 
163
- # 类型到显示名称的映射
164
- display_names = {
165
- 'ios' => 'IPA',
166
- 'android' => 'APK',
167
- 'web' => 'HTML'
168
- }
169
-
170
- # 显示任务计划
171
- puts
172
- puts "========================================".cyan
173
- puts "任务执行计划".green
174
- puts "========================================".cyan
175
- puts "构建类型: #{selected_platforms.map { |p| display_names[p] }.join(', ')}"
176
- puts "上传: #{@args_upload_flag ? '是' : '否'}"
177
-
178
- task_count = selected_platforms.length * 2 # Unity导出 + 构建
179
- task_count += selected_platforms.length if @args_upload_flag # 上传任务
180
- puts "总任务数: #{task_count}"
181
- puts "========================================".cyan
182
- puts
183
-
184
- # 创建任务
185
- unity_tasks = {}
186
- build_tasks = {}
187
- upload_tasks = {}
188
-
189
- # 1. 创建 Unity 导出任务
190
- selected_platforms.each do |platform|
191
- unity_task = Pindo::TaskSystem::UnityExportTask.new(
192
- platform,
193
- project_path: Dir.pwd,
194
- unity_exe_path: unity_exe_path,
195
- unity_helper: unity_helper,
196
- context: {
197
- project_name: @app_info_obj["projectName"]
198
- }
199
- )
200
- unity_tasks[platform] = unity_task
201
- task_manager.add_task(unity_task)
169
+ # 按顺序添加所有任务
170
+ all_tasks.each do |task|
171
+ task_manager.add_task(task)
202
172
  end
203
173
 
204
- # 2. 创建构建任务
174
+ # 执行任务
175
+ task_manager.start
176
+ end
177
+
178
+ # 按平台顺序创建所有任务
179
+ def make_task_with_config(selected_platforms, all_platform_configs)
180
+ all_tasks = []
181
+ build_tasks = [] # 收集所有构建任务
182
+
183
+ # 第一步:创建所有导出和构建任务
205
184
  selected_platforms.each do |platform|
206
- # 准备构建配置
207
- build_config = prepare_build_config(platform)
208
-
209
- build_task = Pindo::TaskSystem::BuildTask.new(
210
- platform,
211
- project_path: Dir.pwd,
212
- build_config: build_config,
213
- context: {
214
- project_name: @app_info_obj["projectName"],
215
- bundle_id: build_config[:bundle_id],
216
- bundle_name: build_config[:bundle_name]
217
- },
218
- dependencies: [unity_tasks[platform].id] # 依赖 Unity 导出
219
- )
220
- build_tasks[platform] = build_task
221
- task_manager.add_task(build_task)
185
+ platform_config = all_platform_configs[platform]
186
+
187
+ # 1. 创建 Unity 导出任务
188
+ unity_task = create_unity_export_task(platform, all_platform_configs)
189
+ all_tasks << unity_task
190
+
191
+ # 2. 创建构建任务
192
+ build_task = create_build_task(platform, platform_config, all_platform_configs, unity_task)
193
+ all_tasks << build_task
194
+ build_tasks << build_task # 收集构建任务
222
195
  end
223
196
 
224
- # 3. 如果需要上传,创建上传任务
197
+ # 第二步:创建所有上传任务(如果需要)
225
198
  if @args_upload_flag
226
- selected_platforms.each do |platform|
227
- upload_task = Pindo::TaskSystem::UploadTask.new(
228
- platform,
229
- nil, # 文件路径将从构建任务结果获取
230
- project_name: @app_info_obj["projectName"],
231
- context: {
232
- project_name: @app_info_obj["projectName"]
233
- },
234
- dependencies: [build_tasks[platform].id] # 依赖构建任务
235
- )
199
+ selected_platforms.each_with_index do |platform, index|
200
+ # 获取对应平台的构建任务
201
+ platform_build_task = build_tasks[index]
202
+
203
+ # 创建上传任务
204
+ upload_task = create_upload_task(platform, all_platform_configs, platform_build_task)
236
205
 
237
- # 设置构建完成后传递输出路径
238
- build_tasks[platform].on(:on_success) do |task|
239
- if task.result && task.result[:output]
240
- upload_task.context[:output_path] = task.result[:output]
206
+ # 让上传任务依赖所有构建任务完成
207
+ build_tasks.each do |build_task|
208
+ unless upload_task.dependencies.include?(build_task.id)
209
+ upload_task.dependencies << build_task.id
241
210
  end
242
211
  end
243
212
 
244
- upload_tasks[platform] = upload_task
245
- task_manager.add_task(upload_task)
213
+ all_tasks << upload_task
246
214
  end
247
215
  end
248
216
 
249
- # 执行任务
250
- task_manager.start
251
-
252
- # 显示执行报告
253
- show_execution_report(task_manager.execution_report)
217
+ # 返回所有任务
218
+ all_tasks
254
219
  end
255
220
 
256
- def prepare_build_config(platform)
257
- config = {}
258
-
221
+ # 获取平台对应的导出/构建路径
222
+ # 优先使用 Base 目录,如果不存在则使用普通目录
223
+ def get_platform_path(platform)
259
224
  case platform
260
225
  when 'ios'
261
- # 获取 iOS Bundle ID
262
- if @args_bundle_id
263
- config[:bundle_id] = @args_bundle_id
264
- else
265
- if @args_deploy_flag
266
- config[:bundle_id] = get_selected_deploy_bundleid()
267
- else
268
- config[:bundle_id] = get_selected_dev_bundleid()
269
- end
270
- end
271
- when 'android', 'web'
272
- # 获取 Android/Web Bundle Name
273
- if @args_bundle_name
274
- config[:bundle_name] = @args_bundle_name
275
- else
276
- config[:bundle_name] = get_selected_dev_bundle_name()
277
- end
226
+ base_ios_path = File.join(Dir.pwd, "GoodPlatform", "BaseiOS")
227
+ ios_path = File.join(Dir.pwd, "GoodPlatform", "iOS")
228
+ File.exist?(base_ios_path) ? base_ios_path : ios_path
229
+ when 'android'
230
+ base_android_path = File.join(Dir.pwd, "GoodPlatform", "BaseAndroid")
231
+ android_path = File.join(Dir.pwd, "GoodPlatform", "Android")
232
+ File.exist?(base_android_path) ? base_android_path : android_path
233
+ when 'web'
234
+ File.join(Dir.pwd, "GoodPlatform", "WebGL")
235
+ else
236
+ Dir.pwd
278
237
  end
238
+ end
279
239
 
280
- config
240
+ # 创建 Unity 导出任务
241
+ def create_unity_export_task(platform, all_platform_configs)
242
+ platform_config = all_platform_configs[platform]
243
+
244
+ # 构建 context
245
+ context = {
246
+ }
247
+
248
+ # 添加 project_name
249
+ context[:project_name] = all_platform_configs["project_name"] if all_platform_configs["project_name"]
250
+
251
+ # 添加 index_count
252
+ context[:index_count] = platform_config["index_count"] if platform_config["index_count"]
253
+
254
+ # 获取平台路径
255
+ export_path = get_platform_path(platform)
256
+
257
+ Pindo::TaskSystem::UnityExportTask.new(
258
+ platform,
259
+ project_path: Dir.pwd,
260
+ export_path: export_path,
261
+ context: context
262
+ )
281
263
  end
282
264
 
283
- def show_execution_report(report)
284
- puts
285
- puts "========================================".cyan
286
- puts "任务执行报告".green
287
- puts "========================================".cyan
288
-
289
- # 显示统计
290
- puts "执行统计:"
291
- puts " 成功: #{report[:success]}".green if report[:success] > 0
292
- puts " 失败: #{report[:failed]}".red if report[:failed] > 0
293
- puts
294
-
295
- # 显示每个任务的状态
296
- puts "任务详情:"
297
- report[:tasks].each do |task|
298
- status_icon = case task[:status]
299
- when :success then "✅"
300
- when :failed then "❌"
301
- when :cancelled then "⏹"
302
- else "⏸"
303
- end
304
-
305
- status_color = case task[:status]
306
- when :success then :green
307
- when :failed then :red
308
- when :cancelled then :yellow
309
- else :gray
310
- end
311
-
312
- time_str = task[:execution_time] ? " (#{task[:execution_time].round(2)}s)" : ""
313
- status_str = "#{status_icon} #{task[:name]}#{time_str}"
314
-
315
- if status_color == :green && defined?(String.green)
316
- puts status_str.green
317
- elsif status_color == :red && defined?(String.red)
318
- puts status_str.red
319
- elsif status_color == :yellow && defined?(String.yellow)
320
- puts status_str.yellow
321
- else
322
- puts status_str
323
- end
265
+ # 创建构建任务
266
+ def create_build_task(platform, platform_config, all_platform_configs, unity_task)
267
+ # 确定构建模式
268
+ build_mode = determine_build_mode(platform)
269
+
270
+ # 获取平台路径
271
+ platform_path = get_platform_path(platform)
272
+
273
+ # 准备构建选项
274
+ build_options = {
275
+ proj_name: all_platform_configs["project_name"],
276
+ upload: @args_upload_flag,
277
+ send: @args_send_flag,
278
+ app_info_obj: all_platform_configs["app_info_obj"], # 共享的项目信息
279
+ workflow_info: platform_config["workflow_info"], # 平台特定的工作流
280
+ project_path: platform_path
281
+ }
324
282
 
325
- if task[:status] == :failed && task[:error]
326
- puts " 错误: #{task[:error]}".red if defined?(String.red)
327
- end
283
+ # 设置平台特定参数
284
+ case platform
285
+ when 'ios'
286
+ build_options[:bundle_id] = platform_config["bundle_id"]
287
+ build_options[:unity_root_path] = Dir.pwd # 传递 Unity 根目录路径
288
+ when 'android'
289
+ build_options[:bundle_name] = platform_config["bundle_name"]
290
+ when 'web'
291
+ build_options[:project_path] = Dir.pwd # Web 平台使用根目录
292
+ build_options[:force_select_unity] = false
328
293
  end
329
294
 
330
- puts "========================================".cyan
295
+ # 使用工厂方法创建任务
296
+ build_task = Pindo::TaskSystem::BuildTask.create_task(
297
+ platform: platform,
298
+ mode: build_mode,
299
+ options: build_options
300
+ )
301
+
302
+ # 设置依赖关系
303
+ build_task.dependencies << unity_task.id
304
+
305
+ build_task
331
306
  end
332
307
 
333
- def web_autobuild(unity_helper:nil, unity_exe_path:nil)
308
+ # 创建上传任务
309
+ def create_upload_task(platform, all_platform_configs, build_task)
310
+ # 获取平台路径
311
+ platform_path = get_platform_path(platform)
312
+
313
+ # 获取平台特定的配置
314
+ platform_config = all_platform_configs[platform]
315
+
316
+ # 确定文件类型和上传路径
317
+ file_type, upload_path = case platform
318
+ when 'ios'
319
+ ['ipa', File.join(platform_path, 'build')]
320
+ when 'android'
321
+ ['apk', File.join(platform_path, 'build')]
322
+ when 'web'
323
+ ['html', File.join(platform_path, 'build')]
324
+ else
325
+ [platform, platform_path]
326
+ end
327
+
328
+ upload_task = Pindo::TaskSystem::UploadTask.new(
329
+ file_type,
330
+ upload_path,
331
+ nil,
332
+ app_info_obj: all_platform_configs["app_info_obj"], # 使用共享的项目信息
333
+ workflow_info: platform_config["workflow_info"], # 使用平台特定的工作流
334
+ project_name: all_platform_configs["project_name"],
335
+ context: {
336
+ send_to_chat: @args_send_flag # 是否发送到测试群
337
+ },
338
+ dependencies: [build_task.id] # 依赖构建任务
339
+ )
340
+
341
+ upload_task
342
+ end
334
343
 
335
- args_temp = []
344
+ # 按平台顺序准备所有配置(iOS → Android → Web)
345
+ def prepare_all_platform_configs(selected_platforms)
336
346
 
337
- if @main_bundle_name
338
- args_temp << "--bundle_name=#{@main_bundle_name}"
339
- end
347
+ # 按优先级排序:iOS → Android → Web
348
+ platform_order = ['ios', 'android', 'web']
349
+ sorted_platforms = selected_platforms.sort_by { |p| platform_order.index(p) || 999 }
340
350
 
341
- if @args_upload_flag
342
- args_temp << "--proj=#{@app_info_obj["projectName"]}"
343
- args_temp << "--upload"
344
- end
351
+ # 初始化配置结构
352
+ configs = {
353
+ "project_name" => nil,
354
+ "app_info_obj" => nil,
355
+ "ios" => {},
356
+ "android" => {},
357
+ "web" => {}
358
+ }
345
359
 
346
- Pindo::Command::Android::Autobuild::run(args_temp)
360
+ # ========== 为每个平台准备特定配置 ==========
361
+
362
+ sorted_platforms.each do |platform|
363
+ puts "\n准备 #{platform.upcase} 配置:"
364
+ puts "----------------------------------------"
365
+
366
+ platform_config = {}
367
+
368
+ # 确定当前平台的 package_type
369
+ package_type = case platform
370
+ when 'ios'
371
+ 'ipa'
372
+ when 'android'
373
+ 'apk'
374
+ when 'web'
375
+ 'zip'
376
+ else
377
+ 'ipa'
378
+ end
379
+
380
+ # 获取当前平台的 JPS 配置
381
+ app_info_obj, workflow_info = PgyerHelper.share_instace.prepare_upload(
382
+ working_directory: Dir.pwd,
383
+ proj_name: @args_proj_name,
384
+ package_type: package_type
385
+ )
347
386
 
348
- end
349
-
387
+ # 保存 app_info_obj 到共享配置(所有平台共享同一个项目)
388
+ if configs["app_info_obj"].nil?
389
+ configs["app_info_obj"] = app_info_obj
390
+ configs["project_name"] = app_info_obj ? app_info_obj["projectName"] : nil
391
+ end
350
392
 
351
- def ios_autobuild(unity_helper:nil, unity_exe_path:nil)
393
+ # 保存平台特定的 workflow_info(每个平台有不同的工作流)
394
+ platform_config["workflow_info"] = workflow_info
352
395
 
353
- pindo_project_dir = Dir.pwd
354
- mainapp_bundleid= nil
355
- if @args_bundle_id
356
- mainapp_bundleid = @args_bundle_id
357
- else
358
- if @args_deploy_flag
359
- mainapp_bundleid = get_selected_deploy_bundleid()
360
- else
361
- mainapp_bundleid = get_selected_dev_bundleid()
396
+ puts " ✓ Project: #{app_info_obj ? app_info_obj["projectName"] : "N/A"}"
397
+ puts " ✓ Package Type: #{package_type}"
398
+ puts " ✓ Workflow: #{workflow_info[:package_name]}" if workflow_info
399
+
400
+ case platform
401
+ when 'ios'
402
+ # 获取 iOS Bundle ID
403
+ if @args_bundle_id
404
+ platform_config["bundle_id"] = @args_bundle_id
405
+ else
406
+ if @args_deploy_flag
407
+ platform_config["bundle_id"] = get_selected_deploy_bundleid()
408
+ else
409
+ platform_config["bundle_id"] = get_selected_dev_bundleid()
410
+ end
411
+ end
412
+ puts " Bundle ID: #{platform_config["bundle_id"]}"
413
+
414
+ when 'android'
415
+ # 获取 Android Package Name
416
+ if @args_bundle_name
417
+ platform_config["bundle_name"] = @args_bundle_name
418
+ else
419
+ platform_config["bundle_name"] = get_selected_dev_bundle_name()
420
+ end
421
+ puts " Package Name: #{platform_config["bundle_name"]}"
422
+
423
+ when 'web'
424
+ # Web 平台获取 indexNo
425
+ platform_config["index_count"] = fetch_webgl_index_no(
426
+ app_info_obj: app_info_obj,
427
+ workflow_info: workflow_info
428
+ )
429
+ puts " WebGL Index: #{platform_config["index_count"]}"
362
430
  end
363
- end
364
-
365
- args_temp = []
366
- args_temp << "--bundleid=#{mainapp_bundleid}"
367
431
 
368
- if @args_upload_flag
369
- args_temp << "--proj=#{@app_info_obj["projectName"]}"
370
- args_temp << "--upload"
432
+ # 存储平台配置
433
+ configs[platform] = platform_config
371
434
  end
372
-
373
-
374
- Pindo::Command::Ios::Autobuild::run(args_temp)
375
435
 
436
+ configs
376
437
  end
377
438
 
378
- def and_autobuild(unity_helper:nil, unity_exe_path:nil)
379
-
439
+ private
380
440
 
381
- @main_bundle_name = nil
382
- if @args_bundle_name
383
- @main_bundle_name = @args_bundle_name
384
- else
385
- @main_bundle_name = get_selected_dev_bundle_name()
386
- end
441
+ # 获取 WebGL 包序号
442
+ def fetch_webgl_index_no(app_info_obj:, workflow_info:)
443
+ index_count = -1
387
444
 
388
- puts "Unity项目构建完成,准备处理Android项目..."
389
- args_temp = []
445
+ if workflow_info && workflow_info[:package_name] && app_info_obj
446
+ begin
447
+ pgyer_helper = PgyerHelper.share_instace
390
448
 
391
- if @main_bundle_name
392
- args_temp << "--bundle_name=#{@main_bundle_name}"
393
- end
449
+ result = pgyer_helper.instance_variable_get(:@pgyer_client).get_project_package_list(
450
+ projectId: app_info_obj["id"],
451
+ params: {
452
+ pageNo: 1,
453
+ pageSize: 1,
454
+ nativePackageType: 'zip',
455
+ packageName: workflow_info[:package_name]
456
+ }
457
+ )
394
458
 
395
- if @args_upload_flag
396
- args_temp << "--proj=#{@app_info_obj["projectName"]}"
397
- args_temp << "--upload"
459
+ if result && result['data'] && !result['data'].empty?
460
+ latest_package = result['data'].first
461
+ index_count = latest_package['indexNo'] || 0
462
+ else
463
+ index_count = 0
464
+ end
465
+ rescue => e
466
+ puts " ⚠ 获取WebGL包序号失败: #{e.message}"
467
+ index_count = -1
468
+ end
398
469
  end
399
470
 
400
- Pindo::Command::Android::Autobuild::run(args_temp)
401
-
471
+ index_count
402
472
  end
403
473
 
404
-
474
+ # 确定构建模式
475
+ def determine_build_mode(platform)
476
+ case platform
477
+ when 'ios'
478
+ # iOS 支持 dev/adhoc/release
479
+ return :release if @args_deploy_flag
480
+ return :adhoc if @args_adhoc_flag
481
+ return :dev
482
+ when 'android'
483
+ # Android 支持 dev/release
484
+ return :release if @args_release_flag
485
+ return :dev
486
+ when 'web'
487
+ # Web 目前只有 dev 模式
488
+ return :dev
489
+ else
490
+ return :dev
491
+ end
492
+ end
405
493
  end
406
494
  end
407
495
  end
@@ -1,8 +1,5 @@
1
1
 
2
2
 
3
- require 'pindo/command/unity/ipa'
4
- require 'pindo/command/unity/apk'
5
- require 'pindo/command/unity/web'
6
3
  require 'pindo/command/unity/autobuild'
7
4
  require 'pindo/command/unity/packinit'
8
5
  require 'pindo/command/unity/packbuild'