@dotenvx/dotenvx 0.6.1 โ 0.6.3
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/README.md +209 -71
- package/package.json +1 -1
- package/src/cli/dotenvx.js +19 -3
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
*a better dotenv*โfrom the creator of [`dotenv`](https://github.com/motdotla/dotenv).
|
|
4
4
|
|
|
5
|
-
* run anywhere (cross-platform)
|
|
6
|
-
* multi-environment
|
|
7
|
-
* encrypted envs
|
|
5
|
+
* [run anywhere](#run-anywhere) (cross-platform)
|
|
6
|
+
* [multi-environment](#multiple-environments)
|
|
7
|
+
* [encrypted envs](#encryption)
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
```sh
|
|
15
15
|
brew install dotenvx/brew/dotenvx
|
|
16
16
|
```
|
|
17
|
-
> * [other ways to install](
|
|
17
|
+
> * [other ways to install](https://dotenvx.com/docs/install)
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
@@ -36,7 +36,7 @@ More examples
|
|
|
36
36
|
* <details><summary>Python ๐</summary><br>
|
|
37
37
|
|
|
38
38
|
```sh
|
|
39
|
-
$ echo 'import os;print("Hello " + os.getenv("HELLO", ""))' > index.py
|
|
39
|
+
$ echo "HELLO=World" > .env && echo 'import os;print("Hello " + os.getenv("HELLO", ""))' > index.py
|
|
40
40
|
|
|
41
41
|
$ dotenvx run -- python3 index.py
|
|
42
42
|
Hello World
|
|
@@ -46,7 +46,7 @@ More examples
|
|
|
46
46
|
* <details><summary>PHP ๐</summary><br>
|
|
47
47
|
|
|
48
48
|
```sh
|
|
49
|
-
$ echo '<?php echo "Hello {$_SERVER["HELLO"]}\n";' > index.php
|
|
49
|
+
$ echo "HELLO=World" > .env && echo '<?php echo "Hello {$_SERVER["HELLO"]}\n";' > index.php
|
|
50
50
|
|
|
51
51
|
$ dotenvx run -- php index.php
|
|
52
52
|
Hello World
|
|
@@ -56,7 +56,7 @@ More examples
|
|
|
56
56
|
* <details><summary>Ruby ๐</summary><br>
|
|
57
57
|
|
|
58
58
|
```sh
|
|
59
|
-
$ echo 'puts "Hello #{ENV["HELLO"]}"' > index.rb
|
|
59
|
+
$ echo "HELLO=World" > .env && echo 'puts "Hello #{ENV["HELLO"]}"' > index.rb
|
|
60
60
|
|
|
61
61
|
$ dotenvx run -- ruby index.rb
|
|
62
62
|
Hello World
|
|
@@ -66,7 +66,7 @@ More examples
|
|
|
66
66
|
* <details><summary>Rust ๐ฆ</summary><br>
|
|
67
67
|
|
|
68
68
|
```sh
|
|
69
|
-
$ echo 'fn main() {let hello = std::env::var("HELLO").unwrap_or("".to_string());println!("Hello {hello}");}' > src/main.rs
|
|
69
|
+
$ echo "HELLO=World" > .env && echo 'fn main() {let hello = std::env::var("HELLO").unwrap_or("".to_string());println!("Hello {hello}");}' > src/main.rs
|
|
70
70
|
|
|
71
71
|
$ dotenvx run -- cargo run
|
|
72
72
|
Hello World
|
|
@@ -76,7 +76,7 @@ More examples
|
|
|
76
76
|
* <details><summary>Java โ๏ธ</summary><br>
|
|
77
77
|
|
|
78
78
|
```sh
|
|
79
|
-
$ echo 'public class Index { public static void main(String[] args) { System.out.println("Hello " + System.getenv("HELLO")); } }' > index.java
|
|
79
|
+
$ echo "HELLO=World" > .env && echo 'public class Index { public static void main(String[] args) { System.out.println("Hello " + System.getenv("HELLO")); } }' > index.java
|
|
80
80
|
|
|
81
81
|
$ dotenvx run -- java index.java
|
|
82
82
|
Hello World
|
|
@@ -88,7 +88,7 @@ More examples
|
|
|
88
88
|
```sh
|
|
89
89
|
$ dotnet new console -n HelloWorld -o HelloWorld
|
|
90
90
|
$ cd HelloWorld
|
|
91
|
-
$ echo 'Console.WriteLine($"Hello {Environment.GetEnvironmentVariable("HELLO")}");' > Program.cs && echo "HELLO=World" > .env
|
|
91
|
+
$ echo "HELLO=World" > .env && echo 'Console.WriteLine($"Hello {Environment.GetEnvironmentVariable("HELLO")}");' > Program.cs && echo "HELLO=World" > .env
|
|
92
92
|
|
|
93
93
|
$ dotenvx run -- dotnet run
|
|
94
94
|
Hello World
|
|
@@ -190,33 +190,220 @@ More examples
|
|
|
190
190
|
|
|
191
191
|
## Multiple Environments
|
|
192
192
|
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
> Create a `.env.production` file and use `--env-file` to load it. It's straightforward, yet flexible.
|
|
195
194
|
```sh
|
|
195
|
+
$ echo "HELLO=production" > .env.production && echo "console.log('Hello ' + process.env.HELLO)" > index.js
|
|
196
|
+
|
|
196
197
|
$ dotenvx run --env-file=.env.production -- node index.js
|
|
197
|
-
|
|
198
|
+
Hello production
|
|
199
|
+
> ^^
|
|
198
200
|
```
|
|
199
201
|
|
|
200
|
-
|
|
202
|
+
More examples
|
|
201
203
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
204
|
+
* <details><summary>multiple `.env` files</summary><br>
|
|
205
|
+
|
|
206
|
+
```sh
|
|
207
|
+
$ echo "HELLO=local" > .env.local
|
|
208
|
+
|
|
209
|
+
$ echo "HELLO=World" > .env
|
|
210
|
+
|
|
211
|
+
$ dotenvx run --env-file=.env.local --env-file=.env -- node index.js
|
|
212
|
+
Hello local
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
</details>
|
|
216
|
+
|
|
217
|
+
* <details><summary>`--overload` flag</summary><br>
|
|
218
|
+
|
|
219
|
+
```sh
|
|
220
|
+
$ echo "HELLO=local" > .env.local
|
|
221
|
+
|
|
222
|
+
$ echo "HELLO=World" > .env
|
|
223
|
+
|
|
224
|
+
$ dotenvx run --env-file=.env.local --env-file=.env --overload -- node index.js
|
|
225
|
+
Hello World
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
* <details><summary>`--verbose` flag</summary><br>
|
|
229
|
+
|
|
230
|
+
```sh
|
|
231
|
+
$ echo "HELLO=production" > .env.production
|
|
232
|
+
|
|
233
|
+
$ dotenvx run --env-file=.env.production --verbose -- node index.js
|
|
234
|
+
[dotenvx][VERBOSE] injecting env from /path/to/.env.production
|
|
235
|
+
[dotenvx][VERBOSE] HELLO set
|
|
236
|
+
[dotenvx][INFO] injecting 1 environment variable from .env.production
|
|
237
|
+
Hello production
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
* <details><summary>`--debug` flag</summary><br>
|
|
241
|
+
|
|
242
|
+
```sh
|
|
243
|
+
$ echo "HELLO=production" > .env.production
|
|
244
|
+
|
|
245
|
+
$ dotenvx run --env-file=.env.production --debug -- node index.js
|
|
246
|
+
[dotenvx][DEBUG] configuring options
|
|
247
|
+
[dotenvx][DEBUG] {"envFile":[".env.production"]}
|
|
248
|
+
[dotenvx][VERBOSE] injecting env from /path/to/.env.production
|
|
249
|
+
[dotenvx][DEBUG] reading env from /path/to/.env.production
|
|
250
|
+
[dotenvx][DEBUG] parsing env from /path/to/.env.production
|
|
251
|
+
[dotenvx][DEBUG] {"HELLO":"production"}
|
|
252
|
+
[dotenvx][DEBUG] writing env from /path/to/.env.production
|
|
253
|
+
[dotenvx][VERBOSE] HELLO set
|
|
254
|
+
[dotenvx][DEBUG] HELLO set to production
|
|
255
|
+
[dotenvx][INFO] injecting 1 environment variable from .env.production
|
|
256
|
+
Hello production
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
</details>
|
|
206
260
|
|
|
207
261
|
|
|
208
262
|
|
|
209
|
-
##
|
|
263
|
+
## Encryption
|
|
210
264
|
|
|
265
|
+
> Encrypt your secrets to a `.env.vault` file.
|
|
211
266
|
```
|
|
267
|
+
$ echo "HELLO=World" > .env && echo "console.log('Hello ' + process.env.HELLO)" > index.js
|
|
268
|
+
|
|
269
|
+
$ echo "HELLO=production" > .env.production
|
|
270
|
+
|
|
212
271
|
$ dotenvx encrypt
|
|
272
|
+
[dotenvx][INFO] encrypted .env,.env.production to .env.vault
|
|
273
|
+
[dotenvx][INFO]
|
|
274
|
+
[dotenvx][INFO] try it out:
|
|
275
|
+
[dotenvx][INFO]
|
|
276
|
+
[dotenvx][INFO] DOTENV_KEY='<DOTENV_KEY_ENVIRONMENT>' dotenvx run -- node index.js
|
|
277
|
+
[dotenvx][INFO]
|
|
278
|
+
[dotenvx][INFO] next:
|
|
279
|
+
[dotenvx][INFO]
|
|
280
|
+
[dotenvx][INFO] 1. commit .env.vault safely to code
|
|
281
|
+
[dotenvx][INFO] 2. set DOTENV_KEY on server (or ci)
|
|
282
|
+
[dotenvx][INFO] 3. push your code
|
|
283
|
+
[dotenvx][INFO]
|
|
284
|
+
[dotenvx][INFO] tips:
|
|
285
|
+
[dotenvx][INFO]
|
|
286
|
+
[dotenvx][INFO] * .env.keys file holds your decryption DOTENV_KEYs
|
|
287
|
+
[dotenvx][INFO] * DO NOT commit .env.keys to code
|
|
288
|
+
[dotenvx][INFO] * share .env.keys file over secure channels only
|
|
289
|
+
> :-]
|
|
213
290
|
```
|
|
214
291
|
|
|
215
|
-
|
|
216
|
-
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
> Then load env from encrypted `.env.vault` file
|
|
295
|
+
|
|
296
|
+
```sh
|
|
297
|
+
$ DOTENV_KEY='dotenv://:key_abc123@dotenvx.com/vault/.env.vault?environment=production' dotenvx run -- node index.js
|
|
298
|
+
[dotenvx][INFO] injecting 1 environment variable from encrypted .env.vault
|
|
299
|
+
Hello production
|
|
300
|
+
|
|
301
|
+
> :-]
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
More examples
|
|
305
|
+
|
|
306
|
+
* <details><summary>AWS Lambda</summary><br>
|
|
307
|
+
|
|
308
|
+
```sh
|
|
309
|
+
coming soon
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
</details>
|
|
313
|
+
|
|
314
|
+
* <details><summary>Digital Ocean</summary><br>
|
|
315
|
+
|
|
316
|
+
```sh
|
|
317
|
+
coming soon
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
</details>
|
|
321
|
+
|
|
322
|
+
* <details><summary>Docker</summary><br>
|
|
323
|
+
|
|
324
|
+
```sh
|
|
325
|
+
coming soon
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
</details>
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
* <details><summary>Fly.io</summary><br>
|
|
332
|
+
|
|
333
|
+
```sh
|
|
334
|
+
coming soon
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
</details>
|
|
338
|
+
|
|
339
|
+
* <details><summary>Heroku</summary><br>
|
|
340
|
+
|
|
341
|
+
```sh
|
|
342
|
+
coming soon
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
</details>
|
|
346
|
+
|
|
347
|
+
* <details><summary>Laravel Forge</summary><br>
|
|
348
|
+
|
|
349
|
+
```sh
|
|
350
|
+
coming soon
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
</details>
|
|
354
|
+
|
|
355
|
+
* <details><summary>Netlify</summary><br>
|
|
356
|
+
|
|
357
|
+
```sh
|
|
358
|
+
coming soon
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
</details>
|
|
362
|
+
|
|
363
|
+
* <details><summary>Railway</summary><br>
|
|
364
|
+
|
|
365
|
+
```sh
|
|
366
|
+
coming soon
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
</details>
|
|
370
|
+
|
|
371
|
+
* <details><summary>Render</summary><br>
|
|
372
|
+
|
|
373
|
+
```sh
|
|
374
|
+
coming soon
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
</details>
|
|
378
|
+
|
|
379
|
+
* <details><summary>Vercel</summary><br>
|
|
380
|
+
|
|
381
|
+
```sh
|
|
382
|
+
coming soon
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
</details>
|
|
386
|
+
|
|
387
|
+
* <details><summary>CircleCI</summary><br>
|
|
388
|
+
|
|
389
|
+
```sh
|
|
390
|
+
coming soon
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
</details>
|
|
394
|
+
|
|
395
|
+
* <details><summary>GitHub Actions</summary><br>
|
|
396
|
+
|
|
397
|
+
```sh
|
|
398
|
+
coming soon
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
</details>
|
|
217
402
|
|
|
218
403
|
|
|
219
404
|
|
|
405
|
+
---
|
|
406
|
+
|
|
220
407
|
## Usage
|
|
221
408
|
|
|
222
409
|
### Guide
|
|
@@ -291,58 +478,9 @@ Hello World
|
|
|
291
478
|
|
|
292
479
|
|
|
293
480
|
|
|
294
|
-
|
|
295
|
-
## Install
|
|
296
|
-
|
|
297
|
-
Installing with [`brew`](https://brew.sh) is most straight forward:
|
|
298
|
-
|
|
299
|
-
```sh
|
|
300
|
-
brew install dotenvx/brew/dotenvx
|
|
301
|
-
```
|
|
302
|
-
|
|
303
|
-
### Other Ways to Install
|
|
304
|
-
|
|
305
|
-
#### 1. global npm
|
|
306
|
-
|
|
307
|
-
After `brew`, installing globally using [`npm`](https://www.npmjs.com/package/@dotenvx/dotenvx) is easiest:
|
|
308
|
-
|
|
309
|
-
```sh
|
|
310
|
-
npm install @dotenvx/dotenvx --global
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
#### 2. local npm
|
|
314
|
-
|
|
315
|
-
Or install in your `package.json`:
|
|
316
|
-
|
|
317
|
-
```sh
|
|
318
|
-
npm i @dotenvx/dotenvx --save
|
|
319
|
-
```
|
|
320
|
-
```json
|
|
321
|
-
{
|
|
322
|
-
"scripts": {
|
|
323
|
-
"start": "./node_modules/.bin/dotenvx run -- node index.js"
|
|
324
|
-
},
|
|
325
|
-
"dependencies": {
|
|
326
|
-
"@dotenvx/dotenvx": "^0.6.0"
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
#### 3. standalone binary
|
|
332
|
-
|
|
333
|
-
Or download it directly as a standalone binary:
|
|
334
|
-
|
|
335
|
-
```sh
|
|
336
|
-
# download it to `/user/local/bin/dotenvx`
|
|
337
|
-
curl -fsS https://dotenvx.sh/ | sh
|
|
338
|
-
|
|
339
|
-
# check it works
|
|
340
|
-
dotenvx help
|
|
341
|
-
```
|
|
342
|
-
|
|
343
481
|
## Contributing
|
|
344
482
|
|
|
345
|
-
|
|
483
|
+
You can fork this repo and create [pull requests](https://github.com/dotenvx/dotenvx/pulls) or if you have questions or feedback:
|
|
346
484
|
|
|
347
485
|
* [github.com/dotenvx/dotenvx](https://github.com/dotenvx/dotenvx/issues) - bugs and discussions
|
|
348
486
|
* [@dotenvx ๐](https://x.com/dotenvx) (DMs are open)
|
package/package.json
CHANGED
package/src/cli/dotenvx.js
CHANGED
|
@@ -210,9 +210,9 @@ program.command('encrypt')
|
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
let keysData = `#/!!!!!!!!!!!!!!!!!!!.env.keys!!!!!!!!!!!!!!!!!!!!!!/
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
213
|
+
#/ DOTENV_KEYs. DO NOT commit to source control /
|
|
214
|
+
#/ [how it works](https://dotenv.org/env-keys) /
|
|
215
|
+
#/--------------------------------------------------/\n`
|
|
216
216
|
|
|
217
217
|
for (const key in dotenvKeys) {
|
|
218
218
|
const value = dotenvKeys[key]
|
|
@@ -270,6 +270,22 @@ program.command('encrypt')
|
|
|
270
270
|
}
|
|
271
271
|
|
|
272
272
|
logger.info(`encrypted ${optionEnvFile} to .env.vault`)
|
|
273
|
+
logger.info('')
|
|
274
|
+
logger.info('try it out:')
|
|
275
|
+
logger.info('')
|
|
276
|
+
logger.info(' DOTENV_KEY=\'<DOTENV_KEY_ENVIRONMENT>\' dotenvx run -- node index.js')
|
|
277
|
+
logger.info('')
|
|
278
|
+
logger.info('next:')
|
|
279
|
+
logger.info('')
|
|
280
|
+
logger.info(' 1. commit .env.vault safely to code')
|
|
281
|
+
logger.info(' 2. set DOTENV_KEY on server (or ci)')
|
|
282
|
+
logger.info(' 3. push your code')
|
|
283
|
+
logger.info('')
|
|
284
|
+
logger.info('tips:')
|
|
285
|
+
logger.info('')
|
|
286
|
+
logger.info(' * .env.keys file holds your decryption DOTENV_KEYs')
|
|
287
|
+
logger.info(' * DO NOT commit .env.keys to code')
|
|
288
|
+
logger.info(' * share .env.keys file over secure channels only')
|
|
273
289
|
})
|
|
274
290
|
|
|
275
291
|
program.parse(process.argv)
|