import process from 'node:process';
import { d as defineCommand, b as legacyRootDirArgs, c as cwdArgs } from '../shared/nuxi.C0YEEVs2.mjs';
import { x as ve } from './main.mjs';
import { l as logger } from '../shared/nuxi.DQjfoGl0.mjs';
import { r as resolve } from '../shared/nuxi.Do0aYBCO.mjs';
import 'node:crypto';
import 'node:path';
import 'node:tty';
import 'node:url';
import 'node:module';
import 'child_process';
import 'path';
import 'process';
import 'stream';
import 'readline';
import 'node:util';

const devtools = defineCommand({
  meta: {
    name: "devtools",
    description: "Enable or disable devtools in a Nuxt project"
  },
  args: {
    ...cwdArgs,
    command: {
      type: "positional",
      description: "Command to run",
      valueHint: "enable|disable"
    },
    ...legacyRootDirArgs
  },
  async run(ctx) {
    const cwd = resolve(ctx.args.cwd || ctx.args.rootDir);
    if (!["enable", "disable"].includes(ctx.args.command)) {
      logger.error(`Unknown command \`${ctx.args.command}\`.`);
      process.exit(1);
    }
    await ve(
      "npx",
      ["@nuxt/devtools-wizard@latest", ctx.args.command, cwd],
      {
        throwOnError: true,
        nodeOptions: {
          stdio: "inherit",
          cwd
        }
      }
    );
  }
});

export { devtools as default };
