firebase-tools
Version:
Command-Line Interface for Firebase
52 lines (43 loc) • 2.14 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.get_environment = void 0;
const zod_1 = require("zod");
const tool_js_1 = require("../../tool.js");
const util_js_1 = require("../../util.js");
const projectUtils_js_1 = require("../../../projectUtils.js");
const js_yaml_1 = require("js-yaml");
const auth_js_1 = require("../../../auth.js");
exports.get_environment = (0, tool_js_1.tool)({
name: "get_environment",
description: "Retrieves information about the current Firebase environment including current authenticated user, project directory, active project, and more.",
inputSchema: zod_1.z.object({}),
annotations: {
title: "Get Firebase Environment Info",
readOnlyHint: true,
},
_meta: {
requiresAuth: false,
requiresProject: false,
},
}, async (_, { projectId, host, accountEmail, rc, config }) => {
const aliases = projectId ? (0, projectUtils_js_1.getAliases)({ rc }, projectId) : [];
return (0, util_js_1.toContent)(`# Environment Information
Project Directory: ${host.cachedProjectRoot}
Project Config Path: ${config.projectFileExists("firebase.json") ? config.path("firebase.json") : "<NO CONFIG PRESENT>"}
Active Project ID: ${projectId ? `${projectId}${aliases.length ? ` (alias: ${aliases.join(",")})` : ""}` : "<NONE>"}
Authenticated User: ${accountEmail || "<NONE>"}
# Available Project Aliases (format: '[alias]: [projectId]')
${(0, js_yaml_1.dump)(rc.projects).trim()}
# Available Accounts:
${(0, js_yaml_1.dump)((0, auth_js_1.getAllAccounts)().map((account) => account.user.email)).trim()}
${config.projectFileExists("firebase.json")
? `
# firebase.json contents:
\`\`\`json
${config.readProjectFile("firebase.json")}
\`\`\``
: `\n# Empty Environment
It looks like the current directory is not initialized as a Firebase project. The user will most likely want to:
a) Change the project directory using the 'firebase_update_environment' tool to select a directory with a 'firebase.json' file in it, or
b) Initialize a new Firebase project directory using the 'firebase_init' tool.`}`);
});
;