pindo 5.15.1 → 5.15.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 +4 -4
- data/lib/pindo/base/aeshelper.rb +42 -0
- data/lib/pindo/command/appstore/cert.rb +86 -98
- data/lib/pindo/command/ios/autobuild.rb +4 -1
- data/lib/pindo/command/ios/cert.rb +190 -41
- data/lib/pindo/command/ios/fixproj.rb +71 -34
- data/lib/pindo/command/unity/packpush.rb +22 -6
- data/lib/pindo/command/utils/decrypt.rb +231 -0
- data/lib/pindo/command/utils/encrypt.rb +208 -0
- data/lib/pindo/command/utils/renewcert.rb +0 -1
- data/lib/pindo/command/utils.rb +2 -0
- data/lib/pindo/command.rb +2 -2
- data/lib/pindo/config/build_info_manager.rb +1 -1
- data/lib/pindo/config/pindoconfig.rb +17 -1
- data/lib/pindo/module/android/android_config_helper.rb +5 -3
- data/lib/pindo/module/cert/cert_helper.rb +410 -184
- data/lib/pindo/module/cert/mode/base_cert_operator.rb +515 -0
- data/lib/pindo/module/cert/mode/custom_git_cert_operator.rb +337 -0
- data/lib/pindo/module/cert/mode/custom_https_cert_operator.rb +538 -0
- data/lib/pindo/module/cert/mode/match_git_cert_operator.rb +250 -0
- data/lib/pindo/module/task/model/build/ios_build_adhoc_task.rb +3 -3
- data/lib/pindo/module/task/model/build/ios_build_appstore_task.rb +3 -3
- data/lib/pindo/module/task/model/build/ios_build_dev_task.rb +2 -2
- data/lib/pindo/module/task/model/build_task.rb +8 -5
- data/lib/pindo/module/utils/file_downloader.rb +318 -0
- data/lib/pindo/module/xcode/xcode_build_config.rb +5 -3
- data/lib/pindo/options/core/option_initializer.rb +17 -8
- data/lib/pindo/options/groups/build_options.rb +30 -5
- data/lib/pindo/options/groups/cert_options.rb +240 -0
- data/lib/pindo/options/helpers/bundleid_selector.rb +9 -6
- data/lib/pindo/version.rb +1 -1
- metadata +13 -7
- data/lib/pindo/module/build/icon_downloader.rb +0 -85
- data/lib/pindo/module/cert/xcode_cert_helper.rb +0 -703
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 931d648cd4154c3372f8be276a3f8c1ba343c1ee521997a5b2fc593ea5e4cb18
|
|
4
|
+
data.tar.gz: 8859ad809b6006f3709b315b6eb830eecd670eb77d49c8109a504f82519acd8d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cf977c0431a53abcbcc6da091da61ccbbca6dc420c03507977aef574b4cb85f45ff5f628d021ac8ece839d2fd17362527b5f260d6e76b466fa30c95513fb05ae
|
|
7
|
+
data.tar.gz: 2b91cb9a006234e86bbc5b66040bbc54ebf7a2c75d01acb8fa44524d7811e321de1de882f3ee84b498b19e1686be73b51f46f8df51bfeb5599214e2498fa680d
|
data/lib/pindo/base/aeshelper.rb
CHANGED
|
@@ -8,7 +8,49 @@ module Pindo
|
|
|
8
8
|
|
|
9
9
|
module AESHelper
|
|
10
10
|
|
|
11
|
+
# 密码内存缓存,避免重复从 Keychain 获取
|
|
12
|
+
# key: keychain_name, value: password
|
|
13
|
+
@@password_cache = {}
|
|
14
|
+
|
|
15
|
+
# ========================================
|
|
16
|
+
# 密码管理方法(带缓存)
|
|
17
|
+
# ========================================
|
|
18
|
+
|
|
19
|
+
# 获取密码(带内存缓存)
|
|
20
|
+
# 优先从内存缓存获取,缓存未命中时从 Keychain 读取
|
|
21
|
+
# @param keychain_name [String] Keychain 名称
|
|
22
|
+
# @return [String] 密码
|
|
23
|
+
def self.get_password(keychain_name:)
|
|
24
|
+
unless @@password_cache[keychain_name]
|
|
25
|
+
puts "\e[33m[DEBUG] 密码缓存中未找到,从 Keychain 获取: #{keychain_name}\e[0m" if ENV['PINDO_DEBUG']
|
|
26
|
+
@@password_cache[keychain_name] = fetch_password(keychain_name: keychain_name)
|
|
27
|
+
puts "\e[32m[DEBUG] 密码已缓存: #{keychain_name}\e[0m" if ENV['PINDO_DEBUG']
|
|
28
|
+
else
|
|
29
|
+
puts "\e[32m[DEBUG] 从密码缓存获取: #{keychain_name}\e[0m" if ENV['PINDO_DEBUG']
|
|
30
|
+
end
|
|
31
|
+
@@password_cache[keychain_name]
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# 清除所有密码缓存
|
|
35
|
+
def self.clear_password_cache
|
|
36
|
+
@@password_cache.clear
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# 清除特定 keychain_name 的密码缓存
|
|
40
|
+
# @param keychain_name [String] Keychain 名称
|
|
41
|
+
def self.clear_password_cache_for(keychain_name:)
|
|
42
|
+
@@password_cache.delete(keychain_name)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# ========================================
|
|
46
|
+
# Keychain 操作方法
|
|
47
|
+
# ========================================
|
|
11
48
|
|
|
49
|
+
# 从 Keychain 获取密码(不使用缓存)
|
|
50
|
+
# 如果 Keychain 中不存在,则提示用户输入
|
|
51
|
+
# @param keychain_name [String] Keychain 名称
|
|
52
|
+
# @param test_file [String, nil] 测试文件(可选)
|
|
53
|
+
# @return [String] 密码
|
|
12
54
|
def self.fetch_password(keychain_name:nil, test_file:nil)
|
|
13
55
|
# password = ENV["MATCH_PASSWORD"]
|
|
14
56
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
require 'fileutils'
|
|
2
2
|
require 'match'
|
|
3
3
|
require 'pindo/module/build/swark_helper'
|
|
4
|
-
require 'pindo/module/cert/xcode_cert_helper'
|
|
5
4
|
require 'pindo/module/cert/cert_helper'
|
|
6
5
|
require 'pindo/config/ios_config_parser'
|
|
7
6
|
require 'pindo/base/git_handler'
|
|
7
|
+
require 'pindo/options/groups/cert_options'
|
|
8
8
|
|
|
9
9
|
module Pindo
|
|
10
10
|
class Command
|
|
@@ -26,10 +26,13 @@ module Pindo
|
|
|
26
26
|
|
|
27
27
|
使用示例:
|
|
28
28
|
|
|
29
|
-
$ pindo appstore cert # 创建 appstore
|
|
30
|
-
$ pindo appstore cert --
|
|
31
|
-
$ pindo appstore cert --
|
|
32
|
-
$ pindo appstore cert --
|
|
29
|
+
$ pindo appstore cert # 创建 appstore 证书(默认)
|
|
30
|
+
$ pindo appstore cert --dev # 创建开发证书(快捷方式)
|
|
31
|
+
$ pindo appstore cert --adhoc # 创建 adhoc 证书(快捷方式)
|
|
32
|
+
$ pindo appstore cert --build_type=dev # 创建开发证书(显式指定)
|
|
33
|
+
$ pindo appstore cert --develop_id --macos # 创建 macOS Developer ID 证书(推荐)
|
|
34
|
+
$ pindo appstore cert --develop_id --platform=macos # 创建 macOS Developer ID 证书(完整写法)
|
|
35
|
+
$ pindo appstore cert --macos # macOS 平台 appstore 证书
|
|
33
36
|
$ pindo appstore cert --renew # 重新生成证书
|
|
34
37
|
$ pindo appstore cert --clean # 清理本地证书
|
|
35
38
|
$ pindo appstore cert --config=/path/config.json # 指定配置文件
|
|
@@ -39,66 +42,9 @@ module Pindo
|
|
|
39
42
|
# 无位置参数
|
|
40
43
|
]
|
|
41
44
|
|
|
42
|
-
#
|
|
45
|
+
# 定义此命令使用的参数项(使用 CertOptions)
|
|
43
46
|
def self.option_items
|
|
44
|
-
@option_items ||=
|
|
45
|
-
Pindo::Options::OptionItem.new(
|
|
46
|
-
key: :config,
|
|
47
|
-
description: '指定 config.json 文件路径',
|
|
48
|
-
type: String,
|
|
49
|
-
optional: true
|
|
50
|
-
),
|
|
51
|
-
Pindo::Options::OptionItem.new(
|
|
52
|
-
key: :build_type,
|
|
53
|
-
description: '构建类型 (dev/adhoc/release)',
|
|
54
|
-
type: String,
|
|
55
|
-
optional: true,
|
|
56
|
-
default_value: 'release'
|
|
57
|
-
),
|
|
58
|
-
Pindo::Options::OptionItem.new(
|
|
59
|
-
key: :renew,
|
|
60
|
-
description: '重新生成证书',
|
|
61
|
-
type: :boolean,
|
|
62
|
-
optional: true,
|
|
63
|
-
default_value: false
|
|
64
|
-
),
|
|
65
|
-
Pindo::Options::OptionItem.new(
|
|
66
|
-
key: :platform,
|
|
67
|
-
description: '平台类型 (ios/macos)',
|
|
68
|
-
type: String,
|
|
69
|
-
optional: true,
|
|
70
|
-
default_value: 'ios'
|
|
71
|
-
),
|
|
72
|
-
Pindo::Options::OptionItem.new(
|
|
73
|
-
key: :clean,
|
|
74
|
-
description: '删除本地缓存的证书',
|
|
75
|
-
type: :boolean,
|
|
76
|
-
optional: true,
|
|
77
|
-
default_value: false
|
|
78
|
-
),
|
|
79
|
-
Pindo::Options::OptionItem.new(
|
|
80
|
-
key: :cleangit,
|
|
81
|
-
description: '删除远程仓库中的证书',
|
|
82
|
-
type: :boolean,
|
|
83
|
-
optional: true,
|
|
84
|
-
default_value: false
|
|
85
|
-
),
|
|
86
|
-
|
|
87
|
-
Pindo::Options::OptionItem.new(
|
|
88
|
-
key: :match,
|
|
89
|
-
description: '使用 match 生成证书',
|
|
90
|
-
type: :boolean,
|
|
91
|
-
optional: true,
|
|
92
|
-
default_value: false
|
|
93
|
-
),
|
|
94
|
-
Pindo::Options::OptionItem.new(
|
|
95
|
-
key: :upload,
|
|
96
|
-
description: '生成上传 JPS 的证书',
|
|
97
|
-
type: :boolean,
|
|
98
|
-
optional: true,
|
|
99
|
-
default_value: false
|
|
100
|
-
)
|
|
101
|
-
]
|
|
47
|
+
@option_items ||= Pindo::Options::CertOptions.all
|
|
102
48
|
end
|
|
103
49
|
|
|
104
50
|
# 命令的选项列表
|
|
@@ -110,6 +56,12 @@ module Pindo
|
|
|
110
56
|
# 使用 Options 模块初始化参数
|
|
111
57
|
@options = initialize_options(argv)
|
|
112
58
|
|
|
59
|
+
# 证书类型快捷参数
|
|
60
|
+
@args_dev_flag = @options[:dev]
|
|
61
|
+
@args_adhoc_flag = @options[:adhoc]
|
|
62
|
+
@args_develop_id_flag = @options[:develop_id]
|
|
63
|
+
@args_macos_flag = @options[:macos]
|
|
64
|
+
|
|
113
65
|
# 保存参数到实例变量
|
|
114
66
|
@config_file = @options[:config]
|
|
115
67
|
@build_type = @options[:build_type]
|
|
@@ -119,13 +71,48 @@ module Pindo
|
|
|
119
71
|
@renew_cert_flag = @options[:renew]
|
|
120
72
|
@match_flag = @options[:match]
|
|
121
73
|
@upload_flag = @options[:upload]
|
|
74
|
+
@cert_mode = @options[:cert_mode]
|
|
75
|
+
@storage = @options[:storage]
|
|
76
|
+
|
|
77
|
+
# appstore cert 命令默认值
|
|
78
|
+
@cert_mode ||= 'match' # 默认使用 Match 模式
|
|
79
|
+
@storage ||= 'git' # 默认使用 Git 存储
|
|
80
|
+
|
|
81
|
+
# 参数优先级:--develop_id > --adhoc > --dev > 用户指定的 build_type > 默认 appstore
|
|
82
|
+
if @args_develop_id_flag
|
|
83
|
+
@build_type = 'developer_id'
|
|
84
|
+
elsif @args_adhoc_flag
|
|
85
|
+
@build_type = 'adhoc'
|
|
86
|
+
elsif @args_dev_flag
|
|
87
|
+
@build_type = 'dev'
|
|
88
|
+
elsif @build_type.nil? || @build_type.empty?
|
|
89
|
+
@build_type = 'appstore' # 默认使用 appstore 证书
|
|
90
|
+
end
|
|
91
|
+
# 如果用户明确指定了 --build_type,则保持用户指定的值
|
|
92
|
+
|
|
93
|
+
# 标准化构建类型(dev -> development, release -> appstore)
|
|
94
|
+
@build_type = Pindo::Options::CertOptions.normalize_build_type(@build_type)
|
|
95
|
+
|
|
96
|
+
# 处理平台类型
|
|
97
|
+
if @args_macos_flag
|
|
98
|
+
@platform_type = 'macos'
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# macOS 平台特殊处理(向后兼容:adhoc → developer_id)
|
|
102
|
+
if @platform_type == 'macos' && @build_type == 'adhoc'
|
|
103
|
+
@build_type = 'developer_id'
|
|
104
|
+
end
|
|
122
105
|
|
|
123
106
|
super
|
|
124
107
|
end
|
|
125
108
|
|
|
126
109
|
def run
|
|
127
|
-
#
|
|
128
|
-
|
|
110
|
+
# ============================================
|
|
111
|
+
# 1. 前置处理:配置加载和清理逻辑
|
|
112
|
+
# ============================================
|
|
113
|
+
|
|
114
|
+
# @build_type 已在 initialize 中标准化
|
|
115
|
+
@cert_type = @build_type
|
|
129
116
|
|
|
130
117
|
# 加载配置文件
|
|
131
118
|
config_file_path = @config_file || File.join(Dir.pwd, "config.json")
|
|
@@ -136,6 +123,7 @@ module Pindo
|
|
|
136
123
|
@apple_id = @config_parser.apple_id
|
|
137
124
|
@group_id = @config_parser.group_id
|
|
138
125
|
@icloud_id = @config_parser.icloud_id
|
|
126
|
+
|
|
139
127
|
# 清理本地证书
|
|
140
128
|
if @clean_flag
|
|
141
129
|
puts "清理本地证书..."
|
|
@@ -153,55 +141,55 @@ module Pindo
|
|
|
153
141
|
)
|
|
154
142
|
end
|
|
155
143
|
|
|
144
|
+
# ============================================
|
|
145
|
+
# 2. 执行证书操作(通过 CertHelper 门面)
|
|
146
|
+
# ============================================
|
|
147
|
+
|
|
156
148
|
bundle_id_array = @config_parser.get_bundle_id_array
|
|
157
|
-
provisioning_info_array = nil
|
|
158
149
|
|
|
159
|
-
if @renew_cert_flag
|
|
160
|
-
#
|
|
161
|
-
|
|
150
|
+
if @renew_cert_flag
|
|
151
|
+
# 创建证书模式
|
|
152
|
+
provisioning_info_array = Pindo::CertHelper.create_and_install_certs(
|
|
153
|
+
cert_mode: @cert_mode,
|
|
154
|
+
storage: @storage,
|
|
162
155
|
apple_id: @apple_id,
|
|
163
156
|
bundle_id_array: bundle_id_array,
|
|
164
|
-
|
|
157
|
+
cert_type: @cert_type,
|
|
165
158
|
platform_type: @platform_type,
|
|
166
|
-
|
|
159
|
+
match_flag: @match_flag
|
|
167
160
|
)
|
|
168
|
-
config = FastlaneCore::Configuration.create(Match::Options.available_options, values)
|
|
169
|
-
|
|
170
|
-
# 注意:fastlane match 可能会产生 '--template_name' 弃用警告
|
|
171
|
-
# 这是 fastlane 内部使用的参数,在 App Store Connect API v3.8.0 中已弃用
|
|
172
|
-
# 该警告不影响功能,fastlane 会自动处理兼容性
|
|
173
|
-
# 参考:https://docs.fastlane.tools/actions/match/#managed-capabilities
|
|
174
|
-
Match::Runner.new.run(config)
|
|
175
|
-
|
|
176
|
-
provisioning_info_array = Pindo::XcodeCertHelper.create_provisioning_info_array(
|
|
177
|
-
build_type: @cert_type,
|
|
178
|
-
platform_type: @platform_type
|
|
179
|
-
)
|
|
180
|
-
pindo_single_config.set_cert_info(dict: provisioning_info_array)
|
|
181
|
-
|
|
182
|
-
# 获取 team_id
|
|
183
|
-
raise Informative, "未找到证书信息" if provisioning_info_array.nil? || provisioning_info_array.empty?
|
|
184
|
-
@team_id_value = provisioning_info_array.first["team_id"]
|
|
185
161
|
else
|
|
186
|
-
#
|
|
187
|
-
|
|
188
|
-
|
|
162
|
+
# 获取证书模式
|
|
163
|
+
provisioning_info_array = Pindo::CertHelper.fetch_and_install_certs(
|
|
164
|
+
cert_mode: @cert_mode,
|
|
165
|
+
storage: @storage,
|
|
166
|
+
apple_id: @apple_id,
|
|
167
|
+
bundle_id_array: bundle_id_array,
|
|
168
|
+
cert_type: @cert_type,
|
|
189
169
|
platform_type: @platform_type,
|
|
190
|
-
project_dir: Dir.pwd
|
|
170
|
+
project_dir: Dir.pwd,
|
|
171
|
+
match_flag: @match_flag
|
|
191
172
|
)
|
|
173
|
+
end
|
|
192
174
|
|
|
193
|
-
|
|
194
|
-
|
|
175
|
+
# 验证证书信息
|
|
176
|
+
if provisioning_info_array.nil? || provisioning_info_array.empty?
|
|
177
|
+
raise Informative, "未找到证书信息"
|
|
195
178
|
end
|
|
196
179
|
|
|
197
|
-
|
|
180
|
+
@team_id_value = provisioning_info_array.first["team_id"]
|
|
181
|
+
|
|
182
|
+
# ============================================
|
|
183
|
+
# 3. 后置处理:生成上传测试平台的证书
|
|
184
|
+
# ============================================
|
|
185
|
+
|
|
198
186
|
if @upload_flag
|
|
199
|
-
Pindo::
|
|
187
|
+
Pindo::CertHelper.create_upload_cert_info(
|
|
200
188
|
apple_id: @apple_id,
|
|
201
189
|
cert_type: @cert_type,
|
|
202
190
|
platform_type: @platform_type
|
|
203
191
|
)
|
|
204
|
-
Pindo::
|
|
192
|
+
Pindo::CertHelper.create_upload_provisioning_info(
|
|
205
193
|
apple_id: @apple_id,
|
|
206
194
|
cert_type: @cert_type,
|
|
207
195
|
platform_type: @platform_type,
|
|
@@ -120,7 +120,10 @@ module Pindo
|
|
|
120
120
|
@args_proj_name = @options[:proj]
|
|
121
121
|
@args_bundle_id = @options[:bundleid]
|
|
122
122
|
@build_type = @options[:build_type] || 'dev'
|
|
123
|
-
|
|
123
|
+
|
|
124
|
+
# 标准化构建类型(dev -> development, release -> appstore)
|
|
125
|
+
@build_type = Pindo::Options::BuildOptions.normalize_build_type(@build_type)
|
|
126
|
+
|
|
124
127
|
|
|
125
128
|
# send、media 或 bind 都依赖 upload:如果指定了任一参数,自动启用 upload
|
|
126
129
|
@args_upload_flag = @options[:send] || @options[:bind] || @options[:media] || @options[:upload]
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
require 'fileutils'
|
|
2
|
+
require 'pindo/module/cert/cert_helper'
|
|
3
|
+
require 'pindo/options/groups/cert_options'
|
|
4
|
+
require 'pindo/options/groups/build_options'
|
|
2
5
|
|
|
3
6
|
module Pindo
|
|
4
7
|
class Command
|
|
5
8
|
class Ios < Command
|
|
6
9
|
class Cert < Ios
|
|
7
|
-
|
|
10
|
+
|
|
8
11
|
include Appselect
|
|
9
12
|
|
|
10
13
|
# 命令的简要说明 - 更新证书并设置工程
|
|
@@ -24,46 +27,116 @@ module Pindo
|
|
|
24
27
|
|
|
25
28
|
* 支持iOS和macOS平台
|
|
26
29
|
|
|
30
|
+
* 支持多种证书操作方式(match/custom)
|
|
31
|
+
|
|
32
|
+
* 支持多种存储后端(git/https/s3)
|
|
33
|
+
|
|
27
34
|
使用示例:
|
|
28
35
|
|
|
29
|
-
$ pindo ios cert #
|
|
36
|
+
$ pindo ios cert # 使用开发证书(默认: Custom + HTTPS)
|
|
37
|
+
|
|
38
|
+
$ pindo ios cert --dev # 明确指定使用开发证书
|
|
39
|
+
|
|
40
|
+
$ pindo ios cert --adhoc # 使用 AdHoc 证书
|
|
41
|
+
|
|
42
|
+
$ pindo ios cert --build_type=appstore # 使用 AppStore 证书
|
|
30
43
|
|
|
31
|
-
$ pindo ios cert --
|
|
44
|
+
$ pindo ios cert --develop_id --macos # 使用 macOS Developer ID 证书(推荐)
|
|
32
45
|
|
|
33
|
-
$ pindo ios cert --
|
|
46
|
+
$ pindo ios cert --develop_id --platform=macos # 使用 macOS Developer ID 证书(完整写法)
|
|
34
47
|
|
|
35
|
-
$ pindo ios cert --
|
|
48
|
+
$ pindo ios cert --match # 使用 fastlane match
|
|
49
|
+
|
|
50
|
+
$ pindo ios cert --renew --match # 重新创建证书
|
|
51
|
+
|
|
52
|
+
$ pindo ios cert --storage=git # 使用 Git 存储
|
|
36
53
|
DESC
|
|
37
54
|
|
|
38
55
|
# 命令的参数列表
|
|
39
56
|
self.arguments = [
|
|
40
57
|
# 暂无参数
|
|
41
58
|
]
|
|
42
|
-
|
|
59
|
+
|
|
60
|
+
# 定义此命令使用的参数项(直接使用 CertOptions)
|
|
61
|
+
def self.option_items
|
|
62
|
+
@option_items ||= Pindo::Options::CertOptions.all
|
|
63
|
+
end
|
|
64
|
+
|
|
43
65
|
# 命令的选项列表
|
|
44
66
|
def self.options
|
|
45
|
-
|
|
46
|
-
['--deploy', '使用发布bundle id(默认使用开发bundle id)'],
|
|
47
|
-
['--adhoc', '使用adhoc证书(默认使用dev证书)'],
|
|
48
|
-
['--macos', '使用macOS平台证书'],
|
|
49
|
-
].concat(super)
|
|
67
|
+
option_items.map { |item| item.to_claide_option }.concat(super)
|
|
50
68
|
end
|
|
51
69
|
|
|
52
70
|
def initialize(argv)
|
|
53
|
-
|
|
54
|
-
@
|
|
55
|
-
|
|
56
|
-
|
|
71
|
+
# 使用 Options 模块初始化参数
|
|
72
|
+
@options = initialize_options(argv)
|
|
73
|
+
|
|
74
|
+
# 证书快捷参数
|
|
75
|
+
@args_dev_flag = @options[:dev]
|
|
76
|
+
@args_adhoc_flag = @options[:adhoc]
|
|
77
|
+
@args_develop_id_flag = @options[:develop_id]
|
|
78
|
+
@args_macos_flag = @options[:macos]
|
|
79
|
+
|
|
80
|
+
# 证书参数
|
|
81
|
+
@config_file = @options[:config]
|
|
82
|
+
@clean_flag = @options[:clean]
|
|
83
|
+
@cleangit_flag = @options[:cleangit]
|
|
84
|
+
@renew_flag = @options[:renew]
|
|
85
|
+
@match_flag = @options[:match]
|
|
86
|
+
@upload_flag = @options[:upload]
|
|
87
|
+
@cert_mode = @options[:cert_mode]
|
|
88
|
+
@storage = @options[:storage]
|
|
89
|
+
|
|
90
|
+
# iOS cert 命令默认使用 Custom + HTTPS 模式
|
|
91
|
+
@cert_mode ||= 'custom'
|
|
92
|
+
@storage ||= 'https'
|
|
93
|
+
|
|
94
|
+
# 根据快捷参数确定构建类型
|
|
95
|
+
@build_type = @options[:build_type]
|
|
96
|
+
|
|
97
|
+
# 参数优先级:--develop_id > --adhoc > --dev > 用户指定的 build_type > 默认 dev
|
|
98
|
+
if @args_develop_id_flag
|
|
99
|
+
@build_type = 'developer_id'
|
|
100
|
+
elsif @args_adhoc_flag
|
|
101
|
+
@build_type = 'adhoc'
|
|
102
|
+
elsif @args_dev_flag
|
|
103
|
+
@build_type = 'dev'
|
|
104
|
+
elsif @build_type.nil? || @build_type.empty?
|
|
105
|
+
# build_type 为 nil 时,iOS cert 命令默认使用 dev
|
|
106
|
+
@build_type = 'dev'
|
|
107
|
+
end
|
|
108
|
+
# 如果用户明确指定了 --build_type,则保持用户指定的值
|
|
109
|
+
|
|
110
|
+
# 标准化构建类型(dev -> development, release -> appstore)
|
|
111
|
+
@build_type = Pindo::Options::CertOptions.normalize_build_type(@build_type)
|
|
112
|
+
|
|
113
|
+
# 处理平台类型
|
|
114
|
+
@platform_type = @options[:platform]
|
|
115
|
+
if @args_macos_flag
|
|
116
|
+
@platform_type = 'macos'
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# macOS 平台特殊处理(向后兼容:adhoc → developer_id)
|
|
120
|
+
if @platform_type == 'macos' && @build_type == 'adhoc'
|
|
121
|
+
@build_type = 'developer_id'
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
super
|
|
57
125
|
end
|
|
58
126
|
|
|
59
127
|
|
|
60
128
|
def run
|
|
129
|
+
# ============================================
|
|
130
|
+
# 1. 前置处理:获取 Bundle ID 和拉取配置
|
|
131
|
+
# ============================================
|
|
61
132
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
else
|
|
133
|
+
# 根据构建类型选择 Bundle ID
|
|
134
|
+
mainapp_bundleid = nil
|
|
135
|
+
if @build_type == 'development'
|
|
66
136
|
mainapp_bundleid = get_selected_dev_bundleid()
|
|
137
|
+
else
|
|
138
|
+
# adhoc、appstore、developer_id 使用发布 bundle id
|
|
139
|
+
mainapp_bundleid = get_selected_deploy_bundleid()
|
|
67
140
|
end
|
|
68
141
|
|
|
69
142
|
# 拉取应用配置
|
|
@@ -78,40 +151,116 @@ module Pindo
|
|
|
78
151
|
|
|
79
152
|
# 加载配置到 IosConfigParser
|
|
80
153
|
require 'pindo/config/ios_config_parser'
|
|
81
|
-
config_json_file = File.join(project_dir, "config.json")
|
|
154
|
+
config_json_file = @config_file || File.join(project_dir, "config.json")
|
|
82
155
|
Pindo::IosConfigParser.instance.load_config(config_file: config_json_file)
|
|
83
156
|
|
|
84
|
-
# 处理entitlements配置
|
|
157
|
+
# 处理 entitlements 配置
|
|
85
158
|
Pindo::XcodeBuildConfig.update_entitlements_config(project_dir: project_dir)
|
|
86
159
|
|
|
87
|
-
#
|
|
88
|
-
|
|
160
|
+
# 获取配置信息
|
|
161
|
+
apple_id = Pindo::IosConfigParser.instance.apple_id
|
|
162
|
+
bundle_id_array = Pindo::IosConfigParser.instance.get_bundle_id_array
|
|
89
163
|
|
|
90
|
-
#
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
@args_macos_flag = true
|
|
98
|
-
end
|
|
164
|
+
# ============================================
|
|
165
|
+
# 2. 确定平台类型
|
|
166
|
+
# ============================================
|
|
167
|
+
|
|
168
|
+
# 如果用户没有指定平台类型,则自动检测
|
|
169
|
+
if @platform_type.nil? || @platform_type.empty?
|
|
170
|
+
@platform_type = detect_platform_type(project_dir)
|
|
99
171
|
end
|
|
100
172
|
|
|
101
|
-
|
|
173
|
+
# ============================================
|
|
174
|
+
# 3. 清理操作(可选)
|
|
175
|
+
# ============================================
|
|
102
176
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
177
|
+
if @clean_flag
|
|
178
|
+
Funlog.instance.fancyinfo("清理本地证书...")
|
|
179
|
+
Pindo::CertHelper.clean_local_certs
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
if @renew_flag && @cleangit_flag
|
|
183
|
+
pindo_config = Pindoconfig.instance
|
|
184
|
+
Pindo::CertHelper.clean_git_certs(
|
|
185
|
+
apple_id: apple_id,
|
|
186
|
+
pindo_dir: pindo_config.pindo_dir,
|
|
187
|
+
deploy_cert_giturl: pindo_config.deploy_cert_giturl,
|
|
188
|
+
dev_cert_giturl: pindo_config.dev_cert_giturl,
|
|
189
|
+
demo_apple_id: pindo_config.demo_apple_id
|
|
190
|
+
)
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
# ============================================
|
|
194
|
+
# 4. 执行证书操作(通过 CertHelper 门面)
|
|
195
|
+
# ============================================
|
|
196
|
+
|
|
197
|
+
# @build_type 已在 initialize 中标准化
|
|
198
|
+
cert_type = @build_type
|
|
199
|
+
|
|
200
|
+
if @renew_flag
|
|
201
|
+
# 创建证书模式
|
|
202
|
+
provisioning_info_array = Pindo::CertHelper.create_and_install_certs(
|
|
203
|
+
cert_mode: @cert_mode,
|
|
204
|
+
storage: @storage,
|
|
205
|
+
apple_id: apple_id,
|
|
206
|
+
bundle_id_array: bundle_id_array,
|
|
207
|
+
cert_type: cert_type,
|
|
208
|
+
platform_type: @platform_type,
|
|
209
|
+
match_flag: @match_flag
|
|
210
|
+
)
|
|
211
|
+
else
|
|
212
|
+
# 获取证书模式(默认)
|
|
213
|
+
provisioning_info_array = Pindo::CertHelper.fetch_and_install_certs(
|
|
214
|
+
cert_mode: @cert_mode,
|
|
215
|
+
storage: @storage,
|
|
216
|
+
apple_id: apple_id,
|
|
217
|
+
bundle_id_array: bundle_id_array,
|
|
218
|
+
cert_type: cert_type,
|
|
219
|
+
platform_type: @platform_type,
|
|
220
|
+
project_dir: project_dir,
|
|
221
|
+
match_flag: @match_flag
|
|
222
|
+
)
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
# ============================================
|
|
226
|
+
# 5. 后置处理:生成上传测试平台的证书(可选)
|
|
227
|
+
# ============================================
|
|
228
|
+
|
|
229
|
+
if @upload_flag
|
|
230
|
+
Pindo::CertHelper.create_upload_cert_info(
|
|
231
|
+
apple_id: apple_id,
|
|
232
|
+
cert_type: cert_type,
|
|
233
|
+
platform_type: @platform_type
|
|
234
|
+
)
|
|
235
|
+
Pindo::CertHelper.create_upload_provisioning_info(
|
|
236
|
+
apple_id: apple_id,
|
|
237
|
+
cert_type: cert_type,
|
|
238
|
+
platform_type: @platform_type,
|
|
239
|
+
provisioning_info_array: provisioning_info_array
|
|
240
|
+
)
|
|
241
|
+
end
|
|
111
242
|
|
|
112
243
|
Funlog.instance.fancyinfo_success("证书安装和配置完成!")
|
|
113
244
|
end
|
|
114
245
|
|
|
246
|
+
private
|
|
247
|
+
|
|
248
|
+
# 自动检测平台类型(iOS 或 macOS)
|
|
249
|
+
# @param project_dir [String] 项目目录
|
|
250
|
+
# @return [String] 'ios' 或 'macos'
|
|
251
|
+
def detect_platform_type(project_dir)
|
|
252
|
+
project_fullname = Dir.glob(File.join(project_dir, "/*.xcodeproj")).max_by {|f| File.mtime(f)}
|
|
253
|
+
if !project_fullname.nil?
|
|
254
|
+
require 'xcodeproj'
|
|
255
|
+
project_obj = Xcodeproj::Project.open(project_fullname)
|
|
256
|
+
project_build_platform = project_obj.root_object.build_configuration_list.get_setting("SDKROOT")["Release"]
|
|
257
|
+
if !project_build_platform.nil? && project_build_platform.eql?("macosx")
|
|
258
|
+
return 'macos'
|
|
259
|
+
end
|
|
260
|
+
end
|
|
261
|
+
'ios'
|
|
262
|
+
end
|
|
263
|
+
|
|
115
264
|
|
|
116
265
|
end
|
|
117
266
|
end
|