From a567209f837744ad6f1c220277380560faca494c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Mar 2022 16:06:46 +0000 Subject: [PATCH 1/7] Bump actions/checkout from 2 to 3 Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 67855ed..b38910d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: ruby: ['2.5', '2.6', '2.7', '3.0'] steps: - name: Check out repository code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Do some action caching uses: actions/cache@v2.1.6 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b557937..d8b2ec0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,7 +4,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v3 - name: Release dotenv uses: cadwallion/publish-rubygems-action@master env: From df238424b4ecd42a8a25d5ac79affe42a2656e3f Mon Sep 17 00:00:00 2001 From: Ahmed Kamal Date: Wed, 16 Mar 2022 14:13:25 +0200 Subject: [PATCH 2/7] Add overload option for the CLI --- lib/dotenv/cli.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/dotenv/cli.rb b/lib/dotenv/cli.rb index da5c964..a13b2df 100644 --- a/lib/dotenv/cli.rb +++ b/lib/dotenv/cli.rb @@ -7,18 +7,23 @@ module Dotenv # The CLI is a class responsible of handling all the command line interface # logic. class CLI - attr_reader :argv, :filenames + attr_reader :argv, :filenames, :overload def initialize(argv = []) @argv = argv.dup @filenames = [] + @overload = false end def run parse_argv!(@argv) begin - Dotenv.load!(*@filenames) + if @overload + Dotenv.overload!(*@filenames) + else + Dotenv.load!(*@filenames) + end rescue Errno::ENOENT => e abort e.message else @@ -38,6 +43,7 @@ def parse_argv!(argv) def add_options(parser) add_files_option(parser) + add_overload_option(parser) add_help_option(parser) add_version_option(parser) add_template_option(parser) @@ -49,6 +55,12 @@ def add_files_option(parser) end end + def add_overload_option(parser) + parser.on("-o", "--overload", "Use Dotenv.overload To overwrite existing environment variables") do + @overload = true + end + end + def add_help_option(parser) parser.on("-h", "--help", "Display help") do puts parser From 0bbba288634f02ea06242b0859cff7a18df05de5 Mon Sep 17 00:00:00 2001 From: Ahmed Kamal Date: Wed, 13 Apr 2022 21:47:08 +0200 Subject: [PATCH 3/7] Fix lint failures --- lib/dotenv/cli.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/dotenv/cli.rb b/lib/dotenv/cli.rb index a13b2df..368bf2a 100644 --- a/lib/dotenv/cli.rb +++ b/lib/dotenv/cli.rb @@ -19,11 +19,7 @@ def run parse_argv!(@argv) begin - if @overload - Dotenv.overload!(*@filenames) - else - Dotenv.load!(*@filenames) - end + load_dotenv(@overload, @filenames) rescue Errno::ENOENT => e abort e.message else @@ -41,6 +37,14 @@ def parse_argv!(argv) @filenames end + def load_dotenv(overload, filenames) + if overload + Dotenv.overload!(*filenames) + else + Dotenv.load!(*filenames) + end + end + def add_options(parser) add_files_option(parser) add_overload_option(parser) @@ -56,7 +60,7 @@ def add_files_option(parser) end def add_overload_option(parser) - parser.on("-o", "--overload", "Use Dotenv.overload To overwrite existing environment variables") do + parser.on("-o", "--overload", "override existing ENV variables") do @overload = true end end From bd482d1f5261d0279f7cac55ac5f5849bc1efe5a Mon Sep 17 00:00:00 2001 From: Ahmed Kamal Date: Wed, 13 Apr 2022 22:05:07 +0200 Subject: [PATCH 4/7] Update README --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a424eda..6dce6c7 100644 --- a/README.md +++ b/README.md @@ -223,7 +223,7 @@ You can use the `-t` or `--template` flag on the dotenv cli to create a template ```shell $ dotenv -t .env ``` -A template will be created in your working directory named `{FINAME}.template`. So in the above example, it would create a `.env.template` file. +A template will be created in your working directory named `{FINAME}.template`. So in the above example, it would create a `.env.template` file. The template will contain all the environment variables in your `.env` file but with their values set to the variable names. @@ -233,7 +233,7 @@ S3_BUCKET=YOURS3BUCKET SECRET_KEY=YOURSECRETKEYGOESHERE ``` -Would become +Would become ```shell # .env.template @@ -247,6 +247,11 @@ Personally, I prefer to commit the `.env` file with development-only settings. T By default, it **won't** overwrite existing environment variables as dotenv assumes the deployment environment has more knowledge about configuration than the application does. To overwrite existing environment variables you can use `Dotenv.overload`. +You can use the `-o` or `--overload` flag on the dotenv cli to override existing `ENV` variables. +```shell +$ dotenv -o -f ".env.local,.env" +``` + ## Contributing If you want a better idea of how dotenv works, check out the [Ruby Rogues Code Reading of dotenv](https://www.youtube.com/watch?v=lKmY_0uY86s). From 60b2135505a66c3efc2975b98b518b349f1303b0 Mon Sep 17 00:00:00 2001 From: Ahmed Kamal Date: Wed, 13 Apr 2022 22:08:01 +0200 Subject: [PATCH 5/7] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6dce6c7..b1b5a7a 100644 --- a/README.md +++ b/README.md @@ -247,7 +247,7 @@ Personally, I prefer to commit the `.env` file with development-only settings. T By default, it **won't** overwrite existing environment variables as dotenv assumes the deployment environment has more knowledge about configuration than the application does. To overwrite existing environment variables you can use `Dotenv.overload`. -You can use the `-o` or `--overload` flag on the dotenv cli to override existing `ENV` variables. +You can also use the `-o` or `--overload` flag on the dotenv cli to override existing `ENV` variables. ```shell $ dotenv -o -f ".env.local,.env" ``` From 80ae76ba45759e77f7327f25ccfce3b660d899c8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jun 2022 16:07:07 +0000 Subject: [PATCH 6/7] Bump actions/cache from 2.1.6 to 3.0.4 Bumps [actions/cache](https://github.com/actions/cache) from 2.1.6 to 3.0.4. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v2.1.6...v3.0.4) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 67855ed..690ee62 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: - name: Check out repository code uses: actions/checkout@v2 - name: Do some action caching - uses: actions/cache@v2.1.6 + uses: actions/cache@v3.0.4 with: path: vendor key: ${{ runner.os }}-gem-${{ hashFiles('Gemfile', '*.gemspec') }} From 18ea42445fbc3db1ce35ea720285c601146c9427 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Jul 2022 16:07:10 +0000 Subject: [PATCH 7/7] Bump actions/cache from 3.0.4 to 3.0.5 Bumps [actions/cache](https://github.com/actions/cache) from 3.0.4 to 3.0.5. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v3.0.4...v3.0.5) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8294426..318715e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: - name: Check out repository code uses: actions/checkout@v3 - name: Do some action caching - uses: actions/cache@v3.0.4 + uses: actions/cache@v3.0.5 with: path: vendor key: ${{ runner.os }}-gem-${{ hashFiles('Gemfile', '*.gemspec') }}