pindo 5.13.7 → 5.13.10

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 (74) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pindo/base/git_handler.rb +247 -42
  3. data/lib/pindo/command/android/autobuild.rb +104 -31
  4. data/lib/pindo/command/android/autoresign.rb +23 -322
  5. data/lib/pindo/command/android/keystore.rb +7 -130
  6. data/lib/pindo/command/appstore/adhocbuild.rb +52 -15
  7. data/lib/pindo/command/appstore/autobuild.rb +104 -8
  8. data/lib/pindo/command/appstore/autoresign.rb +3 -5
  9. data/lib/pindo/command/ios/autobuild.rb +96 -32
  10. data/lib/pindo/command/ios/build.rb +8 -186
  11. data/lib/pindo/command/jps/media.rb +146 -0
  12. data/lib/pindo/command/jps/upload.rb +49 -21
  13. data/lib/pindo/command/jps.rb +1 -0
  14. data/lib/pindo/command/unity/autobuild.rb +141 -32
  15. data/lib/pindo/command/unity/packpush.rb +5 -8
  16. data/lib/pindo/command/utils/repoinit.rb +0 -2
  17. data/lib/pindo/command/utils/tag.rb +58 -26
  18. data/lib/pindo/command/utils.rb +0 -1
  19. data/lib/pindo/command/web/autobuild.rb +98 -34
  20. data/lib/pindo/command.rb +0 -56
  21. data/lib/pindo/config/build_info_manager.rb +7 -8
  22. data/lib/pindo/module/android/android_config_helper.rb +2 -11
  23. data/lib/pindo/module/appselect.rb +15 -41
  24. data/lib/pindo/module/appstore/itcapp_helper.rb +3 -6
  25. data/lib/pindo/module/build/build_helper.rb +28 -18
  26. data/lib/pindo/module/build/git_repo_helper.rb +284 -405
  27. data/lib/pindo/module/cert/pem_helper.rb +3 -6
  28. data/lib/pindo/module/pgyer/pgyerhelper.rb +193 -25
  29. data/lib/pindo/module/task/model/appstore/appstore_task.rb +5 -0
  30. data/lib/pindo/module/task/model/build/android_build_adhoc_task.rb +13 -187
  31. data/lib/pindo/module/task/model/build/android_build_dev_task.rb +36 -34
  32. data/lib/pindo/module/task/model/build/android_build_gplay_task.rb +13 -187
  33. data/lib/pindo/module/task/model/build/ios_build_adhoc_task.rb +9 -6
  34. data/lib/pindo/module/task/model/build/ios_build_appstore_task.rb +9 -6
  35. data/lib/pindo/module/task/model/build/ios_build_dev_task.rb +37 -32
  36. data/lib/pindo/module/task/model/build/web_build_dev_task.rb +7 -5
  37. data/lib/pindo/module/task/model/build_task.rb +8 -11
  38. data/lib/pindo/module/task/model/git/git_commit_task.rb +118 -0
  39. data/lib/pindo/module/task/model/git/git_tag_task.rb +125 -0
  40. data/lib/pindo/module/task/model/git_task.rb +75 -0
  41. data/lib/pindo/module/task/model/jps/jps_message_task.rb +178 -0
  42. data/lib/pindo/module/task/model/{jps_resign_task.rb → jps/jps_resign_task.rb} +14 -23
  43. data/lib/pindo/module/task/model/jps/jps_upload_media_task.rb +248 -0
  44. data/lib/pindo/module/task/model/{jps_upload_task.rb → jps/jps_upload_task.rb} +39 -94
  45. data/lib/pindo/module/task/model/jps_task.rb +43 -0
  46. data/lib/pindo/module/task/model/{ipa_local_resign_task.rb → resign/ipa_local_resign_task.rb} +7 -2
  47. data/lib/pindo/module/task/model/unity/unity_config_task.rb +103 -0
  48. data/lib/pindo/module/task/model/{unity_export_task.rb → unity/unity_export_task.rb} +76 -78
  49. data/lib/pindo/module/task/model/unity/unity_update_task.rb +95 -0
  50. data/lib/pindo/module/task/model/unity/unity_yoo_asset_task.rb +156 -0
  51. data/lib/pindo/module/task/model/unity_task.rb +118 -0
  52. data/lib/pindo/module/task/pindo_task.rb +101 -1
  53. data/lib/pindo/module/task/task_manager.rb +29 -24
  54. data/lib/pindo/module/unity/nuget_helper.rb +7 -7
  55. data/lib/pindo/module/unity/unity_command_helper.rb +188 -0
  56. data/lib/pindo/module/unity/unity_env_helper.rb +208 -0
  57. data/lib/pindo/module/unity/unity_helper.rb +189 -746
  58. data/lib/pindo/module/unity/unity_proc_helper.rb +390 -0
  59. data/lib/pindo/options/core/global_options_state.rb +96 -26
  60. data/lib/pindo/options/core/option_configuration.rb +3 -0
  61. data/lib/pindo/options/core/option_item.rb +36 -0
  62. data/lib/pindo/options/groups/build_options.rb +23 -6
  63. data/lib/pindo/options/groups/git_options.rb +115 -0
  64. data/lib/pindo/options/groups/jps_options.rb +7 -0
  65. data/lib/pindo/options/groups/option_group.rb +15 -0
  66. data/lib/pindo/options/groups/unity_options.rb +49 -0
  67. data/lib/pindo/options/options.rb +2 -0
  68. data/lib/pindo/version.rb +2 -2
  69. metadata +25 -14
  70. data/lib/pindo/base/githelper.rb +0 -686
  71. data/lib/pindo/base/pindocontext.rb +0 -602
  72. data/lib/pindo/command/utils/feishu.rb +0 -134
  73. data/lib/pindo/module/build/version_helper.rb +0 -146
  74. data/lib/pindo/module/task/model/git_tag_task.rb +0 -80
@@ -28,9 +28,6 @@ module Pindo
28
28
  # @param dev_flag [Boolean] 是否为开发证书
29
29
  # @param deploy_repo_name [String, nil] 部署仓库名称
30
30
  def execute_pem_creation(config_json:, dev_flag: false, deploy_repo_name: nil)
31
- require_relative '../../base/githelper'
32
- include Pindo::Githelper
33
-
34
31
  # 提取配置信息
35
32
  config_info = extract_config_info(config_json)
36
33
 
@@ -61,14 +58,14 @@ module Pindo
61
58
 
62
59
  # 如果提供了部署仓库名称,则上传到 Git 仓库
63
60
  if !deploy_repo_name.nil? && !deploy_repo_name.empty? && File.exist?(x509_cert_path) && File.exist?(push_path)
64
- app_config_dir = clong_buildconfig_repo(repo_name: deploy_repo_name)
61
+ app_config_dir = Pindo::GitHandler.clong_buildconfig_repo(repo_name: deploy_repo_name)
65
62
  push_repo_dir = File.join(app_config_dir, "push")
66
63
 
67
64
  FileUtils.mkdir_p(push_repo_dir) unless File.exist?(push_repo_dir)
68
65
  FileUtils.cp_r(File.join(push_path, "."), push_repo_dir)
69
66
 
70
- prepare_gitenv()
71
- git_addpush_repo(path: app_config_dir, message: "add push cert")
67
+ Pindo::GitHandler.prepare_gitenv()
68
+ Pindo::GitHandler.git_addpush_repo(path: app_config_dir, message: "add push cert")
72
69
 
73
70
  puts "✓ 证书已上传到配置仓库: #{push_repo_dir}"
74
71
  end
@@ -7,18 +7,14 @@ require "rqrcode"
7
7
  require 'jpsclient'
8
8
  require 'pindo/config/pindoconfig'
9
9
  require 'pindo/config/pindouserlocalconfig'
10
- require 'pindo/base/pindocontext'
11
10
  require 'pindo/base/funlog'
12
- require 'pindo/base/githelper'
11
+ require 'pindo/base/git_handler'
13
12
 
14
13
 
15
14
  module Pindo
16
15
 
17
16
  class PgyerHelper
18
17
 
19
-
20
- include Pindo::Githelper
21
-
22
18
  class << self
23
19
  attr_writer :instance
24
20
  end
@@ -438,11 +434,9 @@ module Pindo
438
434
  end
439
435
 
440
436
  if !app_info_obj.nil?
441
- # 如果使用环境变量找到了项目,保存到缓存
437
+ # 如果使用环境变量找到了项目,保存到 GlobalOptionsState
442
438
  if env_project_name && !env_project_name.empty?
443
- require_relative '../../base/pindocontext'
444
- context = Pindo::PindoContext.instance
445
- context.set_selection(Pindo::PindoContext::SelectionKey::PROJECT_NAME, upload_proj_name)
439
+ Pindo::Options::GlobalOptionsState.instance[:proj] = upload_proj_name
446
440
  end
447
441
 
448
442
  # 如果提供了 package_type,选择工作流并保存配置
@@ -521,18 +515,14 @@ module Pindo
521
515
 
522
516
  # 如果环境变量已经设置了项目名,跳过选择逻辑
523
517
  if !(env_project_name && !env_project_name.empty?)
524
- # 检查缓存的 App Key
525
- require_relative '../../base/pindocontext'
526
- context = Pindo::PindoContext.instance
527
- cached_app_key = context.get_selection(Pindo::PindoContext::SelectionKey::PROJECT_NAME)
518
+ # 检查 GlobalOptionsState 缓存
519
+ cached_app_key = Pindo::Options::GlobalOptionsState.instance[:proj]
528
520
 
529
521
  if cached_app_key && proj_name_array.include?(cached_app_key)
530
522
  puts "\n使用之前选择的JPS项目: #{cached_app_key}"
531
523
  upload_proj_name = cached_app_key
532
524
  # 直接使用缓存的选择,跳过后续选择逻辑
533
525
  end
534
-
535
-
536
526
  end
537
527
 
538
528
  # 只有在没有缓存或缓存无效,且没有环境变量时才显示选择菜单
@@ -552,9 +542,9 @@ module Pindo
552
542
  upload_proj_name = upload_proj_name.strip if upload_proj_name
553
543
  end
554
544
 
555
- # 保存选择到缓存(排除自定义输入选项)
545
+ # 保存选择到 GlobalOptionsState(排除自定义输入选项)
556
546
  if upload_proj_name && !upload_proj_name.include?("自定义输入")
557
- context.set_selection(Pindo::PindoContext::SelectionKey::PROJECT_NAME, upload_proj_name)
547
+ Pindo::Options::GlobalOptionsState.instance[:proj] = upload_proj_name
558
548
  end
559
549
  end
560
550
 
@@ -756,10 +746,33 @@ module Pindo
756
746
  workflowId: workflow_info[:workflow_id] # workflowId 必传
757
747
  }
758
748
 
759
- result_data = @pgyer_client.upload_project_package(
760
- projectId: app_info_obj["id"],
761
- params: upload_params
762
- )
749
+ # 提交包信息到服务器
750
+ Funlog.instance.fancyinfo_start("正在提交包信息到服务器...")
751
+ begin
752
+ result_data = @pgyer_client.upload_project_package(
753
+ projectId: app_info_obj["id"],
754
+ params: upload_params,
755
+ timeout: 300
756
+ )
757
+
758
+ # 验证上传结果
759
+ if ENV['JPS_CLIENT_DEBUG']
760
+ puts "[JPS_CLIENT_DEBUG] upload_project_package result_data: #{result_data.inspect}"
761
+ end
762
+
763
+ if result_data && result_data["data"] && result_data["data"]["id"]
764
+ Funlog.instance.fancyinfo_success("提交包信息完成!")
765
+ else
766
+ error_msg = result_data&.dig('msg') || '未知错误'
767
+ Funlog.instance.fancyinfo_error("提交包信息失败: #{error_msg}")
768
+ raise Informative, "上传失败:未获取到有效的返回数据"
769
+ end
770
+ rescue Informative
771
+ raise
772
+ rescue => e
773
+ Funlog.instance.fancyinfo_error("提交包信息失败: #{e.message}")
774
+ raise
775
+ end
763
776
 
764
777
  return result_data
765
778
  else
@@ -769,6 +782,161 @@ module Pindo
769
782
 
770
783
  end
771
784
 
785
+ # 上传 media 文件(图片、视频等)到 JPS
786
+ # 上传成功后自动更新 commit_log 记录
787
+ #
788
+ # @param file_paths [Array<String>] 要上传的文件路径列表
789
+ # @param git_commit_id [String] Git commit SHA(必需)
790
+ # @param workflow_id [Integer] 工作流ID(可选,用于筛选查询)
791
+ # @param git_commit_time [String] Git commit 时间(可选,用于显示)
792
+ # @param git_commit_desc [String] Git commit 描述(可选,用于显示)
793
+ # @return [Hash] 上传结果
794
+ # - success_urls: 本次上传成功的 URL 列表
795
+ # - failed_files: 本次上传失败的文件列表
796
+ # - existing_urls: 之前已存在的 URL 列表
797
+ # - all_urls: 全部 URL 列表(已有 + 新增)
798
+ # - commit_log_id: JPS 提交记录 ID
799
+ # - git_commit_id: Git commit SHA
800
+ # - update_success: update_commit_log 是否成功
801
+ def start_media_upload(file_paths:, git_commit_id:, workflow_id: nil)
802
+ result = {
803
+ success_urls: [],
804
+ failed_files: [],
805
+ existing_urls: [],
806
+ all_urls: [],
807
+ commit_log_id: nil,
808
+ git_commit_id: git_commit_id,
809
+ update_success: false
810
+ }
811
+
812
+ # 1. 验证参数
813
+ if file_paths.nil? || file_paths.empty?
814
+ Funlog.instance.fancyinfo_error("未提供要上传的文件")
815
+ return result
816
+ end
817
+
818
+ if git_commit_id.nil? || git_commit_id.empty?
819
+ Funlog.instance.fancyinfo_error("git_commit_id 不能为空")
820
+ return result
821
+ end
822
+
823
+ # 2. 根据 git_commit_id 查找对应的 commit_log 记录
824
+ Funlog.instance.fancyinfo_start("正在根据 git commit id 查找 JPS 提交记录...")
825
+ commit_log = find_commit_log_by_git_commit_id(git_commit_id, workflow_id)
826
+
827
+ if commit_log.nil?
828
+ Funlog.instance.fancyinfo_error("未找到 git commit id: #{git_commit_id} 对应的 JPS 提交记录")
829
+ Funlog.instance.warning("请确保该 commit 已经通过 JPS 发送过消息通知")
830
+ return result
831
+ end
832
+
833
+ commit_log_id = commit_log["id"]
834
+ result[:commit_log_id] = commit_log_id
835
+
836
+ Funlog.instance.fancyinfo_success("找到 JPS 提交记录 ##{commit_log_id}")
837
+ puts " 项目: #{commit_log["projectName"]}"
838
+ puts " 工作流: #{commit_log["tabName"]}"
839
+ puts " 分支: #{commit_log["branch"]}"
840
+ puts
841
+
842
+ # 3. 获取已存在的 fileUrls
843
+ if commit_log["fileUrls"] && commit_log["fileUrls"].any?
844
+ result[:existing_urls] = commit_log["fileUrls"]
845
+ puts "已有附件: #{result[:existing_urls].size} 个"
846
+ end
847
+
848
+ # 4. 使用 UploadMediaClient 并发上传文件
849
+ media_client = JPSClient::UploadMediaClient.new(@pgyer_client)
850
+ upload_result = media_client.upload_files(file_paths: file_paths)
851
+
852
+ # 5. 提取上传结果
853
+ result[:success_urls] = upload_result["success_urls"]
854
+ result[:failed_files] = upload_result["failed_files"]
855
+
856
+ # 6. 合并 URL 列表
857
+ result[:all_urls] = result[:existing_urls] + result[:success_urls]
858
+
859
+ # 7. 更新 commit_log
860
+ if result[:success_urls].any?
861
+ Funlog.instance.fancyinfo_start("正在更新提交记录附件...")
862
+ begin
863
+ update_result = @pgyer_client.update_commit_log(
864
+ id: commit_log_id,
865
+ params: { fileUrls: result[:all_urls] }
866
+ )
867
+
868
+ if update_result && (update_result.dig("meta", "code") == 0 || update_result.dig("meta", "code") == 200)
869
+ result[:update_success] = true
870
+ Funlog.instance.fancyinfo_success("提交记录附件更新成功!共 #{result[:all_urls].size} 个附件")
871
+ else
872
+ error_msg = update_result&.dig("meta", "message") || "未知错误"
873
+ Funlog.instance.fancyinfo_error("更新提交记录失败: #{error_msg}")
874
+ end
875
+ rescue => e
876
+ Funlog.instance.fancyinfo_error("更新提交记录失败: #{e.message}")
877
+ end
878
+ else
879
+ Funlog.instance.warning("没有成功上传的文件,跳过更新提交记录")
880
+ end
881
+
882
+ # 8. 输出统计
883
+ puts
884
+ puts "上传统计:"
885
+ puts " 成功: #{result[:success_urls].size} 个"
886
+ puts " 失败: #{result[:failed_files].size} 个"
887
+ puts " 总附件: #{result[:all_urls].size} 个"
888
+
889
+ return result
890
+ end
891
+
892
+ # 根据 git commit id 查找对应的 JPS commit_log 记录
893
+ #
894
+ # @param git_commit_id [String] Git commit SHA
895
+ # @param workflow_id [Integer] 工作流ID(可选)
896
+ # @return [Hash, nil] commit_log 记录或 nil
897
+ def find_commit_log_by_git_commit_id(git_commit_id, workflow_id = nil)
898
+ params = {
899
+ pageNo: 1,
900
+ pageSize: 50 # 查询最近的 50 条记录
901
+ }
902
+
903
+ # 如果指定了 workflow_id,添加到筛选条件
904
+ params[:workflowIds] = [workflow_id] if workflow_id
905
+
906
+ begin
907
+ list_result = @pgyer_client.get_commit_log_list(params: params)
908
+
909
+ if list_result && list_result["data"] && list_result["data"]["details"]
910
+ details = list_result["data"]["details"]
911
+
912
+ # 遍历查找匹配的 commitId
913
+ # 支持完整匹配或前缀匹配(git 短 SHA)
914
+ commit_log = details.find do |item|
915
+ item_commit_id = item["commitId"]
916
+ next false unless item_commit_id
917
+
918
+ # 完整匹配
919
+ if item_commit_id == git_commit_id
920
+ true
921
+ # 前缀匹配(支持 git 短 SHA,如 9e959ffd)
922
+ elsif git_commit_id.length >= 7 && item_commit_id.start_with?(git_commit_id)
923
+ true
924
+ elsif git_commit_id.length >= 7 && git_commit_id.start_with?(item_commit_id)
925
+ true
926
+ else
927
+ false
928
+ end
929
+ end
930
+
931
+ return commit_log
932
+ end
933
+ rescue => e
934
+ Funlog.instance.warning("查询 commit_log 列表失败: #{e.message}")
935
+ end
936
+
937
+ nil
938
+ end
939
+
772
940
  def get_user_local_wechat_url( )
773
941
 
774
942
  wechat_msg_url = nil
@@ -1151,8 +1319,8 @@ module Pindo
1151
1319
  description = nil
1152
1320
 
1153
1321
  # 检查是否是 git 仓库
1154
- if !current_project_dir.nil? && is_git_directory?(local_repo_dir: current_project_dir)
1155
- current_git_root_path = git_root_directory(local_repo_dir: current_project_dir)
1322
+ if !current_project_dir.nil? && Pindo::GitHandler.is_git_directory?(local_repo_dir: current_project_dir)
1323
+ current_git_root_path = Pindo::GitHandler.git_root_directory(local_repo_dir: current_project_dir)
1156
1324
 
1157
1325
  # 检查 git-cliff 是否已安装
1158
1326
  `git-cliff --version 2>&1`
@@ -1303,8 +1471,8 @@ module Pindo
1303
1471
  def determine_config_file_path(working_directory)
1304
1472
  # 获取 Git 仓库根目录
1305
1473
  repo_root_dir = nil
1306
- if is_git_directory?(local_repo_dir: working_directory)
1307
- repo_root_dir = git_root_directory(local_repo_dir: working_directory)
1474
+ if Pindo::GitHandler.is_git_directory?(local_repo_dir: working_directory)
1475
+ repo_root_dir = Pindo::GitHandler.git_root_directory(local_repo_dir: working_directory)
1308
1476
  end
1309
1477
  repo_root_dir ||= working_directory
1310
1478
 
@@ -13,6 +13,11 @@ module Pindo
13
13
  def self.task_type
14
14
  :appstore
15
15
  end
16
+
17
+ # 任务类型显示名称
18
+ def self.task_type_name
19
+ "App Store操作"
20
+ end
16
21
  end
17
22
  end
18
23
  end
@@ -1,209 +1,35 @@
1
1
  require_relative 'android_build_task'
2
- require 'pindo/module/build/build_helper'
3
- require 'pindo/module/build/version_helper'
4
- require 'pindo/module/build/git_repo_helper'
5
- require 'pindo/module/android/android_config_helper'
6
- require 'pindo/module/android/android_build_helper'
7
- require 'pindo/module/pgyer/pgyerhelper'
8
- require 'pindo/base/githelper'
9
2
 
10
3
  module Pindo
11
4
  module TaskSystem
12
5
  # Android AdHoc 模式构建任务
13
- # 使用 Release 模式编译 Android 工程(AdHoc 版本)
6
+ # TODO: 待实现
14
7
  class AndroidBuildAdhocTask < AndroidBuildTask
15
- include Pindo::Githelper
8
+ # 任务键
9
+ def self.task_key
10
+ :android_build_adhoc
11
+ end
16
12
 
17
13
  def initialize(options = {})
18
- @bundle_name = options[:bundle_name]
19
- @proj_name = options[:proj_name]
20
- @upload_flag = options[:upload] || false
21
- @send_flag = options[:send] || false
22
-
23
- # 接收外部传入的 JPS 配置
24
- @app_info_obj = options[:app_info_obj]
25
- @workflow_info = options[:workflow_info]
26
-
27
- super(:android, :adhoc, options)
14
+ options[:platform] = :android
15
+ options[:mode] = :adhoc
16
+ super("构建 APK (AdHoc)", options)
28
17
  end
29
18
 
30
19
  protected
31
20
 
32
- def build_task_name
33
- "构建 APK (AdHoc)"
34
- end
35
-
36
21
  def prepare_build
37
- # 校验必需的参数
38
- Dir.chdir(@project_path)
39
- validate_workflow_info
40
- check_git_tag if @upload_flag
41
- update_project_config
42
- update_version_info
43
- handle_bundle_name_config if @bundle_name
44
- add_application_id_scheme
22
+ # TODO: 待实现
23
+ raise Informative, "AndroidBuildAdhocTask 暂未实现"
45
24
  end
46
25
 
47
26
  def execute_build
48
- build_android_project
27
+ # TODO: 待实现
49
28
  end
50
29
 
51
30
  def find_output
52
- # 搜索 APK 和 AAB 文件
53
- search_paths = []
54
- search_paths.concat(TaskConfig::BUILD_OUTPUT_PATTERNS[:apk].map { |p| File.join(@project_path, p) })
55
- search_paths.concat(TaskConfig::BUILD_OUTPUT_PATTERNS[:aab].map { |p| File.join(@project_path, p) })
56
-
57
- package_files = []
58
- search_paths.each do |pattern|
59
- package_files.concat(Dir.glob(pattern))
60
- end
61
-
62
- # 过滤测试包和未签名包
63
- package_files.reject! do |f|
64
- basename = File.basename(f).downcase
65
- TaskConfig::EXCLUDED_PATTERNS.any? { |pattern| basename.include?(pattern) }
66
- end
67
-
68
- if package_files.any?
69
- # 优先返回 AAB,其次 APK
70
- aab_files = package_files.select { |f| f.end_with?(".aab") }
71
- apk_files = package_files.select { |f| f.end_with?(".apk") }
72
-
73
- latest_package = if aab_files.any?
74
- aab_files.max_by { |f| File.mtime(f) }
75
- elsif apk_files.any?
76
- apk_files.max_by { |f| File.mtime(f) }
77
- else
78
- package_files.max_by { |f| File.mtime(f) }
79
- end
80
-
81
- puts " 找到 Android 包文件: #{latest_package}"
82
- latest_package
83
- else
84
- puts " 警告: 未找到 APK/AAB 文件"
85
- nil
86
- end
87
- end
88
-
89
- private
90
-
91
- # 校验工作流信息
92
- def validate_workflow_info
93
- unless @workflow_info && @workflow_info[:package_name]
94
- raise Informative, "未提供工作流信息,请在创建任务时传入 workflow_info 参数"
95
- end
96
- end
97
-
98
- # Git 标签检查
99
- def check_git_tag
100
- git_repo_helper = Pindo::GitRepoHelper.share_instance
101
- is_need_add_tag, tag_action_params = git_repo_helper.check_is_need_add_tag?(@project_path)
102
- if is_need_add_tag
103
- git_repo_helper.create_and_push_tag(
104
- project_dir: @project_path,
105
- mode: 'minor',
106
- force_retag: tag_action_params&.include?('--retag') || false,
107
- custom_tag: nil,
108
- release_branch: 'master'
109
- )
110
- end
111
- end
112
-
113
- # 更新工程配置
114
- def update_project_config
115
- workflow_packname = @workflow_info[:package_name]
116
-
117
- puts "\n使用工作流配置更新 Android 项目:"
118
- puts " Workflow Package Name: #{workflow_packname}"
119
-
120
- # 更新 App Name、Application ID 和 URL Schemes
121
- Pindo::AndroidConfigHelper.update_project_with_workflow(
122
- project_dir: @project_path,
123
- workflow_packname: workflow_packname
124
- )
125
-
126
- # 下载并替换 Icon
127
- if @app_info_obj && @app_info_obj["projectIcon"] && !@app_info_obj["projectIcon"].empty?
128
- icon_replace_success = Pindo::AndroidConfigHelper.download_and_replace_icon_from_url(
129
- project_dir: @project_path,
130
- icon_url: @app_info_obj["projectIcon"]
131
- )
132
-
133
- unless icon_replace_success
134
- raise Informative, "Icon 下载或替换失败,请检查 Icon URL 是否有效: #{@app_info_obj["projectIcon"]}"
135
- end
136
- else
137
- Funlog.warning("未配置 Icon URL,跳过 Icon 替换")
138
- end
139
- end
140
-
141
- # 更新版本号
142
- def update_version_info
143
- version_helper = Pindo::VersionHelper.share_instance
144
- version_info = version_helper.get_version_info(project_dir: @project_path)
145
-
146
- if version_info[:is_git_repo]
147
- Pindo::AndroidConfigHelper.update_android_project_version(
148
- project_dir: @project_path,
149
- version_name: version_info[:version],
150
- version_code: version_info[:build_number]
151
- )
152
- else
153
- Funlog.warning("非Git仓库,保持工程原有版本号")
154
- end
155
- end
156
-
157
- # 处理 Bundle Name 特殊配置
158
- def handle_bundle_name_config
159
- return unless @bundle_name && !@bundle_name.empty?
160
-
161
- puts "\n正在处理指定的 Bundle Name: #{@bundle_name}..."
162
-
163
- # 检查是否为通配符
164
- is_wildcard = @bundle_name.include?('*') ||
165
- @bundle_name.end_with?('.') ||
166
- ['com.test', 'com.example', 'com.demo'].include?(@bundle_name)
167
-
168
- if is_wildcard
169
- puts " ⚠️ 检测到通配符或通用 Bundle Name: #{@bundle_name}"
170
- puts " ⚠️ 跳过 google-services.json 和 Application ID 更新"
171
- else
172
- # 拉取配置仓库
173
- config_repo_dir = clong_buildconfig_repo(repo_name: @bundle_name)
174
-
175
- if config_repo_dir && File.exist?(config_repo_dir)
176
- # 拷贝 google-services.json
177
- Pindo::AndroidConfigHelper.copy_google_services_from_config_repo(
178
- config_repo_dir: config_repo_dir,
179
- project_dir: @project_path
180
- )
181
-
182
- # 更新 Application ID
183
- Pindo::AndroidConfigHelper.update_application_id(
184
- project_dir: @project_path,
185
- application_id: @bundle_name
186
- )
187
-
188
- puts " ✓ Bundle Name 配置处理完成"
189
- else
190
- raise Informative, "无法获取配置仓库"
191
- end
192
- end
193
- end
194
-
195
- # 添加基于 Application ID 的 Scheme
196
- def add_application_id_scheme
197
- Pindo::AndroidConfigHelper.add_application_id_based_scheme(
198
- project_dir: @project_path
199
- )
200
- end
201
-
202
- # 构建 Android 工程
203
- def build_android_project
204
- android_build_helper = Pindo::AndroidBuildHelper.share_instance
205
- # 第二个参数 false 表示 release 模式
206
- android_build_helper.auto_build_apk(@project_path, false)
31
+ # TODO: 待实现
32
+ nil
207
33
  end
208
34
  end
209
35
  end
@@ -1,18 +1,20 @@
1
1
  require_relative 'android_build_task'
2
2
  require 'pindo/module/build/build_helper'
3
- require 'pindo/module/build/version_helper'
4
3
  require 'pindo/module/build/git_repo_helper'
4
+ require 'pindo/base/git_handler'
5
5
  require 'pindo/module/android/android_config_helper'
6
6
  require 'pindo/module/android/android_build_helper'
7
7
  require 'pindo/module/pgyer/pgyerhelper'
8
- require 'pindo/base/githelper'
9
8
 
10
9
  module Pindo
11
10
  module TaskSystem
12
11
  # Android Dev 模式构建任务
13
12
  # 使用 Debug 模式编译 Android 工程
14
13
  class AndroidBuildDevTask < AndroidBuildTask
15
- include Pindo::Githelper
14
+ def self.task_key
15
+ :android_build_dev
16
+ end
17
+
16
18
  def initialize(options = {})
17
19
  @bundle_name = options[:bundle_name]
18
20
  @proj_name = options[:proj_name]
@@ -23,20 +25,22 @@ module Pindo
23
25
  @app_info_obj = options[:app_info_obj]
24
26
  @workflow_info = options[:workflow_info]
25
27
 
26
- super(:android, :dev, options)
28
+ # Git 版本控制参数(与 GitOptions 一致)
29
+ @ver_inc = options[:ver_inc] || Pindo::VersionIncreaseType::MINI
30
+ @tag_type = options[:tag_type] || Pindo::CreateTagType::NEW
31
+ @tag_pre = options[:tag_pre] || 'v'
32
+
33
+ options[:platform] = :android
34
+ options[:mode] = :dev
35
+ super("构建 APK (Debug)", options)
27
36
  end
28
37
 
29
38
  protected
30
39
 
31
- def build_task_name
32
- "构建 APK (Debug)"
33
- end
34
-
35
40
  def prepare_build
36
41
  # 校验必需的参数
37
42
  Dir.chdir(@project_path)
38
43
  validate_workflow_info
39
- check_git_tag if @upload_flag
40
44
  update_project_config
41
45
  update_version_info
42
46
  handle_bundle_name_config if @bundle_name
@@ -94,21 +98,6 @@ module Pindo
94
98
  end
95
99
  end
96
100
 
97
- # Git 标签检查
98
- def check_git_tag
99
- git_repo_helper = Pindo::GitRepoHelper.share_instance
100
- is_need_add_tag, tag_action_params = git_repo_helper.check_is_need_add_tag?(@project_path)
101
- if is_need_add_tag
102
- git_repo_helper.create_and_push_tag(
103
- project_dir: @project_path,
104
- mode: 'minor',
105
- force_retag: tag_action_params&.include?('--retag') || false,
106
- custom_tag: nil,
107
- release_branch: 'master'
108
- )
109
- end
110
- end
111
-
112
101
  # 更新工程配置
113
102
  def update_project_config
114
103
  workflow_packname = @workflow_info[:package_name]
@@ -139,18 +128,31 @@ module Pindo
139
128
 
140
129
  # 更新版本号
141
130
  def update_version_info
142
- version_helper = Pindo::VersionHelper.share_instance
143
- version_info = version_helper.get_version_info(project_dir: @project_path)
131
+ git_repo_helper = Pindo::GitRepoHelper.share_instance
144
132
 
145
- if version_info[:is_git_repo]
146
- Pindo::AndroidConfigHelper.update_android_project_version(
147
- project_dir: @project_path,
148
- version_name: version_info[:version],
149
- version_code: version_info[:build_number]
150
- )
151
- else
133
+ # 检查是否是 Git 仓库
134
+ git_root = Pindo::GitHandler.git_root_directory(local_repo_dir: @project_path)
135
+ unless git_root
152
136
  Funlog.warning("非Git仓库,保持工程原有版本号")
137
+ return
153
138
  end
139
+
140
+ # 获取 build_number(从 commit hash 计算)
141
+ build_number = git_repo_helper.get_build_number_from_commit(project_dir: @project_path)
142
+
143
+ # 计算 build_version
144
+ build_version = git_repo_helper.calculate_build_version(
145
+ project_dir: @project_path,
146
+ tag_prefix: @tag_pre,
147
+ create_tag_type: @tag_type,
148
+ version_increase_type: @ver_inc
149
+ )
150
+
151
+ Pindo::AndroidConfigHelper.update_android_project_version(
152
+ project_dir: @project_path,
153
+ version_name: build_version,
154
+ version_code: build_number
155
+ )
154
156
  end
155
157
 
156
158
  # 处理 Bundle Name 特殊配置
@@ -169,7 +171,7 @@ module Pindo
169
171
  puts " ⚠️ 跳过 google-services.json 和 Application ID 更新"
170
172
  else
171
173
  # 拉取配置仓库
172
- config_repo_dir = clong_buildconfig_repo(repo_name: @bundle_name)
174
+ config_repo_dir = Pindo::GitHandler.clong_buildconfig_repo(repo_name: @bundle_name)
173
175
 
174
176
  if config_repo_dir && File.exist?(config_repo_dir)
175
177
  # 拷贝 google-services.json