import { spawnSync } from 'node:child_process';

const commands = [
  ['pnpm', ['validate']],
  ['pnpm', ['format:check']],
  ['pnpm', ['lint']],
  ['pnpm', ['typecheck']],
  ['pnpm', ['test:unit']],
  ['pnpm', ['test:integration']],
  ['pnpm', ['test:security']],
  ['pnpm', ['test:privacy']],
  ['pnpm', ['build'], { SITE_ORIGIN: 'http://127.0.0.1:3000', PUBLIC_RELEASE_APPROVED: 'false' }],
  ['pnpm', ['audit']],
];
for (const [command, args, extraEnv = {}] of commands) {
  const result = spawnSync(command, args, {
    stdio: 'inherit',
    shell: process.platform === 'win32',
    env: { ...process.env, ...extraEnv },
  });
  if (result.status !== 0) process.exit(result.status ?? 1);
}
