Repository navigation
fix: read the CLI version from package.json - #11
Merged
Asdivyansh merged 1 commit intoNov 2, 2026
Merged
Conversation
The version was hard-coded as "0.2.0" in five places (--version, the logger and onboarding banners, and the integrations-test user-agent), so bumping package.json for a release would leave them stale. Add src/version.ts, which loads package.json with createRequire so the path resolves the same from src/ and from the bundled dist/ files and is unaffected by tests that mock node:fs. Use it everywhere. Fixes SilosLabs#10
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.
Fixes #10
What
src/version.ts: exportsVERSION, read frompackage.jsonwithcreateRequire(import.meta.url)("../package.json"). That path resolves the same fromsrc/(tsx, vitest) and from the bundleddist/cli.js/dist/proxy-daemon.js, andpackage.jsonships next todist/in the npm package, withnpm link, and withinstall.sh(which copies it).0.2.0s now useVERSION:silo --version(cli.ts), the logger banner, the two onboarding banners, and thesilo integrations testuser-agent.tests/version.test.ts: checks thatVERSIONmatchespackage.jsonand is a semver string.I used
createRequirerather thanfs.readFileSyncdeliberately:tests/commands/onboard.test.tsmocksnode:fswith onlyexistsSync, so areadFileSyncat module load would break any test that mocksfsthat way.Testing
npm run typecheck: passes.npm test: 24 files, 341 tests pass (2 new).npm run build: succeeds. Both bundles contain the runtimecreateRequire(...)("../package.json"), so nothing is baked in at build time.node dist/cli.js --versionprints0.2.0.package.jsonto0.2.1-test, it prints0.2.1-testwith no rebuild.