From f48802845583036fd7773ff95d4889b50bf37a28 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 10 Jan 2024 17:04:53 -0300 Subject: [PATCH] BREAKING CHANGE: variables de entorno --- .env.example => .env | 0 .gitignore | 2 +- Gemfile | 3 +-- README.md | 11 +++++++++++ Taskfile.yaml | 17 +++-------------- config/application.rb | 11 +++++++++++ 6 files changed, 27 insertions(+), 17 deletions(-) rename .env.example => .env (100%) diff --git a/.env.example b/.env similarity index 100% rename from .env.example rename to .env diff --git a/.gitignore b/.gitignore index ec350559..2bdf8c49 100644 --- a/.gitignore +++ b/.gitignore @@ -28,7 +28,7 @@ /data/* /_storage/* -.env* +.env.* # Ignore master key for decrypting credentials and more. /config/master.key diff --git a/Gemfile b/Gemfile index 03da906d..f97c29ab 100644 --- a/Gemfile +++ b/Gemfile @@ -4,8 +4,6 @@ source ENV.fetch('GEMS_SOURCE', 'https://17.3.alpine.gems.sutty.nl') ruby "~> #{ENV.fetch('RUBY_VERSION', '3.1')}" -gem 'dotenv-rails', require: 'dotenv/rails-now' - # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 6.1.0' # Use Puma as the app server @@ -108,6 +106,7 @@ end group :development, :test do gem 'derailed_benchmarks' + gem 'dotenv-rails' gem 'pry' # Adds support for Capybara system testing and selenium driver gem 'capybara', '~> 2.13' diff --git a/README.md b/README.md index 6fefe82f..5139f6cd 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,12 @@ instalación (en inglés)](https://taskfile.dev/installation/) go-task ``` +### Variables de entorno + +Las variables de entorno por defecto se encuentran en el archivo `.env`. +Para modificar las opciones, crear o modificar el archivo `.env.local` +con valores distintos. + ### Documentación Para navegar la documentación del código usando YARD: @@ -62,6 +68,11 @@ instructions](https://taskfile.dev/installation/). go-task ``` +### Environment variables + +Default env vars are store on `.env`. For local options, copy them to +`.env.local`. + ### Documentation To browse documentation using YARD: diff --git a/Taskfile.yaml b/Taskfile.yaml index 71f582db..e98c2d0e 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -6,8 +6,10 @@ vars: shopt: - "globstar" dotenv: -- ".env" - ".env.development" +- ".env" +- ".env.local" +- ".env.development.local" tasks: credentials: desc: "Generate credentials file" @@ -17,20 +19,9 @@ tasks: - "config/credentials.yml.enc.ci" generates: - "config/credentials.yml.enc" - env: - desc: "Install the .env file" - cmds: - - "test -f .env || cp .env.example .env" - - ": == Environment vars have changed, please review and edit ==" - - "diff -auN --color .env.example .env" - sources: - - ".env.example" - generates: - - ".env" gems: desc: "Install gems" deps: - - "env" - "credentials" cmds: - "go-task bundle" @@ -79,8 +70,6 @@ tasks: - "grep -q \" panel.{{.SUTTY}} \" /etc/hosts" database-init: desc: "Database install" - deps: - - "env" cmds: - "{{.HAINISH}} /usr/bin/initdb --locale en_US.utf8 -E UTF8 -D /var/lib/postgresql/{{.PGVER}}/data" - "echo \"host all all samenet trust\" >> ../hain/var/lib/postgresql/{{.PGVER}}/data/pg_hba.conf" diff --git a/config/application.rb b/config/application.rb index 606ccaf4..529e341a 100644 --- a/config/application.rb +++ b/config/application.rb @@ -21,6 +21,17 @@ require 'rails/test_unit/railtie' # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) +if %w[development test].include? ENV['RAILS_ENV'] + # https://github.com/bkeepers/dotenv/pull/453 + Dotenv::Railtie.class_eval do + def overload + Dotenv.overload(*dotenv_files.reverse) + end + end + + Dotenv::Railtie.overload +end + module Sutty # Sutty! class Application < Rails::Application