@dotenvx/dotenvx
Advanced tools
Comparing version 1.14.2 to 1.15.0
@@ -5,4 +5,10 @@ # Changelog | ||
## [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.14.2...main) | ||
## [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.15.0...main) | ||
## 1.15.0 | ||
### Added | ||
* add `--format=shell` option for `keypair` ([#389](https://github.com/dotenvx/dotenvx/pull/389)) | ||
## 1.14.2 | ||
@@ -9,0 +15,0 @@ |
{ | ||
"version": "1.14.2", | ||
"version": "1.15.0", | ||
"name": "@dotenvx/dotenvx", | ||
@@ -4,0 +4,0 @@ "description": "a better dotenv–from the creator of `dotenv`", |
@@ -1060,3 +1060,5 @@ [![dotenvx](https://dotenvx.com/better-banner.png)](https://dotenvx.com) | ||
``` | ||
$ env $(dotenvx get format --shell) your-command | ||
$ echo "console.log('Hello ' + process.env.KEY + ' ' + process.env.HELLO)" > index.js | ||
$ env $(dotenvx get --format=shell) node index.js | ||
Hello value World | ||
``` | ||
@@ -1067,3 +1069,6 @@ | ||
``` | ||
$ export $(dotenvx get format --shell) your-command | ||
$ echo "console.log('Hello ' + process.env.KEY + ' ' + process.env.HELLO)" > index.js | ||
$ export $(dotenvx get --format=shell) | ||
$ node index.js | ||
Hello value World | ||
``` | ||
@@ -1307,3 +1312,3 @@ | ||
Print specific key for `.env` file. | ||
Print specific keypair for `.env` file. | ||
@@ -1319,2 +1324,15 @@ ```sh | ||
</details> | ||
* <details><summary>`keypair --format shell`</summary><br> | ||
Print a shell formatted response of keypair(s). | ||
```sh | ||
$ echo "HELLO=World" > .env | ||
$ dotenx encrypt | ||
$ dotenvx keypair --format shell | ||
DOTENV_PUBLIC_KEY=<publicKey> DOTENV_PRIVATE_KEY=<privateKey> | ||
``` | ||
</details> | ||
* <details><summary>`ls`</summary><br> | ||
@@ -1321,0 +1339,0 @@ |
@@ -16,8 +16,20 @@ const { logger } = require('./../../shared/logger') | ||
if (typeof results === 'object' && results !== null) { | ||
let space = 0 | ||
if (options.prettyPrint) { | ||
space = 2 | ||
// inline shell format - env $(dotenvx keypair --format=shell) your-command | ||
if (options.format === 'shell') { | ||
let inline = '' | ||
for (const [key, value] of Object.entries(results)) { | ||
inline += `${key}=${value || ''} ` | ||
} | ||
inline = inline.trim() | ||
console.log(inline) | ||
// json format | ||
} else { | ||
let space = 0 | ||
if (options.prettyPrint) { | ||
space = 2 | ||
} | ||
console.log(JSON.stringify(results, null, space)) | ||
} | ||
console.log(JSON.stringify(results, null, space)) | ||
} else { | ||
@@ -24,0 +36,0 @@ if (results === undefined) { |
@@ -125,2 +125,3 @@ #!/usr/bin/env node | ||
.option('-pp, --pretty-print', 'pretty print output') | ||
.option('--format <type>', 'format of the output (json, shell)', 'json') | ||
.action(keypairAction) | ||
@@ -127,0 +128,0 @@ |
200671
3451
1677