Class: Pindo::Command::Appstore::Cert
- Inherits:
-
Pindo::Command::Appstore
- Object
- CLAide::Command
- Pindo::Command
- Pindo::Command::Appstore
- Pindo::Command::Appstore::Cert
- Defined in:
- lib/pindo/command/appstore/cert.rb
Constant Summary
Constants inherited from Pindo::Command
DEFAULT_OPTIONS, DEFAULT_ROOT_OPTIONS
Instance Attribute Summary
Attributes inherited from Pindo::Command
Class Method Summary collapse
-
.option_items ⇒ Object
定义此命令使用的参数项.
-
.options ⇒ Object
命令的选项列表.
Instance Method Summary collapse
-
#initialize(argv) ⇒ Cert
constructor
A new instance of Cert.
- #run ⇒ Object
Methods inherited from Pindo::Command
command_name, #initialize_options, run, use_cache?, #validate!
Methods included from Funlog::Mixin
Methods included from Pindoconfig::Mixin
Constructor Details
#initialize(argv) ⇒ Cert
Returns a new instance of Cert.
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/pindo/command/appstore/cert.rb', line 109 def initialize(argv) # 使用 Options 模块初始化参数 = (argv) # 保存参数到实例变量 @config_file = [:config] @build_type = [:build_type] @platform_type = [:platform] @clean_flag = [:clean] @clean_git_flag = [:cleangit] @renew_cert_flag = [:renew] @match_flag = [:match] @upload_flag = [:upload] super end |
Class Method Details
.option_items ⇒ Object
定义此命令使用的参数项
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/pindo/command/appstore/cert.rb', line 43 def self.option_items @option_items ||= [ Pindo::Options::OptionItem.new( key: :config, description: '指定 config.json 文件路径', type: String, optional: true ), Pindo::Options::OptionItem.new( key: :build_type, description: '构建类型 (dev/adhoc/release)', type: String, optional: true, default_value: 'release' ), Pindo::Options::OptionItem.new( key: :renew, description: '重新生成证书', type: :boolean, optional: true, default_value: false ), Pindo::Options::OptionItem.new( key: :platform, description: '平台类型 (ios/macos)', type: String, optional: true, default_value: 'ios' ), Pindo::Options::OptionItem.new( key: :clean, description: '删除本地缓存的证书', type: :boolean, optional: true, default_value: false ), Pindo::Options::OptionItem.new( key: :cleangit, description: '删除远程仓库中的证书', type: :boolean, optional: true, default_value: false ), Pindo::Options::OptionItem.new( key: :match, description: '使用 match 生成证书', type: :boolean, optional: true, default_value: false ), Pindo::Options::OptionItem.new( key: :upload, description: '生成上传 JPS 的证书', type: :boolean, optional: true, default_value: false ) ] end |
.options ⇒ Object
命令的选项列表
105 106 107 |
# File 'lib/pindo/command/appstore/cert.rb', line 105 def self. option_items.map { |item| item.to_claide_option }.concat(super) end |
Instance Method Details
#run ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/pindo/command/appstore/cert.rb', line 126 def run # 标准化构建类型 (dev/adhoc/release -> development/adhoc/appstore) @cert_type = Pindo::XcodeCertHelper.normalize_build_type(@build_type) # 加载配置文件 config_file_path = @config_file || File.join(Dir.pwd, "config.json") @config_parser = Pindo::IosConfigParser.instance @config_parser.load_config(config_file: config_file_path) # 获取配置信息 @apple_id = @config_parser.apple_id @group_id = @config_parser.group_id @icloud_id = @config_parser.icloud_id # 清理本地证书 if @clean_flag puts "清理本地证书..." Pindo::CertHelper.clean_local_certs end # 清理远程 Git 证书 if @renew_cert_flag && @clean_git_flag Pindo::CertHelper.clean_git_certs( apple_id: @apple_id, pindo_dir: pindo_single_config.pindo_dir, deploy_cert_giturl: pindo_single_config.deploy_cert_giturl, dev_cert_giturl: pindo_single_config.dev_cert_giturl, demo_apple_id: pindo_single_config.demo_apple_id ) end bundle_id_array = @config_parser.get_bundle_id_array provisioning_info_array = nil if @renew_cert_flag || @match_flag # 创建新证书 values = Pindo::XcodeCertHelper.get_create_cert_match_values( apple_id: @apple_id, bundle_id_array: bundle_id_array, build_type: @cert_type, platform_type: @platform_type, renew_flag: @renew_cert_flag ) config = FastlaneCore::Configuration.create(Match::Options., values) Match::Runner.new.run(config) provisioning_info_array = Pindo::XcodeCertHelper.create_provisioning_info_array( build_type: @cert_type, platform_type: @platform_type ) pindo_single_config.set_cert_info(dict: provisioning_info_array) # 获取 team_id raise Informative, "未找到证书信息" if provisioning_info_array.nil? || provisioning_info_array.empty? @team_id_value = provisioning_info_array.first["team_id"] else # 使用新封装的方法安装证书并配置 Xcode result = Pindo::XcodeCertHelper.install_and_config_certs( build_type: @cert_type, platform_type: @platform_type, project_dir: Dir.pwd ) provisioning_info_array = result[:provisioning_info_array] @team_id_value = result[:team_id] end # 生成上传测试平台的证书 if @upload_flag Pindo::XcodeCertHelper.create_upload_cert_info( apple_id: @apple_id, cert_type: @cert_type, platform_type: @platform_type ) Pindo::XcodeCertHelper.create_upload_provisioning_info( apple_id: @apple_id, cert_type: @cert_type, platform_type: @platform_type, provisioning_info_array: provisioning_info_array ) end puts "✓ 证书配置完成!" end |