Class: Belt::CLI::DeployCommand
- Inherits:
-
Object
- Object
- Belt::CLI::DeployCommand
- Defined in:
- lib/belt/cli/deploy_command.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(env, auto_approve: false, extra_args: []) ⇒ DeployCommand
constructor
A new instance of DeployCommand.
- #run ⇒ Object
Constructor Details
#initialize(env, auto_approve: false, extra_args: []) ⇒ DeployCommand
Returns a new instance of DeployCommand.
86 87 88 89 90 91 |
# File 'lib/belt/cli/deploy_command.rb', line 86 def initialize(env, auto_approve: false, extra_args: []) @env = env @auto_approve = auto_approve @extra_args = extra_args @infra_dir = TerraformCommand.find_infrastructure_dir end |
Class Method Details
.help_text ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/belt/cli/deploy_command.rb', line 58 def self.help_text <<~HELP Deploy your Belt application to AWS. Usage: belt deploy [environment] [options] belt deploy frontend <environment> This runs the full deployment lifecycle: 1. terraform init (initialize providers/modules) 2. terraform plan (preview changes) 3. Prompt for confirmation (unless --auto) 4. terraform apply (deploy changes) Options: --auto, --yes, -y Skip confirmation prompt (auto-approve) -h, --help Show this help Environment: Defaults to BELT_ENV if set, otherwise requires an argument. Examples: belt deploy # Deploy dev (or BELT_ENV) belt deploy prod # Deploy to prod belt deploy dev --auto # Deploy without confirmation (CI mode) belt deploy frontend dev # Deploy frontend assets only HELP end |
.run(args) ⇒ Object
9 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 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/belt/cli/deploy_command.rb', line 9 def self.run(args) # Handle `belt deploy frontend <env>` as before if args.first == 'frontend' args.shift Belt::CLI::FrontendDeployCommand.run(args) return end auto_approve = false filtered_args = [] args.each do |arg| case arg when '--auto', '--yes', '-y' auto_approve = true when '-h', '--help' puts help_text exit 0 else filtered_args << arg end end env = EnvResolver.resolve(filtered_args) # Default to the first available environment when none specified if env.nil? available = TerraformCommand.list_environments if available.any? env = available.first else puts 'Usage: belt deploy [environment] [options]' puts "\nDefaults to BELT_ENV or the first available environment." puts "\nOptions:" puts ' --auto, --yes, -y Skip confirmation prompt (auto-approve)' puts ' -h, --help Show this help' puts "\nExamples:" puts ' belt deploy # Deploy dev (or BELT_ENV)' puts ' belt deploy prod # Deploy to prod' puts ' belt deploy dev --auto # Deploy without confirmation' puts ' belt deploy frontend dev # Deploy frontend only' puts "\nNo environments found. Run `belt generate environment dev` first." exit 1 end end new(env, auto_approve: auto_approve, extra_args: filtered_args).run end |
Instance Method Details
#run ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/belt/cli/deploy_command.rb', line 93 def run validate! env_dir = File.join(@infra_dir, @env) puts "belt ā deploying #{@env} (in #{env_dir}/)\n\n" Dir.chdir(env_dir) do run_init run_plan return unless confirm_apply run_apply end puts "\nā Deployed #{@env} successfully!" print_outputs(env_dir) puts "\n Run `belt server` to view your app locally (auto-connects to the deployed API)." end |