pindo 5.13.9 → 5.13.11

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 (71) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pindo/base/funlog.rb +13 -0
  3. data/lib/pindo/base/git_handler.rb +247 -42
  4. data/lib/pindo/command/android/autobuild.rb +72 -30
  5. data/lib/pindo/command/android/autoresign.rb +23 -322
  6. data/lib/pindo/command/android/keystore.rb +7 -130
  7. data/lib/pindo/command/appstore/adhocbuild.rb +5 -14
  8. data/lib/pindo/command/appstore/autobuild.rb +64 -14
  9. data/lib/pindo/command/appstore/autoresign.rb +1 -3
  10. data/lib/pindo/command/ios/autobuild.rb +71 -53
  11. data/lib/pindo/command/ios/build.rb +8 -186
  12. data/lib/pindo/command/jps/media.rb +146 -0
  13. data/lib/pindo/command/jps/upload.rb +48 -20
  14. data/lib/pindo/command/jps.rb +1 -0
  15. data/lib/pindo/command/unity/autobuild.rb +99 -27
  16. data/lib/pindo/command/unity/packpush.rb +5 -8
  17. data/lib/pindo/command/utils/repoinit.rb +0 -2
  18. data/lib/pindo/command/utils/tag.rb +58 -26
  19. data/lib/pindo/command/utils.rb +0 -1
  20. data/lib/pindo/command/web/autobuild.rb +71 -37
  21. data/lib/pindo/command.rb +0 -56
  22. data/lib/pindo/config/build_info_manager.rb +7 -8
  23. data/lib/pindo/module/android/android_config_helper.rb +2 -11
  24. data/lib/pindo/module/appselect.rb +15 -41
  25. data/lib/pindo/module/appstore/itcapp_helper.rb +3 -6
  26. data/lib/pindo/module/build/build_helper.rb +28 -18
  27. data/lib/pindo/module/build/git_repo_helper.rb +284 -405
  28. data/lib/pindo/module/cert/pem_helper.rb +3 -6
  29. data/lib/pindo/module/pgyer/pgyerhelper.rb +193 -25
  30. data/lib/pindo/module/task/model/appstore/appstore_task.rb +5 -0
  31. data/lib/pindo/module/task/model/build/android_build_adhoc_task.rb +13 -187
  32. data/lib/pindo/module/task/model/build/android_build_dev_task.rb +36 -34
  33. data/lib/pindo/module/task/model/build/android_build_gplay_task.rb +13 -187
  34. data/lib/pindo/module/task/model/build/ios_build_adhoc_task.rb +9 -6
  35. data/lib/pindo/module/task/model/build/ios_build_appstore_task.rb +9 -6
  36. data/lib/pindo/module/task/model/build/ios_build_dev_task.rb +37 -32
  37. data/lib/pindo/module/task/model/build/web_build_dev_task.rb +7 -5
  38. data/lib/pindo/module/task/model/build_task.rb +8 -11
  39. data/lib/pindo/module/task/model/git/git_commit_task.rb +118 -0
  40. data/lib/pindo/module/task/model/git/git_tag_task.rb +125 -0
  41. data/lib/pindo/module/task/model/git_task.rb +75 -0
  42. data/lib/pindo/module/task/model/jps/jps_message_task.rb +178 -0
  43. data/lib/pindo/module/task/model/{resign → jps}/jps_resign_task.rb +13 -22
  44. data/lib/pindo/module/task/model/jps/jps_upload_media_task.rb +248 -0
  45. data/lib/pindo/module/task/model/jps/jps_upload_task.rb +38 -93
  46. data/lib/pindo/module/task/model/jps_task.rb +43 -0
  47. data/lib/pindo/module/task/model/resign/ipa_local_resign_task.rb +5 -0
  48. data/lib/pindo/module/task/model/unity/unity_config_task.rb +0 -4
  49. data/lib/pindo/module/task/model/unity/unity_export_task.rb +8 -7
  50. data/lib/pindo/module/task/model/unity/unity_update_task.rb +4 -3
  51. data/lib/pindo/module/task/model/unity/unity_yoo_asset_task.rb +8 -7
  52. data/lib/pindo/module/task/model/unity_task.rb +7 -2
  53. data/lib/pindo/module/task/pindo_task.rb +101 -1
  54. data/lib/pindo/module/task/task_manager.rb +29 -32
  55. data/lib/pindo/module/unity/nuget_helper.rb +7 -7
  56. data/lib/pindo/options/core/global_options_state.rb +96 -26
  57. data/lib/pindo/options/core/option_configuration.rb +3 -0
  58. data/lib/pindo/options/core/option_item.rb +36 -0
  59. data/lib/pindo/options/groups/build_options.rb +23 -6
  60. data/lib/pindo/options/groups/git_options.rb +115 -0
  61. data/lib/pindo/options/groups/jps_options.rb +7 -0
  62. data/lib/pindo/options/groups/option_group.rb +15 -0
  63. data/lib/pindo/options/groups/unity_options.rb +49 -0
  64. data/lib/pindo/options/options.rb +2 -0
  65. data/lib/pindo/version.rb +2 -2
  66. metadata +15 -11
  67. data/lib/pindo/base/githelper.rb +0 -686
  68. data/lib/pindo/base/pindocontext.rb +0 -602
  69. data/lib/pindo/command/utils/feishu.rb +0 -134
  70. data/lib/pindo/module/build/version_helper.rb +0 -146
  71. data/lib/pindo/module/task/model/git_tag_task.rb +0 -80
@@ -1,134 +0,0 @@
1
- require 'highline/import'
2
- require 'fileutils'
3
- require 'pindo/client/feishuclient'
4
- require 'pindo/module/build/build_helper'
5
- require 'pindo/module/build/git_repo_helper'
6
- require 'pindo/module/pgyer/pgyerhelper'
7
-
8
- module Pindo
9
- class Command
10
- class Utils < Command
11
- class Feishu < Utils
12
- # 命令的简要说明 - 发送飞书消息
13
- self.summary = '发送飞书消息'
14
-
15
- # 命令的详细说明,包含用法示例
16
- self.description = <<-DESC
17
- 发送飞书消息到指定的飞书群。
18
-
19
- 支持功能:
20
-
21
- * 发送文本消息到飞书群
22
-
23
- * 支持自定义Webhook URL
24
-
25
- * 支持消息签名验证
26
-
27
- * 支持富文本格式
28
-
29
- 使用示例:
30
-
31
- $ pindo utils feishu "要发送的消息" # 发送简单文本消息
32
-
33
- $ pindo utils feishu --webhook=URL "消息内容" # 指定webhook发送
34
-
35
- $ pindo utils feishu "构建完成通知" # 发送构建通知
36
-
37
- $ pindo utils feishu "@所有人 版本已发布" # 发送@所有人消息
38
- DESC
39
-
40
- # 命令的参数列表
41
- self.arguments = []
42
-
43
- # 命令的选项列表
44
- def self.options
45
- [
46
- ['--webhook', '使用feishu 机器人的webhook url'],
47
- ].concat(super)
48
- end
49
-
50
- def initialize(argv)
51
- super
52
- @webhook_url = argv.option('webhook')
53
- # @webhook_url = 'https://open.feishu.cn/open-apis/bot/v2/hook/dbffda6e-a809-4e79-9652-c427c93ffe62'
54
- # @secret = 'VoC4vVmhwWs676zK62NK8d'
55
- @secret = nil
56
- @message = argv.shift_argument || "测试消息"
57
- end
58
-
59
- def validate!
60
- super
61
- help! '请提供要发送的消息内容' unless @message
62
- end
63
-
64
- def run
65
-
66
- pindo_project_dir = Dir.pwd
67
- if @webhook_url.nil? || @webhook_url.empty?
68
- if is_git_directory?(local_repo_dir: pindo_project_dir)
69
- current_git_root_path = git_root_directory(local_repo_dir: pindo_project_dir)
70
- if File.exist?(File.join(current_git_root_path, 'feishu.json'))
71
- feishu_config = JSON.parse(File.read(File.join(current_git_root_path, 'feishu.json')))
72
- @webhook_url = feishu_config['webhook_url']
73
- @secret = feishu_config['secret']
74
- end
75
- end
76
-
77
- if @webhook_url.nil? || @webhook_url.empty?
78
- @webhook_url = ask("请输入飞书webhook url:")
79
- if is_git_directory?(local_repo_dir: pindo_project_dir)
80
- current_git_root_path = git_root_directory(local_repo_dir: pindo_project_dir)
81
- feishu_config = {webhook_url: @webhook_url, secret: @secret}
82
- File.write(File.join(current_git_root_path, 'feishu.json'), JSON.pretty_generate(feishu_config))
83
- Dir.chdir(current_git_root_path)
84
- current_branch = git!(%W(-C #{current_git_root_path} rev-parse --abbrev-ref HEAD)).strip
85
- git!(%W(-C #{current_git_root_path} add feishu.json))
86
- commit_message = "docs: 添加飞书webhook url".encode('UTF-8')
87
- git!(%W(-C #{current_git_root_path} commit -m #{commit_message}))
88
- git!(%W(-C #{current_git_root_path} push origin #{current_branch}))
89
- puts "添加飞书webhook url成功"
90
- end
91
- end
92
-
93
- end
94
- puts "webhook_url: #{@webhook_url}"
95
- puts "secret: #{@secret}"
96
- puts
97
- puts "正在发送飞书消息..."
98
-
99
-
100
- git_repo_helper = Pindo::GitRepoHelper.share_instance
101
- git_repo_helper.check_check_and_install_cliff(pindo_project_dir)
102
- is_need_add_tag, tag_action_parms = git_repo_helper.check_is_need_add_tag?(pindo_project_dir)
103
- if is_need_add_tag
104
- git_repo_helper.create_and_push_tag(
105
- project_dir: pindo_project_dir,
106
- mode: 'minor',
107
- force_retag: tag_action_parms&.include?('--retag') || false,
108
- custom_tag: nil,
109
- release_branch: 'master'
110
- )
111
- end
112
-
113
- unless @webhook_url.nil? || @webhook_url.empty?
114
- @client = Pindo::FeishuClient.new(@webhook_url, @secret)
115
- end
116
-
117
- markdown_content = PgyerHelper.share_instace.get_description_from_git(current_project_dir:pindo_project_dir)
118
- puts
119
- puts "#{markdown_content}"
120
- puts
121
- if !markdown_content.nil? && !markdown_content.empty?
122
- @client.send_markdown(nil, markdown_content)
123
- # @client.send_rich_text("1111", markdown_content)
124
- end
125
-
126
- end
127
-
128
-
129
-
130
-
131
- end
132
- end
133
- end
134
- end
@@ -1,146 +0,0 @@
1
- require 'singleton'
2
- require_relative '../../base/githelper'
3
- require_relative '../../base/funlog'
4
-
5
- module Pindo
6
- class VersionHelper
7
- include Singleton
8
- include Pindo::Githelper
9
-
10
- class << self
11
- def share_instance
12
- instance
13
- end
14
- end
15
-
16
- # 从Git tag获取版本号
17
- # @param project_dir [String] 项目目录路径
18
- # @return [String] 版本号(例如:1.2.0),如果没有tag则返回0.0.1
19
- def get_version_from_tag(project_dir: nil)
20
- raise ArgumentError, "项目目录不能为空" if project_dir.nil?
21
-
22
- # 获取git根目录
23
- git_root = git_root_directory(local_repo_dir: project_dir)
24
- return "0.0.1" unless git_root
25
-
26
- # 尝试不同的tag前缀
27
- latest_tag = nil
28
- ["v", "release", ""].each do |prefix|
29
- latest_tag = get_latest_version_tag(project_dir: git_root, tag_prefix: prefix)
30
- break if latest_tag
31
- end
32
-
33
- return "0.0.1" if latest_tag.nil?
34
-
35
- # 从tag中提取版本号
36
- version = latest_tag.gsub(/^(v|release[\s_-]*)/, '')
37
-
38
- # 确保版本号格式正确(x.y.z)
39
- if version =~ /^\d+\.\d+\.\d+$/
40
- version
41
- elsif version =~ /^\d+\.\d+$/
42
- "#{version}.0"
43
- elsif version =~ /^\d+$/
44
- "#{version}.0.0"
45
- else
46
- "0.0.1"
47
- end
48
- end
49
-
50
- # 获取Build号(从commit hash转换而来)
51
- # @param project_dir [String] 项目目录路径
52
- # @return [Integer] Build号(6位16进制转10进制)
53
- def get_build_number_from_commit(project_dir: nil)
54
- raise ArgumentError, "项目目录不能为空" if project_dir.nil?
55
-
56
- # 获取git根目录
57
- git_root = git_root_directory(local_repo_dir: project_dir)
58
- return 1 unless git_root
59
-
60
- begin
61
- # 获取当前HEAD的commit hash前6位
62
- commit_hash = git!(%W(-C #{git_root} rev-parse HEAD)).strip[0..5]
63
-
64
- # 将16进制转换为10进制
65
- build_number = commit_hash.to_i(16)
66
-
67
- # 确保在Android versionCode安全范围内(最大值为2^31-1)
68
- max_value = 2**31 - 1
69
- build_number = build_number % max_value if build_number > max_value
70
-
71
- # 确保build_number不为0
72
- build_number = 1 if build_number == 0
73
-
74
- build_number
75
- rescue StandardError => e
76
- Funlog.instance.fancyinfo_error("获取commit hash失败: #{e.message}")
77
- # 如果获取失败,返回基于时间戳的默认值
78
- Time.now.to_i % 1000000 + 1
79
- end
80
- end
81
-
82
- # 从Build号反推commit hash前缀
83
- # @param build_number [Integer] Build号
84
- # @return [String] 6位16进制commit hash前缀
85
- def get_commit_hash_from_build_number(build_number: nil)
86
- raise ArgumentError, "Build号不能为空" if build_number.nil?
87
-
88
- # 将10进制转换为6位16进制字符串
89
- "%06x" % build_number.to_i
90
- end
91
-
92
- # 获取版本信息摘要
93
- # @param project_dir [String] 项目目录路径
94
- # @return [Hash] 包含版本号、Build号、commit hash等信息
95
- def get_version_info(project_dir: nil)
96
- raise ArgumentError, "项目目录不能为空" if project_dir.nil?
97
-
98
- # 检查是否为Git仓库
99
- if !is_git_directory?(local_repo_dir: project_dir)
100
- return {
101
- is_git_repo: false,
102
- version: nil,
103
- build_number: nil,
104
- message: "项目不在Git仓库中,保持原有版本号"
105
- }
106
- end
107
-
108
- git_root = git_root_directory(local_repo_dir: project_dir)
109
- version = get_version_from_tag(project_dir: project_dir)
110
- build_number = get_build_number_from_commit(project_dir: project_dir)
111
- commit_hash_prefix = get_commit_hash_from_build_number(build_number: build_number)
112
-
113
- begin
114
- full_commit_hash = git!(%W(-C #{git_root} rev-parse HEAD)).strip
115
- current_branch = git!(%W(-C #{git_root} rev-parse --abbrev-ref HEAD)).strip
116
- latest_tag = get_latest_version_tag(project_dir: git_root) || "无"
117
- rescue StandardError => e
118
- full_commit_hash = ""
119
- current_branch = ""
120
- latest_tag = "无"
121
- end
122
-
123
- {
124
- is_git_repo: true,
125
- version: version,
126
- build_number: build_number,
127
- commit_hash_prefix: commit_hash_prefix,
128
- full_commit_hash: full_commit_hash,
129
- current_branch: current_branch,
130
- latest_tag: latest_tag,
131
- version_string: "#{version} (#{build_number})"
132
- }
133
- end
134
-
135
-
136
- # 验证Build号是否在有效范围内
137
- # @param build_number [Integer] Build号
138
- # @return [Boolean] 是否有效
139
- def valid_build_number?(build_number)
140
- return false if build_number.nil?
141
-
142
- # Android versionCode的有效范围是1到2^31-1
143
- build_number >= 1 && build_number <= 2**31 - 1
144
- end
145
- end
146
- end
@@ -1,80 +0,0 @@
1
- require_relative '../pindo_task'
2
- require 'pindo/module/build/git_repo_helper'
3
-
4
- module Pindo
5
- module TaskSystem
6
- # Git 标签任务
7
- # 检查并创建 Git 标签
8
- class GitTagTask < PindoTask
9
- attr_reader :project_path
10
-
11
- def self.task_type
12
- :git_tag
13
- end
14
-
15
- # 重试配置
16
- def self.default_retry_mode
17
- RetryMode::IMMEDIATE # 立即重试
18
- end
19
-
20
- def self.default_retry_count
21
- 0 # 可以重试 0 次
22
- end
23
-
24
- def self.default_retry_delay
25
- 5 # 默认延迟 5 秒
26
- end
27
-
28
- # 初始化 Git 标签任务
29
- # @param project_path [String] 项目路径
30
- # @param options [Hash] 选项
31
- def initialize(project_path, options = {})
32
- @project_path = project_path
33
-
34
- super("Git仓库打标签", options)
35
- end
36
-
37
- def validate
38
- # 验证项目路径是否存在
39
- unless @project_path && Dir.exist?(@project_path)
40
- @error = "项目路径不存在:#{@project_path}"
41
- return false
42
- end
43
-
44
- true
45
- end
46
-
47
- protected
48
-
49
- def do_work
50
- git_repo_helper = Pindo::GitRepoHelper.share_instance
51
-
52
- # 检查是否需要打标签
53
- is_need_add_tag, tag_action_params = git_repo_helper.check_is_need_add_tag?(@project_path)
54
-
55
- if is_need_add_tag
56
- # 直接调用 GitRepoHelper 创建标签
57
- git_repo_helper.create_and_push_tag(
58
- project_dir: @project_path,
59
- mode: 'minor',
60
- force_retag: tag_action_params&.include?('--retag') || false,
61
- custom_tag: nil,
62
- release_branch: 'master'
63
- )
64
-
65
- {
66
- success: true,
67
- tag_added: true,
68
- tag_params: tag_action_params
69
- }
70
- else
71
- {
72
- success: true,
73
- tag_added: false,
74
- message: "无需添加 Git 标签"
75
- }
76
- end
77
- end
78
- end
79
- end
80
- end