class Fanforce::AppFactory::CLI::Scripts include Fanforce::AppFactory::CLI::Utils require_relative '../lib/bitbucket' require_relative '../lib/uranium' require_relative '../lib/pow' ###################################################################################################################### def destroy(app_id) app_id || error('You must supply a valid APP_ID', :delete) app_dir = "#{Fanforce::CLI::DIR}/#{app_id}" error "Directory was not found for app: #{app_dir}" if !File.directory?("#{app_dir}") error 'Bitbucket credentials were not found in config file' if !config[:bitbucket] app = Fanforce::CLI::App.new(app_dir) log divider '+-----' confirm("You are about to delete both local and remote files for #{app_id}.\nARE YOU SURE?", true) # puts "\n---------------------------------------------------------------------------------------------------------------" # puts 'DELETING HEROKU APPS...' # [:staging,:production].each do |environment| # next if $Config[:heroku].blank? or $Config[:heroku][environment].blank? # heroku = auth_heroku(environment) # heroku_app_name = get_heroku_app_name(app, environment) # begin # heroku.delete_app(heroku_app_name) # puts "#{'Removed '.format(:green,:bold)}" + " #{heroku_app_name}" # rescue Exception => e # puts "#{'Already Removed'.format(:green,:bold)}" + " #{heroku_app_name}" # end # end log divider '+-----------------------------------------------------------------------------------------------------' log 'REMOVING BITBUCKET REPOSITORY...' Fanforce::AppFactory::CLI::Bitbucket.new(app).destroy log divider '+-----------------------------------------------------------------------------------------------------' log 'REMOVING URANIUM RECORD...' Fanforce::AppFactory::CLI::Uranium.new(app).destroy log divider '+-----------------------------------------------------------------------------------------------------' log 'REMOVING POW DOMAINS...' Fanforce::AppFactory::CLI::Pow.new(app).destroy log divider '+-----------------------------------------------------------------------------------------------------' log 'REMOVING FILES...' if File.directory?(app_dir) FileUtils.rm_rf(app_dir) log "#{'Removed'.format(:bold, :green)} #{app_dir}/" else log "#{'Already Removed'.format(:bold, :green)} #{app_dir}/" end log divider '+-----------------------------------------------------------------------------------------------------' log 'DONE! (note: iron workers were not deleted)' log divider '+-----------------------------------------------------------------------------------------------------' end end