Class: Match::Nuke
- Inherits:
-
Object
- Object
- Match::Nuke
- Defined in:
- lib/match/nuke.rb
Instance Attribute Summary collapse
-
#certs ⇒ Object
Returns the value of attribute certs.
-
#files ⇒ Object
Returns the value of attribute files.
-
#params ⇒ Object
Returns the value of attribute params.
-
#profiles ⇒ Object
Returns the value of attribute profiles.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #nuke_it_now! ⇒ Object
-
#prepare_list ⇒ Object
Collect all the certs/profiles.
-
#print_tables ⇒ Object
Print tables to ask the user.
- #run(params, type: nil) ⇒ Object
Instance Attribute Details
#certs ⇒ Object
Returns the value of attribute certs.
6 7 8 |
# File 'lib/match/nuke.rb', line 6 def certs @certs end |
#files ⇒ Object
Returns the value of attribute files.
8 9 10 |
# File 'lib/match/nuke.rb', line 8 def files @files end |
#params ⇒ Object
Returns the value of attribute params.
3 4 5 |
# File 'lib/match/nuke.rb', line 3 def params @params end |
#profiles ⇒ Object
Returns the value of attribute profiles.
7 8 9 |
# File 'lib/match/nuke.rb', line 7 def profiles @profiles end |
#type ⇒ Object
Returns the value of attribute type.
4 5 6 |
# File 'lib/match/nuke.rb', line 4 def type @type end |
Instance Method Details
#nuke_it_now! ⇒ Object
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 |
# File 'lib/match/nuke.rb', line 116 def nuke_it_now! UI.header "Deleting #{self.profiles.count} provisioning profiles..." unless self.profiles.count == 0 self.profiles.each do |profile| UI. "Deleting profile '#{profile.name}' (#{profile.id})..." begin profile.delete! rescue => ex UI.(ex.to_s) end UI.success "Successfully deleted profile" end UI.header "Revoking #{self.certs.count} certificates..." unless self.certs.count == 0 self.certs.each do |cert| UI. "Revoking certificate '#{cert.name}' (#{cert.id})..." begin cert.revoke! rescue => ex UI.(ex.to_s) end UI.success "Successfully deleted certificate" end if self.files.count > 0 delete_files! end # Now we need to commit and push all this too = ["[fastlane]", "Nuked", "files", "for", type.to_s].join(" ") GitHelper.commit_changes(params[:workspace], , self.params[:git_url], params[:git_branch]) end |
#prepare_list ⇒ Object
Collect all the certs/profiles
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 |
# File 'lib/match/nuke.rb', line 48 def prepare_list UI. "Fetching certificates and profiles..." cert_type = Match.cert_type_sym(type) prov_types = [:development] prov_types = [:appstore, :adhoc] if cert_type == :distribution Spaceship.login(params[:username]) Spaceship.select_team self.certs = certificate_type(cert_type).all self.profiles = [] prov_types.each do |prov_type| self.profiles += profile_type(prov_type).all end certs = Dir[File.join(params[:workspace], "**", cert_type.to_s, "*.cer")] keys = Dir[File.join(params[:workspace], "**", cert_type.to_s, "*.p12")] profiles = [] prov_types.each do |prov_type| profiles += Dir[File.join(params[:workspace], "**", prov_type.to_s, "*.mobileprovision")] end self.files = certs + keys + profiles end |
#print_tables ⇒ Object
Print tables to ask the user
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 |
# File 'lib/match/nuke.rb', line 75 def print_tables puts "" if self.certs.count > 0 puts Terminal::Table.new({ title: "Certificates that are going to be revoked".green, headings: ["Name", "ID", "Type", "Expires"], rows: self.certs.collect { |c| [c.name, c.id, c.class.to_s.split("::").last, c.expires.strftime("%Y-%m-%d")] } }) puts "" end if self.profiles.count > 0 puts Terminal::Table.new({ title: "Provisioning Profiles that are going to be revoked".green, headings: ["Name", "ID", "Status", "Type", "Expires"], rows: self.profiles.collect do |p| status = p.status == 'Active' ? p.status.green : p.status.red [p.name, p.id, status, p.type, p.expires.strftime("%Y-%m-%d")] end }) puts "" end if self.files.count > 0 puts Terminal::Table.new({ title: "Files that are going to be deleted".green, headings: ["Type", "File Name"], rows: self.files.collect do |f| components = f.split(File::SEPARATOR)[-3..-1] # from "...1o7xtmh/certs/distribution/8K38XUY3AY.cer" to "distribution cert" file_type = components[0..1].reverse.join(" ")[0..-2] [file_type, components[2]] end }) puts "" end end |
#run(params, type: nil) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/match/nuke.rb', line 10 def run(params, type: nil) self.params = params self.type = type params[:workspace] = GitHelper.clone(params[:git_url], params[:shallow_clone], skip_docs: params[:skip_docs], branch: params[:git_branch]) had_app_identifier = self.params[:app_identifier] self.params[:app_identifier] = '' # we don't really need a value here FastlaneCore::PrintTable.print_values(config: params, hide_keys: [:app_identifier, :workspace], title: "Summary for match nuke #{Match::VERSION}") prepare_list print_tables if params[:readonly] UI.user_error!("`match nuke` doesn't delete anything when running with --readonly enabled") end if (self.certs + self.profiles + self.files).count > 0 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)" 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 "---" if agree("(y/n)", true) nuke_it_now! UI.success "Successfully cleaned your account ♻️" else UI.success "Cancelled nuking #thanks 🏠 👨 👩 👧" end else UI.success "No relevant certificates or provisioning profiles found, nothing to nuke here :)" end end |