Add local dev defaults and utility functions - #44
Closed
mspandey wants to merge 2 commits into
Closed
Conversation
Added local development defaults for environment variables and applied them when generating .env file.
Owner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Enhances the environment bootstrap workflow by automatically replacing empty or well-defined placeholder environment variable values (such as
MONGO_URI,DATABASE_URL, andREDIS_URL) with sensible local development defaults when generating a.envfile 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_DEFAULTSmappings 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 likeYOUR_orCHANGE_ME.Created
applyLocalDevDefaultsto parse.envlines, substitute matching keys safely, and preserve spacing, formatting, and comments.Integrated into Environment Bootstrap:
Updated
src/runners/EnvBootstrap.tsto process.env.examplefile contents through the defaults engine prior to writing out the generated.env.Testing Scenarios Verified
MONGO_URI=MONGO_URI=mongodb://localhost:27017/<database-name>DATABASE_URL=DATABASE_URL=postgresql://<username>:<password>@localhost:5432/<database-name>REDIS_URL=REDIS_URL=redis://localhost:6379MONGO_URI=YOUR_MONGODB_URIDATABASE_URL=<your_database_url>REDIS_URL=your_redis_urlMONGO_URI=mongodb://localhost:27017/mydb) and unrelated environment variables (e.g.,JWT_SECRET, API keys) remain completely unchanged.Benefits
[Feature]: Generate Local Development Defaults for Placeholder Env Variables #32