UNPKG

firebase-tools

Version:
56 lines (55 loc) 2.34 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 prompt_1 = require("../prompt"); const utils = require("../utils"); const apphosting = require("../gcp/apphosting"); const apphosting_backends_list_1 = require("./apphosting-backends-list"); const backend_1 = require("../apphosting/backend"); const ora = require("ora"); exports.command = new command_1.Command("apphosting:backends:delete <backend>") .description("delete a Firebase App Hosting backend") .option("-l, --location <location>", "specify the location of the backend") .withForce() .before(apphosting.ensureApiEnabled) .action(async (backendId, options) => { var _a; const projectId = (0, projectUtils_1.needProjectId)(options); if (options.location !== undefined) { utils.logWarning("--location is being removed in the next major release."); } let location = (_a = options.location) !== null && _a !== void 0 ? _a : "-"; let backend; if (location === "-" || location === "") { backend = await (0, backend_1.getBackendForAmbiguousLocation)(projectId, backendId, "Please select the location of the backend you'd like to delete:"); location = apphosting.parseBackendName(backend.name).location; } else { backend = await (0, backend_1.getBackendForLocation)(projectId, location, backendId); } utils.logWarning("You are about to permanently delete this backend:"); (0, apphosting_backends_list_1.printBackendsTable)([backend]); const confirmDeletion = await (0, prompt_1.promptOnce)({ type: "confirm", name: "force", default: false, message: "Are you sure?", }, options); if (!confirmDeletion) { return; } const spinner = ora("Deleting backend...").start(); try { await (0, backend_1.deleteBackendAndPoll)(projectId, location, backendId); spinner.succeed(`Successfully deleted the backend: ${backendId}`); } catch (err) { spinner.stop(); throw new error_1.FirebaseError(`Failed to delete backend: ${backendId}.`, { original: (0, error_1.getError)(err), }); } });