#!/usr/bin/env node
/**
 * Block npm start on unsupported Node versions (msnodesqlv8 requires Node 20–22 LTS).
 */
const major = Number(process.versions.node.split('.')[0]);
const version = process.version;

if (major >= 24 || major < 20) {
  console.error('');
  console.error('DBAOps Sovereign — unsupported Node.js version');
  console.error(`  Current: ${version}`);
  console.error('  Required: Node 20.x or 22.x LTS (NOT Node 24+)');
  console.error('');
  console.error('Node 24 breaks the SQL native driver (msnodesqlv8) → demo/mock fleet.');
  console.error('');
  console.error('Fix (Windows — no nvm required):');
  console.error('  winget install OpenJS.NodeJS.22');
  console.error('  Close PowerShell, open a new window, then:');
  console.error('  node -v          # must show v22.x');
  console.error('  npm run repair:sql');
  console.error('  npm start');
  console.error('');
  console.error('Or download Node 22 LTS from https://nodejs.org/ and reopen PowerShell.');
  console.error('');
  process.exit(1);
}
