Class: Pindo::Command::Utils::Renewbundleid

Inherits:
Pindo::Command::Utils show all
Includes:
Appselect
Defined in:
lib/pindo/command/utils/renewbundleid.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, use_cache?

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) ⇒ Renewbundleid

Returns a new instance of Renewbundleid.



52
53
54
55
# File 'lib/pindo/command/utils/renewbundleid.rb', line 52

def initialize(argv)
  @dry_run = argv.flag?('dry-run', false)
  super
end

Class Method Details

.optionsObject



46
47
48
49
50
# File 'lib/pindo/command/utils/renewbundleid.rb', line 46

def self.options
  [
    ['--dry-run', '预览模式,只显示差异不修改文件']
  ].concat(super)
end

Instance Method Details

#runObject



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
# File 'lib/pindo/command/utils/renewbundleid.rb', line 57

def run
    @dev_bundle_id_array = all_dev_bundleid()
    @tool_bundle_id_array = all_tool_bundleid()
    @deploy_bundle_id_array = all_release_bundleid()
    all_bundle_ids = @dev_bundle_id_array + @deploy_bundle_id_array + @tool_bundle_id_array

    puts "#{all_bundle_ids.length} 个 Bundle ID 需要处理"
    puts

    # 只登录一次
    first_config = load_first_config(all_bundle_ids)
    if first_config.nil?
        puts "无法加载任何 config.json,退出"
        return
    end

    apple_id = first_config.dig('account_info', 'apple_acount_id')
    if apple_id.nil? || apple_id.empty? || apple_id.include?("__________")
        puts "config.json 中缺少有效的 Apple ID"
        return
    end

    puts "Login #{apple_id}..."
    Spaceship.(apple_id.to_s)
    Spaceship.select_team
    puts

    success_count = 0
    fail_count = 0
    skip_count = 0

    all_bundle_ids.each do |bundle_id|
        if bundle_id.include?("*")
            bundle_id = bundle_id.gsub(".*", "")
        end

        begin
            result = update_bundleid_capabilities(bundle_id: bundle_id)
            case result
            when :success then success_count += 1
            when :skip then skip_count += 1
            end
        rescue => err
            puts "  #{bundle_id} — 失败: #{err.message}"
            fail_count += 1
        end
    end

    puts
    puts "完成: #{success_count} 成功, #{fail_count} 失败, #{skip_count} 跳过"
end