Skip to content

Commit 5c798e8

Browse files
zeevdrclaude
andauthored
fix: generate SUPPORTED_SERVER_VERSION from package.json and align README (#89)
SUPPORTED_SERVER_VERSION was hardcoded in src/index.ts and the README claimed server v0.3.0+, contradicting the actual constraint of >=0.8.0,<1.0.0. - Add `supportedServerVersion` field to package.json as the single source of truth for the supported server version range - Extend scripts/gen-version.mjs to emit SUPPORTED_SERVER_VERSION into src/version.ts alongside VERSION; existing check:version CI job now catches drift for both constants - Remove the hardcoded constant from src/index.ts; re-export from version.js - Update README Requirements section to reflect the actual range Closes #60 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 63711bb commit 5c798e8

5 files changed

Lines changed: 25 additions & 10 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Runnable examples in the [`examples/`](examples/) directory:
106106
## Requirements
107107

108108
- Node.js 20+
109-
- A running OpenDecree server (v0.3.0+)
109+
- A running OpenDecree server (v0.8.0 – v0.x, pre-1.0)
110110

111111
## Questions?
112112

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,6 @@
6363
"ts-proto": "^2.11.6",
6464
"typescript": "^6.0.3",
6565
"vitest": "^4.1.5"
66-
}
66+
},
67+
"supportedServerVersion": ">=0.8.0,<1.0.0"
6768
}

scripts/gen-version.mjs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,38 @@ import { readFileSync, writeFileSync } from "node:fs";
55

66
const pkg = JSON.parse(readFileSync("package.json", "utf8"));
77
const version = pkg.version;
8+
const serverVersion = pkg.supportedServerVersion;
9+
10+
if (!serverVersion) {
11+
console.error("package.json missing supportedServerVersion field");
12+
process.exit(1);
13+
}
814

915
const content =
1016
`// Generated by scripts/gen-version.mjs — do not edit manually.\n` +
11-
`export const VERSION = "${version}";\n`;
17+
`export const VERSION = "${version}";\n` +
18+
`export const SUPPORTED_SERVER_VERSION = "${serverVersion}";\n`;
1219

1320
if (process.argv.includes("--check")) {
1421
const existing = readFileSync("src/version.ts", "utf8");
1522
if (existing !== content) {
16-
const match = existing.match(/VERSION = "([^"]+)"/);
23+
const vMatch = existing.match(/VERSION = "([^"]+)"/);
24+
const sMatch = existing.match(/SUPPORTED_SERVER_VERSION = "([^"]+)"/);
1725
console.error(
1826
`src/version.ts is out of sync with package.json\n` +
19-
` package.json : ${version}\n` +
20-
` src/version.ts: ${match?.[1] ?? "(unreadable)"}`,
27+
` package.json version : ${version}\n` +
28+
` src/version.ts VERSION : ${vMatch?.[1] ?? "(unreadable)"}\n` +
29+
` package.json supportedServerVersion: ${serverVersion}\n` +
30+
` src/version.ts SUPPORTED_SERVER_VERSION: ${sMatch?.[1] ?? "(unreadable)"}`,
2131
);
2232
process.exit(1);
2333
}
24-
console.log(`src/version.ts is in sync with package.json (${version})`);
34+
console.log(
35+
`src/version.ts is in sync with package.json (${version}, server ${serverVersion})`,
36+
);
2537
} else {
2638
writeFileSync("src/version.ts", content);
27-
console.log(`Generated src/version.ts with VERSION = "${version}"`);
39+
console.log(
40+
`Generated src/version.ts with VERSION = "${version}", SUPPORTED_SERVER_VERSION = "${serverVersion}"`,
41+
);
2842
}

src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
* @packageDocumentation
55
*/
66

7-
export { VERSION } from "./version.js";
8-
export const SUPPORTED_SERVER_VERSION = ">=0.8.0,<1.0.0";
7+
export { SUPPORTED_SERVER_VERSION, VERSION } from "./version.js";
98
export const PROTO_VERSION = "v1";
109

1110
export { createChannel } from "./channel.js";

src/version.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
// Generated by scripts/gen-version.mjs — do not edit manually.
22
export const VERSION = "0.3.0-alpha.1";
3+
export const SUPPORTED_SERVER_VERSION = ">=0.8.0,<1.0.0";

0 commit comments

Comments
 (0)