@dotenvx/dotenvx 0.6.0 → 0.6.2

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 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](#encrypt-your-env-files)
8
8
 
9
9
   
10
10
 
@@ -190,30 +190,109 @@ More examples
190
190
 
191
191
  ## Multiple Environments
192
192
 
193
- Pass the `--env-file` flag (shorthand `-f`) to run any environment from a `.env.environment` file.
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
196
+
196
197
  $ dotenvx run --env-file=.env.production -- node index.js
197
- [dotenvx][INFO] injecting 12 environment variables from .env.production
198
+ Hello production
199
+ > ^^
198
200
  ```
199
201
 
200
- Combine multiple `.env` files if you like.
202
+ More examples
203
+
204
+ * <details><summary>multiple `.env` files</summary><br>
201
205
 
202
- ```
203
- $ dotenvx run --env-file=.env.local --env-file=.env -- node index.js
204
- [dotenvx][INFO] injecting 13 environment variables from .env.local,.env
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
  &nbsp;
208
262
 
209
263
  ## Encrypt Your Env Files
210
264
 
265
+ > Encrypt your secrets to a `.env.vault` file.
211
266
  ```
267
+ $ echo "HELLO=World" > .env
268
+
269
+ $ echo "HELLO=production" > .env.production
270
+
212
271
  $ dotenvx encrypt
213
- ```
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
+
290
+ $ DOTENV_KEY='dotenv://:key_abc123@dotenvx.com/vault/.env.vault?environment=development' dotenvx run -- node index.js
291
+ [dotenvx][INFO] injecting 1 environment variable from encrypted .env.vault
292
+ Hello World
214
293
 
215
- > This will encrypt your `.env` file to a `.env.vault` file. Commit your `.env.vault` file safely to code.
216
- > This will also generate a `.env.keys` file. Do NOT commit this file to code. Keep your `.env.keys` secret. 🤫
294
+ > :-]
295
+ ```
217
296
 
218
297
  &nbsp;
219
298
 
@@ -302,50 +381,41 @@ brew install dotenvx/brew/dotenvx
302
381
 
303
382
  ### Other Ways to Install
304
383
 
305
- 1. After `brew`, installing globally using [`npm`](https://www.npmjs.com/package/@dotenvx/dotenvx) is easiest:
384
+ #### 1. global npm
385
+
386
+ After `brew`, installing globally using [`npm`](https://www.npmjs.com/package/@dotenvx/dotenvx) is easiest:
306
387
 
307
388
  ```sh
308
389
  npm install @dotenvx/dotenvx --global
309
390
  ```
310
391
 
311
- 2. Or use with [`npx`](https://www.npmjs.com/package/npx):
312
-
313
- ```sh
314
- npx @dotenvx/dotenvx help
315
- ```
392
+ #### 2. local npm
316
393
 
317
- 3. Or install in your `package.json`
394
+ Or install in your `package.json`:
318
395
 
319
396
  ```sh
320
397
  npm i @dotenvx/dotenvx --save
321
398
  ```
322
399
  ```json
323
- "scripts": {
324
- "start": "./node_modules/.bin/dotenvx run -- nodex index.js"
400
+ {
401
+ "scripts": {
402
+ "start": "./node_modules/.bin/dotenvx run -- node index.js"
403
+ },
404
+ "dependencies": {
405
+ "@dotenvx/dotenvx": "^0.6.0"
406
+ }
325
407
  }
326
408
  ```
327
409
 
328
- 3. Or download it directly as a standalone binary:
410
+ #### 3. standalone binary
329
411
 
330
- ```sh
331
- curl -fsS https://dotenvx.sh/ | sh
332
- ```
412
+ Or download it directly as a standalone binary:
333
413
 
334
414
  ```sh
335
- # download it to `./dotenvx`
415
+ # download it to `/user/local/bin/dotenvx`
336
416
  curl -fsS https://dotenvx.sh/ | sh
337
417
 
338
418
  # check it works
339
- ./dotenvx help
340
-
341
- # move it to `/usr/local/bin/dotenvx`
342
- sudo install -m 755 dotenvx /usr/local/bin
343
-
344
- # check it still works
345
- /usr/local/bin/dotenvx help
346
-
347
- # check it is in your path
348
- which dotenv
349
419
  dotenvx help
350
420
  ```
351
421
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.6.0",
2
+ "version": "0.6.2",
3
3
  "name": "@dotenvx/dotenvx",
4
4
  "description": "a better dotenv–from the creator of `dotenv`",
5
5
  "author": "@motdotla",
@@ -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)
@@ -7,14 +7,10 @@ const transports = winston.transports
7
7
 
8
8
  const packageJson = require('./packageJson')
9
9
 
10
- function pad (word) {
11
- return word.padEnd(9, ' ')
12
- }
13
-
14
10
  const dotenvxFormat = printf(({ level, message, label, timestamp }) => {
15
11
  const formattedMessage = typeof message === 'object' ? JSON.stringify(message) : message
16
12
 
17
- return `[dotenvx@${packageJson.version}]${pad(`[${level.toUpperCase()}]`)} ${formattedMessage}`
13
+ return `[dotenvx@${packageJson.version}][${level.toUpperCase()}] ${formattedMessage}`
18
14
  })
19
15
 
20
16
  const logger = createLogger({