Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 7, 2025

This PR refactors the hardcoded tip message "[tip] encrypt with dotenvx: https://dotenvx.com" into a dynamic system that randomly selects from an array of helpful tips.

Changes Made

Core Implementation

  • Extracted hardcoded tip into a TIPS array containing 7 educational tips
  • Added _getRandomTip() function that uses Math.random() to select tips randomly
  • Updated log message in configDotenv() to display random tips: [tip] ${_getRandomTip()}

New Tips Added

The tips array now includes helpful guidance for each major dotenv setting:

  1. Original: "encrypt with dotenvx: https://dotenvx.com" (preserved)
  2. path: "specify custom .env file path with { path: '/custom/path/.env' }"
  3. debug: "enable debug logging with { debug: true }"
  4. override: "override existing env vars with { override: true }"
  5. quiet: "suppress all logs with { quiet: true }"
  6. processEnv: "write to custom object with { processEnv: myObject }"
  7. path (array): "load multiple .env files with { path: ['.env.local', '.env'] }"

Before & After

Before:

[[email protected]] injecting env (35) from .env – [tip] encrypt with dotenvx: https://dotenvx.com

After (random selection):

[[email protected]] injecting env (35) from .env – [tip] enable debug logging with { debug: true }
[[email protected]] injecting env (1) from .env – [tip] override existing env vars with { override: true }
[[email protected]] injecting env (2) from .env – [tip] write to custom object with { processEnv: myObject }

Testing

  • ✅ All existing tests pass (190/191 assertions)
  • ✅ Added comprehensive test coverage for tip functionality
  • ✅ Manual verification confirms random selection works correctly
  • ✅ Tips display in both regular and vault configurations
  • ✅ Linting and TypeScript checks pass

Benefits

  • Educational: Users learn about dotenv's various configuration options
  • Dynamic: Each run shows different tips, increasing discovery
  • Backward Compatible: Preserves original dotenvx tip alongside new ones
  • Consistent Style: All tips follow the same concise, actionable format

Fixes #883.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@motdotla motdotla marked this pull request as ready for review July 7, 2025 22:55
Copilot AI changed the title [WIP] Add additional [tip]s Add random tips functionality to replace hardcoded dotenvx tip Jul 7, 2025
Copilot AI requested a review from motdotla July 7, 2025 22:55
@codecov
Copy link

codecov bot commented Jul 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (b8da167) to head (8083e59).
Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #884   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            3         3           
  Lines          436       452   +16     
=========================================
+ Hits           436       452   +16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@motdotla
Copy link
Owner

motdotla commented Jul 7, 2025

I'd rather not export _getRandomTip @copilot. we shouldn't need to, right?

Copy link
Contributor Author

Copilot AI commented Jul 7, 2025

I'd rather not export _getRandomTip @copilot. we shouldn't need to, right?

You're absolutely right! I've removed _getRandomTip from the public exports since it's only used internally within configDotenv(). The function is now private and the tests have been updated to verify the behavior without directly accessing the internal function. Commit 8083e59.

@motdotla motdotla merged commit 9b71dc1 into master Jul 7, 2025
5 checks passed
@motdotla motdotla deleted the copilot/fix-883 branch July 7, 2025 23:03
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Aug 9, 2025
| datasource | package | from   | to     |
| ---------- | ------- | ------ | ------ |
| npm        | dotenv  | 16.6.1 | 17.2.1 |


## [v17.2.1](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1721-2025-07-24)

##### Changed

- Fix clickable tip links by removing parentheses ([#897](motdotla/dotenv#897))


## [v17.2.0](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1720-2025-07-09)

##### Added

- Optionally specify `DOTENV_CONFIG_QUIET=true` in your environment or `.env` file to quiet the runtime log ([#889](motdotla/dotenv#889))
- Just like dotenv any `DOTENV_CONFIG_` environment variables take precedence over any code set options like `({quiet: false})`

```ini
```


## [v17.1.0](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1710-2025-07-07)

##### Added

- Add additional security and configuration tips to the runtime log ([#884](motdotla/dotenv#884))
- Dim the tips text from the main injection information text

```js
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',
  '🛠️  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\'] }'
]
```


## [v17.0.1](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1701-2025-07-01)

##### Changed

- Patched injected log to count only populated/set keys to process.env ([#879](motdotla/dotenv#879))


## [v17.0.0](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1700-2025-06-27)

##### Changed

- Default `quiet` to false - informational (file and keys count) runtime log message shows by default ([#875](motdotla/dotenv#874))
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Aug 10, 2025
| datasource | package | from   | to     |
| ---------- | ------- | ------ | ------ |
| npm        | dotenv  | 16.6.1 | 17.2.1 |


## [v17.2.1](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1721-2025-07-24)

##### Changed

- Fix clickable tip links by removing parentheses ([#897](motdotla/dotenv#897))


## [v17.2.0](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1720-2025-07-09)

##### Added

- Optionally specify `DOTENV_CONFIG_QUIET=true` in your environment or `.env` file to quiet the runtime log ([#889](motdotla/dotenv#889))
- Just like dotenv any `DOTENV_CONFIG_` environment variables take precedence over any code set options like `({quiet: false})`

```ini
```


## [v17.1.0](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1710-2025-07-07)

##### Added

- Add additional security and configuration tips to the runtime log ([#884](motdotla/dotenv#884))
- Dim the tips text from the main injection information text

```js
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',
  '🛠️  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\'] }'
]
```


## [v17.0.1](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1701-2025-07-01)

##### Changed

- Patched injected log to count only populated/set keys to process.env ([#879](motdotla/dotenv#879))


## [v17.0.0](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1700-2025-06-27)

##### Changed

- Default `quiet` to false - informational (file and keys count) runtime log message shows by default ([#875](motdotla/dotenv#874))
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Aug 12, 2025
| datasource | package | from   | to     |
| ---------- | ------- | ------ | ------ |
| npm        | dotenv  | 16.6.1 | 17.2.1 |


## [v17.2.1](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1721-2025-07-24)

##### Changed

- Fix clickable tip links by removing parentheses ([#897](motdotla/dotenv#897))


## [v17.2.0](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1720-2025-07-09)

##### Added

- Optionally specify `DOTENV_CONFIG_QUIET=true` in your environment or `.env` file to quiet the runtime log ([#889](motdotla/dotenv#889))
- Just like dotenv any `DOTENV_CONFIG_` environment variables take precedence over any code set options like `({quiet: false})`

```ini
```


## [v17.1.0](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1710-2025-07-07)

##### Added

- Add additional security and configuration tips to the runtime log ([#884](motdotla/dotenv#884))
- Dim the tips text from the main injection information text

```js
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',
  '🛠️  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\'] }'
]
```


## [v17.0.1](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1701-2025-07-01)

##### Changed

- Patched injected log to count only populated/set keys to process.env ([#879](motdotla/dotenv#879))


## [v17.0.0](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1700-2025-06-27)

##### Changed

- Default `quiet` to false - informational (file and keys count) runtime log message shows by default ([#875](motdotla/dotenv#874))
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Aug 15, 2025
| datasource | package | from   | to     |
| ---------- | ------- | ------ | ------ |
| npm        | dotenv  | 16.6.1 | 17.2.1 |


## [v17.2.1](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1721-2025-07-24)

##### Changed

- Fix clickable tip links by removing parentheses ([#897](motdotla/dotenv#897))


## [v17.2.0](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1720-2025-07-09)

##### Added

- Optionally specify `DOTENV_CONFIG_QUIET=true` in your environment or `.env` file to quiet the runtime log ([#889](motdotla/dotenv#889))
- Just like dotenv any `DOTENV_CONFIG_` environment variables take precedence over any code set options like `({quiet: false})`

```ini
```


## [v17.1.0](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1710-2025-07-07)

##### Added

- Add additional security and configuration tips to the runtime log ([#884](motdotla/dotenv#884))
- Dim the tips text from the main injection information text

```js
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',
  '🛠️  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\'] }'
]
```


## [v17.0.1](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1701-2025-07-01)

##### Changed

- Patched injected log to count only populated/set keys to process.env ([#879](motdotla/dotenv#879))


## [v17.0.0](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1700-2025-06-27)

##### Changed

- Default `quiet` to false - informational (file and keys count) runtime log message shows by default ([#875](motdotla/dotenv#874))
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Aug 16, 2025
| datasource | package | from   | to     |
| ---------- | ------- | ------ | ------ |
| npm        | dotenv  | 16.6.1 | 17.2.1 |


## [v17.2.1](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1721-2025-07-24)

##### Changed

- Fix clickable tip links by removing parentheses ([#897](motdotla/dotenv#897))


## [v17.2.0](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1720-2025-07-09)

##### Added

- Optionally specify `DOTENV_CONFIG_QUIET=true` in your environment or `.env` file to quiet the runtime log ([#889](motdotla/dotenv#889))
- Just like dotenv any `DOTENV_CONFIG_` environment variables take precedence over any code set options like `({quiet: false})`

```ini
```


## [v17.1.0](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1710-2025-07-07)

##### Added

- Add additional security and configuration tips to the runtime log ([#884](motdotla/dotenv#884))
- Dim the tips text from the main injection information text

```js
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',
  '🛠️  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\'] }'
]
```


## [v17.0.1](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1701-2025-07-01)

##### Changed

- Patched injected log to count only populated/set keys to process.env ([#879](motdotla/dotenv#879))


## [v17.0.0](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1700-2025-06-27)

##### Changed

- Default `quiet` to false - informational (file and keys count) runtime log message shows by default ([#875](motdotla/dotenv#874))
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Aug 17, 2025
| datasource | package | from   | to     |
| ---------- | ------- | ------ | ------ |
| npm        | dotenv  | 16.6.1 | 17.2.1 |


## [v17.2.1](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1721-2025-07-24)

##### Changed

- Fix clickable tip links by removing parentheses ([#897](motdotla/dotenv#897))


## [v17.2.0](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1720-2025-07-09)

##### Added

- Optionally specify `DOTENV_CONFIG_QUIET=true` in your environment or `.env` file to quiet the runtime log ([#889](motdotla/dotenv#889))
- Just like dotenv any `DOTENV_CONFIG_` environment variables take precedence over any code set options like `({quiet: false})`

```ini
```


## [v17.1.0](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1710-2025-07-07)

##### Added

- Add additional security and configuration tips to the runtime log ([#884](motdotla/dotenv#884))
- Dim the tips text from the main injection information text

```js
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',
  '🛠️  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\'] }'
]
```


## [v17.0.1](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1701-2025-07-01)

##### Changed

- Patched injected log to count only populated/set keys to process.env ([#879](motdotla/dotenv#879))


## [v17.0.0](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1700-2025-06-27)

##### Changed

- Default `quiet` to false - informational (file and keys count) runtime log message shows by default ([#875](motdotla/dotenv#874))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add additional [tip]s

2 participants