v2: Support Zod Mini; Remove dotenv & dotenv-expand; Improve Logging & Functionality - #189
Merged
Conversation
Signed-off-by: Noah Tigner <46695778+noahtigner@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces version 2.0.0 of validate-env-vars with significant architectural changes and new functionality. The package now supports both Zod v4 Classic and Zod Mini, removes external dependencies (dotenv and dotenv-expand), and implements native environment variable loading and expansion using Node.js built-in features.
Key Changes:
- Adds Zod Mini support by migrating to
zod/v4/coreimports and updating type validation logic - Replaces dotenv/dotenv-expand with custom implementation using Node's
process.loadEnvFile()and custom expansion logic - Makes
envPathparameter optional, allowing validation ofprocess.envwithout loading a file
Reviewed changes
Copilot reviewed 18 out of 21 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Bumped to v2.0.0; removed dotenv dependencies; updated peer dependencies to support Zod ^4.0.0 |
| package-lock.json | Removed dotenv and dotenv-expand packages from lock file |
| tsconfig.json | Changed target to "esnext"; added "local.ts" to exclusions |
| eslint.config.js | Streamlined ESLint configuration; separated source and test file linting rules |
| .gitignore | Added local.ts and .git to ignore list |
| src/schemaTypes.ts | Completely rewritten to use Zod v4 core types; removed custom env* helper functions |
| src/validateInput.ts | Added comprehensive field type validation for Zod v4; moved validation logic from index; added isValidFieldType function |
| src/logParseResults.ts | Enhanced logging with metadata support (title, description, examples); added helper functions for parsing metadata |
| src/loadEnvVars.ts | New file implementing custom env file loading with variable expansion (replaces dotenv/dotenv-expand) |
| src/index.ts | Simplified main entry point; refactored to use new validation and loading functions |
| src/constants.ts | Removed ALLOWED_TYPE_NAMES array; added HINT_SYMBOL constant |
| tests/validateInput.test.ts | Expanded test coverage for field type validation; added comprehensive test table |
| tests/schemaTypes.test.ts | File deleted (helper functions removed from main API) |
| tests/logParseResults.test.ts | Updated tests for new logging format; added tests for metadata parsing |
| tests/loadEnvVars.test.ts | New test file for env loading and expansion functionality |
| tests/jest.setup.ts | Added mock for process.loadEnvFile; improved test environment setup |
| tests/index.test.ts | Updated integration tests for new API; removed dotenv-specific tests |
| tests/compatibility.test.ts | New test file verifying Zod Classic and Zod Mini compatibility |
| tests/.env.test | Renamed variables with TEST_ prefix; added more test cases |
| README.md | Updated documentation with new usage examples and schema recipes; fixed typo in function name |
| CHANGELOG.md | New file documenting version history and changes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Noah Tigner <46695778+noahtigner@users.noreply.github.com>
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.
Changes
process.loadEnvFileenvPathparameter optional. If not provided, no file is read, and onlyprocess.envis validated.metais logged (title,description, andexamplessupported)schemais validated and field types are allowed/disallowedExample Output