Class: Pindo::Command::Utils::Allcopyconfig
- Inherits:
-
Utils
- Object
- Utils
- Pindo::Command::Utils::Allcopyconfig
show all
- Includes:
- Appselect
- Defined in:
- lib/pindo/command/utils/allcopyconfig.rb
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
Constructor Details
Returns a new instance of Allcopyconfig.
47
48
49
50
51
|
# File 'lib/pindo/command/utils/allcopyconfig.rb', line 47
def initialize(argv)
@to_prefix = argv.option('to-prefix')
@new_apple_id = argv.option('apple-id')
super
end
|
Class Method Details
.options ⇒ Object
40
41
42
43
44
45
|
# File 'lib/pindo/command/utils/allcopyconfig.rb', line 40
def self.options
[
['--to-prefix', '目标组织前缀 (如 com.eyesofstorms)'],
['--apple-id', '新的Apple开发者账号邮箱']
].concat(super)
end
|
Instance Method Details
#run ⇒ Object
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
|
# File 'lib/pindo/command/utils/allcopyconfig.rb', line 59
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 "目标前缀: #{@to_prefix}"
puts "目标 Apple ID: #{@new_apple_id}"
puts "共 #{all_bundle_ids.length} 个 Bundle ID 需要复制"
puts
success_count = 0
skip_count = 0
failed_ids = []
all_bundle_ids.each_with_index do |from_bundle_id, index|
if from_bundle_id.include?("*")
clean_from = from_bundle_id.gsub(".*", "")
new_bundle_id = @to_prefix
puts "=" * 60
puts "[#{index + 1}/#{all_bundle_ids.length}] #{clean_from} -> #{new_bundle_id}"
puts "=" * 60
begin
args_temp = []
args_temp << new_bundle_id
args_temp << "--from=#{clean_from}"
args_temp << "--apple-id=#{@new_apple_id}"
Pindo::Command::Utils::Copyconfig.run(args_temp)
success_count += 1
rescue => err
puts " 失败: #{err.message}"
failed_ids << clean_from
end
puts
next
end
from_parts = from_bundle_id.split('.')
if from_parts.length < 3
puts "[#{index + 1}/#{all_bundle_ids.length}] #{from_bundle_id} — 格式不合法,跳过"
skip_count += 1
next
end
app_name_parts = from_parts[2..]
new_bundle_id = "#{@to_prefix}.#{app_name_parts.join('.')}"
puts "=" * 60
puts "[#{index + 1}/#{all_bundle_ids.length}] #{from_bundle_id} -> #{new_bundle_id}"
puts "=" * 60
begin
args_temp = []
args_temp << new_bundle_id
args_temp << "--from=#{from_bundle_id}"
args_temp << "--apple-id=#{@new_apple_id}"
Pindo::Command::Utils::Copyconfig.run(args_temp)
success_count += 1
rescue => err
puts " 失败: #{err.message}"
failed_ids << from_bundle_id
end
puts
end
puts "=" * 60
puts "完成: #{success_count} 成功, #{failed_ids.length} 失败, #{skip_count} 跳过"
if !failed_ids.empty?
puts
puts "失败的 Bundle ID:"
failed_ids.each { |bid| puts " #{bid}" }
end
end
|
#validate! ⇒ Object
53
54
55
56
57
|
# File 'lib/pindo/command/utils/allcopyconfig.rb', line 53
def validate!
super
help! "请通过 --to-prefix 指定目标组织前缀 (如 com.eyesofstorms)" if @to_prefix.nil? || @to_prefix.empty?
help! "请通过 --apple-id 指定新的Apple开发者账号" if @new_apple_id.nil? || @new_apple_id.empty?
end
|