fix(ci/sdk): the SDK could not be published at all — bun publish runs prepare
ci / web (pull_request) Successful in 1m10s
ci / rust-arm64 (pull_request) Successful in 2m28s
ci / docs-site (pull_request) Successful in 1m23s
ci / bun-nix (pull_request) Successful in 26s
ci / rust (pull_request) Successful in 4m45s
nix / flake (pull_request) Successful in 15m6s

`sdk-v0.1.3` failed at the publish step with `bun2nix: command not found`, exit 127.
Nothing was published, so 0.1.3 is still free.

`bun publish` runs the `prepare` lifecycle script, and sdk's `prepare` is
`bun2nix -o bun.nix` — regenerating the nix dependency file. That tool is a
devDependency of the repo, not something the `oven/bun:1` publish container has, and
the workflow's own install is `--ignore-scripts`, so nothing put it on PATH either.

This was latent, not new. `prepare` gained the bun2nix call on 2026-07-27 (1db8f763,
"move the bun packages to bun2nix"), while the last SDK publish was 0.1.2, bumped
2026-07-20. So the hook has been broken for every SDK release since it landed, and
0.1.3 is simply the first one to try. `@punktfunk/plugin-kit` has no `prepare` and was
never affected, which is why kit 0.3.2 published fine in that window and hid this.

The fix is NOT to copy `web/package.json`, which does the same job from `postinstall`.
That is right for web — it is never published — and would be worse here: a published
package's `postinstall` runs in every CONSUMER's install, so every plugin depending on
`@punktfunk/host` would try to run bun2nix and fail. `prepare` is the correct hook for
a published package (it does not run for consumers); it just must not assume a
repo-maintenance tool exists wherever a publish happens.

So the script skips when bun2nix is absent — and ONLY then. A present-but-failing
bun2nix still fails the script, because swallowing that would publish with a silently
stale bun.nix, which is the exact hand-maintained-hash problem 1db8f763 set out to end.
Both directions measured against the same `sh -e` bun and the Gitea runner use:
absent → exit 0, present-and-failing → exit 3.

`bun publish --dry-run` now completes and reports `+ @punktfunk/host@0.1.3`.
This commit is contained in:
2026-08-08 12:55:37 +02:00
parent e4f8c64b9f
commit 1df39d9617
+1 -1
View File
@@ -34,7 +34,7 @@
"registry": "https://git.unom.io/api/packages/unom/npm/"
},
"scripts": {
"prepare": "bun2nix -o bun.nix",
"prepare": "if command -v bun2nix >/dev/null 2>&1; then bun2nix -o bun.nix; fi",
"gen": "openapigen --spec ../api/openapi.json --name Punktfunk --format httpclient > src/gen/punktfunk.ts",
"typecheck": "tsc --noEmit",
"build": "tsc -p tsconfig.build.json",