firebase-tools
Version:
Command-Line Interface for Firebase
84 lines (83 loc) • 3.41 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.doSetup = void 0;
const utils = require("../../utils");
const prompt_1 = require("../../prompt");
const index_1 = require("./aitools/index");
const logger_1 = require("../../logger");
const AGENT_CHOICES = Object.values(index_1.AI_TOOLS).map((tool) => ({
value: tool.name,
name: tool.displayName,
checked: false,
}));
async function doSetup(setup, config) {
logger_1.logger.info();
logger_1.logger.info("This command will configure AI coding assistants to work with your Firebase project by:");
utils.logBullet("• Setting up the Firebase MCP server for direct Firebase operations");
utils.logBullet("• Installing context files that help AI understand:");
utils.logBullet(" - Firebase project structure and firebase.json configuration");
utils.logBullet(" - Common Firebase CLI commands and debugging practices");
utils.logBullet(" - Product-specific guidance (Functions, Firestore, Hosting, etc.)");
logger_1.logger.info();
const selections = {};
selections.tools = await (0, prompt_1.checkbox)({
message: "Which tools would you like to configure?",
choices: AGENT_CHOICES,
validate: (choices) => {
if (choices.length === 0) {
return "Must select at least one tool.";
}
return true;
},
});
if (!selections.tools || selections.tools.length === 0) {
return;
}
logger_1.logger.info();
logger_1.logger.info("Configuring selected tools...");
const projectPath = config.projectDir;
const enabledFeatures = getEnabledFeatures(setup.config);
let anyUpdates = false;
for (const toolName of selections.tools) {
const tool = index_1.AI_TOOLS[toolName];
if (!tool) {
utils.logWarning(`Unknown tool: ${toolName}`);
continue;
}
const result = await tool.configure(config, projectPath, enabledFeatures);
const updatedCount = result.files.filter((f) => f.updated).length;
const hasChanges = updatedCount > 0;
if (hasChanges) {
anyUpdates = true;
logger_1.logger.info();
utils.logSuccess(`${tool.displayName} configured - ${updatedCount} file${updatedCount > 1 ? "s" : ""} updated:`);
}
else {
logger_1.logger.info();
utils.logBullet(`${tool.displayName} - all files up to date`);
}
for (const file of result.files) {
const status = file.updated ? "(updated)" : "(unchanged)";
utils.logBullet(` ${file.path} ${status}`);
}
}
logger_1.logger.info();
if (anyUpdates) {
utils.logSuccess("AI tools configuration complete!");
logger_1.logger.info();
logger_1.logger.info("Next steps:");
utils.logBullet("Restart your AI tools to load the new configuration");
utils.logBullet("Try asking your AI assistant about your Firebase project structure");
utils.logBullet("AI assistants now understand Firebase CLI commands and debugging");
}
else {
utils.logSuccess("All AI tools are already up to date.");
}
}
exports.doSetup = doSetup;
function getEnabledFeatures(config) {
const features = [];
if (config.functions)
features.push("functions");
return features;
}