Skip to content

Simplify version management by reading from package.json#210

Merged
senechko merged 3 commits into
mainfrom
worktree-simplify-version-management
Jun 1, 2026
Merged

Simplify version management by reading from package.json#210
senechko merged 3 commits into
mainfrom
worktree-simplify-version-management

Conversation

@senechko
Copy link
Copy Markdown
Member

@senechko senechko commented May 28, 2026

Summary

  • Replace the hardcoded version string in lib/version.ts with import packageJson from '../package.json', so the version is always derived from package.json at runtime
  • Delete update-version.js (npm version hook) and check-version.ts (pre-commit guard) — both are no longer needed
  • Remove the "version" script from package.json and the check-version.ts pre-commit hook

This works because npm always includes package.json in published tarballs regardless of the "files" field, so dist/lib/version.js's require("../package.json") resolves correctly in consumers' node_modules.

Test plan

  • npm run build succeeds
  • npm run lint passes
  • npm test passes (162 tests, 100% coverage)
  • Verified dist/lib/version.js emits require("../package.json") which resolves to the package root

🤖 Generated with Claude Code


Note

Low Risk
Build/release tooling and developer hooks only; runtime API behavior is unchanged aside from keeping lib/version.ts in sync at build time.

Overview
Version sync is centralized in scripts/sync-version.js (replacing root update-version.js), which rewrites lib/version.ts from package.json. prebuild runs that script before tsc, and the version npm lifecycle script now syncs and stages lib/version.ts for release commits.

Manual drift checks are removed: check-version.ts is deleted, the Husky pre-commit hook no longer runs it (only lint-staged), and ESLint/TS eslint configs stop treating check-version.ts as a project file.

Reviewed by Cursor Bugbot for commit 2981747. Bugbot is set up for automated code reviews on this repo. Configure here.

@senechko senechko requested a review from mike-engel May 28, 2026 21:39
@mike-engel
Copy link
Copy Markdown
Collaborator

@senechko this won't work—some environments don't include the package.json file. See the original PR introducing this file and the original issue it solved

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 58a0f9f. Configure here.

Comment thread tsconfig.eslint.json
senechko and others added 3 commits June 1, 2026 09:49
Replace the hardcoded version string in lib/version.ts with a direct
import from package.json, eliminating the manual sync machinery:
- Delete update-version.js (npm version hook that wrote lib/version.ts)
- Delete check-version.ts (pre-commit guard against version drift)
- Remove the "version" script from package.json
- Remove the check-version pre-commit hook

This works because npm always includes package.json in published
tarballs regardless of the "files" field, so the runtime require
from dist/lib/version.js resolves correctly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Address review feedback from @mike-engel: some environments (e.g.
Rollup-bundled Lambda) don't include package.json at runtime, so
importing it directly breaks. See #100 for the original issue.

Instead, keep the hardcoded version string in lib/version.ts and sync
it automatically via scripts/sync-version.js:
- prebuild: runs before tsc to ensure version.ts matches package.json
- version: runs during npm version to update and stage version.ts

This preserves the bundler-safe hardcoded string while eliminating the
manual check-version.ts pre-commit guard and the separate
update-version.js script.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@senechko senechko force-pushed the worktree-simplify-version-management branch from 22f180c to 2981747 Compare June 1, 2026 16:49
@senechko senechko merged commit ad46f41 into main Jun 1, 2026
9 checks passed
@senechko senechko deleted the worktree-simplify-version-management branch June 1, 2026 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants