CLI toolkit
toolkit overview
The firebase CLI allows to:
-
run an emulated backend locally to debug it without incurring cost. It emulates authentication servers, databases, and serverless functions.
-
run a shell to call and debug the emulated cloud functions.
-
scaffold a project or directory with boilerplate code, notably the cloud functions directory.
-
deploy cloud functions, security rules, and possibly a website.
-
list and manage firebase projects that belong to the account
package and executable
the npm package and the executable have a distinct name
firebase-tools # npm package
firebase # executable name
firebase CLI setup
firebase login
firebase login:list # indicates which account is logged in
project initialization
firebase init
main uses
firebase help deploy # get help about a command
firebase help | grep firestore
firebase help | grep functions
firebase projects:list
firebase functions:list
firebase functions:shell
firebase functions:config:set OPENAI_TOKEN="...."
firebase deploy
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 emulator to run in firebase.json
. In absence of such file, no emulator may run.
{
"emulators": {
"firestore": {
"port": 8080
},
"auth": {
"port": 9099
},
"functions": {
"port": 5001
},
"storage": {
"port": 9199
},
"ui": {
"enabled": true
}
},
"functions": [
{
"source": "functions",
"codebase": "default",
"ignore": ["node_modules", ".git", "firebase-debug.log", "firebase-debug.*.log"],
"predeploy": ["npm --prefix \"$RESOURCE_DIR\" run build"]
}
],
"storage": {
"rules": "storage.rules"
}
}