-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: Add configDir to specify a directory for .env files
#9000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
|
/gemini review |
There was a problem hiding this 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.
Remove unnecessary conditional check when assigning backend.configDir to projectInfo since the property is already optional.
963d1d4 to
131ba76
Compare
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.
- 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
…se/firebase-tools into feat-functions-config-dir
convertIfPresent supports transformation functions, which is needed to convert configDir paths using options.config.path() and path.join()
This change introduces a new property,
configDir, to thefunctionsconfiguration infirebase.json. This property allows users to specify a directory where.envfiles are located, providing more flexibility in project structure.The
configDirproperty is supported for both deployment and the local functions emulator.configDirpath is resolved relative to thefirebase.jsonfile.configDiris not specified, the behavior remains unchanged, and.envfiles are looked for in the functions source directory.Unit and emulator integration tests have been added to verify the new functionality.