class Fastlane::Flint::Nuke

Attributes

files[RW]
params[RW]
type[RW]

Public Instance Methods

nuke_it_now!() click to toggle source
# File lib/fastlane/plugin/flint/helper/nuke.rb, line 95
def nuke_it_now!
  if self.files.count > 0
    delete_files!
  end

  # Now we need to commit and push all this too
  message = ["[fastlane]", "Nuked", "files", "for", type.to_s].join(" ")
  GitHelper.commit_changes(params[:workspace], message, self.params[:git_url], params[:git_branch], nil, Encrypt.new)
end
prepare_list() click to toggle source

Collect all the keystores

# File lib/fastlane/plugin/flint/helper/nuke.rb, line 67
def prepare_list
  UI.message("Fetching keystores...")
  cert_type = Flint.cert_type_sym(type)

  certs = Dir[File.join(params[:workspace], "**", "*-#{cert_type.to_s}.keystore")]

  self.files = certs
end
print_tables() click to toggle source

Print tables to ask the user

run(params, type: nil) click to toggle source
# File lib/fastlane/plugin/flint/helper/nuke.rb, line 16
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],
                                      git_full_name: params[:git_full_name],
                                      git_user_email: params[:git_user_email],
                                      clone_branch_directly: params[:clone_branch_directly],
                                      encrypt: Encrypt.new)

  had_app_identifier = self.params.fetch(:app_identifier, ask: false)
  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 flint nuke #{Fastlane::VERSION}")

  prepare_list
  print_tables

  if params[:readonly]
    UI.user_error!("`fastlane flint nuke` doesn't delete anything when running with --readonly enabled")
  end

  if (self.files).count > 0
    unless params[:skip_confirmation]
      if type == "release"
        UI.confirm(
          "DANGER: By nuking release keys you might not " + 
          "be able to update your app in the play store. Are you sure?"
        )
      end
      UI.error("---")
      UI.error("Are you sure you want to completely delete and revoke all the")
      UI.error("keystores listed above? (y/n)")
      UI.error("---")
    end
    if params[:skip_confirmation] || UI.confirm("Do you really want to nuke everything listed above?")
      nuke_it_now!
      UI.success("Successfully cleaned up ♻️")
    else
      UI.success("Cancelled nuking #thanks 🏠 👨 ‍👩 ‍👧")
    end
  else
    UI.success("No relevant keystores found, nothing to nuke here :)")
  end
end

Private Instance Methods

delete_files!() click to toggle source
# File lib/fastlane/plugin/flint/helper/nuke.rb, line 107
def delete_files!
  UI.header("Deleting #{self.files.count} files from the git repo...")

  self.files.each do |file|
    UI.message("Deleting file '#{File.basename(file)}'...")

    File.delete(file)
    UI.success("Successfully deleted file")
  end
end