@dotenvx/dotenvx 1.14.2 → 1.15.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/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.14.2...main)
5
+ ## [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.15.0...main)
6
+
7
+ ## 1.15.0
8
+
9
+ ### Added
10
+
11
+ * add `--format=shell` option for `keypair` ([#389](https://github.com/dotenvx/dotenvx/pull/389))
6
12
 
7
13
  ## 1.14.2
8
14
 
package/README.md CHANGED
@@ -1057,13 +1057,18 @@ More examples
1057
1057
  This can be useful when combined with `env` on the command line.
1058
1058
 
1059
1059
  ```
1060
- $ env $(dotenvx get format --shell) your-command
1060
+ $ echo "console.log('Hello ' + process.env.KEY + ' ' + process.env.HELLO)" > index.js
1061
+ $ env $(dotenvx get --format=shell) node index.js
1062
+ Hello value World
1061
1063
  ```
1062
1064
 
1063
1065
  or with `export`.
1064
1066
 
1065
1067
  ```
1066
- $ export $(dotenvx get format --shell) your-command
1068
+ $ echo "console.log('Hello ' + process.env.KEY + ' ' + process.env.HELLO)" > index.js
1069
+ $ export $(dotenvx get --format=shell)
1070
+ $ node index.js
1071
+ Hello value World
1067
1072
  ```
1068
1073
 
1069
1074
  </details>
@@ -1302,7 +1307,7 @@ More examples
1302
1307
  </details>
1303
1308
  * <details><summary>`keypair DOTENV_PRIVATE_KEY`</summary><br>
1304
1309
 
1305
- Print specific key for `.env` file.
1310
+ Print specific keypair for `.env` file.
1306
1311
 
1307
1312
  ```sh
1308
1313
  $ echo "HELLO=World" > .env
@@ -1312,6 +1317,19 @@ More examples
1312
1317
  <privateKey>
1313
1318
  ```
1314
1319
 
1320
+ </details>
1321
+ * <details><summary>`keypair --format shell`</summary><br>
1322
+
1323
+ Print a shell formatted response of keypair(s).
1324
+
1325
+ ```sh
1326
+ $ echo "HELLO=World" > .env
1327
+ $ dotenx encrypt
1328
+
1329
+ $ dotenvx keypair --format shell
1330
+ DOTENV_PUBLIC_KEY=<publicKey> DOTENV_PRIVATE_KEY=<privateKey>
1331
+ ```
1332
+
1315
1333
  </details>
1316
1334
  * <details><summary>`ls`</summary><br>
1317
1335
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.14.2",
2
+ "version": "1.15.0",
3
3
  "name": "@dotenvx/dotenvx",
4
4
  "description": "a better dotenv–from the creator of `dotenv`",
5
5
  "author": "@motdotla",
@@ -13,12 +13,24 @@ function keypair (key) {
13
13
  const results = main.keypair(options.envFile, key)
14
14
 
15
15
  if (typeof results === 'object' && results !== null) {
16
- let space = 0
17
- if (options.prettyPrint) {
18
- space = 2
19
- }
16
+ // inline shell format - env $(dotenvx keypair --format=shell) your-command
17
+ if (options.format === 'shell') {
18
+ let inline = ''
19
+ for (const [key, value] of Object.entries(results)) {
20
+ inline += `${key}=${value || ''} `
21
+ }
22
+ inline = inline.trim()
23
+
24
+ console.log(inline)
25
+ // json format
26
+ } else {
27
+ let space = 0
28
+ if (options.prettyPrint) {
29
+ space = 2
30
+ }
20
31
 
21
- console.log(JSON.stringify(results, null, space))
32
+ console.log(JSON.stringify(results, null, space))
33
+ }
22
34
  } else {
23
35
  if (results === undefined) {
24
36
  console.log('')
@@ -122,6 +122,7 @@ program.command('keypair')
122
122
  .argument('[key]', 'environment variable key name')
123
123
  .option('-f, --env-file <paths...>', 'path(s) to your env file(s)')
124
124
  .option('-pp, --pretty-print', 'pretty print output')
125
+ .option('--format <type>', 'format of the output (json, shell)', 'json')
125
126
  .action(keypairAction)
126
127
 
127
128
  // dotenvx ls