@dotenvx/dotenvx 2.1.2 → 2.1.4
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 +13 -1
- package/README.md +36 -0
- package/package.json +1 -1
- package/src/cli/actions/get.js +2 -1
- package/src/cli/actions/run.js +2 -1
- package/src/lib/helpers/envResolution/determine.js +10 -7
- package/src/lib/helpers/normalizeDotenvConfigConvention.js +9 -0
- package/src/lib/main.js +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,19 @@
|
|
|
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/v2.1.
|
|
5
|
+
[Unreleased](https://github.com/dotenvx/dotenvx/compare/v2.1.4...main)
|
|
6
|
+
|
|
7
|
+
## [2.1.4](https://github.com/dotenvx/dotenvx/compare/v2.1.3...v2.1.4) (2026-07-02)
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
* Add support for `DOTENV_CONFIG_CONVENTION=nextjs` ([#869](https://github.com/dotenvx/dotenvx/pull/869))
|
|
12
|
+
|
|
13
|
+
## [2.1.3](https://github.com/dotenvx/dotenvx/compare/v2.1.2...v2.1.3) (2026-07-02)
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
* Patch edge case when custom unspecified `-f` and `--env` flag ([#868](https://github.com/dotenvx/dotenvx/pull/868))
|
|
6
18
|
|
|
7
19
|
## [2.1.2](https://github.com/dotenvx/dotenvx/compare/v2.1.1...v2.1.2) (2026-07-02)
|
|
8
20
|
|
package/README.md
CHANGED
|
@@ -1319,6 +1319,14 @@ $ dotenvx run --convention=nextjs -- node index.js
|
|
|
1319
1319
|
Hello development local
|
|
1320
1320
|
```
|
|
1321
1321
|
|
|
1322
|
+
You can also set `DOTENV_CONFIG_CONVENTION=nextjs`.
|
|
1323
|
+
|
|
1324
|
+
```sh
|
|
1325
|
+
$ DOTENV_CONFIG_CONVENTION=nextjs dotenvx run -- node index.js
|
|
1326
|
+
[dotenvx@1.X.X] injecting env (1) from .env.development.local, .env.local, .env.development, .env
|
|
1327
|
+
Hello development local
|
|
1328
|
+
```
|
|
1329
|
+
|
|
1322
1330
|
(more conventions available upon request)
|
|
1323
1331
|
|
|
1324
1332
|
</details>
|
|
@@ -1338,6 +1346,14 @@ $ NODE_ENV=development dotenvx run --convention=flow -- node index.js
|
|
|
1338
1346
|
Hello development local
|
|
1339
1347
|
```
|
|
1340
1348
|
|
|
1349
|
+
You can also set `DOTENV_CONFIG_CONVENTION=flow`.
|
|
1350
|
+
|
|
1351
|
+
```sh
|
|
1352
|
+
$ NODE_ENV=development DOTENV_CONFIG_CONVENTION=flow dotenvx run -- node index.js
|
|
1353
|
+
[dotenvx@1.X.X] injecting env (1) from .env.development.local, .env.development, .env.local, .env
|
|
1354
|
+
Hello development local
|
|
1355
|
+
```
|
|
1356
|
+
|
|
1341
1357
|
Further, we recommend using `DOTENV_ENV` over `NODE_ENV`– as `dotenvx` works everywhere, not just node.
|
|
1342
1358
|
|
|
1343
1359
|
```sh
|
|
@@ -1468,6 +1484,13 @@ $ dotenvx get HELLO --convention=nextjs
|
|
|
1468
1484
|
development local
|
|
1469
1485
|
```
|
|
1470
1486
|
|
|
1487
|
+
You can also set `DOTENV_CONFIG_CONVENTION=nextjs`.
|
|
1488
|
+
|
|
1489
|
+
```sh
|
|
1490
|
+
$ DOTENV_CONFIG_CONVENTION=nextjs dotenvx get HELLO
|
|
1491
|
+
development local
|
|
1492
|
+
```
|
|
1493
|
+
|
|
1471
1494
|
</details>
|
|
1472
1495
|
<details><summary>`get KEY --convention=flow`</summary><br>
|
|
1473
1496
|
|
|
@@ -1484,6 +1507,13 @@ $ NODE_ENV=development dotenvx get HELLO --convention=flow
|
|
|
1484
1507
|
development local
|
|
1485
1508
|
```
|
|
1486
1509
|
|
|
1510
|
+
You can also set `DOTENV_CONFIG_CONVENTION=flow`.
|
|
1511
|
+
|
|
1512
|
+
```sh
|
|
1513
|
+
$ NODE_ENV=development DOTENV_CONFIG_CONVENTION=flow dotenvx get HELLO
|
|
1514
|
+
development local
|
|
1515
|
+
```
|
|
1516
|
+
|
|
1487
1517
|
Further, we recommend using `DOTENV_ENV` over `NODE_ENV`– as `dotenvx` works everywhere, not just node.
|
|
1488
1518
|
|
|
1489
1519
|
```sh
|
|
@@ -2568,6 +2598,12 @@ This is equivalent to using `--convention=nextjs` with the CLI:
|
|
|
2568
2598
|
$ dotenvx run --convention=nextjs -- node index.js
|
|
2569
2599
|
```
|
|
2570
2600
|
|
|
2601
|
+
You can also set `DOTENV_CONFIG_CONVENTION=nextjs`.
|
|
2602
|
+
|
|
2603
|
+
```sh
|
|
2604
|
+
$ DOTENV_CONFIG_CONVENTION=nextjs node index.js
|
|
2605
|
+
```
|
|
2606
|
+
|
|
2571
2607
|
</details>
|
|
2572
2608
|
<details><summary>`config(noArmor:)` - noArmor</summary><br>
|
|
2573
2609
|
|
package/package.json
CHANGED
package/src/cli/actions/get.js
CHANGED
|
@@ -7,9 +7,10 @@ const createSpinner = require('../../lib/helpers/createSpinner')
|
|
|
7
7
|
const Session = require('../../db/session')
|
|
8
8
|
const getResolver = require('./../../lib/resolvers/get')
|
|
9
9
|
const normalizeArmorAliases = require('./normalizeArmorAliases')
|
|
10
|
+
const normalizeDotenvConfigConvention = require('../../lib/helpers/normalizeDotenvConfigConvention')
|
|
10
11
|
|
|
11
12
|
async function get (key) {
|
|
12
|
-
const options = normalizeArmorAliases(this.opts())
|
|
13
|
+
const options = normalizeDotenvConfigConvention(normalizeArmorAliases(this.opts()))
|
|
13
14
|
const spinner = await createSpinner({ ...options, text: 'decrypting' })
|
|
14
15
|
|
|
15
16
|
logger.debug(`options: ${JSON.stringify(options)}`)
|
package/src/cli/actions/run.js
CHANGED
|
@@ -8,6 +8,7 @@ const createSpinner = require('../../lib/helpers/createSpinner')
|
|
|
8
8
|
const Session = require('../../db/session')
|
|
9
9
|
const normalizeArmorAliases = require('./normalizeArmorAliases')
|
|
10
10
|
const normalizeDotenvConfigQuiet = require('../../lib/helpers/normalizeDotenvConfigQuiet')
|
|
11
|
+
const normalizeDotenvConfigConvention = require('../../lib/helpers/normalizeDotenvConfigConvention')
|
|
11
12
|
|
|
12
13
|
const conventions = require('./../../lib/helpers/conventions')
|
|
13
14
|
const { determine } = require('./../../lib/helpers/envResolution')
|
|
@@ -46,7 +47,7 @@ function uniqueInjectedKeys (processedEnvs) {
|
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
async function run () {
|
|
49
|
-
const options = normalizeDotenvConfigQuiet(normalizeArmorAliases(this.opts()))
|
|
50
|
+
const options = normalizeDotenvConfigConvention(normalizeDotenvConfigQuiet(normalizeArmorAliases(this.opts())))
|
|
50
51
|
|
|
51
52
|
let commandArgs = this.args
|
|
52
53
|
if (commandArgs.length < 1) {
|
|
@@ -17,13 +17,16 @@ function envsFromDotenvPrivateKey (privateKeyNames) {
|
|
|
17
17
|
|
|
18
18
|
function determine (envs = [], processEnv) {
|
|
19
19
|
const privateKeyNames = dotenvPrivateKeyNames(processEnv)
|
|
20
|
-
if (!envs || envs.length <= 0) {
|
|
21
|
-
// if process.env.DOTENV_PRIVATE_KEY or process.env.DOTENV_PRIVATE_KEY_${environment} is set, assume inline encryption methodology
|
|
22
|
-
if (privateKeyNames.length > 0) {
|
|
23
|
-
return envsFromDotenvPrivateKey(privateKeyNames)
|
|
24
|
-
}
|
|
25
20
|
|
|
26
|
-
|
|
21
|
+
// https://github.com/dotenvx/dotenvx/issues/670
|
|
22
|
+
let defaults = DEFAULT_ENVS // default to .env file expectation
|
|
23
|
+
// if process.env.DOTENV_PRIVATE_KEY or process.env.DOTENV_PRIVATE_KEY_${environment} is set, assume inline encryption methodology
|
|
24
|
+
if (privateKeyNames.length > 0) {
|
|
25
|
+
defaults = envsFromDotenvPrivateKey(privateKeyNames)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!envs || envs.length <= 0) {
|
|
29
|
+
return defaults
|
|
27
30
|
} else {
|
|
28
31
|
let fileAlreadySpecified = false
|
|
29
32
|
|
|
@@ -39,7 +42,7 @@ function determine (envs = [], processEnv) {
|
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
// no .env file specified as a flag so default to .env
|
|
42
|
-
return [...
|
|
45
|
+
return [...defaults, ...envs]
|
|
43
46
|
}
|
|
44
47
|
}
|
|
45
48
|
|
package/src/lib/main.js
CHANGED
|
@@ -23,6 +23,7 @@ const fsx = require('./helpers/fsx')
|
|
|
23
23
|
const decryptKeyValue = require('./helpers/cryptography/decryptKeyValue')
|
|
24
24
|
const Errors = require('./helpers/errors')
|
|
25
25
|
const normalizeDotenvConfigQuiet = require('./helpers/normalizeDotenvConfigQuiet')
|
|
26
|
+
const normalizeDotenvConfigConvention = require('./helpers/normalizeDotenvConfigConvention')
|
|
26
27
|
|
|
27
28
|
function uniqueInjectedKeys (processedEnvs) {
|
|
28
29
|
const result = new Set()
|
|
@@ -37,6 +38,7 @@ function uniqueInjectedKeys (processedEnvs) {
|
|
|
37
38
|
/** @type {import('./main').config} */
|
|
38
39
|
const config = function (options = {}) {
|
|
39
40
|
options = normalizeDotenvConfigQuiet(options)
|
|
41
|
+
options = normalizeDotenvConfigConvention(options)
|
|
40
42
|
|
|
41
43
|
// allow user to set processEnv to write to
|
|
42
44
|
let processEnv = process.env
|
|
@@ -300,6 +302,8 @@ const set = async function (key, value, options = {}) {
|
|
|
300
302
|
|
|
301
303
|
/* @type {import('./main').get} */
|
|
302
304
|
const get = async function (key, options = {}) {
|
|
305
|
+
options = normalizeDotenvConfigConvention(options)
|
|
306
|
+
|
|
303
307
|
const envs = buildEnvs(options)
|
|
304
308
|
const noArmor = resolveNoArmor(options)
|
|
305
309
|
|