import {
  ESBuild
} from "./chunk-X43BY2LQ.js";
import {
  Hello
} from "./chunk-SPJRFISZ.js";
import {
  World
} from "./chunk-U3C275WD.js";
import {
  init_default
} from "./chunk-CDZ5O4CJ.js";
import {
  require_ansis,
  require_lib,
  require_src
} from "./chunk-LPEKLRLJ.js";
import {
  require_lib as require_lib2
} from "./chunk-SO2G2ODZ.js";
import {
  require_semver
} from "./chunk-7EKGHPU5.js";
import {
  __toESM,
  init_cjs_shims
} from "./chunk-RRP6KXWN.js";

// src/index.ts
init_cjs_shims();
var import_core13 = __toESM(require_lib(), 1);

// node_modules/@oclif/plugin-plugins/lib/index.js
init_cjs_shims();

// node_modules/@oclif/plugin-plugins/lib/commands/plugins/index.js
init_cjs_shims();
var import_core5 = __toESM(require_lib(), 1);

// node_modules/ansis/index.mjs
init_cjs_shims();
var import_index = __toESM(require_ansis(), 1);
var { Ansis, ansi256, fg, bgAnsi256, bg, rgb, bgRgb, hex, bgHex, reset, inverse, hidden, visible, bold, dim, italic, underline, strikethrough, strike, black, red, green, yellow, blue, magenta, cyan, white, grey, gray, blackBright, redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bgGrey, bgGray, bgBlackBright, bgRedBright, bgGreenBright, bgYellowBright, bgBlueBright, bgMagentaBright, bgCyanBright, bgWhiteBright } = import_index.default;

// node_modules/object-treeify/lib/index.js
init_cjs_shims();

// node_modules/object-treeify/lib/assert.js
init_cjs_shims();
var assert_default = (condition, message) => {
  if (!condition) {
    throw new Error(message);
  }
};

// node_modules/object-treeify/lib/index.js
var buildCtx = (opts) => {
  const ctx = {
    joined: true,
    spacerNoNeighbour: "   ",
    spacerNeighbour: "\u2502  ",
    keyNoNeighbour: "\u2514\u2500 ",
    keyNeighbour: "\u251C\u2500 ",
    separator: ": ",
    renderFn: (node) => ["boolean", "string", "number"].includes(typeof node) ? node : void 0,
    sortFn: null,
    breakCircularWith: " (circular ref.)",
    ...opts
  };
  assert_default(Object.keys(ctx).length === 9, "Unexpected Option(s) provided");
  assert_default(typeof ctx.joined === "boolean", 'Option "joined" has invalid format');
  assert_default(typeof ctx.spacerNoNeighbour === "string", 'Option "spacerNoNeighbour" has invalid format');
  assert_default(typeof ctx.spacerNeighbour === "string", 'Option "spacerNeighbour" has invalid format');
  assert_default(typeof ctx.keyNoNeighbour === "string", 'Option "keyNoNeighbour" has invalid format');
  assert_default(typeof ctx.keyNeighbour === "string", 'Option "keyNeighbour" has invalid format');
  assert_default(typeof ctx.separator === "string", 'Option "separator" has invalid format');
  assert_default(typeof ctx.renderFn === "function", 'Option "renderFn" has invalid format');
  assert_default(typeof ctx.sortFn === "function" || ctx.sortFn === null, 'Option "sortFn" has invalid format');
  assert_default(
    typeof ctx.breakCircularWith === "string" || ctx.breakCircularWith === null,
    'Option "breakCircularWith" has invalid format'
  );
  return ctx;
};
var lib_default = (tree, opts = {}) => {
  const ctx = buildCtx(opts);
  const result = [];
  const rootRendered = ctx.renderFn(tree);
  if (rootRendered !== void 0) {
    result.push(String(rootRendered));
  }
  const sort = (input) => ctx.sortFn === null ? input.reverse() : input.sort((a2, b) => ctx.sortFn(b, a2));
  const neighbours = [];
  const keys = sort(Object.keys(tree)).map((k) => [k]);
  const lookup = [tree];
  while (keys.length !== 0) {
    const key = keys.pop();
    const node = lookup[key.length - 1][key[key.length - 1]];
    const isCircular = ctx.breakCircularWith !== null && lookup.includes(node);
    neighbours[key.length - 1] = keys.length !== 0 && keys[keys.length - 1].length === key.length;
    const nodeRendered = ctx.renderFn(node);
    result.push([
      neighbours.slice(0, key.length - 1).map((n) => n ? ctx.spacerNeighbour : ctx.spacerNoNeighbour).join(""),
      neighbours[key.length - 1] ? ctx.keyNeighbour : ctx.keyNoNeighbour,
      key[key.length - 1],
      nodeRendered === void 0 ? "" : `${ctx.separator}${node}`,
      isCircular ? ctx.breakCircularWith : ""
    ].join(""));
    if (node instanceof Object && !Array.isArray(node) && !isCircular) {
      keys.push(...sort(Object.keys(node)).map((k) => key.concat(k)));
      lookup[key.length] = node;
    }
  }
  return ctx.joined === true ? result.join("\n") : result;
};

// node_modules/@oclif/plugin-plugins/lib/plugins.js
init_cjs_shims();
var import_core4 = __toESM(require_lib(), 1);
var import_debug4 = __toESM(require_src(), 1);
var import_semver = __toESM(require_semver(), 1);
import { spawn as spawn2 } from "node:child_process";
import { access, mkdir, readFile as readFile2, rename, rm, writeFile } from "node:fs/promises";
import { basename, dirname, join as join2, parse, resolve } from "node:path";
import { fileURLToPath as fileURLToPath3 } from "node:url";

// node_modules/@oclif/plugin-plugins/lib/npm.js
init_cjs_shims();
var import_core2 = __toESM(require_lib(), 1);
var import_debug2 = __toESM(require_src(), 1);
import { readFile } from "node:fs/promises";
import { createRequire } from "node:module";
import { join, sep } from "node:path";

// node_modules/@oclif/plugin-plugins/lib/spawn.js
init_cjs_shims();
var import_core = __toESM(require_lib(), 1);
var import_debug = __toESM(require_src(), 1);
import { spawn as cpSpawn } from "node:child_process";

// node_modules/npm-run-path/index.js
init_cjs_shims();
import process2 from "node:process";
import path from "node:path";
import { fileURLToPath } from "node:url";

// node_modules/npm-run-path/node_modules/path-key/index.js
init_cjs_shims();
function pathKey(options = {}) {
  const {
    env = process.env,
    platform = process.platform
  } = options;
  if (platform !== "win32") {
    return "PATH";
  }
  return Object.keys(env).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
}

// node_modules/npm-run-path/index.js
var npmRunPath = ({
  cwd = process2.cwd(),
  path: pathOption = process2.env[pathKey()],
  preferLocal = true,
  execPath = process2.execPath,
  addExecPath = true
} = {}) => {
  const cwdString = cwd instanceof URL ? fileURLToPath(cwd) : cwd;
  const cwdPath = path.resolve(cwdString);
  const result = [];
  if (preferLocal) {
    applyPreferLocal(result, cwdPath);
  }
  if (addExecPath) {
    applyExecPath(result, execPath, cwdPath);
  }
  return [...result, pathOption].join(path.delimiter);
};
var applyPreferLocal = (result, cwdPath) => {
  let previous;
  while (previous !== cwdPath) {
    result.push(path.join(cwdPath, "node_modules/.bin"));
    previous = cwdPath;
    cwdPath = path.resolve(cwdPath, "..");
  }
};
var applyExecPath = (result, execPath, cwdPath) => {
  const execPathString = execPath instanceof URL ? fileURLToPath(execPath) : execPath;
  result.push(path.resolve(cwdPath, execPathString, ".."));
};
var npmRunPathEnv = ({ env = process2.env, ...options } = {}) => {
  env = { ...env };
  const pathName = pathKey({ env });
  options.path = env[pathName];
  env[pathName] = npmRunPath(options);
  return env;
};

// node_modules/@oclif/plugin-plugins/lib/spawn.js
var debug = (0, import_debug.default)("@oclif/plugin-plugins:spawn");
async function spawn(modulePath, args = [], { cwd, logLevel }) {
  return new Promise((resolve2, reject) => {
    if (process.platform === "win32" && modulePath.endsWith(".js")) {
      args.unshift(`"${modulePath}"`);
      modulePath = "node";
    }
    debug("modulePath", modulePath);
    debug("args", args);
    const spawned = cpSpawn(modulePath, args, {
      cwd,
      env: {
        ...npmRunPathEnv(),
        // Disable husky hooks because a plugin might be trying to install them, which will
        // break the install since the install location isn't a .git directory.
        HUSKY: "0"
      },
      stdio: "pipe",
      windowsVerbatimArguments: true,
      ...process.platform === "win32" && modulePath.toLowerCase().endsWith(".cmd") && { shell: true }
    });
    const possibleLastLinesOfNpmInstall = ["up to date", "added"];
    const stderr = [];
    const stdout = [];
    const loggedStderr = [];
    const loggedStdout = [];
    const shouldPrint = (str) => {
      const noOtherOutput = loggedStderr.length === 0 && loggedStdout.length === 0;
      const isLastLine = possibleLastLinesOfNpmInstall.some((line) => str.startsWith(line));
      if (noOtherOutput && isLastLine && logLevel === "notice") {
        return false;
      }
      return logLevel !== "silent";
    };
    spawned.stderr?.setEncoding("utf8");
    spawned.stderr?.on("data", (d) => {
      const output = d.toString().trim();
      stderr.push(output);
      if (shouldPrint(output)) {
        loggedStderr.push(output);
        import_core.ux.stdout(output);
      } else
        debug(output);
    });
    spawned.stdout?.setEncoding("utf8");
    spawned.stdout?.on("data", (d) => {
      const output = d.toString().trim();
      stdout.push(output);
      if (shouldPrint(output)) {
        loggedStdout.push(output);
        import_core.ux.stdout(output);
      } else
        debug(output);
    });
    spawned.on("error", reject);
    spawned.on("exit", (code) => {
      if (code === 0) {
        resolve2({ stderr, stdout });
      } else {
        reject(new import_core.Errors.CLIError(`${modulePath} ${args.join(" ")} exited with code ${code}`, {
          suggestions: ["Run with DEBUG=@oclif/plugin-plugins* to see debug output."]
        }));
      }
    });
  });
}

// node_modules/@oclif/plugin-plugins/lib/npm.js
var debug2 = (0, import_debug2.default)("@oclif/plugin-plugins:npm");
var NPM = class {
  bin;
  config;
  logLevel;
  constructor({ config, logLevel }) {
    this.config = config;
    this.logLevel = logLevel;
  }
  async exec(args = [], options) {
    const bin = await this.findNpm();
    debug2("npm binary path", bin);
    args.push(`--loglevel=${this.logLevel}`, "--no-fund");
    if (this.config.npmRegistry)
      args.push(`--registry=${this.config.npmRegistry}`);
    if (options.logLevel !== "notice" && options.logLevel !== "silent") {
      import_core2.ux.stderr(`${options.cwd}: ${bin} ${args.join(" ")}`);
    }
    debug2(`${options.cwd}: ${bin} ${args.join(" ")}`);
    try {
      const output = await spawn(bin, args, options);
      debug2("npm done");
      return output;
    } catch (error) {
      debug2("npm error", error);
      throw error;
    }
  }
  async install(args, opts) {
    const prod = opts.prod ? ["--omit", "dev"] : [];
    return this.exec(["install", ...args, ...prod, "--no-audit"], opts);
  }
  async uninstall(args, opts) {
    return this.exec(["uninstall", ...args], opts);
  }
  async update(args, opts) {
    return this.exec(["update", ...args], opts);
  }
  async view(args, opts) {
    return this.exec(["view", ...args], { ...opts, logLevel: "silent" });
  }
  /**
   * Get the path to the npm CLI file.
   * This will resolve npm to the pinned version in `@oclif/plugin-plugins/package.json` if it exists.
   * Otherwise, it will use the globally installed npm.
   *
   * @returns The path to the `npm/bin/npm-cli.js` file.
   */
  async findNpm() {
    if (this.bin)
      return this.bin;
    try {
      const npmPjsonPath = createRequire(import.meta.url).resolve("npm/package.json");
      const npmPjson = JSON.parse(await readFile(npmPjsonPath, { encoding: "utf8" }));
      const npmPath = npmPjsonPath.slice(0, Math.max(0, npmPjsonPath.lastIndexOf(sep)));
      this.bin = join(npmPath, npmPjson.bin.npm);
    } catch {
      const { default: which } = await import("./lib-EQZCZ6WM.js");
      this.bin = await which("npm");
    }
    if (!this.bin) {
      throw new import_core2.Errors.CLIError("npm not found");
    }
    return this.bin;
  }
};

// node_modules/@oclif/plugin-plugins/lib/util.js
init_cjs_shims();
function compare(a2, b) {
  const itemA = a2 === void 0 ? 0 : a2;
  const itemB = b === void 0 ? 0 : b;
  if (Array.isArray(itemA) && Array.isArray(itemB)) {
    if (itemA.length === 0 && itemB.length === 0)
      return 0;
    const diff = compare(itemA[0], itemB[0]);
    if (diff !== 0)
      return diff;
    return compare(itemA.slice(1), itemB.slice(1));
  }
  if (itemA < itemB)
    return -1;
  if (itemA > itemB)
    return 1;
  return 0;
}
function sortBy(arr, fn) {
  return arr.sort((a2, b) => compare(fn(a2), fn(b)));
}
function uniqWith(arr, fn) {
  return arr.filter((a2, i) => !arr.some((b, j) => j > i && fn(a2, b)));
}

// node_modules/@oclif/plugin-plugins/lib/yarn.js
init_cjs_shims();
var import_core3 = __toESM(require_lib(), 1);
var import_debug3 = __toESM(require_src(), 1);
import { createRequire as createRequire2 } from "node:module";
import { fileURLToPath as fileURLToPath2 } from "node:url";
var require2 = createRequire2(import.meta.url);
var debug3 = (0, import_debug3.default)("@oclif/plugin-plugins:yarn");
var Yarn = class {
  bin;
  config;
  logLevel;
  constructor({ config, logLevel }) {
    this.config = config;
    this.logLevel = logLevel;
  }
  async exec(args = [], options) {
    const bin = await this.findYarn();
    debug3("yarn binary path", bin);
    if (options.logLevel === "verbose")
      args.push("--verbose");
    if (this.config.npmRegistry)
      args.push(`--registry=${this.config.npmRegistry}`);
    if (options.logLevel !== "notice" && options.logLevel !== "silent") {
      import_core3.ux.stderr(`${options.cwd}: ${bin} ${args.join(" ")}`);
    }
    debug3(`${options.cwd}: ${bin} ${args.join(" ")}`);
    try {
      const output = await spawn(bin, args, options);
      debug3("yarn done");
      return output;
    } catch (error) {
      debug3("yarn error", error);
      throw error;
    }
  }
  async install(args, opts) {
    return this.exec(["install", ...args], opts);
  }
  async findYarn() {
    if (this.bin)
      return this.bin;
    try {
      this.bin = require2.resolve("yarn/bin/yarn.js", { paths: [this.config.root, fileURLToPath2(import.meta.url)] });
    } catch {
      const { default: which } = await import("./lib-EQZCZ6WM.js");
      this.bin = await which("yarn");
    }
    if (!this.bin) {
      throw new import_core3.Errors.CLIError("yarn not found");
    }
    return this.bin;
  }
};

// node_modules/@oclif/plugin-plugins/lib/plugins.js
var initPJSON = {
  dependencies: {},
  oclif: { plugins: [], schema: 1 },
  private: true
};
async function fileExists(filePath) {
  try {
    await access(filePath);
    return true;
  } catch {
    return false;
  }
}
function dedupePlugins(plugins) {
  return uniqWith(plugins, (a2, b) => a2.name === b.name || a2.type === "link" && b.type === "link" && a2.root === b.root);
}
function extractIssuesLocation(bugs, repository) {
  if (bugs) {
    return typeof bugs === "string" ? bugs : bugs.url;
  }
  if (repository) {
    return typeof repository === "string" ? repository : repository.url.replace("git+", "").replace(".git", "");
  }
}
function notifyUser(plugin, output) {
  const containsWarnings = [...output.stdout, ...output.stderr].some((l) => l.includes("npm WARN"));
  if (containsWarnings) {
    import_core4.ux.stderr(bold.yellow(`
These warnings can only be addressed by the owner(s) of ${plugin.name}.`));
    if (plugin.pjson.bugs || plugin.pjson.repository) {
      import_core4.ux.stderr(`We suggest that you create an issue at ${extractIssuesLocation(plugin.pjson.bugs, plugin.pjson.repository)} and ask the plugin owners to address them.
`);
    }
  }
}
function normaliseTag(jitPlugins, modifiedPlugins, p) {
  if (!(0, import_semver.valid)(p.tag))
    return `${p.name}@${p.tag}`;
  if (p.tag && (0, import_semver.valid)(p.tag) && jitPlugins[p.name] && (0, import_semver.valid)(jitPlugins[p.name]) && (0, import_semver.gt)(p.tag, jitPlugins[p.name])) {
    return `${p.name}@${p.tag}`;
  }
  const tag = jitPlugins[p.name] ?? p.tag;
  modifiedPlugins.push({ ...p, tag });
  return `${p.name}@${tag}`;
}
var Plugins = class {
  config;
  npm;
  debug;
  logLevel;
  constructor(options) {
    this.config = options.config;
    this.debug = (0, import_debug4.default)("@oclif/plugin-plugins");
    this.logLevel = options.logLevel ?? "notice";
    this.npm = new NPM({
      config: this.config,
      logLevel: this.logLevel
    });
  }
  get pjsonPath() {
    return join2(this.config.dataDir, "package.json");
  }
  async add(...plugins) {
    const pjson = await this.pjson();
    const mergedPlugins = [...pjson.oclif.plugins || [], ...plugins];
    await this.savePJSON({
      ...pjson,
      oclif: {
        ...pjson.oclif,
        plugins: dedupePlugins(mergedPlugins)
      }
    });
  }
  friendlyName(name) {
    const { pluginPrefix, scope } = this.config.pjson.oclif;
    if (!scope)
      return name;
    const match = name.match(`@${scope}/${pluginPrefix ?? "plugin"}-(.+)`);
    return match?.[1] ?? name;
  }
  async hasPlugin(name) {
    const list = await this.list();
    const friendlyName = this.friendlyName(name);
    const unfriendlyName = this.unfriendlyName(name) ?? name;
    return list.find((p) => this.friendlyName(p.name) === friendlyName) ?? // friendly
    list.find((p) => this.unfriendlyName(p.name) === unfriendlyName) ?? // unfriendly
    list.find((p) => p.type === "link" && resolve(p.root) === resolve(name)) ?? // link
    false;
  }
  async install(name, { force = false, tag = "latest" } = {}) {
    await this.maybeCleanUp();
    try {
      this.debug(`installing plugin ${name}`);
      const options = { cwd: this.config.dataDir, logLevel: this.logLevel, prod: true };
      await this.ensurePJSON();
      let plugin;
      const args = force ? ["--force"] : [];
      if (name.includes(":")) {
        const url = name;
        const output = await this.npm.install([...args, url], options);
        const { dependencies } = await this.pjson();
        const { default: npa } = await import("./npa-MSYXREUM.js");
        const normalizedUrl = npa(url);
        const matches = Object.entries(dependencies ?? {}).find(([, npmVersion]) => {
          const normalized = npa(npmVersion);
          if (normalized.type !== normalizedUrl.type) {
            return false;
          }
          if (normalized.type === "file" && normalized.raw) {
            return parse(url).base === parse(normalized.raw).base;
          }
          return normalized.hosted?.type === normalizedUrl.hosted?.type && normalized.hosted?.user === normalizedUrl.hosted?.user && normalized.hosted?.project === normalizedUrl.hosted?.project;
        });
        const installedPluginName = matches?.[0];
        if (!installedPluginName)
          throw new import_core4.Errors.CLIError(`Could not find plugin name for ${url}`);
        const root = join2(this.config.dataDir, "node_modules", installedPluginName);
        plugin = await import_core4.Config.load({
          devPlugins: false,
          name: installedPluginName,
          root,
          userPlugins: false
        });
        notifyUser(plugin, output);
        this.isValidPlugin(plugin);
        await this.add({ name: installedPluginName, type: "user", url });
        const safeToNotExist = /* @__PURE__ */ new Set(["npm-shrinkwrap.json", "oclif.lock", "oclif.manifest.json"]);
        const files = (plugin.pjson.files ?? []).map((f) => join2(root, f)).filter((f) => !safeToNotExist.has(basename(f)));
        this.debug(`checking for existence of files: ${files.join(", ")}`);
        const results = Object.fromEntries(await Promise.all(files?.map(async (f) => [f, await fileExists(f)]) ?? []));
        this.debug(results);
        if (!Object.values(results).every(Boolean)) {
          import_core4.ux.warn(`This plugin may not work as expected because the prepare script did not produce all the expected files.`);
        }
      } else {
        const range = (0, import_semver.validRange)(tag);
        const unfriendly = this.unfriendlyName(name);
        if (unfriendly && await this.npmHasPackage(unfriendly)) {
          name = unfriendly;
        }
        await this.npmHasPackage(name, true);
        const output = await this.npm.install([...args, `${name}@${tag}`], options);
        this.debug(`loading plugin ${name}...`);
        plugin = await import_core4.Config.load({
          devPlugins: false,
          name,
          root: join2(this.config.dataDir, "node_modules", name),
          userPlugins: false
        });
        this.debug(`finished loading plugin ${name} at root ${plugin.root}`);
        notifyUser(plugin, output);
        this.isValidPlugin(plugin);
        await this.add({ name, tag: range ?? tag, type: "user" });
      }
      await rm(join2(this.config.dataDir, "yarn.lock"), { force: true });
      return plugin;
    } catch (error) {
      this.debug("error installing plugin:", error);
      await this.uninstall(name).catch((error2) => this.debug(error2));
      if (String(error).includes("EACCES")) {
        throw new import_core4.Errors.CLIError(error, {
          suggestions: [
            `Plugin failed to install because of a permissions error.
Does your current user own the directory ${this.config.dataDir}?`
          ]
        });
      }
      throw error;
    }
  }
  async link(p, { install }) {
    const c = await import_core4.Config.load(resolve(p));
    this.isValidPlugin(c);
    if (install) {
      if (await fileExists(join2(c.root, "yarn.lock"))) {
        this.debug("installing dependencies with yarn");
        const yarn = new Yarn({ config: this.config, logLevel: this.logLevel });
        import_core4.ux.warn(`The ${import_core4.ux.colorize("dim", "plugins link")} command will no longer auto install dependencies in future versions. Please run ${import_core4.ux.colorize("dim", "yarn")} manually in the plugin directory before linking.`);
        await yarn.install([], {
          cwd: c.root,
          logLevel: this.logLevel
        });
      } else if (await fileExists(join2(c.root, "package-lock.json"))) {
        this.debug("installing dependencies with npm");
        await this.npm.install([], {
          cwd: c.root,
          logLevel: this.logLevel,
          prod: false
        });
      } else if (await fileExists(join2(c.root, "pnpm-lock.yaml"))) {
        import_core4.ux.warn(`pnpm is not supported for installing after a link. The link succeeded, but you may need to run 'pnpm install' in ${c.root}.`);
      } else {
        import_core4.ux.warn(`No lockfile found in ${c.root}. The link succeeded, but you may need to install the dependencies in your project.`);
      }
    }
    await this.add({ name: c.name, root: c.root, type: "link" });
    return c;
  }
  async list() {
    const pjson = await this.pjson();
    return pjson.oclif.plugins;
  }
  async maybeUnfriendlyName(name) {
    await this.ensurePJSON();
    const unfriendly = this.unfriendlyName(name);
    this.debug(`checking registry for expanded package name ${unfriendly}`);
    if (unfriendly && await this.npmHasPackage(unfriendly)) {
      return unfriendly;
    }
    this.debug(`expanded package name ${unfriendly} not found, using given package name ${name}`);
    return name;
  }
  async pjson() {
    const pjson = await this.readPJSON();
    const plugins = pjson ? normalizePlugins(pjson.oclif.plugins) : [];
    return {
      ...initPJSON,
      ...pjson,
      oclif: {
        ...initPJSON.oclif,
        ...pjson?.oclif,
        plugins
      }
    };
  }
  async remove(name) {
    const pjson = await this.pjson();
    if (pjson.dependencies)
      delete pjson.dependencies[name];
    await this.savePJSON({
      ...pjson,
      oclif: {
        ...pjson.oclif,
        plugins: pjson.oclif.plugins.filter((p) => p.name !== name)
      }
    });
  }
  unfriendlyName(name) {
    if (name.includes("@"))
      return;
    const { pluginPrefix, scope } = this.config.pjson.oclif;
    if (!scope)
      return;
    return `@${scope}/${pluginPrefix ?? "plugin"}-${name}`;
  }
  async uninstall(name) {
    try {
      const pjson = await this.pjson();
      if ((pjson.oclif.plugins ?? []).some((p) => typeof p === "object" && p.type === "user" && p.name === name)) {
        await this.npm.uninstall([name], {
          cwd: this.config.dataDir,
          logLevel: this.logLevel
        });
      }
    } catch (error) {
      import_core4.ux.warn(error);
    } finally {
      await this.remove(name);
    }
  }
  async update() {
    let plugins = (await this.list()).filter((p) => p.type === "user");
    if (plugins.length === 0)
      return;
    await this.maybeCleanUp();
    const aliases = this.config.pjson.oclif.aliases || {};
    for (const [name, to] of Object.entries(aliases)) {
      const plugin = plugins.find((p) => p.name === name);
      if (!plugin)
        continue;
      if (to)
        await this.install(to);
      await this.uninstall(name);
      plugins = plugins.filter((p) => p.name !== name);
    }
    const urlPlugins = plugins.filter((p) => Boolean(p.url));
    if (urlPlugins.length > 0) {
      await this.npm.update(urlPlugins.map((p) => p.name), {
        cwd: this.config.dataDir,
        logLevel: this.logLevel
      });
    }
    const npmPlugins = plugins.filter((p) => !p.url);
    const jitPlugins = this.config.pjson.oclif.jitPlugins ?? {};
    const modifiedPlugins = [];
    if (npmPlugins.length > 0) {
      await this.npm.install(npmPlugins.map((p) => normaliseTag(jitPlugins, modifiedPlugins, p)), { cwd: this.config.dataDir, logLevel: this.logLevel, prod: true });
    }
    await this.add(...modifiedPlugins);
  }
  async ensurePJSON() {
    if (!await fileExists(this.pjsonPath)) {
      this.debug(`creating ${this.pjsonPath} with pjson: ${JSON.stringify(initPJSON, null, 2)}`);
      await this.savePJSON(initPJSON);
    }
  }
  isValidPlugin(p) {
    if (p.valid)
      return true;
    if (this.config.plugins.get("@oclif/plugin-legacy") || // @ts-expect-error because _base is private
    p._base.includes("@oclif/plugin-legacy")) {
      return true;
    }
    throw new import_core4.Errors.CLIError("plugin is invalid", {
      suggestions: [
        "Plugin failed to install because it does not appear to be a valid CLI plugin.\nIf you are sure it is, contact the CLI developer noting this error."
      ]
    });
  }
  async maybeCleanUp() {
    if (await fileExists(join2(this.config.dataDir, "yarn.lock"))) {
      try {
        this.debug("Found yarn.lock! Removing yarn.lock and node_modules...");
        await Promise.all([
          rename(join2(this.config.dataDir, "node_modules"), join2(this.config.dataDir, "node_modules.old")),
          rm(join2(this.config.dataDir, "yarn.lock"), { force: true })
        ]);
        const rmScript = join2(dirname(fileURLToPath3(import.meta.url)), "rm.js");
        this.debug(`spawning ${rmScript} to remove node_modules.old`);
        spawn2(process.argv[0], [rmScript, join2(this.config.dataDir, "node_modules.old")], {
          detached: true,
          stdio: "ignore",
          ...this.config.windows ? { shell: true } : {}
        }).unref();
      } catch (error) {
        this.debug("Error cleaning up yarn.lock and node_modules:", error);
      }
    }
  }
  async npmHasPackage(name, throwOnNotFound = false) {
    try {
      await this.npm.view([name], {
        cwd: this.config.dataDir,
        logLevel: this.logLevel
      });
      this.debug(`Found ${name} in the registry.`);
      return true;
    } catch (error) {
      this.debug(error);
      if (throwOnNotFound)
        throw new import_core4.Errors.CLIError(`${name} does not exist in the registry.`);
      return false;
    }
  }
  async readPJSON() {
    try {
      return JSON.parse(await readFile2(this.pjsonPath, "utf8"));
    } catch (error) {
      this.debug(error);
      const err = error;
      if (err.code !== "ENOENT")
        process.emitWarning(err);
    }
  }
  async savePJSON(pjson) {
    await mkdir(dirname(this.pjsonPath), { recursive: true });
    await writeFile(this.pjsonPath, JSON.stringify({ name: this.config.name, ...pjson }, null, 2));
  }
};
var normalizePlugins = (input) => {
  const normalized = (input ?? []).map((p) => typeof p === "string" ? {
    name: p,
    tag: "latest",
    type: "user"
  } : p);
  return dedupePlugins(normalized);
};

// node_modules/@oclif/plugin-plugins/lib/commands/plugins/index.js
var PluginsIndex = class _PluginsIndex extends import_core5.Command {
  static description = "List installed plugins.";
  static enableJsonFlag = true;
  static examples = ["<%= config.bin %> <%= command.id %>"];
  static flags = {
    core: import_core5.Flags.boolean({ description: "Show core plugins." })
  };
  plugins;
  async run() {
    const { flags } = await this.parse(_PluginsIndex);
    this.plugins = new Plugins({
      config: this.config
    });
    let plugins = this.config.getPluginsList();
    sortBy(plugins, (p) => this.plugins.friendlyName(p.name));
    if (!flags.core) {
      plugins = plugins.filter((p) => p.type !== "core" && p.type !== "dev");
    }
    if (plugins.length === 0)
      this.log("No plugins installed.");
    const results = this.config.getPluginsList();
    const userAndLinkedPlugins = new Set(results.filter((p) => p.type === "user" || p.type === "link").map((p) => p.name));
    const jitPluginsConfig = this.config.pjson.oclif.jitPlugins ?? {};
    const jitPlugins = Object.entries(jitPluginsConfig).map(([name, version]) => ({ name, type: "jit", version })).filter((p) => !userAndLinkedPlugins.has(p.name));
    sortBy(jitPlugins, (p) => p.name);
    if (!this.jsonEnabled()) {
      this.display(plugins);
      this.displayJitPlugins(jitPlugins);
    }
    return [
      ...results.filter((p) => !p.parent).map((p) => {
        const { config, ...rest } = p;
        return rest;
      }),
      ...jitPlugins
    ];
  }
  createTree(plugin) {
    const tree = {};
    for (const p of plugin.children ?? []) {
      tree[this.formatPlugin(p)] = this.createTree(p);
    }
    return tree;
  }
  display(plugins) {
    const rootPlugin = plugins.find((p) => p.root === this.config.root);
    for (const plugin of plugins.filter((p) => !p.parent)) {
      if (plugin.name === rootPlugin?.name)
        continue;
      this.log(this.formatPlugin(plugin));
      if (plugin.children && plugin.children.length > 0) {
        const tree = this.createTree(plugin);
        this.log(lib_default(tree));
      }
    }
  }
  displayJitPlugins(jitPlugins) {
    if (jitPlugins.length === 0)
      return;
    this.log(dim("\nUninstalled JIT Plugins:"));
    for (const { name, version } of jitPlugins) {
      this.log(`${this.plugins.friendlyName(name)} ${dim(version)}`);
    }
  }
  formatPlugin(plugin) {
    let output = `${this.plugins.friendlyName(plugin.name)} ${dim(plugin.version)}`;
    if (plugin.type !== "user")
      output += dim(` (${plugin.type})`);
    if (plugin.type === "link")
      output += ` ${plugin.root}`;
    else if (plugin.tag && plugin.tag !== "latest")
      output += dim(` (${String(plugin.tag)})`);
    return output;
  }
};

// node_modules/@oclif/plugin-plugins/lib/commands/plugins/inspect.js
init_cjs_shims();
var import_core6 = __toESM(require_lib(), 1);
import { readFile as readFile3 } from "node:fs/promises";
import { dirname as dirname2, join as join3, sep as sep2 } from "node:path";

// node_modules/@oclif/plugin-plugins/lib/log-level.js
init_cjs_shims();
var LOG_LEVELS = ["silent", "error", "warn", "notice", "http", "info", "verbose", "silly"];
function determineLogLevel(config, flags, defaultLevel) {
  if (flags.verbose)
    return "verbose";
  if (flags.silent)
    return "silent";
  const envVar = config.scopedEnvVar("NPM_LOG_LEVEL");
  if (LOG_LEVELS.includes(envVar))
    return envVar;
  return defaultLevel;
}

// node_modules/@oclif/plugin-plugins/lib/commands/plugins/inspect.js
function trimUntil(fsPath, part) {
  const parts = fsPath.split(sep2);
  const indices = parts.reduce((result, current, index) => current === part ? [...result, index] : result, []);
  const partIndex = Math.max(...indices);
  if (partIndex === -1)
    return fsPath;
  return parts.slice(0, partIndex + 1).join(sep2);
}
var PluginsInspect = class _PluginsInspect extends import_core6.Command {
  static args = {
    plugin: import_core6.Args.string({
      default: ".",
      description: "Plugin to inspect.",
      required: true
    })
  };
  static description = "Displays installation properties of a plugin.";
  static enableJsonFlag = true;
  static examples = ['<%= config.bin %> <%= command.id %> <%- config.pjson.oclif.examplePlugin || "myplugin" %> '];
  static flags = {
    help: import_core6.Flags.help({ char: "h" }),
    verbose: import_core6.Flags.boolean({ char: "v" })
  };
  static strict = false;
  static usage = "plugins:inspect PLUGIN...";
  plugins;
  async findDep(plugin, dependency) {
    const dependencyPath = join3(...dependency.split("/"));
    let start = join3(plugin.root, "node_modules");
    const paths = [start];
    while ((start.match(/node_modules/g) ?? []).length > 1) {
      start = trimUntil(dirname2(start), "node_modules");
      paths.push(start);
    }
    for (const p of paths) {
      try {
        const fullPath = join3(p, dependencyPath);
        const pkgJsonPath = join3(fullPath, "package.json");
        const pkgJson = JSON.parse(await readFile3(pkgJsonPath, "utf8"));
        return { pkgPath: fullPath, version: pkgJson.version };
      } catch {
      }
    }
    return { pkgPath: null, version: null };
  }
  findPlugin(pluginName) {
    const pluginConfig = this.config.getPluginsList().find((plg) => plg.name === pluginName);
    if (pluginConfig)
      return pluginConfig;
    if (this.config.pjson.oclif.jitPlugins?.[pluginName]) {
      this.warn(`Plugin ${pluginName} is a JIT plugin. It will be installed the first time you run one of it's commands.`);
    }
    throw new Error(`${pluginName} not installed`);
  }
  async inspect(pluginName, verbose = false) {
    const plugin = this.findPlugin(pluginName);
    const dependencies = {};
    const depsJson = {};
    for (const dep of sortBy(Object.keys({ ...plugin.pjson.dependencies }), (d) => d)) {
      const { pkgPath, version } = await this.findDep(plugin, dep);
      if (!version)
        continue;
      const from = plugin.pjson.dependencies?.[dep];
      const versionMsg = dim(from ? `${from} => ${version}` : version);
      const msg = verbose ? `${dep} ${versionMsg} ${pkgPath}` : `${dep} ${versionMsg}`;
      dependencies[msg] = null;
      depsJson[dep] = { from, version };
    }
    const tree = {
      [bold.cyan(plugin.name)]: {
        [`version ${plugin.version}`]: null,
        ...plugin.tag ? { [`tag ${plugin.tag}`]: null } : {},
        ...plugin.pjson.homepage ? { [`homepage ${plugin.pjson.homepage}`]: null } : {},
        [`location ${plugin.root}`]: null,
        commands: Object.fromEntries(sortBy(plugin.commandIDs, (c) => c).map((id) => [id, null])),
        dependencies
      }
    };
    this.log(lib_default(tree));
    return { ...plugin, deps: depsJson };
  }
  /* eslint-disable no-await-in-loop */
  async run() {
    const { argv, flags } = await this.parse(_PluginsInspect);
    this.plugins = new Plugins({
      config: this.config,
      logLevel: determineLogLevel(this.config, flags, "silent")
    });
    const aliases = this.config.pjson.oclif.aliases ?? {};
    const plugins = [];
    for (let name of argv) {
      if (name === ".") {
        const pkgJson = JSON.parse(await readFile3("package.json", "utf8"));
        name = pkgJson.name;
      }
      if (aliases[name] === null)
        this.error(`${name} is blocked`);
      name = aliases[name] ?? name;
      const pluginName = await this.plugins.maybeUnfriendlyName(name) ?? name;
      try {
        plugins.push(await this.inspect(pluginName, flags.verbose));
      } catch (error) {
        this.log(bold.red("failed"));
        throw error;
      }
    }
    return plugins;
  }
};

// node_modules/@oclif/plugin-plugins/lib/commands/plugins/install.js
init_cjs_shims();
var import_core7 = __toESM(require_lib(), 1);
var import_validate_npm_package_name = __toESM(require_lib2(), 1);
var PluginsInstall = class _PluginsInstall extends import_core7.Command {
  static aliases = ["plugins:add"];
  static args = {
    plugin: import_core7.Args.string({ description: "Plugin to install.", required: true })
  };
  static description = `Uses npm to install plugins.

Installation of a user-installed plugin will override a core plugin.

Use the <%= config.scopedEnvVarKey('NPM_LOG_LEVEL') %> environment variable to set the npm loglevel.
Use the <%= config.scopedEnvVarKey('NPM_REGISTRY') %> environment variable to set the npm registry.`;
  static enableJsonFlag = true;
  static examples = [
    {
      command: '<%= config.bin %> <%= command.id %> <%- config.pjson.oclif.examplePlugin || "myplugin" %> ',
      description: "Install a plugin from npm registry."
    },
    {
      command: "<%= config.bin %> <%= command.id %> https://github.com/someuser/someplugin",
      description: "Install a plugin from a github url."
    },
    {
      command: "<%= config.bin %> <%= command.id %> someuser/someplugin",
      description: "Install a plugin from a github slug."
    }
  ];
  static flags = {
    force: import_core7.Flags.boolean({
      char: "f",
      description: "Force npm to fetch remote resources even if a local copy exists on disk."
    }),
    help: import_core7.Flags.help({ char: "h" }),
    jit: import_core7.Flags.boolean({
      hidden: true,
      async parse(input, ctx) {
        if (input === false || input === void 0)
          return input;
        const requestedPlugins = ctx.argv.filter((a2) => !a2.startsWith("-"));
        if (requestedPlugins.length === 0)
          return input;
        const jitPluginsConfig = ctx.config.pjson.oclif.jitPlugins ?? {};
        if (Object.keys(jitPluginsConfig).length === 0)
          return input;
        const plugins = new Plugins({ config: ctx.config });
        const nonJitPlugins = await Promise.all(requestedPlugins.map(async (plugin) => {
          const name = await plugins.maybeUnfriendlyName(plugin);
          return { jit: Boolean(jitPluginsConfig[name]), name };
        }));
        const nonJitPluginsNames = nonJitPlugins.filter((p) => !p.jit).map((p) => p.name);
        if (nonJitPluginsNames.length > 0) {
          throw new import_core7.Errors.CLIError(`The following plugins are not JIT plugins: ${nonJitPluginsNames.join(", ")}`);
        }
        return input;
      }
    }),
    silent: import_core7.Flags.boolean({
      char: "s",
      description: "Silences npm output.",
      exclusive: ["verbose"]
    }),
    verbose: import_core7.Flags.boolean({
      char: "v",
      description: "Show verbose npm output.",
      exclusive: ["silent"]
    })
  };
  static strict = false;
  static summary = "Installs a plugin into <%= config.bin %>.";
  flags;
  // In this case we want these operations to happen
  // sequentially so the `no-await-in-loop` rule is ignored
  async parsePlugin(plugins, input) {
    if (input.startsWith("git+ssh://") || input.endsWith(".git")) {
      return { type: "repo", url: input };
    }
    const getNameAndTag = async (input2) => {
      const regexAtSymbolNotAtBeginning = /(?<!^)@/;
      const [splitName, tag2 = "latest"] = input2.split(regexAtSymbolNotAtBeginning);
      const name2 = splitName.startsWith("@") ? splitName : await plugins.maybeUnfriendlyName(splitName);
      validateNpmPkgName(name2);
      if (this.flags.jit) {
        const jitVersion = this.config.pjson.oclif?.jitPlugins?.[name2];
        if (jitVersion) {
          if (regexAtSymbolNotAtBeginning.test(input2))
            this.warn(`--jit flag is present along side a tag. Ignoring tag ${tag2} and using the version specified in package.json (${jitVersion}).`);
          return { name: name2, tag: jitVersion };
        }
        this.warn(`--jit flag is present but ${name2} is not a JIT plugin. Installing ${tag2} instead.`);
        return { name: name2, tag: tag2 };
      }
      return { name: name2, tag: tag2 };
    };
    if (input.startsWith("@") && input.includes("/")) {
      const { name: name2, tag: tag2 } = await getNameAndTag(input);
      return { name: name2, tag: tag2, type: "npm" };
    }
    if (input.includes("/")) {
      if (input.includes(":"))
        return { type: "repo", url: input };
      return { type: "repo", url: `https://github.com/${input}` };
    }
    const { name, tag } = await getNameAndTag(input);
    return { name, tag, type: "npm" };
  }
  async run() {
    const { argv, flags } = await this.parse(_PluginsInstall);
    this.flags = flags;
    const plugins = new Plugins({
      config: this.config,
      logLevel: determineLogLevel(this.config, this.flags, "notice")
    });
    const aliases = this.config.pjson.oclif.aliases || {};
    const count = argv.length;
    for (let name of argv) {
      if (aliases[name] === null)
        this.error(`${name} is blocked`);
      name = aliases[name] || name;
      if (name === this.config.name) {
        const updateInstructions = (
          // this.config.binPath is set when the CLI is installed from an installer but not when it's installed from npm
          this.config.binPath && this.config.plugins.get("@oclif/plugin-update") ? ` Use "${this.config.bin} update" to update ${this.config.name}.` : ""
        );
        const msg = `Ignoring top-level CLI plugin ${this.config.name}.${updateInstructions}`;
        if (count === 1) {
          this.error(msg);
        } else {
          this.warn(msg);
        }
        continue;
      }
      const p = await this.parsePlugin(plugins, name);
      let plugin;
      await this.config.runHook("plugins:preinstall", {
        plugin: p
      });
      try {
        if (p.type === "npm") {
          import_core7.ux.action.start(`${this.config.name}: Installing plugin ${cyan(plugins.friendlyName(p.name) + "@" + p.tag)}`);
          plugin = await plugins.install(p.name, {
            force: flags.force,
            tag: p.tag
          });
        } else {
          import_core7.ux.action.start(`${this.config.name}: Installing plugin ${cyan(p.url)}`);
          plugin = await plugins.install(p.url, { force: flags.force });
        }
      } catch (error) {
        import_core7.ux.action.stop(bold.red("failed"));
        throw error;
      }
      const pluginInstance = new import_core7.Plugin(plugin);
      await pluginInstance.load();
      this.config.plugins.set(pluginInstance.name, pluginInstance);
      await this.config.runHook("plugins:postinstall", {});
      import_core7.ux.action.stop(`installed v${plugin.version}`);
    }
  }
};
function validateNpmPkgName(name) {
  if (!(0, import_validate_npm_package_name.default)(name).validForNewPackages) {
    throw new import_core7.Errors.CLIError("Invalid npm package name.");
  }
}

// node_modules/@oclif/plugin-plugins/lib/commands/plugins/link.js
init_cjs_shims();
var import_core8 = __toESM(require_lib(), 1);
var PluginsLink = class _PluginsLink extends import_core8.Command {
  static args = {
    path: import_core8.Args.string({ default: ".", description: "path to plugin", name: "path", required: true })
  };
  static description = `Installation of a linked plugin will override a user-installed or core plugin.

e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello' command will override the user-installed or core plugin implementation. This is useful for development work.
`;
  static examples = ['<%= config.bin %> <%= command.id %> <%- config.pjson.oclif.examplePlugin || "myplugin" %> '];
  static flags = {
    help: import_core8.Flags.help({ char: "h" }),
    install: import_core8.Flags.boolean({
      allowNo: true,
      default: true,
      description: "Install dependencies after linking the plugin."
    }),
    verbose: import_core8.Flags.boolean({ char: "v" })
  };
  static summary = "Links a plugin into the CLI for development.";
  async run() {
    const { args, flags } = await this.parse(_PluginsLink);
    const plugins = new Plugins({
      config: this.config,
      logLevel: determineLogLevel(this.config, flags, "silent")
    });
    import_core8.ux.action.start(`${this.config.name}: Linking plugin ${cyan(args.path)}`);
    await plugins.link(args.path, { install: flags.install });
    import_core8.ux.action.stop();
  }
};

// node_modules/@oclif/plugin-plugins/lib/commands/plugins/reset.js
init_cjs_shims();
var import_core9 = __toESM(require_lib(), 1);
import { rm as rm2 } from "node:fs/promises";
import { join as join4 } from "node:path";
var Reset = class _Reset extends import_core9.Command {
  static flags = {
    hard: import_core9.Flags.boolean({
      summary: "Delete node_modules and package manager related files in addition to uninstalling plugins."
    }),
    reinstall: import_core9.Flags.boolean({
      summary: "Reinstall all plugins after uninstalling."
    })
  };
  static summary = "Remove all user-installed and linked plugins.";
  // eslint-disable-next-line complexity
  async run() {
    const { flags } = await this.parse(_Reset);
    const plugins = new Plugins({
      config: this.config
    });
    const userPlugins = await plugins.list();
    this.log(`Found ${userPlugins.length} plugin${userPlugins.length === 0 ? "" : "s"}:`);
    for (const plugin of userPlugins) {
      this.log(`- ${plugin.name} ${dim(this.config.plugins.get(plugin.name)?.version ?? "")} ${dim(`(${plugin.type})`)}`);
    }
    if (flags.hard) {
      const filesToDelete = [
        join4(this.config.dataDir, "node_modules"),
        join4(this.config.dataDir, "package.json"),
        join4(this.config.dataDir, "yarn.lock"),
        join4(this.config.dataDir, "package-lock.json")
      ];
      this.log("\u2705 Removed the following files:");
      for (const file of filesToDelete) {
        this.log(`- ${file}`);
      }
      await Promise.all(filesToDelete.map((file) => rm2(file, { force: true, recursive: true })));
      for (const plugin of userPlugins) {
        this.log(`\u2705 ${plugin.type === "link" ? "Unlinked" : "Uninstalled"} ${plugin.name}`);
      }
    } else {
      for (const plugin of userPlugins) {
        try {
          await plugins.uninstall(plugin.name);
          this.log(`\u2705 ${plugin.type === "link" ? "Unlinked" : "Uninstalled"} ${plugin.name}`);
        } catch {
          this.warn(`Failed to uninstall ${plugin.name}`);
        }
      }
    }
    if (flags.reinstall) {
      this.log("Reinstall flag passed:");
      for (const plugin of userPlugins) {
        if (plugin.type === "link") {
          try {
            const newPlugin = await plugins.link(plugin.root, { install: false });
            const newVersion = dim(`-> ${newPlugin.version}`);
            this.log(`\u2705 Relinked ${plugin.name} ${newVersion}`);
          } catch {
            this.warn(`Failed to relink ${plugin.name}`);
          }
        }
        if (plugin.type === "user") {
          try {
            const newPlugin = plugin.url ? await plugins.install(plugin.url) : await plugins.install(plugin.name, { tag: plugin.tag });
            const newVersion = dim(`-> ${newPlugin.version}`);
            const tag = plugin.tag ? `@${plugin.tag}` : plugin.url ? ` (${plugin.url})` : "";
            this.log(`\u2705 Reinstalled ${plugin.name}${tag} ${newVersion}`);
          } catch {
            this.warn(`Failed to reinstall ${plugin.name}`);
          }
        }
      }
    }
  }
};

// node_modules/@oclif/plugin-plugins/lib/commands/plugins/uninstall.js
init_cjs_shims();
var import_core10 = __toESM(require_lib(), 1);
function removeTags(plugin) {
  if (plugin.includes("@")) {
    const chunked = plugin.split("@");
    const last = chunked.at(-1);
    if (!last?.includes("/") && chunked.length > 1) {
      chunked.pop();
    }
    return chunked.join("@");
  }
  return plugin;
}
var PluginsUninstall = class _PluginsUninstall extends import_core10.Command {
  static aliases = ["plugins:unlink", "plugins:remove"];
  static args = {
    plugin: import_core10.Args.string({ description: "plugin to uninstall" })
  };
  static description = "Removes a plugin from the CLI.";
  static examples = ['<%= config.bin %> <%= command.id %> <%- config.pjson.oclif.examplePlugin || "myplugin" %>'];
  static flags = {
    help: import_core10.Flags.help({ char: "h" }),
    verbose: import_core10.Flags.boolean({ char: "v" })
  };
  static strict = false;
  // In this case we want these operations to happen
  // sequentially so the `no-await-in-loop` rule is ignored
  async run() {
    const { argv, flags } = await this.parse(_PluginsUninstall);
    const plugins = new Plugins({
      config: this.config,
      logLevel: determineLogLevel(this.config, flags, "silent")
    });
    const pluginNameToDelete = [];
    if (argv.length === 0)
      argv.push(".");
    for (const plugin of argv) {
      const friendly = removeTags(plugins.friendlyName(plugin));
      const unfriendly = await plugins.hasPlugin(removeTags(plugin));
      if (!unfriendly) {
        const p = this.config.getPluginsList().find((p2) => p2.name === plugin);
        if (p?.parent)
          return this.error(`${friendly} is installed via plugin ${p.parent.name}, uninstall ${p.parent.name} instead`);
        return this.error(`${friendly} is not installed`);
      }
      try {
        const { name } = unfriendly;
        const displayName = friendly === "." ? name : friendly ?? name;
        import_core10.ux.action.start(`${this.config.name}: Uninstalling ${displayName}`);
        await plugins.uninstall(name);
        pluginNameToDelete.push(name);
      } catch (error) {
        import_core10.ux.action.stop(bold.red("failed"));
        throw error;
      }
      import_core10.ux.action.stop();
    }
    for (const p of pluginNameToDelete) {
      this.config.plugins.delete(p);
    }
    await this.config.runHook("plugins:postuninstall", {});
  }
};

// node_modules/@oclif/plugin-plugins/lib/commands/plugins/update.js
init_cjs_shims();
var import_core11 = __toESM(require_lib(), 1);
var PluginsUpdate = class _PluginsUpdate extends import_core11.Command {
  static description = "Update installed plugins.";
  static flags = {
    help: import_core11.Flags.help({ char: "h" }),
    verbose: import_core11.Flags.boolean({ char: "v" })
  };
  async run() {
    const { flags } = await this.parse(_PluginsUpdate);
    const plugins = new Plugins({
      config: this.config,
      logLevel: determineLogLevel(this.config, flags, "silent")
    });
    import_core11.ux.action.start(`${this.config.name}: Updating plugins`);
    await plugins.update();
    import_core11.ux.action.stop();
  }
};

// node_modules/@oclif/plugin-plugins/lib/hooks/update.js
init_cjs_shims();
var update = async function() {
  const plugins = new Plugins({
    config: this.config
  });
  try {
    await plugins.update();
  } catch (error) {
    if (error instanceof Error) {
      this.error(error.message);
    }
  }
};

// node_modules/@oclif/plugin-plugins/lib/index.js
var commands = {
  plugins: PluginsIndex,
  "plugins:inspect": PluginsInspect,
  "plugins:install": PluginsInstall,
  "plugins:link": PluginsLink,
  "plugins:reset": Reset,
  "plugins:uninstall": PluginsUninstall,
  "plugins:update": PluginsUpdate
};
var hooks = {
  update
};

// node_modules/@oclif/plugin-test-esm-1/dist/index.js
init_cjs_shims();

// node_modules/@oclif/plugin-test-esm-1/dist/commands/esm1.js
init_cjs_shims();
var import_core12 = __toESM(require_lib(), 1);
var ESM1 = class _ESM1 extends import_core12.Command {
  static args = {
    optionalArg: import_core12.Args.string(),
    defaultArg: import_core12.Args.string({
      default: "simple string default"
    }),
    defaultFnArg: import_core12.Args.string({
      default: async () => "async fn default"
    })
  };
  static enableJsonFlag = true;
  static flags = {
    optionalString: import_core12.Flags.string(),
    defaultString: import_core12.Flags.string({
      default: "simple string default"
    }),
    defaultFnString: import_core12.Flags.string({
      default: async () => "async fn default"
    })
  };
  async run() {
    const { args, flags } = await this.parse(_ESM1);
    this.log(`hello I am an ESM plugin from ${this.config.root}!`);
    return { args, flags };
  }
};

// node_modules/@oclif/plugin-test-esm-1/dist/hooks/init/init.js
init_cjs_shims();
var hook = async function() {
  console.log("Greetings! from plugin-test-esm-1 init hook");
};
var init_default2 = hook;

// node_modules/@oclif/plugin-test-esm-1/dist/index.js
var hooks2 = {
  init: init_default2
};
var commands2 = {
  esm1: ESM1
};

// src/index.ts
var ESM1_INIT_HOOK = hooks2.init;
var UPDATE_HOOK = hooks.update;
var COMMANDS = {
  ...commands2,
  ...commands,
  esbuild: ESBuild,
  hello: Hello,
  "hello:alias": World,
  "hello:world": World
};
async function run() {
  await (0, import_core13.execute)({ dir: import.meta.url });
}
export {
  COMMANDS,
  ESM1_INIT_HOOK,
  init_default as INIT_HOOK,
  UPDATE_HOOK,
  run
};
