brasa 0.6.0 → 0.7.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a728c8d3747051635cf62354d9e1be55a04e3d677a5f5df9f6c3b7bc45578a02
4
- data.tar.gz: 79cbc855852b1dfcd5bb9d08aa2be22a8de867e5ef687b232abc741e719194b8
3
+ metadata.gz: c43a2e611cb76f921a9c2066be2fe84a4da611eb81aff758d47bb481a09f3710
4
+ data.tar.gz: 78108a8be50018a5ff96ad2c4026e20b2942d74234d335e0aad065360976ef00
5
5
  SHA512:
6
- metadata.gz: 8288ced4e3c745f096703aa9bf7184c0508a7131e259615e8ad0393b5c8ad3ffe6f95a872e9fba14c377afa6fdde950293dafa8c167245e03cefd38441eec259
7
- data.tar.gz: 65c522b9ab984069496ead760d8f8a476c07c82304972a03afca86beee84fe2aed0ce994b455e2dca82c986532327fb6b5a257cb375ba8ace19fdef1a082d5cf
6
+ metadata.gz: 7cf9cf1b338037c816efadd34cc79a395b0d24a6edb045d9d3cce197a678274b8ddafcc7a925c35480fd2b37ed579fba5014c8da5525bad67bfadc0ddeeda4d3
7
+ data.tar.gz: 8766f38b9203e02dd9f92f8fa0c21fd4c94c4ace3362c1b9c28925cfcd36833873665ffb4d80e0621f42b1f24cf546eef787e12b2b24be2b9aa402c3b6cad78e
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 :web, type: :numeric, desc: "Número de instâncias web"
83
- option :preset, type: :string, desc: "Preset (hobby, production, scale)"
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 " Engine: #{db["engine"]} #{db["engine_version"]}"
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
@@ -6,16 +6,18 @@ module Brasa
6
6
  module Commands
7
7
  class Init < Base
8
8
  PRESETS = {
9
- "nano" => "Nano1 vCPU, 1GB RAM, 10GB disco, DB embedded (R$ 19/mês) [Node.js/Docker]",
10
- "micro" => "Micro1 vCPU, 2GB RAM, 20GB disco, DB embedded (R$ 29/mês)",
11
- "hobby" => "Hobby1 vCPU, 2GB RAM, 40GB disco, DB managed (R$ 99/mês)",
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" => "Micro256MB RAM, 1 réplica (Grátis)",
10
+ "hobby" => "Hobby1GB 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
- DATABASE_ENGINES = { "postgresql" => "PostgreSQL", "mysql" => "MySQL" }.freeze
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
- engine = prompt.select("Banco de dados:", DATABASE_ENGINES.map { |k, v| { name: v, value: k } })
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
- "database_engine" => engine
53
+ "database_tier" => db_tier
52
54
  }
53
55
 
54
56
  File.write(config_path, YAML.dump(config))
@@ -24,11 +24,11 @@ module Brasa
24
24
  message = entry["message"]
25
25
 
26
26
  level_str = case level
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
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
@@ -23,7 +23,7 @@ module Brasa
23
23
  when String
24
24
  puts result
25
25
  else
26
- puts result.to_s
26
+ puts result
27
27
  end
28
28
  rescue Api::Client::ApiError => e
29
29
  error("Erro: #{e.message}")
@@ -9,15 +9,18 @@ module Brasa
9
9
  slug = app_slug
10
10
 
11
11
  body = {}
12
- body[:web] = options["web"].to_i if options["web"]
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 --web ou --preset. Ex: brasa scale --web 3")
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["database_engine"]}"
19
- puts " URL: https://#{app["subdomain"]}.usebrasa.com.br"
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"
@@ -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"] == "active"
21
+ if %w[active sleeping].include?(@app["status"])
22
22
  info("Iniciando deploy...")
23
23
  else
24
24
  info("Provisionando infraestrutura...")
@@ -72,7 +72,7 @@ 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[:database_engine] = config[:database_engine] if config[:database_engine]
75
+ app_params[:database_tier] = config[:database_tier] if config[:database_tier]
76
76
  api.post("/api/v1/apps", body: { app: app_params })
77
77
  end
78
78
 
@@ -205,9 +205,9 @@ module Brasa
205
205
  end
206
206
 
207
207
  def status_label(status)
208
- { "pending" => "Aguardando...", "provisioning" => "Provisionando VM...",
208
+ { "pending" => "Aguardando...", "provisioning" => "Provisionando...",
209
209
  "queued" => "Na fila...", "building" => "Construindo imagem...",
210
- "deploying" => "Deployando..." }[status] || status
210
+ "deploying" => "Implantando..." }[status] || status
211
211
  end
212
212
 
213
213
  def show_elapsed(started)
data/lib/brasa/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Brasa
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
@@ -6,7 +6,7 @@ module Brasa
6
6
  class CableClient
7
7
  class ConnectionError < StandardError; end
8
8
 
9
- RECONNECT_DELAYS = [1, 3, 10].freeze
9
+ RECONNECT_DELAYS = [ 1, 3, 10 ].freeze
10
10
 
11
11
  def initialize(api_url: nil, token: nil)
12
12
  @api_url = api_url || Brasa::Config.api_url
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brasa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brasa