pindo 5.0.9 → 5.1.1

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: '08d012f8edb60e226490c213a446837bc36c852d531d5ac5de0a57b3ff5e525c'
4
- data.tar.gz: 4d32c862affc436c18d9ff6cacdf00e332a868ca9fc07208d0c2ba29b1516ff1
3
+ metadata.gz: '05592fa0b0cb7bf97bec159a83fd562ab7fd0cbd08305e4f1a71cd827612bf01'
4
+ data.tar.gz: 717a3c0b905d7482974d04c4e901ec8f3fefe08a95dc1128af5263747a2435bd
5
5
  SHA512:
6
- metadata.gz: 8afdcda6e2f03492f285e44d140259b9c609470a5911eb8008c23788658bf076ee2eec5210afedf2b2e03faf717f3820132ccb883cc7d0b32b94ae9e0971f31c
7
- data.tar.gz: 51a451ef991d341d6f4621cdd391ec9b4fd7267c1fa0bba045f35375252fccf8a6feb29474fa8fb49776762a5138026a8251ff3e6885e95bf67c839976ef013e
6
+ metadata.gz: 4b7772dd3ad4793df33b3ff90d20847b2676ab0c6b6583d0fa176eb43c010e4bde2e6e2755d1009a4b3bd92c14ab34b8690f97074b9ba7f3042d059abba27dfb
7
+ data.tar.gz: bbe8a06d9b55eaf57d247a83a8976b46ce2922ec8f4a1538ee2e889d09ce4638a9216d70eca2b7a3eb1fb3ec7d6c54c70e6188e98d9b0579fd78814501a6aee2
@@ -120,8 +120,7 @@ module Pindo
120
120
  build_helper.delete_libtarget_firebase_shell(pindo_project_dir)
121
121
  end
122
122
 
123
-
124
-
123
+
125
124
  mainapp_bundleid= nil
126
125
  if @args_bundle_id
127
126
  mainapp_bundleid = @args_bundle_id
@@ -87,7 +87,6 @@ module Pindo
87
87
 
88
88
  if @args_upload_flag
89
89
  build_helper = Pindo::BuildHelper.share_instance
90
- build_helper.check_check_and_install_cliff(pindo_project_dir)
91
90
  is_need_add_tag,tag_action_parms = build_helper.check_is_need_add_tag?(pindo_project_dir)
92
91
  if is_need_add_tag
93
92
  Pindo::Command::Dev::Tag::run(tag_action_parms)
@@ -0,0 +1,165 @@
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 Web < Command
12
+ class Autobuild < Web
13
+
14
+ include Appselect
15
+ include Pindo::Githelper
16
+
17
+ self.summary = '打包Unity WebGL包'
18
+
19
+ # 命令的详细说明,包含用法示例
20
+ self.description = <<-DESC
21
+ 编译WebGL包并支持上传到测试平台。
22
+
23
+ 支持功能:
24
+
25
+ * 编译Debug包
26
+
27
+ * 上传到测试平台
28
+
29
+ * 发送测试通知
30
+
31
+ 使用示例:
32
+
33
+ $ pindo web autobuild # 编译Debug包
34
+
35
+ $ pindo web autobuild --upload # 编译并上传
36
+
37
+ $ pindo web autobuild --proj=myapp # 指定项目名称
38
+
39
+ $ pindo web autobuild --run # 编译完成后再本地打开webgl包
40
+ DESC
41
+
42
+ # 命令的参数列表
43
+ self.arguments = [
44
+ # 暂无参数
45
+ ]
46
+
47
+ # 命令的选项列表
48
+ def self.options
49
+ [
50
+ ['--bundleid', '指定打包的bundleID'],
51
+ # 指定上传到蒲公英的项目
52
+ ['--proj', '指定上传到测试平台的项目名称'],
53
+ # 上传编译包
54
+ ['--upload', '上传编译后的ipa到测试平台'],
55
+ # 发送通知
56
+ ['--send', '上传成功后发送测试通知'],
57
+ # 编译完成后再本地打开webgl包
58
+ ['--run', '编译完成后再本地打开webgl包']
59
+ ].concat(super)
60
+ end
61
+
62
+ def initialize(argv)
63
+
64
+ @args_deploy_flag = argv.flag?('deploy', false)
65
+ @args_adhoc_flag = argv.flag?('adhoc', false)
66
+ @args_upload_flag = argv.flag?('upload', false)
67
+ @args_send_flag = argv.flag?('send', false)
68
+ @args_proj_name = argv.option('proj')
69
+ @args_bundle_id = argv.option('bundleid')
70
+ @args_run_flag = argv.flag?('run', false)
71
+
72
+ if @args_send_flag
73
+ @args_upload_flag = true
74
+ end
75
+
76
+ super
77
+ @additional_args = argv.remainder!
78
+ end
79
+
80
+ def validate!
81
+
82
+ super
83
+ end
84
+
85
+ def run
86
+ pindo_project_dir = Dir.pwd
87
+
88
+ build_helper = Pindo::BuildHelper.share_instance
89
+ project_type = build_helper.project_type(pindo_project_dir)
90
+
91
+ args_temp = []
92
+ args_temp << "--proj=#{@args_proj_name}" if @args_proj_name
93
+ args_temp << "--upload" if @args_upload_flag
94
+ args_temp << "--send" if @args_send_flag
95
+ case project_type
96
+ when :ios
97
+ puts "iOS 工程, 请使用 pindo ios autobuild"
98
+ when :android
99
+ puts "Android 工程, 请使用 pindo android build"
100
+
101
+ when :unity
102
+ web_autobuild
103
+ else
104
+ raise Informative, "当前目录不是工程目录,不能编译"
105
+ end
106
+ end
107
+
108
+ def web_autobuild
109
+ pindo_project_dir = Dir.pwd
110
+ build_helper = Pindo::BuildHelper.share_instance
111
+
112
+ if @args_upload_flag
113
+ is_need_add_tag,tag_action_parms = build_helper.check_is_need_add_tag?(pindo_project_dir)
114
+ if is_need_add_tag
115
+ Pindo::Command::Dev::Tag::run(tag_action_parms)
116
+ end
117
+ end
118
+
119
+ unity_helper = Pindo::Client::UnityHelper.share_instance
120
+ project_unity_version = unity_helper.get_unity_version(pindo_project_dir)
121
+ puts
122
+ puts "工程的Unity版本: #{project_unity_version}"
123
+ unity_exe_path = unity_helper.find_unity_path(project_unity_version:project_unity_version, force_change_version: @force_select_unity)
124
+ puts "选择的Unity路径: #{unity_exe_path}"
125
+ puts
126
+
127
+ app_info_obj = nil
128
+ if @args_upload_flag
129
+ proj_name = @args_proj_name
130
+ app_info_obj = PgyerHelper.share_instace.prepare_upload(working_directory:Dir.pwd, proj_name:proj_name)
131
+ end
132
+
133
+ web_export_dir = File.join(pindo_project_dir, "GoodPlatform/WebGL")
134
+ unity_helper.build_project(unity_exe_full_path:unity_exe_path, project_path:pindo_project_dir, platform:'WebGL')
135
+
136
+ build_path = File.join(web_export_dir, "build", "index.{html}")
137
+ html_file_upload = Dir.glob(build_path).max_by {|f| File.mtime(f)}
138
+ puts "html_file_upload: #{html_file_upload}"
139
+ puts "app_info_obj: #{app_info_obj}"
140
+
141
+ if !html_file_upload.nil? && !app_info_obj.nil?
142
+ description = nil
143
+ result_data = PgyerHelper.share_instace.start_upload(app_info_obj:app_info_obj, ipa_file_upload:html_file_upload, description:description)
144
+ if !result_data.nil? && !result_data["data"].nil? && !result_data["data"]["id"].nil?
145
+ msg_data = PgyerHelper.share_instace.make_msg_data(app_info_obj:app_info_obj, app_version_info_obj:result_data["data"])
146
+ PgyerHelper.share_instace.print_app_version_info(msg_data:msg_data)
147
+ if @args_send_flag
148
+ PgyerHelper.share_instace.send_apptest_wechat_msg(msg_data:msg_data)
149
+ end
150
+ end
151
+ end
152
+
153
+ system "open #{pindo_project_dir}"
154
+
155
+ if @args_run_flag
156
+ Pindo::Command::Web::Run.run([])
157
+ end
158
+ end
159
+
160
+
161
+ end
162
+ end
163
+ end
164
+ end
165
+
@@ -0,0 +1,282 @@
1
+ require 'highline/import'
2
+ require 'xcodeproj'
3
+ require 'find'
4
+ require 'fileutils'
5
+ require 'pindo/base/executable'
6
+ require 'pindo/module/build/buildhelper'
7
+ require 'webrick' # 添加WebRick HTTP服务器
8
+ require 'socket'
9
+
10
+ module Pindo
11
+ class Command
12
+ class Web < Command
13
+ class Run < Web
14
+
15
+
16
+ self.summary = '运行Unity WebGL包'
17
+
18
+ # 命令的详细说明,包含用法示例
19
+ self.description = <<-DESC
20
+ 运行Unity WebGL包。
21
+
22
+ 使用示例:
23
+
24
+ $ pindo web run
25
+
26
+ DESC
27
+
28
+ # 命令的参数列表
29
+ self.arguments = [
30
+ # 暂无参数
31
+ ]
32
+
33
+ # 命令的选项列表
34
+ def self.options
35
+ [
36
+ # 添加HTTP服务器端口选项
37
+ ['--port', '指定HTTP服务器的端口,默认为8000'],
38
+ # 添加调试选项
39
+ ['--debug', '显示详细的调试信息']
40
+ ].concat(super)
41
+ end
42
+
43
+ def initialize(argv)
44
+ @args_port = argv.option('port', '8000').to_i # 添加端口参数,默认8000
45
+ @args_debug = argv.flag?('debug', false) # 是否显示调试信息
46
+
47
+ super
48
+ @additional_args = argv.remainder!
49
+ end
50
+
51
+ def validate!
52
+ super
53
+ end
54
+
55
+ # 添加UI模块作为输出辅助
56
+ module UI
57
+ def self.puts(message)
58
+ Kernel.puts message
59
+ end
60
+
61
+ def self.debug(message, debug_enabled)
62
+ Kernel.puts message if debug_enabled
63
+ end
64
+ end
65
+
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
+ def run
241
+ pindo_project_dir = Dir.pwd
242
+ build_helper = Pindo::BuildHelper.share_instance
243
+ project_type = build_helper.project_type(pindo_project_dir)
244
+
245
+ webgl_res_dir = Dir.pwd
246
+ case project_type
247
+ when :unity
248
+ webgl_res_dir = File.join(pindo_project_dir, "GoodPlatform/WebGL/build")
249
+ end
250
+
251
+ # 确保路径规范化
252
+ webgl_res_dir = File.expand_path(webgl_res_dir)
253
+
254
+ # 只在调试模式下显示这些信息
255
+ UI.debug("WebGL资源目录: #{webgl_res_dir}", @args_debug)
256
+ UI.debug("目录存在: #{File.directory?(webgl_res_dir)}", @args_debug)
257
+
258
+ # 启动HTTP服务器而不是简单打开目录
259
+ server = start_http_server(webgl_res_dir, @args_port)
260
+
261
+ if server
262
+ # 打开浏览器展示WebGL内容
263
+ system("open http://localhost:#{@args_port}/index.html")
264
+
265
+ # 捕获Ctrl+C信号来优雅地关闭服务器
266
+ trap('INT') { server.shutdown }
267
+ trap('TERM') { server.shutdown }
268
+
269
+ # 启动服务器主循环
270
+ UI.puts("服务器运行中,按Ctrl+C停止...")
271
+ server.start
272
+ else
273
+ # 如果服务器启动失败,回退到简单打开目录
274
+ UI.puts("无法启动HTTP服务器,将直接打开WebGL目录")
275
+ system "open #{webgl_res_dir}"
276
+ end
277
+ end
278
+ end
279
+ end
280
+ end
281
+ end
282
+
@@ -0,0 +1,14 @@
1
+
2
+
3
+ require 'pindo/command/web/autobuild'
4
+ require 'pindo/command/web/run'
5
+
6
+ module Pindo
7
+ class Command
8
+
9
+ class Web < Command
10
+ self.abstract_command = true
11
+ self.summary = 'Web 相关命令'
12
+ end
13
+ end
14
+ end
data/lib/pindo/command.rb CHANGED
@@ -49,7 +49,8 @@ module Pindo
49
49
  require 'pindo/command/unity'
50
50
  require 'pindo/command/ios'
51
51
  require 'pindo/command/android'
52
-
52
+ require 'pindo/command/web'
53
+
53
54
  attr_accessor :args_help_flag
54
55
  alias_method :args_help_flag?, :args_help_flag
55
56
 
@@ -149,6 +149,7 @@ module Pindo
149
149
  if !ipa_file_upload.nil? &&
150
150
  File.extname(ipa_file_upload).eql?(".app") &&
151
151
  File.extname(ipa_file_upload).eql?(".apk")
152
+
152
153
  mac_app_path = ipa_file_upload
153
154
  ipa_base_dir = File.dirname(ipa_file_upload)
154
155
  ipa_base_name = File.basename(ipa_file_upload, File.extname(ipa_file_upload))
@@ -167,8 +168,39 @@ module Pindo
167
168
  Dir.chdir(current_dir)
168
169
  end
169
170
  end
171
+ puts "ipa_file_upload: ++++1"
172
+ if !ipa_file_upload.nil? &&
173
+ File.extname(ipa_file_upload).eql?(".html")
170
174
 
175
+ web_res_path = File.dirname(ipa_file_upload)
176
+ web_zip_dir = File.dirname(web_res_path)
177
+ web_build_name = "webgl_build"
178
+ # web_build_version = "1.0.0"
179
+ begin
180
+ if File.exist?(File.join(web_zip_dir, "web_build_info.json"))
181
+ json_data = JSON.parse(File.read(File.join(web_zip_dir, "web_build_info.json")))
182
+ web_build_name = json_data["productName"]
183
+ # web_build_version = json_data["version"]
184
+ end
185
+ rescue StandardError => e
171
186
 
187
+ end
188
+ current_project_dir = Dir.pwd
189
+ web_build_name = web_build_name.downcase.strip.gsub(/[\s\-_]/, '')
190
+ web_res_zip_fullname = File.join(web_zip_dir, web_build_name + ".zip")
191
+ if File.exist?(web_res_zip_fullname)
192
+ FileUtils.rm_rf(web_res_zip_fullname)
193
+ end
194
+ Zip::File.open(web_res_zip_fullname, Zip::File::CREATE) do |zipfile|
195
+ Dir.chdir web_res_path
196
+ Dir.glob("**/*").reject {|fn| File.directory?(fn) }.each do |file|
197
+ zipfile.add(file.sub(web_res_path + '/', ''), file)
198
+ end
199
+ end
200
+ Dir.chdir(current_project_dir)
201
+ ipa_file_upload = web_res_zip_fullname
202
+ end
203
+ puts "ipa_file_upload: ++++2"
172
204
  unless !ipa_file_upload.nil? && File.exist?(ipa_file_upload)
173
205
  return
174
206
  end
data/lib/pindo/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Pindo
2
2
 
3
- VERSION = "5.0.9"
3
+ VERSION = "5.1.1"
4
4
 
5
5
  class VersionCheck
6
6
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pindo
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.9
4
+ version: 5.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - wade
@@ -389,6 +389,9 @@ files:
389
389
  - lib/pindo/command/utils/tgate.rb
390
390
  - lib/pindo/command/utils/xcassets.rb
391
391
  - lib/pindo/command/utils/xcassets.sh
392
+ - lib/pindo/command/web.rb
393
+ - lib/pindo/command/web/autobuild.rb
394
+ - lib/pindo/command/web/run.rb
392
395
  - lib/pindo/config/pindoconfig.rb
393
396
  - lib/pindo/config/pindouserlocalconfig.rb
394
397
  - lib/pindo/module/android/apk_helper.rb