#!/bin/bash # Application Analysis and Download Script # Downloads source code and analyzes application requirements for Cloudron packaging set -e WORKSPACE="/home/localuser/TSYSDevStack/Cloudron/CloudronPackages-Workspace" GIT_URL_LIST="/home/localuser/TSYSDevStack/Cloudron/GitUrlList.txt" # Function to analyze application type and requirements analyze_application() { local app_dir="$1" local app_name="$2" echo "🔍 Analyzing $app_name..." cd "$app_dir" # Detect application type if [ -f "go.mod" ]; then echo " ✅ Go application detected" echo " 📦 Go version: $(grep -E '^go [0-9]' go.mod | cut -d' ' -f2)" echo " 🔗 Module: $(grep '^module ' go.mod | cut -d' ' -f2)" # Look for main.go or cmd directory if [ -f "main.go" ]; then echo " 🎯 Entry point: main.go" elif [ -d "cmd" ]; then echo " 🎯 Entry point: cmd/ directory" find cmd -name "main.go" -type f | head -3 | sed 's/^/ 📁 /' fi # Check for Dockerfile if [ -f "Dockerfile" ]; then echo " 🐳 Original Dockerfile found" head -5 Dockerfile | sed 's/^/ /' fi elif [ -f "package.json" ]; then echo " ✅ Node.js application detected" echo " 📦 Package name: $(grep -E '"name":' package.json | cut -d'"' -f4)" echo " 🚀 Scripts: $(grep -E '"start":|"dev":' package.json | tr '\n' ' ')" # Check for build tools if grep -q "webpack\|vite\|rollup" package.json; then echo " 🔨 Build tools detected" fi elif [ -f "requirements.txt" ] || [ -f "setup.py" ] || [ -f "pyproject.toml" ]; then echo " ✅ Python application detected" if [ -f "requirements.txt" ]; then echo " 📦 Dependencies: $(wc -l < requirements.txt) packages" fi elif [ -f "pom.xml" ] || [ -f "build.gradle" ]; then echo " ✅ Java application detected" if [ -f "pom.xml" ]; then echo " 📦 Maven project" grep -E '||' pom.xml | head -3 | sed 's/^/ /' fi elif [ -f "Cargo.toml" ]; then echo " ✅ Rust application detected" grep -E '^\[package\]' -A 5 Cargo.toml | sed 's/^/ /' else echo " ❓ Unknown application type" echo " 📁 Key files:" ls -la | head -10 | sed 's/^/ /' fi echo "" } # Function to download and analyze one application process_application() { local line_number="$1" local git_url="$2" # Extract app name from URL local app_name=$(basename "$git_url" | sed 's/.git$//') local app_dir="$WORKSPACE/$app_name" echo "📥 Processing $line_number: $app_name from $git_url" # Skip if already downloaded (like goalert) if [ -d "$app_dir" ] && [ "$(find "$app_dir" -maxdepth 1 -type f ! -path "*/app/*" | wc -l)" -gt 5 ]; then echo "⏭️ Already downloaded, analyzing..." analyze_application "$app_dir" "$app_name" return fi # Download the repository echo "📥 Downloading $app_name..." if ! git clone "$git_url" "$app_dir" 2>/dev/null; then echo "❌ Failed to clone $git_url" return fi echo "✅ Downloaded $app_name" # Analyze the application analyze_application "$app_dir" "$app_name" } # Main execution echo "🚀 Starting application analysis and download..." echo "📁 Workspace: $WORKSPACE" echo "📋 URL list: $GIT_URL_LIST" echo "" # Process first 10 applications to establish pattern echo "🎯 Processing first 10 applications to establish pattern..." echo "" head -10 "$GIT_URL_LIST" | while IFS= read -r git_url; do line_number=$((10#$(grep -n "$git_url" "$GIT_URL_LIST" | cut -d: -f1))) process_application "$line_number" "$git_url" done echo "🎉 First batch analysis complete!" echo "📊 Summary: Analyzed application types and requirements" echo ""