@dotenvx/dotenvx 0.45.0 → 1.0.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 +39 -1
- package/README.md +245 -150
- package/package.json +1 -2
- package/src/cli/actions/{convert.js → encrypt.js} +4 -4
- package/src/cli/actions/{genexample.js → ext/genexample.js} +4 -4
- package/src/cli/actions/{gitignore.js → ext/gitignore.js} +1 -1
- package/src/cli/actions/{hub → ext/hub}/login.js +4 -4
- package/src/cli/actions/{hub → ext/hub}/logout.js +4 -4
- package/src/cli/actions/{hub → ext/hub}/open.js +9 -9
- package/src/cli/actions/{hub → ext/hub}/pull.js +9 -9
- package/src/cli/actions/{hub → ext/hub}/push.js +12 -12
- package/src/cli/actions/{hub → ext/hub}/status.js +2 -2
- package/src/cli/actions/{hub → ext/hub}/token.js +2 -2
- package/src/cli/actions/{ls.js → ext/ls.js} +3 -3
- package/src/cli/actions/{prebuild.js → ext/prebuild.js} +2 -2
- package/src/cli/actions/{precommit.js → ext/precommit.js} +2 -2
- package/src/cli/actions/{scan.js → ext/scan.js} +1 -1
- package/src/cli/actions/{settings.js → ext/settings.js} +2 -2
- package/src/cli/actions/{vault → ext/vault}/decrypt.js +4 -4
- package/src/cli/actions/{vault → ext/vault}/encrypt.js +6 -6
- package/src/cli/actions/{vault → ext/vault}/migrate.js +7 -7
- package/src/cli/actions/{vault → ext/vault}/status.js +2 -2
- package/src/cli/actions/run.js +1 -1
- package/src/cli/actions/set.js +8 -2
- package/src/cli/commands/ext/hub.js +89 -0
- package/src/cli/commands/ext/vault.js +36 -0
- package/src/cli/commands/ext.js +58 -0
- package/src/cli/commands/hub.js +22 -22
- package/src/cli/commands/vault.js +31 -10
- package/src/cli/dotenvx.js +88 -61
- package/src/cli/examples.js +12 -12
- package/src/cli/pro.txt +22 -0
- package/src/lib/helpers/dotenvExpand.js +81 -0
- package/src/lib/helpers/installPrecommitHook.js +5 -5
- package/src/lib/helpers/parseDecryptEvalExpand.js +10 -9
- package/src/lib/main.js +1 -7
- package/src/lib/services/precommit.js +1 -1
- package/src/lib/services/run.js +4 -3
- package/src/lib/services/sets.js +1 -1
- package/src/lib/services/vaultEncrypt.js +2 -2
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-

|
|
1
|
+
[](https://dotenvx.com)
|
|
2
2
|
|
|
3
3
|
*a better dotenv*–from the creator of [`dotenv`](https://github.com/motdotla/dotenv).
|
|
4
4
|
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
### Quickstart [](https://www.npmjs.com/package/@dotenvx/dotenvx) [](https://www.npmjs.com/package/@dotenvx/dotenvx)
|
|
13
13
|
|
|
14
14
|
Install and use it in code just like `dotenv`.
|
|
15
15
|
|
|
@@ -25,16 +25,63 @@ console.log(`Hello ${process.env.HELLO}`)
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
or install globally - *unlocks dotenv for any language, framework, or platform!*
|
|
29
|
+
|
|
30
|
+
<details><summary>with brew 🍺</summary><br>
|
|
29
31
|
|
|
30
32
|
```sh
|
|
31
33
|
brew install dotenvx/brew/dotenvx
|
|
34
|
+
dotenvx help
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
[](https://github.com/dotenvx/homebrew-brew/blob/main/Formula/dotenvx.rb)
|
|
38
|
+
<sup>*homebrew installs sourced from github releases - <a href="https://github.com/dotenvx/homebrew-brew/blob/main/Formula/dotenvx.rb">formula</a></sup>
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
</details>
|
|
43
|
+
|
|
44
|
+
<details><summary>with curl 🌐 </summary><br>
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
curl -sfS https://dotenvx.sh | sh
|
|
48
|
+
dotenvx help
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
[](https://github.com/dotenvx/dotenvx.sh/blob/main/install.sh)
|
|
52
|
+
[](https://github.com/dotenvx/dotenvx.sh/blob/main/install.sh)
|
|
53
|
+
[](https://github.com/dotenvx/dotenvx.sh/blob/main/install.sh)
|
|
54
|
+
<sup>*curl installs sourced from npm binary packages - <a href="https://www.npmjs.com/package/@dotenvx/dotenvx-linux-x86_64">example</a></sup>
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
</details>
|
|
59
|
+
|
|
60
|
+
<details><summary>with docker 🐳</summary><br>
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
docker run -it --rm -v $(pwd):/app dotenv/dotenvx help
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
[](https://hub.docker.com/r/dotenv/dotenvx)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
</details>
|
|
71
|
+
|
|
72
|
+
<details><summary>or with github releases 🐙</summary><br>
|
|
73
|
+
|
|
74
|
+
```sh
|
|
75
|
+
curl -L -o dotenvx.tar.gz "https://github.com/dotenvx/dotenvx/releases/latest/download/dotenvx-$(uname -s)-$(uname -m).tar.gz"
|
|
76
|
+
tar -xzf dotenvx.tar.gz
|
|
77
|
+
./dotenvx help
|
|
32
78
|
```
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
>
|
|
79
|
+
|
|
80
|
+
[](https://github.com/dotenvx/dotenvx/releases)
|
|
81
|
+
<sup>*includes homebrew installs</sup>
|
|
82
|
+
|
|
83
|
+
</details>
|
|
84
|
+
|
|
38
85
|
|
|
39
86
|
|
|
40
87
|
|
|
@@ -83,7 +130,6 @@ More examples
|
|
|
83
130
|
```
|
|
84
131
|
|
|
85
132
|
</details>
|
|
86
|
-
|
|
87
133
|
* <details><summary>Deno 🦕</summary><br>
|
|
88
134
|
|
|
89
135
|
```sh
|
|
@@ -97,6 +143,7 @@ More examples
|
|
|
97
143
|
Hello World
|
|
98
144
|
```
|
|
99
145
|
|
|
146
|
+
</details>
|
|
100
147
|
* <details><summary>Bun 🥟</summary><br>
|
|
101
148
|
|
|
102
149
|
```sh
|
|
@@ -110,6 +157,7 @@ More examples
|
|
|
110
157
|
Hello Test
|
|
111
158
|
```
|
|
112
159
|
|
|
160
|
+
</details>
|
|
113
161
|
* <details><summary>Python 🐍</summary><br>
|
|
114
162
|
|
|
115
163
|
```sh
|
|
@@ -247,7 +295,6 @@ More examples
|
|
|
247
295
|
see [docker guide](https://dotenvx.com/docs/platforms/docker)
|
|
248
296
|
|
|
249
297
|
</details>
|
|
250
|
-
|
|
251
298
|
* <details><summary>CI/CDs 🐙</summary><br>
|
|
252
299
|
|
|
253
300
|
```yaml
|
|
@@ -298,7 +345,6 @@ More examples
|
|
|
298
345
|
see [process manager guides](https://dotenvx.com/docs#process-managers)
|
|
299
346
|
|
|
300
347
|
</details>
|
|
301
|
-
|
|
302
348
|
* <details><summary>npx</summary><br>
|
|
303
349
|
|
|
304
350
|
```sh
|
|
@@ -337,7 +383,6 @@ More examples
|
|
|
337
383
|
```
|
|
338
384
|
|
|
339
385
|
</details>
|
|
340
|
-
|
|
341
386
|
* <details><summary>Git</summary><br>
|
|
342
387
|
|
|
343
388
|
```sh
|
|
@@ -512,14 +557,14 @@ More examples
|
|
|
512
557
|
|
|
513
558
|
## Encryption
|
|
514
559
|
|
|
515
|
-
> Add encryption to your `.env` files with a single command.
|
|
560
|
+
> Add encryption to your `.env` files with a single command. Use `dotenvx encrypt`.
|
|
516
561
|
|
|
517
562
|
```sh
|
|
518
|
-
$ dotenvx
|
|
519
|
-
|
|
563
|
+
$ dotenvx encrypt
|
|
564
|
+
✔ encrypted (.env)
|
|
520
565
|
```
|
|
521
566
|
|
|
522
|
-

|
|
523
568
|
|
|
524
569
|
> A `DOTENV_PUBLIC_KEY` (encryption key) and a `DOTENV_PRIVATE_KEY` (decryption key) are generated using the same public-key cryptography as [Bitcoin](https://en.bitcoin.it/wiki/Secp256k1).
|
|
525
570
|
|
|
@@ -528,7 +573,8 @@ More examples
|
|
|
528
573
|
* <details><summary>`.env`</summary><br>
|
|
529
574
|
|
|
530
575
|
```sh
|
|
531
|
-
$
|
|
576
|
+
$ echo "HELLO=World" > .env
|
|
577
|
+
$ dotenvx encrypt
|
|
532
578
|
$ echo "console.log('Hello ' + process.env.HELLO)" > index.js
|
|
533
579
|
|
|
534
580
|
$ dotenvx run -- node index.js
|
|
@@ -536,10 +582,12 @@ More examples
|
|
|
536
582
|
Hello World
|
|
537
583
|
```
|
|
538
584
|
|
|
585
|
+
</details>
|
|
539
586
|
* <details><summary>`.env.production`</summary><br>
|
|
540
587
|
|
|
541
588
|
```sh
|
|
542
|
-
$
|
|
589
|
+
$ echo "HELLO=Production" > .env.production
|
|
590
|
+
$ dotenvx encrypt -f .env.production
|
|
543
591
|
$ echo "console.log('Hello ' + process.env.HELLO)" > index.js
|
|
544
592
|
|
|
545
593
|
$ DOTENV_PRIVATE_KEY_PRODUCTION="<.env.production private key>" dotenvx run -- node index.js
|
|
@@ -549,10 +597,12 @@ More examples
|
|
|
549
597
|
|
|
550
598
|
Note the `DOTENV_PRIVATE_KEY_PRODUCTION` ends with `_PRODUCTION`. This instructs `dotenvx run` to load the `.env.production` file.
|
|
551
599
|
|
|
600
|
+
</details>
|
|
552
601
|
* <details><summary>`.env.ci`</summary><br>
|
|
553
602
|
|
|
554
603
|
```sh
|
|
555
|
-
$
|
|
604
|
+
$ echo "HELLO=Ci" > .env.ci
|
|
605
|
+
$ dotenvx encrypt -f .env.ci
|
|
556
606
|
$ echo "console.log('Hello ' + process.env.HELLO)" > index.js
|
|
557
607
|
|
|
558
608
|
$ DOTENV_PRIVATE_KEY_CI="<.env.ci private key>" dotenvx run -- node index.js
|
|
@@ -562,11 +612,12 @@ More examples
|
|
|
562
612
|
|
|
563
613
|
Note the `DOTENV_PRIVATE_KEY_CI` ends with `_CI`. This instructs `dotenvx run` to load the `.env.ci` file. See the pattern?
|
|
564
614
|
|
|
615
|
+
</details>
|
|
565
616
|
* <details><summary>combine multiple encrypted .env files</summary><br>
|
|
566
617
|
|
|
567
618
|
```sh
|
|
568
|
-
$ dotenvx set HELLO World
|
|
569
|
-
$ dotenvx set HELLO Production
|
|
619
|
+
$ dotenvx set HELLO World -f .env
|
|
620
|
+
$ dotenvx set HELLO Production -f .env.production
|
|
570
621
|
$ echo "console.log('Hello ' + process.env.HELLO)" > index.js
|
|
571
622
|
|
|
572
623
|
$ DOTENV_PRIVATE_KEY="<.env private key>" DOTENV_PRIVATE_KEY_PRODUCTION="<.env.production private key>" dotenvx run -- node index.js
|
|
@@ -576,15 +627,42 @@ More examples
|
|
|
576
627
|
|
|
577
628
|
Note the `DOTENV_PRIVATE_KEY` instructs `dotenvx run` to load the `.env` file and the `DOTENV_PRIVATE_KEY_PRODUCTION` instructs it to load the `.env.production` file. See the pattern?
|
|
578
629
|
|
|
630
|
+
</details>
|
|
631
|
+
* <details><summary>combine multiple encrypted .env files for monorepo</summary><br>
|
|
632
|
+
|
|
633
|
+
```sh
|
|
634
|
+
$ mkdir app1
|
|
635
|
+
$ mkdir app2
|
|
636
|
+
$ dotenvx set HELLO app1 -f app1/.env.ci
|
|
637
|
+
$ dotenvx set HELLO app2 -f app2/.env.ci
|
|
638
|
+
$ echo "console.log('Hello ' + process.env.HELLO)" > index.js
|
|
639
|
+
|
|
640
|
+
$ DOTENV_PRIVATE_KEY_CI="<app1/privat ci key>,<app2/private ci key>" dotenvx run -f app1/.env.ci -f app2/.env.ci -- node index.js
|
|
641
|
+
[dotenvx] injecting env (2) from app1/.env.ci,app2/.env.ci
|
|
642
|
+
Hello app1
|
|
643
|
+
|
|
644
|
+
$ DOTENV_PRIVATE_KEY_CI="<app1/privat ci key>,<app2/private ci key>" dotenvx run -f app1/.env.ci -f app2/.env.ci --overload -- node index.js
|
|
645
|
+
[dotenvx] injecting env (2) from app1/.env.ci,app2/.env.ci
|
|
646
|
+
Hello app2
|
|
647
|
+
```
|
|
648
|
+
|
|
649
|
+
Note the `DOTENV_PRIVATE_KEY_CI` (and any `DOTENV_PRIVATE_KEY*`) can take multiple private keys by simply comma separating them.
|
|
650
|
+
|
|
651
|
+
</details>
|
|
579
652
|
* <details><summary>other curves</summary><br>
|
|
580
653
|
|
|
581
654
|
> `secp256k1` is a well-known and battle tested curve, in use with Bitcoin and other cryptocurrencies, but we are open to adding support for more curves.
|
|
582
655
|
>
|
|
583
656
|
> If your organization's compliance department requires [NIST approved curves](https://csrc.nist.gov/projects/elliptic-curve-cryptography) or other curves like `curve25519`, please reach out at [security@dotenvx.com](mailto:security@dotenvx.com).
|
|
584
657
|
|
|
658
|
+
</details>
|
|
659
|
+
|
|
585
660
|
|
|
586
661
|
|
|
587
|
-
## Advanced
|
|
662
|
+
## Advanced
|
|
663
|
+
|
|
664
|
+
> Become a `dotenvx` power user.
|
|
665
|
+
>
|
|
588
666
|
|
|
589
667
|
* <details><summary>`run` - Variable Expansion</summary><br>
|
|
590
668
|
|
|
@@ -685,7 +763,7 @@ More examples
|
|
|
685
763
|
|
|
686
764
|
```sh
|
|
687
765
|
$ touch .env
|
|
688
|
-
$ dotenvx set HELLO encrypted
|
|
766
|
+
$ dotenvx set HELLO encrypted
|
|
689
767
|
$ echo "console.log('Hello ' + process.env.HELLO)" > index.js
|
|
690
768
|
|
|
691
769
|
# check your .env.keys files for your privateKey
|
|
@@ -701,7 +779,7 @@ More examples
|
|
|
701
779
|
|
|
702
780
|
```sh
|
|
703
781
|
$ touch .env.production
|
|
704
|
-
$ dotenvx set HELLO "production encrypted" -f .env.production
|
|
782
|
+
$ dotenvx set HELLO "production encrypted" -f .env.production
|
|
705
783
|
$ echo "console.log('Hello ' + process.env.HELLO)" > index.js
|
|
706
784
|
|
|
707
785
|
# check .env.keys for your privateKey
|
|
@@ -719,7 +797,7 @@ More examples
|
|
|
719
797
|
|
|
720
798
|
```sh
|
|
721
799
|
$ touch .env.ci
|
|
722
|
-
$ dotenvx set HELLO "ci encrypted" -f .env.production
|
|
800
|
+
$ dotenvx set HELLO "ci encrypted" -f .env.production
|
|
723
801
|
$ echo "console.log('Hello ' + process.env.HELLO)" > index.js
|
|
724
802
|
|
|
725
803
|
# check .env.keys for your privateKey
|
|
@@ -738,8 +816,8 @@ More examples
|
|
|
738
816
|
```sh
|
|
739
817
|
$ touch .env
|
|
740
818
|
$ touch .env.production
|
|
741
|
-
$ dotenvx set HELLO encrypted
|
|
742
|
-
$ dotenvx set HELLO "production encrypted" -f .env.production
|
|
819
|
+
$ dotenvx set HELLO encrypted
|
|
820
|
+
$ dotenvx set HELLO "production encrypted" -f .env.production
|
|
743
821
|
$ echo "console.log('Hello ' + process.env.HELLO)" > index.js
|
|
744
822
|
|
|
745
823
|
# check .env.keys for your privateKeys
|
|
@@ -949,24 +1027,12 @@ More examples
|
|
|
949
1027
|
</details>
|
|
950
1028
|
* <details><summary>`set KEY value`</summary><br>
|
|
951
1029
|
|
|
952
|
-
Set
|
|
1030
|
+
Set an encrypted key/value (on by default).
|
|
953
1031
|
|
|
954
1032
|
```sh
|
|
955
1033
|
$ touch .env
|
|
956
1034
|
|
|
957
1035
|
$ dotenvx set HELLO World
|
|
958
|
-
set HELLO (.env)
|
|
959
|
-
```
|
|
960
|
-
|
|
961
|
-
</details>
|
|
962
|
-
* <details><summary>`set KEY value --encrypt`</summary><br>
|
|
963
|
-
|
|
964
|
-
Set an encrypted key/value.
|
|
965
|
-
|
|
966
|
-
```sh
|
|
967
|
-
$ touch .env
|
|
968
|
-
|
|
969
|
-
$ dotenvx set HELLO World --encrypt
|
|
970
1036
|
set HELLO with encryption (.env)
|
|
971
1037
|
```
|
|
972
1038
|
|
|
@@ -978,7 +1044,7 @@ More examples
|
|
|
978
1044
|
```sh
|
|
979
1045
|
$ touch .env.production
|
|
980
1046
|
|
|
981
|
-
$ dotenvx set HELLO production
|
|
1047
|
+
$ dotenvx set HELLO production -f .env.production
|
|
982
1048
|
set HELLO with encryption (.env.production)
|
|
983
1049
|
```
|
|
984
1050
|
|
|
@@ -991,18 +1057,30 @@ More examples
|
|
|
991
1057
|
$ touch .env.ci
|
|
992
1058
|
|
|
993
1059
|
$ dotenvx set HELLO "my ci" -f .env.ci
|
|
994
|
-
set HELLO (.env.ci)
|
|
1060
|
+
set HELLO with encryption (.env.ci)
|
|
995
1061
|
```
|
|
996
1062
|
|
|
997
1063
|
</details>
|
|
998
|
-
* <details><summary>`
|
|
1064
|
+
* <details><summary>`set KEY value --plain`</summary><br>
|
|
999
1065
|
|
|
1000
|
-
|
|
1066
|
+
Set a plaintext key/value.
|
|
1067
|
+
|
|
1068
|
+
```sh
|
|
1069
|
+
$ touch .env
|
|
1070
|
+
|
|
1071
|
+
$ dotenvx set HELLO World --plain
|
|
1072
|
+
set HELLO (.env)
|
|
1073
|
+
```
|
|
1074
|
+
|
|
1075
|
+
</details>
|
|
1076
|
+
* <details><summary>`encrypt`</summary><br>
|
|
1077
|
+
|
|
1078
|
+
Encrypt the contents of a `.env` file to an encrypted `.env` file.
|
|
1001
1079
|
|
|
1002
1080
|
```sh
|
|
1003
1081
|
$ echo "HELLO=World" > .env
|
|
1004
1082
|
|
|
1005
|
-
$ dotenvx
|
|
1083
|
+
$ dotenvx encrypt
|
|
1006
1084
|
✔ encrypted (.env)
|
|
1007
1085
|
✔ key added to .env.keys (DOTENV_PRIVATE_KEY)
|
|
1008
1086
|
ℹ add .env.keys to .gitignore: [echo ".env.keys" >> .gitignore]
|
|
@@ -1010,15 +1088,15 @@ More examples
|
|
|
1010
1088
|
```
|
|
1011
1089
|
|
|
1012
1090
|
</details>
|
|
1013
|
-
* <details><summary>`
|
|
1091
|
+
* <details><summary>`encrypt -f`</summary><br>
|
|
1014
1092
|
|
|
1015
|
-
|
|
1093
|
+
Encrypt the contents of a specified `.env` file to an encrypted `.env` file.
|
|
1016
1094
|
|
|
1017
1095
|
```sh
|
|
1018
1096
|
$ echo "HELLO=World" > .env
|
|
1019
1097
|
$ echo "HELLO=Production" > .env.production
|
|
1020
1098
|
|
|
1021
|
-
$ dotenvx
|
|
1099
|
+
$ dotenvx encrypt -f .env.production
|
|
1022
1100
|
✔ encrypted (.env.production)
|
|
1023
1101
|
✔ key added to .env.keys (DOTENV_PRIVATE_KEY_PRODUCTION)
|
|
1024
1102
|
ℹ add .env.keys to .gitignore: [echo ".env.keys" >> .gitignore]
|
|
@@ -1026,7 +1104,82 @@ More examples
|
|
|
1026
1104
|
```
|
|
1027
1105
|
|
|
1028
1106
|
</details>
|
|
1029
|
-
* <details><summary>`
|
|
1107
|
+
* <details><summary>`help`</summary><br>
|
|
1108
|
+
|
|
1109
|
+
Output help for `dotenvx`.
|
|
1110
|
+
|
|
1111
|
+
```sh
|
|
1112
|
+
$ dotenvx help
|
|
1113
|
+
Usage: @dotenvx/dotenvx [options] [command]
|
|
1114
|
+
|
|
1115
|
+
a better dotenv–from the creator of `dotenv`
|
|
1116
|
+
|
|
1117
|
+
Options:
|
|
1118
|
+
-l, --log-level <level> set log level (default: "info")
|
|
1119
|
+
-q, --quiet sets log level to error
|
|
1120
|
+
-v, --verbose sets log level to verbose
|
|
1121
|
+
-d, --debug sets log level to debug
|
|
1122
|
+
-V, --version output the version number
|
|
1123
|
+
-h, --help display help for command
|
|
1124
|
+
|
|
1125
|
+
Commands:
|
|
1126
|
+
run [options] inject env at runtime [dotenvx run -- yourcommand]
|
|
1127
|
+
get [options] [key] return a single environment variable
|
|
1128
|
+
set [options] <KEY> <value> set a single environment variable
|
|
1129
|
+
encrypt [options] convert .env file(s) to encrypted .env file(s)
|
|
1130
|
+
pro 🏆 pro
|
|
1131
|
+
ext 🔌 extensions
|
|
1132
|
+
help [command] display help for command
|
|
1133
|
+
```
|
|
1134
|
+
|
|
1135
|
+
You can get more detailed help per command with `dotenvx help COMMAND`.
|
|
1136
|
+
|
|
1137
|
+
```sh
|
|
1138
|
+
$ dotenvx help run
|
|
1139
|
+
Usage: @dotenvx/dotenvx run [options]
|
|
1140
|
+
|
|
1141
|
+
inject env at runtime [dotenvx run -- yourcommand]
|
|
1142
|
+
|
|
1143
|
+
Options:
|
|
1144
|
+
-e, --env <strings...> environment variable(s) set as string (example: "HELLO=World") (default: [])
|
|
1145
|
+
-f, --env-file <paths...> path(s) to your env file(s) (default: [])
|
|
1146
|
+
-fv, --env-vault-file <paths...> path(s) to your .env.vault file(s) (default: [])
|
|
1147
|
+
-o, --overload override existing env variables
|
|
1148
|
+
--convention <name> load a .env convention (available conventions: ['nextjs'])
|
|
1149
|
+
-h, --help display help for command
|
|
1150
|
+
|
|
1151
|
+
Examples:
|
|
1152
|
+
|
|
1153
|
+
$ dotenvx run -- npm run dev
|
|
1154
|
+
$ dotenvx run -- flask --app index run
|
|
1155
|
+
$ dotenvx run -- php artisan serve
|
|
1156
|
+
$ dotenvx run -- bin/rails s
|
|
1157
|
+
|
|
1158
|
+
Try it:
|
|
1159
|
+
|
|
1160
|
+
$ echo "HELLO=World" > .env
|
|
1161
|
+
$ echo "console.log('Hello ' + process.env.HELLO)" > index.js
|
|
1162
|
+
|
|
1163
|
+
$ dotenvx run -- node index.js
|
|
1164
|
+
[dotenvx] injecting env (1) from .env
|
|
1165
|
+
Hello World
|
|
1166
|
+
```
|
|
1167
|
+
|
|
1168
|
+
</details>
|
|
1169
|
+
* <details><summary>`--version`</summary><br>
|
|
1170
|
+
|
|
1171
|
+
Check current version of `dotenvx`.
|
|
1172
|
+
|
|
1173
|
+
```sh
|
|
1174
|
+
$ dotenvx --version
|
|
1175
|
+
X.X.X
|
|
1176
|
+
```
|
|
1177
|
+
|
|
1178
|
+
</details>
|
|
1179
|
+
|
|
1180
|
+
### Extensions 🔌
|
|
1181
|
+
|
|
1182
|
+
* <details><summary>`ext ls`</summary><br>
|
|
1030
1183
|
|
|
1031
1184
|
Print all `.env` files in a tree structure.
|
|
1032
1185
|
|
|
@@ -1036,7 +1189,7 @@ More examples
|
|
|
1036
1189
|
$ mkdir -p apps/backend
|
|
1037
1190
|
$ touch apps/backend/.env
|
|
1038
1191
|
|
|
1039
|
-
$ dotenvx ls
|
|
1192
|
+
$ dotenvx ext ls
|
|
1040
1193
|
├─ .env.production
|
|
1041
1194
|
├─ .env
|
|
1042
1195
|
└─ apps
|
|
@@ -1045,7 +1198,7 @@ More examples
|
|
|
1045
1198
|
```
|
|
1046
1199
|
|
|
1047
1200
|
</details>
|
|
1048
|
-
* <details><summary>`ls directory`</summary><br>
|
|
1201
|
+
* <details><summary>`ext ls directory`</summary><br>
|
|
1049
1202
|
|
|
1050
1203
|
Print all `.env` files inside a specified path to a directory.
|
|
1051
1204
|
|
|
@@ -1055,12 +1208,12 @@ More examples
|
|
|
1055
1208
|
$ mkdir -p apps/backend
|
|
1056
1209
|
$ touch apps/backend/.env
|
|
1057
1210
|
|
|
1058
|
-
$ dotenvx ls apps/backend
|
|
1211
|
+
$ dotenvx ext ls apps/backend
|
|
1059
1212
|
└─ .env
|
|
1060
1213
|
```
|
|
1061
1214
|
|
|
1062
1215
|
</details>
|
|
1063
|
-
* <details><summary>`ls -f`</summary><br>
|
|
1216
|
+
* <details><summary>`ext ls -f`</summary><br>
|
|
1064
1217
|
|
|
1065
1218
|
Glob `.env` filenames matching a wildcard.
|
|
1066
1219
|
|
|
@@ -1071,7 +1224,7 @@ More examples
|
|
|
1071
1224
|
$ touch apps/backend/.env
|
|
1072
1225
|
$ touch apps/backend/.env.prod
|
|
1073
1226
|
|
|
1074
|
-
$ dotenvx ls -f **/.env.prod*
|
|
1227
|
+
$ dotenvx ext ls -f **/.env.prod*
|
|
1075
1228
|
├─ .env.production
|
|
1076
1229
|
└─ apps
|
|
1077
1230
|
└─ backend
|
|
@@ -1079,14 +1232,14 @@ More examples
|
|
|
1079
1232
|
```
|
|
1080
1233
|
|
|
1081
1234
|
</details>
|
|
1082
|
-
* <details><summary>`genexample`</summary><br>
|
|
1235
|
+
* <details><summary>`ext genexample`</summary><br>
|
|
1083
1236
|
|
|
1084
1237
|
In one command, generate a `.env.example` file from your current `.env` file contents.
|
|
1085
1238
|
|
|
1086
1239
|
```sh
|
|
1087
1240
|
$ echo "HELLO=World" > .env
|
|
1088
1241
|
|
|
1089
|
-
$ dotenvx genexample
|
|
1242
|
+
$ dotenvx ext genexample
|
|
1090
1243
|
✔ updated .env.example (1)
|
|
1091
1244
|
```
|
|
1092
1245
|
|
|
@@ -1096,7 +1249,7 @@ More examples
|
|
|
1096
1249
|
```
|
|
1097
1250
|
|
|
1098
1251
|
</details>
|
|
1099
|
-
* <details><summary>`genexample -f`</summary><br>
|
|
1252
|
+
* <details><summary>`ext genexample -f`</summary><br>
|
|
1100
1253
|
|
|
1101
1254
|
Pass multiple `.env` files to generate your `.env.example` file from the combination of their contents.
|
|
1102
1255
|
|
|
@@ -1104,7 +1257,7 @@ More examples
|
|
|
1104
1257
|
$ echo "HELLO=World" > .env
|
|
1105
1258
|
$ echo "DB_HOST=example.com" > .env.production
|
|
1106
1259
|
|
|
1107
|
-
$ dotenvx genexample -f .env -f .env.production
|
|
1260
|
+
$ dotenvx ext genexample -f .env -f .env.production
|
|
1108
1261
|
✔ updated .env.example (2)
|
|
1109
1262
|
```
|
|
1110
1263
|
|
|
@@ -1115,7 +1268,7 @@ More examples
|
|
|
1115
1268
|
```
|
|
1116
1269
|
|
|
1117
1270
|
</details>
|
|
1118
|
-
* <details><summary>`genexample directory`</summary><br>
|
|
1271
|
+
* <details><summary>`ext genexample directory`</summary><br>
|
|
1119
1272
|
|
|
1120
1273
|
Generate a `.env.example` file inside the specified directory. Useful for monorepos.
|
|
1121
1274
|
|
|
@@ -1124,7 +1277,7 @@ More examples
|
|
|
1124
1277
|
$ mkdir -p apps/backend
|
|
1125
1278
|
$ echo "HELLO=Backend" > apps/backend/.env
|
|
1126
1279
|
|
|
1127
|
-
$ dotenvx genexample apps/backend
|
|
1280
|
+
$ dotenvx ext genexample apps/backend
|
|
1128
1281
|
✔ updated .env.example (1)
|
|
1129
1282
|
```
|
|
1130
1283
|
|
|
@@ -1134,60 +1287,60 @@ More examples
|
|
|
1134
1287
|
```
|
|
1135
1288
|
|
|
1136
1289
|
</details>
|
|
1137
|
-
* <details><summary>`gitignore`</summary><br>
|
|
1290
|
+
* <details><summary>`ext gitignore`</summary><br>
|
|
1138
1291
|
|
|
1139
1292
|
Gitignore your `.env` files.
|
|
1140
1293
|
|
|
1141
1294
|
```sh
|
|
1142
|
-
$ dotenvx gitignore
|
|
1295
|
+
$ dotenvx ext gitignore
|
|
1143
1296
|
creating .gitignore
|
|
1144
1297
|
appending .env* to .gitignore
|
|
1145
1298
|
done
|
|
1146
1299
|
```
|
|
1147
1300
|
|
|
1148
1301
|
</details>
|
|
1149
|
-
* <details><summary>`precommit`</summary><br>
|
|
1302
|
+
* <details><summary>`ext precommit`</summary><br>
|
|
1150
1303
|
|
|
1151
1304
|
Prevent `.env` files from being committed to code.
|
|
1152
1305
|
|
|
1153
1306
|
```sh
|
|
1154
|
-
$ dotenvx precommit
|
|
1307
|
+
$ dotenvx ext precommit
|
|
1155
1308
|
[dotenvx][precommit] success
|
|
1156
1309
|
```
|
|
1157
1310
|
|
|
1158
1311
|
</details>
|
|
1159
|
-
* <details><summary>`precommit --install`</summary><br>
|
|
1312
|
+
* <details><summary>`ext precommit --install`</summary><br>
|
|
1160
1313
|
|
|
1161
1314
|
Install a shell script to `.git/hooks/pre-commit` to prevent accidentally committing any `.env` files to source control.
|
|
1162
1315
|
|
|
1163
1316
|
```sh
|
|
1164
|
-
$ dotenvx precommit --install
|
|
1317
|
+
$ dotenvx ext precommit --install
|
|
1165
1318
|
[dotenvx][precommit] dotenvx precommit installed [.git/hooks/pre-commit]
|
|
1166
1319
|
```
|
|
1167
1320
|
|
|
1168
1321
|
</details>
|
|
1169
|
-
* <details><summary>`prebuild`</summary><br>
|
|
1322
|
+
* <details><summary>`ext prebuild`</summary><br>
|
|
1170
1323
|
|
|
1171
1324
|
Prevent `.env` files from being built into your docker containers.
|
|
1172
1325
|
|
|
1173
1326
|
Add it to your `Dockerfile`.
|
|
1174
1327
|
|
|
1175
1328
|
```sh
|
|
1176
|
-
RUN curl -fsS https://dotenvx.sh
|
|
1329
|
+
RUN curl -fsS https://dotenvx.sh | sh
|
|
1177
1330
|
|
|
1178
1331
|
...
|
|
1179
1332
|
|
|
1180
|
-
RUN dotenvx prebuild
|
|
1333
|
+
RUN dotenvx ext prebuild
|
|
1181
1334
|
CMD ["dotenvx", "run", "--", "node", "index.js"]
|
|
1182
1335
|
```
|
|
1183
1336
|
|
|
1184
1337
|
</details>
|
|
1185
|
-
* <details><summary>`scan`</summary><br>
|
|
1338
|
+
* <details><summary>`ext scan`</summary><br>
|
|
1186
1339
|
|
|
1187
1340
|
Use [gitleaks](https://gitleaks.io) under the hood to scan for possible secrets in your code.
|
|
1188
1341
|
|
|
1189
1342
|
```sh
|
|
1190
|
-
$ dotenvx scan
|
|
1343
|
+
$ dotenvx ext scan
|
|
1191
1344
|
|
|
1192
1345
|
○
|
|
1193
1346
|
│╲
|
|
@@ -1199,91 +1352,33 @@ More examples
|
|
|
1199
1352
|
no leaks found
|
|
1200
1353
|
```
|
|
1201
1354
|
|
|
1202
|
-
</details>
|
|
1203
|
-
* <details><summary>`help`</summary><br>
|
|
1204
|
-
|
|
1205
|
-
Output help for `dotenvx`.
|
|
1206
|
-
|
|
1207
|
-
```sh
|
|
1208
|
-
$ dotenvx help
|
|
1209
|
-
Usage: @dotenvx/dotenvx [options] [command]
|
|
1210
|
-
|
|
1211
|
-
a better dotenv–from the creator of `dotenv`
|
|
1212
|
-
|
|
1213
|
-
Options:
|
|
1214
|
-
-l, --log-level <level> set log level (default: "info")
|
|
1215
|
-
-q, --quiet sets log level to error
|
|
1216
|
-
-v, --verbose sets log level to verbose
|
|
1217
|
-
-d, --debug sets log level to debug
|
|
1218
|
-
-V, --version output the version number
|
|
1219
|
-
-h, --help display help for command
|
|
1220
|
-
|
|
1221
|
-
Commands:
|
|
1222
|
-
run [options] inject env at runtime [dotenvx run -- yourcommand]
|
|
1223
|
-
get [options] [key] return a single environment variable
|
|
1224
|
-
set [options] <KEY> <value> set a single environment variable
|
|
1225
|
-
...
|
|
1226
|
-
help [command] display help for command
|
|
1227
|
-
```
|
|
1228
|
-
|
|
1229
|
-
You can get more detailed help per command with `dotenvx help COMMAND`.
|
|
1230
|
-
|
|
1231
|
-
```sh
|
|
1232
|
-
$ dotenvx help run
|
|
1233
|
-
Usage: @dotenvx/dotenvx run [options]
|
|
1234
|
-
|
|
1235
|
-
inject env at runtime [dotenvx run -- yourcommand]
|
|
1236
|
-
|
|
1237
|
-
Options:
|
|
1238
|
-
-e, --env <strings...> environment variable(s) set as string (example: "HELLO=World") (default: [])
|
|
1239
|
-
-f, --env-file <paths...> path(s) to your env file(s) (default: [])
|
|
1240
|
-
-fv, --env-vault-file <paths...> path(s) to your .env.vault file(s) (default: [])
|
|
1241
|
-
-o, --overload override existing env variables
|
|
1242
|
-
--convention <name> load a .env convention (available conventions: ['nextjs'])
|
|
1243
|
-
-h, --help display help for command
|
|
1244
|
-
|
|
1245
|
-
Examples:
|
|
1246
|
-
|
|
1247
|
-
$ dotenvx run -- npm run dev
|
|
1248
|
-
$ dotenvx run -- flask --app index run
|
|
1249
|
-
$ dotenvx run -- php artisan serve
|
|
1250
|
-
$ dotenvx run -- bin/rails s
|
|
1251
|
-
|
|
1252
|
-
Try it:
|
|
1253
|
-
|
|
1254
|
-
$ echo "HELLO=World" > .env
|
|
1255
|
-
$ echo "console.log('Hello ' + process.env.HELLO)" > index.js
|
|
1256
|
-
|
|
1257
|
-
$ dotenvx run -- node index.js
|
|
1258
|
-
[dotenvx] injecting env (1) from .env
|
|
1259
|
-
Hello World
|
|
1260
|
-
```
|
|
1261
|
-
|
|
1262
|
-
</details>
|
|
1263
|
-
* <details><summary>`--version`</summary><br>
|
|
1264
|
-
|
|
1265
|
-
Check current version of `dotenvx`.
|
|
1266
|
-
|
|
1267
|
-
```sh
|
|
1268
|
-
$ dotenvx --version
|
|
1269
|
-
X.X.X
|
|
1270
|
-
```
|
|
1271
|
-
|
|
1272
1355
|
</details>
|
|
1273
1356
|
|
|
1274
1357
|
|
|
1275
1358
|
|
|
1276
1359
|
## Guides
|
|
1277
1360
|
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
*
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1361
|
+
> Go deeper into using `dotenvx` with detailed framework and platform guides.
|
|
1362
|
+
>
|
|
1363
|
+
|
|
1364
|
+
* <a href="https://dotenvx.com/docs/platforms/digital-ocean">Digital Ocean <img src="https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/digitalocean.svg" alt="Digital Ocean Logo" width="20" height="20" style="fill:#0080FF;"></a>
|
|
1365
|
+
* <a href="https://dotenvx.com/docs/platforms/docker">Docker <img src="https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/docker.svg" alt="Docker Logo" width="20" height="20" style="fill:#2496ED;"></a>
|
|
1366
|
+
* <a href="https://dotenvx.com/docs/platforms/fly">Fly.io</a>
|
|
1367
|
+
* <a href="https://dotenvx.com/docs/cis/github-actions">GitHub Actions <img src="https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/github.svg" alt="GitHub Logo" width="20" height="20" style="fill:#181717;"></a>
|
|
1368
|
+
* <a href="https://dotenvx.com/docs/platforms/heroku">Heroku <img src="https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/heroku.svg" alt="Heroku Logo" width="20" height="20" style="fill:#430098;"></a>
|
|
1369
|
+
* <a href="https://dotenvx.com/docs/platforms/netlify">Netlify <img src="https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/netlify.svg" alt="Netlify Logo" width="20" height="20" style="fill:#00C7B7;"></a>
|
|
1370
|
+
* <a href="https://dotenvx.com/docs/package-managers/npm">NPM <img src="https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/npm.svg" alt="NPM Logo" width="20" height="20" style="fill:#CB3837;"></a>
|
|
1371
|
+
* <a href="https://dotenvx.com/docs/monorepos/nx">Nx <img src="https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/nx.svg" alt="Nx Logo" width="20" height="20" style="fill:#143055;"></a>
|
|
1372
|
+
* <a href="https://dotenvx.com/docs/platforms/render">Render <img src="https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/render.svg" alt="Render Logo" width="20" height="20" style="fill:#000000;"></a>
|
|
1373
|
+
* <a href="https://dotenvx.com/docs/platforms/railway">Railway <img src="https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/railway.svg" alt="Railway Logo" width="20" height="20" style="fill:#0B0D0E;"></a>
|
|
1374
|
+
* <a href="https://dotenvx.com/docs/monorepos/turborepo">Turborepo <img src="https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/turborepo.svg" alt="Turborepo Logo" width="20" height="20" style="fill:#EF4444;"></a>
|
|
1375
|
+
* <a href="https://dotenvx.com/docs/platforms/vercel">Vercel <img src="https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/vercel.svg" alt="Vercel Logo" width="20" height="20" style="fill:#000000;"></a>
|
|
1376
|
+
* [more](https://dotenvx.com/docs/guides)
|
|
1377
|
+
* <a href="https://dotenvx.com/docs/guides#node-js">Node.js <img src="https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/nodejs.svg" alt="Node.js Logo" width="20" height="20" style="fill:#5FA04E;"></a>
|
|
1378
|
+
* <a href="https://dotenvx.com/docs/guides#python">Python <img src="https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/python.svg" alt="Python Logo" width="20" height="20" style="fill:#3776AB;"></a>
|
|
1379
|
+
* <a href="https://dotenvx.com/docs/guides#php">PHP <img src="https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/php.svg" alt="PHP Logo" width="20" height="20" style="fill:#777BB4;"></a>
|
|
1380
|
+
* <a href="https://dotenvx.com/docs/guides#ruby">Ruby <img src="https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/ruby.svg" alt="Ruby Logo" width="20" height="20" style="fill:#CC342D;"></a>
|
|
1381
|
+
* <a href="https://dotenvx.com/docs/guides#rust">Rust <img src="https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/rust.svg" alt="Rust Logo" width="20" height="20" style="fill:#000000;"></a>
|
|
1287
1382
|
|
|
1288
1383
|
|
|
1289
1384
|
|