<commit_before>import * as _ from "lodash";
import * as clc from "cli-color";
import * as ora from "ora";
import { Command } from "../command";
import { FirebaseError } from "../error";
import * as getProjectId from "../getProjectId";
import * as extensionsApi from "../extensions/extensionsApi";
import {
  ensureExtensionsApiEnabled,
  logPrefix,
  resourceTypeToNiceName,
} from "../extensions/extensionsHelper";
import { promptOnce } from "../prompt";
import { requirePermissions } from "../requirePermissions";
import * as utils from "../utils";
import * as logger from "../logger";

export default new Command("ext:uninstall <extensionInstanceId>")
  .description("uninstall an extension that is installed in your Firebase project by instance ID")
  .option("-f, --force", "No confirmation. Otherwise, a confirmation prompt will appear.")
  .before(requirePermissions, ["firebaseextensions.instances.delete"])
  .before(ensureExtensionsApiEnabled)
  .action(async (instanceId: string, options: any) => {
    const projectId = getProjectId(options);
    let instance;
    try {
      instance = await extensionsApi.getInstance(projectId, instanceId);
    } catch (err) {
      if (err.status === 404) {
        return utils.reject(`No extension instance ${instanceId} in project ${projectId}.`, {
          exit: 1,
        });
      }
      throw err;
    }
    if (!options.force) {<commit_msg>Redirect user to Console for uninstallation of pubsub-stream-bigquery (#2582)<commit_after>import * as _ from "lodash";
import * as clc from "cli-color";
import * as ora from "ora";
import * as marked from "marked";
import TerminalRenderer = require("marked-terminal");

import { Command } from "../command";
import { FirebaseError } from "../error";
import * as getProjectId from "../getProjectId";
import * as extensionsApi from "../extensions/extensionsApi";
import {
  ensureExtensionsApiEnabled,
  logPrefix,
  resourceTypeToNiceName,
} from "../extensions/extensionsHelper";
import { promptOnce } from "../prompt";
import { requirePermissions } from "../requirePermissions";
import * as utils from "../utils";
import * as logger from "../logger";

marked.setOptions({
  renderer: new TerminalRenderer(),
});

/**
 * We do not currently support uninstalling extensions that require additional uninstall steps to be taken in the CLI. Direct them to the Console to uninstall the extension.
 *
 * @param projectId ID of the user's project
 * @param instanceId ID of the extension instance
 * @return a void Promise
 */
function consoleUninstallOnly(projectId: string, instanceId: string): Promise<void> {
  const instanceURL = `https://console.firebase.google.com/project/${projectId}/extensions/instances/${instanceId}`;
  const consoleUninstall =
    "This extension has additional uninstall checks that are not currently supported by the CLI, and can only be uninstalled through the Firebase Console. " +
    `Please visit **[${instanceURL}](${instanceURL})** to uninstall this extension.`;
  logger.info("\n");
  utils.logLabeledWarning(logPrefix, marked(consoleUninstall));
  return Promise.resolve();
}

export default new Command("ext:uninstall <extensionInstanceId>")
  .description("uninstall an extension that is installed in your Firebase project by instance ID")
  .option("-f, --force", "No confirmation. Otherwise, a confirmation prompt will appear.")
  .before(requirePermissions, ["firebaseextensions.instances.delete"])
  .before(ensureExtensionsApiEnabled)
  .action(async (instanceId: string, options: any) => {
    const projectId = getProjectId(options);
    let instance;

    try {
      instance = await extensionsApi.getInstance(projectId, instanceId);
    } catch (err) {
      if (err.status === 404) {
        return utils.reject(`No extension instance ${instanceId} in project ${projectId}.`, {
          exit: 1,
        });
      }
      throw err;
    }

    // Special case for pubsub-stream-bigquery extension
    if (_.get(instance, "config.source.spec.name") === "pubsub-stream-bigquery") {
      return consoleUninstallOnly(projectId, instanceId);
    }

    if (!options.force) {
{'fraction_non_alphanumeric': 0.12597087378640776, 'fraction_numerical': 0.002912621359223301, 'mean_word_length': 4.100247524752476, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 8, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5370009', 'n_tokens_mistral': 1111, 'n_tokens_neox': 1095, 'n_words': 365}