Firebase CLI

repository·main·Indexed 26 days ago

https://github.com/firebase/firebase-tools

Command-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.

Tokens
72.4K
Snippets
135
Records
555
Agent score
88%

What's inside firebase-tools

  1. Overview of Firebase MCP Server

    main
    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.
  2. Use Firebase SQL Connect for VSCode

    main
    The 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.
  3. Understand Firebase MCP Server capabilities

    main

    The 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.
  4. Understand the firebase-vscode extension architecture

    main

    The extension is structured into several key components:

    • extension.ts: The main entry point. It orchestrates sidebar.ts and workflow.ts.
    • sidebar.ts: Responsible for loading the UI from the webviews folder.
    • workflow.ts: The core logic component that drives the extension's behavior.
    • cli.ts: A wrapper for CLI methods that imports functionality from firebase-tools/src. When workflow.ts needs to execute a CLI command, it delegates the task to cli.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.
  5. Verify Emulator Function Trigger compatibility

    main

    The end-to-end test suite verifies the integration between various Firebase emulators. It ensures that:

    1. Functions & Database: The functions emulator (>= v7.0.0) can register database event triggers with database emulators (>= v4.0.0).
    2. Database & Functions: The database emulator (>= v4.0.0) can successfully invoke functions hosted on a local functions emulator instance.
    3. Functions & Database (Admin SDK): Functions served by the functions emulator can operate on a local database emulator using the firebase-admin Node.js SDK.
    4. 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.
    5. 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.

  6. Understand the Framework-aware Hosting Preview limitations

    main

    Framework-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.
  7. Run the WebFrameworks Deploy Integration Test

    main

    This integration test deploys a Next.js hosted project with webframeworks enabled.

    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_PROJECT environment variable to your project ID and execute the test script via npm.

    $ GCLOUD_PROJECT=${PROJECT_ID} npm run test:webframeworks-deploy
  8. Regenerate Authentication Emulator API specs and schemas

    main

    The Authentication Emulator relies on autogenerated files apiSpec.js (the merged OpenAPI 3.0 specification) and schemas.ts (TypeScript interfaces for request/response bodies). These are generated from Google API Discovery Documents using the gen-auth-api-spec.ts script.

    To re-generate these files, run the following command from the firebase-tools root directory:

    npm run generate:auth-api
  9. Build firepit standalone binaries locally

    main

    You can manually create firepit builds (standalone firebase-tools binaries) from non-published firebase-tools builds or test updates to the firepit runtime using the pipeline.js script.

    Prerequisites:

    1. Install the GitHub CLI (hub).
    2. Have a local instance of the firebase-tools repository with your changes.
    3. Ensure the firebase-tools folder has been built using npm run build.

    Steps:

    1. Navigate to the scripts/firepit-builder directory.
    2. Run npm install.
    3. 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.