Class: Jatai::Commands::Init
Constant Summary collapse
- PRESETS =
{ "micro" => "Micro — 256MB RAM, 1 réplica (Grátis)", "hobby" => "Hobby — 1GB RAM, réplicas ilimitadas (R$ 19/mês)", "pro" => "Pro — 2GB RAM, réplicas ilimitadas (R$ 69/mês)" }.freeze
- REGIONS =
{ "br-se1" => "São Paulo", "br-ne1" => "Nordeste" }.freeze
- STACKS =
{ "rails" => "Rails", "node" => "Node.js", "static" => "Estático (HTML/CSS/JS, sem build)", "docker" => "Docker (custom Dockerfile)" }.freeze
- DATABASE_TIERS =
{ "mini" => "Mini — 512MB, 20 conexões (Grátis)", "essencial" => "Essencial — 1GB, 50 conexões (R$ 19/mês)", "padrao" => "Padrão — 5GB, 100 conexões (R$ 49/mês)" }.freeze
Instance Method Summary collapse
Methods inherited from Base
#api, #app_slug, #error, #info, #pastel, #project_config, #require_auth!, #success
Instance Method Details
#execute(options = {}) ⇒ Object
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 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/jatai/commands/init.rb', line 27 def execute( = {}) prompt = TTY::Prompt.new config_path = File.join(Dir.pwd, Config::PROJECT_FILE) if File.exist?(config_path) return unless prompt.yes?("Arquivo .jatai.yml já existe. Sobrescrever?") end stack = detect_stack if stack info("Stack detectado: #{STACKS[stack]}") unless prompt.yes?("Confirmar stack #{STACKS[stack]}?") stack = prompt.select("Stack:", STACKS.map { |k, v| { name: v, value: k } }) end else info("Não foi possível detectar o stack automaticamente.") stack = prompt.select("Stack:", STACKS.map { |k, v| { name: v, value: k } }) end name = prompt.ask("Nome do app:") { |q| q.required true } preset = prompt.select("Preset:", PRESETS.map { |k, v| { name: v, value: k } }) region = prompt.select("Região:", REGIONS.map { |k, v| { name: "#{v} (#{k})", value: k } }) # Sites estáticos não têm banco — não pergunta o tier. db_tier = stack == "static" ? nil : prompt.select("Banco de dados:", DATABASE_TIERS.map { |k, v| { name: v, value: k } }) branch = detect_git_branch || "main" config = { "app" => name, "stack" => stack, "preset" => preset, "region" => region, "branch" => branch } config["database_tier"] = db_tier if db_tier File.write(config_path, YAML.dump(config)) success("Arquivo .jatai.yml criado com sucesso!") info("Branch: #{branch}") info("Execute `jatai up` para criar e fazer deploy do app.") end |