Firebase CLI
repository·main·Indexed 26 days ago
https://github.com/firebase/firebase-toolsCommand-Line Interface for Firebase (version 15.24.0) that allows developers to test, manage, and deploy Firebase projects. It includes tools for project initialization, deployment, local emulation, and management of services such as Cloud Functions, Realtime Database, Remote Config, App Distribution, and Firebase Extensions. The repository also hosts the official Firebase Model Context Protocol (MCP) Server and provides a VSCode extension for Firebase SQL Connect.
What's inside firebase-tools
- The Firebase Model Context Protocol (MCP) Server enables AI-powered development tools to interact directly with your Firebase projects and application codebase. It provides an agent with the capabilities of an expert Firebase developer, allowing it to manage projects, interact with Firebase products, and assist in coding and debugging.
Use Firebase SQL Connect for VSCode
mainThe Firebase SQL Connect extension provides tools for the SQL Connect development workflow, including language support, query execution, and SDK generation. It features a GraphQL Language Server for syntax and compile-time error checking, along with auto-complete suggestions specific to SQL Connect.Understand Firebase MCP Server capabilities
mainThe Firebase MCP (Model Context Protocol) server provides three distinct types of capabilities to AI models:
- Tools: Functions that allow the AI to perform specific actions within the Firebase ecosystem.
- Prompts: Reusable command templates that help guide the AI in performing complex tasks.
- Resources: Documentation files provided as context to help AI models understand Firebase-specific information.
Understand the firebase-vscode extension architecture
mainThe extension is structured into several key components:
extension.ts: The main entry point. It orchestratessidebar.tsandworkflow.ts.sidebar.ts: Responsible for loading the UI from thewebviewsfolder.workflow.ts: The core logic component that drives the extension's behavior.cli.ts: A wrapper for CLI methods that imports functionality fromfirebase-tools/src. Whenworkflow.tsneeds to execute a CLI command, it delegates the task tocli.ts.- UI Communication: The communication between the UI (Webview) and the extension is handled via a broker using
webview.postMessage. The Webview is built using React.
Verify Emulator Function Trigger compatibility
mainThe end-to-end test suite verifies the integration between various Firebase emulators. It ensures that:
- Functions & Database: The functions emulator (>= v7.0.0) can register database event triggers with database emulators (>= v4.0.0).
- Database & Functions: The database emulator (>= v4.0.0) can successfully invoke functions hosted on a local functions emulator instance.
- Functions & Database (Admin SDK): Functions served by the functions emulator can operate on a local database emulator using the
firebase-adminNode.js SDK. - Database-triggered Functions & Firestore: Local functions triggered by a database emulator event can operate on a local Firestore emulator using the Node.js Admin SDK.
- Firestore-triggered Functions & Database: Local functions triggered by a Firestore emulator event can operate on both local database emulators (>= v4.0.0) and the invoking Firestore emulator using the Node.js Admin SDK.
Essentially, the test validates that Cloud Functions can act as a bidirectional communication channel between the Realtime Database emulator and the Firestore emulator.
Understand the Framework-aware Hosting Preview limitations
mainFramework-aware {{hosting}} is currently in an early public preview. Users should be aware that:
- Functionality may change in backward-incompatible ways.
- The preview release is not subject to any Service Level Agreement (SLA).
- The preview release is not subject to any deprecation policy.
- Support for this feature may be limited or unavailable.
Run the WebFrameworks Deploy Integration Test
mainThis integration test deploys a Next.js hosted project with
webframeworksenabled.WARNINGS:
- Destructive: This test will overwrite/delete what is currently being hosted. Do not run this on a project containing Firebase Functions or any other resources you wish to preserve.
- Concurrency: The test is not thread-safe. Ensure no other tests are running on the target project simultaneously.
- Recommendation: Use a dedicated test project rather than a production or development project.
To run the test, set the
GCLOUD_PROJECTenvironment variable to your project ID and execute the test script via npm.$ GCLOUD_PROJECT=${PROJECT_ID} npm run test:webframeworks-deployInitialize Firebase for a framework project
mainTo begin using Firebase with your framework project, you must initialize Firebase within your project directory. For existing projects, you can configure Firebase by modifying thefirebase.jsonconfiguration file.Regenerate Authentication Emulator API specs and schemas
mainThe Authentication Emulator relies on autogenerated files
apiSpec.js(the merged OpenAPI 3.0 specification) andschemas.ts(TypeScript interfaces for request/response bodies). These are generated from Google API Discovery Documents using thegen-auth-api-spec.tsscript.To re-generate these files, run the following command from the
firebase-toolsroot directory:npm run generate:auth-apiIntegrate Firebase JS SDK with Angular SSR
mainWhen using Firebase JS SDK methods in both server and client bundles, you must guard against runtime errors by checkingisSupported()before using the product, as not all products are supported in all environments. Alternatively, use AngularFire to handle this automatically.Build firepit standalone binaries locally
mainYou can manually create
firepitbuilds (standalonefirebase-toolsbinaries) from non-publishedfirebase-toolsbuilds or test updates to thefirepitruntime using thepipeline.jsscript.Prerequisites:
- Install the GitHub CLI (
hub). - Have a local instance of the
firebase-toolsrepository with your changes. - Ensure the
firebase-toolsfolder has been built usingnpm run build.
Steps:
- Navigate to the
scripts/firepit-builderdirectory. - Run
npm install. - Execute the pipeline script pointing to your local built package:
node ./pipeline.js --package="/absolute/path/to/firebase-tools".
Upon success, the script will output a list of binary artifacts.
- Install the GitHub CLI (
Integrate Lit using Vite
mainLit support in Firebase is implemented via the Vite framework integration. To integrate Lit, follow the full guidance provided in the Vite framework documentation.