Class: Belt::CLI::FrontendDeployCommand
- Inherits:
-
Object
- Object
- Belt::CLI::FrontendDeployCommand
show all
- Includes:
- AppDetection
- Defined in:
- lib/belt/cli/frontend_deploy_command.rb
Class Method Summary
collapse
Instance Method Summary
collapse
#detect_app_name, #detect_environments, #detect_namespace, #find_contracts_file_path, #find_routes_file_path, #find_schema_file_path, #s3_safe_name
Constructor Details
Returns a new instance of FrontendDeployCommand.
54
55
56
57
58
59
|
# File 'lib/belt/cli/frontend_deploy_command.rb', line 54
def initialize(env, frontend: nil)
@env = env
@app_name = detect_app_name
@env_dir = "infrastructure/#{@env}"
@frontend = frontend || FrontendRegistry.new.resolve!
end
|
Class Method Details
.deploy_all(env) ⇒ Object
44
45
46
47
48
49
50
51
52
|
# File 'lib/belt/cli/frontend_deploy_command.rb', line 44
def self.deploy_all(env)
frontends = FrontendRegistry.new.existing
abort FrontendRegistry.new.empty_message if frontends.empty?
frontends.each_with_index do |frontend, index|
puts if index.positive?
new(env, frontend: frontend).run
end
end
|
.run(args) ⇒ Object
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
|
# File 'lib/belt/cli/frontend_deploy_command.rb', line 15
def self.run(args)
frontend_name = FrontendRegistry.(args, '--frontend')
env = EnvResolver.resolve(args)
if env.nil?
puts 'Usage: belt deploy frontend <environment> [--frontend NAME]'
puts "\nBuilds frontend app(s) and deploys to S3 + invalidates CloudFront."
puts 'You can also set BELT_ENV to skip the environment argument.'
puts "\nWith multiple frontends (config/frontends.yml):"
puts ' belt deploy frontend wups # deploy all'
puts ' belt deploy frontend wups --frontend ops # deploy one'
puts "\nExamples:"
puts ' belt deploy frontend wups'
puts ' belt deploy frontend dev01'
puts ' BELT_ENV=wups belt deploy frontend'
exit 1
end
leftover = args.reject { |a| a.start_with?('-') }
frontend_name ||= leftover.shift
if frontend_name
frontend = FrontendRegistry.new.resolve!(frontend_name)
new(env, frontend: frontend).run
else
deploy_all(env)
end
end
|
Instance Method Details
#run ⇒ Object
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/belt/cli/frontend_deploy_command.rb', line 61
def run
validate!
puts "━━━ #{@frontend.label} (#{@frontend.path}/) ━━━"
build_frontend
sync_to_s3
invalidate_cloudfront
url = fetch_frontend_url
puts "\n✅ #{@frontend.label.capitalize} deployed to #{@env}!"
puts " #{url}" if url
end
|