#!/bin/bash
set -e

echo "🚀 Publishing to npm from correct directory..."

# Change to the script's directory
cd "$(dirname "$0")"

# Verify we're in the right place
if [ ! -f "package.json" ]; then
    echo "❌ Error: package.json not found!"
    exit 1
fi

# Check current package info
echo "📦 Package info:"
npm pack --dry-run | head -3

# Publish to npm
echo "📤 Publishing to npm..."
npm publish --access public

echo "✅ Successfully published!"
echo "🎉 Install with: npm install -g wappler-cleanup-tool"