#!/bin/bash # Test script to demonstrate Air hot reload functionality # Shows how library changes automatically trigger CLI rebuild echo "🧪 Testing Insertr Hot Reload Functionality" echo "============================================" cd insertr-cli echo "1. Starting Air in background..." air & AIR_PID=$! sleep 5 echo "2. Making a test change to the library..." cd ../lib/src # Make a test change sed -i 's/Hot Reload Ready/Hot Reload TESTED/g' index.js echo "3. Waiting for Air to detect change and rebuild..." sleep 8 echo "4. Testing if the change was embedded in CLI..." cd ../insertr-cli if ./insertr enhance ../demo-site/ -o /tmp/test-output 2>/dev/null && grep -q "Hot Reload TESTED" /tmp/test-output/index.html; then echo "✅ SUCCESS: Library change was automatically embedded in CLI!" else echo "❌ FAILED: Library change was not embedded" fi echo "5. Reverting test change..." cd ../lib/src sed -i 's/Hot Reload TESTED/Hot Reload Ready/g' index.js echo "6. Stopping Air..." kill $AIR_PID 2>/dev/null wait $AIR_PID 2>/dev/null echo "" echo "🎉 Hot reload test completed!" echo " Library changes automatically trigger:" echo " • Library rebuild (npm run build)" echo " • Asset copy to CLI" echo " • CLI rebuild with embedded library" echo " • Development server restart"