CLI tool
The Firebase CLI tool is important for some workflows:
- we may run an emulated backend locally to debug it with no incurred cost: authentication, database, and cloud functions.
- it is the main way to scaffold the cloud functions directory with boilerplate code
- it is the main way to deploy cloud functions, security rules, and websites if we host them on Firebase.
- we may browse and manage the Firebase projects linked to the Firebase account.
the executable
The executable is provided by the firebase-tools npm package. It is invoked as firebase:
npm i firebase-tools
firebase
one-time setup
firebase login
firebase login:list # indicates which account is logged-in
list projects and select one
firebase projects:list
firebase use imagetales
project configuration and scaffolding
firebase init
help
firebase help
firebase help deploy
firebase help | grep firestore
cloud functions
firebase functions:list
firebase functions:shell
firebase functions:secrets:access ABC_API_KEY
firebase functions:secrets:set ABC_API_KEY
firebase functions:secrets:destroy ABC_API_KEY
firebase deploy --only functions
firebase deploy --only functions:requestPlanet
emulators
start emulators:
firebase emulators:start
firebase emulators:start --import=./emulatorData/ --export-on-exit
We specify which emulators to run in firebase.json. In absence of such file, emulators will not run. The port is optional: we may omit it and provide an empty object instead.
{
"emulators": {
"firestore": { "port": 8080 },
"auth": { "port": 9099 },
"functions": { "port": 5001 },
"storage": { "port": 9199 },
"ui": { "enabled": true }
},
"storage": { "rules": "storage.rules" },
"functions": [
/* ... */
]
}
Google Cloud CLI tool
The tool unlocks some operations not available on the Firebase's one.
gcloud secrets list --project <PROJECT_ID>