This commit is contained in:
Benjamin Toby 2026-07-14 09:13:07 +01:00
parent 56462e6cc2
commit 3faf4be368
2 changed files with 40 additions and 9 deletions

View File

@ -21,7 +21,10 @@
"bun": ">=1.0.0" "bun": ">=1.0.0"
}, },
"scripts": { "scripts": {
"dev": "tsc --watch" "dev": "tsc --watch",
"compile": "rm -rf dist tsconfig.tsbuildinfo && tsc -p tsconfig.json",
"typecheck": "tsc -p tsconfig.json --noEmit",
"prepublishOnly": "bun run compile"
}, },
"devDependencies": { "devDependencies": {
"@types/bun": "latest", "@types/bun": "latest",

View File

@ -2,23 +2,51 @@
set -euo pipefail set -euo pipefail
cd "$(dirname "$0")"
if [ -z "${1:-}" ]; then if [ -z "${1:-}" ]; then
msg="Updates" msg="Updates"
else else
msg="$1" msg="$1"
fi fi
tsc --noEmit # Always use the project's TypeScript (global `tsc` may not emit)
rm -rf dist export PATH="$(pwd)/node_modules/.bin:$PATH"
tsc
# Ensure CLI shebang survived compile if [ ! -x "./node_modules/.bin/tsc" ]; then
if ! head -1 dist/commands/index.js | grep -q '#!/usr/bin/env bun'; then echo "Installing dependencies..."
echo "ERROR: dist/commands/index.js is missing the bun shebang" bun install
fi
echo "Typechecking..."
tsc -p tsconfig.json --noEmit
echo "Compiling..."
# Clear emit output AND incremental cache. Otherwise a prior --noEmit run leaves
# tsbuildinfo "up to date" and tsc emits nothing after `rm -rf dist`.
rm -rf dist tsconfig.tsbuildinfo
tsc -p tsconfig.json
if [ ! -f dist/commands/index.js ]; then
echo "ERROR: compile failed — dist/commands/index.js was not produced"
exit 1 exit 1
fi fi
git add . # Ensure CLI shebang survived compile
if ! head -1 dist/commands/index.js | grep -q '^#!/usr/bin/env bun'; then
echo "Restoring bun shebang on dist/commands/index.js"
printf '%s\n' '#!/usr/bin/env bun' | cat - dist/commands/index.js > dist/commands/index.js.tmp
mv dist/commands/index.js.tmp dist/commands/index.js
fi
chmod +x dist/commands/index.js
echo "Build OK: $(head -1 dist/commands/index.js)"
echo "Publishing package..."
git add -A
git commit -m "$msg" || true git commit -m "$msg" || true
git push git push || true
bun publish bun publish
echo "Done."