pindo 5.13.11 → 5.13.13
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 +4 -4
- data/lib/pindo/base/funlog.rb +62 -5
- data/lib/pindo/base/git_handler.rb +83 -22
- data/lib/pindo/base/output_sink.rb +69 -0
- data/lib/pindo/command/android/autobuild.rb +57 -8
- data/lib/pindo/command/appstore/autobuild.rb +10 -1
- data/lib/pindo/command/ios/autobuild.rb +59 -7
- data/lib/pindo/command/jps/media.rb +185 -58
- data/lib/pindo/command/jps/upload.rb +14 -9
- data/lib/pindo/command/unity/autobuild.rb +64 -10
- data/lib/pindo/command/unity/packpush.rb +27 -3
- data/lib/pindo/command/utils/tag.rb +9 -1
- data/lib/pindo/command/web/autobuild.rb +59 -10
- data/lib/pindo/module/android/android_build_helper.rb +6 -7
- data/lib/pindo/module/build/git_repo_helper.rb +29 -25
- data/lib/pindo/module/pgyer/pgyerhelper.rb +174 -77
- data/lib/pindo/module/task/core/concurrent_execution_strategy.rb +237 -0
- data/lib/pindo/module/task/core/dependency_checker.rb +123 -0
- data/lib/pindo/module/task/core/execution_strategy.rb +61 -0
- data/lib/pindo/module/task/core/resource_lock_manager.rb +190 -0
- data/lib/pindo/module/task/core/serial_execution_strategy.rb +60 -0
- data/lib/pindo/module/task/core/task_executor.rb +131 -0
- data/lib/pindo/module/task/core/task_queue.rb +221 -0
- data/lib/pindo/module/task/model/build/android_build_dev_task.rb +1 -1
- data/lib/pindo/module/task/model/build/android_build_task.rb +6 -2
- data/lib/pindo/module/task/model/build/ios_build_dev_task.rb +2 -3
- data/lib/pindo/module/task/model/build/ios_build_task.rb +6 -0
- data/lib/pindo/module/task/model/build_task.rb +22 -0
- data/lib/pindo/module/task/model/git/git_commit_task.rb +11 -2
- data/lib/pindo/module/task/model/git_task.rb +6 -0
- data/lib/pindo/module/task/model/jps/jps_message_task.rb +9 -11
- data/lib/pindo/module/task/model/jps/jps_upload_media_task.rb +264 -64
- data/lib/pindo/module/task/model/jps_task.rb +0 -1
- data/lib/pindo/module/task/model/unity_task.rb +38 -2
- data/lib/pindo/module/task/output/multi_line_output_manager.rb +380 -0
- data/lib/pindo/module/task/output/multi_line_task_display.rb +185 -0
- data/lib/pindo/module/task/output/stdout_redirector.rb +95 -0
- data/lib/pindo/module/task/pindo_task.rb +133 -9
- data/lib/pindo/module/task/task_manager.rb +98 -268
- data/lib/pindo/module/task/task_reporter.rb +135 -0
- data/lib/pindo/module/task/task_resources/resource_instance.rb +90 -0
- data/lib/pindo/module/task/task_resources/resource_registry.rb +105 -0
- data/lib/pindo/module/task/task_resources/resource_type.rb +59 -0
- data/lib/pindo/module/task/task_resources/types/directory_based_resource.rb +63 -0
- data/lib/pindo/module/task/task_resources/types/global_exclusive_resource.rb +33 -0
- data/lib/pindo/module/task/task_resources/types/global_shared_resource.rb +34 -0
- data/lib/pindo/module/xcode/xcode_build_helper.rb +26 -8
- data/lib/pindo/options/groups/jps_options.rb +10 -0
- data/lib/pindo/options/groups/task_options.rb +39 -0
- data/lib/pindo/version.rb +3 -2
- metadata +20 -1
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
require 'highline/import'
|
|
2
|
-
require 'fileutils'
|
|
3
|
-
require 'json'
|
|
4
1
|
require 'pindo/module/pgyer/pgyerhelper'
|
|
5
2
|
require 'pindo/module/task/task_manager'
|
|
6
3
|
require 'pindo/module/task/model/jps/jps_upload_media_task'
|
|
4
|
+
require 'pindo/options/options'
|
|
5
|
+
require 'pindo/options/groups/task_options'
|
|
7
6
|
|
|
8
7
|
module Pindo
|
|
9
8
|
class Command
|
|
@@ -19,21 +18,22 @@ module Pindo
|
|
|
19
18
|
|
|
20
19
|
* 上传多个media文件(图片、视频等)
|
|
21
20
|
* 并发上传,支持重试
|
|
22
|
-
*
|
|
21
|
+
* 自动关联到当前 HEAD commit 记录
|
|
23
22
|
* 支持追加模式(保留已有附件)
|
|
24
|
-
* 自动模式:从项目 JPSMedia/
|
|
23
|
+
* 自动模式:从项目 JPSMedia/ 目录查找 3 小时内的文件
|
|
24
|
+
* 支持选择历史 commit(使用 --select 参数)
|
|
25
25
|
|
|
26
26
|
使用示例:
|
|
27
27
|
|
|
28
|
-
$ pindo jps media #
|
|
28
|
+
$ pindo jps media # 自动模式:从 JPSMedia/ 查找文件
|
|
29
29
|
|
|
30
|
-
$ pindo jps media path/to/1.png path/to/2.mov #
|
|
30
|
+
$ pindo jps media path/to/1.png path/to/2.mov # 上传指定文件
|
|
31
31
|
|
|
32
|
-
$ pindo jps media --
|
|
32
|
+
$ pindo jps media --proj=demo # 指定项目
|
|
33
33
|
|
|
34
|
-
$ pindo jps media --
|
|
34
|
+
$ pindo jps media --select # 交互式选择历史 commit
|
|
35
35
|
|
|
36
|
-
$ pindo jps media --
|
|
36
|
+
$ pindo jps media --select path/to/file.png # 选择 commit 并上传指定文件
|
|
37
37
|
|
|
38
38
|
DESC
|
|
39
39
|
|
|
@@ -41,13 +41,17 @@ module Pindo
|
|
|
41
41
|
CLAide::Argument.new('files...', false),
|
|
42
42
|
]
|
|
43
43
|
|
|
44
|
+
# 定义此命令使用的参数项
|
|
45
|
+
def self.option_items
|
|
46
|
+
@option_items ||= Pindo::Options::OptionGroup.merge(
|
|
47
|
+
Pindo::Options::JPSOptions.select(:proj),
|
|
48
|
+
Pindo::Options::TaskOptions.select(:select),
|
|
49
|
+
Pindo::Options::GitOptions.all
|
|
50
|
+
)
|
|
51
|
+
end
|
|
52
|
+
|
|
44
53
|
def self.options
|
|
45
|
-
|
|
46
|
-
['--commit_id', '指定 git commit id(默认使用 HEAD)'],
|
|
47
|
-
['--workflow_id', '指定工作流ID(用于查找 commit_log)'],
|
|
48
|
-
['--proj', '指定项目代号名称'],
|
|
49
|
-
['--login', '强制再次登录jps网站'],
|
|
50
|
-
].concat(super)
|
|
54
|
+
option_items.map(&:to_claide_option).concat(super)
|
|
51
55
|
end
|
|
52
56
|
|
|
53
57
|
def initialize(argv)
|
|
@@ -57,49 +61,101 @@ module Pindo
|
|
|
57
61
|
@file_paths << arg.strip.gsub(/\"/, '')
|
|
58
62
|
end
|
|
59
63
|
|
|
60
|
-
|
|
61
|
-
@
|
|
62
|
-
@args_proj_name = argv.option('proj')
|
|
63
|
-
@args_login_flag = argv.flag?('login', false)
|
|
64
|
+
# 使用 Options 系统解析参数
|
|
65
|
+
@options = initialize_options(argv)
|
|
64
66
|
|
|
65
|
-
#
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
# JPS 参数
|
|
68
|
+
@args_proj_name = @options[:proj]
|
|
69
|
+
|
|
70
|
+
# Task 参数
|
|
71
|
+
@args_select_flag = @options[:select] || false
|
|
69
72
|
|
|
70
73
|
super(argv)
|
|
71
74
|
end
|
|
72
75
|
|
|
73
76
|
def validate!
|
|
74
77
|
super
|
|
75
|
-
# 不再强制要求参数,Task 会自动从 git 获取
|
|
76
78
|
end
|
|
77
79
|
|
|
78
80
|
def run
|
|
79
81
|
project_path = Dir.pwd
|
|
80
82
|
|
|
81
|
-
#
|
|
82
|
-
|
|
83
|
+
# 如果启用 --select 参数,获取用户选择的 commit
|
|
84
|
+
selected_commit_info = nil
|
|
85
|
+
if @args_select_flag
|
|
86
|
+
selected_commit_info = select_git_commit(project_path)
|
|
87
|
+
|
|
88
|
+
if selected_commit_info.nil?
|
|
89
|
+
puts "未选择任何提交,已取消操作"
|
|
90
|
+
return
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
puts "\n已选择提交:"
|
|
94
|
+
puts " Commit ID: #{selected_commit_info[:commit_id][0..7]}"
|
|
95
|
+
puts " 时间: #{selected_commit_info[:commit_time]}"
|
|
96
|
+
puts " 描述: #{selected_commit_info[:commit_desc]}"
|
|
97
|
+
puts ""
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# 获取 JPS 配置(app_info_obj 和 workflow_info)
|
|
101
|
+
# 使用 manage_type: "git" 来获取 git 管理类型的工作流
|
|
102
|
+
app_info_obj, workflow_info = PgyerHelper.share_instace.prepare_upload(
|
|
103
|
+
working_directory: project_path,
|
|
104
|
+
proj_name: @args_proj_name,
|
|
105
|
+
package_type: "", # package_type 在 manage_type=git 时会被忽略
|
|
106
|
+
manage_type: "git"
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
if app_info_obj.nil?
|
|
110
|
+
raise Informative, "#{@args_proj_name} 错误,请输入正确的App代号名称"
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# 获取 workflow_id
|
|
114
|
+
workflow_id = workflow_info&.dig(:workflow_id) || workflow_info&.dig('id')
|
|
115
|
+
|
|
116
|
+
# 创建任务链
|
|
117
|
+
tasks = []
|
|
118
|
+
|
|
119
|
+
# 1. 提前询问用户如何处理未提交的文件
|
|
120
|
+
process_type = Pindo::GitHandler.get_uncommitted_files_process_type(
|
|
121
|
+
project_dir: project_path,
|
|
122
|
+
interactive: true
|
|
123
|
+
)
|
|
83
124
|
|
|
84
|
-
#
|
|
85
|
-
|
|
125
|
+
# 2. 创建 Git 提交任务
|
|
126
|
+
git_commit_task = Pindo::TaskSystem::GitCommitTask.new(
|
|
127
|
+
project_path,
|
|
128
|
+
{
|
|
129
|
+
process_type: process_type,
|
|
130
|
+
commit_message: "feat: jps media 上传前提交"
|
|
131
|
+
}
|
|
132
|
+
)
|
|
133
|
+
tasks << git_commit_task
|
|
86
134
|
|
|
87
|
-
#
|
|
135
|
+
# 3. 创建 JPS Media 上传任务
|
|
88
136
|
# 所有逻辑都在 Task 中处理:
|
|
89
137
|
# - 自动查找 git 仓库和 HEAD 信息
|
|
138
|
+
# - 展开文件路径(通配符、目录)
|
|
90
139
|
# - 自动查找 JPSMedia/ 目录
|
|
91
140
|
# - 匹配 git_commit_id 到 JPS commit_log
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
141
|
+
media_upload_task = Pindo::TaskSystem::JPSUploadMediaTask.new(
|
|
142
|
+
@file_paths,
|
|
143
|
+
project_path, # upload_path
|
|
144
|
+
app_info_obj: app_info_obj,
|
|
145
|
+
workflow_info: workflow_info,
|
|
96
146
|
project_name: @args_proj_name,
|
|
97
|
-
|
|
147
|
+
git_commit_id: selected_commit_info&.dig(:commit_id),
|
|
148
|
+
git_commit_time: selected_commit_info&.dig(:commit_time),
|
|
149
|
+
git_commit_desc: selected_commit_info&.dig(:commit_desc)
|
|
98
150
|
)
|
|
151
|
+
# Media 上传任务依赖 Git 提交任务
|
|
152
|
+
media_upload_task.dependencies << git_commit_task.id
|
|
153
|
+
tasks << media_upload_task
|
|
99
154
|
|
|
155
|
+
# 执行任务链
|
|
100
156
|
task_manager = Pindo::TaskSystem::TaskManager.instance
|
|
101
157
|
task_manager.clear_all
|
|
102
|
-
task_manager.add_task(task)
|
|
158
|
+
tasks.each { |task| task_manager.add_task(task) }
|
|
103
159
|
task_manager.start
|
|
104
160
|
|
|
105
161
|
# 输出结果
|
|
@@ -113,31 +169,102 @@ module Pindo
|
|
|
113
169
|
|
|
114
170
|
private
|
|
115
171
|
|
|
116
|
-
#
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
172
|
+
# 交互式选择 git commit
|
|
173
|
+
# @param project_path [String] 项目路径
|
|
174
|
+
# @return [Hash, nil] 包含 :commit_id, :commit_time, :commit_desc,或 nil(取消)
|
|
175
|
+
def select_git_commit(project_path)
|
|
176
|
+
# 1. 查找 git 根目录
|
|
177
|
+
git_root = find_git_root(project_path)
|
|
178
|
+
unless git_root
|
|
179
|
+
raise Informative, "当前目录不是 git 仓库"
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
# 2. 获取最近 15 条 commit 历史
|
|
183
|
+
all_commits = get_recent_commits(git_root, limit: 15)
|
|
184
|
+
|
|
185
|
+
if all_commits.empty?
|
|
186
|
+
raise Informative, "未找到 git commit 历史"
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
# 3. 筛选符合规范的提交(以 feat:, fix: 等开头)
|
|
190
|
+
valid_prefixes = ['feat:', 'fix:', 'docs:', 'style:', 'refactor:', 'perf:', 'test:', 'build:', 'ci:', 'chore:', 'revert:']
|
|
191
|
+
commits = all_commits.select do |commit|
|
|
192
|
+
desc = commit[:commit_desc].to_s.strip
|
|
193
|
+
valid_prefixes.any? { |prefix| desc.downcase.start_with?(prefix) }
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
# 如果没有符合规范的提交,提示用户并使用全部提交
|
|
197
|
+
if commits.empty?
|
|
198
|
+
puts "\n警告:在最近15个提交中未找到符合规范的提交(feat:, fix: 等开头)"
|
|
199
|
+
puts "显示所有提交供您选择:"
|
|
200
|
+
commits = all_commits
|
|
201
|
+
else
|
|
202
|
+
puts "\n从最近15个提交中筛选出 #{commits.size} 个符合规范的提交:"
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
# 4. 显示 commit 列表
|
|
206
|
+
puts "\n请选择要上传 media 的 git 提交:"
|
|
207
|
+
puts "━" * 80
|
|
208
|
+
commits.each_with_index do |commit, index|
|
|
209
|
+
puts "#{index + 1}. [#{commit[:commit_id][0..7]}] #{commit[:commit_time]} - #{commit[:commit_desc]}"
|
|
210
|
+
end
|
|
211
|
+
puts "0. 取消操作"
|
|
212
|
+
puts "━" * 80
|
|
213
|
+
|
|
214
|
+
# 5. 获取用户选择
|
|
215
|
+
choice = nil
|
|
216
|
+
loop do
|
|
217
|
+
print "\n请输入序号 (0-#{commits.size}): "
|
|
218
|
+
input = $stdin.gets.strip
|
|
219
|
+
|
|
220
|
+
choice = input.to_i
|
|
221
|
+
break if choice >= 0 && choice <= commits.size
|
|
222
|
+
|
|
223
|
+
puts "无效输入,请输入 0-#{commits.size} 之间的数字"
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
# 6. 返回选择的 commit(0 表示取消)
|
|
227
|
+
choice == 0 ? nil : commits[choice - 1]
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
# 查找 git 根目录
|
|
231
|
+
# @param path [String] 起始路径
|
|
232
|
+
# @return [String, nil] git 根目录,未找到返回 nil
|
|
233
|
+
def find_git_root(path)
|
|
234
|
+
current = File.expand_path(path)
|
|
235
|
+
while current != '/'
|
|
236
|
+
if File.exist?(File.join(current, '.git'))
|
|
237
|
+
return current
|
|
136
238
|
end
|
|
239
|
+
current = File.dirname(current)
|
|
137
240
|
end
|
|
241
|
+
nil
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
# 获取最近的 git commits
|
|
245
|
+
# @param git_root [String] git 根目录
|
|
246
|
+
# @param limit [Integer] 获取的 commit 数量
|
|
247
|
+
# @return [Array<Hash>] commit 列表,每个元素包含 :commit_id, :commit_time, :commit_desc
|
|
248
|
+
def get_recent_commits(git_root, limit: 20)
|
|
249
|
+
Dir.chdir(git_root) do
|
|
250
|
+
# 使用 git log 获取 commit 历史
|
|
251
|
+
# 格式:commit_id|commit_time|commit_desc
|
|
252
|
+
output = `git log -#{limit} --format="%H|%ci|%s" 2>/dev/null`.strip
|
|
253
|
+
|
|
254
|
+
return [] if output.empty?
|
|
138
255
|
|
|
139
|
-
|
|
140
|
-
|
|
256
|
+
output.split("\n").map do |line|
|
|
257
|
+
parts = line.split('|', 3)
|
|
258
|
+
{
|
|
259
|
+
commit_id: parts[0],
|
|
260
|
+
commit_time: parts[1],
|
|
261
|
+
commit_desc: parts[2]
|
|
262
|
+
}
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
rescue => e
|
|
266
|
+
Funlog.instance.fancyinfo_error("获取 git commit 历史失败: #{e.message}")
|
|
267
|
+
[]
|
|
141
268
|
end
|
|
142
269
|
|
|
143
270
|
end
|
|
@@ -8,7 +8,6 @@ require 'pindo/module/build/build_helper'
|
|
|
8
8
|
require 'pindo/module/task/task_manager'
|
|
9
9
|
require 'pindo/module/task/model/jps/jps_upload_task'
|
|
10
10
|
require 'pindo/module/task/model/git/git_commit_task'
|
|
11
|
-
require 'pindo/module/task/model/git/git_tag_task'
|
|
12
11
|
require 'pindo/options/options'
|
|
13
12
|
|
|
14
13
|
module Pindo
|
|
@@ -164,20 +163,26 @@ module Pindo
|
|
|
164
163
|
}
|
|
165
164
|
|
|
166
165
|
# 1. Git 提交和标签任务
|
|
166
|
+
# 1.0 提前询问用户如何处理未提交的文件
|
|
167
|
+
process_type = Pindo::GitHandler.get_uncommitted_files_process_type(
|
|
168
|
+
project_dir: project_dir,
|
|
169
|
+
interactive: true
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
git_options_with_process = git_options.merge({
|
|
173
|
+
process_type: process_type,
|
|
174
|
+
commit_message: "feat: jps upload 构建前提交"
|
|
175
|
+
})
|
|
176
|
+
|
|
167
177
|
# 1.1 Git 提交任务
|
|
168
|
-
git_commit_task = Pindo::TaskSystem::GitCommitTask.new(project_dir,
|
|
178
|
+
git_commit_task = Pindo::TaskSystem::GitCommitTask.new(project_dir, git_options_with_process)
|
|
169
179
|
tasks << git_commit_task
|
|
170
180
|
|
|
171
|
-
# 1.2 Git 标签任务(依赖提交任务)
|
|
172
|
-
git_tag_task = Pindo::TaskSystem::GitTagTask.new(project_dir, git_options)
|
|
173
|
-
git_tag_task.dependencies << git_commit_task.id
|
|
174
|
-
tasks << git_tag_task
|
|
175
|
-
|
|
176
181
|
# 2. 查找并创建上传任务
|
|
177
182
|
upload_tasks = find_and_create_upload_tasks(project_dir)
|
|
178
|
-
# 让所有上传任务依赖 Git
|
|
183
|
+
# 让所有上传任务依赖 Git 提交任务
|
|
179
184
|
upload_tasks.each do |upload_task|
|
|
180
|
-
upload_task.dependencies <<
|
|
185
|
+
upload_task.dependencies << git_commit_task.id
|
|
181
186
|
end
|
|
182
187
|
tasks.concat(upload_tasks)
|
|
183
188
|
|
|
@@ -13,12 +13,14 @@ require 'pindo/module/task/model/unity/unity_update_task'
|
|
|
13
13
|
require 'pindo/module/task/model/unity/unity_yoo_asset_task'
|
|
14
14
|
require 'pindo/module/task/model/unity/unity_export_task'
|
|
15
15
|
require 'pindo/module/task/model/jps/jps_upload_task'
|
|
16
|
+
require 'pindo/module/task/model/jps/jps_upload_media_task'
|
|
16
17
|
require 'pindo/module/task/model/jps/jps_message_task'
|
|
17
18
|
require 'pindo/module/task/model/git/git_commit_task'
|
|
18
19
|
require 'pindo/module/task/model/git/git_tag_task'
|
|
19
20
|
require 'pindo/config/build_info_manager'
|
|
20
21
|
require 'pindo/config/ios_config_parser'
|
|
21
22
|
require 'pindo/options/options'
|
|
23
|
+
require 'pindo/options/groups/task_options'
|
|
22
24
|
|
|
23
25
|
module Pindo
|
|
24
26
|
class Command
|
|
@@ -50,9 +52,13 @@ module Pindo
|
|
|
50
52
|
|
|
51
53
|
* 支持发送测试通知
|
|
52
54
|
|
|
55
|
+
* 支持并发任务执行(使用 --multi 参数)
|
|
56
|
+
|
|
53
57
|
使用示例:
|
|
54
58
|
|
|
55
|
-
$ pindo unity autobuild #
|
|
59
|
+
$ pindo unity autobuild # 编译所有类型(默认串行执行)
|
|
60
|
+
|
|
61
|
+
$ pindo unity autobuild --multi # 使用并发模式执行(速度更快)
|
|
56
62
|
|
|
57
63
|
$ pindo unity autobuild --types=ipa # 仅编译IPA
|
|
58
64
|
|
|
@@ -63,6 +69,10 @@ module Pindo
|
|
|
63
69
|
$ pindo unity autobuild --upload # 编译所有类型并上传到JPS
|
|
64
70
|
|
|
65
71
|
$ pindo unity autobuild --proj="My App" # 指定项目名称
|
|
72
|
+
|
|
73
|
+
$ pindo unity autobuild --media # 编译并上传媒体附件
|
|
74
|
+
|
|
75
|
+
$ pindo unity autobuild --multi --upload # 并发执行并上传
|
|
66
76
|
DESC
|
|
67
77
|
|
|
68
78
|
# 命令参数
|
|
@@ -73,9 +83,10 @@ module Pindo
|
|
|
73
83
|
# 定义此命令使用的参数项
|
|
74
84
|
def self.option_items
|
|
75
85
|
@option_items ||= Pindo::Options::OptionGroup.merge(
|
|
76
|
-
Pindo::Options::JPSOptions.select(:proj, :upload, :send),
|
|
86
|
+
Pindo::Options::JPSOptions.select(:proj, :upload, :send, :media),
|
|
77
87
|
Pindo::Options::UnityOptions.select(:skiplib, :skipyoo),
|
|
78
88
|
Pindo::Options::UnityOptions.select_with_defaults(skipconfig: true),
|
|
89
|
+
Pindo::Options::TaskOptions.select(:multi),
|
|
79
90
|
Pindo::Options::GitOptions.all
|
|
80
91
|
)
|
|
81
92
|
end
|
|
@@ -99,6 +110,7 @@ module Pindo
|
|
|
99
110
|
@args_proj_name = @options[:proj]
|
|
100
111
|
@args_upload_flag = @options[:upload] || false
|
|
101
112
|
@args_send_flag = @options[:send] || false
|
|
113
|
+
@args_media_flag = @options[:media] || false
|
|
102
114
|
@args_adhoc_flag = argv.flag?('adhoc', false)
|
|
103
115
|
@args_deploy_flag = argv.flag?('deploy', false)
|
|
104
116
|
@args_release_flag = argv.flag?('release', false)
|
|
@@ -108,14 +120,17 @@ module Pindo
|
|
|
108
120
|
@args_skip_lib = @options[:skiplib] || false
|
|
109
121
|
@args_skip_yoo = @options[:skipyoo] || false
|
|
110
122
|
|
|
123
|
+
# Task 参数
|
|
124
|
+
@args_multi_flag = @options[:multi] || false
|
|
125
|
+
|
|
111
126
|
# Git 参数
|
|
112
127
|
@args_release_branch = @options[:release_branch] || 'master'
|
|
113
128
|
@args_ver_inc = Pindo::Options::GitOptions.parse_version_increase_type(@options[:ver_inc] || 'mini')
|
|
114
129
|
@args_tag_type = Pindo::Options::GitOptions.parse_create_tag_type(@options[:tag_type] || 'new')
|
|
115
130
|
@args_tag_pre = @options[:tag_pre] || 'v'
|
|
116
131
|
|
|
117
|
-
# 如果开启 send,自动开启 upload
|
|
118
|
-
if @args_send_flag
|
|
132
|
+
# 如果开启 send 或 media,自动开启 upload
|
|
133
|
+
if @args_send_flag || @args_media_flag
|
|
119
134
|
@args_upload_flag = true
|
|
120
135
|
end
|
|
121
136
|
|
|
@@ -180,8 +195,18 @@ module Pindo
|
|
|
180
195
|
task_manager.add_task(task)
|
|
181
196
|
end
|
|
182
197
|
|
|
183
|
-
#
|
|
184
|
-
task_manager.
|
|
198
|
+
# # 启用输出管理(自动处理多线程日志隔离)
|
|
199
|
+
# task_manager.enable_output_management(
|
|
200
|
+
# log_dir: File.join(pindo_project_dir, 'pindo_logs'),
|
|
201
|
+
# max_lines_per_task: 0
|
|
202
|
+
# )
|
|
203
|
+
|
|
204
|
+
# 执行任务(根据 --multi 参数决定模式)
|
|
205
|
+
if @args_multi_flag
|
|
206
|
+
task_manager.start(mode: :concurrent, max_workers: 3)
|
|
207
|
+
else
|
|
208
|
+
task_manager.start(mode: :serial)
|
|
209
|
+
end
|
|
185
210
|
end
|
|
186
211
|
|
|
187
212
|
# 按平台顺序创建所有任务
|
|
@@ -194,12 +219,20 @@ module Pindo
|
|
|
194
219
|
selected_platforms = selected_platforms.sort_by { |p| platform_order.index(p) || 999 }
|
|
195
220
|
|
|
196
221
|
# 第零步:创建 Git 提交任务
|
|
222
|
+
# 提前询问用户如何处理未提交的文件
|
|
223
|
+
process_type = Pindo::GitHandler.get_uncommitted_files_process_type(
|
|
224
|
+
project_dir: Dir.pwd,
|
|
225
|
+
interactive: true # 允许交互,因为这是在任务执行前的主线程中
|
|
226
|
+
)
|
|
227
|
+
|
|
197
228
|
git_commit_task = Pindo::TaskSystem::GitCommitTask.new(
|
|
198
229
|
Dir.pwd,
|
|
199
230
|
release_branch: @args_release_branch,
|
|
200
231
|
ver_inc: @args_ver_inc,
|
|
201
232
|
tag_type: @args_tag_type,
|
|
202
|
-
tag_pre: @args_tag_pre
|
|
233
|
+
tag_pre: @args_tag_pre,
|
|
234
|
+
process_type: process_type,
|
|
235
|
+
commit_message: "feat: unity autobuild 构建前提交"
|
|
203
236
|
)
|
|
204
237
|
all_tasks << git_commit_task
|
|
205
238
|
|
|
@@ -293,19 +326,40 @@ module Pindo
|
|
|
293
326
|
upload_task = create_upload_task(platform, all_platform_configs, build_task)
|
|
294
327
|
all_tasks << upload_task
|
|
295
328
|
|
|
296
|
-
#
|
|
329
|
+
# 创建消息发送任务(只依赖上传任务)
|
|
297
330
|
message_task = Pindo::TaskSystem::JPSMessageTask.new(
|
|
298
331
|
nil, # app_version_info 为 nil,从依赖任务获取
|
|
299
332
|
app_info_obj: all_platform_configs["app_info_obj"],
|
|
300
333
|
project_name: all_platform_configs["project_name"],
|
|
301
334
|
send_message_type: @args_send_flag ? 'group' : 'self',
|
|
302
|
-
|
|
335
|
+
dependencies: [upload_task.id] # 从 upload_task 获取数据
|
|
303
336
|
)
|
|
304
|
-
message_task.dependencies << upload_task.id # 执行顺序依赖
|
|
305
337
|
all_tasks << message_task
|
|
306
338
|
end
|
|
307
339
|
end
|
|
308
340
|
|
|
341
|
+
# 第五步:创建媒体附件上传任务(如果需要,只依赖 Git 提交任务)
|
|
342
|
+
if @args_media_flag
|
|
343
|
+
# 获取 Git 管理类型的工作流(不同于包上传的工作流)
|
|
344
|
+
git_app_info_obj, git_workflow_info = PgyerHelper.share_instace.prepare_upload(
|
|
345
|
+
working_directory: Dir.pwd,
|
|
346
|
+
proj_name: all_platform_configs["project_name"],
|
|
347
|
+
package_type: "", # package_type 在 manage_type=git 时会被忽略
|
|
348
|
+
manage_type: "git"
|
|
349
|
+
)
|
|
350
|
+
|
|
351
|
+
media_upload_task = Pindo::TaskSystem::JPSUploadMediaTask.new(
|
|
352
|
+
[], # 空数组,自动从 JPSMedia/ 目录查找
|
|
353
|
+
Dir.pwd, # upload_path
|
|
354
|
+
app_info_obj: git_app_info_obj,
|
|
355
|
+
workflow_info: git_workflow_info,
|
|
356
|
+
project_name: all_platform_configs["project_name"]
|
|
357
|
+
)
|
|
358
|
+
# 只依赖 Git 提交任务
|
|
359
|
+
media_upload_task.dependencies << git_commit_task.id
|
|
360
|
+
all_tasks << media_upload_task
|
|
361
|
+
end
|
|
362
|
+
|
|
309
363
|
# 返回所有任务
|
|
310
364
|
all_tasks
|
|
311
365
|
end
|
|
@@ -221,13 +221,37 @@ module Pindo
|
|
|
221
221
|
raise Informative, "JPS 中没有任何项目,请联系管理员创建"
|
|
222
222
|
end
|
|
223
223
|
|
|
224
|
-
|
|
224
|
+
# 优先通过固定 ID 查找 Nuget 组件库项目
|
|
225
|
+
target_project_id = '5e6b36f61b614ed88086373ef874616c'
|
|
226
|
+
nuget_project = projects.find { |p| p['id'] == target_project_id }
|
|
227
|
+
|
|
228
|
+
if nuget_project
|
|
229
|
+
puts "✅ 找到 Nuget 组件库项目: #{nuget_project['projectName']} (ID: #{nuget_project['id']})"
|
|
230
|
+
return nuget_project
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
# 如果没找到固定 ID,让用户输入项目名称
|
|
234
|
+
puts
|
|
235
|
+
puts "⚠️ 未找到默认 Nuget 组件库项目 (ID: #{target_project_id})"
|
|
236
|
+
puts
|
|
237
|
+
|
|
238
|
+
project_name = ask('请输入 Nuget组件的项目名称:') || ''
|
|
239
|
+
project_name = project_name.strip
|
|
240
|
+
|
|
241
|
+
if project_name.empty?
|
|
242
|
+
raise Informative, "项目名称不能为空"
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
# 根据用户输入的名称匹配项目(去掉空格后比较)
|
|
246
|
+
nuget_project = projects.find do |p|
|
|
247
|
+
p['projectName']&.gsub(/\s+/, '')&.downcase == project_name.gsub(/\s+/, '').downcase
|
|
248
|
+
end
|
|
225
249
|
|
|
226
250
|
if nuget_project.nil?
|
|
227
251
|
puts
|
|
228
|
-
puts "❌ 未找到名为 '
|
|
252
|
+
puts "❌ 未找到名为 '#{project_name}' 的项目"
|
|
229
253
|
puts
|
|
230
|
-
raise Informative, "
|
|
254
|
+
raise Informative, "请确认项目名称是否正确,或联系 JPS 管理员添加项目权限"
|
|
231
255
|
end
|
|
232
256
|
|
|
233
257
|
puts "✅ 找到项目: #{nuget_project['projectName']} (ID: #{nuget_project['id']})"
|
|
@@ -76,13 +76,21 @@ module Pindo
|
|
|
76
76
|
# 创建任务列表
|
|
77
77
|
tasks = []
|
|
78
78
|
|
|
79
|
+
# 0. 提前询问用户如何处理未提交的文件
|
|
80
|
+
process_type = Pindo::GitHandler.get_uncommitted_files_process_type(
|
|
81
|
+
project_dir: pindo_project_dir,
|
|
82
|
+
interactive: true
|
|
83
|
+
)
|
|
84
|
+
|
|
79
85
|
# 1. Git 提交任务
|
|
80
86
|
git_commit_task = Pindo::TaskSystem::GitCommitTask.new(
|
|
81
87
|
pindo_project_dir,
|
|
82
88
|
release_branch: @args_release_branch,
|
|
83
89
|
ver_inc: @args_ver_inc,
|
|
84
90
|
tag_type: @args_tag_type,
|
|
85
|
-
tag_pre: @args_tag_pre
|
|
91
|
+
tag_pre: @args_tag_pre,
|
|
92
|
+
process_type: process_type,
|
|
93
|
+
commit_message: "feat: tag 操作前提交"
|
|
86
94
|
)
|
|
87
95
|
tasks << git_commit_task
|
|
88
96
|
|