CDP-5969: replace hand-synced lib/version.ts with build-time generation#206
Closed
senechko wants to merge 3 commits into
Closed
CDP-5969: replace hand-synced lib/version.ts with build-time generation#206senechko wants to merge 3 commits into
senechko wants to merge 3 commits into
Conversation
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>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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.
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>
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
lib/version.tsat build time viaupdate-version.jsinstead of manually syncing itprepare(runs afternpm ci) so the file exists before tests on clean checkoutslib/version.ts— it's now a build artifact, not a source filecheck-version.tsand its pre-commit hook (~500ms saved per commit)versionnpm lifecycle script (no longer needed)Closes CDP-5969
Context
PR #105 introduced the hard-coded version file because some bundlers couldn't resolve
package.jsonat runtime. That's still valid — this PR keeps the same generated output, just automates the sync so it can't drift.How it works
npm ci/npm installprepare→husky && node update-version.jsnpm run buildnode update-version.js && tscnpm publishprepublishOnly→build→ generates + compilesThe version file is always regenerated from
package.jsonbefore it's needed.Test plan
npm cion clean checkout generateslib/version.tsnpm test— 162 tests pass, 100% coveragenpm run build— compiles cleanlynpm run lint— no issuesdist/lib/version.jscontains correct version string🤖 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.tsis no longer checked in; it is gitignored and regenerated frompackage.jsonbyupdate-version.jsduringnpm run buildandprepare(after install), so clean checkouts still get the file before tests or compile.The manual sync guard is removed:
check-version.tsand its husky pre-commit step are deleted, and theversionnpm lifecycle script is dropped in favor of always running generation inprepare/build.Reviewed by Cursor Bugbot for commit 310a4b4. Bugbot is set up for automated code reviews on this repo. Configure here.