@dotenvx/dotenvx 1.42.2 → 1.44.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 +17 -1
- package/package.json +1 -1
- package/src/cli/actions/decrypt.js +5 -5
- package/src/cli/actions/ext/genexample.js +2 -2
- package/src/cli/actions/ext/scan.js +3 -3
- package/src/cli/actions/get.js +4 -4
- package/src/cli/actions/run.js +8 -8
- package/src/lib/helpers/catchAndLog.js +1 -1
- package/src/lib/helpers/executeCommand.js +2 -2
- package/src/lib/main.d.ts +1 -5
- package/src/lib/main.js +8 -8
- package/src/shared/logger.js +14 -23
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,23 @@
|
|
|
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.
|
|
5
|
+
[Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.44.0...main)
|
|
6
|
+
|
|
7
|
+
## [1.44.0](https://github.com/dotenvx/dotenvx/compare/v1.43.0...v1.44.0)
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
* Add `armv7` support ([#593](https://github.com/dotenvx/dotenvx/pull/593))
|
|
12
|
+
|
|
13
|
+
## [1.43.0](https://github.com/dotenvx/dotenvx/compare/v1.42.2...v1.43.0)
|
|
14
|
+
|
|
15
|
+
### Removed
|
|
16
|
+
|
|
17
|
+
* Remove `errorv, errornocolor, blank` from logger options ([#584](https://github.com/dotenvx/dotenvx/pull/584))
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
* Replace instances of `console.error` with `logger.error` ([#584](https://github.com/dotenvx/dotenvx/pull/584))
|
|
6
22
|
|
|
7
23
|
## [1.42.2](https://github.com/dotenvx/dotenvx/compare/v1.42.1...v1.42.2)
|
|
8
24
|
|
package/package.json
CHANGED
|
@@ -22,9 +22,9 @@ function decrypt () {
|
|
|
22
22
|
for (const processedEnv of processedEnvs) {
|
|
23
23
|
if (processedEnv.error) {
|
|
24
24
|
errorCount += 1
|
|
25
|
-
|
|
25
|
+
logger.error(processedEnv.error.message)
|
|
26
26
|
if (processedEnv.error.help) {
|
|
27
|
-
|
|
27
|
+
logger.error(processedEnv.error.help)
|
|
28
28
|
}
|
|
29
29
|
} else {
|
|
30
30
|
console.log(processedEnv.envSrc)
|
|
@@ -51,12 +51,12 @@ function decrypt () {
|
|
|
51
51
|
errorCount += 1
|
|
52
52
|
|
|
53
53
|
if (processedEnv.error.code === 'MISSING_ENV_FILE') {
|
|
54
|
-
|
|
54
|
+
logger.error(processedEnv.error.message)
|
|
55
55
|
logger.help(`? add one with [echo "HELLO=World" > ${processedEnv.envFilepath}] and re-run [dotenvx decrypt]`)
|
|
56
56
|
} else {
|
|
57
|
-
|
|
57
|
+
logger.error(processedEnv.error.message)
|
|
58
58
|
if (processedEnv.error.help) {
|
|
59
|
-
|
|
59
|
+
logger.error(processedEnv.error.help)
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
} else if (processedEnv.changed) {
|
|
@@ -23,10 +23,10 @@ function genexample (directory) {
|
|
|
23
23
|
if (addedKeys.length > 0) {
|
|
24
24
|
logger.success(`updated .env.example (${addedKeys.length})`)
|
|
25
25
|
} else {
|
|
26
|
-
logger.
|
|
26
|
+
logger.info('no changes (.env.example)')
|
|
27
27
|
}
|
|
28
28
|
} catch (error) {
|
|
29
|
-
|
|
29
|
+
logger.error(error.message)
|
|
30
30
|
if (error.help) {
|
|
31
31
|
logger.help(error.help)
|
|
32
32
|
}
|
|
@@ -11,7 +11,7 @@ function scan () {
|
|
|
11
11
|
// redirect stderr to stdout to capture and ignore it
|
|
12
12
|
childProcess.execSync('gitleaks version', { stdio: ['ignore', 'pipe', 'ignore'] })
|
|
13
13
|
} catch (error) {
|
|
14
|
-
|
|
14
|
+
logger.error('gitleaks: command not found')
|
|
15
15
|
logger.help('? install gitleaks: [brew install gitleaks]')
|
|
16
16
|
logger.help('? other install options: [https://github.com/gitleaks/gitleaks]')
|
|
17
17
|
process.exit(1)
|
|
@@ -21,10 +21,10 @@ function scan () {
|
|
|
21
21
|
let output = ''
|
|
22
22
|
try {
|
|
23
23
|
output = childProcess.execSync('gitleaks detect --no-banner --verbose 2>&1').toString() // gitleaks sends exit code 1 but puts data on stdout for failures, so we catch later and resurface the stdout
|
|
24
|
-
logger.
|
|
24
|
+
logger.info(chomp(output))
|
|
25
25
|
} catch (error) {
|
|
26
26
|
if (error.stdout) {
|
|
27
|
-
|
|
27
|
+
logger.error(chomp(error.stdout.toString()))
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
process.exit(1)
|
package/src/cli/actions/get.js
CHANGED
|
@@ -33,9 +33,9 @@ function get (key) {
|
|
|
33
33
|
continue // ignore error
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
logger.error(error.message)
|
|
37
37
|
if (error.help) {
|
|
38
|
-
|
|
38
|
+
logger.error(error.help)
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -73,9 +73,9 @@ function get (key) {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
} catch (error) {
|
|
76
|
-
|
|
76
|
+
logger.error(error.message)
|
|
77
77
|
if (error.help) {
|
|
78
|
-
|
|
78
|
+
logger.error(error.help)
|
|
79
79
|
}
|
|
80
80
|
process.exit(1)
|
|
81
81
|
}
|
package/src/cli/actions/run.js
CHANGED
|
@@ -20,10 +20,10 @@ async function run () {
|
|
|
20
20
|
const hasSeparator = process.argv.indexOf('--') !== -1
|
|
21
21
|
|
|
22
22
|
if (hasSeparator) {
|
|
23
|
-
|
|
23
|
+
logger.error('missing command after [dotenvx run --]. try [dotenvx run -- yourcommand]')
|
|
24
24
|
} else {
|
|
25
25
|
const realExample = options.envFile[0] || '.env'
|
|
26
|
-
|
|
26
|
+
logger.error(`ambiguous command due to missing '--' separator. try [dotenvx run -f ${realExample} -- yourcommand]`)
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
process.exit(1)
|
|
@@ -71,15 +71,15 @@ async function run () {
|
|
|
71
71
|
|
|
72
72
|
if (error.code === 'MISSING_ENV_FILE') {
|
|
73
73
|
if (!options.convention) { // do not output error for conventions (too noisy)
|
|
74
|
-
|
|
74
|
+
logger.error(error.message)
|
|
75
75
|
if (error.help) {
|
|
76
|
-
|
|
76
|
+
logger.error(`${error.help} and re-run [dotenvx run -- ${commandArgs.join(' ')}]`)
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
} else {
|
|
80
|
-
|
|
80
|
+
logger.error(error.message)
|
|
81
81
|
if (error.help) {
|
|
82
|
-
|
|
82
|
+
logger.error(error.help)
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
}
|
|
@@ -111,9 +111,9 @@ async function run () {
|
|
|
111
111
|
|
|
112
112
|
logger.successv(msg)
|
|
113
113
|
} catch (error) {
|
|
114
|
-
|
|
114
|
+
logger.error(error.message)
|
|
115
115
|
if (error.help) {
|
|
116
|
-
|
|
116
|
+
logger.error(error.help)
|
|
117
117
|
}
|
|
118
118
|
process.exit(1)
|
|
119
119
|
}
|
|
@@ -97,9 +97,9 @@ async function executeCommand (commandArgs, env) {
|
|
|
97
97
|
// no color on these errors as they can be standard errors for things like jest exiting with exitCode 1 for a single failed test.
|
|
98
98
|
if (!['SIGINT', 'SIGTERM'].includes(signalSent || error.signal)) {
|
|
99
99
|
if (error.code === 'ENOENT') {
|
|
100
|
-
|
|
100
|
+
logger.error(`Unknown command: ${error.command}`)
|
|
101
101
|
} else {
|
|
102
|
-
|
|
102
|
+
logger.error(error.message)
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
|
package/src/lib/main.d.ts
CHANGED
|
@@ -139,17 +139,13 @@ export interface DotenvConfigOptions {
|
|
|
139
139
|
|
|
140
140
|
logLevel?:
|
|
141
141
|
| 'error'
|
|
142
|
-
| 'errorv'
|
|
143
|
-
| 'errornocolor'
|
|
144
142
|
| 'warn'
|
|
145
143
|
| 'success'
|
|
146
144
|
| 'successv'
|
|
147
145
|
| 'info'
|
|
148
146
|
| 'help'
|
|
149
|
-
| 'http'
|
|
150
147
|
| 'verbose'
|
|
151
|
-
| 'debug'
|
|
152
|
-
| 'blank';
|
|
148
|
+
| 'debug';
|
|
153
149
|
}
|
|
154
150
|
|
|
155
151
|
export interface DotenvConfigOutput {
|
package/src/lib/main.js
CHANGED
|
@@ -80,15 +80,15 @@ const config = function (options = {}) {
|
|
|
80
80
|
|
|
81
81
|
if (error.code === 'MISSING_ENV_FILE') {
|
|
82
82
|
if (!options.convention) { // do not output error for conventions (too noisy)
|
|
83
|
-
|
|
83
|
+
logger.error(error.message)
|
|
84
84
|
if (error.help) {
|
|
85
|
-
|
|
85
|
+
logger.error(error.help)
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
} else {
|
|
89
|
-
|
|
89
|
+
logger.error(error.message)
|
|
90
90
|
if (error.help) {
|
|
91
|
-
|
|
91
|
+
logger.error(error.help)
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
}
|
|
@@ -153,9 +153,9 @@ const parse = function (src, options = {}) {
|
|
|
153
153
|
|
|
154
154
|
// display any errors
|
|
155
155
|
for (const error of errors) {
|
|
156
|
-
|
|
156
|
+
logger.error(error.message)
|
|
157
157
|
if (error.help) {
|
|
158
|
-
|
|
158
|
+
logger.error(error.help)
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
|
|
@@ -251,9 +251,9 @@ const get = function (key, options = {}) {
|
|
|
251
251
|
|
|
252
252
|
if (options.strict) throw error // throw immediately if strict
|
|
253
253
|
|
|
254
|
-
|
|
254
|
+
logger.error(error.message)
|
|
255
255
|
if (error.help) {
|
|
256
|
-
|
|
256
|
+
logger.error(error.help)
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
259
|
|
package/src/shared/logger.js
CHANGED
|
@@ -3,14 +3,11 @@ const { getColor, bold } = require('./colors')
|
|
|
3
3
|
|
|
4
4
|
const levels = {
|
|
5
5
|
error: 0,
|
|
6
|
-
errorv: 0,
|
|
7
|
-
errornocolor: 0,
|
|
8
6
|
warn: 1,
|
|
9
7
|
success: 2,
|
|
10
8
|
successv: 2,
|
|
11
9
|
info: 2,
|
|
12
10
|
help: 2,
|
|
13
|
-
blank: 2,
|
|
14
11
|
verbose: 4,
|
|
15
12
|
debug: 5,
|
|
16
13
|
silly: 6
|
|
@@ -26,7 +23,12 @@ const debug = getColor('plum')
|
|
|
26
23
|
|
|
27
24
|
let currentLevel = levels.info // default log level
|
|
28
25
|
|
|
29
|
-
function
|
|
26
|
+
function stderr (level, message) {
|
|
27
|
+
const formattedMessage = formatMessage(level, message)
|
|
28
|
+
console.error(formattedMessage)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function stdout (level, message) {
|
|
30
32
|
if (levels[level] === undefined) {
|
|
31
33
|
throw new Error(`MISSING_LOG_LEVEL: '${level}'. implement in logger.`)
|
|
32
34
|
}
|
|
@@ -44,10 +46,6 @@ function formatMessage (level, message) {
|
|
|
44
46
|
// errors
|
|
45
47
|
case 'error':
|
|
46
48
|
return error(formattedMessage)
|
|
47
|
-
case 'errorv':
|
|
48
|
-
return error(`[dotenvx@${packageJson.version}] ${formattedMessage}`)
|
|
49
|
-
case 'errornocolor':
|
|
50
|
-
return formattedMessage
|
|
51
49
|
// warns
|
|
52
50
|
case 'warn':
|
|
53
51
|
return warn(formattedMessage)
|
|
@@ -68,9 +66,6 @@ function formatMessage (level, message) {
|
|
|
68
66
|
// debug
|
|
69
67
|
case 'debug':
|
|
70
68
|
return debug(formattedMessage)
|
|
71
|
-
// blank
|
|
72
|
-
case 'blank': // custom
|
|
73
|
-
return formattedMessage
|
|
74
69
|
}
|
|
75
70
|
}
|
|
76
71
|
|
|
@@ -79,24 +74,20 @@ const logger = {
|
|
|
79
74
|
level: 'info',
|
|
80
75
|
|
|
81
76
|
// errors
|
|
82
|
-
error: (msg) =>
|
|
83
|
-
errorv: (msg) => log('errorv', msg),
|
|
84
|
-
errornocolor: (msg) => log('errornocolor', msg),
|
|
77
|
+
error: (msg) => stderr('error', msg),
|
|
85
78
|
// warns
|
|
86
|
-
warn: (msg) =>
|
|
79
|
+
warn: (msg) => stdout('warn', msg),
|
|
87
80
|
// success
|
|
88
|
-
success: (msg) =>
|
|
89
|
-
successv: (msg) =>
|
|
81
|
+
success: (msg) => stdout('success', msg),
|
|
82
|
+
successv: (msg) => stdout('successv', msg),
|
|
90
83
|
// info
|
|
91
|
-
info: (msg) =>
|
|
84
|
+
info: (msg) => stdout('info', msg),
|
|
92
85
|
// help
|
|
93
|
-
help: (msg) =>
|
|
86
|
+
help: (msg) => stdout('help', msg),
|
|
94
87
|
// verbose
|
|
95
|
-
verbose: (msg) =>
|
|
88
|
+
verbose: (msg) => stdout('verbose', msg),
|
|
96
89
|
// debug
|
|
97
|
-
debug: (msg) =>
|
|
98
|
-
// blank
|
|
99
|
-
blank: (msg) => log('blank', msg),
|
|
90
|
+
debug: (msg) => stdout('debug', msg),
|
|
100
91
|
setLevel: (level) => {
|
|
101
92
|
if (levels[level] !== undefined) {
|
|
102
93
|
currentLevel = levels[level]
|