@dotenvx/dotenvx 2.10.0 → 2.11.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 +11 -1
- package/package.json +1 -1
- package/src/cli/actions/update.js +15 -0
- package/src/cli/dotenvx.js +7 -0
- package/src/lib/helpers/colorDepth.js +7 -1
- package/src/lib/main.d.ts +0 -1
- package/src/shared/colors.js +4 -4
- package/src/shared/logger.js +31 -35
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,17 @@
|
|
|
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/v2.
|
|
5
|
+
[Unreleased](https://github.com/dotenvx/dotenvx/compare/v2.11.0...main)
|
|
6
|
+
|
|
7
|
+
## [2.11.0](https://github.com/dotenvx/dotenvx/compare/v2.10.0...v2.11.0) (2026-07-15)
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
* Add convenience method `dotenvx update` ([#897](https://github.com/dotenvx/dotenvx/pull/897))
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
* BREAKING: Send informational messages like `injected env` to stderr instead of stdout. This makes it more reliable to do things like piping output to a file without needing `--quiet`. ([#898](https://github.com/dotenvx/dotenvx/pull/898))
|
|
6
16
|
|
|
7
17
|
## [2.10.0](https://github.com/dotenvx/dotenvx/compare/v2.9.0...v2.10.0) (2026-07-15)
|
|
8
18
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const childProcess = require('child_process')
|
|
2
|
+
|
|
3
|
+
const INSTALL_COMMAND = 'curl -sfS https://dotenvx.sh | sh'
|
|
4
|
+
|
|
5
|
+
function update () {
|
|
6
|
+
if (process.pkg) {
|
|
7
|
+
childProcess.execSync(INSTALL_COMMAND, { stdio: 'inherit' })
|
|
8
|
+
return
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
console.log('global: npm install -g @dotenvx/dotenvx@latest')
|
|
12
|
+
console.log('local: npm install @dotenvx/dotenvx@latest --save')
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
module.exports = update
|
package/src/cli/dotenvx.js
CHANGED
|
@@ -227,6 +227,13 @@ program.command('doctor', { hidden: true })
|
|
|
227
227
|
return require('./actions/doctor').apply(this, args)
|
|
228
228
|
})
|
|
229
229
|
|
|
230
|
+
// dotenvx update
|
|
231
|
+
program.command('update')
|
|
232
|
+
.description('update dotenvx')
|
|
233
|
+
.action(function (...args) {
|
|
234
|
+
return require('./actions/update').apply(this, args)
|
|
235
|
+
})
|
|
236
|
+
|
|
230
237
|
// dotenvx login (compatibility alias for dotenvx armor login)
|
|
231
238
|
program.command('login', { hidden: true })
|
|
232
239
|
.description('log in to move keys off-device, share with your team, and audit access')
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
const { WriteStream } = require('tty')
|
|
2
2
|
|
|
3
|
-
const getColorDepth = () => {
|
|
3
|
+
const getColorDepth = (stream) => {
|
|
4
|
+
if (stream && !stream.isTTY) return 1
|
|
5
|
+
|
|
4
6
|
try {
|
|
7
|
+
if (stream && typeof stream.getColorDepth === 'function') {
|
|
8
|
+
return stream.getColorDepth()
|
|
9
|
+
}
|
|
10
|
+
|
|
5
11
|
return WriteStream.prototype.getColorDepth()
|
|
6
12
|
} catch (error) {
|
|
7
13
|
const term = process.env.TERM
|
package/src/lib/main.d.ts
CHANGED
package/src/shared/colors.js
CHANGED
|
@@ -33,8 +33,8 @@ const colorsTrueColor = new Map([
|
|
|
33
33
|
['red', [140, 35, 50]] // #8C2332 brighter garnet
|
|
34
34
|
])
|
|
35
35
|
|
|
36
|
-
function getColor (color) {
|
|
37
|
-
const colorDepth = depth.getColorDepth()
|
|
36
|
+
function getColor (color, stream) {
|
|
37
|
+
const colorDepth = depth.getColorDepth(stream)
|
|
38
38
|
if (!colors256.has(color)) {
|
|
39
39
|
throw new Errors({ color }).invalidColor()
|
|
40
40
|
}
|
|
@@ -53,8 +53,8 @@ function getColor (color) {
|
|
|
53
53
|
return (message) => message
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
function bold (message) {
|
|
57
|
-
if (depth.getColorDepth() >= 4) {
|
|
56
|
+
function bold (message, stream) {
|
|
57
|
+
if (depth.getColorDepth(stream) >= 4) {
|
|
58
58
|
return `\x1b[1m${message}\x1b[22m`
|
|
59
59
|
}
|
|
60
60
|
|
package/src/shared/logger.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const packageJson = require('../lib/helpers/packageJson')
|
|
2
1
|
const Errors = require('../lib/helpers/errors')
|
|
3
2
|
const { getColor, bold } = require('./colors')
|
|
4
3
|
|
|
@@ -7,7 +6,6 @@ const levels = {
|
|
|
7
6
|
infoerror: 0,
|
|
8
7
|
warn: 1,
|
|
9
8
|
success: 2,
|
|
10
|
-
successv: 2,
|
|
11
9
|
info: 2,
|
|
12
10
|
help: 2,
|
|
13
11
|
verbose: 4,
|
|
@@ -15,23 +13,26 @@ const levels = {
|
|
|
15
13
|
silly: 6
|
|
16
14
|
}
|
|
17
15
|
|
|
18
|
-
const error = (m) => bold(getColor('red')(`☠ ${m}`))
|
|
19
|
-
const infoerror = getColor('gray') // actually an error
|
|
20
|
-
const warn = (m) => getColor('orangered')(`⚠ ${m}`)
|
|
21
|
-
const success = getColor('amber')
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const debug = (m) => getColor('plum')(`┆ ${m}`)
|
|
16
|
+
const error = (m, stream) => bold(getColor('red', stream)(`☠ ${m}`), stream)
|
|
17
|
+
const infoerror = (m, stream) => getColor('gray', stream)(m) // actually an error
|
|
18
|
+
const warn = (m, stream) => getColor('orangered', stream)(`⚠ ${m}`)
|
|
19
|
+
const success = (m, stream) => getColor('amber', stream)(m)
|
|
20
|
+
const info = (m, stream) => getColor('gray', stream)(m)
|
|
21
|
+
const help = (m, stream) => getColor('dodgerblue', stream)(m)
|
|
22
|
+
const verbose = (m, stream) => getColor('plum', stream)(`┆ ${m}`)
|
|
23
|
+
const debug = (m, stream) => getColor('plum', stream)(`┆ ${m}`)
|
|
27
24
|
|
|
28
25
|
let currentLevel = levels.info // default log level
|
|
29
|
-
let currentName = 'dotenvx' // default logger name
|
|
30
|
-
let currentVersion = packageJson.version // default logger version
|
|
31
26
|
|
|
32
27
|
function stderr (level, message) {
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
if (levels[level] === undefined) {
|
|
29
|
+
throw new Errors({ level }).missingLogLevel()
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (levels[level] <= currentLevel) {
|
|
33
|
+
const formattedMessage = formatMessage(level, message, process.stderr)
|
|
34
|
+
console.error(formattedMessage)
|
|
35
|
+
}
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
function stdout (level, message) {
|
|
@@ -40,40 +41,38 @@ function stdout (level, message) {
|
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
if (levels[level] <= currentLevel) {
|
|
43
|
-
const formattedMessage = formatMessage(level, message)
|
|
44
|
+
const formattedMessage = formatMessage(level, message, process.stdout)
|
|
44
45
|
console.log(formattedMessage)
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
function formatMessage (level, message) {
|
|
49
|
+
function formatMessage (level, message, stream) {
|
|
49
50
|
const formattedMessage = typeof message === 'object' ? JSON.stringify(message) : message
|
|
50
51
|
|
|
51
52
|
switch (level.toLowerCase()) {
|
|
52
53
|
// errors
|
|
53
54
|
case 'error':
|
|
54
|
-
return error(formattedMessage)
|
|
55
|
+
return error(formattedMessage, stream)
|
|
55
56
|
case 'infoerror':
|
|
56
|
-
return infoerror(formattedMessage)
|
|
57
|
+
return infoerror(formattedMessage, stream)
|
|
57
58
|
// warns
|
|
58
59
|
case 'warn':
|
|
59
|
-
return warn(formattedMessage)
|
|
60
|
+
return warn(formattedMessage, stream)
|
|
60
61
|
// successes
|
|
61
62
|
case 'success':
|
|
62
|
-
return success(formattedMessage)
|
|
63
|
-
case 'successv': // success with 'version'
|
|
64
|
-
return successv(`${formattedMessage} · ${currentName}@${currentVersion}`)
|
|
63
|
+
return success(formattedMessage, stream)
|
|
65
64
|
// info
|
|
66
65
|
case 'info':
|
|
67
|
-
return info(formattedMessage)
|
|
66
|
+
return info(formattedMessage, stream)
|
|
68
67
|
// help
|
|
69
68
|
case 'help':
|
|
70
|
-
return help(formattedMessage)
|
|
69
|
+
return help(formattedMessage, stream)
|
|
71
70
|
// verbose
|
|
72
71
|
case 'verbose':
|
|
73
|
-
return verbose(formattedMessage)
|
|
72
|
+
return verbose(formattedMessage, stream)
|
|
74
73
|
// debug
|
|
75
74
|
case 'debug':
|
|
76
|
-
return debug(formattedMessage)
|
|
75
|
+
return debug(formattedMessage, stream)
|
|
77
76
|
}
|
|
78
77
|
}
|
|
79
78
|
|
|
@@ -85,18 +84,17 @@ const logger = {
|
|
|
85
84
|
error: (msg) => stderr('error', msg),
|
|
86
85
|
infoerror: (msg) => stderr('infoerror', msg),
|
|
87
86
|
// warns
|
|
88
|
-
warn: (msg) =>
|
|
87
|
+
warn: (msg) => stderr('warn', msg),
|
|
89
88
|
// success
|
|
90
|
-
success: (msg) =>
|
|
91
|
-
successv: (msg) => stdout('successv', msg),
|
|
89
|
+
success: (msg) => stderr('success', msg),
|
|
92
90
|
// info
|
|
93
91
|
info: (msg) => stdout('info', msg),
|
|
94
92
|
// help
|
|
95
|
-
help: (msg) =>
|
|
93
|
+
help: (msg) => stderr('help', msg),
|
|
96
94
|
// verbose
|
|
97
|
-
verbose: (msg) =>
|
|
95
|
+
verbose: (msg) => stderr('verbose', msg),
|
|
98
96
|
// debug
|
|
99
|
-
debug: (msg) =>
|
|
97
|
+
debug: (msg) => stderr('debug', msg),
|
|
100
98
|
setLevel: (level) => {
|
|
101
99
|
if (levels[level] !== undefined) {
|
|
102
100
|
currentLevel = levels[level]
|
|
@@ -104,11 +102,9 @@ const logger = {
|
|
|
104
102
|
}
|
|
105
103
|
},
|
|
106
104
|
setName: (name) => {
|
|
107
|
-
currentName = name
|
|
108
105
|
logger.name = name
|
|
109
106
|
},
|
|
110
107
|
setVersion: (version) => {
|
|
111
|
-
currentVersion = version
|
|
112
108
|
logger.version = version
|
|
113
109
|
}
|
|
114
110
|
}
|