pindo 5.14.3 → 5.14.4
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/aeshelper.rb +1 -0
- data/lib/pindo/base/executable.rb +2 -0
- data/lib/pindo/base/git_handler.rb +45 -7
- data/lib/pindo/base/informative.rb +11 -0
- data/lib/pindo/base/plistbuddyexecutable.rb +2 -0
- data/lib/pindo/client/feishuclient.rb +1 -1
- data/lib/pindo/command/android/autobuild.rb +3 -7
- data/lib/pindo/command/appstore/autobuild.rb +8 -18
- data/lib/pindo/command/gplay/pullconfig.rb +3 -2
- data/lib/pindo/command/ios/autobuild.rb +3 -7
- data/lib/pindo/command/unity/autobuild.rb +5 -14
- data/lib/pindo/command/unity/packbuild.rb +3 -8
- data/lib/pindo/command/utils/tag.rb +2 -7
- data/lib/pindo/command/utils/updateconfig.rb +3 -2
- data/lib/pindo/command/web/autobuild.rb +23 -33
- data/lib/pindo/command.rb +1 -8
- data/lib/pindo/config/ios_config_parser.rb +26 -25
- data/lib/pindo/module/android/android_build_helper.rb +1 -1
- data/lib/pindo/module/android/android_config_helper.rb +1 -1
- data/lib/pindo/module/android/android_res_helper.rb +1 -1
- data/lib/pindo/module/task/model/build/android_build_dev_task.rb +29 -15
- data/lib/pindo/module/task/model/build/ios_build_adhoc_task.rb +2 -3
- data/lib/pindo/module/task/model/build/ios_build_dev_task.rb +30 -16
- data/lib/pindo/module/task/model/git/git_commit_task.rb +50 -13
- data/lib/pindo/module/task/model/git/git_tag_task.rb +16 -7
- data/lib/pindo/module/task/model/jps/jps_message_task.rb +3 -2
- data/lib/pindo/module/task/model/jps/jps_upload_media_task.rb +148 -28
- data/lib/pindo/module/task/model/unity/unity_config_task.rb +4 -0
- data/lib/pindo/module/task/pindo_task.rb +1 -0
- data/lib/pindo/module/xcode/xcode_app_config.rb +26 -16
- data/lib/pindo/module/xcode/xcode_build_config.rb +2 -2
- data/lib/pindo/module/xcode/xcode_swark_helper.rb +5 -5
- data/lib/pindo/version.rb +1 -1
- metadata +4 -3
|
@@ -142,25 +142,39 @@ module Pindo
|
|
|
142
142
|
# 更新版本号
|
|
143
143
|
def update_version_info
|
|
144
144
|
git_repo_helper = Pindo::GitRepoHelper.share_instance
|
|
145
|
+
build_version = nil
|
|
146
|
+
build_number = nil
|
|
145
147
|
|
|
146
|
-
#
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
# 获取 build_number(从 commit hash 计算)
|
|
154
|
-
build_number = git_repo_helper.get_build_number_from_commit(project_dir: @project_path)
|
|
148
|
+
# 优先级 1: 从 GitCommitTask 获取版本号(无论当前目录是否为 Git 仓库)
|
|
149
|
+
git_commit_data = get_data_param_by_key(:git_commit)
|
|
150
|
+
if git_commit_data && git_commit_data[:task_param] &&
|
|
151
|
+
git_commit_data[:task_param][:build_version] && git_commit_data[:task_param][:build_number]
|
|
152
|
+
build_version = git_commit_data[:task_param][:build_version]
|
|
153
|
+
build_number = git_commit_data[:task_param][:build_number]
|
|
154
|
+
Funlog.instance.fancyinfo_success("使用 GitCommitTask 的版本号: #{build_version}, Build: #{build_number}")
|
|
155
155
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
156
|
+
else
|
|
157
|
+
# 优先级 2: 检查当前目录是否是 Git 仓库
|
|
158
|
+
git_root = Pindo::GitHandler.git_root_directory(local_repo_dir: @project_path)
|
|
159
|
+
|
|
160
|
+
if git_root
|
|
161
|
+
# 是 Git 仓库,自己计算版本号
|
|
162
|
+
build_number = git_repo_helper.get_build_number_from_commit(project_dir: @project_path)
|
|
163
|
+
build_version = git_repo_helper.calculate_build_version(
|
|
164
|
+
project_dir: @project_path,
|
|
165
|
+
tag_prefix: @tag_pre,
|
|
166
|
+
create_tag_type: @tag_type,
|
|
167
|
+
version_increase_type: @ver_inc
|
|
168
|
+
)
|
|
169
|
+
Funlog.instance.fancyinfo_success("自己计算版本号: #{build_version}, Build: #{build_number}")
|
|
170
|
+
else
|
|
171
|
+
# 不是 Git 仓库且没有从 GitCommitTask 获取到版本号,跳过版本更新
|
|
172
|
+
Funlog.warning("非Git仓库且未从 GitCommitTask 获取到版本号,保持工程原有版本号")
|
|
173
|
+
return
|
|
174
|
+
end
|
|
175
|
+
end
|
|
163
176
|
|
|
177
|
+
# 更新版本号
|
|
164
178
|
Pindo::XcodeBuildConfig.update_ios_project_version(
|
|
165
179
|
project_dir: @project_path,
|
|
166
180
|
version: build_version,
|
|
@@ -27,9 +27,15 @@ module Pindo
|
|
|
27
27
|
# - ver_inc: 版本号增加类型,默认 :mini
|
|
28
28
|
# - tag_type: 创建tag类型,默认 :new
|
|
29
29
|
# - tag_pre: tag前缀,默认 'v'
|
|
30
|
-
# - fixed_version:
|
|
30
|
+
# - fixed_version: 外部指定的固定版本号
|
|
31
31
|
# - process_type: 未提交文件的处理方式 ('skip', 'commit', 'reset', 'stash'),默认 'skip'
|
|
32
32
|
# - commit_message: 提交消息,默认 'build: 构建产生提交'
|
|
33
|
+
#
|
|
34
|
+
# 版本号计算逻辑:
|
|
35
|
+
# 1. 如果 fixed_version 为 nil 且 HEAD 存在 tag 且工作目录干净,
|
|
36
|
+
# 自动设置 fixed_version 为 HEAD tag 的版本(在 check_gitignore 之前)
|
|
37
|
+
# 2. 执行 check_gitignore(可能创建新提交)
|
|
38
|
+
# 3. 最终使用 fixed_version(如果有)或计算新版本号
|
|
33
39
|
def initialize(project_path, options = {})
|
|
34
40
|
@release_branch = options[:release_branch] || 'master'
|
|
35
41
|
@ver_inc = options[:ver_inc] || Pindo::VersionIncreaseType::MINI
|
|
@@ -70,10 +76,24 @@ module Pindo
|
|
|
70
76
|
root_dir = @git_root_path
|
|
71
77
|
git_repo_helper = Pindo::GitRepoHelper.share_instance
|
|
72
78
|
|
|
73
|
-
# 1.
|
|
79
|
+
# 1. 如果 fixed_version 为 nil,尝试从 HEAD 的 tag 获取版本
|
|
80
|
+
# 必须在 check_gitignore 之前检查,因为 check_gitignore 可能创建提交导致 HEAD 移动
|
|
81
|
+
if (@fixed_version.nil? || @fixed_version.empty?) &&
|
|
82
|
+
git_repo_helper.head_has_version_tag?(project_dir: root_dir, tag_prefix: @tag_pre) &&
|
|
83
|
+
!Pindo::GitHandler.has_uncommitted_changes?(git_root_dir: root_dir)
|
|
84
|
+
# HEAD 有 tag 且工作目录干净,使用 tag 的版本
|
|
85
|
+
latest_tag = Pindo::GitHandler.get_latest_version_tag(
|
|
86
|
+
project_dir: root_dir,
|
|
87
|
+
tag_prefix: @tag_pre
|
|
88
|
+
)
|
|
89
|
+
@fixed_version = latest_tag.sub(/^#{@tag_pre}/, '') if latest_tag
|
|
90
|
+
Funlog.instance.fancyinfo_success("HEAD 存在 tag 且工作目录干净,设置 fixed_version: #{@fixed_version}")
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# 2. 检查并修复 .gitignore(可能创建新提交,但 fixed_version 已经确定)
|
|
74
94
|
git_repo_helper.check_gitignore(root_dir)
|
|
75
95
|
|
|
76
|
-
#
|
|
96
|
+
# 3. 检查并处理未提交的文件(使用 GitHandler)
|
|
77
97
|
# process_type 已经在初始化时确定(由外部传入或默认为 skip)
|
|
78
98
|
begin
|
|
79
99
|
Pindo::GitHandler.process_need_add_files(
|
|
@@ -81,26 +101,29 @@ module Pindo
|
|
|
81
101
|
process_type: @process_type || 'skip',
|
|
82
102
|
commit_message: @commit_message
|
|
83
103
|
)
|
|
84
|
-
rescue Informative => e
|
|
104
|
+
rescue Pindo::Informative => e
|
|
85
105
|
# 用户选择手动处理时,不需要重试
|
|
86
106
|
if e.message.include?("请手动处理")
|
|
87
107
|
@retry_count = 0
|
|
88
108
|
end
|
|
89
|
-
|
|
109
|
+
# 重新抛出原始异常,保留错误信息
|
|
110
|
+
raise e
|
|
90
111
|
end
|
|
91
112
|
|
|
92
|
-
#
|
|
113
|
+
# 4. 获取当前分支
|
|
93
114
|
coding_branch = get_current_branch_name
|
|
94
115
|
|
|
95
|
-
#
|
|
116
|
+
# 5. 检查并推送本地提交到远程
|
|
96
117
|
Pindo::GitHandler.check_unpushed_commits(project_dir: root_dir, branch: coding_branch)
|
|
97
118
|
|
|
98
|
-
#
|
|
99
|
-
#
|
|
119
|
+
# 6. 计算 build_version
|
|
120
|
+
# 优先级 1: 如果指定了 fixed_version(外部传入或从 HEAD tag 获取),使用它
|
|
100
121
|
if @fixed_version && !@fixed_version.empty?
|
|
101
122
|
@build_version = @fixed_version
|
|
102
|
-
@build_number =
|
|
103
|
-
Funlog.instance.fancyinfo_success("
|
|
123
|
+
@build_number = git_repo_helper.get_build_number_from_commit(project_dir: root_dir)
|
|
124
|
+
Funlog.instance.fancyinfo_success("使用 fixed_version: #{@build_version}, Build: #{@build_number}")
|
|
125
|
+
|
|
126
|
+
# 优先级 2: 计算新版本号
|
|
104
127
|
else
|
|
105
128
|
@build_number = git_repo_helper.get_build_number_from_commit(project_dir: root_dir)
|
|
106
129
|
@build_version = git_repo_helper.calculate_build_version(
|
|
@@ -109,17 +132,31 @@ module Pindo
|
|
|
109
132
|
create_tag_type: @tag_type,
|
|
110
133
|
version_increase_type: @ver_inc
|
|
111
134
|
)
|
|
112
|
-
Funlog.instance.fancyinfo_success("
|
|
135
|
+
Funlog.instance.fancyinfo_success("计算新版本号: #{@build_version}, Build: #{@build_number}")
|
|
113
136
|
end
|
|
114
137
|
|
|
115
138
|
{
|
|
116
139
|
success: true,
|
|
117
140
|
root_dir: root_dir,
|
|
118
141
|
current_branch: coding_branch,
|
|
142
|
+
message: "Git 提交检查完成"
|
|
143
|
+
}
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# 构建任务参数(供其他任务使用)
|
|
147
|
+
def build_task_param
|
|
148
|
+
return {} unless @status == TaskStatus::SUCCESS
|
|
149
|
+
|
|
150
|
+
# 如果不是 Git 仓库,返回空参数(让依赖任务知道没有有效数据)
|
|
151
|
+
return {} if @build_version.nil? || @build_number.nil?
|
|
152
|
+
|
|
153
|
+
{
|
|
119
154
|
release_branch: @release_branch,
|
|
120
155
|
build_version: @build_version,
|
|
121
156
|
build_number: @build_number,
|
|
122
|
-
tag_pre: @tag_pre
|
|
157
|
+
tag_pre: @tag_pre,
|
|
158
|
+
tag_type: @tag_type,
|
|
159
|
+
ver_inc: @ver_inc
|
|
123
160
|
}
|
|
124
161
|
end
|
|
125
162
|
end
|
|
@@ -27,13 +27,12 @@ module Pindo
|
|
|
27
27
|
# - ver_inc: 版本号增加类型,默认 :mini
|
|
28
28
|
# - tag_type: 创建tag类型,默认 :new
|
|
29
29
|
# - tag_pre: tag前缀,默认 'v'
|
|
30
|
-
#
|
|
30
|
+
# 注意:版本号从 GitCommitTask 获取(GitTagTask 必须依赖 GitCommitTask)
|
|
31
31
|
def initialize(project_path, options = {})
|
|
32
32
|
@release_branch = options[:release_branch] || 'master'
|
|
33
33
|
@ver_inc = options[:ver_inc] || Pindo::VersionIncreaseType::MINI
|
|
34
34
|
@tag_type = options[:tag_type] || Pindo::CreateTagType::NEW
|
|
35
35
|
@tag_pre = options[:tag_pre] || 'v'
|
|
36
|
-
@fixed_version = options[:fixed_version] # 外部指定的固定版本号
|
|
37
36
|
|
|
38
37
|
@build_version = nil
|
|
39
38
|
@build_number = nil
|
|
@@ -83,11 +82,20 @@ module Pindo
|
|
|
83
82
|
)
|
|
84
83
|
end
|
|
85
84
|
|
|
86
|
-
# 3.
|
|
87
|
-
#
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
85
|
+
# 3. 获取版本信息
|
|
86
|
+
# 优先级 1: 从 GitCommitTask 获取所有版本相关参数(标准方式)
|
|
87
|
+
git_commit_data = get_data_param_by_key(:git_commit)
|
|
88
|
+
if git_commit_data && git_commit_data[:task_param] &&
|
|
89
|
+
git_commit_data[:task_param][:build_version] && git_commit_data[:task_param][:build_number]
|
|
90
|
+
@build_version = git_commit_data[:task_param][:build_version]
|
|
91
|
+
@build_number = git_commit_data[:task_param][:build_number]
|
|
92
|
+
@tag_pre = git_commit_data[:task_param][:tag_pre] if git_commit_data[:task_param][:tag_pre]
|
|
93
|
+
@release_branch = git_commit_data[:task_param][:release_branch] if git_commit_data[:task_param][:release_branch]
|
|
94
|
+
@tag_type = git_commit_data[:task_param][:tag_type] if git_commit_data[:task_param][:tag_type]
|
|
95
|
+
@ver_inc = git_commit_data[:task_param][:ver_inc] if git_commit_data[:task_param][:ver_inc]
|
|
96
|
+
Funlog.instance.fancyinfo_success("使用 GitCommitTask 的版本号: #{@build_version}, Build: #{@build_number}, Tag前缀: #{@tag_pre}, Tag类型: #{@tag_type}")
|
|
97
|
+
|
|
98
|
+
# 优先级 2: 自己计算(降级方案,用于向后兼容或 GitCommitTask 无有效数据)
|
|
91
99
|
else
|
|
92
100
|
@build_number = git_repo_helper.get_build_number_from_commit(project_dir: root_dir)
|
|
93
101
|
@build_version = git_repo_helper.calculate_build_version(
|
|
@@ -96,6 +104,7 @@ module Pindo
|
|
|
96
104
|
create_tag_type: @tag_type,
|
|
97
105
|
version_increase_type: @ver_inc
|
|
98
106
|
)
|
|
107
|
+
Funlog.instance.fancyinfo_warning("未找到 GitCommitTask 依赖,降级为自己计算版本号: #{@build_version}")
|
|
99
108
|
end
|
|
100
109
|
|
|
101
110
|
# 4. 创建并推送 Tag
|
|
@@ -86,7 +86,7 @@ module Pindo
|
|
|
86
86
|
rescue => e
|
|
87
87
|
# 外层错误保护:消息发送失败不应影响整体流程
|
|
88
88
|
puts " ⚠️ JPS 消息发送发生未预期错误: #{e.message}"
|
|
89
|
-
puts " ⚠️ 错误堆栈: #{e.backtrace.first(3).join("\n ")}" if e.backtrace
|
|
89
|
+
puts " ⚠️ 错误堆栈: #{e.backtrace.first(3).join("\n ")}" if ENV['PINDO_DEBUG'] && e.backtrace
|
|
90
90
|
puts " ℹ️ 消息发送失败不影响主流程\n"
|
|
91
91
|
|
|
92
92
|
# 消息发送失败不抛出异常,返回成功但带警告
|
|
@@ -105,7 +105,8 @@ module Pindo
|
|
|
105
105
|
# 从 dependencies 获取数据
|
|
106
106
|
upload_data = get_data_param_by_key(:jps_upload)
|
|
107
107
|
|
|
108
|
-
if upload_data && upload_data[:task_param]
|
|
108
|
+
if upload_data && upload_data[:task_param] &&
|
|
109
|
+
upload_data[:task_param][:app_version_info] && upload_data[:task_param][:app_info_obj]
|
|
109
110
|
param = upload_data[:task_param]
|
|
110
111
|
@app_version_info = param[:app_version_info] if @app_version_info.nil?
|
|
111
112
|
@app_info_obj = param[:app_info_obj] if @app_info_obj.nil?
|
|
@@ -325,15 +325,6 @@ module Pindo
|
|
|
325
325
|
|
|
326
326
|
FileUtils.mkdir_p(compress_dir) unless Dir.exist?(compress_dir)
|
|
327
327
|
|
|
328
|
-
puts ""
|
|
329
|
-
puts " 📁 待压缩文件(共 #{files.size} 个)"
|
|
330
|
-
files.each_with_index do |file, index|
|
|
331
|
-
size_str = format_file_size(File.size(file))
|
|
332
|
-
file_name = File.basename(file)
|
|
333
|
-
puts " #{index + 1}. #{file_name} (#{size_str})"
|
|
334
|
-
end
|
|
335
|
-
puts ""
|
|
336
|
-
|
|
337
328
|
# MacCompressCliTool 路径
|
|
338
329
|
pindo_dir = File.expand_path(Pindoconfig.instance.pindo_dir)
|
|
339
330
|
compress_tool = File.join(pindo_dir, "pindo_common_config", "MacCompressCliTool")
|
|
@@ -346,40 +337,169 @@ module Pindo
|
|
|
346
337
|
# 计算原始文件总大小
|
|
347
338
|
original_total_size = files.sum { |f| File.size(f) }
|
|
348
339
|
|
|
349
|
-
#
|
|
350
|
-
|
|
340
|
+
# 是否开启调试模式
|
|
341
|
+
debug_mode = ENV['PINDO_DEBUG'] == '1'
|
|
351
342
|
|
|
352
|
-
#
|
|
353
|
-
#
|
|
354
|
-
#
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
343
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
344
|
+
# 📦 压缩准备
|
|
345
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
346
|
+
puts ""
|
|
347
|
+
puts " \e[1m📦 媒体文件压缩\e[0m"
|
|
348
|
+
puts " " + "─" * 60
|
|
349
|
+
puts ""
|
|
358
350
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
351
|
+
# 文件列表(对齐显示)
|
|
352
|
+
puts " 📁 \e[36m待压缩文件 (#{files.size} 个)\e[0m"
|
|
353
|
+
puts ""
|
|
354
|
+
files.each_with_index do |file, index|
|
|
355
|
+
size_str = format_file_size(File.size(file))
|
|
356
|
+
file_name = File.basename(file)
|
|
357
|
+
# 对齐:序号(3位) + 文件名(左对齐) + 大小(右对齐)
|
|
358
|
+
puts " \e[90m#{(index + 1).to_s.rjust(2)}.\e[0m %-40s \e[33m%8s\e[0m" % [file_name, size_str]
|
|
359
|
+
if debug_mode
|
|
360
|
+
puts " \e[90m路径: #{file}\e[0m"
|
|
361
|
+
end
|
|
362
|
+
end
|
|
363
|
+
puts ""
|
|
364
|
+
puts " \e[90m原始总大小: \e[33m#{format_file_size(original_total_size)}\e[0m"
|
|
365
|
+
puts ""
|
|
362
366
|
|
|
363
|
-
if
|
|
364
|
-
|
|
365
|
-
puts "
|
|
366
|
-
|
|
367
|
+
if debug_mode
|
|
368
|
+
puts " 🔧 \e[90m压缩工具: #{compress_tool}\e[0m"
|
|
369
|
+
puts " 📂 \e[90m输出目录: #{compress_dir}\e[0m"
|
|
370
|
+
puts ""
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
374
|
+
# 🔄 执行压缩
|
|
375
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
376
|
+
puts " " + "─" * 60
|
|
377
|
+
puts " 🔄 \e[36m正在压缩...\e[0m"
|
|
378
|
+
puts ""
|
|
379
|
+
|
|
380
|
+
# 逐个压缩文件(使用文件列表方式)
|
|
381
|
+
require 'shellwords'
|
|
382
|
+
|
|
383
|
+
compressed_files = []
|
|
384
|
+
failed_files = []
|
|
385
|
+
|
|
386
|
+
files.each_with_index do |file, index|
|
|
387
|
+
file_name = File.basename(file)
|
|
388
|
+
|
|
389
|
+
# 显示进度(简洁模式)
|
|
390
|
+
progress = "#{index + 1}/#{files.size}"
|
|
391
|
+
print " [\e[33m#{progress.rjust(7)}\e[0m] #{file_name.ljust(40)} "
|
|
392
|
+
|
|
393
|
+
begin
|
|
394
|
+
# 创建临时文件列表(每个文件一个列表)
|
|
395
|
+
# MacCompressCliTool 的 -f 参数需要一个包含文件路径列表的文本文件
|
|
396
|
+
file_list_path = File.join(compress_dir, "file_list_#{index}.txt")
|
|
397
|
+
File.open(file_list_path, 'w:UTF-8') do |f|
|
|
398
|
+
f.puts(file)
|
|
399
|
+
end
|
|
400
|
+
|
|
401
|
+
# 调用压缩工具: compress-cli -s -f file_list.txt -o output_dir/
|
|
402
|
+
# -s: 静默模式
|
|
403
|
+
# -f: 文件列表文件路径
|
|
404
|
+
# -o: 输出目录
|
|
405
|
+
cmd = "#{Shellwords.escape(compress_tool)} -s -f #{Shellwords.escape(file_list_path)} -o #{Shellwords.escape(compress_dir)}"
|
|
406
|
+
|
|
407
|
+
if debug_mode
|
|
408
|
+
puts ""
|
|
409
|
+
puts " \e[90m完整路径: #{file}\e[0m"
|
|
410
|
+
puts " \e[90m文件列表: #{file_list_path}\e[0m"
|
|
411
|
+
puts " \e[90m执行命令: #{cmd}\e[0m"
|
|
412
|
+
print " "
|
|
413
|
+
end
|
|
414
|
+
|
|
415
|
+
output = `#{cmd} 2>&1`
|
|
416
|
+
exit_code = $?.exitstatus
|
|
417
|
+
|
|
418
|
+
# 清理临时文件列表
|
|
419
|
+
FileUtils.rm_f(file_list_path) if File.exist?(file_list_path)
|
|
420
|
+
|
|
421
|
+
if exit_code == 0
|
|
422
|
+
puts "\e[32m✓\e[0m"
|
|
423
|
+
else
|
|
424
|
+
puts "\e[31m✗\e[0m"
|
|
425
|
+
if debug_mode || output.strip.length < 100
|
|
426
|
+
puts " \e[31m失败原因: #{output.strip}\e[0m" unless output.strip.empty?
|
|
427
|
+
end
|
|
428
|
+
failed_files << file
|
|
429
|
+
end
|
|
430
|
+
rescue => e
|
|
431
|
+
puts "\e[31m✗\e[0m"
|
|
432
|
+
puts " \e[31m异常: #{e.message}\e[0m"
|
|
433
|
+
if debug_mode && e.backtrace
|
|
434
|
+
puts " \e[90m堆栈: #{e.backtrace.first(3).join("\n ")}\e[0m"
|
|
435
|
+
end
|
|
436
|
+
failed_files << file
|
|
437
|
+
end
|
|
367
438
|
end
|
|
368
439
|
|
|
369
440
|
# 从临时目录获取所有压缩后的媒体文件
|
|
370
441
|
compressed_files = get_media_files_from_dir(compress_dir)
|
|
371
442
|
|
|
443
|
+
puts ""
|
|
444
|
+
|
|
445
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
446
|
+
# ✅ 压缩结果
|
|
447
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
448
|
+
|
|
372
449
|
if compressed_files.empty?
|
|
373
|
-
|
|
450
|
+
puts " " + "─" * 60
|
|
451
|
+
puts " \e[31m✗ 压缩失败\e[0m"
|
|
452
|
+
puts ""
|
|
453
|
+
|
|
454
|
+
# 列出输出目录中的所有文件(调试用)
|
|
455
|
+
if debug_mode
|
|
456
|
+
puts " 🔍 输出目录内容:"
|
|
457
|
+
if Dir.exist?(compress_dir)
|
|
458
|
+
all_files = Dir.glob(File.join(compress_dir, "*"))
|
|
459
|
+
if all_files.empty?
|
|
460
|
+
puts " \e[90m(目录为空)\e[0m"
|
|
461
|
+
else
|
|
462
|
+
all_files.each { |f| puts " \e[90m- #{File.basename(f)}\e[0m" }
|
|
463
|
+
end
|
|
464
|
+
else
|
|
465
|
+
puts " \e[90m(目录不存在)\e[0m"
|
|
466
|
+
end
|
|
467
|
+
puts ""
|
|
468
|
+
end
|
|
469
|
+
|
|
374
470
|
raise "压缩失败:未在输出目录中找到压缩结果"
|
|
375
471
|
end
|
|
376
472
|
|
|
377
|
-
#
|
|
473
|
+
# 计算压缩后总大小和压缩率
|
|
378
474
|
compressed_total_size = compressed_files.sum { |f| File.size(f) }
|
|
379
475
|
total_ratio = ((1 - compressed_total_size.to_f / original_total_size) * 100).round(1)
|
|
476
|
+
success_count = files.size - failed_files.size
|
|
477
|
+
|
|
478
|
+
# 生成压缩率可视化进度条(20 个字符宽度)
|
|
479
|
+
bar_width = 20
|
|
480
|
+
filled_width = [(total_ratio / 5.0).round, bar_width].min # 每 5% 填充一格
|
|
481
|
+
bar_filled = "█" * filled_width
|
|
482
|
+
bar_empty = "░" * (bar_width - filled_width)
|
|
483
|
+
ratio_bar = "\e[32m#{bar_filled}\e[90m#{bar_empty}\e[0m"
|
|
380
484
|
|
|
381
|
-
|
|
382
|
-
|
|
485
|
+
puts " " + "─" * 60
|
|
486
|
+
puts " \e[32m✓ 压缩完成\e[0m"
|
|
487
|
+
puts ""
|
|
488
|
+
puts " 成功数量: \e[32m#{success_count}\e[0m / #{files.size}"
|
|
489
|
+
puts " 原始大小: \e[33m#{format_file_size(original_total_size)}\e[0m"
|
|
490
|
+
puts " 压缩后: \e[32m#{format_file_size(compressed_total_size)}\e[0m"
|
|
491
|
+
puts " 压缩率: #{ratio_bar} \e[1m#{total_ratio}%\e[0m"
|
|
492
|
+
|
|
493
|
+
if failed_files.any?
|
|
494
|
+
puts ""
|
|
495
|
+
puts " \e[31m失败文件 (#{failed_files.size}):\e[0m"
|
|
496
|
+
failed_files.each do |f|
|
|
497
|
+
puts " \e[31m✗\e[0m #{File.basename(f)}"
|
|
498
|
+
end
|
|
499
|
+
end
|
|
500
|
+
|
|
501
|
+
puts ""
|
|
502
|
+
puts " " + "─" * 60
|
|
383
503
|
puts ""
|
|
384
504
|
|
|
385
505
|
compressed_files
|
|
@@ -8,6 +8,10 @@ module Pindo
|
|
|
8
8
|
class UnityConfigTask < UnityTask
|
|
9
9
|
attr_reader :deploy_mode
|
|
10
10
|
|
|
11
|
+
def self.task_key
|
|
12
|
+
:unity_config
|
|
13
|
+
end
|
|
14
|
+
|
|
11
15
|
# @param deploy_mode [String] 部署模式 ('dev', 'adhoc', 'release')
|
|
12
16
|
# @param options [Hash] 额外选项
|
|
13
17
|
# - :project_path [String] Unity 项目路径(默认当前目录)
|
|
@@ -134,19 +134,27 @@ module Pindo
|
|
|
134
134
|
|
|
135
135
|
|
|
136
136
|
def modify_appprefix_plist(project_dir:nil, appprefix_file:nil, config_json:nil)
|
|
137
|
-
|
|
137
|
+
|
|
138
|
+
# 如果未指定 appprefix_file,输出警告并返回
|
|
139
|
+
if appprefix_file.nil? || appprefix_file.empty?
|
|
140
|
+
Funlog.instance.fancyinfo_warning("⚠️ 未指定 AppPrefix.plist 配置文件,跳过配置")
|
|
141
|
+
return
|
|
142
|
+
end
|
|
143
|
+
|
|
138
144
|
project_fullname = Dir.glob(File.join(project_dir, "/*.xcodeproj")).max_by {|f| File.mtime(f)}
|
|
139
|
-
project_obj = Xcodeproj::Project.open(project_fullname)
|
|
145
|
+
project_obj = Xcodeproj::Project.open(project_fullname)
|
|
140
146
|
presources_path = nil
|
|
141
147
|
|
|
148
|
+
# 1. 尝试在 Xcode 项目组中查找 PResources 或 PResource 组
|
|
142
149
|
presources_group = find_group(group:project_obj.main_group, group_name:"PResources")
|
|
143
|
-
if presources_group.nil?
|
|
150
|
+
if presources_group.nil?
|
|
144
151
|
presources_group = find_group(group:project_obj.main_group, group_name:"PResource")
|
|
145
152
|
end
|
|
146
|
-
if !presources_group.nil?
|
|
153
|
+
if !presources_group.nil?
|
|
147
154
|
presources_path = presources_group.real_path
|
|
148
|
-
end
|
|
155
|
+
end
|
|
149
156
|
|
|
157
|
+
# 2. 如果项目组中未找到,尝试在文件系统中查找 PResources 目录
|
|
150
158
|
if presources_path.nil?
|
|
151
159
|
presources_path_array = Dir.glob(File.join(project_dir, "**", "PResources"))
|
|
152
160
|
if presources_path_array.size > 1
|
|
@@ -156,6 +164,7 @@ module Pindo
|
|
|
156
164
|
end
|
|
157
165
|
end
|
|
158
166
|
|
|
167
|
+
# 3. 如果仍未找到,尝试在文件系统中查找 PResource 目录
|
|
159
168
|
if presources_path.nil?
|
|
160
169
|
presources_path_array = Dir.glob(File.join(project_dir, "**", "PResource"))
|
|
161
170
|
if presources_path_array.size > 1
|
|
@@ -165,22 +174,23 @@ module Pindo
|
|
|
165
174
|
end
|
|
166
175
|
end
|
|
167
176
|
|
|
168
|
-
|
|
177
|
+
# 4. 如果找不到资源目录,抛出异常
|
|
169
178
|
if presources_path.nil? || !File.exist?(presources_path)
|
|
170
|
-
raise Informative, "
|
|
179
|
+
raise Informative, "未找到资源目录 PResources/PResource!请在项目根目录创建 PResources/ 目录并添加配置文件。"
|
|
171
180
|
end
|
|
172
181
|
|
|
173
|
-
|
|
182
|
+
# 5. 在找到的资源目录中查找配置文件
|
|
174
183
|
config_file = Dir.glob(File.join(presources_path, "**", appprefix_file)).first
|
|
175
184
|
if config_file.nil? || config_file.empty? || !File.exist?(config_file)
|
|
176
|
-
raise Informative, "
|
|
177
|
-
end
|
|
178
|
-
|
|
185
|
+
raise Informative, "在资源目录 #{presources_path} 下未找到配置文件: #{appprefix_file}!请确保配置文件存在。"
|
|
186
|
+
end
|
|
179
187
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
188
|
+
# 6. 验证 config_json 中的 app_setting 配置(如果存在)
|
|
189
|
+
if config_json['app_setting']
|
|
190
|
+
config_json['app_setting'].each do |key, value|
|
|
191
|
+
if !value.nil? && value.to_s.include?("__________config")
|
|
192
|
+
raise Informative, "config.json 配置文件 key: #{key} 包含初始值未修改,请配置正确的值或删除该项!"
|
|
193
|
+
end
|
|
184
194
|
end
|
|
185
195
|
end
|
|
186
196
|
|
|
@@ -291,7 +301,7 @@ module Pindo
|
|
|
291
301
|
|
|
292
302
|
rescue StandardError => e
|
|
293
303
|
Funlog.instance.fancyinfo_error("创建 tag 失败: #{e.message}")
|
|
294
|
-
puts e.backtrace
|
|
304
|
+
puts e.backtrace.join("\n") if ENV['PINDO_DEBUG']
|
|
295
305
|
return false
|
|
296
306
|
end
|
|
297
307
|
end
|
|
@@ -481,7 +481,7 @@ module Pindo
|
|
|
481
481
|
|
|
482
482
|
rescue => e
|
|
483
483
|
Funlog.instance.fancyinfo_error("Icon 处理失败: #{e.message}")
|
|
484
|
-
puts e.backtrace
|
|
484
|
+
puts e.backtrace.join("\n") if ENV['PINDO_DEBUG']
|
|
485
485
|
replace_success = false
|
|
486
486
|
ensure
|
|
487
487
|
# 清理临时文件(无论成功失败都清理)
|
|
@@ -624,7 +624,7 @@ module Pindo
|
|
|
624
624
|
return true
|
|
625
625
|
rescue StandardError => e
|
|
626
626
|
Funlog.instance.fancyinfo_error("配置 Xcode 项目失败: #{e.message}")
|
|
627
|
-
puts e.backtrace
|
|
627
|
+
puts e.backtrace.join("\n") if ENV['PINDO_DEBUG']
|
|
628
628
|
raise Informative, "配置 Xcode 项目失败: #{e.message}"
|
|
629
629
|
end
|
|
630
630
|
|
|
@@ -57,7 +57,7 @@ module Pindo
|
|
|
57
57
|
|
|
58
58
|
rescue StandardError => e
|
|
59
59
|
Funlog.instance.fancyinfo_error("配置 Quark 环境失败: #{e.message}")
|
|
60
|
-
puts e.backtrace
|
|
60
|
+
puts e.backtrace.join("\n") if ENV['PINDO_DEBUG']
|
|
61
61
|
return false
|
|
62
62
|
end
|
|
63
63
|
end
|
|
@@ -115,7 +115,7 @@ module Pindo
|
|
|
115
115
|
|
|
116
116
|
rescue StandardError => e
|
|
117
117
|
Funlog.instance.fancyinfo_error("配置 Swark 环境失败: #{e.message}")
|
|
118
|
-
puts e.backtrace
|
|
118
|
+
puts e.backtrace.join("\n") if ENV['PINDO_DEBUG']
|
|
119
119
|
return false
|
|
120
120
|
end
|
|
121
121
|
end
|
|
@@ -207,7 +207,7 @@ module Pindo
|
|
|
207
207
|
|
|
208
208
|
rescue StandardError => e
|
|
209
209
|
Funlog.instance.fancyinfo_error("Swark 配置失败: #{e.message}")
|
|
210
|
-
puts e.backtrace
|
|
210
|
+
puts e.backtrace.join("\n") if ENV['PINDO_DEBUG']
|
|
211
211
|
return false
|
|
212
212
|
end
|
|
213
213
|
end
|
|
@@ -274,7 +274,7 @@ module Pindo
|
|
|
274
274
|
|
|
275
275
|
rescue StandardError => e
|
|
276
276
|
Funlog.instance.fancyinfo_error("Quark 配置失败: #{e.message}")
|
|
277
|
-
puts e.backtrace
|
|
277
|
+
puts e.backtrace.join("\n") if ENV['PINDO_DEBUG']
|
|
278
278
|
return false
|
|
279
279
|
end
|
|
280
280
|
end
|
|
@@ -340,7 +340,7 @@ module Pindo
|
|
|
340
340
|
|
|
341
341
|
rescue StandardError => e
|
|
342
342
|
Funlog.instance.fancyinfo_error("Swark 授权失败: #{e.message}")
|
|
343
|
-
puts e.backtrace
|
|
343
|
+
puts e.backtrace.join("\n") if ENV['PINDO_DEBUG']
|
|
344
344
|
return false
|
|
345
345
|
end
|
|
346
346
|
end
|
data/lib/pindo/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pindo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.14.
|
|
4
|
+
version: 5.14.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- wade
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 2025-12-29 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: claide
|
|
@@ -299,6 +299,7 @@ files:
|
|
|
299
299
|
- lib/pindo/base/funlog.rb
|
|
300
300
|
- lib/pindo/base/git_handler.rb
|
|
301
301
|
- lib/pindo/base/hashhelper.rb
|
|
302
|
+
- lib/pindo/base/informative.rb
|
|
302
303
|
- lib/pindo/base/output_sink.rb
|
|
303
304
|
- lib/pindo/base/plaininformative.rb
|
|
304
305
|
- lib/pindo/base/plistbuddyexecutable.rb
|
|
@@ -531,7 +532,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
531
532
|
- !ruby/object:Gem::Version
|
|
532
533
|
version: '0'
|
|
533
534
|
requirements: []
|
|
534
|
-
rubygems_version: 3.6.
|
|
535
|
+
rubygems_version: 3.6.3
|
|
535
536
|
specification_version: 3
|
|
536
537
|
summary: easy work
|
|
537
538
|
test_files: []
|