This is embarrassing. I must have removed the preview check while refactoring the code after PR feedback. Also improving the logging logic to not log anything if no local dotenv files are found.
Also addresses bug where wrong `FIREBASE_CONFIG` value was set https://github.com/firebase/firebase-tools/issues/3667
Add support for setting up environment variables for functions using dotenv files.
On deploy, Firebase CLI looks for naive dotenv file (`.env`) file or project-specific ones (`.env.<project id>` or `.env.<project alias>`) files, loads environment variables, and injects them on deployed functions. Environment variable set in project-specific dotenv file wins, and you cannot have both `.<project id>` and `<.project alias>` files.
Environment variables are also loaded up on Firebase Emulators. Emulator will look for `.env` and `.env.local` files and ignore project-specific dotenv files.
We are hiding the feature behind `dotenv` preview flag. We want to get a feeling for the development experience from our users before an official launch + documentations.
Also including a small e2e test for env var support. It's meant to run manually by the Firebase team via command `node scripts/test-functions-env.js`.
Rewrote our logger code in TypeScript.
Because we now need access to types in exported in the logger file, we export logger as a named export instead of assigning exports to logger (an anti-pattern anyway).
This change touches nearly every file because of the named import change. To reduce risk these changes have been made robotically:
```bash
git grep -e "require(.*logger" --name-only | xargs sed -i '' -e 's/var logger = require("\(.*logger\)")/const { logger } = require("\1")/g'
git grep -e "require(.*logger" --name-only | xargs sed -i '' -e 's/const logger = require("\(.*logger\)")/const { logger } = require("\1")/g'
git grep -e "import logger = require(.*logger" --name-only | xargs sed -i '' -e 's/logger = require("\(.*logger\)")/{ logger } from "\1"/g'
git grep -e "import \* as logger" --name-only | xargs sed -i '' -e 's/import \* as logger/import { logger }/g'
```
Other changes like `import { warn } from 'logger'` were touched up manually
Additionally, there were configurations in our logger that had been removed from the winston spec several versions ago (Particularly in our emulator code). TypeScirpt caught these errors and I upgraded to the new version of these APIs.
* move emulator tests into scripts folder
* add run script
* wip
* setup the emulator tests to be compiled and then run
* clean up lines
* upgrade ts-node
* clean up run script
* fix package-lock merge