#!/bin/sh

set -eu

# Setup directories
rm -rf fuse-dist
mkdir -p fuse-dist/bin
mkdir -p fuse-dist/lib

# Create a test binary
cat > fuse-dist/bin/fuse << 'EOF'
#!/bin/sh
echo "DeclareData Fuse v1.0.0"
echo "Status: Running on port $1"
EOF

chmod +x fuse-dist/bin/fuse

# Create a test library (optional)
cat > fuse-dist/lib/helper.sh << 'EOF'
#!/bin/sh
# Example helper library
echo "Helper functions loaded"
EOF

# Create archive for each supported platform
for platform in "x86_64-darwin" "arm64-darwin" "x86_64-linux" "arm64-linux"; do
    echo "Creating archive for $platform"
    tar czf "fuse-${platform}-latest.tar.gz" fuse-dist
done

# Cleanup
rm -rf fuse-dist

echo "Created test archives with correct structure:"
ls -l fuse-*.tar.gz
