// Map Node's process.platform/process.arch to GitHub release target triple and file ext
export function resolveTarget() {
  const p = process.platform;
  const a = process.arch;
  // Supported targets per release matrix
  if (p === 'linux' && a === 'x64') return { target: 'x86_64-unknown-linux-gnu', ext: 'tar.gz' };
  if (p === 'darwin' && a === 'x64') return { target: 'x86_64-apple-darwin', ext: 'tar.gz' };
  if (p === 'darwin' && a === 'arm64') return { target: 'aarch64-apple-darwin', ext: 'tar.gz' };
  if (p === 'win32' && a === 'x64') return { target: 'x86_64-pc-windows-msvc', ext: 'zip' };
  throw new Error(`Unsupported platform/arch: ${p}/${a}. See https://github.com/maravilla-labs/maravilla-cli/releases for supported binaries.`);
}

export function artifactName(binName, tag, target) {
  return `${binName}-${tag}-${target}`;
}
