pindo 5.6.3 → 5.6.4

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: 70e757176e983eadd0e4d4009502520c6e8b414be34b00ce0ed38a676af91612
4
+ data.tar.gz: 6a22e1362c5911ad1de3e48ae13d2d98bf9f839e61eb1dc844b1a8487cfd3f45
5
5
  SHA512:
6
- metadata.gz: 667ea2d4a16d1b8d5581bf69b920158c1e34711fa29fe8f532074d0e85b34629668b641fa4df7436e830466a100e78506b83107f744980520f1439cb2b6fcff5
7
- data.tar.gz: 073d4acec0c92f7592b1ce7a64a1eb0fc2db7858b89a82fd543f9e95da250da5c8eb100b8218b201547a39ab8863d1ece4d57c8ecddbb914bcfae5808464eadd
6
+ metadata.gz: d08b59f594d1940371367f0fcafed27a9521738fe24ebb3319615f058f17482525344e7a516da6ddce45d635ad3631e58a237a6fa87263c311ecdaadf4988842
7
+ data.tar.gz: 14e49d65c3c4977101f8be8c253ba912aceb9a15822d30532c48d8090dce700dedce03bd60e9e85dbdc07f57065ec1a144d09ec811d6e5a6e659e9ea46e34eac
@@ -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,7 @@ module Pindo
17
25
  @cache_enabled = false # 默认禁用缓存
18
26
  @command_group = nil # 命令组名称
19
27
  @verbose = false # 是否输出详细日志
28
+ @loaded_file_cache = nil # 已加载但未应用的文件缓存数据
20
29
  ensure_cache_dir
21
30
  end
22
31
 
@@ -52,10 +61,10 @@ module Pindo
52
61
  puts "[PindoContext] options: #{options.inspect}"
53
62
  end
54
63
 
55
- # 仅在启用缓存时加载文件缓存
64
+ # 仅在启用缓存时加载文件缓存(不确认,只加载到临时变量)
56
65
  if @cache_enabled && !@file_cache_loaded
57
66
  puts "[PindoContext] 准备加载文件缓存..." if verbose?
58
- load_file_cache_with_confirmation
67
+ load_file_cache
59
68
  @file_cache_loaded = true
60
69
  else
61
70
  if verbose?
@@ -143,7 +152,7 @@ module Pindo
143
152
  def enable_cache(enabled = true)
144
153
  @cache_enabled = enabled
145
154
  if enabled && !@file_cache_loaded && @current_command
146
- load_file_cache_with_confirmation
155
+ load_file_cache
147
156
  @file_cache_loaded = true
148
157
  end
149
158
  end
@@ -207,14 +216,6 @@ module Pindo
207
216
  end
208
217
  end
209
218
 
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
219
  private
219
220
 
220
221
  # 递归将Hash的键从字符串转换为符号
@@ -243,14 +244,15 @@ module Pindo
243
244
  File.join(cache_dir, 'context_selections.json')
244
245
  end
245
246
 
246
- # 加载文件缓存并确认(三级结构)
247
- def load_file_cache_with_confirmation
247
+ # 加载文件缓存(仅加载,不确认)
248
+ def load_file_cache
248
249
  file_path = cache_file_path
249
250
 
250
251
  puts "[PindoContext] 检查文件缓存: #{file_path}" if verbose?
251
252
 
252
253
  unless File.exist?(file_path)
253
254
  puts "[PindoContext] 文件缓存不存在,跳过加载" if verbose?
255
+ @loaded_file_cache = nil
254
256
  return
255
257
  end
256
258
 
@@ -261,109 +263,31 @@ module Pindo
261
263
  # 清理过期缓存(超过7天)
262
264
  file_cache = clean_expired_cache(file_cache)
263
265
 
264
- # 获取当前项目和命令的缓存
266
+ # 保存加载的缓存数据,但不应用到内存
267
+ @loaded_file_cache = file_cache
268
+
269
+ # 加载其他项目/命令的缓存到内存(不需要确认的部分)
265
270
  project_path = get_project_path
266
271
  root_command = @command_group || @current_command
267
272
 
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
273
+ file_cache.each do |proj_path, commands|
274
+ @memory_selections[proj_path] ||= {}
275
+ commands.each do |cmd, selections|
276
+ # 跳过当前上下文(需要确认)
277
+ next if proj_path == project_path && cmd == root_command
322
278
 
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
279
+ @memory_selections[proj_path][cmd] ||= {}
280
+ selections.each do |key, value|
281
+ symbol_key = key.to_sym
282
+ @memory_selections[proj_path][cmd][symbol_key] = symbolize_keys(value)
360
283
  end
361
284
  end
362
285
  end
363
286
 
364
- puts "[PindoContext] 处理文件缓存: #{file_path}" if verbose?
287
+ puts "[PindoContext] 已加载文件缓存到临时存储" if verbose?
365
288
  rescue => e
366
289
  puts "[PindoContext] 加载缓存失败: #{e.message}" if verbose?
290
+ @loaded_file_cache = nil
367
291
  end
368
292
  end
369
293
 
@@ -485,6 +409,147 @@ module Pindo
485
409
 
486
410
  public
487
411
 
412
+ # 加载 JPSBuildConfig.json 并覆盖项目名称(如果存在)
413
+ # 应在 confirm_and_apply_cache 之前调用
414
+ def load_and_apply_jps_config(project_dir = nil)
415
+ project_dir ||= get_project_path
416
+
417
+ # 判断工程类型并确定配置文件路径
418
+ # Unity 工程:ProjectSettings/JPSBuildConfig.json
419
+ # iOS/Android 工程:JPSBuildConfig.json
420
+ config_file = nil
421
+ project_type = nil
422
+
423
+ # 检查是否是 Unity 工程(存在 ProjectSettings 目录)
424
+ if File.directory?(File.join(project_dir, 'ProjectSettings'))
425
+ config_file = File.join(project_dir, 'ProjectSettings', 'JPSBuildConfig.json')
426
+ project_type = 'Unity'
427
+ else
428
+ # iOS/Android 工程,直接在根目录
429
+ config_file = File.join(project_dir, 'JPSBuildConfig.json')
430
+ project_type = 'iOS/Android'
431
+ end
432
+
433
+ unless File.exist?(config_file)
434
+ puts "[PindoContext] JPSBuildConfig.json 不存在 (#{project_type} 工程),跳过" if verbose?
435
+ return nil
436
+ end
437
+
438
+ begin
439
+ config_content = File.read(config_file)
440
+ jps_config = JSON.parse(config_content)
441
+
442
+ if jps_config['project_name'] && !jps_config['project_name'].empty?
443
+ project_name = jps_config['project_name']
444
+ puts "[PindoContext] 从 JPSBuildConfig.json 加载项目名称 (#{project_type}): #{project_name}" if verbose?
445
+
446
+ # 设置到当前上下文的缓存中
447
+ set_selection(SelectionKey::PROJECT_NAME, project_name)
448
+
449
+ puts "使用 JPS 配置的项目名称: #{project_name}"
450
+ return project_name
451
+ end
452
+ rescue => e
453
+ puts "[PindoContext] 加载 JPSBuildConfig.json 失败: #{e.message}" if verbose?
454
+ end
455
+
456
+ nil
457
+ end
458
+
459
+ # 确认并应用缓存(供命令在 run 函数中调用)
460
+ # 返回值:true 表示使用缓存,false 表示不使用缓存
461
+ def confirm_and_apply_cache
462
+ return false unless @cache_enabled
463
+ return false unless @loaded_file_cache
464
+
465
+ project_path = get_project_path
466
+ root_command = @command_group || @current_command
467
+
468
+ return false unless project_path && root_command
469
+
470
+ # 检查三级结构中是否有当前上下文的缓存
471
+ cached_selections = @loaded_file_cache.dig(project_path, root_command)
472
+
473
+ unless cached_selections && !cached_selections.empty?
474
+ puts "[PindoContext] 当前上下文没有缓存数据" if verbose?
475
+ return false
476
+ end
477
+
478
+ # 根据命令组显示更友好的描述
479
+ group_desc = case root_command
480
+ when 'ios:autobuild'
481
+ 'iOS 构建'
482
+ when 'and:autobuild', 'android:autobuild'
483
+ 'Android 构建'
484
+ when 'web:autobuild'
485
+ 'Web 构建'
486
+ else
487
+ @current_command # 其他命令显示原始命令名
488
+ end
489
+
490
+ puts "\n检测到之前的选择 (#{group_desc}):"
491
+ puts "────────────────────────────────────────"
492
+
493
+ cached_selections.each do |key, value|
494
+ # 跳过内部字段
495
+ next if key.to_s.start_with?('__')
496
+
497
+ case key.to_s
498
+ when 'bundle_id'
499
+ puts " Bundle ID: #{value}"
500
+ when 'project_name', 'app_key' # 兼容旧的 app_key
501
+ puts " 项目名称: #{value}"
502
+ when 'tag_decision'
503
+ if value.is_a?(Hash)
504
+ action_desc = value['description'] || value['action']
505
+ puts " Tag决定: #{action_desc}"
506
+ end
507
+ when 'cert_type'
508
+ puts " 证书类型: #{value}"
509
+ end
510
+ end
511
+ puts "────────────────────────────────────────"
512
+
513
+ # 检查是否设置了强制编译环境变量
514
+ force_build = ENV['PINDO_FORCE_BUILD']
515
+
516
+ confirm = false
517
+ if force_build && !force_build.empty?
518
+ # 环境变量存在,自动使用缓存
519
+ puts "\n检测到 PINDO_FORCE_BUILD 环境变量,自动使用缓存的选择"
520
+ confirm = true
521
+ else
522
+ # 询问用户是否使用缓存
523
+ require 'highline/import'
524
+ cli = HighLine.new
525
+ confirm = cli.agree("\n是否使用以上缓存的选择? (y/n) ")
526
+ end
527
+
528
+ if confirm
529
+ puts "使用缓存的选择\n" unless force_build
530
+ # 恢复当前上下文的文件缓存到内存缓存
531
+ @memory_selections[project_path] ||= {}
532
+ @memory_selections[project_path][root_command] ||= {}
533
+ cached_selections.each do |key, value|
534
+ symbol_key = key.to_sym
535
+ @memory_selections[project_path][root_command][symbol_key] = symbolize_keys(value)
536
+ end
537
+ return true
538
+ else
539
+ puts "清除缓存,重新选择\n"
540
+ # 清除当前上下文的文件缓存(三级结构)
541
+ file_path = cache_file_path
542
+ if @loaded_file_cache[project_path] && @loaded_file_cache[project_path][root_command]
543
+ @loaded_file_cache[project_path].delete(root_command)
544
+ # 如果项目路径下没有任何命令缓存了,删除项目路径键
545
+ @loaded_file_cache.delete(project_path) if @loaded_file_cache[project_path].empty?
546
+ # 保存清理后的缓存到文件
547
+ save_file_cache
548
+ end
549
+ return false
550
+ end
551
+ end
552
+
488
553
  # 调试信息
489
554
  def debug_info
490
555
  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.4"
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.4
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