pindo 5.1.1 → 5.1.3

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: '05592fa0b0cb7bf97bec159a83fd562ab7fd0cbd08305e4f1a71cd827612bf01'
4
- data.tar.gz: 717a3c0b905d7482974d04c4e901ec8f3fefe08a95dc1128af5263747a2435bd
3
+ metadata.gz: 3fa24d37418344443f4d08b84d7e01ce51dc295830659ab24572c0237ef2f430
4
+ data.tar.gz: 42e2903366c4eac78957837609d4bfe23660cdd8f5ebdb10e20ce2262bc03adc
5
5
  SHA512:
6
- metadata.gz: 4b7772dd3ad4793df33b3ff90d20847b2676ab0c6b6583d0fa176eb43c010e4bde2e6e2755d1009a4b3bd92c14ab34b8690f97074b9ba7f3042d059abba27dfb
7
- data.tar.gz: bbe8a06d9b55eaf57d247a83a8976b46ce2922ec8f4a1538ee2e889d09ce4638a9216d70eca2b7a3eb1fb3ec7d6c54c70e6188e98d9b0579fd78814501a6aee2
6
+ metadata.gz: '05883da5dbaad58a396d33d3b3b2d496bfc2755c1914ddf57cf01a5d3b988af094834a7426fcb0b4b73d817262d882717b1f505e4f39d465bf3b296ecc3e364c'
7
+ data.tar.gz: 2769c89d11df67437faf53633a1b966b21746740f2dea973301acef409ea963c4d2ba4ffd3673ae0e8dfd39cc4c972e87fd274353dcb8f656256b93a78b07480
@@ -95,7 +95,20 @@ module Pindo
95
95
  app_info_obj = PgyerHelper.share_instace.prepare_upload(working_directory:Dir.pwd, proj_name:proj_name)
96
96
  end
97
97
 
98
+ scheme_name = @args_proj_name if @args_proj_name
99
+ if !app_info_obj.nil? && !app_info_obj["appName"].nil? && !app_info_obj["appName"].empty?
100
+ scheme_name = app_info_obj["appName"]
101
+ end
102
+ if scheme_name.nil? || scheme_name.empty? && is_git_directory?(local_repo_dir:pindo_project_dir)
103
+ current_git_root_path = git_root_directory(local_repo_dir: pindo_project_dir)
104
+ git_repo_name = File.basename(current_git_root_path)
105
+ if !git_repo_name.nil? && !git_repo_name.empty?
106
+ scheme_name = git_repo_name
107
+ end
108
+ end
109
+
98
110
  android_build_helper = Pindo::AndroidBuildHelper.share_instance
111
+ android_build_helper.add_test_scheme(project_dir:pindo_project_dir,scheme_name:scheme_name)
99
112
  apk_path = android_build_helper.auto_build_apk(pindo_project_dir, !@args_release_flag)
100
113
  ipa_file_upload = Dir.glob(apk_path).max_by {|f| File.mtime(f)}
101
114
 
@@ -0,0 +1,200 @@
1
+ require 'highline/import'
2
+ require 'xcodeproj'
3
+ require 'find'
4
+ require 'fileutils'
5
+ require 'pindo/base/executable'
6
+ require 'pindo/module/build/unityhelper'
7
+ require 'pindo/module/build/buildhelper'
8
+
9
+ module Pindo
10
+ class Command
11
+ class Unity < Command
12
+ class Autobuild < Unity
13
+
14
+ include Appselect
15
+
16
+ include Pindo::Githelper
17
+ # Unity IPA包编译和上传命令
18
+ self.summary = '编译Unity工程生成iOS IPA并支持上传到测试平台'
19
+
20
+ # 详细说明
21
+ self.description = <<-DESC
22
+ 编译Unity工程生成iOS IPA并支持上传到测试平台。
23
+
24
+ 支持功能:
25
+
26
+ * 编译生成IPA
27
+
28
+ * 上传到测试平台
29
+
30
+ * 发送测试通知
31
+
32
+ 使用示例:
33
+
34
+ $ pindo unity autobuild # 编译
35
+
36
+ $ pindo unity autobuild --upload # 编译并上传
37
+
38
+ $ pindo unity autobuild --proj=myapp # 指定项目名称
39
+ DESC
40
+
41
+ # 命令参数
42
+ self.arguments = [
43
+ # 暂无参数
44
+ ]
45
+
46
+ # 命令选项
47
+ def self.options
48
+ [
49
+ ['--proj', '指定上传到测试平台的项目名称'],
50
+ ['--upload', '上传编译后的IPA到测试平台'],
51
+ ['--base', 'Unity工程编译lib模式'],
52
+ ].concat(super)
53
+ end
54
+
55
+
56
+ def initialize(argv)
57
+
58
+ @args_proj_name = argv.option('proj')
59
+ @args_upload_flag = argv.flag?('upload', false)
60
+ @args_base_flag = argv.flag?('base', false)
61
+
62
+
63
+ super
64
+ end
65
+
66
+
67
+ def run
68
+
69
+ pindo_project_dir = Dir.pwd
70
+
71
+ # 检查是否是Unity工程
72
+ unity_helper = Pindo::Client::UnityHelper.share_instance
73
+ unless unity_helper.unity_project?(pindo_project_dir)
74
+ raise Informative, "当前目录不是Unity工程,请在Unity工程根目录下执行此命令"
75
+ end
76
+
77
+ if @args_upload_flag
78
+ build_helper = Pindo::BuildHelper.share_instance
79
+ is_need_add_tag,tag_action_parms = build_helper.check_is_need_add_tag?(pindo_project_dir)
80
+ if is_need_add_tag
81
+ Pindo::Command::Dev::Tag::run(tag_action_parms)
82
+ end
83
+ end
84
+
85
+ project_unity_version = unity_helper.get_unity_version(pindo_project_dir)
86
+ unity_exe_path = unity_helper.find_unity_path(project_unity_version:project_unity_version, force_change_version: @force_select_unity)
87
+ puts
88
+ puts "工程的Unity版本: #{project_unity_version}"
89
+ puts "选择的Unity路径: #{unity_exe_path}"
90
+ puts
91
+
92
+
93
+ app_info_obj = nil
94
+ if @args_upload_flag
95
+ proj_name = @args_proj_name
96
+ app_info_obj = PgyerHelper.share_instace.prepare_upload(working_directory:Dir.pwd, proj_name:proj_name)
97
+ end
98
+
99
+ pindo_project_dir = Dir.pwd
100
+
101
+ ios_autobuild(unity_helper:unity_helper, unity_exe_path:unity_exe_path)
102
+ Dir.chdir(pindo_project_dir)
103
+
104
+ and_autobuild(unity_helper:unity_helper, unity_exe_path:unity_exe_path)
105
+ Dir.chdir(pindo_project_dir)
106
+
107
+ web_autobuild(unity_helper:unity_helper, unity_exe_path:unity_exe_path)
108
+ Dir.chdir(pindo_project_dir)
109
+
110
+ end
111
+
112
+ def web_autobuild(unity_helper:nil, unity_exe_path:nil)
113
+ pindo_project_dir = Dir.pwd
114
+
115
+ web_export_dir = File.join(pindo_project_dir, "GoodPlatform/WebGL")
116
+ unity_helper.build_project(unity_exe_full_path:unity_exe_path, project_path:pindo_project_dir, platform:'WebGL')
117
+
118
+ system "open #{pindo_project_dir}"
119
+
120
+
121
+ end
122
+
123
+ def ios_autobuild(unity_helper:nil, unity_exe_path:nil)
124
+
125
+ pindo_project_dir = Dir.pwd
126
+ mainapp_bundleid= nil
127
+ if @args_deploy_flag
128
+ mainapp_bundleid = get_selected_deploy_bundleid()
129
+ else
130
+ mainapp_bundleid = get_selected_dev_bundleid()
131
+ end
132
+
133
+ isLibrary = @args_base_flag
134
+ ios_export_lib_dir = File.join(pindo_project_dir, "GoodPlatform/BaseiOS")
135
+ if File.directory?(ios_export_lib_dir)
136
+ isLibrary = true
137
+ end
138
+ pindo_ios_project_dir = File.join(pindo_project_dir, "GoodPlatform/iOS")
139
+ if isLibrary
140
+ pindo_ios_project_dir = ios_export_lib_dir
141
+ end
142
+ unity_helper.build_project(unity_exe_full_path:unity_exe_path, project_path:pindo_project_dir, platform:'iOS', isLibrary:isLibrary)
143
+
144
+
145
+ args_temp = []
146
+ args_temp << "--bundleid=#{mainapp_bundleid}"
147
+
148
+ if @args_upload_flag
149
+ args_temp << "--proj=#{app_info_obj["appName"]}"
150
+ args_temp << "--upload"
151
+ end
152
+
153
+ Dir.chdir(pindo_ios_project_dir)
154
+
155
+ Pindo::Command::Ios::Autobuild::run(args_temp)
156
+
157
+ end
158
+
159
+ def and_autobuild(unity_helper:nil, unity_exe_path:nil)
160
+
161
+ pindo_project_dir = Dir.pwd
162
+ isLibrary = @args_base_flag
163
+
164
+ android_export_lib_dir = File.join(pindo_project_dir, "GoodPlatform/BaseAndroid")
165
+ if File.directory?(android_export_lib_dir)
166
+ isLibrary = true
167
+ end
168
+
169
+ pindo_android_project_dir = File.join(pindo_project_dir, "GoodPlatform/Android")
170
+ if isLibrary
171
+ pindo_android_project_dir = android_export_lib_dir
172
+ end
173
+ puts "开始构建Unity项目..."
174
+
175
+ unity_helper.build_project(
176
+ unity_exe_full_path: unity_exe_path,
177
+ project_path: pindo_project_dir,
178
+ platform: 'Android',
179
+ isLibrary: isLibrary
180
+ )
181
+
182
+ puts "Unity项目构建完成,准备处理Android项目..."
183
+ args_temp = []
184
+
185
+ if @args_upload_flag
186
+ args_temp << "--proj=#{app_info_obj["appName"]}"
187
+ args_temp << "--upload"
188
+ end
189
+
190
+ Dir.chdir(pindo_android_project_dir)
191
+
192
+ Pindo::Command::Android::Autobuild::run(args_temp)
193
+
194
+ end
195
+
196
+
197
+ end
198
+ end
199
+ end
200
+ end
@@ -0,0 +1,152 @@
1
+ require 'highline/import'
2
+ require 'xcodeproj'
3
+ require 'find'
4
+ require 'fileutils'
5
+ require 'pindo/base/executable'
6
+ require 'pindo/module/build/unityhelper'
7
+ require 'pindo/module/build/buildhelper'
8
+
9
+ module Pindo
10
+ class Command
11
+ class Unity < Command
12
+ class Web < Unity
13
+
14
+ include Appselect
15
+
16
+ include Pindo::Githelper
17
+ # Unity IPA包编译和上传命令
18
+ self.summary = '编译Unity工程生成iOS IPA并支持上传到测试平台'
19
+
20
+ # 详细说明
21
+ self.description = <<-DESC
22
+ 编译Unity工程生成iOS IPA并支持上传到测试平台。
23
+
24
+ 支持功能:
25
+
26
+ * 编译生成IPA
27
+
28
+ * 上传到测试平台
29
+
30
+ * 发送测试通知
31
+
32
+ 使用示例:
33
+
34
+ $ pindo unity ipa # 编译IPA
35
+
36
+ $ pindo unity ipa --upload # 编译并上传
37
+
38
+ $ pindo unity ipa --send # 编译上传并发送通知
39
+
40
+ $ pindo unity ipa --proj=myapp # 指定项目名称
41
+ DESC
42
+
43
+ # 命令参数
44
+ self.arguments = [
45
+ # 暂无参数
46
+ ]
47
+
48
+ # 命令选项
49
+ def self.options
50
+ [
51
+ ['--proj', '指定上传到测试平台的项目名称'],
52
+ ['--upload', '上传编译后的IPA到测试平台'],
53
+ ['--send', '上传成功后发送测试通知'],
54
+ ['--base', 'Unity工程编译lib模式'],
55
+ ['--unity-version', '切换Unity版本']
56
+ ].concat(super)
57
+ end
58
+
59
+
60
+ def initialize(argv)
61
+
62
+ @args_proj_name = argv.option('proj')
63
+ @args_upload_flag = argv.flag?('upload', false)
64
+ @args_send_flag = argv.flag?('send', false)
65
+ @args_deploy_flag = argv.flag?('deploy', false)
66
+ @args_base_flag = argv.flag?('base', false)
67
+ @force_select_unity = argv.flag?('unity-version', false)
68
+
69
+
70
+ if @args_send_flag
71
+ @args_upload_flag = true
72
+ end
73
+
74
+ super
75
+ end
76
+
77
+
78
+ def run
79
+
80
+ pindo_project_dir = Dir.pwd
81
+
82
+ # 检查是否是Unity工程
83
+ unity_helper = Pindo::Client::UnityHelper.share_instance
84
+ unless unity_helper.unity_project?(pindo_project_dir)
85
+ raise Informative, "当前目录不是Unity工程,请在Unity工程根目录下执行此命令"
86
+ end
87
+
88
+ if @args_upload_flag
89
+ build_helper = Pindo::BuildHelper.share_instance
90
+ is_need_add_tag,tag_action_parms = build_helper.check_is_need_add_tag?(pindo_project_dir)
91
+ if is_need_add_tag
92
+ Pindo::Command::Dev::Tag::run(tag_action_parms)
93
+ end
94
+ end
95
+
96
+ project_unity_version = unity_helper.get_unity_version(pindo_project_dir)
97
+ puts
98
+ puts "工程的Unity版本: #{project_unity_version}"
99
+ unity_exe_path = unity_helper.find_unity_path(project_unity_version:project_unity_version, force_change_version: @force_select_unity)
100
+ puts "选择的Unity路径: #{unity_exe_path}"
101
+ puts
102
+
103
+ app_info_obj = nil
104
+ if @args_upload_flag
105
+ proj_name = @args_proj_name
106
+ app_info_obj = PgyerHelper.share_instace.prepare_upload(working_directory:Dir.pwd, proj_name:proj_name)
107
+ end
108
+
109
+ mainapp_bundleid= nil
110
+ if @args_deploy_flag
111
+ mainapp_bundleid = get_selected_deploy_bundleid()
112
+ else
113
+ mainapp_bundleid = get_selected_dev_bundleid()
114
+ end
115
+
116
+ isLibrary = @args_base_flag
117
+
118
+ ios_export_lib_dir = File.join(pindo_project_dir, "GoodPlatform/BaseiOS")
119
+ if File.directory?(ios_export_lib_dir)
120
+ isLibrary = true
121
+ end
122
+
123
+ pindo_ios_project_dir = File.join(pindo_project_dir, "GoodPlatform/iOS")
124
+ if isLibrary
125
+ pindo_ios_project_dir = ios_export_lib_dir
126
+ end
127
+ unity_helper.build_project(unity_exe_full_path:unity_exe_path, project_path:pindo_project_dir, platform:'iOS', isLibrary:isLibrary)
128
+
129
+
130
+ args_temp = []
131
+ args_temp << "--bundleid=#{mainapp_bundleid}"
132
+
133
+ if @args_upload_flag
134
+ args_temp << "--proj=#{app_info_obj["appName"]}"
135
+ args_temp << "--upload"
136
+ end
137
+ if @args_send_flag
138
+ args_temp << "--send"
139
+ end
140
+
141
+ Dir.chdir(pindo_ios_project_dir)
142
+
143
+ Pindo::Command::Ios::Autobuild::run(args_temp)
144
+
145
+
146
+ end
147
+
148
+
149
+ end
150
+ end
151
+ end
152
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'pindo/command/unity/ipa'
4
4
  require 'pindo/command/unity/apk'
5
-
5
+ require 'pindo/command/unity/autobuild'
6
6
 
7
7
  module Pindo
8
8
  class Command
@@ -4,6 +4,10 @@ require 'find'
4
4
  require 'fileutils'
5
5
  require 'pindo/base/executable'
6
6
  require 'pindo/module/build/buildhelper'
7
+ require 'pindo/module/webserver/brotli_file_handler'
8
+ require 'pindo/module/webserver/webgl_page_handler'
9
+ require 'pindo/module/webserver/responsive_preview_handler'
10
+ require 'pindo/module/webserver/webgl_server_helper'
7
11
  require 'webrick' # 添加WebRick HTTP服务器
8
12
  require 'socket'
9
13
 
@@ -63,180 +67,6 @@ module Pindo
63
67
  end
64
68
  end
65
69
 
66
- # 处理.br扩展名请求的servlet
67
- class BrotliFileHandler < WEBrick::HTTPServlet::AbstractServlet
68
- def initialize(server, root_dir, debug=false)
69
- super(server)
70
- @root_dir = root_dir
71
- @debug = debug
72
- end
73
-
74
- def do_GET(req, res)
75
- # 只处理.br结尾的文件
76
- unless req.path.end_with?('.br')
77
- res.status = 404
78
- return
79
- end
80
-
81
- file_path = File.join(@root_dir, req.path[1..-1])
82
- UI.debug("处理.br文件请求: #{req.path}", @debug)
83
-
84
- if File.exist?(file_path)
85
- # 确定原始文件类型
86
- base_name = File.basename(req.path, ".br")
87
- ext = File.extname(base_name)
88
-
89
- content_type = case ext
90
- when ".js" then "application/javascript"
91
- when ".wasm" then "application/wasm"
92
- when ".data" then "application/octet-stream"
93
- when ".json" then "application/json"
94
- else "application/octet-stream"
95
- end
96
-
97
- # 读取文件
98
- file_content = File.binread(file_path)
99
-
100
- # 设置响应
101
- res.status = 200
102
- res.header["Content-Encoding"] = "br"
103
- res.content_type = content_type
104
- res.body = file_content
105
- else
106
- UI.debug("未找到.br文件: #{file_path}", @debug)
107
- res.status = 404
108
- end
109
- end
110
- end
111
-
112
- # 自定义前端页面处理器,处理Unity WebGL的特殊文件加载需求
113
- class WebGLPageHandler < WEBrick::HTTPServlet::AbstractServlet
114
- def initialize(server, root_dir, debug=false)
115
- super(server)
116
- @root_dir = root_dir
117
- @debug = debug
118
- end
119
-
120
- def do_GET(req, res)
121
- path = req.path
122
- path = "/index.html" if path == "/"
123
-
124
- file_path = File.join(@root_dir, path[1..-1])
125
-
126
- if File.exist?(file_path)
127
- # 确定内容类型
128
- ext = File.extname(file_path)
129
- content_type = case ext
130
- when ".html" then "text/html"
131
- when ".js" then "application/javascript"
132
- when ".css" then "text/css"
133
- when ".png" then "image/png"
134
- when ".jpg", ".jpeg" then "image/jpeg"
135
- when ".gif" then "image/gif"
136
- when ".ico" then "image/x-icon"
137
- else "application/octet-stream"
138
- end
139
-
140
- res.content_type = content_type
141
- res.body = File.read(file_path)
142
- res.status = 200
143
- else
144
- res.status = 404
145
- end
146
- end
147
- end
148
-
149
- # 获取本机局域网IP地址
150
- def get_local_ip
151
- ip = nil
152
- Socket.ip_address_list.each do |addr_info|
153
- if addr_info.ipv4? && !addr_info.ipv4_loopback?
154
- ip = addr_info.ip_address
155
- break
156
- end
157
- end
158
- return ip || 'localhost'
159
- end
160
-
161
- # 启动HTTP服务器
162
- def start_http_server(webgl_dir, port)
163
- begin
164
- # 确保目录存在
165
- unless File.directory?(webgl_dir)
166
- UI.puts("错误: WebGL目录不存在: #{webgl_dir}")
167
- return nil
168
- end
169
-
170
- # 检查index.html是否存在
171
- if !File.exist?(File.join(webgl_dir, "index.html"))
172
- UI.puts("警告: WebGL目录中未找到index.html文件")
173
- end
174
-
175
- # 创建自定义日志格式器,只记录错误
176
- custom_log = [
177
- [:error, WEBrick::AccessLog::COMMON_LOG_FORMAT],
178
- ]
179
-
180
- # 采用直接的方法配置服务器
181
- server = WEBrick::HTTPServer.new(
182
- :Port => port,
183
- :DocumentRoot => webgl_dir,
184
- :Logger => WEBrick::Log.new(nil, WEBrick::Log::ERROR),
185
- :AccessLog => @args_debug ? nil : [],
186
- :DoNotReverseLookup => true,
187
- :BindAddress => '0.0.0.0' # 绑定到所有网络接口,使其在局域网可访问
188
- )
189
-
190
- # 挂载处理程序
191
- server.mount("/", WebGLPageHandler, webgl_dir, @args_debug)
192
-
193
- # 挂载Brotli处理器(后缀为.br的文件)
194
- paths_with_br = []
195
- Find.find(webgl_dir) do |path|
196
- if path.end_with?('.br') && File.file?(path)
197
- rel_path = path.sub(webgl_dir, '')
198
- paths_with_br << rel_path
199
- end
200
- end
201
-
202
- # 挂载每个.br文件
203
- paths_with_br.each do |br_path|
204
- server.mount(br_path, BrotliFileHandler, webgl_dir, @args_debug)
205
- end
206
-
207
- # 只在调试模式下显示详细信息
208
- if @args_debug
209
- UI.puts("找到.br文件: #{paths_with_br.join(', ')}")
210
-
211
- UI.puts("WebGL目录内容:")
212
- Dir.entries(webgl_dir).each do |entry|
213
- next if entry == "." || entry == ".."
214
- UI.puts(" - #{entry}")
215
-
216
- # 递归显示子目录中的文件(限制为一级)
217
- entry_path = File.join(webgl_dir, entry)
218
- if File.directory?(entry_path)
219
- Dir.entries(entry_path).each do |subentry|
220
- next if subentry == "." || subentry == ".."
221
- UI.puts(" - #{entry}/#{subentry}")
222
- end
223
- end
224
- end
225
- end
226
-
227
- # 启动服务器并返回
228
- local_ip = get_local_ip
229
- UI.puts("启动WebGL HTTP服务器,端口: #{port},目录: #{webgl_dir}")
230
- UI.puts("本地访问地址: http://localhost:#{port}/index.html")
231
- UI.puts("局域网访问地址: http://#{local_ip}:#{port}/index.html")
232
- return server
233
- rescue Exception => e
234
- UI.puts("启动HTTP服务器失败: #{e.message}")
235
- UI.debug(e.backtrace.join("\n"), @args_debug)
236
- return nil
237
- end
238
- end
239
-
240
70
  def run
241
71
  pindo_project_dir = Dir.pwd
242
72
  build_helper = Pindo::BuildHelper.share_instance
@@ -255,12 +85,22 @@ module Pindo
255
85
  UI.debug("WebGL资源目录: #{webgl_res_dir}", @args_debug)
256
86
  UI.debug("目录存在: #{File.directory?(webgl_res_dir)}", @args_debug)
257
87
 
258
- # 启动HTTP服务器而不是简单打开目录
259
- server = start_http_server(webgl_res_dir, @args_port)
88
+ # 使用WebGlServerHelper启动HTTP服务器
89
+ server = Pindo::WebServer::WebGlServerHelper.start_http_server(webgl_res_dir, @args_port, @args_debug)
260
90
 
261
91
  if server
262
- # 打开浏览器展示WebGL内容
263
- system("open http://localhost:#{@args_port}/index.html")
92
+ # 获取本地IP地址
93
+ local_ip = Pindo::WebServer::WebGlServerHelper.get_local_ip
94
+
95
+ # 显示访问地址
96
+ UI.puts("启动WebGL HTTP服务器,端口: #{@args_port},目录: #{webgl_res_dir}")
97
+ UI.puts("原始WebGL本地预览地址: http://localhost:#{@args_port}/")
98
+ UI.puts("模拟设备本地预览地址: http://localhost:#{@args_port}/responsive")
99
+ UI.puts("原始WebGL局域网预览地址: http://#{local_ip}:#{@args_port}/")
100
+ UI.puts("模拟设备局域网预览地址: http://#{local_ip}:#{@args_port}/responsive")
101
+
102
+ # 打开浏览器展示WebGL内容 - 直接打开预览页面
103
+ system("open http://localhost:#{@args_port}/responsive")
264
104
 
265
105
  # 捕获Ctrl+C信号来优雅地关闭服务器
266
106
  trap('INT') { server.shutdown }