easyci 0.5.0 → 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 927c11e2ae3813933d519a94a1aa87829c8533531ea18e1b5f19918940d270d0
4
- data.tar.gz: 7812db007b9d28d84b2cfdadadb5dcfa89e7187afda561ac2670f001e69c839e
3
+ metadata.gz: 93e85d54f39687dd87189fe75a8f2500e6ac30e6195b1579d0a9f26145a0d53e
4
+ data.tar.gz: 844a0177557c48cbb462e7cb369e8c69c48e0b9d23b534593f5a388f1ddaee43
5
5
  SHA512:
6
- metadata.gz: c07ea450495999224cdf041ec0b7b043744fcf97255939f130a8ff81b093a07f6b821cbd500a81dc3b31646c4ffc19d14d3efdc8631fa07a163d1862d385f468
7
- data.tar.gz: b4bebdd9becd4cef79a218ae782a92613ec60fa39b179b355ec0c4ce04a392b98cab01795a597d98046bb07bf32cd128a74b7b417c608b11db1f699402e7e69c
6
+ metadata.gz: 23b253fac7ea57d0f50fdfca93b4108dc264a036307e42e2f124ff7467c4655856a8426fc289b4d76d8e437831595417c4220385f5b141a3aaca98ea0af37857
7
+ data.tar.gz: 6acd0d3b11ed1c80b6cfddd59074df5b664c61edc56da7f2b1ee6f230edc18beceaf84655bd8b3c19565ca64115e8819fbea3c5d0992636656d46df4e6794694
@@ -78,14 +78,14 @@ module EasyCI
78
78
  unity_path = find_unity_path(runner_dir)
79
79
  puts "运行Unity截图任务..."
80
80
  FileUtils.chdir(runner_dir)
81
- system("#{unity_path} -projectPath . -executeMethod SpineAutoImporter.CIRunner -logFile screenshot-log.txt")
81
+ system("#{unity_path} -projectPath #{runner_dir} -executeMethod SpineAutoImporter.CIRunner -logFile screenshot-log.txt")
82
82
 
83
83
  # 压缩截图
84
84
  puts "开始压缩截图..."
85
- system("find . -path \"*/Screenshots/*.png\" -exec pngquant --quality=70-95 --ext .png --force {} \\;")
85
+ system("cd #{runner_dir} && find . -path \"*/Screenshots/*.png\" -exec pngquant --quality=70-95 --ext .png --force {} \\;")
86
86
  # 运行Node脚本(如果需要)
87
87
  puts "运行后处理脚本..."
88
- system("docker run --rm -v \"$(pwd):/app\" -w /app node:22.0.0 bash -c \"cd Scripts && yarn install && npx ts-node index.ts\"")
88
+ system("cd #{runner_dir} && docker run --rm -v \"$(pwd):/app\" -w /app node:22.0.0 bash -c \"cd Scripts && yarn install && npx ts-node index.ts\"")
89
89
 
90
90
  end
91
91
 
@@ -1,12 +1,49 @@
1
1
  module EasyCI
2
2
  # UnityExeHelper模块,用于查找和验证Unity可执行文件路径
3
3
  module UnityExeHelper
4
+ # Unity可执行文件的可能路径 (使用通配符)
5
+ UNITY_MAC_PATHS = [
6
+ "/Applications/Unity/Unity.app/Contents/MacOS/Unity",
7
+ "/Applications/Unity/Hub/Editor/*/Unity.app/Contents/MacOS/Unity"
8
+ ]
9
+
10
+ UNITY_WINDOWS_PATHS = [
11
+ "C:/Program Files/Unity/Editor/Unity.exe",
12
+ "C:/Program Files/Unity/Hub/Editor/*/Editor/Unity.exe"
13
+ ]
14
+
15
+ UNITY_LINUX_PATHS = [
16
+ "/opt/Unity/Editor/Unity",
17
+ "/opt/unity/hub/editor/*/Editor/Unity"
18
+ ]
19
+
20
+ # 从路径中提取Unity版本号
21
+ # @param path [String] Unity可执行文件路径
22
+ # @return [String, nil] 提取的版本号,如果无法提取则返回nil
23
+ def self.extract_version_from_path(path)
24
+ # macOS路径格式: /Applications/Unity/Hub/Editor/2021.3.45f1/Unity.app/Contents/MacOS/Unity
25
+ # macOS路径格式(变体): /Applications/Unity/Hub/Editor/2021.3.45f1c1/Unity.app/Contents/MacOS/Unity
26
+ # Windows路径格式: C:/Program Files/Unity/Hub/Editor/2021.3.45f1/Editor/Unity.exe
27
+ # Windows路径格式(变体): C:/Program Files/Unity/Hub/Editor/2021.3.45f1c1/Editor/Unity.exe
28
+
29
+ # 尝试匹配 macOS 路径格式
30
+ if match = path.match(/Editor\/([\d.]+[a-zA-Z]\d+(?:c\d+)?)\//)
31
+ return match[1]
32
+ end
33
+
34
+ # 尝试匹配 Windows 路径格式
35
+ if match = path.match(/([\d.]+[a-zA-Z]\d+(?:c\d+)?)\/Editor\//)
36
+ return match[1]
37
+ end
38
+
39
+ nil
40
+ end
41
+
4
42
  # 查找Unity可执行文件路径
5
43
  # @param project_path [String] Unity项目路径
6
44
  # @param verbose [Boolean] 是否显示详细信息
7
45
  # @return [String] Unity可执行文件路径
8
46
  def self.find_unity_executable(project_path = nil, verbose = false)
9
- unity_path = nil
10
47
  project_version = nil
11
48
 
12
49
  # 如果提供了项目路径,尝试从ProjectVersion.txt中读取版本
@@ -21,117 +58,131 @@ module EasyCI
21
58
  end
22
59
  end
23
60
 
24
- # 如果找到项目版本,尝试定位对应的Unity
61
+ if project_version.nil?
62
+ puts "未找到项目Unity版本信息" if verbose
63
+ end
64
+
65
+ # 如果找到了项目版本,提取主要版本号(例如:2021.3)
66
+ unity_major_version = nil
25
67
  if project_version
26
- # 检查macOS路径
27
- if RUBY_PLATFORM =~ /darwin/
28
- mac_path = "/Applications/Unity/Hub/Editor/#{project_version}/Unity.app/Contents/MacOS/Unity"
29
- if File.exist?(mac_path)
30
- unity_path = mac_path
31
- puts "找到匹配版本的Unity: #{unity_path}" if verbose
32
- end
33
- # 检查Windows路径
34
- elsif RUBY_PLATFORM =~ /mswin|mingw|cygwin/
35
- win_path = "C:/Program Files/Unity/Hub/Editor/#{project_version}/Editor/Unity.exe"
36
- if File.exist?(win_path)
37
- unity_path = win_path
38
- puts "找到匹配版本的Unity: #{unity_path}" if verbose
68
+ unity_major_version = project_version.split('.')[0..1].join('.')
69
+ puts "项目Unity主要版本: #{unity_major_version}" if verbose
70
+ end
71
+
72
+ # 获取所有可能的Unity版本及路径
73
+ unity_versions = []
74
+
75
+ # 获取当前平台的Unity路径集合
76
+ paths = case RUBY_PLATFORM
77
+ when /darwin/
78
+ UNITY_MAC_PATHS
79
+ when /mswin|mingw|cygwin/
80
+ UNITY_WINDOWS_PATHS
81
+ when /linux/
82
+ UNITY_LINUX_PATHS
83
+ else
84
+ []
85
+ end
86
+
87
+ # 查找所有可用的Unity版本
88
+ paths.each do |path|
89
+ if path.include?("*")
90
+ Dir.glob(path).each do |expanded_path|
91
+ version = extract_version_from_path(expanded_path)
92
+ if version
93
+ major_version = version.split('.')[0..1].join('.')
94
+ unity_versions << {
95
+ path: expanded_path,
96
+ version: version,
97
+ major_version: major_version
98
+ }
99
+ puts "找到Unity版本: #{version} 路径: #{expanded_path}" if verbose
100
+ end
39
101
  end
40
- # 检查Linux路径
41
- elsif RUBY_PLATFORM =~ /linux/
42
- linux_path = "/opt/unity/hub/editor/#{project_version}/Editor/Unity"
43
- if File.exist?(linux_path)
44
- unity_path = linux_path
45
- puts "找到匹配版本的Unity: #{unity_path}" if verbose
102
+ elsif File.exist?(path)
103
+ version = extract_version_from_path(path)
104
+ if version
105
+ major_version = version.split('.')[0..1].join('.')
106
+ unity_versions << {
107
+ path: path,
108
+ version: version,
109
+ major_version: major_version
110
+ }
111
+ puts "找到Unity版本: #{version} 路径: #{path}" if verbose
46
112
  end
47
113
  end
48
114
  end
49
115
 
50
- # 如果没有找到匹配版本,尝试查找最新版本
51
- if unity_path.nil?
52
- puts "没有找到匹配的Unity版本,尝试查找最新版本" if verbose
53
- unity_path = find_latest_unity(verbose)
116
+ if unity_versions.empty?
117
+ puts "未找到任何Unity版本" if verbose
118
+ raise "未找到任何Unity版本,请确保Unity已正确安装"
54
119
  end
55
120
 
56
- # 如果仍然找不到,抛出错误
57
- raise "无法找到Unity可执行文件,请确保Unity已正确安装" if unity_path.nil?
58
-
59
- unity_path
60
- end
61
-
62
- # 查找最新版本的Unity
63
- # @param verbose [Boolean] 是否显示详细信息
64
- # @return [String] Unity可执行文件路径
65
- def self.find_latest_unity(verbose = false)
66
- # 检查macOS路径
67
- if RUBY_PLATFORM =~ /darwin/
68
- hub_path = "/Applications/Unity/Hub/Editor"
69
- if Dir.exist?(hub_path)
70
- # 获取所有版本并按版本号排序
71
- versions = Dir.entries(hub_path).select { |e| e =~ /[\d\.]+/ }.sort_by do |v|
72
- v.split('.').map(&:to_i)
73
- end
74
-
75
- if versions.any?
76
- latest_version = versions.last
77
- mac_path = "#{hub_path}/#{latest_version}/Unity.app/Contents/MacOS/Unity"
78
- if File.exist?(mac_path)
79
- puts "使用最新Unity版本 #{latest_version}: #{mac_path}" if verbose
80
- return mac_path
81
- end
82
- end
121
+ # 如果找到项目版本,尝试精确匹配
122
+ if project_version
123
+ # 1. 精确匹配版本号
124
+ exact_matches = unity_versions.select { |v| v[:version] == project_version }
125
+ if !exact_matches.empty?
126
+ unity_path = exact_matches.first[:path]
127
+ puts "找到精确匹配的Unity版本 #{project_version}: #{unity_path}" if verbose
128
+ return unity_path
83
129
  end
84
130
 
85
- # 查找传统路径
86
- traditional_path = "/Applications/Unity/Unity.app/Contents/MacOS/Unity"
87
- if File.exist?(traditional_path)
88
- puts "使用传统路径Unity: #{traditional_path}" if verbose
89
- return traditional_path
90
- end
91
- # 检查Windows路径
92
- elsif RUBY_PLATFORM =~ /mswin|mingw|cygwin/
93
- hub_path = "C:/Program Files/Unity/Hub/Editor"
94
- if Dir.exist?(hub_path)
95
- versions = Dir.entries(hub_path).select { |e| e =~ /[\d\.]+/ }.sort_by do |v|
96
- v.split('.').map(&:to_i)
97
- end
131
+ # 2. 如果没有精确匹配,尝试按主要版本号匹配(如2021.3.x)
132
+ if unity_major_version
133
+ major_matches = unity_versions.select { |v| v[:major_version] == unity_major_version }
98
134
 
99
- if versions.any?
100
- latest_version = versions.last
101
- win_path = "#{hub_path}/#{latest_version}/Editor/Unity.exe"
102
- if File.exist?(win_path)
103
- puts "使用最新Unity版本 #{latest_version}: #{win_path}" if verbose
104
- return win_path
135
+ if !major_matches.empty?
136
+ # 按版本号排序
137
+ sorted_versions = major_matches.sort_by do |v|
138
+ # 解析版本号为数组,如 "2021.3.45f1" => [2021, 3, 45, 1]
139
+ if v[:version] =~ /(\d+)\.(\d+)\.(\d+)f(\d+)/
140
+ [$1.to_i, $2.to_i, $3.to_i, $4.to_i]
141
+ else
142
+ [0, 0, 0, 0]
143
+ end
105
144
  end
106
- end
107
- end
108
-
109
- # 查找传统路径
110
- traditional_path = "C:/Program Files/Unity/Editor/Unity.exe"
111
- if File.exist?(traditional_path)
112
- puts "使用传统路径Unity: #{traditional_path}" if verbose
113
- return traditional_path
114
- end
115
- # 检查Linux路径
116
- elsif RUBY_PLATFORM =~ /linux/
117
- hub_path = "/opt/unity/hub/editor"
118
- if Dir.exist?(hub_path)
119
- versions = Dir.entries(hub_path).select { |e| e =~ /[\d\.]+/ }.sort_by do |v|
120
- v.split('.').map(&:to_i)
121
- end
122
-
123
- if versions.any?
124
- latest_version = versions.last
125
- linux_path = "#{hub_path}/#{latest_version}/Editor/Unity"
126
- if File.exist?(linux_path)
127
- puts "使用最新Unity版本 #{latest_version}: #{linux_path}" if verbose
128
- return linux_path
145
+
146
+ # 标准版本(如2021.3.45f1)优先于特殊版本(如2021.3.45f1c1)
147
+ standard_versions = sorted_versions.select { |v| v[:version] =~ /^[\d\.]+f\d+$/ }
148
+
149
+ if !standard_versions.empty?
150
+ unity_path = standard_versions.last[:path] # 取最新的标准版本
151
+ puts "找到主要版本号匹配的标准Unity版本 #{standard_versions.last[:version]}: #{unity_path}" if verbose
152
+ return unity_path
153
+ else
154
+ unity_path = sorted_versions.last[:path] # 取最新版本
155
+ puts "找到主要版本号匹配的Unity版本 #{sorted_versions.last[:version]}: #{unity_path}" if verbose
156
+ return unity_path
129
157
  end
130
158
  end
131
159
  end
132
160
  end
133
161
 
134
- nil
162
+ # 3. 如果没有找到匹配的版本,使用最新版本
163
+ puts "未找到匹配项目版本的Unity,将使用最新可用版本" if verbose
164
+
165
+ # 按版本号排序
166
+ sorted_all_versions = unity_versions.sort_by do |v|
167
+ if v[:version] =~ /(\d+)\.(\d+)\.(\d+)f(\d+)/
168
+ [$1.to_i, $2.to_i, $3.to_i, $4.to_i]
169
+ else
170
+ [0, 0, 0, 0]
171
+ end
172
+ end
173
+
174
+ # 标准版本优先
175
+ standard_versions = sorted_all_versions.select { |v| v[:version] =~ /^[\d\.]+f\d+$/ }
176
+
177
+ if !standard_versions.empty?
178
+ unity_path = standard_versions.last[:path] # 取最新的标准版本
179
+ puts "使用最新标准Unity版本 #{standard_versions.last[:version]}: #{unity_path}" if verbose
180
+ return unity_path
181
+ else
182
+ unity_path = sorted_all_versions.last[:path] # 取最新版本
183
+ puts "使用最新可用Unity版本 #{sorted_all_versions.last[:version]}: #{unity_path}" if verbose
184
+ return unity_path
185
+ end
135
186
  end
136
187
 
137
188
  # 验证Unity可执行文件路径是否有效
@@ -1,3 +1,3 @@
1
1
  module EasyCI
2
- VERSION = '0.5.0'
2
+ VERSION = '0.7.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easyci
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wade