Improve package.json startup scripts with environment validation and logging #9
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.
Overview
This PR enhances the stability and developer experience of the Quirk bot by implementing comprehensive environment file validation with clear, user-friendly error messages in English.
Problem
Previously, the application would:
dotenv.config()without specifying which.envfile to loadSolution
1. Environment-Specific Configuration Files
.env.local.env.production2. Pre-Flight Validation
All startup scripts now validate environment files before running expensive operations (database migrations, builds, etc.):
3. Centralized Environment Loading
Created
src/config/env-loader.tsthat:NODE_ENV4. Updated Package.json Scripts
New scripts:
check-env:dev- Validates.env.localexistscheck-env:prod- Validates.env.productionexistsEnhanced scripts:
dev:app,dev:pair- Now validate.env.localbefore startingstart,start:direct,start:node,prebuild- Now validate.env.productionbefore runningstart:node- Explicitly setsNODE_ENV=productionfor clarityFiles Changed
Added:
scripts/check-env.js- Environment file validation scriptsrc/config/env-loader.ts- Centralized environment loader modulescripts/test-env-validation.js- Comprehensive test suiteModified:
package.json- Updated scripts with validation checkssrc/start.ts- Uses new centralized env loadersrc/configuration/general.ts- Uses new centralized env loader.gitignore- Added.env.productionto prevent accidental commitsREADME.md- Added environment configuration documentationTesting
scripts/test-env-validation.js)Migration Guide
For existing installations:
Development:
cp .env.template .env.local # Edit .env.local with your configuration npm run devProduction:
cp .env.template .env.production # Edit .env.production with your configuration npm run startBenefits
Resolves the issue of improving production and development command stability with better logging and environment file validation.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
checkpoint.prisma.io/usr/local/bin/node /home/REDACTED/work/Quirk/Quirk/node_modules/prisma/build/child {"product":"prisma","version":"5.22.0","cli_install_type":"local","information":"","local_timestamp":"2025-10-24T19:05:46Z","project_hash":"c8208cdd","cli_path":"/home/REDACTED/work/Quirk/Quirk/node_modules/.bin/prisma","cli_path_hash":"cffe18d0","endpoint":"REDACTED","disable":false,"arch":"x64","os":"linux","node_version":"v20.19.5","ci":true,"ci_name":"GitHub Actions","command":"generate","schema_providers":["postgresql"],"schema_preview_features":[],"schema_generators_providers":["prisma-client-js"],"cache_file":"/home/REDACTED/.cache/checkpoint-nodejs/prisma-cffe18d0","cache_duration":43200000,"remind_duration":172800000,"force":false,"timeout":5000,"unref":true,"child_path":"/home/REDACTED/work/Quirk/Quirk/node_modules/prisma/build/child","client_event_id":"","previous_client_event_id":"","check_if_update_available":true}(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.