Skip to content

fix(cli): report the real version instead of a hardcoded 0.1.0 - #17

Merged
mschmicking merged 1 commit into
mainfrom
fix/version-from-package
Jul 31, 2026
Merged

fix(cli): report the real version instead of a hardcoded 0.1.0#17
mschmicking merged 1 commit into
mainfrom
fix/version-from-package

Conversation

@mschmicking

Copy link
Copy Markdown
Owner

Found by installing the published package and running it:

$ npm i iobroker-sync   # 1.0.0
$ iob-sync --version
0.1.0

The version was a literal in cli.ts. release-please bumps package.json and cannot reach a string in the source, so every release since 0.1.0 would have reported the wrong number.

Now read from package.json at runtime. Verified by dropping the built file into the package installed from npm. The cli test compares against package.json so they cannot drift again.

Found by installing the published package and running it: iobroker-sync@1.0.0
printed 0.1.0 for --version. The version was a string literal in cli.ts, and
release-please bumps package.json — it has no way to reach a literal in the
source, so every release since 0.1.0 would have lied.

It is now read from package.json at runtime via createRequire. dist/cli.js
sits one level below package.json both in the repository and in the
installed package, so the relative path holds in both; verified by dropping
the built file into the package installed from npm.

The cli test now compares --version against package.json rather than a
regex, so the two cannot drift again.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@mschmicking
mschmicking merged commit 3f62ac0 into main Jul 31, 2026
7 checks passed
@mschmicking
mschmicking deleted the fix/version-from-package branch July 31, 2026 13:31
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