brasa 0.6.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/brasa/cli.rb +2 -2
- data/lib/brasa/commands/database.rb +1 -3
- data/lib/brasa/commands/init.rb +10 -8
- data/lib/brasa/commands/logs.rb +5 -5
- data/lib/brasa/commands/logs_export.rb +1 -1
- data/lib/brasa/commands/scale.rb +5 -2
- data/lib/brasa/commands/status.rb +5 -2
- data/lib/brasa/commands/up.rb +5 -4
- data/lib/brasa/source_packer.rb +1 -1
- data/lib/brasa/version.rb +1 -1
- data/lib/brasa/websocket/cable_client.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9ab80fa97972aec65ea87a625cb8d7aa01cb8c387baff5f29b8d0a8f0f73db66
|
|
4
|
+
data.tar.gz: f843c3492c549c7d1d26bfec393d4dad0f06757c47499217e69a9ff2c5630e33
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ac0a0ebb9aad612f996d1e2d5e3e6c1134dbc51ff9ea3f9989f42480a75c1c4a275826db9d0883d359ef19cc2c547b6236b0c509b5c81e5cffa368d5eb782cc7
|
|
7
|
+
data.tar.gz: a6497479a80671d0cac7ce5aba0504ca6b4fbcf435e9058c644db92a056d16fb654da57763cc28ba583d5e0eda04c3600f8264f021d46904f600e82807a7c914
|
data/lib/brasa/cli.rb
CHANGED
|
@@ -79,8 +79,8 @@ module Brasa
|
|
|
79
79
|
subcommand "redis", Commands::Redis
|
|
80
80
|
|
|
81
81
|
desc "scale", "Escalar a aplicação"
|
|
82
|
-
option :
|
|
83
|
-
option :preset, type: :string, desc: "Preset (
|
|
82
|
+
option :replicas, type: :numeric, desc: "Número de réplicas"
|
|
83
|
+
option :preset, type: :string, desc: "Preset (micro, hobby, pro)"
|
|
84
84
|
def scale
|
|
85
85
|
Commands::Scale.new.execute(options)
|
|
86
86
|
end
|
|
@@ -14,13 +14,11 @@ module Brasa
|
|
|
14
14
|
db = helper.api.get("/api/v1/apps/#{slug}/database")
|
|
15
15
|
|
|
16
16
|
puts helper.pastel.bold("Banco de dados de #{slug}")
|
|
17
|
-
puts "
|
|
18
|
-
puts " Modo: #{db["mode"]}"
|
|
17
|
+
puts " Tier: #{db["database_tier"] || db["mode"]}"
|
|
19
18
|
puts " Host: #{db["host"]}"
|
|
20
19
|
puts " Porta: #{db["port"]}"
|
|
21
20
|
puts " Nome: #{db["name"]}"
|
|
22
21
|
puts " Status: #{db["status"]}"
|
|
23
|
-
puts " Machine: #{db["machine_type"]}" if db["machine_type"] && db["machine_type"] != "embedded"
|
|
24
22
|
rescue Api::Client::ApiError => e
|
|
25
23
|
helper.error("Erro: #{e.message}")
|
|
26
24
|
end
|
data/lib/brasa/commands/init.rb
CHANGED
|
@@ -6,16 +6,18 @@ module Brasa
|
|
|
6
6
|
module Commands
|
|
7
7
|
class Init < Base
|
|
8
8
|
PRESETS = {
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"production" => "Production — 2 vCPU, 4GB RAM, 40GB disco, DB managed + storage (R$ 299/mês)",
|
|
13
|
-
"scale" => "Scale — 4 vCPU, 8GB RAM, 100GB disco, DB managed + storage (R$ 599/mês)"
|
|
9
|
+
"micro" => "Micro — 256MB RAM, 1 réplica (Grátis)",
|
|
10
|
+
"hobby" => "Hobby — 1GB RAM, réplicas ilimitadas (R$ 19/mês)",
|
|
11
|
+
"pro" => "Pro — 2GB RAM, réplicas ilimitadas (R$ 69/mês)"
|
|
14
12
|
}.freeze
|
|
15
13
|
|
|
16
14
|
REGIONS = { "br-se1" => "São Paulo", "br-ne1" => "Nordeste" }.freeze
|
|
17
15
|
STACKS = { "rails" => "Rails", "node" => "Node.js", "docker" => "Docker (custom Dockerfile)" }.freeze
|
|
18
|
-
|
|
16
|
+
DATABASE_TIERS = {
|
|
17
|
+
"mini" => "Mini — 512MB, 20 conexões (Grátis)",
|
|
18
|
+
"essencial" => "Essencial — 1GB, 50 conexões (R$ 19/mês)",
|
|
19
|
+
"padrao" => "Padrão — 5GB, 100 conexões (R$ 49/mês)"
|
|
20
|
+
}.freeze
|
|
19
21
|
|
|
20
22
|
def execute(options = {})
|
|
21
23
|
prompt = TTY::Prompt.new
|
|
@@ -39,7 +41,7 @@ module Brasa
|
|
|
39
41
|
name = prompt.ask("Nome do app:") { |q| q.required true }
|
|
40
42
|
preset = prompt.select("Preset:", PRESETS.map { |k, v| { name: v, value: k } })
|
|
41
43
|
region = prompt.select("Região:", REGIONS.map { |k, v| { name: "#{v} (#{k})", value: k } })
|
|
42
|
-
|
|
44
|
+
db_tier = prompt.select("Banco de dados:", DATABASE_TIERS.map { |k, v| { name: v, value: k } })
|
|
43
45
|
branch = detect_git_branch || "main"
|
|
44
46
|
|
|
45
47
|
config = {
|
|
@@ -48,7 +50,7 @@ module Brasa
|
|
|
48
50
|
"preset" => preset,
|
|
49
51
|
"region" => region,
|
|
50
52
|
"branch" => branch,
|
|
51
|
-
"
|
|
53
|
+
"database_tier" => db_tier
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
File.write(config_path, YAML.dump(config))
|
data/lib/brasa/commands/logs.rb
CHANGED
|
@@ -24,11 +24,11 @@ module Brasa
|
|
|
24
24
|
message = entry["message"]
|
|
25
25
|
|
|
26
26
|
level_str = case level
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
when "error" then pastel.red(level)
|
|
28
|
+
when "warn" then pastel.yellow(level)
|
|
29
|
+
when "info" then pastel.green(level)
|
|
30
|
+
else pastel.dim(level || "log")
|
|
31
|
+
end
|
|
32
32
|
|
|
33
33
|
puts "#{pastel.dim(timestamp)} #{pastel.cyan(source)} [#{level_str}] #{message}"
|
|
34
34
|
end
|
data/lib/brasa/commands/scale.rb
CHANGED
|
@@ -9,15 +9,18 @@ module Brasa
|
|
|
9
9
|
slug = app_slug
|
|
10
10
|
|
|
11
11
|
body = {}
|
|
12
|
-
body[:
|
|
12
|
+
body[:replicas] = options["replicas"].to_i if options["replicas"]
|
|
13
13
|
body[:preset] = options["preset"] if options["preset"]
|
|
14
14
|
|
|
15
15
|
if body.empty?
|
|
16
|
-
error("Informe ao menos --
|
|
16
|
+
error("Informe ao menos --replicas ou --preset. Ex: brasa scale --replicas 3")
|
|
17
17
|
return
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
estimate = api.post("/api/v1/apps/#{slug}/scale/estimate", body: body)
|
|
21
|
+
info("Preset: #{estimate["preset"]}")
|
|
22
|
+
info("Réplicas: #{estimate["replicas"]}") if estimate["replicas"]
|
|
23
|
+
info("CPU: #{estimate["cpu_limit"]} | RAM: #{estimate["memory_limit"]}") if estimate["cpu_limit"]
|
|
21
24
|
info("Custo estimado: R$ #{estimate["monthly_cost"]}/mês")
|
|
22
25
|
|
|
23
26
|
prompt = TTY::Prompt.new
|
|
@@ -15,8 +15,9 @@ module Brasa
|
|
|
15
15
|
puts " Status: #{colorize_status(app["status"])}"
|
|
16
16
|
puts " Região: #{app["region"]}"
|
|
17
17
|
puts " Preset: #{app["preset"]}"
|
|
18
|
-
puts " DB: #{app["
|
|
19
|
-
|
|
18
|
+
puts " DB: #{app["database_tier"]}"
|
|
19
|
+
subdomain = app["subdomain"] || app["slug"]
|
|
20
|
+
puts " URL: https://#{subdomain}.usebrasa.com.br"
|
|
20
21
|
|
|
21
22
|
if app["last_deploy"]
|
|
22
23
|
deploy = app["last_deploy"]
|
|
@@ -37,6 +38,8 @@ module Brasa
|
|
|
37
38
|
case status
|
|
38
39
|
when "active", "live"
|
|
39
40
|
pastel.green(status)
|
|
41
|
+
when "sleeping"
|
|
42
|
+
pastel.blue(status)
|
|
40
43
|
when "failed", "error"
|
|
41
44
|
pastel.red(status)
|
|
42
45
|
when "building", "deploying", "provisioning"
|
data/lib/brasa/commands/up.rb
CHANGED
|
@@ -18,7 +18,7 @@ module Brasa
|
|
|
18
18
|
@app = find_or_create_app(config)
|
|
19
19
|
slug = @app["slug"]
|
|
20
20
|
|
|
21
|
-
if @app["status"]
|
|
21
|
+
if %w[active sleeping].include?(@app["status"])
|
|
22
22
|
info("Iniciando deploy...")
|
|
23
23
|
else
|
|
24
24
|
info("Provisionando infraestrutura...")
|
|
@@ -72,7 +72,8 @@ module Brasa
|
|
|
72
72
|
name: config[:app], stack: config[:stack], preset: config[:preset],
|
|
73
73
|
region: config[:region], repo_url: detect_git_remote, repo_branch: config[:branch]
|
|
74
74
|
}
|
|
75
|
-
app_params[:
|
|
75
|
+
app_params[:database_tier] = config[:database_tier] if config[:database_tier]
|
|
76
|
+
app_params[:release_command] = config.dig(:release, :command) if config.dig(:release, :command)
|
|
76
77
|
api.post("/api/v1/apps", body: { app: app_params })
|
|
77
78
|
end
|
|
78
79
|
|
|
@@ -205,9 +206,9 @@ module Brasa
|
|
|
205
206
|
end
|
|
206
207
|
|
|
207
208
|
def status_label(status)
|
|
208
|
-
{ "pending" => "Aguardando...", "provisioning" => "Provisionando
|
|
209
|
+
{ "pending" => "Aguardando...", "provisioning" => "Provisionando...",
|
|
209
210
|
"queued" => "Na fila...", "building" => "Construindo imagem...",
|
|
210
|
-
"deploying" => "
|
|
211
|
+
"deploying" => "Implantando..." }[status] || status
|
|
211
212
|
end
|
|
212
213
|
|
|
213
214
|
def show_elapsed(started)
|
data/lib/brasa/source_packer.rb
CHANGED
|
@@ -6,7 +6,7 @@ module Brasa
|
|
|
6
6
|
class SourcePacker
|
|
7
7
|
IGNORE_PATTERNS = %w[
|
|
8
8
|
.git node_modules tmp log .bundle vendor/bundle
|
|
9
|
-
.
|
|
9
|
+
.env .env.* *.log coverage
|
|
10
10
|
config/master.key config/credentials.yml.enc
|
|
11
11
|
config/credentials config/credentials/*.yml.enc
|
|
12
12
|
*.pem *.key storage/*.key
|
data/lib/brasa/version.rb
CHANGED