fix(cli): auto-inject VERSION from package.json at build time
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:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user