@dotenvx/dotenvx 1.13.2 → 1.13.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/CHANGELOG.md +7 -1
- package/README.md +89 -68
- package/package.json +1 -1
- package/src/cli/actions/decrypt.js +23 -4
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
-
## [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.13.
|
|
5
|
+
## [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.13.3...main)
|
|
6
|
+
|
|
7
|
+
## 1.13.3
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
* exit code 1 when `decrypt` fails in any way ([#374](https://github.com/dotenvx/dotenvx/pull/374))
|
|
6
12
|
|
|
7
13
|
## 1.13.2
|
|
8
14
|
|
package/README.md
CHANGED
|
@@ -1273,6 +1273,78 @@ More examples
|
|
|
1273
1273
|
$ dotenvx decrypt --stdout > somefile.txt
|
|
1274
1274
|
```
|
|
1275
1275
|
|
|
1276
|
+
</details>
|
|
1277
|
+
* <details><summary>`ls`</summary><br>
|
|
1278
|
+
|
|
1279
|
+
Print all `.env` files in a tree structure.
|
|
1280
|
+
|
|
1281
|
+
```sh
|
|
1282
|
+
$ touch .env
|
|
1283
|
+
$ touch .env.production
|
|
1284
|
+
$ mkdir -p apps/backend
|
|
1285
|
+
$ touch apps/backend/.env
|
|
1286
|
+
|
|
1287
|
+
$ dotenvx ls
|
|
1288
|
+
├─ .env.production
|
|
1289
|
+
├─ .env
|
|
1290
|
+
└─ apps
|
|
1291
|
+
└─ backend
|
|
1292
|
+
└─ .env
|
|
1293
|
+
```
|
|
1294
|
+
|
|
1295
|
+
</details>
|
|
1296
|
+
* <details><summary>`ls directory`</summary><br>
|
|
1297
|
+
|
|
1298
|
+
Print all `.env` files inside a specified path to a directory.
|
|
1299
|
+
|
|
1300
|
+
```sh
|
|
1301
|
+
$ touch .env
|
|
1302
|
+
$ touch .env.production
|
|
1303
|
+
$ mkdir -p apps/backend
|
|
1304
|
+
$ touch apps/backend/.env
|
|
1305
|
+
|
|
1306
|
+
$ dotenvx ls apps/backend
|
|
1307
|
+
└─ .env
|
|
1308
|
+
```
|
|
1309
|
+
|
|
1310
|
+
</details>
|
|
1311
|
+
* <details><summary>`ls -f`</summary><br>
|
|
1312
|
+
|
|
1313
|
+
Glob `.env` filenames matching a wildcard.
|
|
1314
|
+
|
|
1315
|
+
```sh
|
|
1316
|
+
$ touch .env
|
|
1317
|
+
$ touch .env.production
|
|
1318
|
+
$ mkdir -p apps/backend
|
|
1319
|
+
$ touch apps/backend/.env
|
|
1320
|
+
$ touch apps/backend/.env.prod
|
|
1321
|
+
|
|
1322
|
+
$ dotenvx ls -f **/.env.prod*
|
|
1323
|
+
├─ .env.production
|
|
1324
|
+
└─ apps
|
|
1325
|
+
└─ backend
|
|
1326
|
+
└─ .env.prod
|
|
1327
|
+
```
|
|
1328
|
+
|
|
1329
|
+
</details>
|
|
1330
|
+
* <details><summary>`ls -ef`</summary><br>
|
|
1331
|
+
|
|
1332
|
+
Glob `.env` filenames excluding a wildcard.
|
|
1333
|
+
|
|
1334
|
+
```sh
|
|
1335
|
+
$ touch .env
|
|
1336
|
+
$ touch .env.production
|
|
1337
|
+
$ mkdir -p apps/backend
|
|
1338
|
+
$ touch apps/backend/.env
|
|
1339
|
+
$ touch apps/backend/.env.prod
|
|
1340
|
+
|
|
1341
|
+
$ dotenvx ls -ef '**/.env.prod*'
|
|
1342
|
+
├─ .env
|
|
1343
|
+
└─ apps
|
|
1344
|
+
└─ backend
|
|
1345
|
+
└─ .env
|
|
1346
|
+
```
|
|
1347
|
+
|
|
1276
1348
|
</details>
|
|
1277
1349
|
|
|
1278
1350
|
* <details><summary>`help`</summary><br>
|
|
@@ -1281,27 +1353,29 @@ More examples
|
|
|
1281
1353
|
|
|
1282
1354
|
```sh
|
|
1283
1355
|
$ dotenvx help
|
|
1284
|
-
Usage:
|
|
1356
|
+
Usage: dotenvx [options] [command] [command] [args...]
|
|
1285
1357
|
|
|
1286
1358
|
a better dotenv–from the creator of `dotenv`
|
|
1287
1359
|
|
|
1288
1360
|
Options:
|
|
1289
|
-
-l, --log-level <level>
|
|
1290
|
-
-q, --quiet
|
|
1291
|
-
-v, --verbose
|
|
1292
|
-
-d, --debug
|
|
1293
|
-
-V, --version
|
|
1294
|
-
-h, --help
|
|
1361
|
+
-l, --log-level <level> set log level (default: "info")
|
|
1362
|
+
-q, --quiet sets log level to error
|
|
1363
|
+
-v, --verbose sets log level to verbose
|
|
1364
|
+
-d, --debug sets log level to debug
|
|
1365
|
+
-V, --version output the version number
|
|
1366
|
+
-h, --help display help for command
|
|
1295
1367
|
|
|
1296
1368
|
Commands:
|
|
1297
|
-
run [options]
|
|
1298
|
-
get [options] [key]
|
|
1299
|
-
set [options] <KEY> <value>
|
|
1300
|
-
encrypt [options]
|
|
1301
|
-
decrypt [options]
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1369
|
+
run [options] inject env at runtime [dotenvx run -- yourcommand]
|
|
1370
|
+
get [options] [key] return a single environment variable
|
|
1371
|
+
set [options] <KEY> <value> set a single environment variable
|
|
1372
|
+
encrypt [options] convert .env file(s) to encrypted .env file(s)
|
|
1373
|
+
decrypt [options] convert encrypted .env file(s) to plain .env file(s)
|
|
1374
|
+
ls [options] [directory] print all .env files in a tree structure
|
|
1375
|
+
|
|
1376
|
+
Advanced:
|
|
1377
|
+
pro 🏆 pro
|
|
1378
|
+
ext 🔌 extensions
|
|
1305
1379
|
```
|
|
1306
1380
|
|
|
1307
1381
|
You can get more detailed help per command with `dotenvx help COMMAND`.
|
|
@@ -1351,59 +1425,6 @@ More examples
|
|
|
1351
1425
|
|
|
1352
1426
|
### Extensions 🔌
|
|
1353
1427
|
|
|
1354
|
-
* <details><summary>`ext ls`</summary><br>
|
|
1355
|
-
|
|
1356
|
-
Print all `.env` files in a tree structure.
|
|
1357
|
-
|
|
1358
|
-
```sh
|
|
1359
|
-
$ touch .env
|
|
1360
|
-
$ touch .env.production
|
|
1361
|
-
$ mkdir -p apps/backend
|
|
1362
|
-
$ touch apps/backend/.env
|
|
1363
|
-
|
|
1364
|
-
$ dotenvx ext ls
|
|
1365
|
-
├─ .env.production
|
|
1366
|
-
├─ .env
|
|
1367
|
-
└─ apps
|
|
1368
|
-
└─ backend
|
|
1369
|
-
└─ .env
|
|
1370
|
-
```
|
|
1371
|
-
|
|
1372
|
-
</details>
|
|
1373
|
-
* <details><summary>`ext ls directory`</summary><br>
|
|
1374
|
-
|
|
1375
|
-
Print all `.env` files inside a specified path to a directory.
|
|
1376
|
-
|
|
1377
|
-
```sh
|
|
1378
|
-
$ touch .env
|
|
1379
|
-
$ touch .env.production
|
|
1380
|
-
$ mkdir -p apps/backend
|
|
1381
|
-
$ touch apps/backend/.env
|
|
1382
|
-
|
|
1383
|
-
$ dotenvx ext ls apps/backend
|
|
1384
|
-
└─ .env
|
|
1385
|
-
```
|
|
1386
|
-
|
|
1387
|
-
</details>
|
|
1388
|
-
* <details><summary>`ext ls -f`</summary><br>
|
|
1389
|
-
|
|
1390
|
-
Glob `.env` filenames matching a wildcard.
|
|
1391
|
-
|
|
1392
|
-
```sh
|
|
1393
|
-
$ touch .env
|
|
1394
|
-
$ touch .env.production
|
|
1395
|
-
$ mkdir -p apps/backend
|
|
1396
|
-
$ touch apps/backend/.env
|
|
1397
|
-
$ touch apps/backend/.env.prod
|
|
1398
|
-
|
|
1399
|
-
$ dotenvx ext ls -f **/.env.prod*
|
|
1400
|
-
├─ .env.production
|
|
1401
|
-
└─ apps
|
|
1402
|
-
└─ backend
|
|
1403
|
-
└─ .env.prod
|
|
1404
|
-
```
|
|
1405
|
-
|
|
1406
|
-
</details>
|
|
1407
1428
|
* <details><summary>`ext genexample`</summary><br>
|
|
1408
1429
|
|
|
1409
1430
|
In one command, generate a `.env.example` file from your current `.env` file contents.
|
package/package.json
CHANGED
|
@@ -9,6 +9,8 @@ function decrypt () {
|
|
|
9
9
|
const options = this.opts()
|
|
10
10
|
logger.debug(`options: ${JSON.stringify(options)}`)
|
|
11
11
|
|
|
12
|
+
let errorCount = 0
|
|
13
|
+
|
|
12
14
|
// stdout - should not have a try so that exit codes can surface to stdout
|
|
13
15
|
if (options.stdout) {
|
|
14
16
|
const {
|
|
@@ -16,9 +18,19 @@ function decrypt () {
|
|
|
16
18
|
} = main.decrypt(options.envFile, options.key, options.excludeKey)
|
|
17
19
|
|
|
18
20
|
for (const processedEnvFile of processedEnvFiles) {
|
|
19
|
-
|
|
21
|
+
if (processedEnvFile.error) {
|
|
22
|
+
errorCount += 1
|
|
23
|
+
console.error(processedEnvFile.error.message)
|
|
24
|
+
} else {
|
|
25
|
+
process.stdout.write(processedEnvFile.envSrc)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (errorCount > 0) {
|
|
30
|
+
process.exit(1)
|
|
31
|
+
} else {
|
|
32
|
+
process.exit(0) // exit early
|
|
20
33
|
}
|
|
21
|
-
process.exit(0) // exit early
|
|
22
34
|
} else {
|
|
23
35
|
try {
|
|
24
36
|
const {
|
|
@@ -29,12 +41,15 @@ function decrypt () {
|
|
|
29
41
|
|
|
30
42
|
for (const processedEnvFile of processedEnvFiles) {
|
|
31
43
|
logger.verbose(`decrypting ${processedEnvFile.envFilepath} (${processedEnvFile.filepath})`)
|
|
44
|
+
|
|
32
45
|
if (processedEnvFile.error) {
|
|
46
|
+
errorCount += 1
|
|
47
|
+
|
|
33
48
|
if (processedEnvFile.error.code === 'MISSING_ENV_FILE') {
|
|
34
|
-
logger.
|
|
49
|
+
logger.error(processedEnvFile.error.message)
|
|
35
50
|
logger.help(`? add one with [echo "HELLO=World" > ${processedEnvFile.envFilepath}] and re-run [dotenvx decrypt]`)
|
|
36
51
|
} else {
|
|
37
|
-
logger.
|
|
52
|
+
logger.error(processedEnvFile.error.message)
|
|
38
53
|
}
|
|
39
54
|
} else if (processedEnvFile.changed) {
|
|
40
55
|
fs.writeFileSync(processedEnvFile.filepath, processedEnvFile.envSrc, ENCODING)
|
|
@@ -52,6 +67,10 @@ function decrypt () {
|
|
|
52
67
|
} else {
|
|
53
68
|
// do nothing - scenario when no .env files found
|
|
54
69
|
}
|
|
70
|
+
|
|
71
|
+
if (errorCount > 0) {
|
|
72
|
+
process.exit(1)
|
|
73
|
+
}
|
|
55
74
|
} catch (error) {
|
|
56
75
|
logger.error(error.message)
|
|
57
76
|
if (error.help) {
|