<% if rubocop? -%>
# rubocop:disable Style/FormatStringToken
<% end -%>
plugin "git"
plugin "env"
plugin "bundler"
plugin "rails"
plugin "nodenv"
plugin "puma"
plugin "rbenv"
plugin "./plugins/<%= app %>.rb"

host "user@hostname.or.ip.address"

set application: <%= app.inspect %>
set deploy_to: "/var/www/%{application}"
<% unless using_ruby_version_file? -%>
set rbenv_ruby_version: <%= RUBY_VERSION.inspect %>
<% end -%>
<% unless using_node_version_file? -%>
set nodenv_node_version: <%= node_version&.inspect || "nil # FIXME" %>
<% end -%>
set nodenv_install_yarn: <%= yarn_version ? "true" : "false" %>
set git_url: <%= git_origin_url&.inspect || "nil # FIXME" %>
set git_branch: <%= git_main_branch&.inspect || "nil # FIXME" %>
set git_exclusions: %w[
  .tomo/
  spec/
  test/
]
set env_vars: {
  RAILS_ENV: "production",
  RUBY_YJIT_ENABLE: "1",
  BOOTSNAP_CACHE_DIR: "tmp/bootsnap-cache",
  DATABASE_URL: :prompt,
  SECRET_KEY_BASE: :generate_secret
}
set linked_dirs: %w[
  .yarn/cache
  log
  node_modules
  public/assets
  public/packs
  public/vite
  tmp/cache
  tmp/pids
  tmp/sockets
]

setup do
  run "env:setup"
  run "core:setup_directories"
  run "git:config"
  run "git:clone"
  run "git:create_release"
  run "core:symlink_shared"
  run "nodenv:install"
  run "rbenv:install"
  run "bundler:upgrade_bundler"
  run "bundler:config"
  run "bundler:install"
  run "rails:db_create"
  run "rails:db_schema_load"
  run "rails:db_seed"
  run "puma:setup_systemd"
end

deploy do
  run "env:update"
  run "git:create_release"
  run "core:symlink_shared"
  run "core:write_release_json"
  run "bundler:install"
  run "rails:db_migrate"
  run "rails:db_seed"
  run "rails:assets_precompile"
  run "core:symlink_current"
  run "puma:restart"
  run "puma:check_active"
  run "core:clean_releases"
  run "bundler:clean"
  run "core:log_revision"
end
<% if rubocop? -%>
# rubocop:enable Style/FormatStringToken
<% end -%>
