pindo 5.14.5 → 5.14.7

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 (31) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pindo/base/git_handler.rb +140 -65
  3. data/lib/pindo/command/android/autobuild.rb +101 -33
  4. data/lib/pindo/command/appstore/bundleid.rb +1 -1
  5. data/lib/pindo/command/appstore/pem.rb +1 -1
  6. data/lib/pindo/command/ios/autobuild.rb +116 -56
  7. data/lib/pindo/command/jps/apptest.rb +129 -50
  8. data/lib/pindo/command/jps/resign.rb +109 -99
  9. data/lib/pindo/command/jps/upload.rb +31 -4
  10. data/lib/pindo/command/jps.rb +0 -1
  11. data/lib/pindo/command/unity/autobuild.rb +101 -40
  12. data/lib/pindo/command/web/autobuild.rb +96 -28
  13. data/lib/pindo/command.rb +23 -15
  14. data/lib/pindo/module/appselect.rb +14 -0
  15. data/lib/pindo/module/pgyer/pgyerhelper.rb +166 -0
  16. data/lib/pindo/module/task/model/git/git_commit_task.rb +36 -3
  17. data/lib/pindo/module/task/model/git/git_tag_task.rb +5 -4
  18. data/lib/pindo/module/task/model/jps/jps_bind_package_task.rb +38 -19
  19. data/lib/pindo/module/task/model/jps/jps_message_task.rb +9 -6
  20. data/lib/pindo/module/task/model/jps/jps_resign_task.rb +20 -21
  21. data/lib/pindo/module/task/model/jps/jps_upload_media_task.rb +37 -1
  22. data/lib/pindo/module/task/model/jps/jps_upload_task.rb +4 -4
  23. data/lib/pindo/module/task/model/jps/jps_workflow_message_task.rb +1 -1
  24. data/lib/pindo/options/core/option_configuration.rb +4 -36
  25. data/lib/pindo/options/core/option_initializer.rb +6 -3
  26. data/lib/pindo/options/core/option_item.rb +0 -3
  27. data/lib/pindo/options/groups/build_options.rb +3 -2
  28. data/lib/pindo/options/groups/jps_options.rb +30 -10
  29. data/lib/pindo/version.rb +1 -1
  30. metadata +25 -8
  31. data/lib/pindo/command/jps/comment.rb +0 -84
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60289998ea7be5f175400dbd6038a6aebe104095280ee7fe10aba1ea513d20f8
4
- data.tar.gz: 1a4fddd44fa17a17716a4e55a9c3ad7df41fed6357934e2b179801779dd7a139
3
+ metadata.gz: 0e61c4fa7bc1f944011a7d2da6ea5f88e6964cf4156fbfc820a82f87f8376b15
4
+ data.tar.gz: '0826f4b21c1fdd8145763b8357dddfa7f6c06a461b128bb458b7c75886ba5208'
5
5
  SHA512:
6
- metadata.gz: 99b491f10a169e0aeac7fef944d969b48bfa8520a220f3705f4762e3643515dd9e978bef2f5d519abc3970dc29ca734d41d5d6532beb61157389a92aee562ff2
7
- data.tar.gz: b806779564f476de930e152265f2b36a340bd0a1dc82a7d703d8a3789f162910991a2a50d26a5c9b5ae9da719ba9b61032d9b4c58eec6ab5360305213547a700
6
+ metadata.gz: a1379dd0f212e82aad3c889d9c06374810441728700616d9a2293c647bbe0272318d744dcfd4056edf69d8bde847a9394225c334a3909e419f34321d38d9f29f
7
+ data.tar.gz: df9c68524dbdbd81f29e3134c9b1a25de3e6fc57e29346b5beae93bcccb8ac1186bbfe7e3f4a86dbfb81ebc5356f91eeb852cf9a6f504144225c3715e9a63975
@@ -859,98 +859,149 @@ module Pindo
859
859
 
860
860
 
861
861
 
862
- # 合并到发布分支
862
+ # 合并分支
863
+ # 将源分支合并到目标分支,支持单向或双向同步
864
+ #
863
865
  # @param project_dir [String] 项目目录
864
- # @param release_branch [String] 发布分支名称
865
- # @param coding_branch [String] 当前开发分支名称
866
- def merge_to_release_branch(project_dir:, release_branch:, coding_branch:)
866
+ # @param source_branch [String] 源分支名称(要合并的分支)
867
+ # @param target_branch [String] 目标分支名称(接收合并的分支)
868
+ # @param sync_branches [Boolean] 是否双向合并(同步两分支),默认 false
869
+ # - true: 双向合并,source → target,然后 target → source(确保两分支完全同步)
870
+ # - false: 单向合并,仅 source → target
871
+ # @return [void]
872
+ def merge_branches(project_dir:, source_branch:, target_branch:, sync_branches: false)
867
873
  current_project_dir = project_dir
868
- Funlog.instance.fancyinfo_start("开始合并到#{release_branch}分支")
869
- if !coding_branch.eql?(release_branch)
870
- coding_branch_commit_id = git!(%W(-C #{current_project_dir} rev-parse #{coding_branch})).strip
871
- release_branch_commit_id = nil
872
-
873
- if remote_branch_exists?(local_repo_dir: current_project_dir, branch: release_branch)
874
- Funlog.instance.fancyinfo_update("存在#{release_branch}远程分支")
875
- if local_branch_exists?(local_repo_dir: current_project_dir, branch: release_branch)
876
- Funlog.instance.fancyinfo_update("存在#{release_branch}本地分支")
877
- git!(%W(-C #{current_project_dir} checkout #{release_branch}))
874
+ Funlog.instance.fancyinfo_start("开始合并到#{target_branch}分支")
875
+ if !source_branch.eql?(target_branch)
876
+ source_branch_commit_id = git!(%W(-C #{current_project_dir} rev-parse #{source_branch})).strip
877
+ target_branch_commit_id = nil
878
+
879
+ if remote_branch_exists?(local_repo_dir: current_project_dir, branch: target_branch)
880
+ Funlog.instance.fancyinfo_update("存在#{target_branch}远程分支")
881
+ if local_branch_exists?(local_repo_dir: current_project_dir, branch: target_branch)
882
+ Funlog.instance.fancyinfo_update("存在#{target_branch}本地分支")
883
+ git!(%W(-C #{current_project_dir} checkout #{target_branch}))
878
884
  else
879
- Funlog.instance.fancyinfo_update("不存在#{release_branch}本地分支")
880
- git!(%W(-C #{current_project_dir} checkout -b #{release_branch} origin/#{release_branch}))
885
+ Funlog.instance.fancyinfo_update("不存在#{target_branch}本地分支")
886
+ git!(%W(-C #{current_project_dir} checkout -b #{target_branch} origin/#{target_branch}))
881
887
  end
882
888
 
883
- git!(%W(-C #{current_project_dir} branch --set-upstream-to=origin/#{release_branch} #{release_branch}))
884
- git!(%W(-C #{current_project_dir} fetch origin #{release_branch}))
885
- git!(%W(-C #{current_project_dir} merge origin/#{release_branch}))
889
+ git!(%W(-C #{current_project_dir} branch --set-upstream-to=origin/#{target_branch} #{target_branch}))
890
+ git!(%W(-C #{current_project_dir} fetch origin #{target_branch}))
891
+ git!(%W(-C #{current_project_dir} merge origin/#{target_branch}))
886
892
 
887
893
  # 执行合并操作
888
- Executable.capture_command('git', %W(-C #{current_project_dir} merge #{coding_branch}), :capture => :out)
894
+ Executable.capture_command('git', %W(-C #{current_project_dir} merge #{source_branch}), :capture => :out)
889
895
 
890
896
  # 检查是否有冲突
891
897
  conflict_filelist = git!(%W(-C #{current_project_dir} diff --name-only --diff-filter=U --relative))
892
898
  if !conflict_filelist.nil? && !conflict_filelist.strip.empty?
893
- raise Informative, "合并#{coding_branch}到#{release_branch}时产生冲突,请手动处理!"
899
+ raise Informative, "合并#{source_branch}到#{target_branch}时产生冲突,请手动处理!"
894
900
  else
895
901
  git!(%W(-C #{current_project_dir} push))
896
- Funlog.instance.fancyinfo_success("代码已经合并到#{release_branch}分支")
897
- # 获取 release_branch 的 commit ID(处理空分支情况)
902
+ Funlog.instance.fancyinfo_success("代码已经合并到#{target_branch}分支")
903
+ # 获取 target_branch 的 commit ID(处理空分支情况)
898
904
  begin
899
- release_branch_commit_id = git!(%W(-C #{current_project_dir} rev-parse #{release_branch})).strip
905
+ target_branch_commit_id = git!(%W(-C #{current_project_dir} rev-parse #{target_branch})).strip
900
906
  rescue => e
901
- # 分支可能存在但没有提交(空分支),此时使用 coding_branch 的 commit
902
- Funlog.instance.fancyinfo_update("#{release_branch}分支为空或获取commit失败,将使用当前分支commit")
903
- release_branch_commit_id = coding_branch_commit_id
907
+ # 分支可能存在但没有提交(空分支),此时使用 source_branch 的 commit
908
+ Funlog.instance.fancyinfo_update("#{target_branch}分支为空或获取commit失败,将使用当前分支commit")
909
+ target_branch_commit_id = source_branch_commit_id
904
910
  end
905
911
  end
906
912
 
907
913
  else
908
- if local_branch_exists?(local_repo_dir: current_project_dir, branch: release_branch)
909
- Funlog.instance.fancyinfo_update("不存在#{release_branch}远程分支")
910
- Funlog.instance.fancyinfo_update("存在#{release_branch}本地分支")
911
- git!(%W(-C #{current_project_dir} checkout #{release_branch}))
914
+ if local_branch_exists?(local_repo_dir: current_project_dir, branch: target_branch)
915
+ Funlog.instance.fancyinfo_update("不存在#{target_branch}远程分支")
916
+ Funlog.instance.fancyinfo_update("存在#{target_branch}本地分支")
917
+ git!(%W(-C #{current_project_dir} checkout #{target_branch}))
912
918
  # 使用带时间戳的备份分支名,避免重复操作时冲突
913
- backup_branch = "#{release_branch}_backup_#{Time.now.strftime('%Y%m%d%H%M%S')}"
919
+ backup_branch = "#{target_branch}_backup_#{Time.now.strftime('%Y%m%d%H%M%S')}"
914
920
  Funlog.instance.fancyinfo_update("备份本地分支到: #{backup_branch}")
915
921
  git!(%W(-C #{current_project_dir} checkout -b #{backup_branch}))
916
- git!(%W(-C #{current_project_dir} checkout #{coding_branch}))
917
- git!(%W(-C #{current_project_dir} branch -D #{release_branch}))
922
+ git!(%W(-C #{current_project_dir} checkout #{source_branch}))
923
+ git!(%W(-C #{current_project_dir} branch -D #{target_branch}))
918
924
  else
919
- Funlog.instance.fancyinfo_update("不存在#{release_branch}远程分支")
920
- Funlog.instance.fancyinfo_update("不存在#{release_branch}本地分支")
925
+ Funlog.instance.fancyinfo_update("不存在#{target_branch}远程分支")
926
+ Funlog.instance.fancyinfo_update("不存在#{target_branch}本地分支")
921
927
  end
922
928
 
923
- git!(%W(-C #{current_project_dir} checkout -b #{release_branch}))
924
- git!(%W(-C #{current_project_dir} push origin #{release_branch}))
925
- git!(%W(-C #{current_project_dir} branch --set-upstream-to=origin/#{release_branch} #{release_branch}))
929
+ # 基于 source_branch 创建 target_branch(明确指定起点,避免基于错误的分支创建)
930
+ git!(%W(-C #{current_project_dir} checkout -b #{target_branch} #{source_branch}))
931
+ git!(%W(-C #{current_project_dir} push origin #{target_branch}))
932
+ git!(%W(-C #{current_project_dir} branch --set-upstream-to=origin/#{target_branch} #{target_branch}))
926
933
 
927
- Funlog.instance.fancyinfo_success("代码已经合并到#{release_branch}分支")
928
- # 获取 release_branch 的 commit ID(处理空分支情况)
934
+ Funlog.instance.fancyinfo_success("代码已经合并到#{target_branch}分支")
935
+ # 获取 target_branch 的 commit ID(处理空分支情况)
929
936
  begin
930
- release_branch_commit_id = git!(%W(-C #{current_project_dir} rev-parse #{release_branch})).strip
937
+ target_branch_commit_id = git!(%W(-C #{current_project_dir} rev-parse #{target_branch})).strip
931
938
  rescue => e
932
- # 新创建的分支,commit ID 应该与 coding_branch 相同
933
- release_branch_commit_id = coding_branch_commit_id
939
+ # 新创建的分支,commit ID 应该与 source_branch 相同
940
+ target_branch_commit_id = source_branch_commit_id
934
941
  end
935
942
  end
936
943
 
937
- git!(%W(-C #{current_project_dir} checkout #{coding_branch}))
938
- if release_branch_commit_id && !release_branch_commit_id.eql?(coding_branch_commit_id)
939
- Executable.capture_command('git', %W(-C #{current_project_dir} merge #{release_branch}), :capture => :out)
940
- conflict_filelist = git!(%W(-C #{current_project_dir} diff --name-only --diff-filter=U --relative))
941
- if !conflict_filelist.nil? && !conflict_filelist.strip.empty?
942
- raise Informative, "合并#{release_branch}到#{coding_branch}时产生冲突,请手动处理!"
944
+ # 同步分支:将 source_branch 同步到 target_branch(确保两分支在同一节点)
945
+ git!(%W(-C #{current_project_dir} checkout #{source_branch}))
946
+ if sync_branches
947
+ if target_branch_commit_id && !target_branch_commit_id.eql?(source_branch_commit_id)
948
+ # 检查是否可以 fast-forward(即 source_branch 是 target_branch 的祖先)
949
+ is_ancestor = false
950
+ begin
951
+ git!(%W(-C #{current_project_dir} merge-base --is-ancestor #{source_branch} #{target_branch}))
952
+ is_ancestor = true
953
+ rescue => e
954
+ # 不是祖先关系,说明 source_branch 有独立提交(理论上不应该,因为刚合并过)
955
+ Funlog.instance.fancyinfo_warning("#{source_branch} 不是 #{target_branch} 的祖先")
956
+ end
957
+
958
+ if is_ancestor
959
+ # 可以安全 fast-forward(source 的所有提交都在 target 中)
960
+ Funlog.instance.fancyinfo_update("#{source_branch}是#{target_branch}的祖先,执行 fast-forward 合并")
961
+ begin
962
+ # 尝试 fast-forward only merge(确保不产生新 commit)
963
+ git!(%W(-C #{current_project_dir} merge --ff-only #{target_branch}))
964
+ Funlog.instance.fancyinfo_success("已将#{source_branch} fast-forward 到#{target_branch},两分支现在在同一节点")
965
+
966
+ # 推送到远程(普通 push,因为是 fast-forward)
967
+ git!(%W(-C #{current_project_dir} push origin #{source_branch}))
968
+ Funlog.instance.fancyinfo_success("已推送#{source_branch}分支到远程")
969
+ rescue => e
970
+ if e.message.include?("Not possible to fast-forward")
971
+ # 理论上不应该到这里,因为前面检查过是祖先
972
+ Funlog.instance.fancyinfo_warning("无法 fast-forward,将产生 merge commit")
973
+ git!(%W(-C #{current_project_dir} merge #{target_branch}))
974
+ git!(%W(-C #{current_project_dir} push origin #{source_branch}))
975
+ else
976
+ raise e
977
+ end
978
+ end
979
+ else
980
+ # 不是祖先关系,使用普通 merge(会产生新的 merge commit)
981
+ Funlog.instance.fancyinfo_warning("#{source_branch}不是#{target_branch}的祖先,将执行普通合并(可能产生新 commit)")
982
+ Executable.capture_command('git', %W(-C #{current_project_dir} merge #{target_branch}), :capture => :out)
983
+
984
+ # 检查冲突
985
+ conflict_filelist = git!(%W(-C #{current_project_dir} diff --name-only --diff-filter=U --relative))
986
+ if !conflict_filelist.nil? && !conflict_filelist.strip.empty?
987
+ raise Informative, "合并#{target_branch}到#{source_branch}时产生冲突,请手动处理!"
988
+ end
989
+
990
+ git!(%W(-C #{current_project_dir} push origin #{source_branch}))
991
+ Funlog.instance.fancyinfo_success("已将#{target_branch}合并到#{source_branch}(产生了新 merge commit)")
992
+ end
993
+ else
994
+ Funlog.instance.fancyinfo_success("#{source_branch}和#{target_branch}已经在同一节点,无需同步")
943
995
  end
944
- Funlog.instance.fancyinfo_success("已将#{release_branch}合并到#{coding_branch}")
996
+ else
997
+ Funlog.instance.fancyinfo_success("单向合并完成,未同步 #{target_branch} 到 #{source_branch}")
945
998
  end
946
- git!(%W(-C #{current_project_dir} push origin #{coding_branch}))
947
- Funlog.instance.fancyinfo_success("已推送#{coding_branch}分支到远程")
948
999
  else
949
- Funlog.instance.fancyinfo_success("代码处于#{coding_branch}分支,无需合并")
1000
+ Funlog.instance.fancyinfo_success("代码处于#{source_branch}分支,无需合并")
950
1001
  end
951
1002
  end
952
1003
 
953
- # 检查并推送未推送的本地提交
1004
+ # 检查并推送未推送的本地提交,确保本地和远程分支完全同步
954
1005
  # @param project_dir [String] 项目目录路径
955
1006
  # @param branch [String] 分支名称
956
1007
  # @return [void]
@@ -976,20 +1027,44 @@ module Pindo
976
1027
  return
977
1028
  end
978
1029
 
979
- # 3. 检查本地分支是否领先远程分支
1030
+ # 3. 先 fetch 获取最新的远程状态
1031
+ git!(%W(-C #{project_dir} fetch origin #{branch}))
1032
+
1033
+ # 4. 检查本地分支是否领先远程分支
980
1034
  ahead_count = git!(%W(-C #{project_dir} rev-list --count #{remote_branch}..#{branch})).strip.to_i
981
1035
 
982
- # 4. 如果没有未推送的提交,直接返回
983
- if ahead_count == 0
984
- Funlog.instance.fancyinfo_success("本地分支 #{branch} 与远程分支同步,无需推送")
1036
+ # 5. 检查远程分支是否领先本地分支
1037
+ behind_count = git!(%W(-C #{project_dir} rev-list --count #{branch}..#{remote_branch})).strip.to_i
1038
+
1039
+ # 6. 根据同步状态执行相应操作
1040
+ if ahead_count == 0 && behind_count == 0
1041
+ Funlog.instance.fancyinfo_success("本地分支 #{branch} 与远程分支完全同步")
985
1042
  return
986
- end
1043
+ elsif ahead_count > 0 && behind_count == 0
1044
+ # 仅本地领先:直接推送
1045
+ Funlog.instance.fancyinfo_warning("检测到 #{ahead_count} 个本地提交尚未推送")
1046
+ Funlog.instance.fancyinfo_start("正在推送到远程分支 #{remote_branch}...")
1047
+ git!(%W(-C #{project_dir} push origin #{branch}))
1048
+ Funlog.instance.fancyinfo_success("推送成功!")
1049
+ elsif ahead_count == 0 && behind_count > 0
1050
+ # 仅远程领先:重置本地到远程位置
1051
+ Funlog.instance.fancyinfo_warning("远程分支领先本地 #{behind_count} 个提交")
1052
+
1053
+ # 检查工作目录是否干净
1054
+ status = git!(%W(-C #{project_dir} status --porcelain)).strip
1055
+ unless status.empty?
1056
+ raise Informative, "工作目录有未提交的修改,无法同步远程更新。请先提交或 stash 修改。"
1057
+ end
987
1058
 
988
- # 5. 有未推送的提交,直接推送(不显示内容,不询问用户)
989
- Funlog.instance.fancyinfo_warning("检测到 #{ahead_count} 个本地提交尚未推送")
990
- Funlog.instance.fancyinfo_start("正在推送到远程分支 #{remote_branch}...")
991
- git!(%W(-C #{project_dir} push origin #{branch}))
992
- Funlog.instance.fancyinfo_success("推送成功!")
1059
+ # 工作目录干净,安全地重置到远程位置
1060
+ Funlog.instance.fancyinfo_start("正在重置本地分支到远程位置...")
1061
+ git!(%W(-C #{project_dir} reset --hard #{remote_branch}))
1062
+ Funlog.instance.fancyinfo_success("已同步到远程分支!")
1063
+ else
1064
+ # 分叉:需要合并
1065
+ Funlog.instance.fancyinfo_warning("本地和远程分支已分叉:本地领先 #{ahead_count} 个提交,远程领先 #{behind_count} 个提交")
1066
+ raise Informative, "本地分支和远程分支已分叉,请手动合并或变基后再继续!"
1067
+ end
993
1068
  end
994
1069
 
995
1070
  end
@@ -33,45 +33,63 @@ module Pindo
33
33
  self.description = <<-DESC
34
34
  编译Android工程生成APK/AAB并支持上传到JPS测试平台。
35
35
 
36
- 支持功能:
36
+ 参数优先级说明(从低到高):
37
37
 
38
- * 自动修改工程配置(Application ID、App Name、URL Schemes)
38
+ 1. 无参数:
39
+ - Git 提交 → 编译 APK → 打 Git Tag
39
40
 
40
- * 编译生成APK或AAB文件
41
+ 2. --upload:
42
+ - 在基础流程上增加:上传 APK → 发送消息给自己
41
43
 
42
- * 支持上传到JPS测试平台
44
+ 3. --media:
45
+ - 自动启用 --upload
46
+ - 在 --upload 基础上增加:上传媒体附件(JPSMedia/ 目录)
43
47
 
44
- * 支持发送测试通知
48
+ 4. --bind:
49
+ - 自动启用 --media 和 --upload
50
+ - 在 --media 基础上增加:绑定 Git commit 到已上传的包
45
51
 
46
- * 支持Unity和原生Android工程
52
+ 5. --send:
53
+ - 自动启用 --bind、--media 和 --upload
54
+ - 在 --bind 基础上增加:发送工作流消息到测试群
55
+
56
+ 支持功能:
47
57
 
58
+ * 自动修改工程配置(Application ID、App Name、URL Schemes)
59
+ * 编译生成 APK 或 AAB 文件
60
+ * 上传到 JPS 测试平台
61
+ * 上传媒体附件(图片、视频)
62
+ * 绑定 Git commit 到已上传的包
63
+ * 发送测试通知(自己/测试群)
64
+ * 支持 Unity 和原生 Android 工程
48
65
  * 支持并发任务执行(使用 --multi 参数)
49
66
 
50
67
  使用示例:
51
68
 
52
- $ pindo android autobuild # 编译Debug包
69
+ $ pindo and autobuild --bundle_name=com.example.app # 指定 Bundle Name
53
70
 
54
- $ pindo android autobuild --release # 编译Release包
71
+ $ pindo and autobuild --proj="My App" # 指定项目名称
55
72
 
56
- $ pindo android autobuild --upload # 编译并上传到JPS
73
+ $ pindo and autobuild # 编译、打tag
57
74
 
58
- $ pindo android autobuild --send # 编译、上传并发送群组通知
75
+ $ pindo and autobuild --release # 编译 Release 包
59
76
 
60
- $ pindo android autobuild --media # 编译、上传并上传媒体附件
77
+ $ pindo and autobuild --upload # 编译、打tag、上传、发上传消息
61
78
 
62
- $ pindo android autobuild --bundle_name=com.example.app # 使用指定bundle name的配置
79
+ $ pindo and autobuild --media # 编译、打tag、上传、发上传消息、上传媒体附件
63
80
 
64
- $ pindo android autobuild --proj="My App" # 指定项目名称
81
+ $ pindo and autobuild --bind # 编译、打tag、上传、发上传消息、上传媒体附件 + 绑定包到工作流
65
82
 
66
- $ pindo android autobuild --multi # 使用并发模式执行(速度更快)
83
+ $ pindo and autobuild --send # 编译、打tag、上传、发上传消息、上传媒体附件、绑定包到工作流 + 发送群消息
67
84
 
68
- $ pindo android autobuild --multi --upload # 并发执行并上传
85
+ $ pindo and autobuild --multi # 使用并发模式执行
69
86
  DESC
70
87
 
71
88
  # 定义此命令使用的参数项
72
89
  def self.option_items
73
90
  @option_items ||= Pindo::Options::OptionGroup.merge(
74
- Pindo::Options::JPSOptions.select(:proj, :upload, :send, :media),
91
+ Pindo::Options::BuildOptions.select(:bundle_name), # 添加 bundle_name 参数
92
+ Pindo::Options::JPSOptions.select(:proj, :upload, :media, :bind, :send),
75
93
  Pindo::Options::UnityOptions.select(:skiplib, :skipyoo),
76
94
  Pindo::Options::UnityOptions.select_with_defaults(skipconfig: true),
77
95
  Pindo::Options::TaskOptions.select(:multi),
@@ -81,8 +99,7 @@ module Pindo
81
99
 
82
100
  def self.options
83
101
  [
84
- ['--release', '使用Release模式构建'],
85
- ['--bundle_name=NAME', '指定Android Package Name(如com.example.app,会拉取对应配置)']
102
+ ['--release', '使用Release模式构建']
86
103
  ].concat(option_items.map(&:to_claide_option)).concat(super)
87
104
  end
88
105
 
@@ -90,14 +107,23 @@ module Pindo
90
107
  @options = initialize_options(argv)
91
108
 
92
109
  @args_release_flag = argv.flag?('release', false)
93
- @args_upload_flag = @options[:upload] || false
94
- @args_send_flag = @options[:send] || false
95
110
  @args_proj_name = @options[:proj]
96
- @args_bundle_name = argv.option('bundle_name')
111
+ @args_bundle_name = @options[:bundle_name] # 从 @options 获取,确保能被缓存
112
+
113
+ # send、media 或 bind 都依赖 upload:如果指定了任一参数,自动启用 upload
114
+ @args_upload_flag = @options[:send] || @options[:bind] || @options[:media] || @options[:upload]
115
+
116
+ # media 任务是独立的,不依赖任何其他任务,但是为输入命令参数更加简单,如果有--bind和--send, 则默认认为一定会有--media参数
117
+ @args_media_flag = @options[:send] || @options[:bind] || @options[:media] || false
118
+
119
+ # send 都依赖 bind:如果指定了任一参数,自动启用 bind
120
+ @args_bind_flag = @options[:send] || @options[:bind] || false
121
+
122
+ @args_send_flag = @options[:send]
123
+
124
+ # Unity 参数
97
125
  @args_skip_lib = @options[:skiplib] || false
98
126
  @args_skip_yoo = @options[:skipyoo] || false
99
- # media 依赖 upload:如果指定了 media,自动启用 upload
100
- @args_media_flag = @options[:media] || false
101
127
 
102
128
  # Task 参数
103
129
  @args_multi_flag = @options[:multi] || false
@@ -108,10 +134,6 @@ module Pindo
108
134
  @args_tag_type = Pindo::Options::GitOptions.parse_create_tag_type(@options[:tag_type] || 'new')
109
135
  @args_tag_pre = @options[:tag_pre] || 'v'
110
136
 
111
- if @args_send_flag || @args_media_flag
112
- @args_upload_flag = true
113
- end
114
-
115
137
  super
116
138
  @additional_args = argv.remainder!
117
139
  end
@@ -150,6 +172,12 @@ module Pindo
150
172
  # 获取 Bundle Name
151
173
  bundle_name = @args_bundle_name || get_selected_dev_bundle_name()
152
174
 
175
+ # 重要:如果 bundle_name 是通过交互式选择获取的,同步回 @options
176
+ if bundle_name && (@args_bundle_name.nil? || @args_bundle_name.empty?)
177
+ @args_bundle_name = bundle_name
178
+ @options[:bundle_name] = bundle_name # 确保能被缓存系统保存
179
+ end
180
+
153
181
  # 获取 JPS 配置
154
182
  app_info_obj, workflow_info = PgyerHelper.share_instace.prepare_upload(
155
183
  working_directory: pindo_project_dir,
@@ -256,8 +284,6 @@ module Pindo
256
284
  project_path: android_project_path,
257
285
  bundle_name: config[:bundle_name],
258
286
  proj_name: @args_proj_name,
259
- upload: @args_upload_flag,
260
- send: @args_send_flag,
261
287
  app_info_obj: config[:app_info_obj],
262
288
  workflow_info: config[:workflow_info],
263
289
  # Git 版本参数
@@ -283,6 +309,7 @@ module Pindo
283
309
  tasks << git_tag_task
284
310
 
285
311
  # 5. 上传和消息发送任务(如果需要)
312
+ upload_task = nil # 声明变量以便后续绑定任务使用
286
313
  if @args_upload_flag
287
314
  # 5.1 创建上传任务
288
315
  upload_task = Pindo::TaskSystem::JPSUploadTask.new(
@@ -296,15 +323,15 @@ module Pindo
296
323
  upload_task.dependencies << build_task.id
297
324
  tasks << upload_task
298
325
 
299
- # 5.2 创建消息发送任务(只依赖上传任务)
326
+ # 5.2 创建消息发送任务(只依赖上传任务,固定发送给自己)
300
327
  # app_version_info 将从 upload_task 的数据参数中获取
301
328
  message_task = Pindo::TaskSystem::JPSMessageTask.new(
302
329
  nil, # app_version_info 为 nil,从依赖任务获取
303
330
  app_info_obj: config[:app_info_obj],
304
331
  project_name: @args_proj_name,
305
- send_message_type: @args_send_flag ? 'group' : 'self',
306
- dependencies: [upload_task.id] # 从 upload_task 获取数据
332
+ send_message_type: 'self' # 固定发送给自己
307
333
  )
334
+ message_task.dependencies << upload_task.id
308
335
  tasks << message_task
309
336
  end
310
337
 
@@ -325,11 +352,52 @@ module Pindo
325
352
  workflow_info: git_workflow_info,
326
353
  project_name: @args_proj_name
327
354
  )
328
- # 只依赖 Git 提交任务
355
+ # 依赖 Git 提交任务
329
356
  media_upload_task.dependencies << git_commit_task.id
330
357
  tasks << media_upload_task
331
358
  end
332
359
 
360
+ # 7. 创建 Git Commit 绑定任务(如果需要,依赖上传任务)
361
+ bind_package_task = nil # 声明变量以便后续工作流消息任务使用
362
+ if @args_bind_flag
363
+ bind_package_task = Pindo::TaskSystem::JPSBindPackageTask.new(
364
+ nil, # app_version_list 为 nil,从依赖任务获取
365
+ project_dir: config[:project_path],
366
+ app_info_obj: config[:app_info_obj],
367
+ workflow_info: config[:workflow_info],
368
+ project_name: @args_proj_name
369
+ )
370
+ # 依赖上传任务和 Git 提交任务
371
+ bind_package_task.dependencies << upload_task.id
372
+ bind_package_task.dependencies << git_commit_task.id
373
+ tasks << bind_package_task
374
+ end
375
+
376
+ # 8. 创建工作流消息任务(如果需要,发送到测试群)
377
+ if @args_send_flag
378
+ # 获取 Git 工作流信息
379
+ git_app_info_obj, git_workflow_info = PgyerHelper.share_instace.prepare_upload(
380
+ working_directory: config[:project_path],
381
+ proj_name: @args_proj_name,
382
+ package_type: "",
383
+ manage_type: "git"
384
+ )
385
+
386
+ workflow_message_task = Pindo::TaskSystem::JPSWorkFlowMessageTask.new(
387
+ project_id: git_app_info_obj["id"],
388
+ workflow_id: git_workflow_info["id"],
389
+ branch: 'master',
390
+ single: true,
391
+ app_info_obj: git_app_info_obj,
392
+ workflow_info: git_workflow_info
393
+ )
394
+ # 依赖 Git Commit、Git Tag 和 Bind Package 任务
395
+ workflow_message_task.dependencies << git_commit_task.id
396
+ workflow_message_task.dependencies << git_tag_task.id
397
+ workflow_message_task.dependencies << bind_package_task.id
398
+ tasks << workflow_message_task
399
+ end
400
+
333
401
  tasks
334
402
  else
335
403
  raise Informative, "当前目录不是工程目录,不能编译"
@@ -55,7 +55,7 @@ module Pindo
55
55
  Pindo::Options::OptionItem.new(
56
56
  key: :sign,
57
57
  description: '启用签名标志',
58
- type: TrueClass,
58
+ type: :boolean,
59
59
  optional: true,
60
60
  default_value: false,
61
61
  example: 'pindo appstore bundleid --sign'
@@ -61,7 +61,7 @@ module Pindo
61
61
  Pindo::Options::OptionItem.new(
62
62
  key: :dev,
63
63
  description: '创建开发环境证书(默认为生产环境)',
64
- type: TrueClass,
64
+ type: :boolean,
65
65
  optional: true,
66
66
  default_value: false,
67
67
  example: 'pindo appstore pem --dev'