diff --git a/README.md b/README.md index 728d6df..5846e07 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ Runnable examples in the [`examples/`](examples/) directory: ## Requirements - Node.js 20+ -- A running OpenDecree server (v0.3.0+) +- A running OpenDecree server (v0.8.0 – v0.x, pre-1.0) ## Questions? diff --git a/package.json b/package.json index 3e87cfa..1552dd3 100644 --- a/package.json +++ b/package.json @@ -63,5 +63,6 @@ "ts-proto": "^2.11.6", "typescript": "^6.0.3", "vitest": "^4.1.5" - } + }, + "supportedServerVersion": ">=0.8.0,<1.0.0" } diff --git a/scripts/gen-version.mjs b/scripts/gen-version.mjs index f270574..ae65814 100644 --- a/scripts/gen-version.mjs +++ b/scripts/gen-version.mjs @@ -5,24 +5,38 @@ import { readFileSync, writeFileSync } from "node:fs"; const pkg = JSON.parse(readFileSync("package.json", "utf8")); const version = pkg.version; +const serverVersion = pkg.supportedServerVersion; + +if (!serverVersion) { + console.error("package.json missing supportedServerVersion field"); + process.exit(1); +} const content = `// Generated by scripts/gen-version.mjs — do not edit manually.\n` + - `export const VERSION = "${version}";\n`; + `export const VERSION = "${version}";\n` + + `export const SUPPORTED_SERVER_VERSION = "${serverVersion}";\n`; if (process.argv.includes("--check")) { const existing = readFileSync("src/version.ts", "utf8"); if (existing !== content) { - const match = existing.match(/VERSION = "([^"]+)"/); + const vMatch = existing.match(/VERSION = "([^"]+)"/); + const sMatch = existing.match(/SUPPORTED_SERVER_VERSION = "([^"]+)"/); console.error( `src/version.ts is out of sync with package.json\n` + - ` package.json : ${version}\n` + - ` src/version.ts: ${match?.[1] ?? "(unreadable)"}`, + ` package.json version : ${version}\n` + + ` src/version.ts VERSION : ${vMatch?.[1] ?? "(unreadable)"}\n` + + ` package.json supportedServerVersion: ${serverVersion}\n` + + ` src/version.ts SUPPORTED_SERVER_VERSION: ${sMatch?.[1] ?? "(unreadable)"}`, ); process.exit(1); } - console.log(`src/version.ts is in sync with package.json (${version})`); + console.log( + `src/version.ts is in sync with package.json (${version}, server ${serverVersion})`, + ); } else { writeFileSync("src/version.ts", content); - console.log(`Generated src/version.ts with VERSION = "${version}"`); + console.log( + `Generated src/version.ts with VERSION = "${version}", SUPPORTED_SERVER_VERSION = "${serverVersion}"`, + ); } diff --git a/src/index.ts b/src/index.ts index e610a1f..af23c19 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,8 +4,7 @@ * @packageDocumentation */ -export { VERSION } from "./version.js"; -export const SUPPORTED_SERVER_VERSION = ">=0.8.0,<1.0.0"; +export { SUPPORTED_SERVER_VERSION, VERSION } from "./version.js"; export const PROTO_VERSION = "v1"; export { createChannel } from "./channel.js"; diff --git a/src/version.ts b/src/version.ts index 83f1e5e..a4990f7 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1,2 +1,3 @@ // Generated by scripts/gen-version.mjs — do not edit manually. export const VERSION = "0.3.0-alpha.1"; +export const SUPPORTED_SERVER_VERSION = ">=0.8.0,<1.0.0";