echo "Running pre-commit checks..."

# Build (required for integ type-check: workspace symlink resolves to dist/)
echo "Building..."
npm run build || { echo "Build failed. Commit aborted."; exit 1; }

# Run tests
echo "Running tests..."
npm run test:coverage || { echo "Tests failed. Commit aborted."; exit 1; }
# WASM tests disabled until componentize-js stream<T> support lands and
# entry.ts re-binds to the per-domain WIT layout. CI's ts-test job runs
# the TS SDK suite; WASM tests are tracked under phase-1 bridge tasks.

# Run linting
echo "Running linting..."
npm run lint || { echo "Linting failed. Commit aborted."; exit 1; }

# Check formatting
echo "Checking code formatting..."
npm run format:check || { echo "Formatting check failed. Run 'npm run format' to fix. Commit aborted."; exit 1; }

# Type checking
echo "Running type checks..."
npm run type-check || { echo "Type checking failed. Commit aborted."; exit 1; }

echo "All pre-commit checks passed!"
