pindo 5.6.3 → 5.6.5

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: 380db3ee1ad0c4583d215d3186a2481f7daa9c66d1f1c64b4b92cf249a410ecf
4
- data.tar.gz: 6051ed21964c7d499718593e24e9f36211f86478109752467fe37673f76e5a9e
3
+ metadata.gz: 6bea8c2179701b8869f82fa53f1c956bdde75bd26e92a60d07da6e290642ef19
4
+ data.tar.gz: 85d684d5255bc4bd2e7ae86ad31abd4e271724f1f5a797cace70bdf36eb9b267
5
5
  SHA512:
6
- metadata.gz: 667ea2d4a16d1b8d5581bf69b920158c1e34711fa29fe8f532074d0e85b34629668b641fa4df7436e830466a100e78506b83107f744980520f1439cb2b6fcff5
7
- data.tar.gz: 073d4acec0c92f7592b1ce7a64a1eb0fc2db7858b89a82fd543f9e95da250da5c8eb100b8218b201547a39ab8863d1ece4d57c8ecddbb914bcfae5808464eadd
6
+ metadata.gz: 36db0639bfe1a0b487dcfef67dd7ccb7d7e51639bfff01e2eca2573214a0ca9feb99dd0b6a941acfd194b49dac16c6ab6276720c956b84cab0e21d85edd4d7b6
7
+ data.tar.gz: a8aa894eb0683a94a38cbca61def8ee1c7718635ec8d5ff36fb98ae19e8f3bf6dee08f5026190201a74db56f00ba798c082b27dcce4d8c92482aa9a3798509fe
@@ -5,6 +5,14 @@ require 'fileutils'
5
5
 
6
6
  module Pindo
7
7
  class PindoContext
8
+ # 选择键定义
9
+ module SelectionKey
10
+ TAG_DECISION = :tag_decision # 打Tag决定
11
+ PROJECT_NAME = :project_name # 项目名称
12
+ BUNDLE_ID = :bundle_id # Bundle ID
13
+ CERT_TYPE = :cert_type # 证书类型
14
+ end
15
+
8
16
  include Singleton
9
17
 
10
18
  attr_reader :current_command, :current_directory
@@ -17,6 +25,8 @@ module Pindo
17
25
  @cache_enabled = false # 默认禁用缓存
18
26
  @command_group = nil # 命令组名称
19
27
  @verbose = false # 是否输出详细日志
28
+ @loaded_file_cache = nil # 已加载但未应用的文件缓存数据
29
+ @cache_confirmed = false # 标记缓存确认是否已完成
20
30
  ensure_cache_dir
21
31
  end
22
32
 
@@ -52,10 +62,10 @@ module Pindo
52
62
  puts "[PindoContext] options: #{options.inspect}"
53
63
  end
54
64
 
55
- # 仅在启用缓存时加载文件缓存
65
+ # 仅在启用缓存时加载文件缓存(不确认,只加载到临时变量)
56
66
  if @cache_enabled && !@file_cache_loaded
57
67
  puts "[PindoContext] 准备加载文件缓存..." if verbose?
58
- load_file_cache_with_confirmation
68
+ load_file_cache
59
69
  @file_cache_loaded = true
60
70
  else
61
71
  if verbose?
@@ -79,6 +89,7 @@ module Pindo
79
89
  @file_cache_loaded = false
80
90
  @cache_enabled = false
81
91
  @command_group = nil
92
+ @cache_confirmed = false
82
93
  # 暂不清理内存缓存,让同一进程内可以复用
83
94
  end
84
95
 
@@ -143,7 +154,7 @@ module Pindo
143
154
  def enable_cache(enabled = true)
144
155
  @cache_enabled = enabled
145
156
  if enabled && !@file_cache_loaded && @current_command
146
- load_file_cache_with_confirmation
157
+ load_file_cache
147
158
  @file_cache_loaded = true
148
159
  end
149
160
  end
@@ -207,14 +218,6 @@ module Pindo
207
218
  end
208
219
  end
209
220
 
210
- # 选择键定义
211
- module SelectionKey
212
- TAG_DECISION = :tag_decision # 打Tag决定
213
- PROJECT_NAME = :project_name # 项目名称
214
- BUNDLE_ID = :bundle_id # Bundle ID
215
- CERT_TYPE = :cert_type # 证书类型
216
- end
217
-
218
221
  private
219
222
 
220
223
  # 递归将Hash的键从字符串转换为符号
@@ -243,14 +246,15 @@ module Pindo
243
246
  File.join(cache_dir, 'context_selections.json')
244
247
  end
245
248
 
246
- # 加载文件缓存并确认(三级结构)
247
- def load_file_cache_with_confirmation
249
+ # 加载文件缓存(仅加载,不确认)
250
+ def load_file_cache
248
251
  file_path = cache_file_path
249
252
 
250
253
  puts "[PindoContext] 检查文件缓存: #{file_path}" if verbose?
251
254
 
252
255
  unless File.exist?(file_path)
253
256
  puts "[PindoContext] 文件缓存不存在,跳过加载" if verbose?
257
+ @loaded_file_cache = nil
254
258
  return
255
259
  end
256
260
 
@@ -261,109 +265,31 @@ module Pindo
261
265
  # 清理过期缓存(超过7天)
262
266
  file_cache = clean_expired_cache(file_cache)
263
267
 
264
- # 获取当前项目和命令的缓存
268
+ # 保存加载的缓存数据,但不应用到内存
269
+ @loaded_file_cache = file_cache
270
+
271
+ # 加载其他项目/命令的缓存到内存(不需要确认的部分)
265
272
  project_path = get_project_path
266
273
  root_command = @command_group || @current_command
267
274
 
268
- puts "[PindoContext] 查找缓存: [#{project_path}][#{root_command}]" if verbose?
269
-
270
- # 检查三级结构中是否有当前上下文的缓存
271
- cached_selections = file_cache.dig(project_path, root_command)
272
-
273
- if cached_selections && !cached_selections.empty?
274
- # 根据命令组显示更友好的描述
275
- group_desc = case root_command
276
- when 'ios:autobuild'
277
- 'iOS 构建'
278
- when 'and:autobuild', 'android:autobuild'
279
- 'Android 构建'
280
- when 'web:autobuild'
281
- 'Web 构建'
282
- else
283
- @current_command # 其他命令显示原始命令名
284
- end
285
-
286
- puts "\n检测到之前的选择 (#{group_desc}):"
287
- puts "────────────────────────────────────────"
288
-
289
- cached_selections.each do |key, value|
290
- # 跳过内部字段
291
- next if key.to_s.start_with?('__')
292
-
293
- case key.to_s
294
- when 'bundle_id'
295
- puts " Bundle ID: #{value}"
296
- when 'project_name', 'app_key' # 兼容旧的 app_key
297
- puts " 项目名称: #{value}"
298
- when 'tag_decision'
299
- if value.is_a?(Hash)
300
- action_desc = value['description'] || value['action']
301
- puts " Tag决定: #{action_desc}"
302
- end
303
- when 'cert_type'
304
- puts " 证书类型: #{value}"
305
- end
306
- end
307
- puts "────────────────────────────────────────"
308
-
309
- # 检查是否设置了强制编译环境变量
310
- force_build = ENV['PINDO_FORCE_BUILD']
311
-
312
- if force_build && !force_build.empty?
313
- # 环境变量存在,自动使用缓存
314
- puts "\n检测到 PINDO_FORCE_BUILD 环境变量,自动使用缓存的选择"
315
- confirm = true
316
- else
317
- # 询问用户是否使用缓存
318
- require 'highline/import'
319
- cli = HighLine.new
320
- confirm = cli.agree("\n是否使用以上缓存的选择? (y/n) ")
321
- end
275
+ file_cache.each do |proj_path, commands|
276
+ @memory_selections[proj_path] ||= {}
277
+ commands.each do |cmd, selections|
278
+ # 跳过当前上下文(需要确认)
279
+ next if proj_path == project_path && cmd == root_command
322
280
 
323
- if confirm
324
- puts "使用缓存的选择\n" unless force_build
325
- # 恢复三级结构的文件缓存到内存缓存
326
- file_cache.each do |proj_path, commands|
327
- @memory_selections[proj_path] ||= {}
328
- commands.each do |cmd, selections|
329
- @memory_selections[proj_path][cmd] ||= {}
330
- selections.each do |key, value|
331
- symbol_key = key.to_sym
332
- @memory_selections[proj_path][cmd][symbol_key] = symbolize_keys(value)
333
- end
334
- end
335
- end
336
- else
337
- puts "清除缓存,重新选择\n"
338
- # 清除当前上下文的文件缓存(三级结构)
339
- if file_cache[project_path] && file_cache[project_path][root_command]
340
- file_cache[project_path].delete(root_command)
341
- # 如果项目路径下没有任何命令缓存了,删除项目路径键
342
- file_cache.delete(project_path) if file_cache[project_path].empty?
343
- end
344
- File.write(file_path, JSON.pretty_generate(file_cache))
345
- # 不加载任何缓存到内存
346
- end
347
- else
348
- # 加载整个文件缓存到内存(不需要确认)
349
- file_cache.each do |proj_path, commands|
350
- @memory_selections[proj_path] ||= {}
351
- commands.each do |cmd, selections|
352
- # 跳过当前上下文(已经是空的)
353
- next if proj_path == project_path && cmd == root_command
354
-
355
- @memory_selections[proj_path][cmd] ||= {}
356
- selections.each do |key, value|
357
- symbol_key = key.to_sym
358
- @memory_selections[proj_path][cmd][symbol_key] = symbolize_keys(value)
359
- end
281
+ @memory_selections[proj_path][cmd] ||= {}
282
+ selections.each do |key, value|
283
+ symbol_key = key.to_sym
284
+ @memory_selections[proj_path][cmd][symbol_key] = symbolize_keys(value)
360
285
  end
361
286
  end
362
287
  end
363
288
 
364
- puts "[PindoContext] 处理文件缓存: #{file_path}" if verbose?
289
+ puts "[PindoContext] 已加载文件缓存到临时存储" if verbose?
365
290
  rescue => e
366
291
  puts "[PindoContext] 加载缓存失败: #{e.message}" if verbose?
292
+ @loaded_file_cache = nil
367
293
  end
368
294
  end
369
295
 
@@ -485,6 +411,160 @@ module Pindo
485
411
 
486
412
  public
487
413
 
414
+ # 加载 JPSBuildConfig.json 并覆盖项目名称(如果存在)
415
+ # 应在 confirm_and_apply_cache 之前调用
416
+ def load_and_apply_jps_config(project_dir = nil)
417
+ project_dir ||= get_project_path
418
+
419
+ # 判断工程类型并确定配置文件路径
420
+ # Unity 工程:ProjectSettings/JPSBuildConfig.json
421
+ # iOS/Android 工程:JPSBuildConfig.json
422
+ config_file = nil
423
+ project_type = nil
424
+
425
+ # 检查是否是 Unity 工程(存在 ProjectSettings 目录)
426
+ if File.directory?(File.join(project_dir, 'ProjectSettings'))
427
+ config_file = File.join(project_dir, 'ProjectSettings', 'JPSBuildConfig.json')
428
+ project_type = 'Unity'
429
+ else
430
+ # iOS/Android 工程,直接在根目录
431
+ config_file = File.join(project_dir, 'JPSBuildConfig.json')
432
+ project_type = 'iOS/Android'
433
+ end
434
+
435
+ unless File.exist?(config_file)
436
+ puts "[PindoContext] JPSBuildConfig.json 不存在 (#{project_type} 工程),跳过" if verbose?
437
+ return nil
438
+ end
439
+
440
+ begin
441
+ config_content = File.read(config_file)
442
+ jps_config = JSON.parse(config_content)
443
+
444
+ if jps_config['project_name'] && !jps_config['project_name'].empty?
445
+ project_name = jps_config['project_name']
446
+ puts "[PindoContext] 从 JPSBuildConfig.json 加载项目名称 (#{project_type}): #{project_name}" if verbose?
447
+
448
+ # 设置到当前上下文的缓存中
449
+ set_selection(SelectionKey::PROJECT_NAME, project_name)
450
+
451
+ puts "使用 JPS 配置的项目名称: #{project_name}"
452
+ return project_name
453
+ end
454
+ rescue => e
455
+ puts "[PindoContext] 加载 JPSBuildConfig.json 失败: #{e.message}" if verbose?
456
+ end
457
+
458
+ nil
459
+ end
460
+
461
+ # 确认并应用缓存(供命令在 run 函数中调用)
462
+ # 返回值:true 表示使用缓存,false 表示不使用缓存
463
+ def confirm_and_apply_cache
464
+ return false unless @cache_enabled
465
+ return false unless @loaded_file_cache
466
+
467
+ # 如果已经确认过缓存,直接返回(避免嵌套调用时重复询问)
468
+ if @cache_confirmed
469
+ puts "[PindoContext] 缓存已确认,跳过重复询问" if verbose?
470
+ # 检查内存中是否已有缓存数据
471
+ project_path = get_project_path
472
+ root_command = @command_group || @current_command
473
+ return @memory_selections.dig(project_path, root_command) != nil
474
+ end
475
+
476
+ project_path = get_project_path
477
+ root_command = @command_group || @current_command
478
+
479
+ return false unless project_path && root_command
480
+
481
+ # 检查三级结构中是否有当前上下文的缓存
482
+ cached_selections = @loaded_file_cache.dig(project_path, root_command)
483
+
484
+ unless cached_selections && !cached_selections.empty?
485
+ puts "[PindoContext] 当前上下文没有缓存数据" if verbose?
486
+ return false
487
+ end
488
+
489
+ # 根据命令组显示更友好的描述
490
+ group_desc = case root_command
491
+ when 'ios:autobuild'
492
+ 'iOS 构建'
493
+ when 'and:autobuild', 'android:autobuild'
494
+ 'Android 构建'
495
+ when 'web:autobuild'
496
+ 'Web 构建'
497
+ else
498
+ @current_command # 其他命令显示原始命令名
499
+ end
500
+
501
+ puts "\n检测到之前的选择 (#{group_desc}):"
502
+ puts "────────────────────────────────────────"
503
+
504
+ cached_selections.each do |key, value|
505
+ # 跳过内部字段
506
+ next if key.to_s.start_with?('__')
507
+
508
+ case key.to_s
509
+ when 'bundle_id'
510
+ puts " Bundle ID: #{value}"
511
+ when 'project_name', 'app_key' # 兼容旧的 app_key
512
+ puts " 项目名称: #{value}"
513
+ when 'tag_decision'
514
+ if value.is_a?(Hash)
515
+ action_desc = value['description'] || value['action']
516
+ puts " Tag决定: #{action_desc}"
517
+ end
518
+ when 'cert_type'
519
+ puts " 证书类型: #{value}"
520
+ end
521
+ end
522
+ puts "────────────────────────────────────────"
523
+
524
+ # 检查是否设置了强制编译环境变量
525
+ force_build = ENV['PINDO_FORCE_BUILD']
526
+
527
+ confirm = false
528
+ if force_build && !force_build.empty?
529
+ # 环境变量存在,自动使用缓存
530
+ puts "\n检测到 PINDO_FORCE_BUILD 环境变量,自动使用缓存的选择"
531
+ confirm = true
532
+ else
533
+ # 询问用户是否使用缓存
534
+ require 'highline/import'
535
+ cli = HighLine.new
536
+ confirm = cli.agree("\n是否使用以上缓存的选择? (y/n) ")
537
+ end
538
+
539
+ if confirm
540
+ puts "使用缓存的选择\n" unless force_build
541
+ # 恢复当前上下文的文件缓存到内存缓存
542
+ @memory_selections[project_path] ||= {}
543
+ @memory_selections[project_path][root_command] ||= {}
544
+ cached_selections.each do |key, value|
545
+ symbol_key = key.to_sym
546
+ @memory_selections[project_path][root_command][symbol_key] = symbolize_keys(value)
547
+ end
548
+ # 标记缓存已确认,避免嵌套调用时重复询问
549
+ @cache_confirmed = true
550
+ return true
551
+ else
552
+ puts "清除缓存,重新选择\n"
553
+ # 清除当前上下文的文件缓存(三级结构)
554
+ file_path = cache_file_path
555
+ if @loaded_file_cache[project_path] && @loaded_file_cache[project_path][root_command]
556
+ @loaded_file_cache[project_path].delete(root_command)
557
+ # 如果项目路径下没有任何命令缓存了,删除项目路径键
558
+ @loaded_file_cache.delete(project_path) if @loaded_file_cache[project_path].empty?
559
+ # 保存清理后的缓存到文件
560
+ save_file_cache
561
+ end
562
+ # 标记缓存已确认(用户选择不使用)
563
+ @cache_confirmed = true
564
+ return false
565
+ end
566
+ end
567
+
488
568
  # 调试信息
489
569
  def debug_info
490
570
  puts "\n=== PindoContext Debug Info ==="
@@ -66,6 +66,13 @@ module Pindo
66
66
 
67
67
  def run
68
68
  pindo_project_dir = Dir.pwd
69
+
70
+ # 加载 JPS 配置(如果存在)
71
+ context = Pindo::PindoContext.instance
72
+ context.load_and_apply_jps_config(pindo_project_dir)
73
+
74
+ # 确认并应用缓存(如果有)
75
+ context.confirm_and_apply_cache
69
76
  build_helper = Pindo::BuildHelper.share_instance
70
77
  project_type = build_helper.project_type(pindo_project_dir)
71
78
 
@@ -93,10 +100,8 @@ module Pindo
93
100
  pindo_project_dir = Dir.pwd
94
101
 
95
102
  app_info_obj = nil
96
- if @args_upload_flag
97
- proj_name = @args_proj_name
98
- app_info_obj = PgyerHelper.share_instace.prepare_upload(working_directory:Dir.pwd, proj_name:proj_name)
99
- end
103
+ proj_name = @args_proj_name
104
+ app_info_obj = PgyerHelper.share_instace.prepare_upload(working_directory:Dir.pwd, proj_name:proj_name)
100
105
 
101
106
  build_helper = Pindo::BuildHelper.share_instance
102
107
  if @args_upload_flag
@@ -107,8 +112,8 @@ module Pindo
107
112
  end
108
113
 
109
114
  scheme_name = @args_proj_name if @args_proj_name
110
- if !app_info_obj.nil? && !app_info_obj["projectName"].nil? && !app_info_obj["projectName"].empty?
111
- scheme_name = app_info_obj["projectName"]
115
+ if !app_info_obj.nil? && !app_info_obj["scheme"].nil? && !app_info_obj["scheme"].empty?
116
+ scheme_name = app_info_obj["scheme"]
112
117
  end
113
118
  if scheme_name.nil? || scheme_name.empty? && is_git_directory?(local_repo_dir:pindo_project_dir)
114
119
  current_git_root_path = git_root_directory(local_repo_dir: pindo_project_dir)
@@ -153,7 +158,7 @@ module Pindo
153
158
  apk_path = android_build_helper.auto_build_apk(pindo_project_dir, !@args_release_flag)
154
159
  ipa_file_upload = Dir.glob(apk_path).max_by {|f| File.mtime(f)}
155
160
 
156
- if !ipa_file_upload.nil? && !app_info_obj.nil?
161
+ if !ipa_file_upload.nil? && !app_info_obj.nil? && @args_upload_flag
157
162
  description = nil
158
163
  result_data = PgyerHelper.share_instace.start_upload(app_info_obj:app_info_obj, ipa_file_upload:ipa_file_upload, description:description)
159
164
  if !result_data.nil? && !result_data["data"].nil? && !result_data["data"]["id"].nil?
@@ -88,6 +88,13 @@ module Pindo
88
88
  def run
89
89
  pindo_project_dir = Dir.pwd
90
90
 
91
+ # 加载 JPS 配置(如果存在)
92
+ context = Pindo::PindoContext.instance
93
+ context.load_and_apply_jps_config(pindo_project_dir)
94
+
95
+ # 确认并应用缓存(如果有)
96
+ context.confirm_and_apply_cache
97
+
91
98
  build_helper = Pindo::BuildHelper.share_instance
92
99
  project_type = build_helper.project_type(pindo_project_dir)
93
100
 
@@ -139,10 +146,8 @@ module Pindo
139
146
  end
140
147
 
141
148
  app_info_obj = nil
142
- if @args_upload_flag
143
- proj_name = @args_proj_name
144
- app_info_obj = PgyerHelper.share_instace.prepare_upload(working_directory:Dir.pwd, proj_name:proj_name)
145
- end
149
+ proj_name = @args_proj_name
150
+ app_info_obj = PgyerHelper.share_instace.prepare_upload(working_directory:Dir.pwd, proj_name:proj_name)
146
151
 
147
152
 
148
153
  args_temp = []
@@ -153,8 +158,8 @@ module Pindo
153
158
  config_json_file = File.join(pindo_project_dir,"config.json")
154
159
 
155
160
  scheme_name = @args_proj_name if @args_proj_name
156
- if !app_info_obj.nil? && !app_info_obj["projectName"].nil? && !app_info_obj["projectName"].empty?
157
- scheme_name = app_info_obj["projectName"]
161
+ if !app_info_obj.nil? && !app_info_obj["scheme"].nil? && !app_info_obj["scheme"].empty?
162
+ scheme_name = app_info_obj["scheme"]
158
163
  end
159
164
  if scheme_name.nil? || scheme_name.empty? && is_git_directory?(local_repo_dir:pindo_project_dir)
160
165
  current_git_root_path = git_root_directory(local_repo_dir: pindo_project_dir)
@@ -246,7 +251,7 @@ module Pindo
246
251
  build_path = File.join(pindo_project_dir, "build", "*.{ipa,app}")
247
252
  ipa_file_upload = Dir.glob(build_path).max_by {|f| File.mtime(f)}
248
253
 
249
- if !ipa_file_upload.nil? && !app_info_obj.nil?
254
+ if !ipa_file_upload.nil? && !app_info_obj.nil? && @args_upload_flag
250
255
  description = nil
251
256
  result_data = PgyerHelper.share_instace.start_upload(app_info_obj:app_info_obj, ipa_file_upload:ipa_file_upload, description:description)
252
257
  if !result_data.nil? && !result_data["data"].nil? && !result_data["data"]["id"].nil?
@@ -73,6 +73,13 @@ DESC
73
73
  def run
74
74
  pindo_project_dir = Dir.pwd
75
75
 
76
+ # 加载 JPS 配置(如果存在)
77
+ context = Pindo::PindoContext.instance
78
+ context.load_and_apply_jps_config(pindo_project_dir)
79
+
80
+ # 确认并应用缓存(如果有)
81
+ context.confirm_and_apply_cache
82
+
76
83
  # 检查是否是Unity工程
77
84
  unity_helper = Pindo::Client::UnityHelper.share_instance
78
85
  unless unity_helper.unity_project?(pindo_project_dir)
@@ -94,10 +101,8 @@ DESC
94
101
  puts
95
102
 
96
103
  app_info_obj = nil
97
- if @args_upload_flag
98
- proj_name = @args_proj_name
99
- app_info_obj = PgyerHelper.share_instace.prepare_upload(working_directory:Dir.pwd, proj_name:proj_name)
100
- end
104
+ proj_name = @args_proj_name
105
+ app_info_obj = PgyerHelper.share_instace.prepare_upload(working_directory:Dir.pwd, proj_name:proj_name)
101
106
 
102
107
  isLibrary = @args_base_flag
103
108
 
@@ -110,14 +115,18 @@ DESC
110
115
  if isLibrary
111
116
  pindo_android_project_dir = android_export_lib_dir
112
117
  end
113
-
118
+
119
+ # 获取 apkCount 用于传递给 Unity 构建
120
+ apk_count = app_info_obj&.dig("apkCount") || -1
121
+
114
122
  puts "开始构建Unity项目..."
115
123
 
116
124
  unity_helper.build_project(
117
125
  unity_exe_full_path: unity_exe_path,
118
126
  project_path: pindo_project_dir,
119
127
  platform: 'Android',
120
- isLibrary: isLibrary
128
+ isLibrary: isLibrary,
129
+ indexNo: apk_count
121
130
  )
122
131
 
123
132
  puts "Unity项目构建完成,准备处理Android项目..."
@@ -91,13 +91,8 @@ DESC
91
91
  puts "选择的Unity路径: #{unity_exe_path}"
92
92
  puts
93
93
 
94
-
95
- app_info_obj = nil
96
- if @args_upload_flag
97
- proj_name = @args_proj_name
98
- app_info_obj = PgyerHelper.share_instace.prepare_upload(working_directory:Dir.pwd, proj_name:proj_name)
99
- end
100
-
94
+ proj_name = @args_proj_name
95
+ app_info_obj = PgyerHelper.share_instace.prepare_upload(working_directory:Dir.pwd, proj_name:proj_name)
101
96
  pindo_project_dir = Dir.pwd
102
97
 
103
98
  ios_autobuild(unity_helper:unity_helper, unity_exe_path:unity_exe_path)
@@ -115,8 +110,12 @@ DESC
115
110
  pindo_project_dir = Dir.pwd
116
111
 
117
112
  web_export_dir = File.join(pindo_project_dir, "GoodPlatform/WebGL")
118
- unity_helper.build_project(unity_exe_full_path:unity_exe_path, project_path:pindo_project_dir, platform:'WebGL')
119
-
113
+
114
+ # 获取 zipCount 用于传递给 Unity 构建
115
+ zip_count = app_info_obj&.dig("zipCount") || -1
116
+
117
+ unity_helper.build_project(unity_exe_full_path:unity_exe_path, project_path:pindo_project_dir, platform:'WebGL', indexNo:zip_count)
118
+
120
119
  system "open #{pindo_project_dir}"
121
120
 
122
121
 
@@ -144,7 +143,11 @@ DESC
144
143
  if isLibrary
145
144
  pindo_ios_project_dir = ios_export_lib_dir
146
145
  end
147
- unity_helper.build_project(unity_exe_full_path:unity_exe_path, project_path:pindo_project_dir, platform:'iOS', isLibrary:isLibrary)
146
+
147
+ # 获取 ipaCount 用于传递给 Unity 构建
148
+ ipa_count = app_info_obj&.dig("ipaCount") || -1
149
+
150
+ unity_helper.build_project(unity_exe_full_path:unity_exe_path, project_path:pindo_project_dir, platform:'iOS', isLibrary:isLibrary, indexNo:ipa_count)
148
151
 
149
152
 
150
153
  args_temp = []
@@ -175,14 +178,13 @@ DESC
175
178
  if isLibrary
176
179
  pindo_android_project_dir = android_export_lib_dir
177
180
  end
181
+
182
+ # 获取 apkCount 用于传递给 Unity 构建
183
+ apk_count = app_info_obj&.dig("apkCount") || -1
184
+
178
185
  puts "开始构建Unity项目..."
179
186
 
180
- unity_helper.build_project(
181
- unity_exe_full_path: unity_exe_path,
182
- project_path: pindo_project_dir,
183
- platform: 'Android',
184
- isLibrary: isLibrary
185
- )
187
+ unity_helper.build_project(unity_exe_full_path: unity_exe_path, project_path: pindo_project_dir, platform: 'Android', isLibrary: isLibrary, indexNo: apk_count)
186
188
 
187
189
  puts "Unity项目构建完成,准备处理Android项目..."
188
190
  args_temp = []
@@ -90,9 +90,15 @@ DESC
90
90
 
91
91
 
92
92
  def run
93
-
94
93
  pindo_project_dir = Dir.pwd
95
94
 
95
+ # 加载 JPS 配置(如果存在)
96
+ context = Pindo::PindoContext.instance
97
+ context.load_and_apply_jps_config(pindo_project_dir)
98
+
99
+ # 确认并应用缓存(如果有)
100
+ context.confirm_and_apply_cache
101
+
96
102
  # 检查是否是Unity工程
97
103
  unity_helper = Pindo::Client::UnityHelper.share_instance
98
104
  unless unity_helper.unity_project?(pindo_project_dir)
@@ -115,10 +121,8 @@ DESC
115
121
  puts
116
122
 
117
123
  app_info_obj = nil
118
- if @args_upload_flag
119
- proj_name = @args_proj_name
120
- app_info_obj = PgyerHelper.share_instace.prepare_upload(working_directory:Dir.pwd, proj_name:proj_name)
121
- end
124
+ proj_name = @args_proj_name
125
+ app_info_obj = PgyerHelper.share_instace.prepare_upload(working_directory:Dir.pwd, proj_name:proj_name)
122
126
 
123
127
  mainapp_bundleid= nil
124
128
  if @args_bundle_id
@@ -142,8 +146,11 @@ DESC
142
146
  if isLibrary
143
147
  pindo_ios_project_dir = ios_export_lib_dir
144
148
  end
145
-
146
- unity_helper.build_project(unity_exe_full_path:unity_exe_path, project_path:pindo_project_dir, platform:'iOS', isLibrary:isLibrary)
149
+
150
+ # 获取 ipaCount 用于传递给 Unity 构建
151
+ ipa_count = app_info_obj&.dig("ipaCount") || -1
152
+
153
+ unity_helper.build_project(unity_exe_full_path:unity_exe_path, project_path:pindo_project_dir, platform:'iOS', isLibrary:isLibrary, indexNo:ipa_count)
147
154
 
148
155
 
149
156
  args_temp = []
@@ -81,9 +81,15 @@ DESC
81
81
 
82
82
 
83
83
  def run
84
-
85
84
  pindo_project_dir = Dir.pwd
86
85
 
86
+ # 加载 JPS 配置(如果存在)
87
+ context = Pindo::PindoContext.instance
88
+ context.load_and_apply_jps_config(pindo_project_dir)
89
+
90
+ # 确认并应用缓存(如果有)
91
+ context.confirm_and_apply_cache
92
+
87
93
  # 检查是否是Unity工程
88
94
  unity_helper = Pindo::Client::UnityHelper.share_instance
89
95
  unless unity_helper.unity_project?(pindo_project_dir)
@@ -106,10 +112,8 @@ DESC
106
112
  puts
107
113
 
108
114
  app_info_obj = nil
109
- if @args_upload_flag
110
- proj_name = @args_proj_name
111
- app_info_obj = PgyerHelper.share_instace.prepare_upload(working_directory:Dir.pwd, proj_name:proj_name)
112
- end
115
+ proj_name = @args_proj_name
116
+ app_info_obj = PgyerHelper.share_instace.prepare_upload(working_directory:Dir.pwd, proj_name:proj_name)
113
117
 
114
118
  mainapp_bundleid= nil
115
119
  if @args_deploy_flag
@@ -129,7 +133,11 @@ DESC
129
133
  if isLibrary
130
134
  pindo_ios_project_dir = ios_export_lib_dir
131
135
  end
132
- unity_helper.build_project(unity_exe_full_path:unity_exe_path, project_path:pindo_project_dir, platform:'iOS', isLibrary:isLibrary)
136
+
137
+ # 获取 ipaCount 用于传递给 Unity 构建
138
+ ipa_count = app_info_obj&.dig("ipaCount") || -1
139
+
140
+ unity_helper.build_project(unity_exe_full_path:unity_exe_path, project_path:pindo_project_dir, platform:'iOS', isLibrary:isLibrary, indexNo:ipa_count)
133
141
 
134
142
 
135
143
  args_temp = []
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'pindo/command/unity/ipa'
4
4
  require 'pindo/command/unity/apk'
5
+ require 'pindo/command/unity/web'
5
6
  require 'pindo/command/unity/autobuild'
6
7
  require 'pindo/command/unity/initpack'
7
8
  require 'pindo/command/unity/pack'
@@ -90,6 +90,13 @@ module Pindo
90
90
  def run
91
91
  pindo_project_dir = Dir.pwd
92
92
 
93
+ # 加载 JPS 配置(如果存在)
94
+ context = Pindo::PindoContext.instance
95
+ context.load_and_apply_jps_config(pindo_project_dir)
96
+
97
+ # 确认并应用缓存(如果有)
98
+ context.confirm_and_apply_cache
99
+
93
100
  build_helper = Pindo::BuildHelper.share_instance
94
101
  project_type = build_helper.project_type(pindo_project_dir)
95
102
 
@@ -130,13 +137,15 @@ module Pindo
130
137
  puts
131
138
 
132
139
  app_info_obj = nil
133
- if @args_upload_flag
134
- proj_name = @args_proj_name
135
- app_info_obj = PgyerHelper.share_instace.prepare_upload(working_directory:Dir.pwd, proj_name:proj_name)
136
- end
140
+ proj_name = @args_proj_name
141
+ app_info_obj = PgyerHelper.share_instace.prepare_upload(working_directory:Dir.pwd, proj_name:proj_name)
137
142
 
138
143
  web_export_dir = File.join(pindo_project_dir, "GoodPlatform/WebGL")
139
- unity_helper.build_project(unity_exe_full_path:unity_exe_path, project_path:pindo_project_dir, platform:'WebGL')
144
+
145
+ # 获取 zipCount 用于传递给 Unity 构建
146
+ zip_count = app_info_obj&.dig("zipCount") || -1
147
+
148
+ unity_helper.build_project(unity_exe_full_path:unity_exe_path, project_path:pindo_project_dir, platform:'WebGL', indexNo:zip_count)
140
149
 
141
150
  build_path = File.join(web_export_dir, "build", "index.{html}")
142
151
  html_file_upload = Dir.glob(build_path).max_by {|f| File.mtime(f)}
@@ -144,7 +153,7 @@ module Pindo
144
153
  # puts "html_file_upload: #{html_file_upload}"
145
154
  # puts "app_info_obj: #{app_info_obj}"
146
155
 
147
- if !html_file_upload.nil? && !app_info_obj.nil?
156
+ if !html_file_upload.nil? && !app_info_obj.nil? && @args_upload_flag
148
157
  description = nil
149
158
  result_data = PgyerHelper.share_instace.start_upload(app_info_obj:app_info_obj, ipa_file_upload:html_file_upload, description:description)
150
159
  if !result_data.nil? && !result_data["data"].nil? && !result_data["data"]["id"].nil?
@@ -458,7 +458,7 @@ module Pindo
458
458
  nil
459
459
  end
460
460
 
461
- def build_project(unity_exe_full_path:nil, project_path:nil, platform: nil, isLibrary: false)
461
+ def build_project(unity_exe_full_path:nil, project_path:nil, platform: nil, isLibrary: false, indexNo: nil)
462
462
 
463
463
  # 检查是否有Unity进程在运行,传入Unity路径和项目路径以精确匹配
464
464
  check_unity_processes(unity_exe_full_path: unity_exe_full_path, project_path: project_path)
@@ -469,6 +469,7 @@ module Pindo
469
469
  additional_args = {}
470
470
  additional_args[:platform] = platform if platform
471
471
  additional_args[:buildtype] = 'library' if isLibrary
472
+ additional_args[:indexno] = indexNo if indexNo
472
473
 
473
474
  # 使用GoodUnityBuild.BuildManager.BatchBuild进行构建
474
475
  result = execute_unity_command(unity_exe_full_path, project_path, additional_args)
@@ -136,6 +136,8 @@ module Pindo
136
136
  upload_proj_name = cached_app_key
137
137
  # 直接使用缓存的选择,跳过后续选择逻辑
138
138
  end
139
+
140
+
139
141
  end
140
142
 
141
143
  # 只有在没有缓存或缓存无效,且没有环境变量时才显示选择菜单
@@ -175,6 +177,9 @@ module Pindo
175
177
  else
176
178
  # 记录上次上传的项目
177
179
  PindoUserLocalConfig.instance.write_last_work_project(proj_name:app_info_obj["projectName"])
180
+
181
+ # 保存项目信息到 JPSBuildConfig.json
182
+ save_jps_build_config(working_directory: working_directory, app_info_obj: app_info_obj)
178
183
  end
179
184
 
180
185
 
@@ -861,6 +866,80 @@ module Pindo
861
866
  end
862
867
 
863
868
  end
869
+
870
+ private
871
+
872
+ # 保存项目信息到 JPSBuildConfig.json
873
+ # Unity 工程:保存到仓库根目录的 ProjectSettings/JPSBuildConfig.json
874
+ # 其他工程:保存到仓库根目录的 JPSBuildConfig.json
875
+ def save_jps_build_config(working_directory: nil, app_info_obj: nil)
876
+ return if working_directory.nil? || app_info_obj.nil?
877
+
878
+ # 获取 Git 仓库根目录
879
+ repo_root_dir = nil
880
+ if is_git_directory?(local_repo_dir: working_directory)
881
+ repo_root_dir = git_root_directory(local_repo_dir: working_directory)
882
+ end
883
+
884
+ # 如果不是 Git 仓库,使用 working_directory
885
+ repo_root_dir ||= working_directory
886
+
887
+ # 判断工程类型并确定配置文件路径
888
+ # Unity 工程:仓库根目录/ProjectSettings/JPSBuildConfig.json
889
+ # iOS/Android 工程:仓库根目录/JPSBuildConfig.json
890
+ config_file = nil
891
+ project_type = nil
892
+
893
+ # 检查是否是 Unity 工程(仓库根目录存在 ProjectSettings 目录)
894
+ if File.directory?(File.join(repo_root_dir, 'ProjectSettings'))
895
+ config_file = File.join(repo_root_dir, 'ProjectSettings', 'JPSBuildConfig.json')
896
+ project_type = 'Unity'
897
+ else
898
+ # iOS/Android 工程,保存到仓库根目录
899
+ config_file = File.join(repo_root_dir, 'JPSBuildConfig.json')
900
+ project_type = 'iOS/Android'
901
+ end
902
+
903
+ # 准备要保存的数据
904
+ new_config = {
905
+ "project_name" => app_info_obj["projectName"],
906
+ "project_scheme" => app_info_obj["scheme"] || app_info_obj["projectName"].to_s.downcase.strip.gsub(/[\s\-_]/, ''),
907
+ "project_id" => app_info_obj["id"]
908
+ }
909
+
910
+ # 检查文件是否已存在
911
+ if File.exist?(config_file)
912
+ begin
913
+ # 读取现有配置
914
+ existing_content = File.read(config_file)
915
+ existing_config = JSON.parse(existing_content)
916
+
917
+ # 如果 project_name 一样,则不需要重新保存
918
+ if existing_config['project_name'] == new_config['project_name']
919
+ puts "[PgyerHelper] JPSBuildConfig.json 项目名称未变化,跳过保存 (#{project_type})" if ENV['DEBUG']
920
+ return
921
+ end
922
+ rescue => e
923
+ puts "[PgyerHelper] 读取现有 JPSBuildConfig.json 失败: #{e.message}" if ENV['DEBUG']
924
+ # 继续保存新配置
925
+ end
926
+ else
927
+ # 文件不存在,需要创建目录(如果是 Unity 工程)
928
+ if project_type == 'Unity'
929
+ project_settings_dir = File.join(working_directory, 'ProjectSettings')
930
+ FileUtils.mkdir_p(project_settings_dir) unless File.directory?(project_settings_dir)
931
+ end
932
+ end
933
+
934
+ # 保存配置到文件
935
+ begin
936
+ File.write(config_file, JSON.pretty_generate(new_config))
937
+ puts "[PgyerHelper] 已保存项目信息到 JPSBuildConfig.json (#{project_type})" if ENV['DEBUG']
938
+ puts "项目信息已保存: #{new_config['project_name']}"
939
+ rescue => e
940
+ puts "[PgyerHelper] 保存 JPSBuildConfig.json 失败: #{e.message}"
941
+ end
942
+ end
864
943
  end
865
944
 
866
945
  end
@@ -599,7 +599,8 @@ module Pindo
599
599
  metadata.add_child(new_node)
600
600
  end
601
601
 
602
- File.write(nuspec_file, doc.to_xml)
602
+ # 使用 save_with 选项来保持 UTF-8 编码,不转义非 ASCII 字符
603
+ File.write(nuspec_file, doc.to_xml(encoding: 'UTF-8', save_with: Nokogiri::XML::Node::SaveOptions::NO_DECLARATION | Nokogiri::XML::Node::SaveOptions::AS_XML))
603
604
  end
604
605
 
605
606
  end
data/lib/pindo/version.rb CHANGED
@@ -6,7 +6,7 @@ require 'time'
6
6
 
7
7
  module Pindo
8
8
 
9
- VERSION = "5.6.3"
9
+ VERSION = "5.6.5"
10
10
 
11
11
  class VersionCheck
12
12
  RUBYGEMS_API = 'https://rubygems.org/api/v1/gems/pindo.json'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pindo
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.6.3
4
+ version: 5.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - wade
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-10-10 00:00:00.000000000 Z
10
+ date: 2025-10-11 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: claide