Port bun-mariadb conventions: init globals, db handler, split schema sync
- init() loads config, schema and the SQLite client once into globals - all CRUD queries go through lib/db-handler.ts (optional per-call config) - split db-schema-manager.ts into lib/schema/* with FK-aware table ordering - add bun:test tests for schema ordering, FK constraints and schema sync - config/schema files can be .ts/.js/.json/.yaml/.yml; db_schema_file_name is now optional (defaults to schema.* in db_dir) - add export/import commands (database snapshot + schema archives) - package exports map, type re-exports, hardened publish.sh - validate table name in delete Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
+43
-8
@@ -1,17 +1,52 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -euo pipefail
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
if [ -z "${1:-}" ]; then
|
||||
msg="Updates"
|
||||
else
|
||||
msg="$1"
|
||||
fi
|
||||
|
||||
tsc --noEmit
|
||||
rm -rf dist
|
||||
tsc
|
||||
git add .
|
||||
git commit -m "$msg"
|
||||
git push
|
||||
# Always use the project's TypeScript (global `tsc` may not emit)
|
||||
export PATH="$(pwd)/node_modules/.bin:$PATH"
|
||||
|
||||
if [ ! -x "./node_modules/.bin/tsc" ]; then
|
||||
echo "Installing dependencies..."
|
||||
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
|
||||
fi
|
||||
|
||||
# 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 push || true
|
||||
bun publish
|
||||
|
||||
echo "Done."
|
||||
|
||||
Reference in New Issue
Block a user