match/lib/match/nuke.rb in fastlane-2.203.0 vs match/lib/match/nuke.rb in fastlane-2.204.0
- old
+ new
@@ -16,10 +16,11 @@
# rubocop:disable Metrics/ClassLength
class Nuke
attr_accessor :params
attr_accessor :type
+ attr_accessor :safe_remove_certs
attr_accessor :certs
attr_accessor :profiles
attr_accessor :files
attr_accessor :storage
@@ -68,10 +69,12 @@
self.params[:app_identifier] = '' # we don't really need a value here
FastlaneCore::PrintTable.print_values(config: params,
hide_keys: [:app_identifier],
title: "Summary for match nuke #{Fastlane::VERSION}")
+ self.safe_remove_certs = params[:safe_remove_certs] || false
+
prepare_list
filter_by_cert
print_tables
if params[:readonly]
@@ -79,15 +82,17 @@
end
if (self.certs + self.profiles + self.files).count > 0
unless params[:skip_confirmation]
UI.error("---")
- UI.error("Are you sure you want to completely delete and revoke all the")
- UI.error("certificates and provisioning profiles listed above? (y/n)")
+ remove_or_revoke_message = self.safe_remove_certs ? "remove" : "revoke"
+ UI.error("Are you sure you want to completely delete and #{remove_or_revoke_message} all the")
+ UI.error("certificates and delete provisioning profiles listed above? (y/n)")
UI.error("Warning: By nuking distribution, both App Store and Ad Hoc profiles will be deleted") if type == "distribution"
UI.error("Warning: The :app_identifier value will be ignored - this will delete all profiles for all your apps!") if had_app_identifier
UI.error("---")
+ print_safe_remove_certs_hint
end
if params[:skip_confirmation] || UI.confirm("Do you really want to nuke everything listed above?")
nuke_it_now!
UI.success("Successfully cleaned your account ♻️")
else
@@ -117,14 +122,16 @@
end
if Spaceship::ConnectAPI.client.in_house? && (type == "distribution" || type == "enterprise")
UI.error("---")
UI.error("⚠️ Warning: This seems to be an Enterprise account!")
- UI.error("By nuking your account's distribution, all your apps deployed via ad-hoc will stop working!") if type == "distribution"
- UI.error("By nuking your account's enterprise, all your in-house apps will stop working!") if type == "enterprise"
+ unless self.safe_remove_certs
+ UI.error("By nuking your account's distribution, all your apps deployed via ad-hoc will stop working!") if type == "distribution"
+ UI.error("By nuking your account's enterprise, all your in-house apps will stop working!") if type == "enterprise"
+ end
UI.error("---")
-
+ print_safe_remove_certs_hint
UI.user_error!("Enterprise account nuke cancelled") unless UI.confirm("Do you really want to nuke your Enterprise account?")
end
end
# Collect all the certs/profiles
@@ -166,11 +173,11 @@
cert_types.each do |ct|
certs += self.storage.list_files(file_name: ct.to_s, file_ext: "cer")
keys += self.storage.list_files(file_name: ct.to_s, file_ext: "p12")
end
- # Finds all the iOS and macOS profofiles in the file storage
+ # Finds all the iOS and macOS profiles in the file storage
profiles = []
prov_types.each do |prov_type|
profiles += self.storage.list_files(file_name: prov_type.to_s, file_ext: "mobileprovision")
profiles += self.storage.list_files(file_name: prov_type.to_s, file_ext: "provisionprofile")
end
@@ -188,11 +195,11 @@
rows = self.certs.each_with_index.collect do |cert, i|
cert_expiration = cert.expiration_date.nil? ? "Unknown" : Time.parse(cert.expiration_date).strftime("%Y-%m-%d")
[i + 1, cert.name, cert.id, cert.class.to_s.split("::").last, cert_expiration]
end
puts(Terminal::Table.new({
- title: "Certificates that can be revoked".green,
+ title: "Certificates that can be #{removed_or_revoked_message}".green,
headings: ["Option", "Name", "ID", "Type", "Expires"],
rows: FastlaneCore::PrintTable.transform_output(rows)
}))
puts("")
@@ -257,11 +264,11 @@
rows = self.certs.collect do |cert|
cert_expiration = cert.expiration_date.nil? ? "Unknown" : Time.parse(cert.expiration_date).strftime("%Y-%m-%d")
[cert.name, cert.id, cert.class.to_s.split("::").last, cert_expiration]
end
puts(Terminal::Table.new({
- title: "Certificates that are going to be revoked".green,
+ title: "Certificates that are going to be #{removed_or_revoked_message}".green,
headings: ["Name", "ID", "Type", "Expires"],
rows: FastlaneCore::PrintTable.transform_output(rows)
}))
puts("")
end
@@ -311,12 +318,18 @@
UI.message(ex.to_s)
end
UI.success("Successfully deleted profile")
end
- UI.header("Revoking #{self.certs.count} certificates...") unless self.certs.count == 0
+ removing_or_revoking_message = self.safe_remove_certs ? "Removing" : "Revoking"
+ UI.header("#{removing_or_revoking_message} #{self.certs.count} certificates...") unless self.certs.count == 0
self.certs.each do |cert|
+ if self.safe_remove_certs
+ UI.message("Certificate '#{cert.name}' (#{cert.id}) will be removed from repository without revoking it")
+ next
+ end
+
UI.message("Revoking certificate '#{cert.name}' (#{cert.id})...")
begin
cert.delete!
rescue => ex
UI.message(ex.to_s)
@@ -424,9 +437,20 @@
Spaceship::ConnectAPI::Profile::ProfileType::MAC_CATALYST_APP_DIRECT
]
else
raise "Unknown provisioning type '#{prov_type}'"
end
+ end
+
+ # Helpers for `safe_remove_certs`
+ def print_safe_remove_certs_hint
+ return if self.safe_remove_certs
+ UI.important("Hint: You can use --safe_remove_certs option to remove certificates")
+ UI.important("from repository without revoking them.")
+ end
+
+ def removed_or_revoked_message
+ self.safe_remove_certs ? "removed" : "revoked"
end
end
# rubocop:disable Metrics/ClassLength
end