2024-05-14 16:41:29 +00:00
|
|
|
import { readFile, writeFile } from "fs/promises";
|
|
|
|
import { execSync } from "child_process";
|
|
|
|
|
|
|
|
let ver = process.argv[2];
|
|
|
|
if (!ver) {
|
|
|
|
console.error(`tag required: bun bun/prepare.js v1.0.0`);
|
|
|
|
process.exit(1);
|
|
|
|
} else if (!/v\d+\.\d+\.\d+/.test(ver)) {
|
|
|
|
console.error(`invalid tag: ${ver}`);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
ver = (/\d+\.\d+\.\d+/.exec(ver) || [])[0] || "";
|
|
|
|
|
|
|
|
const pkg = await readFile("./package.json", "utf8");
|
|
|
|
const pkgnew = pkg.replace(/"version": ".+"/, `"version": "v${ver}"`);
|
|
|
|
await writeFile("./package.json", pkgnew);
|
|
|
|
|
|
|
|
const spago = await readFile("./spago.yaml", "utf8");
|
|
|
|
const spagonew = spago.replace(/version: .+/, `version: '${ver}'`);
|
|
|
|
await writeFile("./spago.yaml", spagonew);
|
|
|
|
|
|
|
|
const readme = await readFile("./README.md", "utf8");
|
|
|
|
const readmenew = readme.replace(
|
2024-07-16 17:55:45 +00:00
|
|
|
/packages\/purescript-threading\/.+?\//g,
|
|
|
|
`/packages/purescript-threading/${ver}/`,
|
2024-05-14 16:41:29 +00:00
|
|
|
);
|
|
|
|
await writeFile("./README.md", readmenew);
|
|
|
|
|
|
|
|
execSync(`git add spago.yaml package.json README.md`);
|
|
|
|
execSync(`git commit -m 'chore: prepare v${ver}'`);
|
|
|
|
execSync(`git tag v${ver}`);
|
|
|
|
execSync(`git push --tags`);
|
|
|
|
execSync(`git push --mirror github-mirror`);
|