fix(cli): auto-inject VERSION from package.json at build time
Some checks failed
CI / Lint (push) Has been cancelled
CI / Typecheck (push) Has been cancelled
CI / Broker tests (Postgres) (push) Has been cancelled
CI / Docker build (linux/amd64) (push) Has been cancelled

alpha.28-30 binaries all reported 'v1.0.0-alpha.27' from a hardcoded
constant in src/constants/urls.ts — my bump sed only matched
package.json's 'version' key, not the TypeScript literal.

build.ts now reads package.json version and injects it via Bun's
`define` (source-text replacement, equivalent to esbuild --define).
urls.ts reads the injected symbol with a runtime fallback for `bun
src/...` dev mode. Version drift can't recur.

+ peers + status migrated to the render.ts unified renderer.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alejandro Gutiérrez
2026-04-15 03:06:13 +01:00
parent 506c470441
commit b998e35d17
5 changed files with 71 additions and 69 deletions

View File

@@ -3,6 +3,11 @@ import { gzipSync } from "node:zlib";
const MAX_GZIPPED_BYTES = 1.2 * 1024 * 1024; // 1.2 MB
// Inject the version from package.json at build time so VERSION can never
// drift from what's published. Bun's `define` is a source-text replacement,
// equivalent to `--define` in esbuild / a webpack DefinePlugin.
const pkgVersion = ((await Bun.file("package.json").json()) as { version: string }).version;
const result = await Bun.build({
entrypoints: [
"src/entrypoints/cli.ts",
@@ -13,6 +18,9 @@ const result = await Bun.build({
format: "esm",
splitting: false,
sourcemap: "external",
define: {
__CLAUDEMESH_VERSION__: JSON.stringify(pkgVersion),
},
external: [
"libsodium-wrappers",
"ws",