import { CliLeaf } from '@alwaysai/alwayscli';
import * as chalk from 'chalk';
import * as logSymbols from 'log-symbols';
import { yesCliInput } from '../cli-inputs';
import { checkUserIsLoggedInComponent } from '../components/user';
import { echo } from '../util';
import { websitePrompt } from '../util/website-prompt';

const zoneCreatorFunc = () =>
  CliLeaf({
    name: 'zone-creator',
    description: 'Run zone creation tool',
    namedInputs: {
      yes: yesCliInput
    },
    async action(_, { yes }) {
      await checkUserIsLoggedInComponent({ yes });

      const zoneTutorial =
        'https://alwaysai.co/tutorials/how-to-use-alwaysais-new-zone-editor-tool';
      const log = `${
        logSymbols.warning
      } The Zone Creator CLI tool is now deprecated. Please use the new Zone Tool on the alwaysAI Console!\nRead how here: ${chalk.bold(
        zoneTutorial
      )}`;
      echo(log);
      await websitePrompt(zoneTutorial);
    }
  });

export const zoneCreator = zoneCreatorFunc();
