class Rockette::Deployer
Push APEX application to target instance
Public Class Methods
new()
click to toggle source
# File lib/rockette/controller/deployer.rb, line 11 def initialize @pastel = Pastel.new @prompt = TTY::Prompt.new @spinner = TTY::Spinner.new end
Public Instance Methods
launch!()
click to toggle source
# File lib/rockette/controller/deployer.rb, line 17 def launch! @conf = Psych.load(File.read(CONF)) intro_text # input/action loop loop do actions = { "🛸 Add" => 1, "📝 Update" => 2, "⬅️ Go Back" => 3 } response = @prompt.select("Add application or update an existing application?", actions) break if response == 3 add_app if response == 1 updater if response == 2 end puts end
Protected Instance Methods
add_app()
click to toggle source
# File lib/rockette/controller/deployer.rb, line 45 def add_app puts padder("Let's choose an export to add") file = choose_file url = choose_env puts padder("You chose to add #{file} to the environment at #{url}") puts return unless @prompt.yes?("Proceed with the deployment?") options = Thor::CoreExt::HashWithIndifferentAccess.new "app_id" => "0", "url" => url, "file" => file, "force" => true Rockette::Commands::Deploy.new(options).execute puts end
choose_app(apps_url)
click to toggle source
# File lib/rockette/controller/deployer.rb, line 59 def choose_app(apps_url) apps = Rockette::Viewer.new.applications(apps_url) list = list_builder(apps) action = @prompt.slider("Application to update => ", list, default: 1) apps[action - 1] end
choose_env()
click to toggle source
# File lib/rockette/controller/deployer.rb, line 67 def choose_env enviros = Rockette::Viewer.new.environments list = list_builder(enviros) action = @prompt.select("Which environment?", list) enviros[action - 1]["deployment_api"] end
choose_file()
click to toggle source
# File lib/rockette/controller/deployer.rb, line 74 def choose_file list = Dir.children(EXPORT_DIR) @prompt.select("Which export from #{EXPORT_DIR}?", list) end
intro_text()
click to toggle source
# File lib/rockette/controller/deployer.rb, line 35 def intro_text puts puts @pastel.yellow("These are the two available options:") print "1. Add application to an APEX instance. " print "It's #{@pastel.green.bold("generally safe and creates a new application")} from the export\n" print "2. Update an existing application with your chosen export. " print "#{@pastel.red.bold("Tread carefully")} with this option!\n" puts end
list_builder(array)
click to toggle source
# File lib/rockette/controller/deployer.rb, line 79 def list_builder(array) names = [] # Start building selection list if array[0].key?("name") array.each { |n| names << n["name"] } else array.each { |n| names << "#{n["application_name"]} App ID: #{n["application_id"]}" } end names << "Go Back" names.map.with_index { |n, x| [n, x + 1] }.to_h end
updater()
click to toggle source
# File lib/rockette/controller/deployer.rb, line 90 def updater puts padder("Please choose the export with your updated application code") file = choose_file url = choose_env app = choose_app(url) puts "Application: #{app["application_name"]} | App ID: #{app["application_id"]} | Env URI: #{url}" puts "will be updated with the code from export: #{file}" puts return unless @prompt.yes?("Proceed with the deployment?") options = Thor::CoreExt::HashWithIndifferentAccess.new "app_id" => app["application_id"], "url" => url, "file" => file, "force" => true Rockette::Commands::Deploy.new(options).execute puts end