Skip to content

Commit 8ab3306

Browse files
committed
replace references to dotenv-vault with dotenvx
1 parent ae54323 commit 8ab3306

File tree

1 file changed

+34
-102
lines changed

1 file changed

+34
-102
lines changed

README.md

+34-102
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Dotenv is a zero-dependency module that loads environment variables from a `.env
4949
* [🌱 Install](#-install)
5050
* [🏗️ Usage (.env)](#%EF%B8%8F-usage)
5151
* [🌴 Multiple Environments 🆕](#-manage-multiple-environments)
52-
* [🚀 Deploying (.env.vault) 🆕](#-deploying)
52+
* [🚀 Deploying (encryption) 🆕](#-deploying)
5353
* [📚 Examples](#-examples)
5454
* [📖 Docs](#-documentation)
5555
* [❓ FAQ](#-faq)
@@ -176,23 +176,41 @@ $ DOTENV_CONFIG_ENCODING=latin1 DOTENV_CONFIG_DEBUG=true node -r dotenv/config y
176176

177177
You need to add the value of another variable in one of your variables? Use [dotenv-expand](https://github.com/motdotla/dotenv-expand).
178178

179+
### Command Substitution
180+
181+
Use [dotenvx](https://github.com/dotenvx/dotenvx) to use command substitution.
182+
183+
Add the output of a command to one of your variables in your .env file.
184+
185+
```ini
186+
# .env
187+
DATABASE_URL="postgres://$(whoami)@localhost/my_database"
188+
```
189+
```js
190+
// index.js
191+
console.log('DATABASE_URL', process.env.DATABASE_URL)
192+
```
193+
```sh
194+
$ dotenvx run --debug -- node index.js
195+
[dotenvx@0.14.1] injecting env (1) from .env
196+
DATABASE_URL postgres://yourusername@localhost/my_database
197+
```
198+
179199
### Syncing
180200

181-
You need to keep `.env` files in sync between machines, environments, or team members? Use [dotenv-vault](https://github.com/dotenv-org/dotenv-vault).
201+
You need to keep `.env` files in sync between machines, environments, or team members? Use [dotenvx](https://github.com/dotenvx/dotenvx) to encrypt your `.env` files and safely include them in source control. This still subscribes to the twelve-factor app rules by generating a decryption key separate from code.
182202

183203
### Multiple Environments
184204

185-
You need to manage your secrets across different environments and apply them as needed? Use a `.env.vault` file with a `DOTENV_KEY`.
205+
Use [dotenvx](https://github.com/dotenvx/dotenvx) to generate `.env.ci`, `.env.production` files, and more.
186206

187207
### Deploying
188208

189-
You need to deploy your secrets in a cloud-agnostic manner? Use a `.env.vault` file. See [deploying `.env.vault` files](https://github.com/motdotla/dotenv/tree/master#-deploying).
209+
You need to deploy your secrets in a cloud-agnostic manner? Use [dotenvx](https://github.com/dotenvx/dotenvx) to generate a private decryption key that is set on your production server.
190210

191211
## 🌴 Manage Multiple Environments
192212

193-
Use [dotenvx](https://github.com/dotenvx/dotenvx) or [dotenv-vault](https://github.com/dotenv-org/dotenv-vault).
194-
195-
### dotenvx
213+
Use [dotenvx](https://github.com/dotenvx/dotenvx)
196214

197215
Run any environment locally. Create a `.env.ENVIRONMENT` file and use `--env-file` to load it. It's straightforward, yet flexible.
198216

@@ -218,78 +236,23 @@ Hello local
218236

219237
[more environment examples](https://dotenvx.com/docs/quickstart/environments)
220238

221-
### dotenv-vault
222-
223-
Edit your production environment variables.
224-
225-
```bash
226-
$ npx dotenv-vault open production
227-
```
228-
229-
Regenerate your `.env.vault` file.
230-
231-
```bash
232-
$ npx dotenv-vault build
233-
```
234-
235-
*ℹ️ 🔐 Vault Managed vs 💻 Locally Managed: The above example, for brevity's sake, used the 🔐 Vault Managed solution to manage your `.env.vault` file. You can instead use the 💻 Locally Managed solution. [Read more here](https://github.com/dotenv-org/dotenv-vault#how-do-i-use--locally-managed-dotenv-vault). Our vision is that other platforms and orchestration tools adopt the `.env.vault` standard as they did the `.env` standard. We don't expect to be the only ones providing tooling to manage and generate `.env.vault` files.*
236-
237-
<a href="https://github.com/dotenv-org/dotenv-vault#-manage-multiple-environments">Learn more at dotenv-vault: Manage Multiple Environments</a>
238-
239239
## 🚀 Deploying
240240

241-
Use [dotenvx](https://github.com/dotenvx/dotenvx) or [dotenv-vault](https://github.com/dotenv-org/dotenv-vault).
241+
Use [dotenvx](https://github.com/dotenvx/dotenvx).
242242

243-
### dotenvx
243+
Add encryption to your `.env` files with a single command. Pass the `--encrypt` flag.
244244

245-
Encrypt your secrets to a `.env.vault` file and load from it (recommended for production and ci).
246-
247-
```bash
248-
$ echo "HELLO=World" > .env
249-
$ echo "HELLO=production" > .env.production
245+
```
246+
$ dotenvx set HELLO Production --encrypt -f .env.production
250247
$ echo "console.log('Hello ' + process.env.HELLO)" > index.js
251248
252-
$ dotenvx encrypt
253-
[dotenvx][info] encrypted to .env.vault (.env,.env.production)
254-
[dotenvx][info] keys added to .env.keys (DOTENV_KEY_PRODUCTION,DOTENV_KEY_PRODUCTION)
255-
256-
$ DOTENV_KEY='<dotenv_key_production>' dotenvx run -- node index.js
257-
[dotenvx][info] loading env (1) from encrypted .env.vault
258-
Hello production
259-
^ :-]
249+
$ DOTENV_PRIVATE_KEY_PRODUCTION="<.env.production private key>" dotenvx run -- node index.js
250+
[dotenvx] injecting env (2) from .env.production
251+
Hello Production
260252
```
261253

262254
[learn more](https://github.com/dotenvx/dotenvx?tab=readme-ov-file#encryption)
263255

264-
### dotenv-vault
265-
266-
*Note: Requires dotenv >= 16.1.0*
267-
268-
Encrypt your `.env.vault` file.
269-
270-
```bash
271-
$ npx dotenv-vault build
272-
```
273-
274-
Fetch your production `DOTENV_KEY`.
275-
276-
```bash
277-
$ npx dotenv-vault keys production
278-
```
279-
280-
Set `DOTENV_KEY` on your server.
281-
282-
```bash
283-
# heroku example
284-
heroku config:set DOTENV_KEY=dotenv://:key_1234…@dotenvx.com/vault/.env.vault?environment=production
285-
```
286-
287-
That's it! On deploy, your `.env.vault` file will be decrypted and its secrets injected as environment variables – just in time.
288-
289-
*ℹ️ A note from [Mot](https://github.com/motdotla): Until recently, we did not have an opinion on how and where to store your secrets in production. We now strongly recommend generating a `.env.vault` file. It's the best way to prevent your secrets from being scattered across multiple servers and cloud providers – protecting you from breaches like the [CircleCI breach](https://techcrunch.com/2023/01/05/circleci-breach/). Also it unlocks interoperability WITHOUT native third-party integrations. Third-party integrations are [increasingly risky](https://coderpad.io/blog/development/heroku-github-breach/) to our industry. They may be the 'du jour' of today, but we imagine a better future.*
290-
291-
<a href="https://github.com/dotenv-org/dotenv-vault#-deploying">Learn more at dotenv-vault: Deploying</a>
292-
293256
## 📚 Examples
294257

295258
See [examples](https://github.com/dotenv-org/examples) of using dotenv with various frameworks, languages, and configurations.
@@ -298,7 +261,6 @@ See [examples](https://github.com/dotenv-org/examples) of using dotenv with vari
298261
* [nodejs (debug on)](https://github.com/dotenv-org/examples/tree/master/usage/dotenv-nodejs-debug)
299262
* [nodejs (override on)](https://github.com/dotenv-org/examples/tree/master/usage/dotenv-nodejs-override)
300263
* [nodejs (processEnv override)](https://github.com/dotenv-org/examples/tree/master/usage/dotenv-custom-target)
301-
* [nodejs (DOTENV_KEY override)](https://github.com/dotenv-org/examples/tree/master/usage/dotenv-vault-custom-target)
302264
* [esm](https://github.com/dotenv-org/examples/tree/master/usage/dotenv-esm)
303265
* [esm (preload)](https://github.com/dotenv-org/examples/tree/master/usage/dotenv-esm-preload)
304266
* [typescript](https://github.com/dotenv-org/examples/tree/master/usage/dotenv-typescript)
@@ -399,20 +361,10 @@ Specify an object to write your secrets to. Defaults to `process.env` environmen
399361
const myObject = {}
400362
require('dotenv').config({ processEnv: myObject })
401363

402-
console.log(myObject) // values from .env or .env.vault live here now.
364+
console.log(myObject) // values from .env
403365
console.log(process.env) // this was not changed or written to
404366
```
405367

406-
##### DOTENV_KEY
407-
408-
Default: `process.env.DOTENV_KEY`
409-
410-
Pass the `DOTENV_KEY` directly to config options. Defaults to looking for `process.env.DOTENV_KEY` environment variable. Note this only applies to decrypting `.env.vault` files. If passed as null or undefined, or not passed at all, dotenv falls back to its traditional job of parsing a `.env` file.
411-
412-
```js
413-
require('dotenv').config({ DOTENV_KEY: 'dotenv://:key_1234…@dotenvx.com/vault/.env.vault?environment=production' })
414-
```
415-
416368
### Parse
417369

418370
The engine which parses the contents of your file containing environment
@@ -483,22 +435,6 @@ Default: `false`
483435

484436
Override any environment variables that have already been set.
485437

486-
### Decrypt
487-
488-
The engine which decrypts the ciphertext contents of your .env.vault file is available for use. It accepts a ciphertext and a decryption key. It uses AES-256-GCM encryption.
489-
490-
For example, decrypting a simple ciphertext:
491-
492-
```js
493-
const dotenv = require('dotenv')
494-
const ciphertext = 's7NYXa809k/bVSPwIAmJhPJmEGTtU0hG58hOZy7I0ix6y5HP8LsHBsZCYC/gw5DDFy5DgOcyd18R'
495-
const decryptionKey = 'ddcaa26504cd70a6fef9801901c3981538563a1767c297cb8416e8a38c62fe00'
496-
497-
const decrypted = dotenv.decrypt(ciphertext, decryptionKey)
498-
499-
console.log(decrypted) // # development@v6\nALPHA="zeta"
500-
```
501-
502438
## ❓ FAQ
503439

504440
### Why is the `.env` file not loading my environment variables successfully?
@@ -675,11 +611,7 @@ Try [dotenv-expand](https://github.com/motdotla/dotenv-expand)
675611

676612
### What about syncing and securing .env files?
677613

678-
Use [dotenv-vault](https://github.com/dotenv-org/dotenv-vault)
679-
680-
### What is a `.env.vault` file?
681-
682-
A `.env.vault` file is an encrypted version of your development (and ci, staging, production, etc) environment variables. It is paired with a `DOTENV_KEY` to deploy your secrets more securely than scattering them across multiple platforms and tools. Use [dotenv-vault](https://github.com/dotenv-org/dotenv-vault) to manage and generate them.
614+
Use [dotenvx](https://github.com/dotenvx/dotenvx)
683615

684616
### What if I accidentally commit my `.env` file to code?
685617

0 commit comments

Comments
 (0)