@dotenvx/dotenvx 0.44.6 → 1.0.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +38 -1
  2. package/README.md +311 -228
  3. package/package.json +1 -1
  4. package/src/cli/actions/{convert.js → encrypt.js} +4 -4
  5. package/src/cli/actions/{genexample.js → ext/genexample.js} +4 -4
  6. package/src/cli/actions/{gitignore.js → ext/gitignore.js} +1 -1
  7. package/src/cli/actions/{hub → ext/hub}/login.js +4 -4
  8. package/src/cli/actions/{hub → ext/hub}/logout.js +4 -4
  9. package/src/cli/actions/{hub → ext/hub}/open.js +9 -9
  10. package/src/cli/actions/{hub → ext/hub}/pull.js +9 -9
  11. package/src/cli/actions/{hub → ext/hub}/push.js +12 -12
  12. package/src/cli/actions/{hub → ext/hub}/status.js +2 -2
  13. package/src/cli/actions/{hub → ext/hub}/token.js +2 -2
  14. package/src/cli/actions/{ls.js → ext/ls.js} +3 -3
  15. package/src/cli/actions/{prebuild.js → ext/prebuild.js} +2 -2
  16. package/src/cli/actions/{precommit.js → ext/precommit.js} +2 -2
  17. package/src/cli/actions/{scan.js → ext/scan.js} +1 -1
  18. package/src/cli/actions/{settings.js → ext/settings.js} +2 -2
  19. package/src/cli/actions/{vault → ext/vault}/decrypt.js +4 -4
  20. package/src/cli/actions/{vault → ext/vault}/encrypt.js +6 -6
  21. package/src/cli/actions/{vault/convert.js → ext/vault/migrate.js} +10 -10
  22. package/src/cli/actions/{vault → ext/vault}/status.js +2 -2
  23. package/src/cli/actions/run.js +1 -1
  24. package/src/cli/actions/set.js +8 -2
  25. package/src/cli/commands/ext/hub.js +89 -0
  26. package/src/cli/commands/ext/vault.js +36 -0
  27. package/src/cli/commands/ext.js +58 -0
  28. package/src/cli/commands/hub.js +22 -22
  29. package/src/cli/commands/vault.js +33 -12
  30. package/src/cli/dotenvx.js +88 -61
  31. package/src/cli/examples.js +12 -12
  32. package/src/cli/pro.txt +22 -0
  33. package/src/lib/helpers/installPrecommitHook.js +5 -5
  34. package/src/lib/main.js +1 -7
  35. package/src/lib/services/precommit.js +1 -1
  36. package/src/lib/services/sets.js +1 -1
  37. package/src/lib/services/vaultEncrypt.js +2 -2
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ![dotenvx](https://dotenvx.com/better-banner.png)
1
+ [![dotenvx](https://dotenvx.com/better-banner.png)](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 [![NPM version](https://img.shields.io/npm/v/@dotenvx/dotenvx.svg?style=flat-square)](https://www.npmjs.com/package/@dotenvx/dotenvx)
12
+ ### Quickstart [![npm version](https://img.shields.io/npm/v/@dotenvx/dotenvx.svg)](https://www.npmjs.com/package/@dotenvx/dotenvx) [![npm installs](https://img.shields.io/npm/dm/@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
- Or install globally
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
+ [![brew installs](https://img.shields.io/github/downloads/dotenvx/dotenvx/total?label=brew%20installs)](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
+ &nbsp;
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
+ [![mac](https://img.shields.io/endpoint?url=https://dotenvx.sh/stats/curl/darwin&label=mac)](https://github.com/dotenvx/dotenvx.sh/blob/main/install.sh)
52
+ [![linux](https://img.shields.io/endpoint?url=https://dotenvx.sh/stats/curl/linux&label=linux)](https://github.com/dotenvx/dotenvx.sh/blob/main/install.sh)
53
+ [![windows](https://img.shields.io/endpoint?url=https://dotenvx.sh/stats/curl/windows&label=windows)](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
+ &nbsp;
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
+ [![docker pulls](https://img.shields.io/docker/pulls/dotenv/dotenvx)](https://hub.docker.com/r/dotenv/dotenvx)
67
+
68
+ &nbsp;
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
- > * [other global ways to install](https://dotenvx.com/docs/install)
34
- >
35
- > Install globally as a cli to unlock dotenv for ANY language, framework, or platform. 💥
36
- >
37
- > I am using (and recommending) this approach going forward. – [motdotla](https://github.com/motdotla)
79
+
80
+ [![github releases](https://img.shields.io/github/downloads/dotenvx/dotenvx/total)](https://github.com/dotenvx/dotenvx/releases)
81
+ <sup>*includes homebrew installs</sup>
82
+
83
+ </details>
84
+
38
85
 
39
86
  &nbsp;
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. Pass the `--encrypt` flag.
560
+ > Add encryption to your `.env` files with a single command. Use `dotenvx encrypt`.
516
561
 
517
562
  ```sh
518
- $ dotenvx set HELLO World --encrypt
519
- set HELLO with encryption (.env)
563
+ $ dotenvx encrypt
564
+ encrypted (.env)
520
565
  ```
521
566
 
522
- ![](https://github.com/dotenvx/dotenvx/assets/3848/21f7a529-7a40-44e4-87d4-a72e1637b702)
567
+ ![encrypted .env](https://github.com/dotenvx/dotenvx/assets/3848/2a8c3dc5-cd8e-4a08-8a59-c24d0535c81a)
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
- $ dotenvx set HELLO World --encrypt
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
- $ dotenvx set HELLO Production --encrypt -f .env.production
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
- $ dotenvx set HELLO Ci --encrypt -f .env.ci
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 --encrypt -f .env
569
- $ dotenvx set HELLO Production --encrypt -f .env.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,220 @@ 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
  &nbsp;
586
661
 
587
- ## Advanced usage
662
+ ## More
663
+
664
+ > Go deeper with [extensions](#extensions-), [advaned usage](#advanced-usage-), and [guides](#guides-).
665
+
666
+ ### Extensions 🔌
667
+
668
+ * <details><summary>`ext ls`</summary><br>
669
+
670
+ Print all `.env` files in a tree structure.
671
+
672
+ ```sh
673
+ $ touch .env
674
+ $ touch .env.production
675
+ $ mkdir -p apps/backend
676
+ $ touch apps/backend/.env
677
+
678
+ $ dotenvx ext ls
679
+ ├─ .env.production
680
+ ├─ .env
681
+ └─ apps
682
+ └─ backend
683
+ └─ .env
684
+ ```
685
+
686
+ </details>
687
+ * <details><summary>`ext ls directory`</summary><br>
688
+
689
+ Print all `.env` files inside a specified path to a directory.
690
+
691
+ ```sh
692
+ $ touch .env
693
+ $ touch .env.production
694
+ $ mkdir -p apps/backend
695
+ $ touch apps/backend/.env
696
+
697
+ $ dotenvx ext ls apps/backend
698
+ └─ .env
699
+ ```
700
+
701
+ </details>
702
+ * <details><summary>`ext ls -f`</summary><br>
703
+
704
+ Glob `.env` filenames matching a wildcard.
705
+
706
+ ```sh
707
+ $ touch .env
708
+ $ touch .env.production
709
+ $ mkdir -p apps/backend
710
+ $ touch apps/backend/.env
711
+ $ touch apps/backend/.env.prod
712
+
713
+ $ dotenvx ext ls -f **/.env.prod*
714
+ ├─ .env.production
715
+ └─ apps
716
+ └─ backend
717
+ └─ .env.prod
718
+ ```
719
+
720
+ </details>
721
+ * <details><summary>`ext genexample`</summary><br>
722
+
723
+ In one command, generate a `.env.example` file from your current `.env` file contents.
724
+
725
+ ```sh
726
+ $ echo "HELLO=World" > .env
727
+
728
+ $ dotenvx ext genexample
729
+ ✔ updated .env.example (1)
730
+ ```
731
+
732
+ ```ini
733
+ # .env.example
734
+ HELLO=""
735
+ ```
736
+
737
+ </details>
738
+ * <details><summary>`ext genexample -f`</summary><br>
739
+
740
+ Pass multiple `.env` files to generate your `.env.example` file from the combination of their contents.
741
+
742
+ ```sh
743
+ $ echo "HELLO=World" > .env
744
+ $ echo "DB_HOST=example.com" > .env.production
745
+
746
+ $ dotenvx ext genexample -f .env -f .env.production
747
+ ✔ updated .env.example (2)
748
+ ```
749
+
750
+ ```ini
751
+ # .env.example
752
+ HELLO=""
753
+ DB_HOST=""
754
+ ```
755
+
756
+ </details>
757
+ * <details><summary>`ext genexample directory`</summary><br>
758
+
759
+ Generate a `.env.example` file inside the specified directory. Useful for monorepos.
760
+
761
+ ```sh
762
+ $ echo "HELLO=World" > .env
763
+ $ mkdir -p apps/backend
764
+ $ echo "HELLO=Backend" > apps/backend/.env
765
+
766
+ $ dotenvx ext genexample apps/backend
767
+ ✔ updated .env.example (1)
768
+ ```
769
+
770
+ ```ini
771
+ # apps/backend/.env.example
772
+ HELLO=""
773
+ ```
774
+
775
+ </details>
776
+ * <details><summary>`ext gitignore`</summary><br>
777
+
778
+ Gitignore your `.env` files.
779
+
780
+ ```sh
781
+ $ dotenvx ext gitignore
782
+ creating .gitignore
783
+ appending .env* to .gitignore
784
+ done
785
+ ```
786
+
787
+ </details>
788
+ * <details><summary>`ext precommit`</summary><br>
789
+
790
+ Prevent `.env` files from being committed to code.
791
+
792
+ ```sh
793
+ $ dotenvx ext precommit
794
+ [dotenvx][precommit] success
795
+ ```
796
+
797
+ </details>
798
+ * <details><summary>`ext precommit --install`</summary><br>
799
+
800
+ Install a shell script to `.git/hooks/pre-commit` to prevent accidentally committing any `.env` files to source control.
801
+
802
+ ```sh
803
+ $ dotenvx ext precommit --install
804
+ [dotenvx][precommit] dotenvx precommit installed [.git/hooks/pre-commit]
805
+ ```
806
+
807
+ </details>
808
+ * <details><summary>`ext prebuild`</summary><br>
809
+
810
+ Prevent `.env` files from being built into your docker containers.
811
+
812
+ Add it to your `Dockerfile`.
813
+
814
+ ```sh
815
+ RUN curl -fsS https://dotenvx.sh | sh
816
+
817
+ ...
818
+
819
+ RUN dotenvx ext prebuild
820
+ CMD ["dotenvx", "run", "--", "node", "index.js"]
821
+ ```
822
+
823
+ </details>
824
+ * <details><summary>`ext scan`</summary><br>
825
+
826
+ Use [gitleaks](https://gitleaks.io) under the hood to scan for possible secrets in your code.
827
+
828
+ ```sh
829
+ $ dotenvx ext scan
830
+
831
+
832
+ │╲
833
+ │ ○
834
+ ○ ░
835
+ ░ gitleaks
836
+
837
+ 100 commits scanned.
838
+ no leaks found
839
+ ```
840
+
841
+ </details>
842
+
843
+ ### Advanced usage 🎓
588
844
 
589
845
  * <details><summary>`run` - Variable Expansion</summary><br>
590
846
 
@@ -685,7 +941,7 @@ More examples
685
941
 
686
942
  ```sh
687
943
  $ touch .env
688
- $ dotenvx set HELLO encrypted --encrypt
944
+ $ dotenvx set HELLO encrypted
689
945
  $ echo "console.log('Hello ' + process.env.HELLO)" > index.js
690
946
 
691
947
  # check your .env.keys files for your privateKey
@@ -701,7 +957,7 @@ More examples
701
957
 
702
958
  ```sh
703
959
  $ touch .env.production
704
- $ dotenvx set HELLO "production encrypted" -f .env.production --encrypt
960
+ $ dotenvx set HELLO "production encrypted" -f .env.production
705
961
  $ echo "console.log('Hello ' + process.env.HELLO)" > index.js
706
962
 
707
963
  # check .env.keys for your privateKey
@@ -719,7 +975,7 @@ More examples
719
975
 
720
976
  ```sh
721
977
  $ touch .env.ci
722
- $ dotenvx set HELLO "ci encrypted" -f .env.production --encrypt
978
+ $ dotenvx set HELLO "ci encrypted" -f .env.production
723
979
  $ echo "console.log('Hello ' + process.env.HELLO)" > index.js
724
980
 
725
981
  # check .env.keys for your privateKey
@@ -738,8 +994,8 @@ More examples
738
994
  ```sh
739
995
  $ touch .env
740
996
  $ touch .env.production
741
- $ dotenvx set HELLO encrypted --encrypt
742
- $ dotenvx set HELLO "production encrypted" -f .env.production --encrypt
997
+ $ dotenvx set HELLO encrypted
998
+ $ dotenvx set HELLO "production encrypted" -f .env.production
743
999
  $ echo "console.log('Hello ' + process.env.HELLO)" > index.js
744
1000
 
745
1001
  # check .env.keys for your privateKeys
@@ -949,24 +1205,12 @@ More examples
949
1205
  </details>
950
1206
  * <details><summary>`set KEY value`</summary><br>
951
1207
 
952
- Set a single key/value.
1208
+ Set an encrypted key/value (on by default).
953
1209
 
954
1210
  ```sh
955
1211
  $ touch .env
956
1212
 
957
1213
  $ 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
1214
  set HELLO with encryption (.env)
971
1215
  ```
972
1216
 
@@ -978,7 +1222,7 @@ More examples
978
1222
  ```sh
979
1223
  $ touch .env.production
980
1224
 
981
- $ dotenvx set HELLO production --encrypt -f .env.production
1225
+ $ dotenvx set HELLO production -f .env.production
982
1226
  set HELLO with encryption (.env.production)
983
1227
  ```
984
1228
 
@@ -991,18 +1235,30 @@ More examples
991
1235
  $ touch .env.ci
992
1236
 
993
1237
  $ dotenvx set HELLO "my ci" -f .env.ci
994
- set HELLO (.env.ci)
1238
+ set HELLO with encryption (.env.ci)
1239
+ ```
1240
+
1241
+ </details>
1242
+ * <details><summary>`set KEY value --plain`</summary><br>
1243
+
1244
+ Set a plaintext key/value.
1245
+
1246
+ ```sh
1247
+ $ touch .env
1248
+
1249
+ $ dotenvx set HELLO World --plain
1250
+ set HELLO (.env)
995
1251
  ```
996
1252
 
997
1253
  </details>
998
- * <details><summary>`convert`</summary><br>
1254
+ * <details><summary>`encrypt`</summary><br>
999
1255
 
1000
- Convert a `.env` file to an encrypted `.env` file.
1256
+ Encrypt the contents of a `.env` file to an encrypted `.env` file.
1001
1257
 
1002
1258
  ```sh
1003
1259
  $ echo "HELLO=World" > .env
1004
1260
 
1005
- $ dotenvx convert
1261
+ $ dotenvx encrypt
1006
1262
  ✔ encrypted (.env)
1007
1263
  ✔ key added to .env.keys (DOTENV_PRIVATE_KEY)
1008
1264
  ℹ add .env.keys to .gitignore: [echo ".env.keys" >> .gitignore]
@@ -1010,195 +1266,21 @@ More examples
1010
1266
  ```
1011
1267
 
1012
1268
  </details>
1013
- * <details><summary>`convert -f`</summary><br>
1269
+ * <details><summary>`encrypt -f`</summary><br>
1014
1270
 
1015
- Convert a specified `.env` file to an encrypted `.env` file.
1271
+ Encrypt the contents of a specified `.env` file to an encrypted `.env` file.
1016
1272
 
1017
1273
  ```sh
1018
1274
  $ echo "HELLO=World" > .env
1019
1275
  $ echo "HELLO=Production" > .env.production
1020
1276
 
1021
- $ dotenvx convert -f .env.production
1277
+ $ dotenvx encrypt -f .env.production
1022
1278
  ✔ encrypted (.env.production)
1023
1279
  ✔ key added to .env.keys (DOTENV_PRIVATE_KEY_PRODUCTION)
1024
1280
  ℹ add .env.keys to .gitignore: [echo ".env.keys" >> .gitignore]
1025
1281
  ℹ run [DOTENV_PRIVATE_KEY_PRODUCTION='bff..bc4' dotenvx run -- yourcommand] to test decryption locally
1026
1282
  ```
1027
1283
 
1028
- </details>
1029
- * <details><summary>`ls`</summary><br>
1030
-
1031
- Print all `.env` files in a tree structure.
1032
-
1033
- ```sh
1034
- $ touch .env
1035
- $ touch .env.production
1036
- $ mkdir -p apps/backend
1037
- $ touch apps/backend/.env
1038
-
1039
- $ dotenvx ls
1040
- ├─ .env.production
1041
- ├─ .env
1042
- └─ apps
1043
- └─ backend
1044
- └─ .env
1045
- ```
1046
-
1047
- </details>
1048
- * <details><summary>`ls directory`</summary><br>
1049
-
1050
- Print all `.env` files inside a specified path to a directory.
1051
-
1052
- ```sh
1053
- $ touch .env
1054
- $ touch .env.production
1055
- $ mkdir -p apps/backend
1056
- $ touch apps/backend/.env
1057
-
1058
- $ dotenvx ls apps/backend
1059
- └─ .env
1060
- ```
1061
-
1062
- </details>
1063
- * <details><summary>`ls -f`</summary><br>
1064
-
1065
- Glob `.env` filenames matching a wildcard.
1066
-
1067
- ```sh
1068
- $ touch .env
1069
- $ touch .env.production
1070
- $ mkdir -p apps/backend
1071
- $ touch apps/backend/.env
1072
- $ touch apps/backend/.env.prod
1073
-
1074
- $ dotenvx ls -f **/.env.prod*
1075
- ├─ .env.production
1076
- └─ apps
1077
- └─ backend
1078
- └─ .env.prod
1079
- ```
1080
-
1081
- </details>
1082
- * <details><summary>`genexample`</summary><br>
1083
-
1084
- In one command, generate a `.env.example` file from your current `.env` file contents.
1085
-
1086
- ```sh
1087
- $ echo "HELLO=World" > .env
1088
-
1089
- $ dotenvx genexample
1090
- ✔ updated .env.example (1)
1091
- ```
1092
-
1093
- ```ini
1094
- # .env.example
1095
- HELLO=""
1096
- ```
1097
-
1098
- </details>
1099
- * <details><summary>`genexample -f`</summary><br>
1100
-
1101
- Pass multiple `.env` files to generate your `.env.example` file from the combination of their contents.
1102
-
1103
- ```sh
1104
- $ echo "HELLO=World" > .env
1105
- $ echo "DB_HOST=example.com" > .env.production
1106
-
1107
- $ dotenvx genexample -f .env -f .env.production
1108
- ✔ updated .env.example (2)
1109
- ```
1110
-
1111
- ```ini
1112
- # .env.example
1113
- HELLO=""
1114
- DB_HOST=""
1115
- ```
1116
-
1117
- </details>
1118
- * <details><summary>`genexample directory`</summary><br>
1119
-
1120
- Generate a `.env.example` file inside the specified directory. Useful for monorepos.
1121
-
1122
- ```sh
1123
- $ echo "HELLO=World" > .env
1124
- $ mkdir -p apps/backend
1125
- $ echo "HELLO=Backend" > apps/backend/.env
1126
-
1127
- $ dotenvx genexample apps/backend
1128
- ✔ updated .env.example (1)
1129
- ```
1130
-
1131
- ```ini
1132
- # apps/backend/.env.example
1133
- HELLO=""
1134
- ```
1135
-
1136
- </details>
1137
- * <details><summary>`gitignore`</summary><br>
1138
-
1139
- Gitignore your `.env` files.
1140
-
1141
- ```sh
1142
- $ dotenvx gitignore
1143
- creating .gitignore
1144
- appending .env* to .gitignore
1145
- done
1146
- ```
1147
-
1148
- </details>
1149
- * <details><summary>`precommit`</summary><br>
1150
-
1151
- Prevent `.env` files from being committed to code.
1152
-
1153
- ```sh
1154
- $ dotenvx precommit
1155
- [dotenvx][precommit] success
1156
- ```
1157
-
1158
- </details>
1159
- * <details><summary>`precommit --install`</summary><br>
1160
-
1161
- Install a shell script to `.git/hooks/pre-commit` to prevent accidentally committing any `.env` files to source control.
1162
-
1163
- ```sh
1164
- $ dotenvx precommit --install
1165
- [dotenvx][precommit] dotenvx precommit installed [.git/hooks/pre-commit]
1166
- ```
1167
-
1168
- </details>
1169
- * <details><summary>`prebuild`</summary><br>
1170
-
1171
- Prevent `.env` files from being built into your docker containers.
1172
-
1173
- Add it to your `Dockerfile`.
1174
-
1175
- ```sh
1176
- RUN curl -fsS https://dotenvx.sh/install.sh | sh
1177
-
1178
- ...
1179
-
1180
- RUN dotenvx prebuild
1181
- CMD ["dotenvx", "run", "--", "node", "index.js"]
1182
- ```
1183
-
1184
- </details>
1185
- * <details><summary>`scan`</summary><br>
1186
-
1187
- Use [gitleaks](https://gitleaks.io) under the hood to scan for possible secrets in your code.
1188
-
1189
- ```sh
1190
- $ dotenvx scan
1191
-
1192
-
1193
- │╲
1194
- │ ○
1195
- ○ ░
1196
- ░ gitleaks
1197
-
1198
- 100 commits scanned.
1199
- no leaks found
1200
- ```
1201
-
1202
1284
  </details>
1203
1285
  * <details><summary>`help`</summary><br>
1204
1286
 
@@ -1222,7 +1304,9 @@ More examples
1222
1304
  run [options] inject env at runtime [dotenvx run -- yourcommand]
1223
1305
  get [options] [key] return a single environment variable
1224
1306
  set [options] <KEY> <value> set a single environment variable
1225
- ...
1307
+ encrypt [options] convert .env file(s) to encrypted .env file(s)
1308
+ pro 🏆 pro
1309
+ ext 🔌 extensions
1226
1310
  help [command] display help for command
1227
1311
  ```
1228
1312
 
@@ -1271,9 +1355,7 @@ More examples
1271
1355
 
1272
1356
  </details>
1273
1357
 
1274
- &nbsp;
1275
-
1276
- ## Guides
1358
+ ### Guides 📖
1277
1359
 
1278
1360
  * [quickstart guides](https://dotenvx.com/docs/quickstart)
1279
1361
  * [run anywhere](https://dotenvx.com/docs/quickstart/run)
@@ -1285,6 +1367,7 @@ More examples
1285
1367
  * [platforms](https://dotenvx.com/docs#platforms)
1286
1368
  * [ci/cd](https://dotenvx.com/docs#cis)
1287
1369
 
1370
+
1288
1371
  &nbsp;
1289
1372
 
1290
1373
  ## FAQ
@@ -1317,9 +1400,9 @@ The `.env.vault` file got us far, but it had limitations such as:
1317
1400
 
1318
1401
  That said, the `.env.vault` tooling will still stick around for at least 1 year under `dotenvx vault` parent command. I'm still using it in projects as are many thousands of other people.
1319
1402
 
1320
- #### Will you provide a migration tool to quickly switch `.env.vault` files to encrypted `.env` files?
1403
+ #### How do I migrate my `.env.vault` file(s) to encrypted `.env` files?
1321
1404
 
1322
- Yes. Working on this soon.
1405
+ Run `$ dotenvx vault migrate` and follow the instructions.
1323
1406
 
1324
1407
  &nbsp;
1325
1408