pindo 5.11.4 → 5.12.2

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