#!/usr/bin/env node

(function minimumNodeVersionCheck() {
  const RED = '\x1B[0;31m';
  const GREEN = '\x1B[0;32m';
  const NO_COLOR = '\x1B[0m';

  const colorize = (color, text) => `${color}${text}${NO_COLOR}`;

  const versionParts = process.versions.node.split('.').map((v) => Number(v));
  const major = versionParts[0];
  const minor = versionParts[1];

  if (major < 20 || (major === 20 && minor < 11)) {
    const currentVersion = colorize(RED, process.versions.node);
    const supportedVersion = colorize(GREEN, '20.11.0');

    console.error(
      `⛔️ Node version ${currentVersion} detected, minimum supported version is ${supportedVersion}`
    );
    console.error('');
    console.error(
      'Your current node version is lower than the minimum required for the CLI to work correctly.'
    );
    console.error(
      'Make sure to update your node version to a compatible version.'
    );
    process.exit(1);
  }
})();

process.setSourceMapsEnabled(true);

require('./import.cjs');
