@dotenvx/dotenvx
Advanced tools
Comparing version 1.13.2 to 1.13.3
@@ -5,4 +5,10 @@ # Changelog | ||
## [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.13.2...main) | ||
## [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.13.3...main) | ||
## 1.13.3 | ||
### Changed | ||
* exit code 1 when `decrypt` fails in any way ([#374](https://github.com/dotenvx/dotenvx/pull/374)) | ||
## 1.13.2 | ||
@@ -9,0 +15,0 @@ |
{ | ||
"version": "1.13.2", | ||
"version": "1.13.3", | ||
"name": "@dotenvx/dotenvx", | ||
@@ -4,0 +4,0 @@ "description": "a better dotenv–from the creator of `dotenv`", |
157
README.md
@@ -1277,3 +1277,75 @@ [![dotenvx](https://dotenvx.com/better-banner.png)](https://dotenvx.com) | ||
</details> | ||
* <details><summary>`ls`</summary><br> | ||
Print all `.env` files in a tree structure. | ||
```sh | ||
$ touch .env | ||
$ touch .env.production | ||
$ mkdir -p apps/backend | ||
$ touch apps/backend/.env | ||
$ dotenvx ls | ||
├─ .env.production | ||
├─ .env | ||
└─ apps | ||
└─ backend | ||
└─ .env | ||
``` | ||
</details> | ||
* <details><summary>`ls directory`</summary><br> | ||
Print all `.env` files inside a specified path to a directory. | ||
```sh | ||
$ touch .env | ||
$ touch .env.production | ||
$ mkdir -p apps/backend | ||
$ touch apps/backend/.env | ||
$ dotenvx ls apps/backend | ||
└─ .env | ||
``` | ||
</details> | ||
* <details><summary>`ls -f`</summary><br> | ||
Glob `.env` filenames matching a wildcard. | ||
```sh | ||
$ touch .env | ||
$ touch .env.production | ||
$ mkdir -p apps/backend | ||
$ touch apps/backend/.env | ||
$ touch apps/backend/.env.prod | ||
$ dotenvx ls -f **/.env.prod* | ||
├─ .env.production | ||
└─ apps | ||
└─ backend | ||
└─ .env.prod | ||
``` | ||
</details> | ||
* <details><summary>`ls -ef`</summary><br> | ||
Glob `.env` filenames excluding a wildcard. | ||
```sh | ||
$ touch .env | ||
$ touch .env.production | ||
$ mkdir -p apps/backend | ||
$ touch apps/backend/.env | ||
$ touch apps/backend/.env.prod | ||
$ dotenvx ls -ef '**/.env.prod*' | ||
├─ .env | ||
└─ apps | ||
└─ backend | ||
└─ .env | ||
``` | ||
</details> | ||
* <details><summary>`help`</summary><br> | ||
@@ -1285,3 +1357,3 @@ | ||
$ dotenvx help | ||
Usage: @dotenvx/dotenvx [options] [command] | ||
Usage: dotenvx [options] [command] [command] [args...] | ||
@@ -1291,18 +1363,20 @@ a better dotenv–from the creator of `dotenv` | ||
Options: | ||
-l, --log-level <level> set log level (default: "info") | ||
-q, --quiet sets log level to error | ||
-v, --verbose sets log level to verbose | ||
-d, --debug sets log level to debug | ||
-V, --version output the version number | ||
-h, --help display help for command | ||
-l, --log-level <level> set log level (default: "info") | ||
-q, --quiet sets log level to error | ||
-v, --verbose sets log level to verbose | ||
-d, --debug sets log level to debug | ||
-V, --version output the version number | ||
-h, --help display help for command | ||
Commands: | ||
run [options] inject env at runtime [dotenvx run -- yourcommand] | ||
get [options] [key] return a single environment variable | ||
set [options] <KEY> <value> set a single environment variable | ||
encrypt [options] convert .env file(s) to encrypted .env file(s) | ||
decrypt [options] convert encrypted .env file(s) to plain .env file(s) | ||
pro 🏆 pro | ||
ext [command] [args...] 🔌 extensions | ||
help [command] display help for command | ||
run [options] inject env at runtime [dotenvx run -- yourcommand] | ||
get [options] [key] return a single environment variable | ||
set [options] <KEY> <value> set a single environment variable | ||
encrypt [options] convert .env file(s) to encrypted .env file(s) | ||
decrypt [options] convert encrypted .env file(s) to plain .env file(s) | ||
ls [options] [directory] print all .env files in a tree structure | ||
Advanced: | ||
pro 🏆 pro | ||
ext 🔌 extensions | ||
``` | ||
@@ -1357,55 +1431,2 @@ | ||
* <details><summary>`ext ls`</summary><br> | ||
Print all `.env` files in a tree structure. | ||
```sh | ||
$ touch .env | ||
$ touch .env.production | ||
$ mkdir -p apps/backend | ||
$ touch apps/backend/.env | ||
$ dotenvx ext ls | ||
├─ .env.production | ||
├─ .env | ||
└─ apps | ||
└─ backend | ||
└─ .env | ||
``` | ||
</details> | ||
* <details><summary>`ext ls directory`</summary><br> | ||
Print all `.env` files inside a specified path to a directory. | ||
```sh | ||
$ touch .env | ||
$ touch .env.production | ||
$ mkdir -p apps/backend | ||
$ touch apps/backend/.env | ||
$ dotenvx ext ls apps/backend | ||
└─ .env | ||
``` | ||
</details> | ||
* <details><summary>`ext ls -f`</summary><br> | ||
Glob `.env` filenames matching a wildcard. | ||
```sh | ||
$ touch .env | ||
$ touch .env.production | ||
$ mkdir -p apps/backend | ||
$ touch apps/backend/.env | ||
$ touch apps/backend/.env.prod | ||
$ dotenvx ext ls -f **/.env.prod* | ||
├─ .env.production | ||
└─ apps | ||
└─ backend | ||
└─ .env.prod | ||
``` | ||
</details> | ||
* <details><summary>`ext genexample`</summary><br> | ||
@@ -1412,0 +1433,0 @@ |
@@ -12,2 +12,4 @@ const fs = require('fs') | ||
let errorCount = 0 | ||
// stdout - should not have a try so that exit codes can surface to stdout | ||
@@ -20,5 +22,15 @@ if (options.stdout) { | ||
for (const processedEnvFile of processedEnvFiles) { | ||
process.stdout.write(processedEnvFile.envSrc) | ||
if (processedEnvFile.error) { | ||
errorCount += 1 | ||
console.error(processedEnvFile.error.message) | ||
} else { | ||
process.stdout.write(processedEnvFile.envSrc) | ||
} | ||
} | ||
process.exit(0) // exit early | ||
if (errorCount > 0) { | ||
process.exit(1) | ||
} else { | ||
process.exit(0) // exit early | ||
} | ||
} else { | ||
@@ -34,8 +46,11 @@ try { | ||
logger.verbose(`decrypting ${processedEnvFile.envFilepath} (${processedEnvFile.filepath})`) | ||
if (processedEnvFile.error) { | ||
errorCount += 1 | ||
if (processedEnvFile.error.code === 'MISSING_ENV_FILE') { | ||
logger.warn(processedEnvFile.error.message) | ||
logger.error(processedEnvFile.error.message) | ||
logger.help(`? add one with [echo "HELLO=World" > ${processedEnvFile.envFilepath}] and re-run [dotenvx decrypt]`) | ||
} else { | ||
logger.warn(processedEnvFile.error.message) | ||
logger.error(processedEnvFile.error.message) | ||
} | ||
@@ -58,2 +73,6 @@ } else if (processedEnvFile.changed) { | ||
} | ||
if (errorCount > 0) { | ||
process.exit(1) | ||
} | ||
} catch (error) { | ||
@@ -60,0 +79,0 @@ logger.error(error.message) |
194327
3316
1620