pindo 5.0.4 → 5.0.5

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: 8e7508977271b8a9092068bffb6c429402f3f4f3ddf9d9c8fdd3e4c7b7580522
4
- data.tar.gz: 912474cf184b1621c147f5c713f374e48f40deeff97306504fa5745fe3648cd2
3
+ metadata.gz: 3875a278d39ee97be6efefd2e2691f398cb0ec145c079e6ff261181e1f7c4cde
4
+ data.tar.gz: 463a3b8a6b68376a35017ed3fe9457c86d06ee60eeb3404d02e3aaaca2f152d5
5
5
  SHA512:
6
- metadata.gz: efc6aeff8688764f201c3723e8b8e391ab02c9abef5d7b9bee68d30a821903549b7343b62e02a02aa8c66918b048c3cc4652523380ab4e08e6a34d96ce8eca6a
7
- data.tar.gz: 92671cf31234549e38c59c2a673ff8bc181ef580b0ae5698c69b3179384346d03d3b8966f4b932348c23fd6cbfd1e7af3516e5431da9bdc841969f274327ad7b
6
+ metadata.gz: 693df9ad920466ab0f93c13e0f5774d970fa24fefb66ff7f0722ca56e25d687098cddb8808113cc4c02feb97d75d7e02ee4b78a6de9f9ec33c545bf8748c910d
7
+ data.tar.gz: ac047d01af53a8b1be66faf6e6aa667e64d67135d32c1d4c8fc4313a59f4df2bb5b18032d2f659eec81f21c3c43a4f8bccfbc6aa0fe94030b86f82e42cf6facd
@@ -545,7 +545,7 @@ module Pindo
545
545
  end
546
546
 
547
547
  git!(%W(-C #{project_dir} reset --hard))
548
- git!(%W(-C #{project_dir} clean -dfx))
548
+ git!(%W(-C #{project_dir} clean -df))
549
549
  git!(%W(-C #{project_dir} branch --set-upstream-to=origin/#{branch} #{branch}))
550
550
  git!(%W(-C #{project_dir} pull))
551
551
  end
@@ -0,0 +1,121 @@
1
+ require 'highline/import'
2
+ require 'fileutils'
3
+ require 'pindo/base/executable'
4
+ require 'pindo/module/build/buildhelper'
5
+ require 'pindo/module/android/build_helper'
6
+
7
+ module Pindo
8
+ class Command
9
+ class Android < Command
10
+ class Autobuild < Android
11
+ include Appselect
12
+
13
+ self.summary = '打包Android工程并发布到蒲公英'
14
+ self.description = <<-DESC
15
+ 编译Android包并支持上传到测试平台。
16
+
17
+ 支持功能:
18
+ * 编译Debug/Release包
19
+ * 上传到测试平台
20
+ * 发送测试通知
21
+
22
+ 使用示例:
23
+ $ pindo android autobuild # 编译Debug包
24
+ $ pindo android autobuild --release # 编译Release包
25
+ $ pindo android autobuild --upload # 编译并上传
26
+ $ pindo android autobuild --send # 编译上传并发送通知
27
+ $ pindo android autobuild --proj=myapp # 指定项目名称
28
+
29
+ DESC
30
+
31
+ def self.options
32
+ [
33
+ ['--release', '使用release模式构建'],
34
+ ['--proj', '指定上传到测试平台的项目名称'],
35
+ ['--upload', '上传编译后的apk到测试平台'],
36
+ ['--send', '上传成功后发送测试通知']
37
+ ].concat(super)
38
+ end
39
+
40
+ def initialize(argv)
41
+ @args_release_flag = argv.flag?('release', false)
42
+ @args_upload_flag = argv.flag?('upload', false)
43
+ @args_send_flag = argv.flag?('send', false)
44
+ @args_proj_name = argv.option('proj')
45
+
46
+
47
+ if @args_send_flag
48
+ @args_upload_flag = true
49
+ end
50
+
51
+ super
52
+ @additional_args = argv.remainder!
53
+ end
54
+
55
+ def run
56
+ pindo_project_dir = Dir.pwd
57
+ build_helper = Pindo::BuildHelper.share_instance
58
+ project_type = build_helper.project_type(pindo_project_dir)
59
+
60
+ args_temp = []
61
+ args_temp << "--proj=#{@args_proj_name}" if @args_proj_name
62
+ args_temp << "--upload" if @args_upload_flag
63
+ args_temp << "--send" if @args_send_flag
64
+
65
+ case project_type
66
+ when :ios
67
+ puts "iOS 工程, 请使用 pindo ios build"
68
+ when :android
69
+ android_autobuild
70
+ when :unity
71
+ Pindo::Command::Unity::Apk::run(args_temp)
72
+ else
73
+ raise Informative, "当前目录不是工程目录,不能编译"
74
+ end
75
+ end
76
+
77
+ private
78
+
79
+ def android_autobuild
80
+
81
+ pindo_project_dir = Dir.pwd
82
+ build_helper = Pindo::BuildHelper.share_instance
83
+
84
+ if @args_upload_flag
85
+ build_helper.check_check_and_install_cliff(pindo_project_dir)
86
+ is_need_add_tag,tag_action_parms = build_helper.check_is_need_add_tag?(pindo_project_dir)
87
+ if is_need_add_tag
88
+ Pindo::Command::Dev::Tag::run(tag_action_parms)
89
+ end
90
+ end
91
+
92
+ app_info_obj = nil
93
+ if @args_upload_flag
94
+ proj_name = @args_proj_name
95
+ app_info_obj = PgyerHelper.share_instace.prepare_upload(working_directory:Dir.pwd, proj_name:proj_name)
96
+ end
97
+
98
+ android_build_helper = Pindo::AndroidBuildHelper.share_instance
99
+ apk_path = android_build_helper.auto_build_apk(pindo_project_dir, !@args_release_flag)
100
+ ipa_file_upload = Dir.glob(apk_path).max_by {|f| File.mtime(f)}
101
+
102
+ if !ipa_file_upload.nil? && !app_info_obj.nil?
103
+ description = nil
104
+ result_data = PgyerHelper.share_instace.start_upload(app_info_obj:app_info_obj, ipa_file_upload:ipa_file_upload, description:description)
105
+ if !result_data.nil? && !result_data["data"].nil? && !result_data["data"]["id"].nil?
106
+ msg_data = PgyerHelper.share_instace.make_msg_data(app_info_obj:app_info_obj, app_version_info_obj:result_data["data"])
107
+ PgyerHelper.share_instace.print_app_version_info(msg_data:msg_data)
108
+ if @args_send_flag
109
+ PgyerHelper.share_instace.send_apptest_wechat_msg(msg_data:msg_data)
110
+ end
111
+ end
112
+ end
113
+
114
+ system "open #{pindo_project_dir}"
115
+
116
+
117
+ end
118
+ end
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,113 @@
1
+ require 'highline/import'
2
+ require 'fileutils'
3
+ require 'json'
4
+ require 'pindo/module/build/buildhelper'
5
+ require 'pindo/module/android/build_helper'
6
+
7
+ module Pindo
8
+ class Command
9
+ class Android < Command
10
+ class Build < Android
11
+
12
+ self.summary = '编译Android工程并支持上传apk'
13
+ self.description = <<-DESC
14
+ 编译Android工程并生成apk文件。
15
+
16
+ 支持功能:
17
+ * 编译工程
18
+ * 生成APK文件
19
+ * 支持上传分发
20
+
21
+ 使用示例:
22
+ $ pindo android build # 仅编译
23
+ $ pindo android build --upload # 编译并上传
24
+ $ pindo android build --send # 编译并发送通知
25
+ $ pindo android build --proj=myapp # 指定项目名称
26
+ DESC
27
+
28
+ def self.options
29
+ [
30
+ ['--proj', '指定上传到测试平台的项目名称'],
31
+ ['--upload', '上传编译后的apk到测试平台'],
32
+ ['--send', '上传成功后发送测试通知'],
33
+ ].concat(super)
34
+ end
35
+
36
+ def initialize(argv)
37
+ @args_upload_flag = argv.flag?('upload', false)
38
+ @args_send_flag = argv.flag?('send', false)
39
+ @args_proj_name = argv.option('proj')
40
+
41
+ if @args_send_flag
42
+ @args_upload_flag = true
43
+ end
44
+
45
+ super
46
+ @additional_args = argv.remainder!
47
+ end
48
+
49
+ def run
50
+
51
+ pindo_project_dir = Dir.pwd
52
+
53
+ build_helper = Pindo::BuildHelper.share_instance
54
+ project_type = build_helper.project_type(pindo_project_dir)
55
+
56
+ args_temp = []
57
+ args_temp << "--proj=#{@args_proj_name}" if @args_proj_name
58
+ args_temp << "--upload" if @args_upload_flag
59
+ args_temp << "--send" if @args_send_flag
60
+ case project_type
61
+ when :ios
62
+ raise Informative, "iOS 工程, 请使用 pindo ios build"
63
+ when :android
64
+ android_build
65
+ when :unity
66
+ raise Informative, "Unity 工程, 请使用 pindo unity apk"
67
+ else
68
+ raise Informative, "当前目录不是工程目录,不能编译"
69
+ end
70
+ end
71
+
72
+ def android_build
73
+ pindo_project_dir = Dir.pwd
74
+ build_helper = Pindo::BuildHelper.share_instance
75
+ if @args_upload_flag
76
+ build_helper.check_check_and_install_cliff(pindo_project_dir)
77
+ is_need_add_tag,tag_action_parms = build_helper.check_is_need_add_tag?(pindo_project_dir)
78
+ if is_need_add_tag
79
+ Pindo::Command::Dev::Tag::run(tag_action_parms)
80
+ end
81
+ end
82
+
83
+ app_info_obj = nil
84
+ if @args_upload_flag
85
+ proj_name = @args_proj_name
86
+ app_info_obj = PgyerHelper.share_instace.prepare_upload(working_directory:Dir.pwd, proj_name:proj_name)
87
+ end
88
+
89
+
90
+ android_build_helper = Pindo::AndroidBuildHelper.share_instance
91
+ apk_path = android_build_helper.auto_build_apk(pindo_project_dir, !@args_release_flag)
92
+ ipa_file_upload = Dir.glob(apk_path).max_by {|f| File.mtime(f)}
93
+
94
+ if !ipa_file_upload.nil? && !app_info_obj.nil?
95
+
96
+ description = nil
97
+ result_data = PgyerHelper.share_instace.start_upload(app_info_obj:app_info_obj, ipa_file_upload:ipa_file_upload, description:description)
98
+ if !result_data.nil? && !result_data["data"].nil? && !result_data["data"]["id"].nil?
99
+ msg_data = PgyerHelper.share_instace.make_msg_data(app_info_obj:app_info_obj, app_version_info_obj:result_data["data"])
100
+
101
+ PgyerHelper.share_instace.print_app_version_info(msg_data:msg_data)
102
+ if @args_send_flag
103
+ PgyerHelper.share_instace.send_apptest_wechat_msg(msg_data:msg_data)
104
+ end
105
+ end
106
+ end
107
+
108
+ system "open #{pindo_project_dir}"
109
+ end
110
+ end
111
+ end
112
+ end
113
+ end
@@ -11,12 +11,12 @@ module Pindo
11
11
  # 详细说明
12
12
  self.description = <<-DESC
13
13
  编译Android Debug包并支持上传到测试平台。
14
-
14
+
15
15
  支持功能:
16
16
 
17
17
  * 编译Debug包
18
18
 
19
- * 上传到测试平台
19
+ * 上传到测试平台
20
20
 
21
21
  * 发送测试通知
22
22
 
@@ -30,6 +30,12 @@ module Pindo
30
30
 
31
31
  $ pindo android debug --proj=myapp # 指定项目名称
32
32
 
33
+ $ pindo android debug --release # 编译Release包
34
+
35
+ $ pindo android debug --dsign # 测试获取签名文件
36
+
37
+ $ pindo android debug --direct # 直接打包而不编译 unity 子 Lib
38
+
33
39
  DESC
34
40
 
35
41
  # 命令参数
@@ -40,34 +46,74 @@ module Pindo
40
46
  # 命令选项
41
47
  def self.options
42
48
  [
43
- ['--proj', '指定上传到测试平台的项目名称'],
44
- ['--upload', '上传编译后的apk到测试平台'],
45
- ['--send', '上传成功后发送测试通知']
49
+ ['--proj', '指定上传到测试平台的项目名称'],
50
+ ['--upload', '上传编译后的apk到测试平台'],
51
+ ['--send', '上传成功后发送测试通知'],
52
+ ['--release', '使用release模式构建'],
53
+ ['--dsign', '获取签名文件'],
54
+ ['--direct', '直接打包而不编译 unity 子 Lib']
46
55
  ].concat(super)
47
56
  end
48
57
 
49
58
  def initialize(argv)
50
- @args_adhoc_flag = argv.flag?('adhoc', false)
51
- @args_deploy_flag = argv.flag?('deploy', false)
52
- @args_macos_flag = argv.flag?('macos', false)
59
+ @args_release_flag = argv.flag?('release', false)
53
60
  @upload_flag = argv.flag?('upload', false)
54
61
  @send_flag = argv.flag?('send', false)
55
62
  @proj_name = argv.option('proj')
56
-
63
+ @args_dsign_flag = argv.flag?('dsign', false)
57
64
  if @send_flag
58
65
  @upload_flag = true
59
66
  end
60
-
67
+ @args_direct_flag = argv.flag?('direct', false)
68
+
61
69
  super
62
70
  end
63
71
 
64
72
  def run
65
- # TODO: 实现编译和上传逻辑
66
- puts "Android Debug包编译和上传命令"
67
-
73
+ pindo_project_dir = Dir.pwd
74
+
75
+ # 如果设置了 dsign 标志,则执行签名文件获取并直接返回
76
+ if @args_dsign_flag
77
+ Pindo::AndroidBuildHelper.share_instance.dsign(pindo_project_dir, !@args_release_flag)
78
+ return
79
+ end
80
+
81
+ build_helper = Pindo::BuildHelper.share_instance
82
+
83
+ if @args_upload_flag
84
+ build_helper.check_check_and_install_cliff(pindo_project_dir)
85
+ is_need_add_tag,tag_action_parms = build_helper.check_is_need_add_tag?(pindo_project_dir)
86
+ if is_need_add_tag
87
+ Pindo::Command::Dev::Tag::run(tag_action_parms)
88
+ end
89
+ end
90
+
91
+ app_info_obj = nil
92
+ if @args_upload_flag
93
+ proj_name = @args_proj_name
94
+ app_info_obj = PgyerHelper.share_instace.prepare_upload(working_directory:Dir.pwd, proj_name:proj_name)
95
+ end
96
+
97
+ apk_path = Pindo::AndroidBuildHelper.share_instance.auto_build_apk(pindo_project_dir, !@args_release_flag, @args_direct_flag)
98
+ ipa_file_upload = Dir.glob(apk_path).max_by {|f| File.mtime(f)}
99
+
100
+ if !ipa_file_upload.nil? && !app_info_obj.nil?
101
+ description = nil
102
+ result_data = PgyerHelper.share_instace.start_upload(app_info_obj:app_info_obj, ipa_file_upload:ipa_file_upload, description:description)
103
+ if !result_data.nil? && !result_data["data"].nil? && !result_data["data"]["id"].nil?
104
+ msg_data = PgyerHelper.share_instace.make_msg_data(app_info_obj:app_info_obj, app_version_info_obj:result_data["data"])
105
+ PgyerHelper.share_instace.print_app_version_info(msg_data:msg_data)
106
+ if @args_send_flag
107
+ PgyerHelper.share_instace.send_apptest_wechat_msg(msg_data:msg_data)
108
+ end
109
+ end
110
+ end
111
+
112
+ system "open #{pindo_project_dir}"
113
+
68
114
  end
69
115
 
70
116
  end
71
117
  end
72
118
  end
73
- end
119
+ end
@@ -1,14 +1,17 @@
1
1
 
2
2
 
3
3
  require 'pindo/command/android/debug'
4
+ require 'pindo/command/android/autobuild'
5
+ require 'pindo/command/android/build'
4
6
 
5
7
  module Pindo
6
8
  class Command
7
-
8
9
  class Android < Command
9
10
  self.abstract_command = true
10
11
  self.summary = 'Android相关命令'
11
- end
12
+ self.command = 'and'
13
+ # self.command_name = 'and'
12
14
 
15
+ end
13
16
  end
14
17
  end
@@ -114,6 +114,12 @@ module Pindo
114
114
  end
115
115
  end
116
116
 
117
+ new_project_fullname = Dir.glob(File.join(pindo_project_dir, "/*.xcodeproj")).max_by {|f| File.mtime(f)}
118
+ if !new_project_fullname.nil? && File.exist?(new_project_fullname)
119
+ build_helper.delete_libtarget_firebase_shell(pindo_project_dir)
120
+ end
121
+
122
+
117
123
 
118
124
  mainapp_bundleid= nil
119
125
  if @args_bundle_id
@@ -98,6 +98,12 @@ module Pindo
98
98
  end
99
99
  end
100
100
 
101
+ new_project_fullname = Dir.glob(File.join(pindo_project_dir, "/*.xcodeproj")).max_by {|f| File.mtime(f)}
102
+ puts "new_project_fullname: #{new_project_fullname}"
103
+ if !new_project_fullname.nil? && File.exist?(new_project_fullname)
104
+ build_helper.delete_libtarget_firebase_shell(pindo_project_dir)
105
+ end
106
+
101
107
  app_info_obj = nil
102
108
  if @args_upload_flag
103
109
  proj_name = @args_proj_name
@@ -110,7 +116,7 @@ module Pindo
110
116
 
111
117
 
112
118
  Dir.chdir(pindo_project_dir)
113
- build_path = File.join(pindo_project_dir, "build", "*.{ipa,app,apk}")
119
+ build_path = File.join(pindo_project_dir, "build", "*.{ipa,app}")
114
120
  ipa_file_upload = Dir.glob(build_path).max_by {|f| File.mtime(f)}
115
121
 
116
122
  if !ipa_file_upload.nil? && !app_info_obj.nil?
@@ -3,7 +3,8 @@ require 'xcodeproj'
3
3
  require 'find'
4
4
  require 'fileutils'
5
5
  require 'pindo/base/executable'
6
-
6
+ require 'pindo/module/build/unityhelper'
7
+ require 'pindo/module/build/buildhelper'
7
8
 
8
9
  module Pindo
9
10
  class Command
@@ -12,11 +13,11 @@ module Pindo
12
13
 
13
14
  # 命令的简要说明 - 编译Unity工程生成Android APK
14
15
  self.summary = '编译Unity工程生成Android APK'
15
-
16
+
16
17
  # 命令的详细说明,包含用法示例
17
18
  self.description = <<-DESC
18
19
  编译Unity工程生成Android APK。
19
-
20
+
20
21
  支持功能:
21
22
 
22
23
  * 编译生成APK
@@ -41,7 +42,6 @@ module Pindo
41
42
 
42
43
  ]
43
44
 
44
-
45
45
  # 命令的选项列表
46
46
  def self.options
47
47
  [
@@ -51,7 +51,7 @@ module Pindo
51
51
  ['--upload', '上传编译后的APK到测试平台'],
52
52
  # 发送通知
53
53
  ['--send', '上传成功后发送测试通知']
54
-
54
+
55
55
  ].concat(super)
56
56
  end
57
57
 
@@ -69,7 +69,70 @@ module Pindo
69
69
  end
70
70
 
71
71
  def run
72
- puts "apk"
72
+ pindo_project_dir = Dir.pwd
73
+
74
+ # 检查是否是Unity工程
75
+ unity_helper = Pindo::Client::UnityHelper.share_instance
76
+ unless unity_helper.unity_project?(pindo_project_dir)
77
+ raise Informative, "当前目录不是Unity工程,请在Unity工程根目录下执行此命令"
78
+ end
79
+
80
+ if @args_upload_flag
81
+ build_helper = Pindo::BuildHelper.share_instance
82
+ build_helper.check_check_and_install_cliff(pindo_project_dir)
83
+ is_need_add_tag,tag_action_parms = build_helper.check_is_need_add_tag?(pindo_project_dir)
84
+ if is_need_add_tag
85
+ Pindo::Command::Dev::Tag::run(tag_action_parms)
86
+ end
87
+ end
88
+
89
+ project_unity_version = unity_helper.get_unity_version(pindo_project_dir)
90
+ puts
91
+ puts "工程的Unity版本: #{project_unity_version}"
92
+ unity_exe_path = unity_helper.find_unity_path(project_unity_version:project_unity_version, force_change_version: @force_select_unity)
93
+ puts "选择的Unity路径: #{unity_exe_path}"
94
+ puts
95
+
96
+ app_info_obj = nil
97
+ if @args_upload_flag
98
+ proj_name = @args_proj_name
99
+ app_info_obj = PgyerHelper.share_instace.prepare_upload(working_directory:Dir.pwd, proj_name:proj_name)
100
+ end
101
+
102
+ isLibrary = @args_base_flag
103
+
104
+ android_export_lib_dir = File.join(pindo_project_dir, "GoodPlatform/BaseAndroid")
105
+ if File.directory?(android_export_lib_dir)
106
+ isLibrary = true
107
+ end
108
+
109
+ pindo_android_project_dir = File.join(pindo_project_dir, "GoodPlatform/Android")
110
+ if isLibrary
111
+ pindo_android_project_dir = android_export_lib_dir
112
+ end
113
+ puts "开始构建Unity项目..."
114
+
115
+ unity_helper.build_project(
116
+ unity_exe_full_path: unity_exe_path,
117
+ project_path: pindo_project_dir,
118
+ platform: 'Android',
119
+ isLibrary: isLibrary
120
+ )
121
+
122
+ puts "Unity项目构建完成,准备处理Android项目..."
123
+ args_temp = []
124
+
125
+ if @args_upload_flag
126
+ args_temp << "--proj=#{app_info_obj["appName"]}"
127
+ args_temp << "--upload"
128
+ end
129
+ if @args_send_flag
130
+ args_temp << "--send"
131
+ end
132
+
133
+ Dir.chdir(pindo_android_project_dir)
134
+
135
+ Pindo::Command::Android::Autobuild::run(args_temp)
73
136
  end
74
137
 
75
138
  end
@@ -55,8 +55,8 @@ module Pindo
55
55
 
56
56
  fixed_bundleid_array.each do |bundle_id|
57
57
  # begin
58
- if bundle_id.eql?("com.heroneverdie101")
59
- bundle_id = "com.heroneverdie101.*"
58
+ if bundle_id.eql?("com.heroneverdie101.*")
59
+ bundle_id = "com.heroneverdie101"
60
60
  end
61
61
  fixed_cert(bundle_id:bundle_id, renew_flag:@renew_cert_flag, upload_flag:@upload_flag, fixed_bundleid_flag:@fixedid_flag)
62
62
  # rescue => err
@@ -0,0 +1,91 @@
1
+ require_relative 'base_helper'
2
+
3
+ module Pindo
4
+ module ApkHelper
5
+ include BaseAndroidHelper
6
+
7
+ def build_apk(project_path, debug)
8
+ raise ArgumentError, "项目路径不能为空" if project_path.nil? || project_path.empty?
9
+
10
+ # 构建 AAB 文件
11
+ unless build_aab(project_path, debug)
12
+ raise RuntimeError, "AAB 构建失败"
13
+ end
14
+
15
+ # 获取必要的配置信息
16
+ main_module = get_main_module(project_path)
17
+ raise ArgumentError, "无法找到主模块" unless main_module
18
+
19
+ keystore_config = get_keystore_config(project_path, debug)
20
+ raise ArgumentError, "无法从 build.gradle 中获取 keystore 信息" unless keystore_config
21
+
22
+ bundle_tool = get_build_tools[:bundle_tool]
23
+ raise ArgumentError, "找不到 bundletool" unless File.exist?(bundle_tool)
24
+
25
+ # 准备输出路径
26
+ build_type = debug ? 'debug' : 'release'
27
+ main_module_name = File.basename(main_module)
28
+ output_dir = File.join(project_path, "build/apks")
29
+
30
+ # 清理已存在的文件
31
+ FileUtils.rm_rf(output_dir)
32
+ FileUtils.mkdir_p(output_dir)
33
+
34
+ # 构建路径配置
35
+ paths = {
36
+ output_apks: File.join(output_dir, "app.apks"),
37
+ bundle: File.join(main_module, "build/outputs/bundle/#{build_type}/#{main_module_name}-#{build_type}.aab"),
38
+ universal_apk: File.join(output_dir, "universal.apk")
39
+ }
40
+
41
+ # 检查 bundle 文件是否存在
42
+ unless File.exist?(paths[:bundle])
43
+ raise RuntimeError, "找不到 AAB 文件: #{paths[:bundle]}"
44
+ end
45
+
46
+ puts "解析 keystore 配置"
47
+ ks = keystore_config[:store_file]
48
+ puts "读取 keystore path = #{ks}"
49
+ ks_pass = keystore_config[:store_password]
50
+ puts "读取 keystore pass = #{ks_pass}"
51
+ key_alias = keystore_config[:key_alias]
52
+ puts "读取 key alias = #{key_alias}"
53
+ key_pass = keystore_config[:key_password]
54
+ puts "读取 key pass = #{key_pass}"
55
+
56
+ # 构建 APK
57
+ bundletool_cmd = [
58
+ "java -jar #{bundle_tool} build-apks",
59
+ "--bundle=#{paths[:bundle]}",
60
+ "--output=#{paths[:output_apks]}",
61
+ "--ks=#{ks}",
62
+ "--ks-pass=pass:#{ks_pass}",
63
+ "--ks-key-alias=#{key_alias}",
64
+ "--key-pass=pass:#{key_pass}",
65
+ "--mode=universal"
66
+ ].join(" ")
67
+
68
+ unless system(bundletool_cmd)
69
+ raise RuntimeError, "APKS 构建失败"
70
+ end
71
+
72
+ # 解压 APKs 文件
73
+ unless system("unzip", "-o", paths[:output_apks], "-d", output_dir)
74
+ raise RuntimeError, "APKS 解压失败"
75
+ end
76
+
77
+ # 返回生成的 APK 路径
78
+ unless File.exist?(paths[:universal_apk])
79
+ raise RuntimeError, "未找到生成的 APK 文件"
80
+ end
81
+
82
+ paths[:universal_apk]
83
+ end
84
+
85
+ def build_aab(project_path, debug)
86
+ Dir.chdir(project_path) do
87
+ system("./gradlew bundle#{debug ? 'Debug' : 'Release'}")
88
+ end
89
+ end
90
+ end
91
+ end