Module: Belt::CLI
- Defined in:
- lib/belt/cli.rb,
lib/belt/cli/new_command.rb,
lib/belt/cli/env_resolver.rb,
lib/belt/cli/app_detection.rb,
lib/belt/cli/setup_command.rb,
lib/belt/cli/tasks_command.rb,
lib/belt/cli/views_command.rb,
lib/belt/cli/deploy_command.rb,
lib/belt/cli/routes_command.rb,
lib/belt/cli/server_command.rb,
lib/belt/cli/tables_command.rb,
lib/belt/cli/bucket_security.rb,
lib/belt/cli/console_command.rb,
lib/belt/cli/destroy_command.rb,
lib/belt/cli/frontend_command.rb,
lib/belt/cli/generate_command.rb,
lib/belt/cli/terraform_command.rb,
lib/belt/cli/environment_command.rb,
lib/belt/cli/frontend_setup_command.rb,
lib/belt/cli/frontend_deploy_command.rb,
lib/belt/cli/routes_command/schema_loader.rb,
lib/belt/cli/routes_command/route_inference.rb
Defined Under Namespace
Modules: AppDetection, BucketSecurity, EnvResolver
Classes: ConsoleCommand, DeployCommand, DestroyCommand, EnvironmentCommand, FrontendCommand, FrontendDeployCommand, FrontendSetupCommand, GenerateCommand, NewCommand, RoutesCommand, ServerCommand, SetupCommand, TablesCommand, TasksCommand, TerraformCommand, ViewsCommand
Constant Summary
collapse
- COMMANDS_DEFINITION =
{
'new' => Belt::CLI::NewCommand,
%w[generate g] => Belt::CLI::GenerateCommand,
%w[destroy d] => Belt::CLI::DestroyCommand,
'routes' => Belt::CLI::RoutesCommand,
%w[console c] => Belt::CLI::ConsoleCommand,
%w[tasks --tasks -T] => Belt::CLI::TasksCommand,
'setup' => Belt::CLI::SetupCommand,
'deploy' => Belt::CLI::DeployCommand,
%w[server s] => Belt::CLI::ServerCommand,
%w[version --version -v] => ->(_args) { puts "Belt #{Belt::VERSION}" }
}.freeze
- COMMANDS =
COMMANDS_DEFINITION.each_with_object({}) do |(keys, handler), hash|
Array(keys).each { |key| hash[key] = handler }
end.freeze
- TERRAFORM_ACTIONS =
Belt::CLI::TerraformCommand::ACTIONS
Class Method Summary
collapse
Class Method Details
.start(args) ⇒ Object
42
43
44
45
46
47
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
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/belt/cli.rb', line 42
def self.start(args)
command = args.shift
if command.nil?
puts usage
exit 1
end
if command == 'destroy'
if args.empty? || args.first =~ /\A-/
if args.include?('--help') || args.include?('-h')
return DestroyCommand.run(args)
end
elsif DestroyCommand::GENERATORS.include?(args.first)
return DestroyCommand.run(args)
end
end
return Belt::CLI::TerraformCommand.run(command, args) if TERRAFORM_ACTIONS.include?(command)
handler = COMMANDS[command]
if handler.nil?
return Belt::CLI::TasksCommand.invoke(command, args) if Belt::CLI::TasksCommand.rake_task?(command)
puts "Unknown command: #{command}\n\n#{usage}"
exit 1
end
if handler.is_a?(Proc)
handler.call(args)
else
handler.run(args)
end
end
|
.usage ⇒ Object
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
115
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
|
# File 'lib/belt/cli.rb', line 84
def self.usage
<<~USAGE
Usage: belt <command> [options]
Commands:
new <app_name> [--frontend react] Create a new Belt application
generate <scaffold|model|controller> <name> Generate components
generate frontend <react|vue|svelte> Scaffold a frontend app
generate views <resource> [fields...] Generate React pages for REST actions
generate environment <name> Create a new environment
destroy <scaffold|model|controller> <name> Remove generated components
destroy frontend Remove the frontend/ directory
destroy views <resource> Remove React pages for a resource
destroy environment <name> Remove an environment directory
server Start local dev server (frontend)
s Alias for server
deploy [environment] Deploy to AWS (init → plan → apply)
deploy frontend <env> Build and deploy frontend to AWS
routes [-g PATTERN] [-f json] Show route definitions
console Start an interactive console (IRB)
c Alias for console
tasks [-g PATTERN] [-a] List available rake tasks
-T [-g PATTERN] [-a] Alias for tasks
setup state Create/select S3 state bucket
setup tables <env> Generate DynamoDB tables from schema
setup frontend <env> Generate S3 + CloudFront infrastructure
init [environment] <env> terraform init for environment
plan [environment] <env> terraform plan for environment
apply [environment] <env> terraform apply for environment
destroy [environment] <env> terraform destroy for environment
output [environment] <env> terraform output for environment
--version Show Belt version
Rake Tasks:
Any rake task from your Gemfile dependencies can be run directly:
belt lambda:build_layer Run a rake task by name
Environment:
Set BELT_ENV to skip the <env> argument:
export BELT_ENV=wups
belt apply # uses BELT_ENV
belt apply dev01 # explicit arg wins
Examples:
belt new blog --frontend react
belt generate scaffold post title:string content:text status:string
belt destroy scaffold post
belt generate frontend react
belt server # Start local frontend server
belt deploy # Deploy dev to AWS
belt deploy prod --auto # Deploy prod without confirmation
belt deploy frontend wups
belt setup frontend wups
belt apply wups
belt tasks # list all rake tasks
belt lambda:build_layer # run a rake task directly
USAGE
end
|