Skip to content

feat: add .env inheritance support in Envied and EnviedGenerator#190

Merged
petercinibulk merged 5 commits into
mainfrom
feat/environment-inheritance
May 10, 2026
Merged

feat: add .env inheritance support in Envied and EnviedGenerator#190
petercinibulk merged 5 commits into
mainfrom
feat/environment-inheritance

Conversation

@techouse
Copy link
Copy Markdown
Collaborator

@techouse techouse commented May 10, 2026

This pull request introduces support for environment file inheritance in the Envied package, allowing users to specify multiple .env files whose values are loaded and merged in order. The changes include updates to the Envied annotation, enhancements to the environment loading logic, and comprehensive tests and documentation to cover the new feature.

Environment inheritance feature:

  • Added a new inheritFrom parameter to the Envied annotation, allowing users to specify an ordered list of .env files 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:

  • Extended the README with a new section and example for environment inheritance, explaining usage and override behavior. (packages/envied/README.md) [1] [2]

Testing and validation:

  • Added new and updated tests to verify the behavior of the inheritFrom parameter, 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 .env files) [1] [2] [3] [4] [5] [6] [7] [8] [9]

Minor improvements:

  • Improved handling of empty path values in the Envied annotation 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:

  • Updated the changelog to reflect the addition of the environment inheritance feature. (CHANGELOG.md)

@techouse techouse added the enhancement New feature or request label May 10, 2026
@techouse techouse linked an issue May 10, 2026 that may be closed by this pull request
@techouse techouse added this to the 1.3.5 milestone May 10, 2026
@techouse techouse requested a review from Copilot May 10, 2026 11:34
@techouse techouse marked this pull request as ready for review May 10, 2026 11:35
@techouse techouse requested a review from petercinibulk as a code owner May 10, 2026 11:35
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 inheritFrom to the Envied annotation and documented inheritance behavior.
  • Updated env loading/parsing in envied_generator to merge multiple files (in order) while keeping “first duplicate wins” within a single file.
  • Added generator tests + new fixture .env files 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.

Comment thread packages/envied/lib/src/envied_base.dart
Comment thread packages/envied_generator/lib/src/generator.dart Outdated
Comment thread CHANGELOG.md
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Comment thread packages/envied_generator/lib/src/generator.dart Outdated
Comment thread packages/envied_generator/lib/src/load_envs.dart Outdated
@techouse techouse marked this pull request as draft May 10, 2026 15:37
@techouse techouse force-pushed the feat/environment-inheritance branch from cdc4b0e to 65cee75 Compare May 10, 2026 16:09
@techouse techouse marked this pull request as ready for review May 10, 2026 16:30
@techouse techouse requested a review from Copilot May 10, 2026 16:30
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 16 changed files in this pull request and generated 2 comments.

Comment thread packages/envied_generator/pubspec.yaml
Comment thread packages/envied/lib/src/envied_base.dart
@techouse
Copy link
Copy Markdown
Collaborator Author

@petercinibulk this should be ready for review now :)

@petercinibulk petercinibulk merged commit a6f1e7f into main May 10, 2026
9 checks passed
@techouse techouse deleted the feat/environment-inheritance branch May 10, 2026 18:38
@techouse techouse mentioned this pull request May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support environment inheritance for .env files

3 participants