UNPKG

firebase-tools

Version:
43 lines (42 loc) 1.87 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.command = void 0; const command_1 = require("../command"); const projectUtils_1 = require("../projectUtils"); const error_1 = require("../error"); const utils_1 = require("../utils"); const apphosting = require("../gcp/apphosting"); const apphosting_backends_list_1 = require("./apphosting-backends-list"); exports.command = new command_1.Command("apphosting:backends:get <backend>") .description("print info about a Firebase App Hosting backend") .option("-l, --location <location>", "backend location") .before(apphosting.ensureApiEnabled) .action(async (backend, options) => { var _a; const projectId = (0, projectUtils_1.needProjectId)(options); if (options.location !== undefined) { (0, utils_1.logWarning)("--location is being removed in the next major release."); } const location = (_a = options.location) !== null && _a !== void 0 ? _a : "-"; let backendsList = []; try { if (location !== "-") { const backendInRegion = await apphosting.getBackend(projectId, location, backend); backendsList.push(backendInRegion); } else { const resp = await apphosting.listBackends(projectId, "-"); const allBackends = resp.backends || []; backendsList = allBackends.filter((bkd) => bkd.name.split("/").pop() === backend); } } catch (err) { throw new error_1.FirebaseError(`Failed to get backend: ${backend}. Please check the parameters you have provided.`, { original: (0, error_1.getError)(err) }); } if (backendsList.length === 0) { (0, utils_1.logWarning)(`Backend "${backend}" not found`); return; } (0, apphosting_backends_list_1.printBackendsTable)(backendsList); return backendsList[0]; });