Skip to content

Commit d179cd9

Browse files
authored
Merge pull request #1003 from motdotla/log-ux
bring log ux closer to `dotenvx`'s
2 parents 093b8c2 + c1f682a commit d179cd9

2 files changed

Lines changed: 33 additions & 48 deletions

File tree

lib/main.js

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,14 @@ const version = packageJson.version
88

99
// Array of tips to display randomly
1010
const TIPS = [
11-
'🔐 encrypt with Dotenvx: https://dotenvx.com',
12-
'🔐 prevent committing .env to code: https://dotenvx.com/precommit',
13-
'🔐 prevent building .env in docker: https://dotenvx.com/prebuild',
14-
'🤖 agentic secret storage: https://dotenvx.com/as2',
15-
'⚡️ secrets for agents: https://dotenvx.com/as2',
16-
'🛡️ auth for agents: https://vestauth.com',
17-
'🛠️ run anywhere with `dotenvx run -- yourcommand`',
18-
'⚙️ specify custom .env file path with { path: \'/custom/path/.env\' }',
19-
'⚙️ enable debug logging with { debug: true }',
20-
'⚙️ override existing env vars with { override: true }',
21-
'⚙️ suppress all logs with { quiet: true }',
22-
'⚙️ write to custom object with { processEnv: myObject }',
23-
'⚙️ load multiple .env files with { path: [\'.env.local\', \'.env\'] }'
11+
'◈ encrypted .env [www.dotenvx.com]',
12+
'◈ secrets for agents [www.dotenvx.com]',
13+
'⌁ auth for agents [www.vestauth.com]',
14+
'⌘ custom filepath { path: \'/custom/path/.env\' }',
15+
'⌘ enable debugging { debug: true }',
16+
'⌘ override existing { override: true }',
17+
'⌘ suppress logs { quiet: true }',
18+
'⌘ multiple files { path: [\'.env.local\', \'.env\'] }'
2419
]
2520

2621
// Get a random tip from the tips array
@@ -128,15 +123,15 @@ function _parseVault (options) {
128123
}
129124

130125
function _warn (message) {
131-
console.error(`[dotenv@${version}][WARN] ${message}`)
126+
console.error(`${message} · dotenv@${version}`)
132127
}
133128

134129
function _debug (message) {
135-
console.log(`[dotenv@${version}][DEBUG] ${message}`)
130+
console.log(`${message} · dotenv@${version}`)
136131
}
137132

138133
function _log (message) {
139-
console.log(`[dotenv@${version}] ${message}`)
134+
console.log(`${message} · dotenv@${version}`)
140135
}
141136

142137
function _dotenvKey (options) {
@@ -230,7 +225,7 @@ function _configVault (options) {
230225
const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || (options && options.quiet))
231226

232227
if (debug || !quiet) {
233-
_log('Loading env from encrypted .env.vault')
228+
_log('loading env from encrypted .env.vault')
234229
}
235230

236231
const parsed = DotenvModule._parseVault(options)
@@ -259,7 +254,7 @@ function configDotenv (options) {
259254
encoding = options.encoding
260255
} else {
261256
if (debug) {
262-
_debug('No encoding is specified. UTF-8 is used by default')
257+
_debug('no encoding is specified (UTF-8 is used by default)')
263258
}
264259
}
265260

@@ -287,7 +282,7 @@ function configDotenv (options) {
287282
DotenvModule.populate(parsedAll, parsed, options)
288283
} catch (e) {
289284
if (debug) {
290-
_debug(`Failed to load ${path} ${e.message}`)
285+
_debug(`failed to load ${path} ${e.message}`)
291286
}
292287
lastError = e
293288
}
@@ -308,13 +303,13 @@ function configDotenv (options) {
308303
shortPaths.push(relative)
309304
} catch (e) {
310305
if (debug) {
311-
_debug(`Failed to load ${filePath} ${e.message}`)
306+
_debug(`failed to load ${filePath} ${e.message}`)
312307
}
313308
lastError = e
314309
}
315310
}
316311

317-
_log(`injecting env (${keysCount}) from ${shortPaths.join(',')} ${dim(`-- tip: ${_getRandomTip()}`)}`)
312+
_log(`injecting env (${keysCount}) from ${shortPaths.join(',')} ${dim(`// tip: ${_getRandomTip()}`)}`)
318313
}
319314

320315
if (lastError) {
@@ -335,7 +330,7 @@ function config (options) {
335330

336331
// dotenvKey exists but .env.vault file does not exist
337332
if (!vaultPath) {
338-
_warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`)
333+
_warn(`you set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}`)
339334

340335
return DotenvModule.configDotenv(options)
341336
}

tests/test-config.js

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -329,19 +329,14 @@ t.test('displays random tips from the tips array', ct => {
329329
// Test that the tip contains one of our expected tip messages
330330
let foundExpectedTip = false
331331
const expectedTips = [
332-
'🔐 encrypt with Dotenvx: https://dotenvx.com',
333-
'🔐 prevent committing .env to code: https://dotenvx.com/precommit',
334-
'🔐 prevent building .env in docker: https://dotenvx.com/prebuild',
335-
'🤖 agentic secret storage: https://dotenvx.com/as2',
336-
'⚡️ secrets for agents: https://dotenvx.com/as2',
337-
'🛡️ auth for agents: https://vestauth.com',
338-
'🛠️ run anywhere with `dotenvx run -- yourcommand`',
339-
'⚙️ specify custom .env file path with { path: \'/custom/path/.env\' }',
340-
'⚙️ enable debug logging with { debug: true }',
341-
'⚙️ override existing env vars with { override: true }',
342-
'⚙️ suppress all logs with { quiet: true }',
343-
'⚙️ write to custom object with { processEnv: myObject }',
344-
'⚙️ load multiple .env files with { path: [\'.env.local\', \'.env\'] }'
332+
'◈ encrypted .env [www.dotenvx.com]',
333+
'◈ secrets for agents [www.dotenvx.com]',
334+
'⌁ auth for agents [www.vestauth.com]',
335+
'⌘ custom filepath { path: \'/custom/path/.env\' }',
336+
'⌘ enable debugging { debug: true }',
337+
'⌘ override existing { override: true }',
338+
'⌘ suppress logs { quiet: true }',
339+
'⌘ multiple files { path: [\'.env.local\', \'.env\'] }'
345340
]
346341

347342
for (const call of logStub.getCalls()) {
@@ -390,19 +385,14 @@ t.test('displays random tips from the tips array with fallback for isTTY false',
390385
// Test that the tip contains one of our expected tip messages
391386
let foundExpectedTip = false
392387
const expectedTips = [
393-
'🔐 encrypt with Dotenvx: https://dotenvx.com',
394-
'🔐 prevent committing .env to code: https://dotenvx.com/precommit',
395-
'🔐 prevent building .env in docker: https://dotenvx.com/prebuild',
396-
'🤖 agentic secret storage: https://dotenvx.com/as2',
397-
'⚡️ secrets for agents: https://dotenvx.com/as2',
398-
'🛡️ auth for agents: https://vestauth.com',
399-
'🛠️ run anywhere with `dotenvx run -- yourcommand`',
400-
'⚙️ specify custom .env file path with { path: \'/custom/path/.env\' }',
401-
'⚙️ enable debug logging with { debug: true }',
402-
'⚙️ override existing env vars with { override: true }',
403-
'⚙️ suppress all logs with { quiet: true }',
404-
'⚙️ write to custom object with { processEnv: myObject }',
405-
'⚙️ load multiple .env files with { path: [\'.env.local\', \'.env\'] }'
388+
'◈ encrypted .env [www.dotenvx.com]',
389+
'◈ secrets for agents [www.dotenvx.com]',
390+
'⌁ auth for agents [www.vestauth.com]',
391+
'⌘ custom filepath { path: \'/custom/path/.env\' }',
392+
'⌘ enable debugging { debug: true }',
393+
'⌘ override existing { override: true }',
394+
'⌘ suppress logs { quiet: true }',
395+
'⌘ multiple files { path: [\'.env.local\', \'.env\'] }'
406396
]
407397

408398
for (const call of logStub.getCalls()) {

0 commit comments

Comments
 (0)