#!/usr/bin/env node
import process from 'node:process';

process.on('unhandledRejection', (reason) => {
  console.error('Unhandled Promise Rejection:', reason);
  process.exitCode = 1;
});
process.on('uncaughtException', (error) => {
  console.error('Uncaught Exception:', error);
  process.exit(1);
});

const [cmd, ...rest] = process.argv.slice(2)

;(async () => {
  switch (cmd) {
    case 'dev': {
      const run = (await import('./dev.js')).default;
      process.env.NODE_ENV = 'development';
      await run(rest);
      break
    }
    case 'build': {
      const run = (await import('./build.js')).default;
      process.env.NODE_ENV = 'production';
      await run(rest);
      break
    }
    case 'copy': {
      const run = (await import('./copy.js')).default;
      process.env.NODE_ENV = 'production';
      await run(rest);
      break
    }
    default: {
      console.log(
        [
          '',
          'vettvangur-vite',
          '---------------------',
          'Usage:',
          '  vettvangur-vite dev      # start HTTPS Vite dev server (MVC supplies HTML)',
          '  vettvangur-vite build    # run Vite production build (CSS/JS to dest)',
          '  vettvangur-vite copy     # copy static assets from config.assets -> dest/assets',
          '',
        ].join('\n')
      );
      process.exit(cmd ? 1 : 0);
    }
  }
})();
//# sourceMappingURL=cli.js.map
