Spaces:
Paused
Paused
| # SillyLoops - Build and Launch Script | |
| # Builds the Flutter web app and launches it in the browser | |
| set -e | |
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | |
| cd "$SCRIPT_DIR" | |
| echo "π₯ SillyLoops - Build & Launch" | |
| echo "==============================" | |
| echo "" | |
| # Colors for output | |
| RED='\033[0;31m' | |
| GREEN='\033[0;32m' | |
| YELLOW='\033[1;33m' | |
| BLUE='\033[0;34m' | |
| NC='\033[0m' # No Color | |
| # Check if Flutter is installed | |
| if ! command -v flutter &> /dev/null; then | |
| echo -e "${RED}β Flutter is not installed or not in PATH${NC}" | |
| echo "" | |
| echo "Please install Flutter:" | |
| echo " macOS: brew install --cask flutter" | |
| echo " Or visit: https://docs.flutter.dev/get-started/install" | |
| echo "" | |
| exit 1 | |
| fi | |
| echo -e "${BLUE}π± Checking Flutter installation...${NC}" | |
| flutter --version | |
| echo "" | |
| # Run Flutter doctor | |
| echo -e "${BLUE}π Running Flutter Doctor...${NC}" | |
| flutter doctor -v 2>&1 | head -20 || true | |
| echo "" | |
| # Download samples if needed | |
| if [ ! -f "assets/samples/README.txt" ] && [ "$(ls -A assets/samples 2>/dev/null)" = "" ]; then | |
| echo -e "${YELLOW}π¦ Downloading drum samples...${NC}" | |
| ./download_samples.sh || true | |
| echo "" | |
| fi | |
| # Get dependencies | |
| echo -e "${BLUE}π₯ Installing Flutter dependencies...${NC}" | |
| flutter pub get | |
| echo "" | |
| # Clean previous build | |
| echo -e "${BLUE}π§Ή Cleaning previous builds...${NC}" | |
| flutter clean | |
| echo "" | |
| # Build for web | |
| echo -e "${BLUE}π¨ Building for web...${NC}" | |
| flutter build web --release | |
| if [ $? -eq 0 ]; then | |
| echo -e "${GREEN}β Web build successful!${NC}" | |
| echo "" | |
| else | |
| echo -e "${RED}β Build failed${NC}" | |
| exit 1 | |
| fi | |
| # Launch in browser | |
| echo -e "${BLUE}π Launching in browser...${NC}" | |
| # Determine which browser to use | |
| BROWSER="" | |
| if command -v open &> /dev/null; then | |
| # macOS | |
| BROWSER="open" | |
| elif command -v xdg-open &> /dev/null; then | |
| # Linux | |
| BROWSER="xdg-open" | |
| elif command -v start &> /dev/null; then | |
| # Windows | |
| BROWSER="start" | |
| fi | |
| if [ -n "$BROWSER" ]; then | |
| BUILD_DIR="$SCRIPT_DIR/build/web" | |
| echo "Opening: $BUILD_DIR/index.html" | |
| # Start a local server (Python) | |
| echo -e "${GREEN}π Starting local server...${NC}" | |
| echo "" | |
| echo -e "${YELLOW}Note: Press Ctrl+C to stop the server${NC}" | |
| echo "" | |
| cd "$BUILD_DIR" | |
| # Try Python 3 first, then Python 2 | |
| if command -v python3 &> /dev/null; then | |
| python3 -m http.server 8080 & | |
| SERVER_PID=$! | |
| sleep 2 | |
| $BROWSER "http://localhost:8080" | |
| wait $SERVER_PID | |
| elif command -v python &> /dev/null; then | |
| python -m SimpleHTTPServer 8080 & | |
| SERVER_PID=$! | |
| sleep 2 | |
| $BROWSER "http://localhost:8080" | |
| wait $SERVER_PID | |
| else | |
| echo -e "${RED}β No Python found. Please open build/web/index.html manually${NC}" | |
| echo "Path: $BUILD_DIR/index.html" | |
| $BROWSER "$BUILD_DIR/index.html" | |
| fi | |
| else | |
| echo -e "${YELLOW}β οΈ Could not determine browser${NC}" | |
| echo "Please open manually: $SCRIPT_DIR/build/web/index.html" | |
| fi | |
| echo "" | |
| echo "==============================" | |
| echo -e "${GREEN}β SillyLoops is ready!${NC}" | |