Class: Pindo::Command::Ios::Autoresign

Inherits:
Pindo::Command::Ios show all
Includes:
Appselect
Defined in:
lib/pindo/command/ios/autoresign.rb

Constant Summary

Constants inherited from Pindo::Command

DEFAULT_OPTIONS, DEFAULT_ROOT_OPTIONS

Instance Attribute Summary

Attributes inherited from Pindo::Command

#args_help_flag

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Appselect

#all_deploy_bundle_name, #all_dev_bundle_name, #all_dev_bundleid, #all_itc_bundleid, #all_release_bundleid, #all_tool_bundleid, #deploy_build_setting_json, #dev_build_setting_json, #get_deploy_repo_with_modul_name, #get_deploy_setting_repo, #get_dev_setting_repo, #get_selected_deploy_bundle_name, #get_selected_deploy_bundleid, #get_selected_dev_bundle_name, #get_selected_dev_bundleid, #get_setting_bundleid_withdir, #load_setting, #select_main_app

Methods inherited from Pindo::Command

command_name, #initialize_options, run

Methods included from Funlog::Mixin

#pindo_log_instance

Methods included from Pindoconfig::Mixin

#pindo_single_config

Methods included from HelpValidator

#validate!

Constructor Details

#initialize(argv) ⇒ Autoresign

Returns a new instance of Autoresign.



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
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/pindo/command/ios/autoresign.rb', line 100

def initialize(argv)

      # 首先获取位置参数(向后兼容)
      positional_ipa = argv.shift_argument

      # 使用 Options 模块初始化参数
      @options = initialize_options(argv)

      # 优先使用选项参数,如果没有则使用位置参数
      @args_ipa_file = @options[:ipa] || positional_ipa

    @args_deploy_flag = @options[:deploy]

    # JPS 参数(从 options 中获取)
    @args_upload_flag = @options[:upload]
    @args_send_flag = @options[:send]
    @args_conf = @options[:conf]

    # 如果设置了 send,自动启用 upload
    if @args_send_flag
        @args_upload_flag = true
    end

    # 证书快捷参数
    @args_adhoc_flag = @options[:adhoc]
    @args_dev_flag = @options[:dev]
    @args_develop_id_flag = @options[:develop_id]
    @args_macos_flag = @options[:macos]
    @args_match_flag = @options[:match]

    # 证书参数(ios autoresign 默认: custom + https)
    @cert_mode = @options[:cert_mode] || 'custom'
    @storage = @options[:storage] || 'https'

    # 处理 --match 快捷方式
    if @args_match_flag
        @cert_mode = 'match'
        @storage = 'git'
    end

    # 构建类型优先级:--develop_id > --adhoc > --dev > --build_type > 默认 dev
    @build_type = @options[:build_type]
    if @args_develop_id_flag
        @build_type = 'developer_id'
    elsif @args_adhoc_flag
        @build_type = 'adhoc'
    elsif @args_dev_flag
        @build_type = 'dev'
    elsif @build_type.nil? || @build_type.to_s.empty?
        @build_type = 'dev'  # autoresign 默认使用 dev 证书
    end

    # 标准化构建类型
    @build_type = Pindo::Options::BuildOptions.normalize_build_type(@build_type)

    # 处理平台类型
    @platform_type = @options[:platform]
    if @args_macos_flag
        @platform_type = 'macos'
    end

    # macOS 平台特殊处理
    if @platform_type == 'macos' && @build_type == 'adhoc'
        @build_type = 'developer_id'
    end

    super
    @additional_args = argv.remainder!
end

Class Method Details

.option_itemsObject



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/pindo/command/ios/autoresign.rb', line 71

def self.option_items
    @option_items ||= begin
        items = []

        # 添加工具参数(ToolOptions)
        items.concat(Pindo::Options::ToolOptions.select(:ipa, :deploy))

        # 添加构建类型参数(BuildOptions)
        items.concat(Pindo::Options::BuildOptions.select(
            :dev, :adhoc, :develop_id, :build_type
        ))

        # 添加证书相关参数(CertOptions)
        items.concat(Pindo::Options::CertOptions.select(
            :platform, :macos, :cert_mode, :storage, :match
        ))

        # 合并 JPSOptions
        items.concat(Pindo::Options::JPSOptions.select(:conf, :upload, :send))

        items
    end
end

.optionsObject



95
96
97
# File 'lib/pindo/command/ios/autoresign.rb', line 95

def self.options
    option_items.map { |item| item.to_claide_option }.concat(super)
end

.use_cache?Boolean

启用缓存机制

Returns:

  • (Boolean)


23
24
25
# File 'lib/pindo/command/ios/autoresign.rb', line 23

def self.use_cache?
    true
end

Instance Method Details

#runObject



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
208
209
210
211
# File 'lib/pindo/command/ios/autoresign.rb', line 171

def run
    begin
        # 1. 查找 IPA 文件
        ipa_file_path = find_ipa_file()
        unless ipa_file_path && File.exist?(ipa_file_path)
            raise Informative, "未找到需要重签名的 IPA 文件"
        end

        # 2. 选择 Bundle ID
        bundle_id = select_bundle_id()
        puts "mainapp_bundleid: #{bundle_id}"

        # 3. 拉取应用配置
        pull_app_config(bundle_id)

        # 4. 准备 JPS 配置(如果需要上传)
        app_info_obj, workflow_info = prepare_jps_config()

        # 5. 计算重签名后的 IPA 文件名
        resigned_ipa_file = ipa_file_path.gsub(/\.ipa$/, '_resigned.ipa')

        # 6. 创建任务
        tasks = create_resign_tasks(
            ipa_file_path: ipa_file_path,
            resigned_ipa_file: resigned_ipa_file,
            bundle_id: bundle_id,
            app_info_obj: app_info_obj,
            workflow_info: workflow_info
        )

        # 7. 执行任务
        task_manager = Pindo::TaskSystem::TaskManager.instance
        task_manager.clear_all
        tasks.each { |task| task_manager.add_task(task) }
        task_manager.start

    ensure
        # 清除命令状态
        Pindo::Options::GlobalOptionsState.instance.clear
    end
end