pindo 5.10.6 → 5.10.9

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 (79) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pindo/base/funlog.rb +12 -1
  3. data/lib/pindo/base/pindocontext.rb +3 -0
  4. data/lib/pindo/command/android/autobuild.rb +62 -9
  5. data/lib/pindo/command/android/build.rb +6 -6
  6. data/lib/pindo/command/android/debug.rb +9 -9
  7. data/lib/pindo/command/android.rb +1 -1
  8. data/lib/pindo/command/appstore.rb +1 -1
  9. data/lib/pindo/command/deploy/build.rb +2 -4
  10. data/lib/pindo/command/deploy/cert.rb +4 -5
  11. data/lib/pindo/command/deploy/configproj.rb +3 -3
  12. data/lib/pindo/command/deploy/confusecode.rb +1 -1
  13. data/lib/pindo/command/deploy/confuseproj.rb +1 -1
  14. data/lib/pindo/command/deploy/pem.rb +3 -4
  15. data/lib/pindo/command/dev/autobuild.rb +1 -1
  16. data/lib/pindo/command/dev/build.rb +1 -1
  17. data/lib/pindo/command/dev/feishu.rb +1 -1
  18. data/lib/pindo/command/gplay/pullconfig.rb +48 -0
  19. data/lib/pindo/command/gplay.rb +7 -6
  20. data/lib/pindo/command/ios/adhoc.rb +6 -5
  21. data/lib/pindo/command/ios/autobuild.rb +24 -24
  22. data/lib/pindo/command/ios/build.rb +7 -6
  23. data/lib/pindo/command/ios/debug.rb +1 -0
  24. data/lib/pindo/command/ios.rb +1 -1
  25. data/lib/pindo/command/ipa/import.rb +2 -3
  26. data/lib/pindo/command/ipa/output.rb +2 -3
  27. data/lib/pindo/command/jps/upload.rb +6 -5
  28. data/lib/pindo/command/unity/apk.rb +19 -2
  29. data/lib/pindo/command/unity/autobuild.rb +58 -63
  30. data/lib/pindo/command/unity/initpack.rb +1 -1
  31. data/lib/pindo/command/unity/ipa.rb +17 -14
  32. data/lib/pindo/command/unity/pack.rb +1 -1
  33. data/lib/pindo/command/unity/upload.rb +1 -1
  34. data/lib/pindo/command/unity/web.rb +2 -2
  35. data/lib/pindo/command/utils/icon.rb +1 -1
  36. data/lib/pindo/command/utils/renewcert.rb +1 -2
  37. data/lib/pindo/command/utils/renewproj.rb +9 -10
  38. data/lib/pindo/command/web/autobuild.rb +2 -2
  39. data/lib/pindo/command/web/run.rb +1 -1
  40. data/lib/pindo/command.rb +2 -1
  41. data/lib/pindo/module/android/android_build_config_helper.rb +267 -35
  42. data/lib/pindo/module/android/android_build_helper.rb +300 -0
  43. data/lib/pindo/module/android/android_project_helper.rb +279 -0
  44. data/lib/pindo/module/android/gp_compliance_helper.rb +33 -87
  45. data/lib/pindo/module/android/gradle_helper.rb +524 -255
  46. data/lib/pindo/module/android/java_env_helper.rb +633 -0
  47. data/lib/pindo/module/android/keystore_helper.rb +1118 -0
  48. data/lib/pindo/module/appselect.rb +109 -0
  49. data/lib/pindo/module/appstore/appstore_in_app_purchase.rb +1 -1
  50. data/lib/pindo/module/build/{buildhelper.rb → build_helper.rb} +1 -2
  51. data/lib/pindo/module/build/{commonconfuseproj.rb → confuse_xcodeproj.rb} +2 -2
  52. data/lib/pindo/module/cert/cert_helper.rb +245 -0
  53. data/lib/pindo/module/cert/keychain_helper.rb +152 -0
  54. data/lib/pindo/module/cert/pem_helper.rb +67 -0
  55. data/lib/pindo/module/cert/xcodecerthelper.rb +2 -2
  56. data/lib/pindo/module/pgyer/pgyerhelper.rb +21 -1
  57. data/lib/pindo/module/{build/unityhelper.rb → unity/unity_helper.rb} +0 -17
  58. data/lib/pindo/module/xcode/{xcodereshandler.rb → res/xcode_res_handler.rb} +1 -1
  59. data/lib/pindo/module/xcode/{xcodebuildconfig.rb → xcode_build_config.rb} +7 -6
  60. data/lib/pindo/module/xcode/{xcodebuildhelper.rb → xcode_build_helper.rb} +4 -3
  61. data/lib/pindo/module/xcode/{xcodehelper.rb → xcode_project_helper.rb} +4 -2
  62. data/lib/pindo/module/xcode/{xcodereshelper.rb → xcode_res_helper.rb} +12 -9
  63. data/lib/pindo/version.rb +185 -7
  64. data/lib/pindo.rb +14 -9
  65. metadata +24 -23
  66. data/lib/pindo/module/android/apk_helper.rb +0 -138
  67. data/lib/pindo/module/android/base_helper.rb +0 -964
  68. data/lib/pindo/module/android/build_helper.rb +0 -128
  69. data/lib/pindo/module/android/so_helper.rb +0 -18
  70. data/lib/pindo/module/cert/certhelper.rb +0 -246
  71. data/lib/pindo/module/cert/keychainhelper.rb +0 -150
  72. data/lib/pindo/module/cert/pemhelper.rb +0 -65
  73. /data/lib/pindo/module/android/{androidreshelper.rb → android_res_helper.rb} +0 -0
  74. /data/lib/pindo/module/appstore/{iap_tier.json → appstore_iap_tier.json} +0 -0
  75. /data/lib/pindo/module/build/{swarkhelper.rb → swark_helper.rb} +0 -0
  76. /data/lib/pindo/module/build/{versionhelper.rb → version_helper.rb} +0 -0
  77. /data/lib/pindo/module/cert/{provisioninghelper.rb → provisioning_helper.rb} +0 -0
  78. /data/lib/pindo/module/unity/{nugethelper.rb → nuget_helper.rb} +0 -0
  79. /data/lib/pindo/module/xcode/{xcoderesconstant.rb → res/xcode_res_constant.rb} +0 -0
@@ -1,41 +1,40 @@
1
1
  require 'fileutils'
2
2
  require 'open-uri'
3
3
  require_relative '../../base/funlog'
4
- require_relative 'base_helper'
4
+ require_relative 'android_project_helper'
5
5
  require_relative '../../base/executable'
6
- require_relative 'androidreshelper'
6
+ require_relative 'android_res_helper'
7
7
 
8
8
  module Pindo
9
9
 
10
10
  class AndroidBuildConfigHelper
11
- include BaseAndroidHelper
12
11
 
13
- # 使用package_name一次性更新App Name、Application ID和URL Schemes
12
+ # 使用工作流配置一次性更新App Name、Application ID和URL Schemes
14
13
  # 优化版本:提高性能,减少代码重复
15
14
  # @param project_dir [String] Android项目目录路径
16
- # @param package_name [String] 工作流的package_name(如:"Test Demo")
15
+ # @param workflow_packname [String] 工作流的名称(如:"Test Demo")
17
16
  # @return [Boolean] 是否成功更新
18
- def self.update_project_with_packagename(project_dir: nil, package_name: nil)
17
+ def self.update_project_with_workflow(project_dir: nil, workflow_packname: nil)
19
18
  raise ArgumentError, "项目目录不能为空" if project_dir.nil?
20
- raise ArgumentError, "Package Name不能为空" if package_name.nil?
19
+ raise ArgumentError, "Workflow Package Name不能为空" if workflow_packname.nil?
21
20
 
22
21
  # 生成各种值
23
- app_name = package_name.gsub(/[^a-zA-Z0-9\s]/, '').gsub(/\s+/, '')
24
- app_id_suffix = package_name.gsub(/[^a-zA-Z0-9]/, '').downcase
22
+ app_name = workflow_packname.gsub(/[^a-zA-Z0-9\s]/, '').gsub(/\s+/, '')
23
+ app_id_suffix = workflow_packname.gsub(/[^a-zA-Z0-9]/, '').downcase
25
24
  application_id = "com.heroneverdie101.#{app_id_suffix}"
26
- package_scheme = package_name.gsub(/[^a-zA-Z0-9]/, '').downcase
25
+ package_scheme = workflow_packname.gsub(/[^a-zA-Z0-9]/, '').downcase
27
26
  bundle_scheme = application_id.gsub(/[^a-zA-Z0-9]/, '').downcase
28
27
 
29
28
  # 1. 更新 App Name
30
29
  success_app_name = update_app_name_with_packagename(
31
30
  project_dir: project_dir,
32
- package_name: package_name
31
+ package_name: workflow_packname
33
32
  )
34
33
 
35
34
  # 2. 更新 Application ID
36
- success_app_id = update_applicationid_with_packagename(
35
+ success_app_id = update_applicationid_with_workflowname(
37
36
  project_dir: project_dir,
38
- package_name: package_name
37
+ package_name: workflow_packname
39
38
  )
40
39
 
41
40
  # 3. 添加基于 package_name 的 Scheme
@@ -78,11 +77,8 @@ module Pindo
78
77
  Funlog.instance.fancyinfo_start("正在更新Android工程版本信息...")
79
78
 
80
79
  begin
81
- # 创建helper实例以使用基类方法
82
- helper = self.new
83
-
84
80
  # 获取主模块路径
85
- main_module = helper.get_main_module(project_dir)
81
+ main_module = Pindo::AndroidProjectHelper.get_main_module(project_dir)
86
82
 
87
83
  if main_module.nil?
88
84
  # 如果无法获取主模块,尝试常见的模块名(优先 launcher,支持 Unity 项目)
@@ -118,11 +114,23 @@ module Pindo
118
114
  content = File.read(gradle_file)
119
115
 
120
116
  # 第一步:清理所有现有的版本信息(无论在什么位置)
117
+ # 直接赋值格式
121
118
  content.gsub!(/^\s*versionCode\s+\d+\s*$/, '')
122
119
  content.gsub!(/^\s*versionCode\s*=\s*\d+\s*$/, '')
123
120
  content.gsub!(/^\s*versionName\s+["'][^"']*["']\s*$/, '')
124
121
  content.gsub!(/^\s*versionName\s*=\s*["'][^"']*["']\s*$/, '')
125
122
 
123
+ # 外部变量引用格式
124
+ content.gsub!(/^\s*versionCode\s+rootProject\.ext\.\w+\s*$/, '')
125
+ content.gsub!(/^\s*versionCode\s+project\.ext\.\w+\s*$/, '')
126
+ content.gsub!(/^\s*versionCode\s+ext\.\w+\s*$/, '')
127
+ content.gsub!(/^\s*versionName\s+["']?\$\{rootProject\.ext\.\w+\}["']?\s*$/, '')
128
+ content.gsub!(/^\s*versionName\s+["']?\$\{project\.ext\.\w+\}["']?\s*$/, '')
129
+ content.gsub!(/^\s*versionName\s+["']?\$\{ext\.\w+\}["']?\s*$/, '')
130
+ content.gsub!(/^\s*versionName\s+rootProject\.ext\.\w+\s*$/, '')
131
+ content.gsub!(/^\s*versionName\s+project\.ext\.\w+\s*$/, '')
132
+ content.gsub!(/^\s*versionName\s+ext\.\w+\s*$/, '')
133
+
126
134
  # 清理多余的空行
127
135
  content.gsub!(/\n\n+/, "\n\n")
128
136
 
@@ -195,9 +203,7 @@ module Pindo
195
203
  app_name = package_name.gsub(/[^a-zA-Z0-9\s]/, '').gsub(/\s+/, '')
196
204
 
197
205
  begin
198
- # 创建helper实例以使用基类方法
199
- helper = self.new
200
- main_module = helper.get_main_module(project_dir)
206
+ main_module = Pindo::AndroidProjectHelper.get_main_module(project_dir)
201
207
 
202
208
  if main_module.nil?
203
209
  # 尝试常见的模块名(优先 launcher,支持 Unity 项目)
@@ -212,6 +218,35 @@ module Pindo
212
218
 
213
219
  return false if main_module.nil?
214
220
 
221
+ # 1. 先删除 build.gradle 中的 resValue("string", "app_name", ...)
222
+ build_gradle_path = File.join(main_module, "build.gradle")
223
+ build_gradle_kts_path = File.join(main_module, "build.gradle.kts")
224
+
225
+ gradle_file = nil
226
+ if File.exist?(build_gradle_kts_path)
227
+ gradle_file = build_gradle_kts_path
228
+ elsif File.exist?(build_gradle_path)
229
+ gradle_file = build_gradle_path
230
+ end
231
+
232
+ if gradle_file
233
+ gradle_content = File.read(gradle_file)
234
+ original_content = gradle_content.dup
235
+
236
+ # 删除 resValue("string", "app_name", ...) 这一行
237
+ # 支持多种格式:
238
+ # resValue("string", "app_name", "xxx")
239
+ # resValue("string", "app_name", "${rootProject.ext.app_name}")
240
+ # resValue "string", "app_name", "xxx"
241
+ gradle_content.gsub!(/^\s*resValue\s*\(?\s*["']string["']\s*,\s*["']app_name["'].*?\)?\s*$\n?/, '')
242
+
243
+ if gradle_content != original_content
244
+ File.write(gradle_file, gradle_content)
245
+ puts " ✓ 已删除 build.gradle 中的 resValue(\"string\", \"app_name\", ...)"
246
+ end
247
+ end
248
+
249
+ # 2. 更新 strings.xml
215
250
  # 查找strings.xml文件
216
251
  strings_xml_path = File.join(main_module, "src", "main", "res", "values", "strings.xml")
217
252
 
@@ -223,15 +258,26 @@ module Pindo
223
258
  # 读取并更新strings.xml
224
259
  content = File.read(strings_xml_path)
225
260
 
226
- # 更新app_name
261
+ # 检查是否存在 app_name
227
262
  if content =~ /<string\s+name="app_name">.*?<\/string>/
263
+ # 存在,直接更新
228
264
  content.gsub!(/<string\s+name="app_name">.*?<\/string>/, "<string name=\"app_name\">#{app_name}</string>")
229
265
  File.write(strings_xml_path, content)
230
266
  puts " ✓ App Name 已更新为: #{app_name} (来自: #{package_name})"
231
267
  return true
232
268
  else
233
- Funlog.instance.fancyinfo_error("strings.xml中未找到app_name字段")
234
- return false
269
+ # 不存在,自动添加
270
+ if content =~ /<resources>(.*?)<\/resources>/m
271
+ # 在 <resources> 标签内添加 app_name
272
+ new_string_entry = "\n <string name=\"app_name\">#{app_name}</string>"
273
+ content.sub!(/<resources>/, "<resources>#{new_string_entry}")
274
+ File.write(strings_xml_path, content)
275
+ puts " ✓ App Name 已添加: #{app_name} (来自: #{package_name})"
276
+ return true
277
+ else
278
+ Funlog.instance.fancyinfo_error("strings.xml格式异常,无法添加app_name")
279
+ return false
280
+ end
235
281
  end
236
282
 
237
283
  rescue StandardError => e
@@ -240,11 +286,11 @@ module Pindo
240
286
  end
241
287
  end
242
288
 
243
- # 使用package_name更新Android Application ID(build.gradle中的applicationId)
289
+ # 使用工作流名称生成并更新Android Application ID(build.gradle中的applicationId)
244
290
  # @param project_dir [String] Android项目目录路径
245
- # @param package_name [String] 工作流的package_name(如:"Test Demo"
291
+ # @param package_name [String] 工作流的名称(如:"Test Demo"),将被转换为application ID格式
246
292
  # @return [Boolean] 是否成功更新
247
- def self.update_applicationid_with_packagename(project_dir: nil, package_name: nil)
293
+ def self.update_applicationid_with_workflowname(project_dir: nil, package_name: nil)
248
294
  raise ArgumentError, "项目目录不能为空" if project_dir.nil?
249
295
  raise ArgumentError, "Package Name不能为空" if package_name.nil?
250
296
 
@@ -253,9 +299,7 @@ module Pindo
253
299
  application_id = "com.heroneverdie101.#{app_id_suffix}"
254
300
 
255
301
  begin
256
- # 创建helper实例以使用基类方法
257
- helper = self.new
258
- main_module = helper.get_main_module(project_dir)
302
+ main_module = Pindo::AndroidProjectHelper.get_main_module(project_dir)
259
303
 
260
304
  if main_module.nil?
261
305
  # 尝试常见的模块名(优先 launcher,支持 Unity 项目)
@@ -284,12 +328,32 @@ module Pindo
284
328
  # 读取并更新gradle文件
285
329
  content = File.read(gradle_file)
286
330
 
287
- # 更新applicationId
331
+ # 更新applicationId(支持多种格式)
332
+ updated = false
333
+
334
+ # 格式1: applicationId "com.example.app"
288
335
  if content =~ /applicationId\s+["'][^"']*["']/
289
336
  content.gsub!(/applicationId\s+["'][^"']*["']/, "applicationId \"#{application_id}\"")
337
+ updated = true
338
+ # 格式2: applicationId = "com.example.app"
290
339
  elsif content =~ /applicationId\s*=\s*["'][^"']*["']/
291
340
  content.gsub!(/applicationId\s*=\s*["'][^"']*["']/, "applicationId = \"#{application_id}\"")
292
- else
341
+ updated = true
342
+ # 格式3: applicationId rootProject.ext.application_id (外部变量引用)
343
+ elsif content =~ /applicationId\s+rootProject\.ext\.\w+/
344
+ content.gsub!(/applicationId\s+rootProject\.ext\.\w+/, "applicationId \"#{application_id}\"")
345
+ updated = true
346
+ # 格式4: applicationId project.ext.application_id
347
+ elsif content =~ /applicationId\s+project\.ext\.\w+/
348
+ content.gsub!(/applicationId\s+project\.ext\.\w+/, "applicationId \"#{application_id}\"")
349
+ updated = true
350
+ # 格式5: applicationId ext.application_id
351
+ elsif content =~ /applicationId\s+ext\.\w+/
352
+ content.gsub!(/applicationId\s+ext\.\w+/, "applicationId \"#{application_id}\"")
353
+ updated = true
354
+ end
355
+
356
+ unless updated
293
357
  Funlog.instance.fancyinfo_error("gradle文件中未找到applicationId字段")
294
358
  return false
295
359
  end
@@ -304,6 +368,177 @@ module Pindo
304
368
  end
305
369
  end
306
370
 
371
+ # 直接更新Application ID(不依赖package_name生成)
372
+ # @param project_dir [String] Android项目目录路径
373
+ # @param application_id [String] 要设置的Application ID(如 com.example.app)
374
+ # @return [Boolean] 是否成功更新
375
+ def self.update_application_id(project_dir: nil, application_id: nil)
376
+ # 参数验证
377
+ if application_id.nil? || application_id.empty?
378
+ Funlog.instance.fancyinfo_error("Application ID不能为空")
379
+ return false
380
+ end
381
+
382
+ if project_dir.nil? || !File.directory?(project_dir)
383
+ Funlog.instance.fancyinfo_error("项目路径无效: #{project_dir}")
384
+ return false
385
+ end
386
+
387
+ begin
388
+ puts "正在设置 Application ID: #{application_id}"
389
+
390
+ # 获取主模块
391
+ main_module = Pindo::AndroidProjectHelper.get_main_module(project_dir)
392
+
393
+ # 支持多种项目结构
394
+ module_paths = []
395
+ module_paths << File.join(project_dir, main_module) if main_module
396
+ module_paths << File.join(project_dir, "app")
397
+ module_paths << File.join(project_dir, "unityLibrary/launcher")
398
+ module_paths << File.join(project_dir, "launcher")
399
+
400
+ gradle_file = nil
401
+ module_paths.each do |module_path|
402
+ next unless File.exist?(module_path)
403
+
404
+ if File.exist?(File.join(module_path, "build.gradle"))
405
+ gradle_file = File.join(module_path, "build.gradle")
406
+ break
407
+ elsif File.exist?(File.join(module_path, "build.gradle.kts"))
408
+ gradle_file = File.join(module_path, "build.gradle.kts")
409
+ break
410
+ end
411
+ end
412
+
413
+ if gradle_file.nil?
414
+ Funlog.instance.fancyinfo_error("未找到build.gradle文件")
415
+ return false
416
+ end
417
+
418
+ # 读取并更新gradle文件
419
+ content = File.read(gradle_file)
420
+ updated = false
421
+
422
+ # 更新applicationId(支持多种格式)
423
+ # 格式1: applicationId "com.example.app"
424
+ if content =~ /applicationId\s+["'][^"']*["']/
425
+ content.gsub!(/applicationId\s+["'][^"']*["']/, "applicationId \"#{application_id}\"")
426
+ updated = true
427
+ # 格式2: applicationId = "com.example.app"
428
+ elsif content =~ /applicationId\s*=\s*["'][^"']*["']/
429
+ content.gsub!(/applicationId\s*=\s*["'][^"']*["']/, "applicationId = \"#{application_id}\"")
430
+ updated = true
431
+ end
432
+
433
+ unless updated
434
+ Funlog.instance.fancyinfo_error("gradle文件中未找到applicationId配置")
435
+ return false
436
+ end
437
+
438
+ File.write(gradle_file, content)
439
+ puts " ✓ 更新 #{File.basename(gradle_file)} 中的 applicationId"
440
+ return true
441
+
442
+ rescue StandardError => e
443
+ Funlog.instance.fancyinfo_error("更新Application ID失败: #{e.message}")
444
+ return false
445
+ end
446
+ end
447
+
448
+ # 从配置仓库拷贝 google-services.json 到项目的 launcher 目录
449
+ # @param config_repo_dir [String] 配置仓库的路径
450
+ # @param project_dir [String] Android项目目录路径
451
+ # @return [Boolean] 是否成功拷贝
452
+ def self.copy_google_services_from_config_repo(config_repo_dir: nil, project_dir: nil)
453
+ # 参数验证
454
+ if config_repo_dir.nil? || !File.directory?(config_repo_dir)
455
+ Funlog.instance.fancyinfo_error("配置仓库路径无效: #{config_repo_dir}")
456
+ return false
457
+ end
458
+
459
+ if project_dir.nil? || !File.directory?(project_dir)
460
+ Funlog.instance.fancyinfo_error("项目路径无效: #{project_dir}")
461
+ return false
462
+ end
463
+
464
+ # 查找配置仓库中的 google-services.json
465
+ source_file = File.join(config_repo_dir, 'google-services.json')
466
+ unless File.exist?(source_file)
467
+ Funlog.instance.fancyinfo_warning("配置仓库中未找到 google-services.json")
468
+ return false
469
+ end
470
+
471
+ puts "正在拷贝 google-services.json..."
472
+
473
+ # 优先拷贝到 launcher 目录
474
+ launcher_dirs = [
475
+ File.join(project_dir, 'unityLibrary', 'launcher'), # Unity 项目的 launcher
476
+ File.join(project_dir, 'launcher'), # 独立的 launcher
477
+ File.join(project_dir, 'app') # 原生 Android 项目
478
+ ]
479
+
480
+ copied = false
481
+ launcher_dirs.each do |launcher_dir|
482
+ if File.exist?(launcher_dir) && File.directory?(launcher_dir)
483
+ target_file = File.join(launcher_dir, 'google-services.json')
484
+ FileUtils.cp(source_file, target_file)
485
+ puts " ✓ google-services.json 已拷贝到: #{launcher_dir}"
486
+ copied = true
487
+
488
+ # Unity 项目也拷贝到 unityLibrary 根目录
489
+ if launcher_dir.include?('unityLibrary/launcher')
490
+ unity_root = File.join(project_dir, 'unityLibrary')
491
+ if File.exist?(unity_root) && File.directory?(unity_root)
492
+ unity_target = File.join(unity_root, 'google-services.json')
493
+ FileUtils.cp(source_file, unity_target)
494
+ puts " ✓ google-services.json 也已拷贝到: unityLibrary/"
495
+ end
496
+ end
497
+
498
+ break # 找到第一个有效目录后停止
499
+ end
500
+ end
501
+
502
+ unless copied
503
+ # 如果没找到合适的目录,至少拷贝到项目根目录
504
+ target_file = File.join(project_dir, 'google-services.json')
505
+ FileUtils.cp(source_file, target_file)
506
+ puts " ✓ google-services.json 已拷贝到项目根目录"
507
+ puts " ⚠ 请确认文件位置是否正确"
508
+ end
509
+
510
+ return true
511
+ end
512
+
513
+ # 从配置仓库应用配置(拷贝 config.json)
514
+ # @param config_repo_dir [String] 配置仓库的路径
515
+ # @param project_dir [String] Android项目目录路径
516
+ # @return [Boolean] 是否成功应用
517
+ def self.apply_config_from_repo(config_repo_dir: nil, project_dir: nil)
518
+ # 参数验证
519
+ if config_repo_dir.nil? || !File.directory?(config_repo_dir)
520
+ Funlog.instance.fancyinfo_error("配置仓库路径无效: #{config_repo_dir}")
521
+ return false
522
+ end
523
+
524
+ if project_dir.nil? || !File.directory?(project_dir)
525
+ Funlog.instance.fancyinfo_error("项目路径无效: #{project_dir}")
526
+ return false
527
+ end
528
+
529
+ # 拷贝 config.json 到项目目录
530
+ config_source = File.join(config_repo_dir, 'config.json')
531
+ if File.exist?(config_source)
532
+ config_target = File.join(project_dir, 'config.json')
533
+ FileUtils.cp(config_source, config_target)
534
+ puts " ✓ config.json 已拷贝到项目目录"
535
+ return true
536
+ else
537
+ puts " ⚠ 配置仓库中未找到 config.json"
538
+ return false
539
+ end
540
+ end
541
+
307
542
  # 添加测试scheme到Android工程
308
543
  # @param project_dir [String] Android项目目录路径
309
544
  # @param scheme_name [String] 要添加的scheme名称
@@ -322,11 +557,8 @@ module Pindo
322
557
 
323
558
  scheme_name = scheme_name.to_s.gsub(/[^a-zA-Z0-9]/, '').downcase
324
559
 
325
- # 创建helper实例以使用基类方法
326
- helper = self.new
327
-
328
560
  # 查找所有可能的模块(添加 launcher 支持 Unity 项目)
329
- main_module = helper.get_main_module(project_dir)
561
+ main_module = Pindo::AndroidProjectHelper.get_main_module(project_dir)
330
562
  search_modules = ["launcher", "app", "unityLibrary"]
331
563
  search_modules << main_module if main_module
332
564
  search_modules = search_modules.compact.uniq