@dotenvx/dotenvx 1.46.0 β†’ 1.47.1

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.
package/CHANGELOG.md CHANGED
@@ -2,19 +2,56 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
- [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.46.0...main)
5
+ [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.47.1...main)
6
6
 
7
- ## Added
7
+ ## 1.47.1
8
+
9
+ ### Added
10
+
11
+ * Add convenience log that `radar active πŸ“‘` when dotenvx-radar is installed ([#625](https://github.com/dotenvx/dotenvx/pull/625))
12
+
13
+ ## 1.47.0
14
+
15
+ ### Added
16
+
17
+ * Add optional `dotenvx radar` command ([#624](https://github.com/dotenvx/dotenvx/pull/624))
18
+ * Radar is an early access commercial extension for dotenvx that will auto backup your .env files.
19
+
20
+ ```
21
+ _______________________________________________________________________
22
+ | |
23
+ | Dotenvx Radar: Env Observability |
24
+ | |
25
+ | β–‘β–’β–“β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘ β–‘β–’β–“β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘ β–‘β–’β–“β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘ |
26
+ | β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘ |
27
+ | β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘ |
28
+ | β–‘β–’β–“β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘β–’β–“β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘ |
29
+ | β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘ |
30
+ | β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘ |
31
+ | β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘ |
32
+ | |
33
+ | Observe, version, and back up your environment variables at runtime. |
34
+ | |
35
+ | Purchase lifetime access at https://dotenvx.com/radar |
36
+ | |
37
+ | --------------------------------------------------------------------- |
38
+ | - thank you for using dotenvx! - @motdotla |
39
+ |_______________________________________________________________________|
40
+ ```
41
+
42
+ ## 1.46.0
43
+
44
+ ### Added
8
45
 
9
46
  * Add error when hoisting issue experienced around commander.js ([#623](https://github.com/dotenvx/dotenvx/pull/623))
10
47
 
11
- ## Removed
48
+ ### Removed
12
49
 
13
50
  * Remove `git-dotenvx` and `git dotenvx` shorthand ([#621](https://github.com/dotenvx/dotenvx/pull/621))
14
51
 
15
52
  ## 1.45.2
16
53
 
17
- ## Changed
54
+ ### Changed
18
55
 
19
56
  * Minor README updates
20
57
 
package/README.md CHANGED
@@ -767,6 +767,104 @@ Advanced CLI commands.
767
767
  DATABASE_URL postgres://username@localhost/my_database
768
768
  ```
769
769
 
770
+ </details>
771
+ * <details><summary>`run` - Default Values</summary><br>
772
+
773
+ Use default values when environment variables are unset or empty.
774
+
775
+ ```ini
776
+ # .env
777
+ # Default value syntax: use value if set, otherwise use default
778
+ DATABASE_HOST=${DB_HOST:-localhost}
779
+ DATABASE_PORT=${DB_PORT:-5432}
780
+
781
+ # Alternative syntax (no colon): use value if set, otherwise use default
782
+ API_URL=${API_BASE_URL-https://api.example.com}
783
+ ```
784
+ ```js
785
+ // index.js
786
+ console.log('DATABASE_HOST', process.env.DATABASE_HOST)
787
+ console.log('DATABASE_PORT', process.env.DATABASE_PORT)
788
+ console.log('API_URL', process.env.API_URL)
789
+ ```
790
+ ```sh
791
+ $ dotenvx run --debug -- node index.js
792
+ [dotenvx@1.X.X] injecting env (3) from .env
793
+ DATABASE_HOST localhost
794
+ DATABASE_PORT 5432
795
+ API_URL https://api.example.com
796
+ ```
797
+
798
+ </details>
799
+ * <details><summary>`run` - Alternate Values</summary><br>
800
+
801
+ Use alternate values when environment variables are set and non-empty.
802
+
803
+ ```ini
804
+ # .env
805
+ NODE_ENV=production
806
+
807
+ # Alternate value syntax: use alternate if set and non-empty, otherwise empty
808
+ DEBUG_MODE=${NODE_ENV:+false}
809
+ LOG_LEVEL=${NODE_ENV:+error}
810
+
811
+ # Alternative syntax (no colon): use alternate if set, otherwise empty
812
+ CACHE_ENABLED=${NODE_ENV+true}
813
+ ```
814
+ ```js
815
+ // index.js
816
+ console.log('NODE_ENV', process.env.NODE_ENV)
817
+ console.log('DEBUG_MODE', process.env.DEBUG_MODE)
818
+ console.log('LOG_LEVEL', process.env.LOG_LEVEL)
819
+ console.log('CACHE_ENABLED', process.env.CACHE_ENABLED)
820
+ ```
821
+ ```sh
822
+ $ dotenvx run --debug -- node index.js
823
+ [dotenvx@1.X.X] injecting env (4) from .env
824
+ NODE_ENV production
825
+ DEBUG_MODE false
826
+ LOG_LEVEL error
827
+ CACHE_ENABLED true
828
+ ```
829
+
830
+ </details>
831
+ * <details><summary>`run` - Interpolation Syntax Summary (Variable Expansion, Default/Alternate Values)</summary><br>
832
+
833
+ Complete reference for variable interpolation patterns supported by dotenvx:
834
+
835
+ ```ini
836
+ # .env
837
+ DEFINED_VAR=hello
838
+ EMPTY_VAR=
839
+ # UNDEFINED_VAR is not set
840
+
841
+ # Default value syntax - use variable if set/non-empty, otherwise use default
842
+ TEST1=${DEFINED_VAR:-fallback} # Result: "hello"
843
+ TEST2=${EMPTY_VAR:-fallback} # Result: "fallback"
844
+ TEST3=${UNDEFINED_VAR:-fallback} # Result: "fallback"
845
+
846
+ # Default value syntax (no colon) - use variable if set, otherwise use default
847
+ TEST4=${DEFINED_VAR-fallback} # Result: "hello"
848
+ TEST5=${EMPTY_VAR-fallback} # Result: "" (empty, but set)
849
+ TEST6=${UNDEFINED_VAR-fallback} # Result: "fallback"
850
+
851
+ # Alternate value syntax - use alternate if variable is set/non-empty, otherwise empty
852
+ TEST7=${DEFINED_VAR:+alternate} # Result: "alternate"
853
+ TEST8=${EMPTY_VAR:+alternate} # Result: "" (empty)
854
+ TEST9=${UNDEFINED_VAR:+alternate} # Result: "" (empty)
855
+
856
+ # Alternate value syntax (no colon) - use alternate if variable is set, otherwise empty
857
+ TEST10=${DEFINED_VAR+alternate} # Result: "alternate"
858
+ TEST11=${EMPTY_VAR+alternate} # Result: "alternate" (empty but set)
859
+ TEST12=${UNDEFINED_VAR+alternate} # Result: "" (empty)
860
+ ```
861
+
862
+ **Key differences:**
863
+ - `:-` vs `-`: The colon makes empty values trigger the fallback
864
+ - `:+` vs `+`: The colon makes empty values not trigger the alternate
865
+ - Default syntax (`-`): Use variable value or fallback
866
+ - Alternate syntax (`+`): Use alternate value or empty string
867
+
770
868
  </details>
771
869
  * <details><summary>`run` - Command Substitution</summary><br>
772
870
 
@@ -897,6 +995,31 @@ Advanced CLI commands.
897
995
 
898
996
  Note that with `--overload` subsequent files DO override pre-existing variables defined in previous files.
899
997
 
998
+ </details>
999
+ * <details><summary>`run` - Environment Variable Precedence (Container/Cloud Deployments)</summary><br>
1000
+
1001
+ When deploying applications in containers or cloud environments, you often need to override specific environment variables at runtime without modifying committed `.env` files. By default, dotenvx follows the historic dotenv principle: **environment variables already present take precedence over `.env` files**.
1002
+
1003
+ ```sh
1004
+ # .env.prod contains: MODEL_REGISTRY=registry.company.com/models/v1
1005
+ $ echo "MODEL_REGISTRY=registry.company.com/models/v1" > .env.prod
1006
+ $ echo "console.log('MODEL_REGISTRY:', process.env.MODEL_REGISTRY)" > app.js
1007
+
1008
+ # Without environment variable set - uses .env.prod value
1009
+ $ dotenvx run -f .env.prod -- node app.js
1010
+ MODEL_REGISTRY: registry.company.com/models/v1
1011
+
1012
+ # With environment variable set (e.g., via Azure Container Service) - environment variable takes precedence
1013
+ $ MODEL_REGISTRY=registry.azure.com/models/v2 dotenvx run -f .env.prod -- node app.js
1014
+ MODEL_REGISTRY: registry.azure.com/models/v2
1015
+
1016
+ # To force .env.prod to override environment variables, use --overload
1017
+ $ MODEL_REGISTRY=registry.azure.com/models/v2 dotenvx run -f .env.prod --overload -- node app.js
1018
+ MODEL_REGISTRY: registry.company.com/models/v1
1019
+ ```
1020
+
1021
+ **For container deployments:** Set environment variables through your cloud provider's UI/configuration (Azure Container Service, AWS ECS, etc.) to override specific values from committed `.env` files without rebuilding your application.
1022
+
900
1023
  </details>
901
1024
  * <details><summary>`DOTENV_PRIVATE_KEY=key run`</summary><br>
902
1025
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.46.0",
2
+ "version": "1.47.1",
3
3
  "name": "@dotenvx/dotenvx",
4
4
  "description": "a better dotenv–from the creator of `dotenv`",
5
5
  "author": "@motdotla",
@@ -6,6 +6,7 @@ const Run = require('./../../lib/services/run')
6
6
 
7
7
  const conventions = require('./../../lib/helpers/conventions')
8
8
  const DeprecationNotice = require('./../../lib/helpers/deprecationNotice')
9
+ const logRadar = require('./../../lib/helpers/logRadar')
9
10
 
10
11
  async function run () {
11
12
  const commandArgs = this.args
@@ -40,6 +41,8 @@ async function run () {
40
41
 
41
42
  new DeprecationNotice().dotenvKey() // DEPRECATION NOTICE
42
43
 
44
+ logRadar()
45
+
43
46
  const {
44
47
  processedEnvs,
45
48
  readableStrings,
@@ -44,7 +44,7 @@ program
44
44
  setLogLevel(options)
45
45
  })
46
46
 
47
- // for dynamic loading of dotenvx-pro, etc
47
+ // for dynamic loading of dotenvx-radar, etc
48
48
  program
49
49
  .argument('[command]', 'dynamic command')
50
50
  .argument('[args...]', 'dynamic command arguments')
@@ -69,7 +69,7 @@ program.command('run')
69
69
  .option('-f, --env-file <paths...>', 'path(s) to your env file(s)', collectEnvs('envFile'), [])
70
70
  .option('-fk, --env-keys-file <path>', 'path to your .env.keys file (default: same path as your env file)')
71
71
  .option('-fv, --env-vault-file <paths...>', 'path(s) to your .env.vault file(s)', collectEnvs('envVaultFile'), [])
72
- .option('-o, --overload', 'override existing env variables')
72
+ .option('-o, --overload', 'override existing env variables (by default, existing env vars take precedence over .env files)')
73
73
  .option('--strict', 'process.exit(1) on any errors', false)
74
74
  .option('--convention <name>', 'load a .env convention (available conventions: [\'nextjs\', \'flow\'])')
75
75
  .option('--ignore <errorCodes...>', 'error code(s) to ignore (example: --ignore=MISSING_ENV_FILE)')
@@ -88,7 +88,7 @@ program.command('get')
88
88
  .option('-f, --env-file <paths...>', 'path(s) to your env file(s)', collectEnvs('envFile'), [])
89
89
  .option('-fk, --env-keys-file <path>', 'path to your .env.keys file (default: same path as your env file)')
90
90
  .option('-fv, --env-vault-file <paths...>', 'path(s) to your .env.vault file(s)', collectEnvs('envVaultFile'), [])
91
- .option('-o, --overload', 'override existing env variables')
91
+ .option('-o, --overload', 'override existing env variables (by default, existing env vars take precedence over .env files)')
92
92
  .option('--strict', 'process.exit(1) on any errors', false)
93
93
  .option('--convention <name>', 'load a .env convention (available conventions: [\'nextjs\', \'flow\'])')
94
94
  .option('--ignore <errorCodes...>', 'error code(s) to ignore (example: --ignore=MISSING_ENV_FILE)')
@@ -200,7 +200,7 @@ program.command('help [command]')
200
200
  // dotenvx pro
201
201
  program.addHelpText('after', ' ')
202
202
  program.addHelpText('after', 'Advanced: ')
203
- program.addHelpText('after', ' pro πŸ† pro')
203
+ program.addHelpText('after', ' radar πŸ“‘ radar')
204
204
  program.addHelpText('after', ' ext πŸ”Œ extensions')
205
205
 
206
206
  // dotenvx ext
@@ -50,6 +50,31 @@ function executeDynamic (program, command, rawArgs) {
50
50
  console.log('')
51
51
  logger.warn(`[INSTALLATION_NEEDED] install dotenvx-${command} to use [dotenvx ${command}] commands πŸ†`)
52
52
  logger.help('? see installation instructions [https://github.com/dotenvx/dotenvx-pro]')
53
+ } else if (command === 'radar') {
54
+ const radar = ` _______________________________________________________________________
55
+ | |
56
+ | Dotenvx Radar: Env Observability |
57
+ | |
58
+ | β–‘β–’β–“β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘ β–‘β–’β–“β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘ β–‘β–’β–“β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘ |
59
+ | β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘ |
60
+ | β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘ |
61
+ | β–‘β–’β–“β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘β–’β–“β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘ |
62
+ | β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘ |
63
+ | β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘ |
64
+ | β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘β–’β–“β–ˆβ–“β–’β–‘β–‘β–’β–“β–ˆβ–“β–’β–‘ |
65
+ | |
66
+ | Observe, version, and back up your environment variables at runtime. |
67
+ | |
68
+ | Purchase lifetime access at https://dotenvx.com/radar |
69
+ | |
70
+ | --------------------------------------------------------------------- |
71
+ | - thank you for using dotenvx! - @motdotla |
72
+ |_______________________________________________________________________|`
73
+
74
+ console.log(radar)
75
+ console.log('')
76
+ logger.warn(`[INSTALLATION_NEEDED] install dotenvx-${command} to use [dotenvx ${command}] πŸ“‘`)
77
+ logger.help('? see installation instructions [https://dotenvx.com/radar]')
53
78
  } else {
54
79
  logger.info(`error: unknown command '${command}'`)
55
80
  }
@@ -0,0 +1,31 @@
1
+ const path = require('path')
2
+ const childProcess = require('child_process')
3
+
4
+ const { logger } = require('./../../shared/logger')
5
+
6
+ function logRadar () {
7
+ let installed = false
8
+
9
+ try {
10
+ // if installed as sibling module
11
+ const projectRoot = path.resolve(process.cwd())
12
+ const dotenvxRadarPath = require.resolve('@dotenvx/dotenvx-radar', { paths: [projectRoot] })
13
+ require(dotenvxRadarPath)
14
+ installed = true
15
+ } catch (_e) {
16
+ try {
17
+ // if installed as binary cli
18
+ childProcess.execSync('dotenvx-radar help', { stdio: ['pipe', 'pipe', 'ignore'] }).toString().trim()
19
+ installed = true
20
+ // if succeeds
21
+ } catch (_e) {
22
+ // do nothing
23
+ }
24
+ }
25
+
26
+ if (installed) {
27
+ logger.successv('radar active πŸ“‘')
28
+ }
29
+ }
30
+
31
+ module.exports = logRadar
package/src/lib/main.js CHANGED
@@ -321,7 +321,7 @@ module.exports = {
321
321
  ls,
322
322
  keypair,
323
323
  genexample,
324
- // expose for libs depending on @dotenvx/dotenvx - like dotenvx-pro
324
+ // expose for libs depending on @dotenvx/dotenvx - like dotenvx-radar
325
325
  setLogLevel,
326
326
  logger,
327
327
  getColor,