import { Command, Option } from "@commander-js/extra-typings";
import { oneoffContext } from "../bundler/context.js";
import { initOrReinitForDeprecatedCommands } from "./configure.js";

// Reinitialize an existing Convex project.
// This command is deprecated and hidden from the command help.
// `npx convex dev --once --configure=existing` replaces it.
export const reinit = new Command("reinit")
  .description(
    "Reinitialize a Convex project in the local directory if you've lost your convex.json file",
  )
  .addOption(
    new Option(
      "--team <team_slug>",
      "The identifier of the team the project belongs to.",
    ),
  )
  .addOption(
    new Option(
      "--project <project_slug>",
      "The identifier of the project you'd like to reinitialize.",
    ),
  )
  .action(async (options) => {
    const ctx = oneoffContext;

    await initOrReinitForDeprecatedCommands(ctx, options);
  });
