pindo 5.11.4 → 5.12.1
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/command/android/autobuild.rb +111 -184
- data/lib/pindo/command/android/build.rb +10 -2
- data/lib/pindo/command/ios/autobuild.rb +115 -210
- data/lib/pindo/command/ios/build.rb +12 -3
- data/lib/pindo/command/jps/upload.rb +257 -117
- data/lib/pindo/command/unity/autobuild.rb +308 -220
- data/lib/pindo/command/unity.rb +0 -3
- data/lib/pindo/command/utils/boss.rb +18 -15
- data/lib/pindo/command/utils/clearcert.rb +26 -18
- data/lib/pindo/command/utils/device.rb +28 -19
- data/lib/pindo/command/utils/feishu.rb +11 -4
- data/lib/pindo/command/utils/icon.rb +26 -20
- data/lib/pindo/command/utils/renewcert.rb +35 -29
- data/lib/pindo/command/utils/renewproj.rb +32 -25
- data/lib/pindo/command/utils/repoinit.rb +1 -1
- data/lib/pindo/command/utils/tag.rb +6 -180
- data/lib/pindo/command/utils/tgate.rb +34 -28
- data/lib/pindo/command/utils/xcassets.rb +30 -20
- data/lib/pindo/command/web/autobuild.rb +148 -128
- data/lib/pindo/module/android/android_build_helper.rb +0 -6
- data/lib/pindo/module/android/android_config_helper.rb +4 -26
- data/lib/pindo/module/build/build_helper.rb +18 -294
- data/lib/pindo/module/build/git_repo_helper.rb +519 -0
- data/lib/pindo/module/build/icon_downloader.rb +85 -0
- data/lib/pindo/module/pgyer/pgyerhelper.rb +16 -11
- data/lib/pindo/module/task/model/build/android_dev_build_task.rb +209 -0
- data/lib/pindo/module/task/model/build/android_release_build_task.rb +29 -0
- data/lib/pindo/module/task/model/build/ios_adhoc_build_task.rb +53 -0
- data/lib/pindo/module/task/model/build/ios_dev_build_task.rb +251 -0
- data/lib/pindo/module/task/model/build/ios_release_build_task.rb +53 -0
- data/lib/pindo/module/task/model/build/web_dev_build_task.rb +43 -0
- data/lib/pindo/module/task/model/build_task.rb +125 -301
- data/lib/pindo/module/task/model/git_tag_task.rb +80 -0
- data/lib/pindo/module/task/model/unity_export_task.rb +53 -41
- data/lib/pindo/module/task/model/upload_task.rb +149 -208
- data/lib/pindo/module/task/pindo_task.rb +135 -95
- data/lib/pindo/module/task/task_manager.rb +202 -352
- data/lib/pindo/module/unity/unity_helper.rb +7 -3
- data/lib/pindo/module/xcode/xcode_build_config.rb +4 -10
- data/lib/pindo/module/xcode/xcode_build_helper.rb +19 -0
- data/lib/pindo/version.rb +1 -1
- metadata +10 -4
- data/lib/pindo/command/unity/apk.rb +0 -185
- data/lib/pindo/command/unity/ipa.rb +0 -198
- data/lib/pindo/command/unity/web.rb +0 -163
|
@@ -2,16 +2,11 @@ require 'singleton'
|
|
|
2
2
|
require 'fileutils'
|
|
3
3
|
require 'xcodeproj' # 用于iOS项目检查
|
|
4
4
|
require_relative '../android/android_project_helper'
|
|
5
|
-
|
|
6
|
-
require_relative '../../base/pindocontext'
|
|
5
|
+
|
|
7
6
|
module Pindo
|
|
8
7
|
|
|
9
8
|
class BuildHelper
|
|
10
9
|
include Singleton
|
|
11
|
-
include Pindo::Githelper
|
|
12
|
-
|
|
13
|
-
# 临时缓存,只在内存中,不保存到文件
|
|
14
|
-
attr_accessor :temp_tag_decision
|
|
15
10
|
|
|
16
11
|
class << self
|
|
17
12
|
def share_instance
|
|
@@ -37,294 +32,6 @@ module Pindo
|
|
|
37
32
|
end
|
|
38
33
|
end
|
|
39
34
|
|
|
40
|
-
def check_check_and_install_cliff(project_path)
|
|
41
|
-
if is_git_directory?(local_repo_dir: project_path)
|
|
42
|
-
current_git_root_path = git_root_directory(local_repo_dir: project_path)
|
|
43
|
-
unless File.exist?(File.join(current_git_root_path, 'cliff.toml'))
|
|
44
|
-
add_git_cliffconfig(current_git_root_path)
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
begin
|
|
49
|
-
if !system('which git-cliff > /dev/null 2>&1')
|
|
50
|
-
puts "安装git-cliff..."
|
|
51
|
-
install_gitcliff()
|
|
52
|
-
end
|
|
53
|
-
rescue
|
|
54
|
-
raise Informative, "安装git-cliff出现错误"
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def write_gitignore(git_root_dir)
|
|
59
|
-
gitignore_path = File.join(git_root_dir, '.gitignore')
|
|
60
|
-
|
|
61
|
-
# 定义要添加的gitignore规则数组
|
|
62
|
-
ignore_rules = [
|
|
63
|
-
'Temp',
|
|
64
|
-
'Logs',
|
|
65
|
-
'build_ios.log',
|
|
66
|
-
'feishu.json',
|
|
67
|
-
'CHANGELOG.md',
|
|
68
|
-
'GoodPlatform/iOS/*',
|
|
69
|
-
'GoodPlatform/Android/*',
|
|
70
|
-
'GoodPlatform/BaseiOS/Unity/*',
|
|
71
|
-
'GoodPlatform/BaseiOS/Pods/',
|
|
72
|
-
'GoodPlatform/BaseiOS/build',
|
|
73
|
-
'GoodPlatform/BaseiOS/config.json',
|
|
74
|
-
'GoodPlatform/BaseiOS/Podfile.lock',
|
|
75
|
-
'GoodPlatform/BaseAndroid/Unity/*',
|
|
76
|
-
'GoodPlatform/BaseAndroid/build',
|
|
77
|
-
'GoodPlatform/WebGL',
|
|
78
|
-
'config.json',
|
|
79
|
-
'Assets/Packages',
|
|
80
|
-
'Assets/WebGLTemplates.meta',
|
|
81
|
-
'Assets/WebGLTemplates/',
|
|
82
|
-
'Packages/packages-lock.json'
|
|
83
|
-
]
|
|
84
|
-
|
|
85
|
-
# 读取现有的gitignore内容
|
|
86
|
-
existing_lines = []
|
|
87
|
-
if File.exist?(gitignore_path)
|
|
88
|
-
existing_lines = File.readlines(gitignore_path).map(&:strip)
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
# 过滤出需要添加的规则(不存在的)
|
|
92
|
-
rules_to_add = ignore_rules.reject { |rule| existing_lines.include?(rule) }
|
|
93
|
-
|
|
94
|
-
# 如果有需要添加的规则,则添加
|
|
95
|
-
unless rules_to_add.empty?
|
|
96
|
-
File.open(gitignore_path, 'a') do |f|
|
|
97
|
-
# 检查是否已有Pindo标记,如果没有则添加
|
|
98
|
-
pindo_marker = '# Added by Pindo (pindo_common_ignore_1.0.0)'
|
|
99
|
-
f.puts("\n#{pindo_marker}") unless existing_lines.include?(pindo_marker.strip)
|
|
100
|
-
|
|
101
|
-
# 添加每条新规则
|
|
102
|
-
rules_to_add.each do |rule|
|
|
103
|
-
f.puts(rule)
|
|
104
|
-
end
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
def add_git_cliffconfig(project_path)
|
|
110
|
-
|
|
111
|
-
temp_dir = Dir.pwd
|
|
112
|
-
Funlog.instance.fancyinfo_start("添加日志变更git-cliff配置...")
|
|
113
|
-
if is_git_directory?(local_repo_dir: project_path)
|
|
114
|
-
current_git_root_path = git_root_directory(local_repo_dir: project_path)
|
|
115
|
-
Dir.chdir(current_git_root_path)
|
|
116
|
-
pindo_common_dir = clone_pindo_common_config_repo(force_delete:false)
|
|
117
|
-
if File.exist?(File.join(pindo_common_dir, 'cliff.toml'))
|
|
118
|
-
FileUtils.cp_r(File.join(pindo_common_dir, 'cliff.toml'), File.join(current_git_root_path, 'cliff.toml'))
|
|
119
|
-
end
|
|
120
|
-
Funlog.instance.fancyinfo_update("仓库添加git-cliff配置")
|
|
121
|
-
write_gitignore(current_git_root_path)
|
|
122
|
-
Funlog.instance.fancyinfo_update("仓库添加.gitignore")
|
|
123
|
-
Dir.chdir(current_git_root_path)
|
|
124
|
-
current_branch = git!(%W(-C #{current_git_root_path} rev-parse --abbrev-ref HEAD)).strip
|
|
125
|
-
git!(%W(-C #{current_git_root_path} add cliff.toml))
|
|
126
|
-
git!(%W(-C #{current_git_root_path} add .gitignore))
|
|
127
|
-
commit_message = "docs: 添加日志变更配置".encode('UTF-8')
|
|
128
|
-
git!(%W(-C #{current_git_root_path} commit -m #{commit_message}))
|
|
129
|
-
git!(%W(-C #{current_git_root_path} push origin #{current_branch}))
|
|
130
|
-
|
|
131
|
-
else
|
|
132
|
-
Funlog.instance.fancyinfo_error("当前目录不是git仓库,请在git仓库根目录下执行此命令")
|
|
133
|
-
raise Informative, "当前目录不是git仓库,请在git仓库根目录下执行此命令"
|
|
134
|
-
Dir.chdir(temp_dir)
|
|
135
|
-
end
|
|
136
|
-
Funlog.instance.fancyinfo_success("日志变更git-cliff配置完成!")
|
|
137
|
-
Dir.chdir(temp_dir)
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
def install_gitcliff()
|
|
141
|
-
puts "\n检查git-cliff命令是否安装"
|
|
142
|
-
# 请检查git-cliff命令是否安装
|
|
143
|
-
begin
|
|
144
|
-
if !system('which git-cliff > /dev/null 2>&1')
|
|
145
|
-
# /bin/bash -c "$(curl -fsSL https://gitee.com/goodtools/env/raw/master/gitcliff_install.sh)"
|
|
146
|
-
#安装git-cliff
|
|
147
|
-
system('bash -c "$(curl -fsSL https://gitee.com/goodtools/env/raw/master/gitcliff_install.sh)"')
|
|
148
|
-
end
|
|
149
|
-
rescue
|
|
150
|
-
raise Informative, "安装git-cliff出现错误"
|
|
151
|
-
end
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
def check_is_need_add_tag?(project_path, auto_mode: false)
|
|
156
|
-
tag_action_parms = nil
|
|
157
|
-
is_need_add_tag = false
|
|
158
|
-
|
|
159
|
-
if is_git_directory?(local_repo_dir: project_path)
|
|
160
|
-
current_git_root_path = git_root_directory(local_repo_dir: project_path)
|
|
161
|
-
latest_tag = get_latest_version_tag(project_dir: current_git_root_path)
|
|
162
|
-
|
|
163
|
-
unless is_tag_at_head?(git_root_dir: current_git_root_path, tag_name: latest_tag)
|
|
164
|
-
# 检查环境变量
|
|
165
|
-
env_tag_decision = ENV['PINDO_TAG_DECISION']
|
|
166
|
-
if env_tag_decision && !env_tag_decision.empty?
|
|
167
|
-
case env_tag_decision.downcase
|
|
168
|
-
when 'new', 'new_tag', '1'
|
|
169
|
-
puts "\n环境变量指定:新增版本号,打新Tag"
|
|
170
|
-
puts
|
|
171
|
-
tag_action_parms = []
|
|
172
|
-
is_need_add_tag = true
|
|
173
|
-
# 保存到缓存
|
|
174
|
-
context = PindoContext.instance
|
|
175
|
-
decision = {
|
|
176
|
-
tag_action_parms: tag_action_parms,
|
|
177
|
-
is_need_add_tag: is_need_add_tag,
|
|
178
|
-
action: :new_tag,
|
|
179
|
-
description: "新增版本号,打新Tag"
|
|
180
|
-
}
|
|
181
|
-
context.set_selection(PindoContext::SelectionKey::TAG_DECISION, decision)
|
|
182
|
-
return is_need_add_tag, tag_action_parms
|
|
183
|
-
when 'retag', 'recreate', '2'
|
|
184
|
-
puts "\n环境变量指定:将上次的Tag删除重新打Tag"
|
|
185
|
-
puts
|
|
186
|
-
tag_action_parms = ['--retag']
|
|
187
|
-
is_need_add_tag = true
|
|
188
|
-
# 保存到缓存
|
|
189
|
-
context = PindoContext.instance
|
|
190
|
-
decision = {
|
|
191
|
-
tag_action_parms: tag_action_parms,
|
|
192
|
-
is_need_add_tag: is_need_add_tag,
|
|
193
|
-
action: :recreate_tag,
|
|
194
|
-
description: "将上次的Tag删除重新打Tag"
|
|
195
|
-
}
|
|
196
|
-
context.set_selection(PindoContext::SelectionKey::TAG_DECISION, decision)
|
|
197
|
-
return is_need_add_tag, tag_action_parms
|
|
198
|
-
when 'skip', 'no', 'none', '3'
|
|
199
|
-
puts "\n环境变量指定:不需要Tag继续编译"
|
|
200
|
-
puts
|
|
201
|
-
tag_action_parms = nil
|
|
202
|
-
is_need_add_tag = false
|
|
203
|
-
# 保存到缓存
|
|
204
|
-
context = PindoContext.instance
|
|
205
|
-
decision = {
|
|
206
|
-
tag_action_parms: tag_action_parms,
|
|
207
|
-
is_need_add_tag: is_need_add_tag,
|
|
208
|
-
action: :continue_without_tag,
|
|
209
|
-
description: "不需要Tag继续编译且上传"
|
|
210
|
-
}
|
|
211
|
-
context.set_selection(PindoContext::SelectionKey::TAG_DECISION, decision)
|
|
212
|
-
return is_need_add_tag, tag_action_parms
|
|
213
|
-
when 'exit', 'quit', '4'
|
|
214
|
-
raise Informative, "环境变量指定:终止退出编译!"
|
|
215
|
-
end
|
|
216
|
-
end
|
|
217
|
-
|
|
218
|
-
if auto_mode
|
|
219
|
-
# 在自动化模式或没有交互式终端时,默认选择新增版本号打新Tag
|
|
220
|
-
puts "检测到当前代码没有打Tag,在自动模式下将自动新增版本号并打新Tag"
|
|
221
|
-
tag_action_parms = []
|
|
222
|
-
is_need_add_tag = true # 自动模式下需要打tag
|
|
223
|
-
else
|
|
224
|
-
# 检查是否已有用户选择
|
|
225
|
-
context = PindoContext.instance
|
|
226
|
-
build_helper = BuildHelper.share_instance
|
|
227
|
-
# 优先从持久化缓存读取,如果没有则从内存临时缓存读取
|
|
228
|
-
cached_decision = context.get_selection(PindoContext::SelectionKey::TAG_DECISION)
|
|
229
|
-
|
|
230
|
-
# 只有当持久化缓存中确实不存在该键时,才从临时缓存读取
|
|
231
|
-
if cached_decision.nil? && !context.has_selection?(PindoContext::SelectionKey::TAG_DECISION)
|
|
232
|
-
cached_decision = build_helper.temp_tag_decision
|
|
233
|
-
end
|
|
234
|
-
|
|
235
|
-
if cached_decision && cached_decision.is_a?(Hash)
|
|
236
|
-
# 使用之前的选择
|
|
237
|
-
puts "\n使用之前的选择:#{cached_decision[:description]}"
|
|
238
|
-
tag_action_parms = cached_decision[:tag_action_parms]
|
|
239
|
-
is_need_add_tag = cached_decision[:is_need_add_tag]
|
|
240
|
-
|
|
241
|
-
# 如果是退出选择,则抛出异常
|
|
242
|
-
if cached_decision[:action] == :exit
|
|
243
|
-
raise Informative, "终止退出编译!"
|
|
244
|
-
end
|
|
245
|
-
else
|
|
246
|
-
# 第一次询问
|
|
247
|
-
cli = HighLine.new
|
|
248
|
-
selected_action = nil
|
|
249
|
-
selected_description = nil
|
|
250
|
-
|
|
251
|
-
menu_options = {
|
|
252
|
-
"新增版本号,打新Tag" => -> {
|
|
253
|
-
tag_action_parms = []
|
|
254
|
-
selected_action = :new_tag
|
|
255
|
-
selected_description = "新增版本号,打新Tag"
|
|
256
|
-
is_need_add_tag = true # 明确设置需要打tag
|
|
257
|
-
:new_tag
|
|
258
|
-
},
|
|
259
|
-
"将上次的Tag删除重新打Tag" => -> {
|
|
260
|
-
tag_action_parms = []
|
|
261
|
-
tag_action_parms << "--retag"
|
|
262
|
-
selected_action = :recreate_tag
|
|
263
|
-
selected_description = "将上次的Tag删除重新打Tag"
|
|
264
|
-
is_need_add_tag = true # 明确设置需要打tag
|
|
265
|
-
:recreate_tag
|
|
266
|
-
},
|
|
267
|
-
"不需要Tag继续编译且上传,手动修改上传备注" => -> {
|
|
268
|
-
puts ""
|
|
269
|
-
tag_action_parms = nil # 明确设置为nil
|
|
270
|
-
selected_action = :continue_without_tag
|
|
271
|
-
selected_description = "不需要Tag继续编译且上传"
|
|
272
|
-
is_need_add_tag = false # 明确设置不需要打tag
|
|
273
|
-
:continue_without_tag
|
|
274
|
-
},
|
|
275
|
-
"终止退出编译" => -> {
|
|
276
|
-
tag_action_parms = nil # 明确设置为nil
|
|
277
|
-
selected_action = :exit
|
|
278
|
-
selected_description = "终止退出编译"
|
|
279
|
-
is_need_add_tag = false # 明确设置不需要打tag
|
|
280
|
-
raise Informative, "终止退出编译!"
|
|
281
|
-
:exit
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
result = cli.choose do |menu|
|
|
286
|
-
menu.header = "当前代码并没有打Tag,上传的Changelog需要Tag"
|
|
287
|
-
menu.prompt = "请选中打Tag的方式, 请输入选项(1/2/3...):"
|
|
288
|
-
menu_options.each do |option, action|
|
|
289
|
-
menu.choice(option) { action.call }
|
|
290
|
-
end
|
|
291
|
-
end
|
|
292
|
-
|
|
293
|
-
# is_need_add_tag 已在各个选项中明确设置,无需重新计算
|
|
294
|
-
|
|
295
|
-
# 保存用户选择
|
|
296
|
-
build_helper = BuildHelper.share_instance
|
|
297
|
-
# 只有选择"新增版本号,打新Tag"时才保存到持久化缓存
|
|
298
|
-
# 其他选项只保存到临时缓存(内存中)
|
|
299
|
-
if selected_action == :new_tag
|
|
300
|
-
# 保存到持久化缓存(文件)
|
|
301
|
-
context.set_selection(PindoContext::SelectionKey::TAG_DECISION, {
|
|
302
|
-
action: selected_action,
|
|
303
|
-
description: selected_description,
|
|
304
|
-
tag_action_parms: tag_action_parms,
|
|
305
|
-
is_need_add_tag: is_need_add_tag
|
|
306
|
-
})
|
|
307
|
-
# 清除临时缓存
|
|
308
|
-
build_helper.temp_tag_decision = nil
|
|
309
|
-
else
|
|
310
|
-
# 清空持久化缓存
|
|
311
|
-
context.set_selection(PindoContext::SelectionKey::TAG_DECISION, nil)
|
|
312
|
-
# 保存到临时缓存(仅在内存中,不会写入文件)
|
|
313
|
-
build_helper.temp_tag_decision = {
|
|
314
|
-
action: selected_action,
|
|
315
|
-
description: selected_description,
|
|
316
|
-
tag_action_parms: tag_action_parms,
|
|
317
|
-
is_need_add_tag: is_need_add_tag
|
|
318
|
-
}
|
|
319
|
-
end
|
|
320
|
-
end
|
|
321
|
-
end
|
|
322
|
-
end
|
|
323
|
-
end
|
|
324
|
-
|
|
325
|
-
return [is_need_add_tag, tag_action_parms]
|
|
326
|
-
end
|
|
327
|
-
|
|
328
35
|
def unity_project?(project_path)
|
|
329
36
|
# 检查Unity工程的关键文件和目录
|
|
330
37
|
project_settings_path = File.join(project_path, "ProjectSettings")
|
|
@@ -361,6 +68,23 @@ module Pindo
|
|
|
361
68
|
false
|
|
362
69
|
end
|
|
363
70
|
|
|
71
|
+
def macos_project?(project_path)
|
|
72
|
+
# 检查是否为 macOS 工程
|
|
73
|
+
begin
|
|
74
|
+
project_fullname = Dir.glob(File.join(project_path, "*.xcodeproj")).max_by {|f| File.mtime(f)}
|
|
75
|
+
if !project_fullname.nil?
|
|
76
|
+
project_obj = Xcodeproj::Project.open(project_fullname)
|
|
77
|
+
project_build_platform = project_obj.root_object.build_configuration_list.get_setting("SDKROOT")["Release"]
|
|
78
|
+
if !project_build_platform.nil? && project_build_platform.eql?("macosx")
|
|
79
|
+
return true
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
rescue => e
|
|
83
|
+
puts "判断 macOS 工程失败: #{e.message}" if ENV['DEBUG']
|
|
84
|
+
end
|
|
85
|
+
false
|
|
86
|
+
end
|
|
87
|
+
|
|
364
88
|
def android_project?(project_path)
|
|
365
89
|
# 检查Android工程的关键文件和目录
|
|
366
90
|
gradle_file = File.exist?(File.join(project_path, "build.gradle")) || File.exist?(File.join(project_path, "build.gradle.kts"))
|