|
| 1 | +#!/usr/bin/env -S deno run --allow-read --allow-write |
| 2 | + |
| 3 | +const args = Deno.args; |
| 4 | +const versionType = args[0] || "patch"; // patch, minor, major |
| 5 | + |
| 6 | +if (!["patch", "minor", "major"].includes(versionType)) { |
| 7 | + console.error("Usage: deno task version [patch|minor|major]"); |
| 8 | + Deno.exit(1); |
| 9 | +} |
| 10 | + |
| 11 | +function bumpVersion(version: string, type: string): string { |
| 12 | + const [major, minor, patch] = version.split(".").map(Number); |
| 13 | + |
| 14 | + switch (type) { |
| 15 | + case "major": |
| 16 | + return `${major + 1}.0.0`; |
| 17 | + case "minor": |
| 18 | + return `${major}.${minor + 1}.0`; |
| 19 | + case "patch": |
| 20 | + return `${major}.${minor}.${patch + 1}`; |
| 21 | + default: |
| 22 | + return version; |
| 23 | + } |
| 24 | +} |
| 25 | + |
| 26 | +const packages = [ |
| 27 | + "./packages/utils/deno.json", |
| 28 | + "./packages/core/deno.json", |
| 29 | + "./packages/cli/deno.json", |
| 30 | + "./packages/mcp-sampling-ai-provider/deno.json", |
| 31 | +]; |
| 32 | + |
| 33 | +for (const pkgPath of packages) { |
| 34 | + const content = await Deno.readTextFile(pkgPath); |
| 35 | + const pkg = JSON.parse(content); |
| 36 | + const oldVersion = pkg.version; |
| 37 | + const newVersion = bumpVersion(oldVersion, versionType); |
| 38 | + |
| 39 | + pkg.version = newVersion; |
| 40 | + |
| 41 | + await Deno.writeTextFile( |
| 42 | + pkgPath, |
| 43 | + JSON.stringify(pkg, null, 2) + "\n", |
| 44 | + ); |
| 45 | + |
| 46 | + console.log(`${pkg.name}: ${oldVersion} → ${newVersion}`); |
| 47 | +} |
| 48 | + |
| 49 | +console.log(`\n✓ All packages updated to ${versionType} version`); |
0 commit comments