Single-source the version from package.json #95

Merged
clawbot merged 1 commits from issue-5-single-version into next2 2026-09-23 05:07:47 +02:00
Collaborator

Closes #5.

package.json is now the only place the version is written. src/index.ts imports it (with { type: "json" }) for VERSION, and bin/quak.ts passes VERSION to commander. The version stays 0.0.0.

Things the diff does not show:

  • tsc copies an imported package.json into dist/package.json (because rootDir is the repo root), so ../package.json resolves from dist/src/index.js as it does from src/index.ts. That copy is inside dist/, which is already in the files list, and npm always packs the root package.json as well; npm pack --dry-run lists both.
  • script/build now runs the built dist/bin/quak.js --version and fails if it differs from package.json, so every make build proves the import resolves from the built output.
  • test/smoke.test.ts replaces the non-empty check: it compares VERSION with package.json, and runs bin/quak.ts in-process with --version (stdout and process.exit stubbed) to compare what the CLI prints. Changing the CLI's version alone makes it fail.

Judgement call: dist/package.json is a full copy of the manifest; Node only reads its type field there, so it does not change how the package resolves.

Model: opus-5-5

Closes https://git.eeqj.de/sneak/quak/issues/5. `package.json` is now the only place the version is written. `src/index.ts` imports it (`with { type: "json" }`) for `VERSION`, and `bin/quak.ts` passes `VERSION` to commander. The version stays `0.0.0`. Things the diff does not show: - tsc copies an imported `package.json` into `dist/package.json` (because `rootDir` is the repo root), so `../package.json` resolves from `dist/src/index.js` as it does from `src/index.ts`. That copy is inside `dist/`, which is already in the `files` list, and npm always packs the root `package.json` as well; `npm pack --dry-run` lists both. - `script/build` now runs the built `dist/bin/quak.js --version` and fails if it differs from `package.json`, so every `make build` proves the import resolves from the built output. - `test/smoke.test.ts` replaces the non-empty check: it compares `VERSION` with `package.json`, and runs `bin/quak.ts` in-process with `--version` (stdout and `process.exit` stubbed) to compare what the CLI prints. Changing the CLI's version alone makes it fail. Judgement call: `dist/package.json` is a full copy of the manifest; Node only reads its `type` field there, so it does not change how the package resolves. Model: opus-5-5
clawbot added the needs-review label 2026-09-23 04:58:40 +02:00
clawbot self-assigned this 2026-09-23 04:58:40 +02:00
clawbot added 1 commit 2026-09-23 04:58:40 +02:00
src/index.ts imports package.json for VERSION and bin/quak.ts passes
VERSION to commander, so package.json is the only place the version is
written. tsc copies package.json to dist/package.json, so the import
resolves from the built output; script/build runs the built CLI with
--version to prove it. A test checks VERSION and quak --version against
package.json.

Model: opus-5-5
Author
Collaborator

PASS on 3354446 rebased onto next2 0ca8887.

Model: opus-5-5

PASS on `3354446` rebased onto `next2` `0ca8887`. Model: opus-5-5
clawbot merged commit d05b53d560 into next2 2026-09-23 05:07:47 +02:00
clawbot deleted branch issue-5-single-version 2026-09-23 05:07:47 +02:00
Sign in to join this conversation.