// scripts/bump-version.ts
const denoConfigPath = "deno.json";
const denoConfig = JSON.parse(await Deno.readTextFile(denoConfigPath));
const currentVersion = denoConfig.version;

const parts = currentVersion.split(".").map(Number);
if (parts.length !== 3 || parts.some(isNaN)) {
  console.error(`Invalid version format in deno.json: ${currentVersion}`);
  Deno.exit(1);
}

// Increment patch version
parts[2]++;
const newVersion = parts.join(".");

denoConfig.version = newVersion;
await Deno.writeTextFile(denoConfigPath, JSON.stringify(denoConfig, null, 2) + "\n");

console.log(`Bumped version: ${currentVersion} -> ${newVersion}`);
