pindo 5.10.4 → 5.10.8
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 +4 -4
- data/lib/pindo/base/funlog.rb +12 -1
- data/lib/pindo/base/pindocontext.rb +3 -0
- data/lib/pindo/command/android/autobuild.rb +62 -9
- data/lib/pindo/command/android/build.rb +6 -6
- data/lib/pindo/command/android/debug.rb +9 -9
- data/lib/pindo/command/deploy/build.rb +5 -2
- data/lib/pindo/command/deploy/cert.rb +6 -7
- data/lib/pindo/command/deploy/configproj.rb +3 -3
- data/lib/pindo/command/deploy/confusecode.rb +1 -1
- data/lib/pindo/command/deploy/confuseproj.rb +1 -1
- data/lib/pindo/command/deploy/pem.rb +3 -4
- data/lib/pindo/command/dev/autobuild.rb +2 -2
- data/lib/pindo/command/dev/build.rb +2 -2
- data/lib/pindo/command/dev/feishu.rb +1 -1
- data/lib/pindo/command/gplay/pullconfig.rb +48 -0
- data/lib/pindo/command/gplay.rb +6 -5
- data/lib/pindo/command/ios/adhoc.rb +7 -6
- data/lib/pindo/command/ios/autobuild.rb +25 -25
- data/lib/pindo/command/ios/build.rb +7 -6
- data/lib/pindo/command/ios/debug.rb +2 -1
- data/lib/pindo/command/ipa/autoresign.rb +2 -2
- data/lib/pindo/command/ipa/import.rb +3 -4
- data/lib/pindo/command/ipa/output.rb +3 -4
- data/lib/pindo/command/jps/upload.rb +6 -5
- data/lib/pindo/command/repo/login.rb +1 -1
- data/lib/pindo/command/unity/apk.rb +19 -2
- data/lib/pindo/command/unity/autobuild.rb +58 -63
- data/lib/pindo/command/unity/initpack.rb +1 -1
- data/lib/pindo/command/unity/ipa.rb +17 -14
- data/lib/pindo/command/unity/pack.rb +1 -1
- data/lib/pindo/command/unity/upload.rb +1 -1
- data/lib/pindo/command/unity/web.rb +2 -2
- data/lib/pindo/command/utils/device.rb +4 -4
- data/lib/pindo/command/utils/icon.rb +1 -1
- data/lib/pindo/command/utils/renewcert.rb +2 -3
- data/lib/pindo/command/utils/renewproj.rb +9 -10
- data/lib/pindo/command/web/autobuild.rb +3 -3
- data/lib/pindo/command/web/run.rb +1 -1
- data/lib/pindo/command.rb +2 -1
- data/lib/pindo/module/android/android_build_config_helper.rb +267 -35
- data/lib/pindo/module/android/android_build_helper.rb +300 -0
- data/lib/pindo/module/android/android_project_helper.rb +279 -0
- data/lib/pindo/module/android/gp_compliance_helper.rb +33 -87
- data/lib/pindo/module/android/gradle_helper.rb +524 -255
- data/lib/pindo/module/android/java_env_helper.rb +633 -0
- data/lib/pindo/module/android/keystore_helper.rb +1118 -0
- data/lib/pindo/module/appselect.rb +109 -0
- data/lib/pindo/module/appstore/appstore_in_app_purchase.rb +1 -1
- data/lib/pindo/module/build/{buildhelper.rb → build_helper.rb} +1 -2
- data/lib/pindo/module/build/{commonconfuseproj.rb → confuse_xcodeproj.rb} +2 -2
- data/lib/pindo/module/cert/cert_helper.rb +245 -0
- data/lib/pindo/module/cert/keychain_helper.rb +152 -0
- data/lib/pindo/module/cert/pem_helper.rb +67 -0
- data/lib/pindo/module/cert/xcodecerthelper.rb +6 -5
- data/lib/pindo/module/pgyer/pgyerhelper.rb +5 -5
- data/lib/pindo/module/{build/unityhelper.rb → unity/unity_helper.rb} +0 -17
- data/lib/pindo/module/xcode/{xcodereshandler.rb → res/xcode_res_handler.rb} +1 -1
- data/lib/pindo/module/xcode/{xcodebuildconfig.rb → xcode_build_config.rb} +7 -6
- data/lib/pindo/module/xcode/{xcodebuildhelper.rb → xcode_build_helper.rb} +84 -2
- data/lib/pindo/module/xcode/{xcodehelper.rb → xcode_project_helper.rb} +4 -2
- data/lib/pindo/module/xcode/{xcodereshelper.rb → xcode_res_helper.rb} +12 -9
- data/lib/pindo/version.rb +185 -7
- data/lib/pindo.rb +14 -9
- metadata +24 -23
- data/lib/pindo/module/android/apk_helper.rb +0 -138
- data/lib/pindo/module/android/base_helper.rb +0 -964
- data/lib/pindo/module/android/build_helper.rb +0 -128
- data/lib/pindo/module/android/so_helper.rb +0 -18
- data/lib/pindo/module/cert/certhelper.rb +0 -246
- data/lib/pindo/module/cert/keychainhelper.rb +0 -150
- data/lib/pindo/module/cert/pemhelper.rb +0 -65
- /data/lib/pindo/module/android/{androidreshelper.rb → android_res_helper.rb} +0 -0
- /data/lib/pindo/module/appstore/{iap_tier.json → appstore_iap_tier.json} +0 -0
- /data/lib/pindo/module/build/{swarkhelper.rb → swark_helper.rb} +0 -0
- /data/lib/pindo/module/build/{versionhelper.rb → version_helper.rb} +0 -0
- /data/lib/pindo/module/cert/{provisioninghelper.rb → provisioning_helper.rb} +0 -0
- /data/lib/pindo/module/unity/{nugethelper.rb → nuget_helper.rb} +0 -0
- /data/lib/pindo/module/xcode/{xcoderesconstant.rb → res/xcode_res_constant.rb} +0 -0
|
@@ -3,8 +3,8 @@ require 'xcodeproj'
|
|
|
3
3
|
require 'find'
|
|
4
4
|
require 'fileutils'
|
|
5
5
|
require 'pindo/base/executable'
|
|
6
|
-
require 'pindo/module/
|
|
7
|
-
require 'pindo/module/build/
|
|
6
|
+
require 'pindo/module/unity/unity_helper'
|
|
7
|
+
require 'pindo/module/build/build_helper'
|
|
8
8
|
|
|
9
9
|
module Pindo
|
|
10
10
|
class Command
|
|
@@ -19,7 +19,7 @@ module Pindo
|
|
|
19
19
|
- 支持iOS和Mac设备管理
|
|
20
20
|
- 读取本地CSV文件的设备数据
|
|
21
21
|
- 生成多种格式的设备列表
|
|
22
|
-
-
|
|
22
|
+
- 兼容JPS平台的设备格式
|
|
23
23
|
- 设备信息统一管理和对比
|
|
24
24
|
|
|
25
25
|
使用示例:
|
|
@@ -29,7 +29,7 @@ module Pindo
|
|
|
29
29
|
生成文件:
|
|
30
30
|
- new_devices_list.txt - App Store格式的设备列表
|
|
31
31
|
- new_user_devices_list.csv - 用户设备列表
|
|
32
|
-
-
|
|
32
|
+
- new_jps_devices_list.csv - JPS格式设备列表
|
|
33
33
|
DESC
|
|
34
34
|
|
|
35
35
|
class DeviceItem
|
|
@@ -199,7 +199,7 @@ DESC
|
|
|
199
199
|
|
|
200
200
|
def write_apppgyer_csv(devices:nil)
|
|
201
201
|
|
|
202
|
-
device_file = File.join(Dir.pwd, "
|
|
202
|
+
device_file = File.join(Dir.pwd, "new_jps_devices_list.csv");
|
|
203
203
|
|
|
204
204
|
devices.each do |key, item|
|
|
205
205
|
if item.device_type.to_s.eql?("ipad")
|
|
@@ -231,7 +231,7 @@ DESC
|
|
|
231
231
|
devices = {}
|
|
232
232
|
|
|
233
233
|
|
|
234
|
-
device_file = File.join(Dir.pwd, "
|
|
234
|
+
device_file = File.join(Dir.pwd, "jps_devices_list.csv");
|
|
235
235
|
if File.exist?(device_file)
|
|
236
236
|
line_num=0
|
|
237
237
|
CSV.foreach(device_file, headers:false) do |row|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require 'fileutils'
|
|
2
2
|
require 'pindo/module/cert/xcodecerthelper'
|
|
3
|
-
require 'pindo/module/cert/
|
|
3
|
+
require 'pindo/module/cert/cert_helper'
|
|
4
4
|
|
|
5
5
|
module Pindo
|
|
6
6
|
class Command
|
|
@@ -9,7 +9,6 @@ module Pindo
|
|
|
9
9
|
|
|
10
10
|
include Appselect
|
|
11
11
|
include XcodeCertHelper
|
|
12
|
-
include CertHelper
|
|
13
12
|
|
|
14
13
|
self.summary = '更新当前账号下所有的Provisioning Profile文件'
|
|
15
14
|
|
|
@@ -51,7 +50,7 @@ DESC
|
|
|
51
50
|
[
|
|
52
51
|
|
|
53
52
|
['--fast', '快速更新证书,开发用bundle id只更新dev证书,发布bundle id只更新adhoc证书'],
|
|
54
|
-
['--upload', '生成上传
|
|
53
|
+
['--upload', '生成上传JPS的证书'],
|
|
55
54
|
['--fixedid', '重新更新bundle id的功能,检查bundle id的功能是否更新'],
|
|
56
55
|
['--renew', '重新生成证书']
|
|
57
56
|
].concat(super)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
require 'xcodeproj'
|
|
3
3
|
require 'find'
|
|
4
4
|
require 'fileutils'
|
|
5
|
-
require 'pindo/module/xcode/
|
|
5
|
+
require 'pindo/module/xcode/xcode_project_helper'
|
|
6
6
|
|
|
7
7
|
module Pindo
|
|
8
8
|
class Command
|
|
@@ -11,7 +11,6 @@ module Pindo
|
|
|
11
11
|
|
|
12
12
|
include Command::DeployOptions
|
|
13
13
|
|
|
14
|
-
include XcodeHelper
|
|
15
14
|
|
|
16
15
|
self.summary = '重新创建Xcode工程'
|
|
17
16
|
|
|
@@ -87,15 +86,15 @@ DESC
|
|
|
87
86
|
old_proj_fullname = File.join(old_proj_path, old_proj_name) + ".xcodeproj"
|
|
88
87
|
old_proj_obj = Xcodeproj::Project.open(old_proj_fullname)
|
|
89
88
|
|
|
90
|
-
copy_to_newproject(new_proj_path:new_proj_path, new_proj_name:new_proj_name, old_proj_path:old_proj_path, old_proj_name:old_proj_name)
|
|
89
|
+
Pindo::XcodeProjectHelper.copy_to_newproject(new_proj_path:new_proj_path, new_proj_name:new_proj_name, old_proj_path:old_proj_path, old_proj_name:old_proj_name)
|
|
91
90
|
|
|
92
|
-
create_project_target(new_proj_name:new_proj_name, new_proj_path:new_proj_path, new_proj_obj:new_proj_obj, old_proj_name:old_proj_name, old_proj_path:old_proj_path, old_proj_obj:old_proj_obj)
|
|
93
|
-
|
|
94
|
-
add_file_to_target(new_proj_name:new_proj_name, new_proj_path:new_proj_path, new_proj_obj:new_proj_obj, old_proj_name:old_proj_name, old_proj_path:old_proj_path, old_proj_obj:old_proj_obj)
|
|
95
|
-
|
|
96
|
-
config_project_target(new_proj_name:new_proj_name, new_proj_path:new_proj_path, new_proj_obj:new_proj_obj, old_proj_name:old_proj_name, old_proj_path:old_proj_path, old_proj_obj:old_proj_obj)
|
|
97
|
-
|
|
98
|
-
setting_new_project(new_proj_name:new_proj_name, new_proj_path:new_proj_path, new_proj_obj:new_proj_obj, old_proj_name:old_proj_name, old_proj_path:old_proj_path, old_proj_obj:old_proj_obj)
|
|
91
|
+
Pindo::XcodeProjectHelper.create_project_target(new_proj_name:new_proj_name, new_proj_path:new_proj_path, new_proj_obj:new_proj_obj, old_proj_name:old_proj_name, old_proj_path:old_proj_path, old_proj_obj:old_proj_obj)
|
|
92
|
+
|
|
93
|
+
Pindo::XcodeProjectHelper.add_file_to_target(new_proj_name:new_proj_name, new_proj_path:new_proj_path, new_proj_obj:new_proj_obj, old_proj_name:old_proj_name, old_proj_path:old_proj_path, old_proj_obj:old_proj_obj)
|
|
94
|
+
|
|
95
|
+
Pindo::XcodeProjectHelper.config_project_target(new_proj_name:new_proj_name, new_proj_path:new_proj_path, new_proj_obj:new_proj_obj, old_proj_name:old_proj_name, old_proj_path:old_proj_path, old_proj_obj:old_proj_obj)
|
|
96
|
+
|
|
97
|
+
Pindo::XcodeProjectHelper.setting_new_project(new_proj_name:new_proj_name, new_proj_path:new_proj_path, new_proj_obj:new_proj_obj, old_proj_name:old_proj_name, old_proj_path:old_proj_path, old_proj_obj:old_proj_obj)
|
|
99
98
|
|
|
100
99
|
end
|
|
101
100
|
|
|
@@ -3,8 +3,8 @@ require 'xcodeproj'
|
|
|
3
3
|
require 'find'
|
|
4
4
|
require 'fileutils'
|
|
5
5
|
require 'pindo/base/executable'
|
|
6
|
-
require 'pindo/module/
|
|
7
|
-
require 'pindo/module/build/
|
|
6
|
+
require 'pindo/module/unity/unity_helper'
|
|
7
|
+
require 'pindo/module/build/build_helper'
|
|
8
8
|
|
|
9
9
|
module Pindo
|
|
10
10
|
class Command
|
|
@@ -53,7 +53,7 @@ module Pindo
|
|
|
53
53
|
def self.options
|
|
54
54
|
[
|
|
55
55
|
['--bundleid', '指定打包的bundleID'],
|
|
56
|
-
#
|
|
56
|
+
# 指定上传到JPS的项目
|
|
57
57
|
['--proj', '指定上传到测试平台的项目名称'],
|
|
58
58
|
# 上传编译包
|
|
59
59
|
['--upload', '上传编译后的ipa到测试平台'],
|
|
@@ -3,7 +3,7 @@ require 'xcodeproj'
|
|
|
3
3
|
require 'find'
|
|
4
4
|
require 'fileutils'
|
|
5
5
|
require 'pindo/base/executable'
|
|
6
|
-
require 'pindo/module/build/
|
|
6
|
+
require 'pindo/module/build/build_helper'
|
|
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'
|
data/lib/pindo/command.rb
CHANGED
|
@@ -30,7 +30,7 @@ module Pindo
|
|
|
30
30
|
require "match"
|
|
31
31
|
require 'pindo/options/deployoptions'
|
|
32
32
|
require 'pindo/module/appselect'
|
|
33
|
-
require 'pindo/module/build/
|
|
33
|
+
require 'pindo/module/build/confuse_xcodeproj'
|
|
34
34
|
require 'pindo/module/cert/xcodecerthelper'
|
|
35
35
|
|
|
36
36
|
require 'pindo/module/appstore/appstore_in_app_purchase'
|
|
@@ -47,6 +47,7 @@ module Pindo
|
|
|
47
47
|
require 'pindo/command/repo'
|
|
48
48
|
require 'pindo/command/ipa'
|
|
49
49
|
require 'pindo/command/appstore'
|
|
50
|
+
require 'pindo/command/gplay'
|
|
50
51
|
require 'pindo/command/unity'
|
|
51
52
|
require 'pindo/command/ios'
|
|
52
53
|
require 'pindo/command/android'
|
|
@@ -1,41 +1,40 @@
|
|
|
1
1
|
require 'fileutils'
|
|
2
2
|
require 'open-uri'
|
|
3
3
|
require_relative '../../base/funlog'
|
|
4
|
-
require_relative '
|
|
4
|
+
require_relative 'android_project_helper'
|
|
5
5
|
require_relative '../../base/executable'
|
|
6
|
-
require_relative '
|
|
6
|
+
require_relative 'android_res_helper'
|
|
7
7
|
|
|
8
8
|
module Pindo
|
|
9
9
|
|
|
10
10
|
class AndroidBuildConfigHelper
|
|
11
|
-
include BaseAndroidHelper
|
|
12
11
|
|
|
13
|
-
#
|
|
12
|
+
# 使用工作流配置一次性更新App Name、Application ID和URL Schemes
|
|
14
13
|
# 优化版本:提高性能,减少代码重复
|
|
15
14
|
# @param project_dir [String] Android项目目录路径
|
|
16
|
-
# @param
|
|
15
|
+
# @param workflow_packname [String] 工作流的名称(如:"Test Demo")
|
|
17
16
|
# @return [Boolean] 是否成功更新
|
|
18
|
-
def self.
|
|
17
|
+
def self.update_project_with_workflow(project_dir: nil, workflow_packname: nil)
|
|
19
18
|
raise ArgumentError, "项目目录不能为空" if project_dir.nil?
|
|
20
|
-
raise ArgumentError, "Package Name不能为空" if
|
|
19
|
+
raise ArgumentError, "Workflow Package Name不能为空" if workflow_packname.nil?
|
|
21
20
|
|
|
22
21
|
# 生成各种值
|
|
23
|
-
app_name =
|
|
24
|
-
app_id_suffix =
|
|
22
|
+
app_name = workflow_packname.gsub(/[^a-zA-Z0-9\s]/, '').gsub(/\s+/, '')
|
|
23
|
+
app_id_suffix = workflow_packname.gsub(/[^a-zA-Z0-9]/, '').downcase
|
|
25
24
|
application_id = "com.heroneverdie101.#{app_id_suffix}"
|
|
26
|
-
package_scheme =
|
|
25
|
+
package_scheme = workflow_packname.gsub(/[^a-zA-Z0-9]/, '').downcase
|
|
27
26
|
bundle_scheme = application_id.gsub(/[^a-zA-Z0-9]/, '').downcase
|
|
28
27
|
|
|
29
28
|
# 1. 更新 App Name
|
|
30
29
|
success_app_name = update_app_name_with_packagename(
|
|
31
30
|
project_dir: project_dir,
|
|
32
|
-
package_name:
|
|
31
|
+
package_name: workflow_packname
|
|
33
32
|
)
|
|
34
33
|
|
|
35
34
|
# 2. 更新 Application ID
|
|
36
|
-
success_app_id =
|
|
35
|
+
success_app_id = update_applicationid_with_workflowname(
|
|
37
36
|
project_dir: project_dir,
|
|
38
|
-
package_name:
|
|
37
|
+
package_name: workflow_packname
|
|
39
38
|
)
|
|
40
39
|
|
|
41
40
|
# 3. 添加基于 package_name 的 Scheme
|
|
@@ -78,11 +77,8 @@ module Pindo
|
|
|
78
77
|
Funlog.instance.fancyinfo_start("正在更新Android工程版本信息...")
|
|
79
78
|
|
|
80
79
|
begin
|
|
81
|
-
# 创建helper实例以使用基类方法
|
|
82
|
-
helper = self.new
|
|
83
|
-
|
|
84
80
|
# 获取主模块路径
|
|
85
|
-
main_module =
|
|
81
|
+
main_module = Pindo::AndroidProjectHelper.get_main_module(project_dir)
|
|
86
82
|
|
|
87
83
|
if main_module.nil?
|
|
88
84
|
# 如果无法获取主模块,尝试常见的模块名(优先 launcher,支持 Unity 项目)
|
|
@@ -118,11 +114,23 @@ module Pindo
|
|
|
118
114
|
content = File.read(gradle_file)
|
|
119
115
|
|
|
120
116
|
# 第一步:清理所有现有的版本信息(无论在什么位置)
|
|
117
|
+
# 直接赋值格式
|
|
121
118
|
content.gsub!(/^\s*versionCode\s+\d+\s*$/, '')
|
|
122
119
|
content.gsub!(/^\s*versionCode\s*=\s*\d+\s*$/, '')
|
|
123
120
|
content.gsub!(/^\s*versionName\s+["'][^"']*["']\s*$/, '')
|
|
124
121
|
content.gsub!(/^\s*versionName\s*=\s*["'][^"']*["']\s*$/, '')
|
|
125
122
|
|
|
123
|
+
# 外部变量引用格式
|
|
124
|
+
content.gsub!(/^\s*versionCode\s+rootProject\.ext\.\w+\s*$/, '')
|
|
125
|
+
content.gsub!(/^\s*versionCode\s+project\.ext\.\w+\s*$/, '')
|
|
126
|
+
content.gsub!(/^\s*versionCode\s+ext\.\w+\s*$/, '')
|
|
127
|
+
content.gsub!(/^\s*versionName\s+["']?\$\{rootProject\.ext\.\w+\}["']?\s*$/, '')
|
|
128
|
+
content.gsub!(/^\s*versionName\s+["']?\$\{project\.ext\.\w+\}["']?\s*$/, '')
|
|
129
|
+
content.gsub!(/^\s*versionName\s+["']?\$\{ext\.\w+\}["']?\s*$/, '')
|
|
130
|
+
content.gsub!(/^\s*versionName\s+rootProject\.ext\.\w+\s*$/, '')
|
|
131
|
+
content.gsub!(/^\s*versionName\s+project\.ext\.\w+\s*$/, '')
|
|
132
|
+
content.gsub!(/^\s*versionName\s+ext\.\w+\s*$/, '')
|
|
133
|
+
|
|
126
134
|
# 清理多余的空行
|
|
127
135
|
content.gsub!(/\n\n+/, "\n\n")
|
|
128
136
|
|
|
@@ -195,9 +203,7 @@ module Pindo
|
|
|
195
203
|
app_name = package_name.gsub(/[^a-zA-Z0-9\s]/, '').gsub(/\s+/, '')
|
|
196
204
|
|
|
197
205
|
begin
|
|
198
|
-
|
|
199
|
-
helper = self.new
|
|
200
|
-
main_module = helper.get_main_module(project_dir)
|
|
206
|
+
main_module = Pindo::AndroidProjectHelper.get_main_module(project_dir)
|
|
201
207
|
|
|
202
208
|
if main_module.nil?
|
|
203
209
|
# 尝试常见的模块名(优先 launcher,支持 Unity 项目)
|
|
@@ -212,6 +218,35 @@ module Pindo
|
|
|
212
218
|
|
|
213
219
|
return false if main_module.nil?
|
|
214
220
|
|
|
221
|
+
# 1. 先删除 build.gradle 中的 resValue("string", "app_name", ...)
|
|
222
|
+
build_gradle_path = File.join(main_module, "build.gradle")
|
|
223
|
+
build_gradle_kts_path = File.join(main_module, "build.gradle.kts")
|
|
224
|
+
|
|
225
|
+
gradle_file = nil
|
|
226
|
+
if File.exist?(build_gradle_kts_path)
|
|
227
|
+
gradle_file = build_gradle_kts_path
|
|
228
|
+
elsif File.exist?(build_gradle_path)
|
|
229
|
+
gradle_file = build_gradle_path
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
if gradle_file
|
|
233
|
+
gradle_content = File.read(gradle_file)
|
|
234
|
+
original_content = gradle_content.dup
|
|
235
|
+
|
|
236
|
+
# 删除 resValue("string", "app_name", ...) 这一行
|
|
237
|
+
# 支持多种格式:
|
|
238
|
+
# resValue("string", "app_name", "xxx")
|
|
239
|
+
# resValue("string", "app_name", "${rootProject.ext.app_name}")
|
|
240
|
+
# resValue "string", "app_name", "xxx"
|
|
241
|
+
gradle_content.gsub!(/^\s*resValue\s*\(?\s*["']string["']\s*,\s*["']app_name["'].*?\)?\s*$\n?/, '')
|
|
242
|
+
|
|
243
|
+
if gradle_content != original_content
|
|
244
|
+
File.write(gradle_file, gradle_content)
|
|
245
|
+
puts " ✓ 已删除 build.gradle 中的 resValue(\"string\", \"app_name\", ...)"
|
|
246
|
+
end
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
# 2. 更新 strings.xml
|
|
215
250
|
# 查找strings.xml文件
|
|
216
251
|
strings_xml_path = File.join(main_module, "src", "main", "res", "values", "strings.xml")
|
|
217
252
|
|
|
@@ -223,15 +258,26 @@ module Pindo
|
|
|
223
258
|
# 读取并更新strings.xml
|
|
224
259
|
content = File.read(strings_xml_path)
|
|
225
260
|
|
|
226
|
-
#
|
|
261
|
+
# 检查是否存在 app_name
|
|
227
262
|
if content =~ /<string\s+name="app_name">.*?<\/string>/
|
|
263
|
+
# 存在,直接更新
|
|
228
264
|
content.gsub!(/<string\s+name="app_name">.*?<\/string>/, "<string name=\"app_name\">#{app_name}</string>")
|
|
229
265
|
File.write(strings_xml_path, content)
|
|
230
266
|
puts " ✓ App Name 已更新为: #{app_name} (来自: #{package_name})"
|
|
231
267
|
return true
|
|
232
268
|
else
|
|
233
|
-
|
|
234
|
-
|
|
269
|
+
# 不存在,自动添加
|
|
270
|
+
if content =~ /<resources>(.*?)<\/resources>/m
|
|
271
|
+
# 在 <resources> 标签内添加 app_name
|
|
272
|
+
new_string_entry = "\n <string name=\"app_name\">#{app_name}</string>"
|
|
273
|
+
content.sub!(/<resources>/, "<resources>#{new_string_entry}")
|
|
274
|
+
File.write(strings_xml_path, content)
|
|
275
|
+
puts " ✓ App Name 已添加: #{app_name} (来自: #{package_name})"
|
|
276
|
+
return true
|
|
277
|
+
else
|
|
278
|
+
Funlog.instance.fancyinfo_error("strings.xml格式异常,无法添加app_name")
|
|
279
|
+
return false
|
|
280
|
+
end
|
|
235
281
|
end
|
|
236
282
|
|
|
237
283
|
rescue StandardError => e
|
|
@@ -240,11 +286,11 @@ module Pindo
|
|
|
240
286
|
end
|
|
241
287
|
end
|
|
242
288
|
|
|
243
|
-
#
|
|
289
|
+
# 使用工作流名称生成并更新Android Application ID(build.gradle中的applicationId)
|
|
244
290
|
# @param project_dir [String] Android项目目录路径
|
|
245
|
-
# @param package_name [String]
|
|
291
|
+
# @param package_name [String] 工作流的名称(如:"Test Demo"),将被转换为application ID格式
|
|
246
292
|
# @return [Boolean] 是否成功更新
|
|
247
|
-
def self.
|
|
293
|
+
def self.update_applicationid_with_workflowname(project_dir: nil, package_name: nil)
|
|
248
294
|
raise ArgumentError, "项目目录不能为空" if project_dir.nil?
|
|
249
295
|
raise ArgumentError, "Package Name不能为空" if package_name.nil?
|
|
250
296
|
|
|
@@ -253,9 +299,7 @@ module Pindo
|
|
|
253
299
|
application_id = "com.heroneverdie101.#{app_id_suffix}"
|
|
254
300
|
|
|
255
301
|
begin
|
|
256
|
-
|
|
257
|
-
helper = self.new
|
|
258
|
-
main_module = helper.get_main_module(project_dir)
|
|
302
|
+
main_module = Pindo::AndroidProjectHelper.get_main_module(project_dir)
|
|
259
303
|
|
|
260
304
|
if main_module.nil?
|
|
261
305
|
# 尝试常见的模块名(优先 launcher,支持 Unity 项目)
|
|
@@ -284,12 +328,32 @@ module Pindo
|
|
|
284
328
|
# 读取并更新gradle文件
|
|
285
329
|
content = File.read(gradle_file)
|
|
286
330
|
|
|
287
|
-
# 更新applicationId
|
|
331
|
+
# 更新applicationId(支持多种格式)
|
|
332
|
+
updated = false
|
|
333
|
+
|
|
334
|
+
# 格式1: applicationId "com.example.app"
|
|
288
335
|
if content =~ /applicationId\s+["'][^"']*["']/
|
|
289
336
|
content.gsub!(/applicationId\s+["'][^"']*["']/, "applicationId \"#{application_id}\"")
|
|
337
|
+
updated = true
|
|
338
|
+
# 格式2: applicationId = "com.example.app"
|
|
290
339
|
elsif content =~ /applicationId\s*=\s*["'][^"']*["']/
|
|
291
340
|
content.gsub!(/applicationId\s*=\s*["'][^"']*["']/, "applicationId = \"#{application_id}\"")
|
|
292
|
-
|
|
341
|
+
updated = true
|
|
342
|
+
# 格式3: applicationId rootProject.ext.application_id (外部变量引用)
|
|
343
|
+
elsif content =~ /applicationId\s+rootProject\.ext\.\w+/
|
|
344
|
+
content.gsub!(/applicationId\s+rootProject\.ext\.\w+/, "applicationId \"#{application_id}\"")
|
|
345
|
+
updated = true
|
|
346
|
+
# 格式4: applicationId project.ext.application_id
|
|
347
|
+
elsif content =~ /applicationId\s+project\.ext\.\w+/
|
|
348
|
+
content.gsub!(/applicationId\s+project\.ext\.\w+/, "applicationId \"#{application_id}\"")
|
|
349
|
+
updated = true
|
|
350
|
+
# 格式5: applicationId ext.application_id
|
|
351
|
+
elsif content =~ /applicationId\s+ext\.\w+/
|
|
352
|
+
content.gsub!(/applicationId\s+ext\.\w+/, "applicationId \"#{application_id}\"")
|
|
353
|
+
updated = true
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
unless updated
|
|
293
357
|
Funlog.instance.fancyinfo_error("gradle文件中未找到applicationId字段")
|
|
294
358
|
return false
|
|
295
359
|
end
|
|
@@ -304,6 +368,177 @@ module Pindo
|
|
|
304
368
|
end
|
|
305
369
|
end
|
|
306
370
|
|
|
371
|
+
# 直接更新Application ID(不依赖package_name生成)
|
|
372
|
+
# @param project_dir [String] Android项目目录路径
|
|
373
|
+
# @param application_id [String] 要设置的Application ID(如 com.example.app)
|
|
374
|
+
# @return [Boolean] 是否成功更新
|
|
375
|
+
def self.update_application_id(project_dir: nil, application_id: nil)
|
|
376
|
+
# 参数验证
|
|
377
|
+
if application_id.nil? || application_id.empty?
|
|
378
|
+
Funlog.instance.fancyinfo_error("Application ID不能为空")
|
|
379
|
+
return false
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
if project_dir.nil? || !File.directory?(project_dir)
|
|
383
|
+
Funlog.instance.fancyinfo_error("项目路径无效: #{project_dir}")
|
|
384
|
+
return false
|
|
385
|
+
end
|
|
386
|
+
|
|
387
|
+
begin
|
|
388
|
+
puts "正在设置 Application ID: #{application_id}"
|
|
389
|
+
|
|
390
|
+
# 获取主模块
|
|
391
|
+
main_module = Pindo::AndroidProjectHelper.get_main_module(project_dir)
|
|
392
|
+
|
|
393
|
+
# 支持多种项目结构
|
|
394
|
+
module_paths = []
|
|
395
|
+
module_paths << File.join(project_dir, main_module) if main_module
|
|
396
|
+
module_paths << File.join(project_dir, "app")
|
|
397
|
+
module_paths << File.join(project_dir, "unityLibrary/launcher")
|
|
398
|
+
module_paths << File.join(project_dir, "launcher")
|
|
399
|
+
|
|
400
|
+
gradle_file = nil
|
|
401
|
+
module_paths.each do |module_path|
|
|
402
|
+
next unless File.exist?(module_path)
|
|
403
|
+
|
|
404
|
+
if File.exist?(File.join(module_path, "build.gradle"))
|
|
405
|
+
gradle_file = File.join(module_path, "build.gradle")
|
|
406
|
+
break
|
|
407
|
+
elsif File.exist?(File.join(module_path, "build.gradle.kts"))
|
|
408
|
+
gradle_file = File.join(module_path, "build.gradle.kts")
|
|
409
|
+
break
|
|
410
|
+
end
|
|
411
|
+
end
|
|
412
|
+
|
|
413
|
+
if gradle_file.nil?
|
|
414
|
+
Funlog.instance.fancyinfo_error("未找到build.gradle文件")
|
|
415
|
+
return false
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
# 读取并更新gradle文件
|
|
419
|
+
content = File.read(gradle_file)
|
|
420
|
+
updated = false
|
|
421
|
+
|
|
422
|
+
# 更新applicationId(支持多种格式)
|
|
423
|
+
# 格式1: applicationId "com.example.app"
|
|
424
|
+
if content =~ /applicationId\s+["'][^"']*["']/
|
|
425
|
+
content.gsub!(/applicationId\s+["'][^"']*["']/, "applicationId \"#{application_id}\"")
|
|
426
|
+
updated = true
|
|
427
|
+
# 格式2: applicationId = "com.example.app"
|
|
428
|
+
elsif content =~ /applicationId\s*=\s*["'][^"']*["']/
|
|
429
|
+
content.gsub!(/applicationId\s*=\s*["'][^"']*["']/, "applicationId = \"#{application_id}\"")
|
|
430
|
+
updated = true
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
unless updated
|
|
434
|
+
Funlog.instance.fancyinfo_error("gradle文件中未找到applicationId配置")
|
|
435
|
+
return false
|
|
436
|
+
end
|
|
437
|
+
|
|
438
|
+
File.write(gradle_file, content)
|
|
439
|
+
puts " ✓ 更新 #{File.basename(gradle_file)} 中的 applicationId"
|
|
440
|
+
return true
|
|
441
|
+
|
|
442
|
+
rescue StandardError => e
|
|
443
|
+
Funlog.instance.fancyinfo_error("更新Application ID失败: #{e.message}")
|
|
444
|
+
return false
|
|
445
|
+
end
|
|
446
|
+
end
|
|
447
|
+
|
|
448
|
+
# 从配置仓库拷贝 google-services.json 到项目的 launcher 目录
|
|
449
|
+
# @param config_repo_dir [String] 配置仓库的路径
|
|
450
|
+
# @param project_dir [String] Android项目目录路径
|
|
451
|
+
# @return [Boolean] 是否成功拷贝
|
|
452
|
+
def self.copy_google_services_from_config_repo(config_repo_dir: nil, project_dir: nil)
|
|
453
|
+
# 参数验证
|
|
454
|
+
if config_repo_dir.nil? || !File.directory?(config_repo_dir)
|
|
455
|
+
Funlog.instance.fancyinfo_error("配置仓库路径无效: #{config_repo_dir}")
|
|
456
|
+
return false
|
|
457
|
+
end
|
|
458
|
+
|
|
459
|
+
if project_dir.nil? || !File.directory?(project_dir)
|
|
460
|
+
Funlog.instance.fancyinfo_error("项目路径无效: #{project_dir}")
|
|
461
|
+
return false
|
|
462
|
+
end
|
|
463
|
+
|
|
464
|
+
# 查找配置仓库中的 google-services.json
|
|
465
|
+
source_file = File.join(config_repo_dir, 'google-services.json')
|
|
466
|
+
unless File.exist?(source_file)
|
|
467
|
+
Funlog.instance.fancyinfo_warning("配置仓库中未找到 google-services.json")
|
|
468
|
+
return false
|
|
469
|
+
end
|
|
470
|
+
|
|
471
|
+
puts "正在拷贝 google-services.json..."
|
|
472
|
+
|
|
473
|
+
# 优先拷贝到 launcher 目录
|
|
474
|
+
launcher_dirs = [
|
|
475
|
+
File.join(project_dir, 'unityLibrary', 'launcher'), # Unity 项目的 launcher
|
|
476
|
+
File.join(project_dir, 'launcher'), # 独立的 launcher
|
|
477
|
+
File.join(project_dir, 'app') # 原生 Android 项目
|
|
478
|
+
]
|
|
479
|
+
|
|
480
|
+
copied = false
|
|
481
|
+
launcher_dirs.each do |launcher_dir|
|
|
482
|
+
if File.exist?(launcher_dir) && File.directory?(launcher_dir)
|
|
483
|
+
target_file = File.join(launcher_dir, 'google-services.json')
|
|
484
|
+
FileUtils.cp(source_file, target_file)
|
|
485
|
+
puts " ✓ google-services.json 已拷贝到: #{launcher_dir}"
|
|
486
|
+
copied = true
|
|
487
|
+
|
|
488
|
+
# Unity 项目也拷贝到 unityLibrary 根目录
|
|
489
|
+
if launcher_dir.include?('unityLibrary/launcher')
|
|
490
|
+
unity_root = File.join(project_dir, 'unityLibrary')
|
|
491
|
+
if File.exist?(unity_root) && File.directory?(unity_root)
|
|
492
|
+
unity_target = File.join(unity_root, 'google-services.json')
|
|
493
|
+
FileUtils.cp(source_file, unity_target)
|
|
494
|
+
puts " ✓ google-services.json 也已拷贝到: unityLibrary/"
|
|
495
|
+
end
|
|
496
|
+
end
|
|
497
|
+
|
|
498
|
+
break # 找到第一个有效目录后停止
|
|
499
|
+
end
|
|
500
|
+
end
|
|
501
|
+
|
|
502
|
+
unless copied
|
|
503
|
+
# 如果没找到合适的目录,至少拷贝到项目根目录
|
|
504
|
+
target_file = File.join(project_dir, 'google-services.json')
|
|
505
|
+
FileUtils.cp(source_file, target_file)
|
|
506
|
+
puts " ✓ google-services.json 已拷贝到项目根目录"
|
|
507
|
+
puts " ⚠ 请确认文件位置是否正确"
|
|
508
|
+
end
|
|
509
|
+
|
|
510
|
+
return true
|
|
511
|
+
end
|
|
512
|
+
|
|
513
|
+
# 从配置仓库应用配置(拷贝 config.json)
|
|
514
|
+
# @param config_repo_dir [String] 配置仓库的路径
|
|
515
|
+
# @param project_dir [String] Android项目目录路径
|
|
516
|
+
# @return [Boolean] 是否成功应用
|
|
517
|
+
def self.apply_config_from_repo(config_repo_dir: nil, project_dir: nil)
|
|
518
|
+
# 参数验证
|
|
519
|
+
if config_repo_dir.nil? || !File.directory?(config_repo_dir)
|
|
520
|
+
Funlog.instance.fancyinfo_error("配置仓库路径无效: #{config_repo_dir}")
|
|
521
|
+
return false
|
|
522
|
+
end
|
|
523
|
+
|
|
524
|
+
if project_dir.nil? || !File.directory?(project_dir)
|
|
525
|
+
Funlog.instance.fancyinfo_error("项目路径无效: #{project_dir}")
|
|
526
|
+
return false
|
|
527
|
+
end
|
|
528
|
+
|
|
529
|
+
# 拷贝 config.json 到项目目录
|
|
530
|
+
config_source = File.join(config_repo_dir, 'config.json')
|
|
531
|
+
if File.exist?(config_source)
|
|
532
|
+
config_target = File.join(project_dir, 'config.json')
|
|
533
|
+
FileUtils.cp(config_source, config_target)
|
|
534
|
+
puts " ✓ config.json 已拷贝到项目目录"
|
|
535
|
+
return true
|
|
536
|
+
else
|
|
537
|
+
puts " ⚠ 配置仓库中未找到 config.json"
|
|
538
|
+
return false
|
|
539
|
+
end
|
|
540
|
+
end
|
|
541
|
+
|
|
307
542
|
# 添加测试scheme到Android工程
|
|
308
543
|
# @param project_dir [String] Android项目目录路径
|
|
309
544
|
# @param scheme_name [String] 要添加的scheme名称
|
|
@@ -322,11 +557,8 @@ module Pindo
|
|
|
322
557
|
|
|
323
558
|
scheme_name = scheme_name.to_s.gsub(/[^a-zA-Z0-9]/, '').downcase
|
|
324
559
|
|
|
325
|
-
# 创建helper实例以使用基类方法
|
|
326
|
-
helper = self.new
|
|
327
|
-
|
|
328
560
|
# 查找所有可能的模块(添加 launcher 支持 Unity 项目)
|
|
329
|
-
main_module =
|
|
561
|
+
main_module = Pindo::AndroidProjectHelper.get_main_module(project_dir)
|
|
330
562
|
search_modules = ["launcher", "app", "unityLibrary"]
|
|
331
563
|
search_modules << main_module if main_module
|
|
332
564
|
search_modules = search_modules.compact.uniq
|