#!/bin/bash # Test build script for the Dispute Protocol site # This script builds the site and runs a temporary server to check it works set -e # Colors for output GREEN='\033[0;32m' YELLOW='\033[1;33m' RED='\033[0;31m' NC='\033[0m' # No Color # Configuration BUILD_DIR="public" PORT=${1:-8080} # Check if Hugo is installed if ! command -v hugo &> /dev/null; then echo -e "${RED}Error: Hugo is not installed. Please install Hugo first.${NC}" echo "Visit https://gohugo.io/installation/ for installation instructions." exit 1 fi echo -e "${YELLOW}Building site...${NC}" hugo --minify # Check if build succeeded if [ ! -d "$BUILD_DIR" ]; then echo -e "${RED}Error: Build failed. The '$BUILD_DIR' directory doesn't exist.${NC}" exit 1 fi echo -e "${GREEN}Build completed successfully!${NC}" echo -e "${YELLOW}Starting a temporary server on port $PORT...${NC}" echo -e "${YELLOW}Press Ctrl+C to stop the server.${NC}" cd $BUILD_DIR python3 -m http.server $PORT exit 0