easyci 0.1.0 → 0.3.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/LICENSE +0 -0
- data/README.md +38 -3
- data/lib/easyci/command/autobuild.rb +0 -0
- data/lib/easyci/command/unitydraw.rb +91 -13
- data/lib/easyci/command.rb +0 -0
- data/lib/easyci/unity_exe_helper.rb +164 -0
- data/lib/easyci/version.rb +1 -1
- data/lib/easyci.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c686b87933dc1724fa1b664bde3a3a69788538a90e517fe24c61dc0b78707403
|
4
|
+
data.tar.gz: 3c3d61196ddcf011c0bf7ff8ae4b1fac6f48ee466f1a878059bfa26d41a1c296
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef0ca99b8cd089f7c3c82f0f92cf139e415b271efcffdd7544b5ecba373442202c8849ce9ec94e5c4808612bb4e106c992d2f6ca83ca60ffc94deddbd81dbce5
|
7
|
+
data.tar.gz: c2c66fb63fca23ab8d4439c19ef75bf51796d9c6dc95aad5ff53d0298edcfdae6a9102a9fac1bea6c4db44796ba699f4a6bb6374ac973d2528d36d3dcadfab7c
|
data/LICENSE
CHANGED
File without changes
|
data/README.md
CHANGED
@@ -10,14 +10,37 @@ gem install easyci
|
|
10
10
|
|
11
11
|
## 使用方法
|
12
12
|
|
13
|
-
### Unity
|
13
|
+
### Unity依赖关系图与截图
|
14
14
|
|
15
|
-
|
15
|
+
#### 本地项目分析
|
16
|
+
|
17
|
+
分析本地Unity项目并生成依赖关系图和截图:
|
16
18
|
|
17
19
|
```bash
|
18
|
-
easyci unitydraw --project-path=/path/to/unity/project --output=dependencies.png
|
20
|
+
easyci unitydraw --project-path=/path/to/unity/project --output=dependencies.png --execute-method=YourMethod.Execute
|
19
21
|
```
|
20
22
|
|
23
|
+
#### Gitee仓库分析
|
24
|
+
|
25
|
+
从Gitee仓库拉取项目并生成依赖关系图和截图:
|
26
|
+
|
27
|
+
```bash
|
28
|
+
easyci unitydraw --repo=username/repo --branch=master --compress
|
29
|
+
```
|
30
|
+
|
31
|
+
#### 完整选项
|
32
|
+
|
33
|
+
unitydraw命令支持以下选项:
|
34
|
+
|
35
|
+
- `--project-path=PATH`: 指定本地Unity项目路径
|
36
|
+
- `--output=PATH`: 输出图形的路径
|
37
|
+
- `--repo=REPO`: Gitee仓库路径,例如:bestwebprimary/MagicSortDemo
|
38
|
+
- `--branch=BRANCH`: Gitee分支名称,默认为master
|
39
|
+
- `--work-dir=DIR`: 工作目录,默认为~/gitee_draw
|
40
|
+
- `--execute-method=METHOD`: Unity执行方法,默认为SpineAutoImporter.CIRunner
|
41
|
+
- `--unity-path=PATH`: 指定Unity可执行文件路径,默认自动查找
|
42
|
+
- `--compress`: 是否压缩生成的截图
|
43
|
+
|
21
44
|
### 自动构建
|
22
45
|
|
23
46
|
自动构建项目:
|
@@ -26,6 +49,18 @@ easyci unitydraw --project-path=/path/to/unity/project --output=dependencies.png
|
|
26
49
|
easyci autobuild --project-path=/path/to/project --build-target=iOS --output=/path/to/output --version=1.0.0
|
27
50
|
```
|
28
51
|
|
52
|
+
## 特性
|
53
|
+
|
54
|
+
### Unity可执行文件自动查找
|
55
|
+
|
56
|
+
EasyCI内置了UnityExeHelper模块,可以根据项目信息自动查找匹配的Unity可执行文件:
|
57
|
+
|
58
|
+
- 自动从ProjectVersion.txt文件中读取项目的Unity版本
|
59
|
+
- 在标准安装路径中查找匹配版本的Unity
|
60
|
+
- 支持macOS、Windows和Linux系统
|
61
|
+
- 如果找不到匹配版本,会自动使用最新版本的Unity
|
62
|
+
- 可以通过`--unity-path`选项手动指定Unity路径
|
63
|
+
|
29
64
|
## 选项
|
30
65
|
|
31
66
|
全局选项:
|
File without changes
|
@@ -1,37 +1,115 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
1
3
|
module EasyCI
|
2
4
|
class Command
|
3
5
|
class Unitydraw < Command
|
4
6
|
self.summary = '绘制Unity项目图形'
|
5
|
-
self.description = '分析Unity
|
7
|
+
self.description = '分析Unity项目并生成依赖关系图和截图'
|
6
8
|
|
7
9
|
def self.options
|
8
10
|
[
|
9
|
-
['--
|
10
|
-
['--output=PATH', '输出图形的路径']
|
11
|
+
['--runner-repo=REPO', 'Runner仓库路径,例如:mygroup/FGUIWorkRunner'],
|
11
12
|
].concat(super)
|
12
13
|
end
|
13
14
|
|
14
15
|
def initialize(argv)
|
15
|
-
@project_path = argv.option('project-path')
|
16
|
-
@output_path = argv.option('output')
|
17
16
|
super
|
17
|
+
@runner_repo = argv.option('runner-repo')
|
18
18
|
end
|
19
19
|
|
20
20
|
def validate!
|
21
21
|
super
|
22
|
-
help! '必须提供项目路径' unless @project_path
|
23
22
|
end
|
24
23
|
|
25
24
|
def run
|
26
|
-
puts "
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
puts "开始Unity项目绘制流程..."
|
26
|
+
|
27
|
+
work_dir = File.expand_path('~/gitee_draw')
|
28
|
+
gitee_repo = ENV['GITEE_REPO'] || 'fundesignexport/MagicSortDemoDesignExport'
|
29
|
+
gitee_branch = ENV['GITEE_BRANCH'] || 'master'
|
30
|
+
|
31
|
+
if @runner_repo.empty?
|
32
|
+
puts "runner-repo 不能为空"
|
33
|
+
exit 1
|
34
|
+
end
|
35
|
+
|
36
|
+
if gitee_repo.empty? || gitee_branch.empty?
|
37
|
+
puts "GITEE_REPO 和 GITEE_BRANCH 不能为空"
|
38
|
+
exit 1
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
puts "gitee_repo: #{gitee_repo}"
|
43
|
+
puts "gitee_branch: #{gitee_branch}"
|
44
|
+
puts "work_dir: #{work_dir}"
|
45
|
+
|
46
|
+
# 清理工作目录
|
47
|
+
FileUtils.mkdir_p(work_dir)
|
48
|
+
runner_dir = File.join(work_dir, 'FGUIWorkRunner')
|
49
|
+
FileUtils.rm_rf(runner_dir) if File.exist?(runner_dir)
|
50
|
+
clone_runner_result = system("cd #{work_dir} && git clone --depth 1 -b dev https://gitee.com/#{@runner_repo}.git FGUIWorkRunner")
|
51
|
+
unless clone_runner_result
|
52
|
+
puts "克隆Runner仓库失败,请检查网络和权限设置"
|
53
|
+
exit 1
|
54
|
+
end
|
55
|
+
unless File.exist?(runner_dir)
|
56
|
+
puts "Runner目录不存在,克隆可能失败"
|
57
|
+
exit 1
|
58
|
+
end
|
59
|
+
|
60
|
+
FileUtils.chdir(runner_dir)
|
61
|
+
resources_dir = File.join(runner_dir, 'Assets/Resources')
|
62
|
+
if File.exist?(resources_dir)
|
63
|
+
FileUtils.rm_rf(resources_dir)
|
64
|
+
end
|
65
|
+
puts "下载截图仓库..."
|
66
|
+
clone_result = system("cd #{runner_dir} && git clone --depth 1 -b #{gitee_branch} https://gitee.com/#{gitee_repo}.git Assets/Resources")
|
67
|
+
|
68
|
+
unless clone_result
|
69
|
+
puts "克隆Assets仓库失败,请检查网络和权限设置"
|
70
|
+
exit 1
|
71
|
+
end
|
72
|
+
|
73
|
+
# 运行Unity截图任务
|
74
|
+
puts "运行Unity截图任务..."
|
75
|
+
unity_path = find_unity_path(runner_dir)
|
76
|
+
FileUtils.chdir(runner_dir)
|
77
|
+
system("#{unity_path} -projectPath . -executeMethod #{@execute_method} -logFile screenshot-log.txt")
|
78
|
+
|
79
|
+
# 压缩截图
|
80
|
+
puts "开始压缩截图..."
|
81
|
+
system("find . -path \"*/Screenshots/*.png\" -exec pngquant --quality=70-95 --ext .png --force {} \\;")
|
82
|
+
# 运行Node脚本(如果需要)
|
83
|
+
puts "运行后处理脚本..."
|
84
|
+
system("docker run --rm -v \"$(pwd):/app\" -w /app node:22.0.0 bash -c \"cd Scripts && yarn install && npx ts-node index.ts\"")
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
private
|
89
|
+
|
90
|
+
def find_unity_path(project_path)
|
91
|
+
# 如果提供了Unity路径,验证它
|
92
|
+
if @unity_path && !@unity_path.empty?
|
93
|
+
if UnityExeHelper.valid_unity_path?(@unity_path)
|
94
|
+
puts "使用指定的Unity路径: #{@unity_path}"
|
95
|
+
return @unity_path
|
96
|
+
else
|
97
|
+
puts "警告: 指定的Unity路径无效,将尝试自动查找"
|
98
|
+
end
|
99
|
+
end
|
31
100
|
|
32
|
-
|
33
|
-
|
101
|
+
# 使用UnityExeHelper查找Unity
|
102
|
+
begin
|
103
|
+
unity_path = UnityExeHelper.find_unity_executable(project_path, @verbose)
|
104
|
+
puts "找到Unity路径: #{unity_path}"
|
105
|
+
return unity_path
|
106
|
+
rescue => e
|
107
|
+
puts "查找Unity路径失败: #{e.message}"
|
108
|
+
exit 1
|
109
|
+
end
|
110
|
+
return nil
|
34
111
|
end
|
112
|
+
|
35
113
|
end
|
36
114
|
end
|
37
115
|
end
|
data/lib/easyci/command.rb
CHANGED
File without changes
|
@@ -0,0 +1,164 @@
|
|
1
|
+
module EasyCI
|
2
|
+
# UnityExeHelper模块,用于查找和验证Unity可执行文件路径
|
3
|
+
module UnityExeHelper
|
4
|
+
# 查找Unity可执行文件路径
|
5
|
+
# @param project_path [String] Unity项目路径
|
6
|
+
# @param verbose [Boolean] 是否显示详细信息
|
7
|
+
# @return [String] Unity可执行文件路径
|
8
|
+
def self.find_unity_executable(project_path = nil, verbose = false)
|
9
|
+
unity_path = nil
|
10
|
+
project_version = nil
|
11
|
+
|
12
|
+
# 如果提供了项目路径,尝试从ProjectVersion.txt中读取版本
|
13
|
+
if project_path && !project_path.empty?
|
14
|
+
version_file = File.join(project_path, 'ProjectSettings', 'ProjectVersion.txt')
|
15
|
+
if File.exist?(version_file)
|
16
|
+
content = File.read(version_file)
|
17
|
+
if content =~ /m_EditorVersion:\s*([\d\.]+[a-zA-Z\d]*)/
|
18
|
+
project_version = $1
|
19
|
+
puts "项目Unity版本: #{project_version}" if verbose
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# 如果找到项目版本,尝试定位对应的Unity
|
25
|
+
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
|
39
|
+
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
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# 如果没有找到匹配版本,尝试查找最新版本
|
51
|
+
if unity_path.nil?
|
52
|
+
puts "没有找到匹配的Unity版本,尝试查找最新版本" if verbose
|
53
|
+
unity_path = find_latest_unity(verbose)
|
54
|
+
end
|
55
|
+
|
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
|
83
|
+
end
|
84
|
+
|
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
|
98
|
+
|
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
|
105
|
+
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
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
nil
|
135
|
+
end
|
136
|
+
|
137
|
+
# 验证Unity可执行文件路径是否有效
|
138
|
+
# @param unity_path [String] Unity可执行文件路径
|
139
|
+
# @return [Boolean] 是否有效
|
140
|
+
def self.valid_unity_path?(unity_path)
|
141
|
+
return false if unity_path.nil? || unity_path.empty?
|
142
|
+
File.exist?(unity_path) && File.executable?(unity_path)
|
143
|
+
end
|
144
|
+
|
145
|
+
# 获取Unity版本信息
|
146
|
+
# @param unity_path [String] Unity可执行文件路径
|
147
|
+
# @return [String] Unity版本信息
|
148
|
+
def self.get_unity_version(unity_path)
|
149
|
+
return nil unless valid_unity_path?(unity_path)
|
150
|
+
|
151
|
+
begin
|
152
|
+
# 使用-version参数获取版本信息
|
153
|
+
version_output = `"#{unity_path}" -version 2>&1`
|
154
|
+
if version_output =~ /([\d\.]+[a-zA-Z\d]*)/
|
155
|
+
return $1
|
156
|
+
end
|
157
|
+
rescue => e
|
158
|
+
puts "获取Unity版本信息失败: #{e.message}"
|
159
|
+
end
|
160
|
+
|
161
|
+
nil
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
data/lib/easyci/version.rb
CHANGED
data/lib/easyci.rb
CHANGED
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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wade
|
@@ -80,6 +80,7 @@ files:
|
|
80
80
|
- lib/easyci/command.rb
|
81
81
|
- lib/easyci/command/autobuild.rb
|
82
82
|
- lib/easyci/command/unitydraw.rb
|
83
|
+
- lib/easyci/unity_exe_helper.rb
|
83
84
|
- lib/easyci/version.rb
|
84
85
|
homepage: https://github.com/yourusername/easyci
|
85
86
|
licenses:
|