pindo 4.8.8 → 4.9.0
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/githelper.rb +21 -0
- data/lib/pindo/client/unityhelper.rb +179 -0
- data/lib/pindo/command/deploy/build.rb +2 -3
- data/lib/pindo/command/ios/debug.rb +10 -4
- data/lib/pindo/command/unity/apk.rb +2 -0
- data/lib/pindo/command/unity/ipa.rb +92 -2
- data/lib/pindo/module/pgyer/pgyerhelper.rb +22 -6
- data/lib/pindo/version.rb +1 -1
- data/lib/pindo.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11b00add7874d6645d53ba3962c504569851df828c965cd31d6fa90ea495c1bd
|
4
|
+
data.tar.gz: 8222a4ed3d3e036fdcaaf3dd8b3f1af1c683881693c2054358d0edc7b5f64362
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 869249634c7c48cf039749c1a36ff5ce2d9bd85c18d90165c168e755ab17001b695a334f909d6d85e67a688c813d6de05f968899f23c8051ac0b3ea04f4cfe24
|
7
|
+
data.tar.gz: c857e9ec891f54021610211ddfacd7009c2045baa5b91da03789a31452282c241e05f4e430915e5aa6d99fb8bb1a475188ec2825ec2bf2b45fcdef1268b41e75
|
data/lib/pindo/base/githelper.rb
CHANGED
@@ -19,6 +19,27 @@ module Pindo
|
|
19
19
|
|
20
20
|
end
|
21
21
|
|
22
|
+
def is_git_directory?(local_repo_dir: nil)
|
23
|
+
args = local_repo_dir ? %W(-C #{local_repo_dir} rev-parse --is-inside-work-tree) : %w(rev-parse --is-inside-work-tree)
|
24
|
+
begin
|
25
|
+
git!(args)
|
26
|
+
true
|
27
|
+
rescue StandardError => e
|
28
|
+
false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def git_root_directory(local_repo_dir: nil)
|
33
|
+
return nil unless is_git_directory?(local_repo_dir: local_repo_dir)
|
34
|
+
|
35
|
+
args = local_repo_dir ? %W(-C #{local_repo_dir} rev-parse --show-toplevel) : %w(rev-parse --show-toplevel)
|
36
|
+
begin
|
37
|
+
git!(args).strip
|
38
|
+
rescue StandardError => e
|
39
|
+
nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
22
43
|
def add_branch(local_repo_dir: nil, branch: nil)
|
23
44
|
|
24
45
|
current=Dir.pwd
|
@@ -0,0 +1,179 @@
|
|
1
|
+
require 'open3'
|
2
|
+
require 'json'
|
3
|
+
require 'singleton'
|
4
|
+
|
5
|
+
module Pindo
|
6
|
+
module Client
|
7
|
+
class UnityHelper
|
8
|
+
include Singleton
|
9
|
+
|
10
|
+
UNITY_MAC_PATHS = [
|
11
|
+
"/Applications/Unity/Unity.app/Contents/MacOS/Unity",
|
12
|
+
"/Applications/Unity/Hub/Editor/*/Unity.app/Contents/MacOS/Unity"
|
13
|
+
]
|
14
|
+
|
15
|
+
UNITY_WINDOWS_PATHS = [
|
16
|
+
"C:/Program Files/Unity/Editor/Unity.exe",
|
17
|
+
"C:/Program Files/Unity/Hub/Editor/*/Unity.exe"
|
18
|
+
]
|
19
|
+
|
20
|
+
TARGET_UNITY_VERSION = "2021.3"
|
21
|
+
|
22
|
+
class << self
|
23
|
+
def share_instance
|
24
|
+
instance
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def find_unity_path
|
29
|
+
paths = case RUBY_PLATFORM
|
30
|
+
when /darwin/
|
31
|
+
UNITY_MAC_PATHS
|
32
|
+
when /mswin|mingw|windows/
|
33
|
+
UNITY_WINDOWS_PATHS
|
34
|
+
else
|
35
|
+
raise "Unsupported platform: #{RUBY_PLATFORM}"
|
36
|
+
end
|
37
|
+
|
38
|
+
unity_versions = []
|
39
|
+
|
40
|
+
paths.each do |path|
|
41
|
+
if path.include?("*")
|
42
|
+
Dir.glob(path).each do |expanded_path|
|
43
|
+
# 从路径中提取版本号
|
44
|
+
version = extract_version_from_path(expanded_path)
|
45
|
+
if version && version.start_with?(TARGET_UNITY_VERSION)
|
46
|
+
unity_versions << {
|
47
|
+
path: expanded_path,
|
48
|
+
version: version
|
49
|
+
}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
elsif File.exist?(path)
|
53
|
+
version = extract_version_from_path(path)
|
54
|
+
if version && version.start_with?(TARGET_UNITY_VERSION)
|
55
|
+
unity_versions << {
|
56
|
+
path: path,
|
57
|
+
version: version
|
58
|
+
}
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
if unity_versions.empty?
|
64
|
+
raise "No Unity #{TARGET_UNITY_VERSION} found in standard locations"
|
65
|
+
end
|
66
|
+
|
67
|
+
# 按版本号排序,取最新的2021.3.x版本
|
68
|
+
selected_unity = unity_versions.sort_by { |v| Gem::Version.new(v[:version]) }.last
|
69
|
+
puts "Selected Unity version: #{selected_unity[:version]}"
|
70
|
+
selected_unity[:path]
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def extract_version_from_path(path)
|
76
|
+
# macOS路径格式: /Applications/Unity/Hub/Editor/2021.3.45f1/Unity.app/Contents/MacOS/Unity
|
77
|
+
# Windows路径格式: C:/Program Files/Unity/Hub/Editor/2021.3.45f1/Editor/Unity.exe
|
78
|
+
if match = path.match(/Editor\/([\d.]+[a-zA-Z]\d+)\//)
|
79
|
+
match[1]
|
80
|
+
else
|
81
|
+
nil
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
public
|
86
|
+
|
87
|
+
def execute_unity_command(project_path, method_name, additional_args = {})
|
88
|
+
unity_path = find_unity_path
|
89
|
+
|
90
|
+
cmd_args = [
|
91
|
+
unity_path,
|
92
|
+
"-batchmode",
|
93
|
+
"-quit",
|
94
|
+
"-projectPath",
|
95
|
+
project_path.to_s,
|
96
|
+
"-executeMethod",
|
97
|
+
method_name
|
98
|
+
]
|
99
|
+
|
100
|
+
# Add any additional arguments
|
101
|
+
additional_args.each do |key, value|
|
102
|
+
cmd_args << "-#{key}"
|
103
|
+
cmd_args << value.to_s if value
|
104
|
+
end
|
105
|
+
|
106
|
+
puts "Executing Unity command: #{cmd_args.join(' ')}"
|
107
|
+
stdout, stderr, status = Open3.capture3(*cmd_args)
|
108
|
+
|
109
|
+
{
|
110
|
+
success: status.success?,
|
111
|
+
stdout: stdout,
|
112
|
+
stderr: stderr,
|
113
|
+
exit_status: status.exitstatus,
|
114
|
+
unity_version: extract_version_from_path(unity_path)
|
115
|
+
}
|
116
|
+
end
|
117
|
+
|
118
|
+
def build_project(project_path, build_method, platform: nil, output_path: nil)
|
119
|
+
additional_args = {}
|
120
|
+
additional_args[:buildTarget] = platform if platform
|
121
|
+
additional_args[:outputPath] = output_path if output_path
|
122
|
+
|
123
|
+
result = execute_unity_command(project_path, build_method, additional_args)
|
124
|
+
|
125
|
+
if result[:success]
|
126
|
+
puts "Unity build completed successfully"
|
127
|
+
puts "Using Unity version: #{result[:unity_version]}"
|
128
|
+
puts result[:stdout]
|
129
|
+
else
|
130
|
+
puts "Unity build failed"
|
131
|
+
puts "Unity version: #{result[:unity_version]}"
|
132
|
+
puts result[:stderr]
|
133
|
+
raise "Unity build failed with status: #{result[:exit_status]}"
|
134
|
+
end
|
135
|
+
|
136
|
+
result
|
137
|
+
end
|
138
|
+
|
139
|
+
def get_project_settings(project_path)
|
140
|
+
settings_path = File.join(project_path, "ProjectSettings", "ProjectSettings.asset")
|
141
|
+
if File.exist?(settings_path)
|
142
|
+
File.read(settings_path)
|
143
|
+
else
|
144
|
+
raise "Project settings file not found at #{settings_path}"
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
def get_unity_version(project_path)
|
149
|
+
version_path = File.join(project_path, "ProjectSettings", "ProjectVersion.txt")
|
150
|
+
if File.exist?(version_path)
|
151
|
+
content = File.read(version_path)
|
152
|
+
if content =~ /m_EditorVersion: (.*)/
|
153
|
+
version = $1.strip
|
154
|
+
unless version.start_with?(TARGET_UNITY_VERSION)
|
155
|
+
raise "Project Unity version (#{version}) does not match required version (#{TARGET_UNITY_VERSION}.x)"
|
156
|
+
end
|
157
|
+
version
|
158
|
+
else
|
159
|
+
raise "Could not parse Unity version from #{version_path}"
|
160
|
+
end
|
161
|
+
else
|
162
|
+
raise "Project version file not found at #{version_path}"
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
def verify_unity_version(project_path)
|
167
|
+
project_version = get_unity_version(project_path)
|
168
|
+
unity_path = find_unity_path
|
169
|
+
editor_version = extract_version_from_path(unity_path)
|
170
|
+
|
171
|
+
if project_version != editor_version
|
172
|
+
raise "Project Unity version (#{project_version}) does not match Editor version (#{editor_version})"
|
173
|
+
end
|
174
|
+
|
175
|
+
true
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
@@ -77,13 +77,12 @@ module Pindo
|
|
77
77
|
config = FastlaneCore::Configuration.create(Gym::Options.available_options, gym_options)
|
78
78
|
Gym::Manager.new.work(config)
|
79
79
|
|
80
|
-
|
81
|
-
|
82
80
|
pindo_new_project_dir = Dir.pwd
|
83
81
|
build_path = File.join(pindo_new_project_dir, "build", "*.ipa")
|
84
82
|
ipa_file_upload = Dir.glob(build_path).max_by {|f| File.mtime(f)}
|
85
|
-
|
83
|
+
|
86
84
|
if !ipa_file_upload.nil? && !app_info_obj.nil?
|
85
|
+
|
87
86
|
description = nil
|
88
87
|
result_data = PgyerHelper.share_instace.start_upload(app_info_obj:app_info_obj, ipa_file_upload:ipa_file_upload, description:description)
|
89
88
|
if !result_data.nil? && !result_data["data"].nil? && !result_data["data"]["id"].nil?
|
@@ -44,6 +44,7 @@ module Pindo
|
|
44
44
|
# 命令的选项列表
|
45
45
|
def self.options
|
46
46
|
[
|
47
|
+
['--bundleid', '指定打包的bundleID'],
|
47
48
|
# 指定上传到蒲公英的项目
|
48
49
|
['--proj', '指定上传到测试平台的项目名称'],
|
49
50
|
# 上传编译包
|
@@ -59,7 +60,8 @@ module Pindo
|
|
59
60
|
@args_adhoc_flag = argv.flag?('adhoc', false)
|
60
61
|
@args_upload_flag = argv.flag?('upload', false)
|
61
62
|
@args_send_flag = argv.flag?('send', false)
|
62
|
-
@args_proj_name = argv.option('proj')
|
63
|
+
@args_proj_name = argv.option('proj')
|
64
|
+
@args_bundle_id = argv.option('bundleid')
|
63
65
|
|
64
66
|
if @args_send_flag
|
65
67
|
@args_upload_flag = true
|
@@ -77,10 +79,14 @@ module Pindo
|
|
77
79
|
def run
|
78
80
|
|
79
81
|
mainapp_bundleid= nil
|
80
|
-
if @
|
81
|
-
mainapp_bundleid =
|
82
|
+
if @args_bundle_id
|
83
|
+
mainapp_bundleid = @args_bundle_id
|
82
84
|
else
|
83
|
-
|
85
|
+
if @args_deploy_flag
|
86
|
+
mainapp_bundleid = get_selected_deploy_bundleid()
|
87
|
+
else
|
88
|
+
mainapp_bundleid = get_selected_dev_bundleid()
|
89
|
+
end
|
84
90
|
end
|
85
91
|
|
86
92
|
app_info_obj = nil
|
@@ -3,11 +3,15 @@ require 'xcodeproj'
|
|
3
3
|
require 'find'
|
4
4
|
require 'fileutils'
|
5
5
|
require 'pindo/base/executable'
|
6
|
+
require 'pindo/client/unityhelper'
|
6
7
|
|
7
8
|
module Pindo
|
8
9
|
class Command
|
9
10
|
class Unity < Command
|
10
11
|
class Ipa < Unity
|
12
|
+
|
13
|
+
include Appselect
|
14
|
+
|
11
15
|
# Unity IPA包编译和上传命令
|
12
16
|
self.summary = '编译Unity工程生成iOS IPA并支持上传到测试平台'
|
13
17
|
|
@@ -44,7 +48,8 @@ module Pindo
|
|
44
48
|
[
|
45
49
|
['--proj', '指定上传到测试平台的项目名称'],
|
46
50
|
['--upload', '上传编译后的IPA到测试平台'],
|
47
|
-
['--send', '上传成功后发送测试通知']
|
51
|
+
['--send', '上传成功后发送测试通知'],
|
52
|
+
['--base', 'Unity工程编译lib模式']
|
48
53
|
].concat(super)
|
49
54
|
end
|
50
55
|
|
@@ -54,6 +59,8 @@ module Pindo
|
|
54
59
|
@args_proj_name = argv.option('proj')
|
55
60
|
@args_upload_flag = argv.flag?('upload', false)
|
56
61
|
@args_send_flag = argv.flag?('send', false)
|
62
|
+
@args_deploy_flag = argv.flag?('deploy', false)
|
63
|
+
@args_base_flag = argv.flag?('base', false)
|
57
64
|
|
58
65
|
if @args_send_flag
|
59
66
|
@args_upload_flag = true
|
@@ -62,10 +69,93 @@ module Pindo
|
|
62
69
|
super
|
63
70
|
end
|
64
71
|
|
72
|
+
def export_ios_project(project_path, pindo_ios_project_dir, additional_args)
|
73
|
+
begin
|
74
|
+
# 获取 UnityHelper 实例
|
75
|
+
unity_helper = Pindo::Client::UnityHelper.share_instance
|
76
|
+
|
77
|
+
# 执行Unity命令
|
78
|
+
result = unity_helper.execute_unity_command(
|
79
|
+
project_path,
|
80
|
+
'GoodUnityBuild.BuildManager.BatchBuild',
|
81
|
+
additional_args
|
82
|
+
)
|
83
|
+
|
84
|
+
if result[:success]
|
85
|
+
puts "Unity iOS library build completed successfully"
|
86
|
+
puts "Unity version: #{result[:unity_version]}"
|
87
|
+
puts "Output: #{pindo_ios_project_dir}"
|
88
|
+
puts result[:stdout]
|
89
|
+
return true
|
90
|
+
else
|
91
|
+
puts "Unity iOS library build failed"
|
92
|
+
puts "Unity version: #{result[:unity_version]}"
|
93
|
+
puts "Error:"
|
94
|
+
puts result[:stderr]
|
95
|
+
raise "Build failed with status: #{result[:exit_status]}"
|
96
|
+
end
|
97
|
+
|
98
|
+
rescue => e
|
99
|
+
puts "Error during Unity build: #{e.message}"
|
100
|
+
puts e.backtrace
|
101
|
+
return false
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
65
105
|
|
66
106
|
def run
|
107
|
+
|
108
|
+
app_info_obj = nil
|
109
|
+
if @args_upload_flag
|
110
|
+
proj_name = @args_proj_name
|
111
|
+
app_info_obj = PgyerHelper.share_instace.prepare_upload(working_directory:Dir.pwd, proj_name:proj_name)
|
112
|
+
end
|
113
|
+
puts app_info_obj
|
114
|
+
|
115
|
+
mainapp_bundleid= nil
|
116
|
+
if @args_deploy_flag
|
117
|
+
mainapp_bundleid = get_selected_deploy_bundleid()
|
118
|
+
else
|
119
|
+
mainapp_bundleid = get_selected_dev_bundleid()
|
120
|
+
end
|
121
|
+
|
122
|
+
pindo_unity_project_dir = Dir.pwd
|
123
|
+
pindo_ios_project_dir = File.join(pindo_unity_project_dir, "Platform/iOS")
|
124
|
+
# 准备额外的参数
|
125
|
+
additional_args = {
|
126
|
+
'platform' => 'iOS'
|
127
|
+
}
|
128
|
+
if @args_base_flag
|
129
|
+
pindo_ios_project_dir = File.join(pindo_unity_project_dir, "Platform/BaseiOS")
|
130
|
+
additional_args = {
|
131
|
+
'platform' => 'iOS',
|
132
|
+
'buildtype' => 'library'
|
133
|
+
}
|
134
|
+
end
|
135
|
+
|
136
|
+
export_ios_project(pindo_unity_project_dir, pindo_ios_project_dir, additional_args)
|
137
|
+
|
138
|
+
args_temp = []
|
139
|
+
args_temp << "--bundleid=#{mainapp_bundleid}"
|
140
|
+
|
141
|
+
if @args_upload_flag
|
142
|
+
args_temp << "--proj=#{app_info_obj["appName"]}"
|
143
|
+
args_temp << "--upload"
|
144
|
+
end
|
145
|
+
if @args_send_flag
|
146
|
+
args_temp << "--send"
|
147
|
+
end
|
148
|
+
|
149
|
+
Dir.chdir(pindo_ios_project_dir)
|
150
|
+
if @args_base_flag
|
151
|
+
`chmod 777 #{pindo_ios_project_dir}`
|
152
|
+
else
|
153
|
+
`chmod 777 #{pindo_ios_project_dir}/Unity`
|
154
|
+
end
|
155
|
+
|
156
|
+
|
157
|
+
Pindo::Command::Ios::Debug::run(args_temp)
|
67
158
|
|
68
|
-
puts "ipa "
|
69
159
|
|
70
160
|
end
|
71
161
|
|
@@ -172,8 +172,9 @@ module Pindo
|
|
172
172
|
args_ipa_file_dir = File.expand_path(File::dirname(ipa_file_upload))
|
173
173
|
ipa_file_upload=File.join(args_ipa_file_dir, File.basename(ipa_file_upload))
|
174
174
|
current_project_dir = Dir.pwd
|
175
|
-
|
176
|
-
|
175
|
+
|
176
|
+
if description.nil? && is_git_directory?(local_repo_dir: current_project_dir)
|
177
|
+
current_git_root_path = git_root_directory(local_repo_dir: current_project_dir)
|
177
178
|
xcodeproj_file_name = Dir.glob(File.join(current_project_dir, "/*.xcodeproj")).max_by {|f| File.mtime(f)}
|
178
179
|
if !xcodeproj_file_name.nil? && !xcodeproj_file_name.empty? && File.exist?(xcodeproj_file_name)
|
179
180
|
project_obj = Xcodeproj::Project.open(xcodeproj_file_name)
|
@@ -182,11 +183,26 @@ module Pindo
|
|
182
183
|
if provisioning_profile_name.include?("adhoc")
|
183
184
|
description = git!(%W(-C #{current_project_dir} show -s --format=commit::%H)).strip
|
184
185
|
elsif provisioning_profile_name.include?("development")
|
185
|
-
|
186
|
-
|
186
|
+
cliff_toml_path = File.join(current_git_root_path, "cliff.toml")
|
187
|
+
if File.exist?(cliff_toml_path)
|
188
|
+
begin
|
189
|
+
`git-cliff --version`
|
190
|
+
git_cliff_installed = $?.success?
|
191
|
+
if git_cliff_installed
|
192
|
+
temp_dir = Dir.pwd
|
193
|
+
Dir.chdir(current_git_root_path)
|
194
|
+
description = `git-cliff -c #{cliff_toml_path} --latest -o -`.strip
|
195
|
+
description = " " if description.empty?
|
196
|
+
Dir.chdir(temp_dir)
|
197
|
+
else
|
198
|
+
description = " "
|
199
|
+
end
|
200
|
+
rescue StandardError => e
|
201
|
+
description = " "
|
202
|
+
end
|
187
203
|
else
|
188
|
-
description =
|
189
|
-
end
|
204
|
+
description = " "
|
205
|
+
end
|
190
206
|
elsif provisioning_profile_name.include?("appstore")
|
191
207
|
description = "提交包重签名"
|
192
208
|
end
|
data/lib/pindo/version.rb
CHANGED
data/lib/pindo.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: 4.
|
4
|
+
version: 4.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- wade
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-02-
|
10
|
+
date: 2025-02-19 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: claide
|
@@ -240,6 +240,7 @@ files:
|
|
240
240
|
- lib/pindo/client/pgyerclient.rb
|
241
241
|
- lib/pindo/client/pgyeruploadclient.rb
|
242
242
|
- lib/pindo/client/tgateclient.rb
|
243
|
+
- lib/pindo/client/unityhelper.rb
|
243
244
|
- lib/pindo/command.rb
|
244
245
|
- lib/pindo/command/android.rb
|
245
246
|
- lib/pindo/command/android/debug.rb
|