mirror of
https://github.com/itsRevela/Revelations-Launcher.git
synced 2026-06-08 11:13:20 +00:00
Add bump script (pnpm bump <version>) that updates package.json, tauri.conf.json, Cargo.toml, and README in one command. CI workflows now read the version from package.json dynamically. App.tsx reads the version via Vite define instead of hardcoding it.
45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
import { readFileSync, writeFileSync } from "fs";
|
|
import { resolve, dirname } from "path";
|
|
import { fileURLToPath } from "url";
|
|
|
|
const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
const version = process.argv[2];
|
|
|
|
if (!version || !/^\d+\.\d+\.\d+$/.test(version)) {
|
|
console.error("Usage: pnpm bump <version> (e.g. pnpm bump 1.2.0)");
|
|
process.exit(1);
|
|
}
|
|
|
|
const files = [
|
|
{
|
|
path: "package.json",
|
|
replace: (s) => s.replace(/"version":\s*"[^"]+"/, `"version": "${version}"`),
|
|
},
|
|
{
|
|
path: "src-tauri/tauri.conf.json",
|
|
replace: (s) => s.replace(/"version":\s*"[^"]+"/, `"version": "${version}"`),
|
|
},
|
|
{
|
|
path: "src-tauri/Cargo.toml",
|
|
replace: (s) => s.replace(/^version = "[^"]+"/m, `version = "${version}"`),
|
|
},
|
|
{
|
|
path: "README.md",
|
|
replace: (s) => s.replace(/### LATEST: v[\d.]+/, `### LATEST: v${version}`),
|
|
},
|
|
];
|
|
|
|
for (const file of files) {
|
|
const fullPath = resolve(root, file.path);
|
|
const original = readFileSync(fullPath, "utf-8");
|
|
const updated = file.replace(original);
|
|
if (original === updated) {
|
|
console.warn(` skip ${file.path} (no match or already at ${version})`);
|
|
} else {
|
|
writeFileSync(fullPath, updated);
|
|
console.log(` done ${file.path} -> ${version}`);
|
|
}
|
|
}
|
|
|
|
console.log(`\nBumped to ${version}`);
|