Skip to content

CDP-5969: replace hand-synced lib/version.ts with build-time generation#206

Closed
senechko wants to merge 3 commits into
mainfrom
worktree-cdp-5969-build-time-version
Closed

CDP-5969: replace hand-synced lib/version.ts with build-time generation#206
senechko wants to merge 3 commits into
mainfrom
worktree-cdp-5969-build-time-version

Conversation

@senechko
Copy link
Copy Markdown
Member

@senechko senechko commented May 28, 2026

Summary

  • Generate lib/version.ts at build time via update-version.js instead of manually syncing it
  • Add generation to prepare (runs after npm ci) so the file exists before tests on clean checkouts
  • Gitignore lib/version.ts — it's now a build artifact, not a source file
  • Remove check-version.ts and its pre-commit hook (~500ms saved per commit)
  • Remove the version npm lifecycle script (no longer needed)

Closes CDP-5969

Context

PR #105 introduced the hard-coded version file because some bundlers couldn't resolve package.json at runtime. That's still valid — this PR keeps the same generated output, just automates the sync so it can't drift.

How it works

Entry point What runs
npm ci / npm install preparehusky && node update-version.js
npm run build node update-version.js && tsc
npm publish prepublishOnlybuild → generates + compiles

The version file is always regenerated from package.json before it's needed.

Test plan

  • npm ci on clean checkout generates lib/version.ts
  • npm test — 162 tests pass, 100% coverage
  • npm run build — compiles cleanly
  • npm run lint — no issues
  • Verified dist/lib/version.js contains correct version string
  • Codex CLI review — caught and fixed clean-checkout CI issue

🤖 Generated with Claude Code


Note

Low Risk
Build and git workflow only; the generated version string behavior stays the same for consumers.

Overview
lib/version.ts is no longer checked in; it is gitignored and regenerated from package.json by update-version.js during npm run build and prepare (after install), so clean checkouts still get the file before tests or compile.

The manual sync guard is removed: check-version.ts and its husky pre-commit step are deleted, and the version npm lifecycle script is dropped in favor of always running generation in prepare / build.

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

senechko and others added 2 commits May 28, 2026 13:35
Generate lib/version.ts via update-version.js at build time (prebuild
script) instead of requiring manual sync. This removes the fragile
pre-commit version check that spawned ts-node on every commit (~500ms)
and the npm "version" lifecycle hook.

- Add prebuild script that runs update-version.js before tsc
- Gitignore lib/version.ts (generated artifact)
- Remove check-version.ts and its pre-commit hook invocation
- Remove npm "version" lifecycle script (no longer needed)

prepublishOnly → build → prebuild ensures the version file is always
correct when publishing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The prepare script now runs update-version.js after husky setup,
ensuring lib/version.ts exists after npm ci — before tests run.
This fixes the clean-checkout CI flow (npm ci → npm test) which
would otherwise fail with a missing module.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@senechko senechko requested a review from mike-engel May 28, 2026 20:43
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 b48e165. Configure here.

Comment thread package.json Outdated
Use (husky || true) so update-version.js runs even when husky fails
(e.g., when installed as a dependency without a .git directory).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@senechko
Copy link
Copy Markdown
Member Author

Closing in favor of #210, which takes a simpler approach by keeping lib/version.ts checked in rather than gitignoring it — avoids the clean-checkout issue.

@senechko senechko closed this May 29, 2026
@mike-engel mike-engel deleted the worktree-cdp-5969-build-time-version branch June 2, 2026 11:58
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.

1 participant