Repository navigation
fix: backend reports actual version on /health and / - #353
Conversation
- Stop hardcoding 0.1.0 in backend/src/index.ts; import version from backend/package.json. Single source of truth. - Bump backend/package.json from 0.1.0 to 0.8.0-dev so it tracks the CLI version (CLI and backend ship together). - bump-version.sh now keeps backend/package.json in sync, so future bumps update both files atomically. - Refresh the index.ts header doc comment: production route is api.nemar.org (SCCN), dev is nemar-api-dev.sccn-org, and the personal api.osc.earth/nemar URL is the read-only buffer.
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR353Version: 🤖 Updated on each push. |
Reviewer note: the three failure paths restored only root package.json, leaving backend/package.json modified if a bump aborted mid-way. Factor a restore_versions() helper that touches both files so the working tree is never half-rolled-back.
Backend was importing ../package.json (backend/package.json), with the bump script syncing the two manifests. That left two write paths to keep aligned. Wire the runtime to import the repo-root package.json directly (../../package.json from backend/src/index.ts), making the CLI manifest the single source of truth. backend/package.json stays (it is private/never published, but wrangler and bun tooling expect it). bump-version.sh keeps it in lockstep and now also asserts backend.version == root.version post-bump, so any drift introduced by a hand-edit fails the bump loudly. Wrangler dry-run + tsc clean with the new import path.
Review pass: addressed + raised the barTwo follow-up commits on top of the original fix:
|
CI deploy-dev failed because backend/package.json pinned [email protected] which does not parse \`import ... with { type: "json" }\` (introduced in PR #353). Bump to wrangler 4.85.0 to match the version used for local dry-runs and the version recommended by wrangler's own deprecation warning. api-test was racing deploy-dev: the tightened /health assertion compared against the locally-checked-out package.json version while the deployed worker on dev still ran the previous version. Replace the exact-match check with a semver shape regex - still catches version=undefined (the original test gap) without locking to current build.
Summary
version: "0.1.0"inbackend/src/index.ts— both/healthand/now read frombackend/package.jsonvia JSON import. Single source of truth.backend/package.jsonfrom0.1.0to0.8.0-devso it tracks the CLI version. CLI and backend ship together; one version.scripts/bump-version.shnow also bumpsbackend/package.jsonatomically, so future runs keep them in lockstep.api.nemar.org(SCCN), dev isnemar-api-dev.sccn-org.workers.dev(SCCN), legacyapi.osc.earth/nemaris the read-only buffer on the personal account.Why
Reported in production:
https://api.nemar.org/healthreturnedversion: "0.1.0"(frozen at project start) instead of the real shipped version. Misleading for ops and for the dashboard's API health card.Test plan
bun run typecheck(backend) cleanwrangler deploy --dry-run -c backend/wrangler-sccn.tomlproduces a valid bundle (JSON import resolves correctly via esbuild)curl https://api.nemar.org/healthshould returnversion: "0.8.0-dev"Notes
with { type: "json" }import-attributes syntax is supported by esbuild (which wrangler bundles with) and TypeScript 5.6+.api.osc.earth/nemar) keeps reporting 0.1.0 until Phase 11 retirement; not worth burning a deploy on a sunset target.