Skip to content

Add a script to check .env.example files stay in sync - #63

Merged
Muhammadcodes112 merged 2 commits into
MiHashport:mainfrom
chillwur:issue-3-check-env-examples-sync
Jul 10, 2026
Merged

Muhammadcodes112 merged 2 commits into
MiHashport:mainfrom
chillwur:issue-3-check-env-examples-sync

Conversation

@chillwur

Copy link
Copy Markdown
Contributor

Problem

The root .env.example is a documentation-only map of which environment variables belong to which workspace (frontend vs. backend). Nothing enforced that this map stayed accurate — a variable could be added to apps/backend/.env.example, apps/frontend/.env.example, or the backend's env schema without anyone updating the root map, silently letting the docs drift out of sync.

Solution

  • Added scripts/check-env-examples.mjs, a dependency-free Node script that:
    • Extracts the variable names declared in apps/backend/.env.example and apps/frontend/.env.example.
    • Extracts the variable names actually read by the backend's validated env schema (apps/backend/src/config/env.ts).
    • Extracts the variable names documented in the root .env.example map (including comma-separated groups like NODE_ENV, PORT, HOST).
    • Fails with a readable list of mismatches if a variable read by the backend schema is missing from apps/backend/.env.example, or if a variable documented in either workspace's .env.example is missing from the root map.
  • Added a root pnpm check:env script that runs the check.
  • Added a "Check env.example sync" step to the CI apps job, right after pnpm lint.

This builds on the validated env schema from #2, since that schema is the source of truth this script checks the backend .env.example against.

closes #3

@Muhammadcodes112
Muhammadcodes112 merged commit 5eecd8c into MiHashport:main Jul 10, 2026
1 of 2 checks passed
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 a script to check .env.example files stay in sync

2 participants