Module: Pindo::Options::CertOptions

Extended by:
OptionGroup
Defined in:
lib/pindo/options/groups/cert_options.rb

Overview

证书管理参数组定义证书创建、获取和配置相关的参数

Constant Summary collapse

CERT_MODES =

证书操作方式的有效值

%w[match custom].freeze
STORAGE_TYPES =

证书存储后端的有效值

%w[git https s3].freeze
BUILD_TYPES =

构建类型的有效值(包含用户输入的所有变体)

%w[dev development adhoc release appstore developer_id develop_id].freeze
PLATFORM_TYPES =

平台类型的有效值

%w[ios macos].freeze

Class Method Summary collapse

Methods included from OptionGroup

all, all_options, except, merge, select, select_with_defaults

Class Method Details

.all_optionsObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
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
# File 'lib/pindo/options/groups/cert_options.rb', line 23

def self.all_options
  @all_options ||= {
    config: OptionItem.new(
      key: :config,
      name: '配置文件路径',
      description: '指定 config.json 文件路径',
      type: String,
      env_name: 'PINDO_CERT_CONFIG',
      optional: true,
      example: 'pindo appstore cert --config=/path/config.json'
    ),

    renew: OptionItem.new(
      key: :renew,
      name: '重新生成证书',
      description: '重新生成证书(创建模式)',
      type: OptionItem::Boolean,
      env_name: 'PINDO_CERT_RENEW',
      default_value: false,
      optional: true,
      example: 'pindo appstore cert --renew'
    ),

    platform: OptionItem.new(
      key: :platform,
      name: '平台类型',
      description: '平台类型: ios 或 macos',
      type: String,
      env_name: 'PINDO_PLATFORM',
      default_value: 'ios',
      optional: true,
      cacheable: true,
      verify_block: proc do |value|
        unless PLATFORM_TYPES.include?(value.to_s.downcase)
          raise "平台类型错误: #{value},必须是 #{PLATFORM_TYPES.join(', ')} 之一"
        end
      end,
      example: 'pindo appstore cert --platform=macos'
    ),

    # 平台类型快捷方式
    macos: OptionItem.new(
      key: :macos,
      name: '使用 macOS 平台',
      description: '使用 macOS 平台(等价于 --platform=macos)',
      type: OptionItem::Boolean,
      env_name: 'PINDO_CERT_MACOS',
      optional: true,
      default_value: false,
      example: 'pindo appstore cert --develop_id --macos'
    ),

    clean: OptionItem.new(
      key: :clean,
      name: '清理本地证书',
      description: '删除本地缓存的证书和 Provisioning Profiles',
      type: OptionItem::Boolean,
      env_name: 'PINDO_CERT_CLEAN',
      default_value: false,
      optional: true,
      example: 'pindo appstore cert --clean'
    ),

    cleangit: OptionItem.new(
      key: :cleangit,
      name: '清理远程证书',
      description: '删除远程 Git 仓库中的证书(需要配合 --renew 使用)',
      type: OptionItem::Boolean,
      env_name: 'PINDO_CERT_CLEANGIT',
      default_value: false,
      optional: true,
      example: 'pindo appstore cert --renew --cleangit'
    ),

    match: OptionItem.new(
      key: :match,
      name: '使用 Match',
      description: '使用 fastlane match 管理证书(等价于 --cert-mode=match --storage=git)',
      type: OptionItem::Boolean,
      env_name: 'PINDO_CERT_MATCH',
      default_value: false,
      optional: true,
      example: 'pindo appstore cert --match'
    ),

    upload: OptionItem.new(
      key: :upload,
      name: '生成上传证书',
      description: '生成上传 JPS 测试平台的证书',
      type: OptionItem::Boolean,
      env_name: 'PINDO_CERT_UPLOAD',
      default_value: false,
      optional: true,
      example: 'pindo appstore cert --upload'
    ),

    cert_mode: OptionItem.new(
      key: :cert_mode,
      name: '证书操作方式',
      description: '证书操作方式: match(使用 fastlane match), custom(自定义方式)',
      type: String,
      env_name: 'PINDO_CERT_MODE',
      default_value: nil,
      optional: true,
      cacheable: true,
      verify_block: proc do |value|
        next if value.nil?  # 允许 nil 值
        unless CERT_MODES.include?(value.to_s.downcase)
          raise "证书操作方式错误: #{value},必须是 #{CERT_MODES.join(', ')} 之一"
        end
      end,
      example: 'pindo appstore cert --cert-mode=match'
    ),

    storage: OptionItem.new(
      key: :storage,
      name: '证书存储后端',
      description: '证书存储后端: git(Git仓库), https(HTTPS服务器), s3(AWS S3)',
      type: String,
      env_name: 'PINDO_CERT_STORAGE',
      default_value: nil,
      optional: true,
      cacheable: true,
      verify_block: proc do |value|
        next if value.nil?  # 允许 nil 值
        unless STORAGE_TYPES.include?(value.to_s.downcase)
          raise "证书存储后端错误: #{value},必须是 #{STORAGE_TYPES.join(', ')} 之一"
        end
      end,
      example: 'pindo appstore cert --storage=git'
    )
  }
end

.normalize_build_type(build_type) ⇒ String

标准化构建类型(委托给 BuildOptions)

将用户输入的构建类型标准化为证书系统使用的类型

  • dev/development -> development

  • adhoc -> adhoc

  • release/appstore -> appstore

  • develop_id/developer_id -> developer_id

Parameters:

  • build_type (String, Symbol)

    构建类型

Returns:

  • (String)

    标准化后的证书类型



181
182
183
184
# File 'lib/pindo/options/groups/cert_options.rb', line 181

def self.normalize_build_type(build_type)
  require 'pindo/options/groups/build_options'
  BuildOptions.normalize_build_type(build_type)
end

.parse_cert_mode(value) ⇒ String

解析证书操作方式

Parameters:

  • value (String)

    命令行参数值 (match/custom)

Returns:

  • (String)

    标准化后的值



160
161
162
# File 'lib/pindo/options/groups/cert_options.rb', line 160

def self.parse_cert_mode(value)
  value.to_s.downcase
end

.parse_storage_type(value) ⇒ String

解析存储类型

Parameters:

  • value (String)

    命令行参数值 (git/https/s3)

Returns:

  • (String)

    标准化后的值



167
168
169
# File 'lib/pindo/options/groups/cert_options.rb', line 167

def self.parse_storage_type(value)
  value.to_s.downcase
end