#!/bin/bash
# DSS npm publish script

set -e

echo "🚀 Publishing @overbits/dss to npm..."

# Ensure we're in the cli directory
cd "$(dirname "$0")/.."

# Build
echo "📦 Building..."
npm run build

# Check if logged in to npm
if ! npm whoami &> /dev/null; then
    echo "❌ Not logged in to npm. Run: npm login"
    exit 1
fi

# Verify package
echo "📋 Package contents:"
npm pack --dry-run

# Confirm
read -p "Publish to npm? (y/N) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
    echo "Cancelled."
    exit 0
fi

# Publish
npm publish --access public

echo "✅ Published @overbits/dss!"
echo ""
echo "Users can now install with:"
echo "  npm install -g @overbits/dss"
echo "  npx @overbits/dss"
