pindo 5.1.2 → 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: edde43d063ecc58b4cd99a2728817aabd63b30a0f43bfca4ac2655f1ed7aa603
4
- data.tar.gz: e41e3030be169bf333d8d32c3da71965d641e1a2a9c4c0d70baab8f10b5ead2b
3
+ metadata.gz: 3fa24d37418344443f4d08b84d7e01ce51dc295830659ab24572c0237ef2f430
4
+ data.tar.gz: 42e2903366c4eac78957837609d4bfe23660cdd8f5ebdb10e20ce2262bc03adc
5
5
  SHA512:
6
- metadata.gz: 0ce8d7846eb86dc1def92d0b30971eec8ad15e828c2038ba1c63031675a9f3c06ce8633137add8db30ec23da7369bc54b95056dabd058b1d387f7d0e21e31e83
7
- data.tar.gz: 4ab25dc12edcd9d722e011c5b4ea496350c84c7aacee68de3333d150525bfacc04f451ee437166e4bd970970edfb17c55992cdf3b072dff15173ca4054da93ed
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
@@ -7,6 +7,7 @@ require 'pindo/module/build/buildhelper'
7
7
  require 'pindo/module/webserver/brotli_file_handler'
8
8
  require 'pindo/module/webserver/webgl_page_handler'
9
9
  require 'pindo/module/webserver/responsive_preview_handler'
10
+ require 'pindo/module/webserver/webgl_server_helper'
10
11
  require 'webrick' # 添加WebRick HTTP服务器
11
12
  require 'socket'
12
13
 
@@ -66,170 +67,6 @@ module Pindo
66
67
  end
67
68
  end
68
69
 
69
-
70
- # 获取本机局域网IP地址
71
- def get_local_ip
72
- ip = nil
73
- Socket.ip_address_list.each do |addr_info|
74
- if addr_info.ipv4? && !addr_info.ipv4_loopback?
75
- ip = addr_info.ip_address
76
- break
77
- end
78
- end
79
- return ip || 'localhost'
80
- end
81
-
82
- # 启动HTTP服务器
83
- def start_http_server(webgl_dir, port)
84
- begin
85
- # 确保目录存在
86
- unless File.directory?(webgl_dir)
87
- UI.puts("错误: WebGL目录不存在: #{webgl_dir}")
88
- return nil
89
- end
90
-
91
- # 检查index.html是否存在
92
- if !File.exist?(File.join(webgl_dir, "index.html"))
93
- UI.puts("警告: WebGL目录中未找到index.html文件")
94
- end
95
-
96
- # 创建自定义日志格式器,只记录错误
97
- custom_log = [
98
- [:error, WEBrick::AccessLog::COMMON_LOG_FORMAT],
99
- ]
100
-
101
- # 采用直接的方法配置服务器
102
- server = WEBrick::HTTPServer.new(
103
- :Port => port,
104
- :DocumentRoot => webgl_dir,
105
- :Logger => WEBrick::Log.new(nil, WEBrick::Log::ERROR),
106
- :AccessLog => @args_debug ? nil : [],
107
- :DoNotReverseLookup => true,
108
- :BindAddress => '0.0.0.0' # 绑定到所有网络接口,使其在局域网可访问
109
- )
110
-
111
- # 挂载一个特殊的处理器专门处理原始的index.html
112
- server.mount_proc("/rawindex.html") { |req, res|
113
- index_path = File.join(webgl_dir, "index.html")
114
- if File.exist?(index_path)
115
- # 读取原始HTML内容
116
- original_html = File.read(index_path)
117
-
118
- # 添加base标签以修复相对路径问题
119
- if !original_html.include?('<base href=')
120
- # 在<head>标签后插入base标签
121
- modified_html = original_html.gsub(/<head>/, '<head><base href="./">')
122
- res.body = modified_html
123
- else
124
- res.body = original_html
125
- end
126
-
127
- res.content_type = "text/html"
128
- res.status = 200
129
- else
130
- res.status = 404
131
- res.body = "WebGL index.html not found"
132
- end
133
- }
134
-
135
- # 设置根路径重定向处理器
136
- server.mount_proc("/") { |req, res|
137
- # 仅对根路径请求进行重定向
138
- if req.path == "/" || req.path == "/index.html"
139
- res.set_redirect(WEBrick::HTTPStatus::Found, "/responsive")
140
- else
141
- # 对于非根路径,使用普通的静态文件处理
142
- path = req.path
143
- file_path = File.join(webgl_dir, path[1..-1])
144
-
145
- if File.exist?(file_path) && !File.directory?(file_path)
146
- # 确定内容类型
147
- ext = File.extname(file_path)
148
- content_type = case ext
149
- when ".html" then "text/html"
150
- when ".js" then "application/javascript"
151
- when ".css" then "text/css"
152
- when ".png" then "image/png"
153
- when ".jpg", ".jpeg" then "image/jpeg"
154
- when ".gif" then "image/gif"
155
- when ".ico" then "image/x-icon"
156
- when ".wasm" then "application/wasm"
157
- when ".data" then "application/octet-stream"
158
- when ".json" then "application/json"
159
- else "application/octet-stream"
160
- end
161
-
162
- # 设置Brotli压缩相关的响应头
163
- if file_path.end_with?('.br')
164
- res.header["Content-Encoding"] = "br"
165
- file_content = File.binread(file_path)
166
- else
167
- file_content = File.read(file_path)
168
- end
169
-
170
- res.content_type = content_type
171
- res.body = file_content
172
- res.status = 200
173
- else
174
- res.status = 404
175
- res.body = "File not found: #{path}"
176
- end
177
- end
178
- }
179
-
180
- # 挂载响应式预览页面处理器
181
- server.mount("/responsive", Pindo::WebServer::ResponsivePreviewHandler, webgl_dir, port, @args_debug)
182
-
183
- # 挂载Brotli处理器(后缀为.br的文件)
184
- paths_with_br = []
185
- Find.find(webgl_dir) do |path|
186
- if path.end_with?('.br') && File.file?(path)
187
- rel_path = path.sub(webgl_dir, '')
188
- paths_with_br << rel_path
189
- end
190
- end
191
-
192
- # 挂载每个.br文件
193
- paths_with_br.each do |br_path|
194
- server.mount(br_path, Pindo::WebServer::BrotliFileHandler, webgl_dir, @args_debug)
195
- end
196
-
197
- # 只在调试模式下显示详细信息
198
- if @args_debug
199
- UI.puts("找到.br文件: #{paths_with_br.join(', ')}")
200
-
201
- UI.puts("WebGL目录内容:")
202
- Dir.entries(webgl_dir).each do |entry|
203
- next if entry == "." || entry == ".."
204
- UI.puts(" - #{entry}")
205
-
206
- # 递归显示子目录中的文件(限制为一级)
207
- entry_path = File.join(webgl_dir, entry)
208
- if File.directory?(entry_path)
209
- Dir.entries(entry_path).each do |subentry|
210
- next if subentry == "." || subentry == ".."
211
- UI.puts(" - #{entry}/#{subentry}")
212
- end
213
- end
214
- end
215
- end
216
-
217
- # 启动服务器并返回
218
- local_ip = get_local_ip
219
- UI.puts("启动WebGL HTTP服务器,端口: #{port},目录: #{webgl_dir}")
220
-
221
- UI.puts("本地访问地址: http://localhost:#{port}/")
222
- UI.puts("局域网访问地址: http://#{local_ip}:#{port}/")
223
- UI.puts("原始WebGL地址: http://localhost:#{port}/index.html")
224
-
225
- return server
226
- rescue Exception => e
227
- UI.puts("启动HTTP服务器失败: #{e.message}")
228
- UI.debug(e.backtrace.join("\n"), @args_debug)
229
- return nil
230
- end
231
- end
232
-
233
70
  def run
234
71
  pindo_project_dir = Dir.pwd
235
72
  build_helper = Pindo::BuildHelper.share_instance
@@ -248,12 +85,22 @@ module Pindo
248
85
  UI.debug("WebGL资源目录: #{webgl_res_dir}", @args_debug)
249
86
  UI.debug("目录存在: #{File.directory?(webgl_res_dir)}", @args_debug)
250
87
 
251
- # 启动HTTP服务器而不是简单打开目录
252
- 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)
253
90
 
254
91
  if server
255
- # 打开浏览器展示WebGL内容 - 使用根路径,会自动重定向到响应式预览
256
- system("open http://localhost:#{@args_port}/")
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")
257
104
 
258
105
  # 捕获Ctrl+C信号来优雅地关闭服务器
259
106
  trap('INT') { server.shutdown }