@dotenvx/dotenvx 0.10.5 → 0.11.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.
package/README.md CHANGED
@@ -11,10 +11,30 @@
11
11
 
12
12
  ### Quickstart
13
13
 
14
+ Install and use it in code just like `dotenv`.
15
+
16
+ ```sh
17
+ npm install @dotenvx/dotenvx --save
18
+ ```
19
+ ```js
20
+ // index.js
21
+ require('@dotenvx/dotenvx').config()
22
+
23
+ console.log(`Hello ${process.env.HELLO}`)
24
+ ```
25
+
26
+  
27
+
28
+ Or install globally
29
+
14
30
  ```sh
15
31
  brew install dotenvx/brew/dotenvx
16
32
  ```
17
- > * [other ways to install](https://dotenvx.com/docs/install)
33
+ > * [other global ways to install](https://dotenvx.com/docs/install)
34
+ >
35
+ > Installing globally as a cli unlocks dotenv for ANY language, framework, or platform. 💥
36
+ >
37
+ > I am using (and recommending) this approach going forward. – [motdotla](https://github.com/motdotla)
18
38
 
19
39
   
20
40
 
@@ -134,6 +154,14 @@ More examples
134
154
  World
135
155
  ```
136
156
 
157
+ </details>
158
+ * <details><summary>Cron ⏰</summary><br>
159
+
160
+ ```sh
161
+ # run every day at 8am
162
+ 0 8 * * * dotenvx run -- /path/to/myscript.sh
163
+ ```
164
+
137
165
  </details>
138
166
  * <details><summary>Frameworks ▲</summary><br>
139
167
 
@@ -329,6 +357,33 @@ More examples
329
357
  ```
330
358
 
331
359
  </details>
360
+ * <details><summary>`--quiet` flag</summary><br>
361
+
362
+ Use `--quiet` to suppress all output (except errors).
363
+
364
+ ```sh
365
+ $ echo "HELLO=production" > .env.production
366
+
367
+ $ dotenvx run --env-file=.env.production --quiet -- node index.js
368
+ Hello production
369
+ ```
370
+
371
+ </details>
372
+ * <details><summary>`--log-level` flag</summary><br>
373
+
374
+ Set `--log-level` to whatever you wish. For example, to supress warnings (risky), set log level to `error`:
375
+
376
+ ```sh
377
+ $ echo "HELLO=production" > .env.production
378
+
379
+ $ dotenvx run --env-file=.env.production --log-level=error -- node index.js
380
+ Hello production
381
+ ```
382
+
383
+ Available log levels are `error, warn, info, verbose, debug, silly`
384
+
385
+ </details>
386
+
332
387
 
333
388
  &nbsp;
334
389
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.10.5",
2
+ "version": "0.11.0",
3
3
  "name": "@dotenvx/dotenvx",
4
4
  "description": "a better dotenv–from the creator of `dotenv`",
5
5
  "author": "@motdotla",
@@ -30,7 +30,7 @@
30
30
  "clipboardy": "^2.3.0",
31
31
  "commander": "^11.1.0",
32
32
  "conf": "^10.2.0",
33
- "dotenv": "^16.3.1",
33
+ "dotenv": "^16.4.0",
34
34
  "execa": "^5.1.1",
35
35
  "ignore": "^5.3.0",
36
36
  "open": "^8.4.2",
@@ -4,7 +4,6 @@ const main = require('./../../lib/main')
4
4
  const logger = require('./../../shared/logger')
5
5
  const helpers = require('./../helpers')
6
6
  const createSpinner = require('./../../shared/createSpinner')
7
- const { AppendToIgnores } = require('./../ignores')
8
7
 
9
8
  const spinner = createSpinner('encrypting')
10
9
 
@@ -12,8 +11,6 @@ const spinner = createSpinner('encrypting')
12
11
  const ENCODING = 'utf8'
13
12
 
14
13
  async function encrypt () {
15
- new AppendToIgnores().run()
16
-
17
14
  spinner.start()
18
15
  await helpers.sleep(500) // better dx
19
16
 
@@ -2,13 +2,10 @@ const fs = require('fs')
2
2
  const logger = require('./../../shared/logger')
3
3
  const helpers = require('./../helpers')
4
4
  const main = require('./../../lib/main')
5
- const { AppendToIgnores } = require('./../ignores')
6
5
 
7
6
  const ENCODING = 'utf8'
8
7
 
9
8
  async function run () {
10
- new AppendToIgnores().run()
11
-
12
9
  const commandArgs = this.args
13
10
  logger.debug(`process command [${commandArgs.join(' ')}]`)
14
11
 
package/src/lib/main.js CHANGED
@@ -6,7 +6,21 @@ const config = function (options) {
6
6
  }
7
7
 
8
8
  const decrypt = function (encrypted, keyStr) {
9
- return dotenv.decrypt(encrypted, keyStr)
9
+ try {
10
+ return dotenv.decrypt(encrypted, keyStr)
11
+ } catch (e) {
12
+ switch (e.code) {
13
+ case 'DECRYPTION_FAILED':
14
+ // more helpful error when decryption fails
15
+ logger.error('[DECRYPTION_FAILED] Unable to decrypt .env.vault with DOTENV_KEY.')
16
+ logger.help('[DECRYPTION_FAILED] Run with debug flag [dotenvx run --debug -- yourcommand] or manually run [echo $DOTENV_KEY] to compare it to the one in .env.keys.')
17
+ logger.debug(`[DECRYPTION_FAILED] DOTENV_KEY is ${process.env.DOTENV_KEY}`)
18
+ process.exit(1)
19
+ break
20
+ default:
21
+ throw e
22
+ }
23
+ }
10
24
  }
11
25
 
12
26
  const configDotenv = function (options) {