@dotenvx/dotenvx 1.12.1 → 1.13.1

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,22 +2,42 @@
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.12.1...main)
5
+ ## [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.13.1...main)
6
+
7
+ ## 1.13.1
8
+
9
+ ### Added
10
+
11
+ * expose `logger` and `setLogLevel` to `lib/main.js` - `const = { logger, setLogLevel } = require('@dotenvx/dotenvx')` ([#368](https://github.com/dotenvx/dotenvx/pull/368))
12
+
13
+ ## 1.13.0
14
+
15
+ ### Changed
16
+
17
+ * move `ls` to core commands ([#367](https://github.com/dotenvx/dotenvx/pull/367))
6
18
 
7
19
  ## 1.12.1
8
20
 
21
+ ### Changed
22
+
9
23
  * return without quotations for `dotenvx get --format shell` ([#366](https://github.com/dotenvx/dotenvx/pull/366))
10
24
 
11
25
  ## 1.12.0
12
26
 
27
+ ### Added
28
+
13
29
  * add `dotenvx get --format shell` option ([#363](https://github.com/dotenvx/dotenvx/pull/363))
14
30
 
15
31
  ## 1.11.5
16
32
 
33
+ ### Changed
34
+
17
35
  * revert `tinyexec` for `execa` - to support usage in bun
18
36
 
19
37
  ## 1.11.4
20
38
 
39
+ ### Changed
40
+
21
41
  * bump `tinyexec` and add postrelease-bunx check ([#362](https://github.com/dotenvx/dotenvx/pull/362))
22
42
 
23
43
  ## 1.11.3
package/README.md CHANGED
@@ -1047,11 +1047,11 @@ More examples
1047
1047
  Return a shell formatted response of all key/value pairs in a `.env` file.
1048
1048
 
1049
1049
  ```sh
1050
- $ echo "HELLO=World\n" > .env
1051
- $ echo "KEY=value\n" >> .env
1050
+ $ echo "HELLO=World" > .env
1051
+ $ echo "KEY=value" >> .env
1052
1052
 
1053
1053
  $ dotenvx get --format shell
1054
- HELLO="World" KEY="value"
1054
+ HELLO=World KEY=value
1055
1055
  ```
1056
1056
 
1057
1057
  This can be useful when combined with `env` on the command line.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.12.1",
2
+ "version": "1.13.1",
3
3
  "name": "@dotenvx/dotenvx",
4
4
  "description": "a better dotenv–from the creator of `dotenv`",
5
5
  "author": "@motdotla",
@@ -1,9 +1,9 @@
1
1
  const treeify = require('object-treeify')
2
2
 
3
- const { logger } = require('./../../../shared/logger')
3
+ const { logger } = require('./../../shared/logger')
4
4
 
5
- const main = require('./../../../lib/main')
6
- const ArrayToTree = require('./../../../lib/helpers/arrayToTree')
5
+ const main = require('./../../lib/main')
6
+ const ArrayToTree = require('./../../lib/helpers/arrayToTree')
7
7
 
8
8
  function ls (directory) {
9
9
  // debug args
@@ -2,6 +2,7 @@ const { Command } = require('commander')
2
2
 
3
3
  const examples = require('./../examples')
4
4
  const executeExtension = require('../../lib/helpers/executeExtension')
5
+ const removeDynamicHelpSection = require('../../lib/helpers/removeDynamicHelpSection')
5
6
 
6
7
  const ext = new Command('ext')
7
8
 
@@ -26,7 +27,7 @@ ext.command('ls')
26
27
  .argument('[directory]', 'directory to list .env files from', '.')
27
28
  .option('-f, --env-file <filenames...>', 'path(s) to your env file(s)', '.env*')
28
29
  .option('-ef, --exclude-env-file <excludeFilenames...>', 'path(s) to exclude from your env file(s) (default: none)')
29
- .action(require('./../actions/ext/ls'))
30
+ .action(require('./../actions/ls'))
30
31
 
31
32
  // dotenvx ext genexample
32
33
  ext.command('genexample')
@@ -59,4 +60,14 @@ ext.command('scan')
59
60
  .description('scan for leaked secrets')
60
61
  .action(require('./../actions/ext/scan'))
61
62
 
63
+ // overide helpInformation to hide dynamic commands
64
+ ext.helpInformation = function () {
65
+ const originalHelp = Command.prototype.helpInformation.call(this)
66
+ const lines = originalHelp.split('\n')
67
+
68
+ removeDynamicHelpSection(lines)
69
+
70
+ return lines.join('\n')
71
+ }
72
+
62
73
  module.exports = ext
@@ -8,6 +8,7 @@ const { setLogLevel, logger } = require('../shared/logger')
8
8
  const examples = require('./examples')
9
9
  const packageJson = require('./../lib/helpers/packageJson')
10
10
  const executeDynamic = require('./../lib/helpers/executeDynamic')
11
+ const removeDynamicHelpSection = require('./../lib/helpers/removeDynamicHelpSection')
11
12
 
12
13
  // for use with run
13
14
  const envs = []
@@ -30,8 +31,7 @@ program
30
31
  setLogLevel(options)
31
32
  })
32
33
 
33
- program.addHelpText('after', ' pro 🏆 pro\n')
34
-
34
+ // for dynamic loading of dotenvx-pro, etc
35
35
  program
36
36
  .argument('[command]', 'dynamic command')
37
37
  .argument('[args...]', 'dynamic command arguments')
@@ -42,7 +42,7 @@ program
42
42
 
43
43
  // cli
44
44
  program
45
- .name(packageJson.name)
45
+ .name('dotenvx')
46
46
  .description(packageJson.description)
47
47
  .version(packageJson.version)
48
48
  .allowUnknownOption()
@@ -115,6 +115,15 @@ program.command('decrypt')
115
115
  .option('--stdout', 'send to stdout')
116
116
  .action(decryptAction)
117
117
 
118
+ // dotenvx ls
119
+ const lsAction = require('./actions/ls')
120
+ program.command('ls')
121
+ .description('print all .env files in a tree structure')
122
+ .argument('[directory]', 'directory to list .env files from', '.')
123
+ .option('-f, --env-file <filenames...>', 'path(s) to your env file(s)', '.env*')
124
+ .option('-ef, --exclude-env-file <excludeFilenames...>', 'path(s) to exclude from your env file(s) (default: none)')
125
+ .action(lsAction)
126
+
118
127
  // dotenvx help
119
128
  program.command('help [command]')
120
129
  .description('display help for command')
@@ -131,6 +140,12 @@ program.command('help [command]')
131
140
  }
132
141
  })
133
142
 
143
+ // dotenvx pro
144
+ program.addHelpText('after', ' ')
145
+ program.addHelpText('after', 'Advanced: ')
146
+ program.addHelpText('after', ' pro 🏆 pro')
147
+ program.addHelpText('after', ' ext 🔌 extensions')
148
+
134
149
  // dotenvx ext
135
150
  program.addCommand(require('./commands/ext'))
136
151
 
@@ -158,13 +173,19 @@ program.command('precommit')
158
173
  precommitAction.apply(this, args)
159
174
  })
160
175
 
161
- // overide helpInformation to hide DEPRECATED commands
176
+ // overide helpInformation to hide DEPRECATED and 'ext' commands
162
177
  program.helpInformation = function () {
163
178
  const originalHelp = Command.prototype.helpInformation.call(this)
164
179
  const lines = originalHelp.split('\n')
165
180
 
181
+ removeDynamicHelpSection(lines)
182
+
166
183
  // Filter out the hidden command from the help output
167
- const filteredLines = lines.filter(line => !line.includes('DEPRECATED') && !line.includes('help [command]'))
184
+ const filteredLines = lines.filter(line =>
185
+ !line.includes('DEPRECATED') &&
186
+ !line.includes('help [command]') &&
187
+ !line.includes('🔌 extensions')
188
+ )
168
189
 
169
190
  return filteredLines.join('\n')
170
191
  }
@@ -5,7 +5,7 @@ const { logger } = require('../../shared/logger')
5
5
  function executeExtension (ext, command, rawArgs) {
6
6
  if (!command) {
7
7
  ext.outputHelp()
8
- process.exit(1)
8
+ process.exit(0)
9
9
  return
10
10
  }
11
11
 
@@ -0,0 +1,21 @@
1
+ // Remove Arguments section from help text. example:
2
+ // Arguments:
3
+ // command dynamic command
4
+ // args dynamic command arguments
5
+
6
+ function removeDynamicHelpSection (lines) {
7
+ let argumentsHelpIndex
8
+ for (let i = 0; i < lines.length; i++) {
9
+ if (lines[i] === 'Arguments:') {
10
+ argumentsHelpIndex = i
11
+ break
12
+ }
13
+ }
14
+ if (argumentsHelpIndex) {
15
+ lines.splice(argumentsHelpIndex, 4) // remove Arguments and the following 3 lines
16
+ }
17
+
18
+ return lines
19
+ }
20
+
21
+ module.exports = removeDynamicHelpSection
package/src/lib/main.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // @ts-check
2
2
  const path = require('path')
3
- const { logger } = require('./../shared/logger')
3
+ const { setLogLevel, logger } = require('./../shared/logger')
4
4
  const dotenv = require('dotenv')
5
5
 
6
6
  // services
@@ -15,7 +15,6 @@ const Genexample = require('./services/genexample')
15
15
  // helpers
16
16
  const conventions = require('./helpers/conventions')
17
17
  const dotenvOptionPaths = require('./helpers/dotenvOptionPaths')
18
- const { setLogLevel } = require('../shared/logger')
19
18
 
20
19
  // proxies to dotenv
21
20
 
@@ -219,5 +218,8 @@ module.exports = {
219
218
  ls,
220
219
  get,
221
220
  set,
222
- genexample
221
+ genexample,
222
+ // expose for libs depending on @dotenvx/dotenvx
223
+ setLogLevel,
224
+ logger
223
225
  }