Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 17 additions & 22 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,14 @@ const version = packageJson.version

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

// Get a random tip from the tips array
Expand Down Expand Up @@ -128,15 +123,15 @@ function _parseVault (options) {
}

function _warn (message) {
console.error(`[dotenv@${version}][WARN] ${message}`)
console.error(`⚠ ${message} · dotenv@${version}`)
}

function _debug (message) {
console.log(`[dotenv@${version}][DEBUG] ${message}`)
console.log(`┆ ${message} · dotenv@${version}`)
}

function _log (message) {
console.log(`[dotenv@${version}] ${message}`)
console.log(`◇ ${message} · dotenv@${version}`)
}
Comment on lines 125 to 135

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new log format uses Unicode glyphs (, , ) and removes the explicit [WARN]/[DEBUG] tokens. That can break downstream tooling that greps for the previous stable prefixes (or for WARN/DEBUG), and Unicode output is still a real-world compatibility issue in some CI/log pipelines and Windows terminals.

Suggestion

Consider preserving a machine-parsable severity token (and/or providing an opt-in/opt-out) while keeping the new UX. For example:

function _warn (message) {
  console.error(`⚠ [WARN] ${message} · dotenv@${version}`)
}
function _debug (message) {
  console.log(`┆ [DEBUG] ${message} · dotenv@${version}`)
}
function _log (message) {
  console.log(`◇ ${message} · dotenv@${version}`)
}

Alternatively, gate the glyphs behind an env var like DOTENV_LOG_FORMAT=pretty|classic and default to classic in non-TTY contexts.

Reply with "@CharlieHelps yes please" if you'd like me to add a commit with this suggestion.


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

if (debug || !quiet) {
_log('Loading env from encrypted .env.vault')
_log('loading env from encrypted .env.vault')
}

const parsed = DotenvModule._parseVault(options)
Expand Down Expand Up @@ -259,7 +254,7 @@ function configDotenv (options) {
encoding = options.encoding
} else {
if (debug) {
_debug('No encoding is specified. UTF-8 is used by default')
_debug('no encoding is specified (UTF-8 is used by default)')
}
}

Expand Down Expand Up @@ -287,7 +282,7 @@ function configDotenv (options) {
DotenvModule.populate(parsedAll, parsed, options)
} catch (e) {
if (debug) {
_debug(`Failed to load ${path} ${e.message}`)
_debug(`failed to load ${path} ${e.message}`)
}
lastError = e
}
Expand All @@ -308,13 +303,13 @@ function configDotenv (options) {
shortPaths.push(relative)
} catch (e) {
if (debug) {
_debug(`Failed to load ${filePath} ${e.message}`)
_debug(`failed to load ${filePath} ${e.message}`)
}
lastError = e
}
}

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

if (lastError) {
Expand All @@ -335,7 +330,7 @@ function config (options) {

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

return DotenvModule.configDotenv(options)
}
Expand Down
42 changes: 16 additions & 26 deletions tests/test-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,19 +329,14 @@ t.test('displays random tips from the tips array', ct => {
// Test that the tip contains one of our expected tip messages
let foundExpectedTip = false
const expectedTips = [
'🔐 encrypt with Dotenvx: https://dotenvx.com',
'🔐 prevent committing .env to code: https://dotenvx.com/precommit',
'🔐 prevent building .env in docker: https://dotenvx.com/prebuild',
'🤖 agentic secret storage: https://dotenvx.com/as2',
'⚡️ secrets for agents: https://dotenvx.com/as2',
'🛡️ auth for agents: https://vestauth.com',
'🛠️ run anywhere with `dotenvx run -- yourcommand`',
'⚙️ specify custom .env file path with { path: \'/custom/path/.env\' }',
'⚙️ enable debug logging with { debug: true }',
'⚙️ override existing env vars with { override: true }',
'⚙️ suppress all logs with { quiet: true }',
'⚙️ write to custom object with { processEnv: myObject }',
'⚙️ load multiple .env files with { path: [\'.env.local\', \'.env\'] }'
'◈ encrypted .env [www.dotenvx.com]',
'◈ secrets for agents [www.dotenvx.com]',
'⌁ auth for agents [www.vestauth.com]',
'⌘ custom filepath { path: \'/custom/path/.env\' }',
'⌘ enable debugging { debug: true }',
'⌘ override existing { override: true }',
'⌘ suppress logs { quiet: true }',
'⌘ multiple files { path: [\'.env.local\', \'.env\'] }'
]

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

for (const call of logStub.getCalls()) {
Expand Down
Loading