pindo 5.0.8 → 5.1.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: bbd9ab9e245a2445159ada59a12a793d1540e92b7560ef32cb4296a2fc146b6d
4
- data.tar.gz: c10f9d424c8a111512689cf6e076984d71de81c71248ea113edef3ebb22261e3
3
+ metadata.gz: c4b35412145fbb0e9fe730f9539f13cd1e09ab3e61410551afe4ac51c9144f33
4
+ data.tar.gz: 03f430b2b2919a302cd23634f0bfe90a818f81f0edd562fa4dc4a2097a32bfe1
5
5
  SHA512:
6
- metadata.gz: bd9326c3c907e9ea350b4a5efab1bb51303708aea1210e601951c5ad8ab8a17f453603e385723f584853c9abb52977c78582ebaa01238504ec8a246763dcd19b
7
- data.tar.gz: ae18025d46aaac286965ed1323e9070dd092a6dd6223e498be81f1c8141c8c0284e2d8465cb3e8258abd486cb61b95c9de9b1abeca12925bcedf96a6a132f3bb
6
+ metadata.gz: 3ba02d4282856b94492237aa0898543f750a67e192d6f5f01ca4e91d1a14d1aca11436d7df49867bf3e19bb617063dfc51ad642e94e40c6790239ea1367a72c7
7
+ data.tar.gz: f36fcc01bb367a57bf9f5eee1e617ee0c75143926d75a0ea13e370e032eab3de9118f25304c41f7b103bbb6cb635a47a3d850e0766fa72cb9a255deb1ab69d76
@@ -11,6 +11,7 @@ module Pindo
11
11
  class Autobuild < Ios
12
12
 
13
13
  include Appselect
14
+ include Pindo::Githelper
14
15
  # 命令的简要说明 - 打包iOS工程并发布到蒲公英
15
16
  self.summary = '打包iOS工程并发布到蒲公英'
16
17
 
@@ -119,8 +120,7 @@ module Pindo
119
120
  build_helper.delete_libtarget_firebase_shell(pindo_project_dir)
120
121
  end
121
122
 
122
-
123
-
123
+
124
124
  mainapp_bundleid= nil
125
125
  if @args_bundle_id
126
126
  mainapp_bundleid = @args_bundle_id
@@ -150,7 +150,14 @@ module Pindo
150
150
  if !app_info_obj.nil? && !app_info_obj["appName"].nil? && !app_info_obj["appName"].empty?
151
151
  scheme_name = app_info_obj["appName"]
152
152
  end
153
-
153
+ if scheme_name.nil? || scheme_name.empty? && is_git_directory?(local_repo_dir:pindo_project_dir)
154
+ current_git_root_path = git_root_directory(local_repo_dir: pindo_project_dir)
155
+ git_repo_name = File.basename(current_git_root_path)
156
+ if !git_repo_name.nil? && !git_repo_name.empty?
157
+ scheme_name = git_repo_name
158
+ end
159
+ end
160
+
154
161
  Pindo::Command::Ios::Debug::modify_cert_with_project(project_dir:pindo_project_dir, config_file:config_json_file, scheme_name:scheme_name)
155
162
 
156
163
  if File.exist?(File.join(pindo_project_dir, "Podfile"))
@@ -6,7 +6,7 @@ module Pindo
6
6
  class Debug < Ios
7
7
 
8
8
  include Appselect
9
-
9
+ include Pindo::Githelper
10
10
  include XcodeCertHelper
11
11
  self.summary = '更新iOS证书并使用新证书设置Xcode工程'
12
12
  self.description = <<-DESC
@@ -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,266 @@
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
+
9
+ module Pindo
10
+ class Command
11
+ class Web < Command
12
+ class Run < Web
13
+
14
+
15
+ self.summary = '运行Unity WebGL包'
16
+
17
+ # 命令的详细说明,包含用法示例
18
+ self.description = <<-DESC
19
+ 运行Unity WebGL包。
20
+
21
+ 使用示例:
22
+
23
+ $ pindo web run
24
+
25
+ DESC
26
+
27
+ # 命令的参数列表
28
+ self.arguments = [
29
+ # 暂无参数
30
+ ]
31
+
32
+ # 命令的选项列表
33
+ def self.options
34
+ [
35
+ # 添加HTTP服务器端口选项
36
+ ['--port', '指定HTTP服务器的端口,默认为8000'],
37
+ # 添加调试选项
38
+ ['--debug', '显示详细的调试信息']
39
+ ].concat(super)
40
+ end
41
+
42
+ def initialize(argv)
43
+ @args_port = argv.option('port', '8000').to_i # 添加端口参数,默认8000
44
+ @args_debug = argv.flag?('debug', false) # 是否显示调试信息
45
+
46
+ super
47
+ @additional_args = argv.remainder!
48
+ end
49
+
50
+ def validate!
51
+ super
52
+ end
53
+
54
+ # 添加UI模块作为输出辅助
55
+ module UI
56
+ def self.puts(message)
57
+ Kernel.puts message
58
+ end
59
+
60
+ def self.debug(message, debug_enabled)
61
+ Kernel.puts message if debug_enabled
62
+ end
63
+ end
64
+
65
+ # 处理.br扩展名请求的servlet
66
+ class BrotliFileHandler < WEBrick::HTTPServlet::AbstractServlet
67
+ def initialize(server, root_dir, debug=false)
68
+ super(server)
69
+ @root_dir = root_dir
70
+ @debug = debug
71
+ end
72
+
73
+ def do_GET(req, res)
74
+ # 只处理.br结尾的文件
75
+ unless req.path.end_with?('.br')
76
+ res.status = 404
77
+ return
78
+ end
79
+
80
+ file_path = File.join(@root_dir, req.path[1..-1])
81
+ UI.debug("处理.br文件请求: #{req.path}", @debug)
82
+
83
+ if File.exist?(file_path)
84
+ # 确定原始文件类型
85
+ base_name = File.basename(req.path, ".br")
86
+ ext = File.extname(base_name)
87
+
88
+ content_type = case ext
89
+ when ".js" then "application/javascript"
90
+ when ".wasm" then "application/wasm"
91
+ when ".data" then "application/octet-stream"
92
+ when ".json" then "application/json"
93
+ else "application/octet-stream"
94
+ end
95
+
96
+ # 读取文件
97
+ file_content = File.binread(file_path)
98
+
99
+ # 设置响应
100
+ res.status = 200
101
+ res.header["Content-Encoding"] = "br"
102
+ res.content_type = content_type
103
+ res.body = file_content
104
+ else
105
+ UI.debug("未找到.br文件: #{file_path}", @debug)
106
+ res.status = 404
107
+ end
108
+ end
109
+ end
110
+
111
+ # 自定义前端页面处理器,处理Unity WebGL的特殊文件加载需求
112
+ class WebGLPageHandler < WEBrick::HTTPServlet::AbstractServlet
113
+ def initialize(server, root_dir, debug=false)
114
+ super(server)
115
+ @root_dir = root_dir
116
+ @debug = debug
117
+ end
118
+
119
+ def do_GET(req, res)
120
+ path = req.path
121
+ path = "/index.html" if path == "/"
122
+
123
+ file_path = File.join(@root_dir, path[1..-1])
124
+
125
+ if File.exist?(file_path)
126
+ # 确定内容类型
127
+ ext = File.extname(file_path)
128
+ content_type = case ext
129
+ when ".html" then "text/html"
130
+ when ".js" then "application/javascript"
131
+ when ".css" then "text/css"
132
+ when ".png" then "image/png"
133
+ when ".jpg", ".jpeg" then "image/jpeg"
134
+ when ".gif" then "image/gif"
135
+ when ".ico" then "image/x-icon"
136
+ else "application/octet-stream"
137
+ end
138
+
139
+ res.content_type = content_type
140
+ res.body = File.read(file_path)
141
+ res.status = 200
142
+ else
143
+ res.status = 404
144
+ end
145
+ end
146
+ end
147
+
148
+ # 启动HTTP服务器
149
+ def start_http_server(webgl_dir, port)
150
+ begin
151
+ # 确保目录存在
152
+ unless File.directory?(webgl_dir)
153
+ UI.puts("错误: WebGL目录不存在: #{webgl_dir}")
154
+ return nil
155
+ end
156
+
157
+ # 检查index.html是否存在
158
+ if !File.exist?(File.join(webgl_dir, "index.html"))
159
+ UI.puts("警告: WebGL目录中未找到index.html文件")
160
+ end
161
+
162
+ # 创建自定义日志格式器,只记录错误
163
+ custom_log = [
164
+ [:error, WEBrick::AccessLog::COMMON_LOG_FORMAT],
165
+ ]
166
+
167
+ # 采用直接的方法配置服务器
168
+ server = WEBrick::HTTPServer.new(
169
+ :Port => port,
170
+ :DocumentRoot => webgl_dir,
171
+ :Logger => WEBrick::Log.new(nil, WEBrick::Log::ERROR),
172
+ :AccessLog => @args_debug ? nil : [],
173
+ :DoNotReverseLookup => true
174
+ )
175
+
176
+ # 挂载处理程序
177
+ server.mount("/", WebGLPageHandler, webgl_dir, @args_debug)
178
+
179
+ # 挂载Brotli处理器(后缀为.br的文件)
180
+ paths_with_br = []
181
+ Find.find(webgl_dir) do |path|
182
+ if path.end_with?('.br') && File.file?(path)
183
+ rel_path = path.sub(webgl_dir, '')
184
+ paths_with_br << rel_path
185
+ end
186
+ end
187
+
188
+ # 挂载每个.br文件
189
+ paths_with_br.each do |br_path|
190
+ server.mount(br_path, BrotliFileHandler, webgl_dir, @args_debug)
191
+ end
192
+
193
+ # 只在调试模式下显示详细信息
194
+ if @args_debug
195
+ UI.puts("找到.br文件: #{paths_with_br.join(', ')}")
196
+
197
+ UI.puts("WebGL目录内容:")
198
+ Dir.entries(webgl_dir).each do |entry|
199
+ next if entry == "." || entry == ".."
200
+ UI.puts(" - #{entry}")
201
+
202
+ # 递归显示子目录中的文件(限制为一级)
203
+ entry_path = File.join(webgl_dir, entry)
204
+ if File.directory?(entry_path)
205
+ Dir.entries(entry_path).each do |subentry|
206
+ next if subentry == "." || subentry == ".."
207
+ UI.puts(" - #{entry}/#{subentry}")
208
+ end
209
+ end
210
+ end
211
+ end
212
+
213
+ # 启动服务器并返回
214
+ UI.puts("启动WebGL HTTP服务器,端口: #{port},目录: #{webgl_dir}")
215
+ UI.puts("请访问: http://localhost:#{port}/index.html")
216
+ return server
217
+ rescue Exception => e
218
+ UI.puts("启动HTTP服务器失败: #{e.message}")
219
+ UI.debug(e.backtrace.join("\n"), @args_debug)
220
+ return nil
221
+ end
222
+ end
223
+
224
+ def run
225
+ pindo_project_dir = Dir.pwd
226
+ build_helper = Pindo::BuildHelper.share_instance
227
+ project_type = build_helper.project_type(pindo_project_dir)
228
+
229
+ webgl_res_dir = Dir.pwd
230
+ case project_type
231
+ when :unity
232
+ webgl_res_dir = File.join(pindo_project_dir, "GoodPlatform/WebGL/build")
233
+ end
234
+
235
+ # 确保路径规范化
236
+ webgl_res_dir = File.expand_path(webgl_res_dir)
237
+
238
+ # 只在调试模式下显示这些信息
239
+ UI.debug("WebGL资源目录: #{webgl_res_dir}", @args_debug)
240
+ UI.debug("目录存在: #{File.directory?(webgl_res_dir)}", @args_debug)
241
+
242
+ # 启动HTTP服务器而不是简单打开目录
243
+ server = start_http_server(webgl_res_dir, @args_port)
244
+
245
+ if server
246
+ # 打开浏览器展示WebGL内容
247
+ system("open http://localhost:#{@args_port}/index.html")
248
+
249
+ # 捕获Ctrl+C信号来优雅地关闭服务器
250
+ trap('INT') { server.shutdown }
251
+ trap('TERM') { server.shutdown }
252
+
253
+ # 启动服务器主循环
254
+ UI.puts("服务器运行中,按Ctrl+C停止...")
255
+ server.start
256
+ else
257
+ # 如果服务器启动失败,回退到简单打开目录
258
+ UI.puts("无法启动HTTP服务器,将直接打开WebGL目录")
259
+ system "open #{webgl_res_dir}"
260
+ end
261
+ end
262
+ end
263
+ end
264
+ end
265
+ end
266
+
@@ -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.8"
3
+ VERSION = "5.1.0"
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.8
4
+ version: 5.1.0
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