@dotenvx/dotenvx 1.38.5 → 1.39.0
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 +12 -4
- package/README.md +31 -6
- package/package.json +1 -1
- package/src/cli/commands/ext.js +1 -1
- package/src/cli/dotenvx.js +3 -3
- package/src/lib/helpers/conventions.js +12 -3
- package/src/lib/main.d.ts +2 -2
- package/src/lib/services/precommit.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,15 @@
|
|
|
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.
|
|
5
|
+
[Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.39.0...main)
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
* Add `--convention flow` option to `dotenvx run` ([#551](https://github.com/dotenvx/dotenvx/pull/551))
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
* Fix typos ([#550](https://github.com/dotenvx/dotenvx/pull/550))
|
|
6
14
|
|
|
7
15
|
## [1.38.5](https://github.com/dotenvx/dotenvx/compare/v1.38.4...v1.38.5)
|
|
8
16
|
|
|
@@ -306,7 +314,7 @@ FOO=${FOO}bar
|
|
|
306
314
|
|
|
307
315
|
### Changed
|
|
308
316
|
|
|
309
|
-
* for `--convention nextjs`
|
|
317
|
+
* for `--convention nextjs` ignore `.env.local` for TEST environment ([#425](https://github.com/dotenvx/dotenvx/pull/425))
|
|
310
318
|
* for `precommit` redirect missing `dotenvx` command using POSIX compliant redirection ([#424](https://github.com/dotenvx/dotenvx/pull/424))
|
|
311
319
|
* make parent `dotenvx help` command less noisy by removing `[options]`. run `dotenvx COMMAND -h` to list all available options like always ([#429](https://github.com/dotenvx/dotenvx/pull/429))
|
|
312
320
|
|
|
@@ -847,7 +855,7 @@ Learn more at [https://dotenvx.com/docs/quickstart#add-encryption]
|
|
|
847
855
|
|
|
848
856
|
### Added
|
|
849
857
|
|
|
850
|
-
* Support encryption
|
|
858
|
+
* Support encryption replacement of multiline values ([#220](https://github.com/dotenvx/dotenvx/pull/220))
|
|
851
859
|
|
|
852
860
|
## 0.40.0
|
|
853
861
|
|
|
@@ -900,7 +908,7 @@ Further notes:
|
|
|
900
908
|
|
|
901
909
|
* `DOTENV_PUBLIC_KEY` lives in the `.env` file. You can safely share this with whomever you wish.
|
|
902
910
|
* `DOTENV_PRIVATE_KEY` lives in your `.env.keys` file. Share this only with those you trust to decrypt your secrets.
|
|
903
|
-
* If using encrypted `.env` files like this it is safe to
|
|
911
|
+
* If using encrypted `.env` files like this it is safe to commit them to source code. This makes reviewing PRs that contain secrets much easier.
|
|
904
912
|
* Tell your contributors to contribute a secret using the command `dotenvx set HELLO world --encrypt`.
|
|
905
913
|
* Set your `DOTENV_PRIVATE_KEY` on your server to decrypt these values using `dotenvx run -- yourcommand`
|
|
906
914
|
* You can repeat all this per environment by modifying your set command to `dotenvx set HELLO production -f .env.production --encrypt` (for example)
|
package/README.md
CHANGED
|
@@ -604,7 +604,7 @@ More examples
|
|
|
604
604
|
</details>
|
|
605
605
|
* <details><summary>`--convention` flag</summary><br>
|
|
606
606
|
|
|
607
|
-
Load envs using [Next.js' convention](https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables#environment-variable-load-order). Set `--convention` to `nextjs`:
|
|
607
|
+
Load envs using [Next.js' convention](https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables#environment-variable-load-order) or [dotenv-flow convention](https://www.npmjs.com/package/dotenv-flow). Set `--convention` to `nextjs` or `flow`:
|
|
608
608
|
|
|
609
609
|
```sh
|
|
610
610
|
$ echo "HELLO=development local" > .env.development.local
|
|
@@ -1029,6 +1029,31 @@ Advanced CLI commands.
|
|
|
1029
1029
|
|
|
1030
1030
|
(more conventions available upon request)
|
|
1031
1031
|
|
|
1032
|
+
</details>
|
|
1033
|
+
* <details><summary>`run --convention=flow`</summary><br>
|
|
1034
|
+
|
|
1035
|
+
Load envs using [dotenv-flow's convention](https://www.npmjs.com/package/dotenv-flow). Set `--convention` to `flow`:
|
|
1036
|
+
|
|
1037
|
+
```sh
|
|
1038
|
+
$ echo "HELLO=development local" > .env.development.local
|
|
1039
|
+
$ echo "HELLO=development" > .env.development
|
|
1040
|
+
$ echo "HELLO=local" > .env.local
|
|
1041
|
+
$ echo "HELLO=env" > .env
|
|
1042
|
+
$ echo "console.log('Hello ' + process.env.HELLO)" > index.js
|
|
1043
|
+
|
|
1044
|
+
$ NODE_ENV=development dotenvx run --convention=flow -- node index.js
|
|
1045
|
+
[dotenvx@1.X.X] injecting env (1) from .env.development.local, .env.development, .env.local, .env
|
|
1046
|
+
Hello development local
|
|
1047
|
+
```
|
|
1048
|
+
|
|
1049
|
+
Further, we recommend using `DOTENV_ENV` over `NODE_ENV`– as `dotenvx` works everywhere, not just node.
|
|
1050
|
+
|
|
1051
|
+
```sh
|
|
1052
|
+
$ DOTENV_ENV=development dotenvx run --convention=flow -- node index.js
|
|
1053
|
+
[dotenvx@1.X.X] injecting env (1) from .env.development.local, .env.development, .env.local, .env
|
|
1054
|
+
Hello development local
|
|
1055
|
+
```
|
|
1056
|
+
|
|
1032
1057
|
</details>
|
|
1033
1058
|
* <details><summary>`run -fk`</summary><br>
|
|
1034
1059
|
|
|
@@ -1508,7 +1533,7 @@ Advanced CLI commands.
|
|
|
1508
1533
|
</details>
|
|
1509
1534
|
* <details><summary>`decrypt -ek`</summary><br>
|
|
1510
1535
|
|
|
1511
|
-
Decrypt the contents inside an encrypted `.env` file except for an
|
|
1536
|
+
Decrypt the contents inside an encrypted `.env` file except for an excluded key.
|
|
1512
1537
|
|
|
1513
1538
|
```sh
|
|
1514
1539
|
$ echo "HELLO=World\nHOLA=Mundo" > .env
|
|
@@ -1606,7 +1631,7 @@ Advanced CLI commands.
|
|
|
1606
1631
|
</details>
|
|
1607
1632
|
* <details><summary>`keypair --format shell`</summary><br>
|
|
1608
1633
|
|
|
1609
|
-
Print a shell formatted
|
|
1634
|
+
Print a shell formatted response of public/private keys.
|
|
1610
1635
|
|
|
1611
1636
|
```sh
|
|
1612
1637
|
$ echo "HELLO=World" > .env
|
|
@@ -1757,7 +1782,7 @@ Advanced CLI commands.
|
|
|
1757
1782
|
</details>
|
|
1758
1783
|
* <details><summary>`rotate -ek`</summary><br>
|
|
1759
1784
|
|
|
1760
|
-
Rotate the encrypted contents inside an encrypted `.env` file except for an
|
|
1785
|
+
Rotate the encrypted contents inside an encrypted `.env` file except for an excluded key.
|
|
1761
1786
|
|
|
1762
1787
|
```sh
|
|
1763
1788
|
$ echo "HELLO=World\nHOLA=Mundo" > .env
|
|
@@ -2212,7 +2237,7 @@ Use dotenvx directly in code.
|
|
|
2212
2237
|
</details>
|
|
2213
2238
|
* <details><summary>`set(KEY, value)`</summary><br>
|
|
2214
2239
|
|
|
2215
|
-
|
|
2240
|
+
Programmatically set an environment variable.
|
|
2216
2241
|
|
|
2217
2242
|
```js
|
|
2218
2243
|
// index.js
|
|
@@ -2223,7 +2248,7 @@ Use dotenvx directly in code.
|
|
|
2223
2248
|
</details>
|
|
2224
2249
|
* <details><summary>`get(KEY)` - <i>Decryption at Access</i></summary><br>
|
|
2225
2250
|
|
|
2226
|
-
|
|
2251
|
+
Programmatically get an environment variable at access/runtime.
|
|
2227
2252
|
|
|
2228
2253
|
```js
|
|
2229
2254
|
// index.js
|
package/package.json
CHANGED
package/src/cli/commands/ext.js
CHANGED
|
@@ -61,7 +61,7 @@ ext.command('scan')
|
|
|
61
61
|
.description('scan for leaked secrets')
|
|
62
62
|
.action(require('./../actions/ext/scan'))
|
|
63
63
|
|
|
64
|
-
//
|
|
64
|
+
// override helpInformation to hide dynamic commands
|
|
65
65
|
ext.helpInformation = function () {
|
|
66
66
|
const originalHelp = Command.prototype.helpInformation.call(this)
|
|
67
67
|
const lines = originalHelp.split('\n')
|
package/src/cli/dotenvx.js
CHANGED
|
@@ -60,7 +60,7 @@ program.command('run')
|
|
|
60
60
|
.option('-fv, --env-vault-file <paths...>', 'path(s) to your .env.vault file(s)', collectEnvs('envVaultFile'), [])
|
|
61
61
|
.option('-o, --overload', 'override existing env variables')
|
|
62
62
|
.option('--strict', 'process.exit(1) on any errors', false)
|
|
63
|
-
.option('--convention <name>', 'load a .env convention (available conventions: [\'nextjs\'])')
|
|
63
|
+
.option('--convention <name>', 'load a .env convention (available conventions: [\'nextjs\', \'flow\'])')
|
|
64
64
|
.option('--ignore <errorCodes...>', 'error code(s) to ignore (example: --ignore=MISSING_ENV_FILE)')
|
|
65
65
|
.action(function (...args) {
|
|
66
66
|
this.envs = envs
|
|
@@ -79,7 +79,7 @@ program.command('get')
|
|
|
79
79
|
.option('-fv, --env-vault-file <paths...>', 'path(s) to your .env.vault file(s)', collectEnvs('envVaultFile'), [])
|
|
80
80
|
.option('-o, --overload', 'override existing env variables')
|
|
81
81
|
.option('--strict', 'process.exit(1) on any errors', false)
|
|
82
|
-
.option('--convention <name>', 'load a .env convention (available conventions: [\'nextjs\'])')
|
|
82
|
+
.option('--convention <name>', 'load a .env convention (available conventions: [\'nextjs\', \'flow\'])')
|
|
83
83
|
.option('--ignore <errorCodes...>', 'error code(s) to ignore (example: --ignore=MISSING_ENV_FILE)')
|
|
84
84
|
.option('-a, --all', 'include all machine envs as well')
|
|
85
85
|
.option('-pp, --pretty-print', 'pretty print output')
|
|
@@ -219,7 +219,7 @@ program.command('precommit')
|
|
|
219
219
|
precommitAction.apply(this, args)
|
|
220
220
|
})
|
|
221
221
|
|
|
222
|
-
//
|
|
222
|
+
// override helpInformation to hide DEPRECATED and 'ext' commands
|
|
223
223
|
program.helpInformation = function () {
|
|
224
224
|
const originalHelp = Command.prototype.helpInformation.call(this)
|
|
225
225
|
const lines = originalHelp.split('\n')
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
function conventions (convention) {
|
|
2
|
+
const env = process.env.DOTENV_ENV || process.env.NODE_ENV || 'development'
|
|
3
|
+
|
|
2
4
|
if (convention === 'nextjs') {
|
|
3
|
-
const
|
|
4
|
-
const canonicalEnv = ['development', 'test', 'production'].includes(nodeEnv) && nodeEnv
|
|
5
|
+
const canonicalEnv = ['development', 'test', 'production'].includes(env) && env
|
|
5
6
|
|
|
6
7
|
return [
|
|
7
8
|
canonicalEnv && { type: 'envFile', value: `.env.${canonicalEnv}.local` },
|
|
@@ -9,8 +10,16 @@ function conventions (convention) {
|
|
|
9
10
|
canonicalEnv && { type: 'envFile', value: `.env.${canonicalEnv}` },
|
|
10
11
|
{ type: 'envFile', value: '.env' }
|
|
11
12
|
].filter(Boolean)
|
|
13
|
+
} else if (convention === 'flow') {
|
|
14
|
+
return [
|
|
15
|
+
{ type: 'envFile', value: `.env.${env}.local` },
|
|
16
|
+
{ type: 'envFile', value: `.env.${env}` },
|
|
17
|
+
{ type: 'envFile', value: '.env.local' },
|
|
18
|
+
{ type: 'envFile', value: '.env' },
|
|
19
|
+
{ type: 'envFile', value: '.env.defaults' }
|
|
20
|
+
]
|
|
12
21
|
} else {
|
|
13
|
-
throw new Error(`INVALID_CONVENTION: '${convention}'. permitted conventions: ['nextjs']`)
|
|
22
|
+
throw new Error(`INVALID_CONVENTION: '${convention}'. permitted conventions: ['nextjs', 'flow']`)
|
|
14
23
|
}
|
|
15
24
|
}
|
|
16
25
|
|
package/src/lib/main.d.ts
CHANGED
|
@@ -121,7 +121,7 @@ export interface DotenvConfigOptions {
|
|
|
121
121
|
DOTENV_KEY?: string;
|
|
122
122
|
|
|
123
123
|
/**
|
|
124
|
-
* Load a .env convention (available conventions: 'nextjs')
|
|
124
|
+
* Load a .env convention (available conventions: 'nextjs, flow')
|
|
125
125
|
*/
|
|
126
126
|
convention?: string;
|
|
127
127
|
|
|
@@ -191,7 +191,7 @@ export interface SetOptions {
|
|
|
191
191
|
envKeysFile?: string;
|
|
192
192
|
|
|
193
193
|
/**
|
|
194
|
-
* Set a .env convention (available conventions: 'nextjs')
|
|
194
|
+
* Set a .env convention (available conventions: 'nextjs, flow')
|
|
195
195
|
*/
|
|
196
196
|
convention?: string;
|
|
197
197
|
|
|
@@ -46,7 +46,7 @@ class Precommit {
|
|
|
46
46
|
dotenvFiles.forEach(file => {
|
|
47
47
|
count += 1
|
|
48
48
|
|
|
49
|
-
// check if file is going to be
|
|
49
|
+
// check if file is going to be committed
|
|
50
50
|
if (this._isFileToBeCommitted(file)) {
|
|
51
51
|
// check if that file is being ignored
|
|
52
52
|
if (ig.ignores(file)) {
|