Skip to content

Conversation

@taeold
Copy link
Contributor

@taeold taeold commented Aug 19, 2025

This change introduces a new property, configDir, to the functions configuration in firebase.json. This property allows users to specify a directory where .env files are located, providing more flexibility in project structure.

The configDir property is supported for both deployment and the local functions emulator.

  • The configDir path is resolved relative to the firebase.json file.
  • If configDir is not specified, the behavior remains unchanged, and .env files are looked for in the functions source directory.

Unit and emulator integration tests have been added to verify the new functionality.

This change introduces a new property, `configDir`, to the `functions`
configuration in `firebase.json`. This property allows users to specify a
directory where `.env` files are located, providing more flexibility in
project structure.

The `configDir` property is supported for both deployment and the local
functions emulator.

- The `configDir` path is resolved relative to the `firebase.json` file.
- If `configDir` is not specified, the behavior remains unchanged, and `.env`
  files are looked for in the functions source directory.

Unit and emulator integration tests have been added to verify the new
functionality.
@taeold
Copy link
Contributor Author

taeold commented Aug 20, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the configDir property, allowing users to specify a custom directory for .env files. This is a valuable feature for projects with non-standard structures. The implementation is solid across both deployment and the emulator, and it's great to see comprehensive unit and integration tests to validate the new functionality. I've also noticed some nice refactoring in the test suite and environment variable handling logic, which improves code clarity. I have one minor suggestion to simplify the code in getUserEnvs.

@taeold taeold marked this pull request as ready for review August 20, 2025 02:01
@taeold taeold requested a review from inlined August 20, 2025 02:03
Remove unnecessary conditional check when assigning backend.configDir
to projectInfo since the property is already optional.
@taeold taeold force-pushed the feat-functions-config-dir branch from 963d1d4 to 131ba76 Compare August 20, 2025 02:05
taeold added 3 commits August 19, 2025 19:05
Reverted the unnecessary addition of configDir parameter to existing
tests in env.spec.ts since the default behavior when configDir is
undefined is backward compatible. Only kept configDir in the test that
specifically tests the new configDir functionality.
taeold added 3 commits August 20, 2025 13:02
- Use proto.copyIfPresent in prepare.ts and controller.ts to conditionally
  set configDir only when it has a value
- Remove unnecessary fs.rmSync for temp directory in test cleanup
@taeold taeold enabled auto-merge (squash) August 20, 2025 22:07
taeold added 2 commits August 20, 2025 15:40
convertIfPresent supports transformation functions, which is needed
to convert configDir paths using options.config.path() and path.join()
@taeold taeold merged commit 79e3ab5 into master Aug 21, 2025
48 checks passed
@taeold taeold deleted the feat-functions-config-dir branch August 21, 2025 18:01
@github-project-automation github-project-automation bot moved this from Approved [PR] to Done in [Cloud] Extensions + Functions Aug 21, 2025
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.

2 participants