feat: add .env inheritance support in Envied and EnviedGenerator#190
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds .env inheritance to Envied so consumers can define shared defaults in one or more base files and override them in environment-specific files, with generator support to load/merge/interpolate across the chain.
Changes:
- Added
inheritFromto theEnviedannotation and documented inheritance behavior. - Updated env loading/parsing in
envied_generatorto merge multiple files (in order) while keeping “first duplicate wins” within a single file. - Added generator tests + new fixture
.envfiles covering override, interpolation, duplicates, and missing inherited files.
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/envied/test/envy_test.dart | Adds unit tests for the new inheritFrom default/assignment behavior. |
| packages/envied/README.md | Documents “Environment inheritance” and clarifies interaction with build path override. |
| packages/envied/lib/src/envied_base.dart | Introduces inheritFrom on Envied annotation. |
| packages/envied_generator/lib/src/parser.dart | Extends parsing to support interpolation using an externally-supplied env map (for inherited values). |
| packages/envied_generator/lib/src/load_envs.dart | Adds loadEnvsFromPaths to load/merge envs from multiple files in order. |
| packages/envied_generator/lib/src/generator.dart | Wires inheritFrom into generation, updates generated_from comment to include all contributing files. |
| packages/envied_generator/test/envy_generator_test.dart | Registers the new inheritance-focused generator test suite. |
| packages/envied_generator/test/src/generator_tests_with_inheritance.dart | Adds source_gen_test coverage for inheritance scenarios (overrides, interpolation, missing files, multi-annotation). |
| packages/envied_generator/test/.env.inheritance_defaults | Inheritance fixture: base defaults. |
| packages/envied_generator/test/.env.inheritance_middle | Inheritance fixture: mid-layer overrides. |
| packages/envied_generator/test/.env.inheritance_child | Inheritance fixture: child overrides + interpolation + duplicates. |
| packages/envied_generator/test/.env.inheritance_alt_defaults | Inheritance fixture: alternate defaults for multi-annotation test. |
| packages/envied_generator/test/.env.inheritance_alt_child | Inheritance fixture: alternate child overrides for multi-annotation test. |
| CHANGELOG.md | Trims trailing whitespace (no functional/log entry change). |
| .gitignore | Ignores .history and .DS_Store. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 17 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
CHANGELOG.md:484
- PR description mentions a changelog entry for the new environment inheritance feature, but this change only removes a trailing blank line. If the feature is intended to be released, please add an explicit changelog bullet under the appropriate package/version section.
- **FIX**(envied_generator): build extensions setting (#30).
- **FIX**: CI workflow and dependency updates (#31).
cdc4b0e to
65cee75
Compare
Collaborator
Author
|
@petercinibulk this should be ready for review now :) |
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.
This pull request introduces support for environment file inheritance in the Envied package, allowing users to specify multiple
.envfiles whose values are loaded and merged in order. The changes include updates to theEnviedannotation, enhancements to the environment loading logic, and comprehensive tests and documentation to cover the new feature.Environment inheritance feature:
Added a new
inheritFromparameter to theEnviedannotation, allowing users to specify an ordered list of.envfiles to be loaded before the primary file, with later files overriding earlier values. (packages/envied/lib/src/envied_base.dart,packages/envied_generator/lib/src/generator.dart) [1] [2] [3] [4] [5] [6] [7]Updated the environment variable loading logic to support merging values from multiple files, preserving the correct override order and supporting variable interpolation across inherited files. (
packages/envied_generator/lib/src/load_envs.dart,packages/envied_generator/lib/src/parser.dart) [1] [2] [3]Documentation improvements:
packages/envied/README.md) [1] [2]Testing and validation:
inheritFromparameter, including edge cases with missing files and multiple inheritance scenarios. (packages/envied/test/envy_test.dart,packages/envied_generator/test/envy_generator_test.dart,packages/envied_generator/test/src/generator_tests_with_inheritance.dart, and new test.envfiles) [1] [2] [3] [4] [5] [6] [7] [8] [9]Minor improvements:
pathvalues in theEnviedannotation to default to.env. (packages/envied/lib/src/envied_base.dart,packages/envied_generator/lib/src/generator.dart,packages/envied_generator/test/src/generator_tests.dart) [1] [2]Changelog update:
CHANGELOG.md)