Skip to content

Add local dev defaults and utility functions - #44

Closed
mspandey wants to merge 2 commits into
ZarrarPeshimam:mainfrom
mspandey:patch-2
Closed

Add local dev defaults and utility functions#44
mspandey wants to merge 2 commits into
ZarrarPeshimam:mainfrom
mspandey:patch-2

Conversation

@mspandey

Copy link
Copy Markdown

Description

Enhances the environment bootstrap workflow by automatically replacing empty or well-defined placeholder environment variable values (such as MONGO_URI, DATABASE_URL, and REDIS_URL) with sensible local development defaults when generating a .env file from .env.example.

This significantly reduces manual setup friction and improves the developer onboarding experience for first-time contributors.


Changes Made

  • **Added src/utils/envDefaults.ts**:

  • Implemented LOCAL_DEV_DEFAULTS mappings for standard databases/services (MONGO_URI, DATABASE_URL, REDIS_URL).

  • Added robust placeholder detection (isPlaceholderOrEmpty) to identify empty fields, bracketed tags (<your_database_url>), and keywords like YOUR_ or CHANGE_ME.

  • Created applyLocalDevDefaults to parse .env lines, substitute matching keys safely, and preserve spacing, formatting, and comments.

  • Integrated into Environment Bootstrap:

  • Updated src/runners/EnvBootstrap.ts to process .env.example file contents through the defaults engine prior to writing out the generated .env.


Testing Scenarios Verified

  1. Empty Values:
  • MONGO_URI= $\rightarrow$ MONGO_URI=mongodb://localhost:27017/<database-name>
  • DATABASE_URL= $\rightarrow$ DATABASE_URL=postgresql://<username>:<password>@localhost:5432/<database-name>
  • REDIS_URL= $\rightarrow$ REDIS_URL=redis://localhost:6379
  1. Placeholder Values:
  • MONGO_URI=YOUR_MONGODB_URI $\rightarrow$ Replaced with local dev default.
  • DATABASE_URL=<your_database_url> $\rightarrow$ Replaced with local dev default.
  • REDIS_URL=your_redis_url $\rightarrow$ Replaced with local dev default.
  1. Preservation of Custom / Unrelated Values:
  • Verified that user-provided valid connection strings (e.g., MONGO_URI=mongodb://localhost:27017/mydb) and unrelated environment variables (e.g., JWT_SECRET, API keys) remain completely unchanged.

Benefits

Copilot AI lite review requested due to automatic review settings August 20, 2026 17:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Added local development defaults for environment variables and applied them when generating .env file.
@ZarrarPeshimam

Copy link
Copy Markdown
Owner

@mspandey, why have u posted 2 PRs (#43 #44) for one issue?

@mspandey mspandey closed this Aug 21, 2026
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.

3 participants