#!/bin/bash

# Build script for secure stock-nse-india fork
set -e

echo "🔧 Building secure stock-nse-india fork..."

# Build the Docker image
echo "📦 Building Docker image..."
docker build -f Dockerfile.secure -t vercelink/stock-nse-india-secure:latest .

echo "🧪 Testing the build..."
# Test that the package can be imported
docker run --rm vercelink/stock-nse-india-secure:latest node -e "
const { NseIndia } = require('./build/index.js');
const nse = new NseIndia();
console.log('✅ Package imports successfully');
console.log('✅ NseIndia class instantiated');
"

echo "🔍 Checking axios version..."
docker run --rm vercelink/stock-nse-india-secure:latest npm ls axios

echo "🎉 Build completed successfully!"
echo "📋 Next steps:"
echo "   1. Test the package with your application"
echo "   2. Publish to npm registry if needed"
echo "   3. Update your project to use the secure version"
