Something went wrong. Try again.
A self-hosted household ledger.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364// ChronVer (https://chronver.org) version helpers for Quantum.//// Format: YYYY.MM.DD[.CHANGESET][-feature|-break]// - the date is the release date// - CHANGESET counts additional releases cut on the same day (first extra = 1)// - an optional -feature / -break suffix flags branch or breaking releases//// `package.json` `version` is the source of truth: the release script writes the// next version there, and every other tool (the image build, this CLI) reads it.
const PKG = new URL("../package.json", import.meta.url);
const CHRONVER = /^(\d{4})\.(\d{2})\.(\d{2})(?:\.(\d+))?(-[0-9A-Za-z.-]+)?$/;
export function isChronVer(v: string): boolean { return CHRONVER.test(v);}
/** Today's date as the ChronVer date component, e.g. "2026.07.16". */export function today(now: Date = new Date()): string { const y = now.getFullYear(); const m = String(now.getMonth() + 1).padStart(2, "0"); const d = String(now.getDate()).padStart(2, "0"); return `${y}.${m}.${d}`;}
/** The version recorded in package.json (may be a non-ChronVer seed like 0.0.1). */export async function pkgVersion(): Promise<string> { const pkg = JSON.parse(await Deno.readTextFile(PKG)); return String(pkg.version ?? "");}
/** * The version this build represents right now: the recorded version if it is * already ChronVer, otherwise today's date (so a fresh 0.0.1 repo still reports * a sensible date-based version before its first formal release). */export async function currentVersion(): Promise<string> { const v = await pkgVersion(); return isChronVer(v) ? v : today();}
/** The version a release cut right now would receive. */export async function nextVersion(suffix = ""): Promise<string> { const date = today(); const current = await pkgVersion(); let base: string; if (current === date) { base = `${date}.1`; } else if (current.startsWith(`${date}.`)) { const changeset = Number(current.slice(date.length + 1).split("-")[0]); base = `${date}.${Number.isFinite(changeset) ? changeset + 1 : 1}`; } else { // A new day, or a non-ChronVer seed: start the day fresh at changeset 0. base = date; } return suffix ? `${base}-${suffix}` : base;}
if (import.meta.main) { const wantNext = Deno.args.includes("--next"); console.log(wantNext ? await nextVersion() : await currentVersion());}