import {
  base_command_default
} from "./chunk-74OMYEAL.js";
import {
  cacheClear
} from "./chunk-ONG7EKNR.js";
import {
  isTruthy
} from "./chunk-IW7KNM7Q.js";
import {
  require_lib
} from "./chunk-EI5KZ5NN.js";
import {
  __toESM,
  init_cjs_shims
} from "./chunk-POZ5MGPT.js";

// src/cli/commands/cache/clear.ts
init_cjs_shims();

// ../cli-kit/dist/public/node/cli.js
init_cjs_shims();
var import_core = __toESM(require_lib());
async function warnIfOldNodeVersion(versions = process.versions) {
  let nodeVersion = versions.node, nodeMajorVersion = Number(nodeVersion.split(".")[0]);
  if (nodeMajorVersion < 18) {
    let { renderWarning } = await import("./ui-MGEDXBPD.js");
    renderWarning({
      headline: "Upgrade to a supported Node version now.",
      body: [
        `Node ${nodeMajorVersion} has reached end-of-life and poses security risks. When you upgrade to a`,
        {
          link: {
            url: "https://nodejs.dev/en/about/previous-releases",
            label: "supported version"
          }
        },
        { char: "," },
        "you'll be able to use Shopify CLI without interruption."
      ]
    });
  }
}
function setupEnvironmentVariables(options, argv = process.argv, env = process.env) {
  argv.includes("--verbose") && (env.DEBUG = env.DEBUG ?? "*"), options.development && (env.SHOPIFY_CLI_ENV = env.SHOPIFY_CLI_ENV ?? "development");
}
function forceNoColor(argv = process.argv, env = process.env) {
  (argv.includes("--no-color") || isTruthy(env.NO_COLOR) || isTruthy(env.SHOPIFY_FLAG_NO_COLOR) || env.TERM === "dumb") && (env.FORCE_COLOR = "0");
}
async function runCLI(options, launchCLI, argv = process.argv, env = process.env, versions = process.versions) {
  return setupEnvironmentVariables(options, argv, env), options.runInCreateMode && await addInitToArgvWhenRunningCreateCLI(options, argv), forceNoColor(argv, env), await warnIfOldNodeVersion(versions), launchCLI({ moduleURL: options.moduleURL });
}
async function addInitToArgvWhenRunningCreateCLI(options, argv = process.argv) {
  let { findUpAndReadPackageJson } = await import("./node-package-manager-FIGFH4VI.js"), { moduleDirectory } = await import("./path-QLKIBORJ.js"), name = (await findUpAndReadPackageJson(moduleDirectory(options.moduleURL))).content.name.replace("@shopify/create-", "");
  if (argv.findIndex((arg) => arg.includes("init")) === -1) {
    let initIndex2 = argv.findIndex((arg) => arg.match(new RegExp(`bin(\\/|\\\\)+(create-${name}|dev|run)`))) + 1;
    argv.splice(initIndex2, 0, "init");
  }
}
var globalFlags = {
  "no-color": import_core.Flags.boolean({
    hidden: !1,
    description: "Disable color output.",
    env: "SHOPIFY_FLAG_NO_COLOR"
  }),
  verbose: import_core.Flags.boolean({
    hidden: !1,
    description: "Increase the verbosity of the output.",
    env: "SHOPIFY_FLAG_VERBOSE"
  })
};
function clearCache() {
  cacheClear();
}

// src/cli/commands/cache/clear.ts
var ClearCache = class extends base_command_default {
  static {
    this.description = "Clear the CLI cache, used to store some API responses and handle notifications status";
  }
  static {
    this.hidden = !0;
  }
  async run() {
    clearCache();
  }
};

export {
  runCLI,
  globalFlags,
  ClearCache
};
//# sourceMappingURL=chunk-T7SEICYH.js.map
