6 Commits

Author SHA1 Message Date
Daniel Lee
592a4ee6cb Fix Firebase Function deploy bugs. (#3668)
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
2021-08-12 11:23:12 -07:00
Daniel Lee
d9aaaec1f3 Deploy environment variables in dotenv files for functions (#3645)
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`.
2021-08-11 13:31:18 -07:00
Kiana McNellis
92e1809ae2 Enable a function to be emulated in multiple regions (#3364) 2021-05-19 08:36:19 -04:00
Abe Haskins
93abee929d Implements Storage Emulator (#3230)
* Adds Storage Emulator

* npm run format

* Attempt to fix failing runtime test
2021-03-25 13:15:21 -07:00
Thomas Bouldin
1633f4fccb Upgrade logger to TypeScript (#3138)
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.
2021-03-12 14:47:50 -08:00
Bryan Kendall
daa9fd58dc move emulator suite tests into scripts folder (#3035)
* 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
2021-01-15 09:48:05 -08:00