Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,6 @@
"ts-proto": "^2.11.6",
"typescript": "^6.0.3",
"vitest": "^4.1.5"
}
},
"supportedServerVersion": ">=0.8.0,<1.0.0"
}
26 changes: 20 additions & 6 deletions scripts/gen-version.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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}"`,
);
}
3 changes: 1 addition & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions src/version.ts
Original file line number Diff line number Diff line change
@@ -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";