195 lines
5.2 KiB
Bash
195 lines
5.2 KiB
Bash
|
|
#!/bin/bash
|
||
|
|
|
||
|
|
# xterm.js Upgrade Verification Script
|
||
|
|
# This script verifies that the upgrade to xterm.js 5.x was successful
|
||
|
|
|
||
|
|
set -e
|
||
|
|
|
||
|
|
echo "=========================================="
|
||
|
|
echo "xterm.js Upgrade Verification"
|
||
|
|
echo "=========================================="
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
# Color codes
|
||
|
|
RED='\033[0;31m'
|
||
|
|
GREEN='\033[0;32m'
|
||
|
|
YELLOW='\033[1;33m'
|
||
|
|
NC='\033[0m' # No Color
|
||
|
|
|
||
|
|
# Track overall status
|
||
|
|
FAILED=0
|
||
|
|
|
||
|
|
# Function to check if a file exists
|
||
|
|
check_file() {
|
||
|
|
if [ -f "$1" ]; then
|
||
|
|
echo -e "${GREEN}✓${NC} $1 exists"
|
||
|
|
return 0
|
||
|
|
else
|
||
|
|
echo -e "${RED}✗${NC} $1 NOT FOUND"
|
||
|
|
FAILED=1
|
||
|
|
return 1
|
||
|
|
fi
|
||
|
|
}
|
||
|
|
|
||
|
|
# Function to check if a directory exists
|
||
|
|
check_dir() {
|
||
|
|
if [ -d "$1" ]; then
|
||
|
|
echo -e "${GREEN}✓${NC} $1 exists"
|
||
|
|
return 0
|
||
|
|
else
|
||
|
|
echo -e "${RED}✗${NC} $1 NOT FOUND"
|
||
|
|
FAILED=1
|
||
|
|
return 1
|
||
|
|
fi
|
||
|
|
}
|
||
|
|
|
||
|
|
# Function to check package version
|
||
|
|
check_version() {
|
||
|
|
local package=$1
|
||
|
|
local expected=$2
|
||
|
|
|
||
|
|
if [ -f "node_modules/$package/package.json" ]; then
|
||
|
|
local version=$(grep '"version"' "node_modules/$package/package.json" | head -1 | sed 's/.*"\([0-9.]*\)".*/\1/')
|
||
|
|
echo -e "${GREEN}✓${NC} $package version: $version"
|
||
|
|
return 0
|
||
|
|
else
|
||
|
|
echo -e "${RED}✗${NC} $package NOT INSTALLED"
|
||
|
|
FAILED=1
|
||
|
|
return 1
|
||
|
|
fi
|
||
|
|
}
|
||
|
|
|
||
|
|
echo "1. Checking npm packages..."
|
||
|
|
echo "----------------------------"
|
||
|
|
check_dir "node_modules/@xterm/xterm"
|
||
|
|
check_dir "node_modules/@xterm/addon-fit"
|
||
|
|
check_version "@xterm/xterm" "5.x"
|
||
|
|
check_version "@xterm/addon-fit" "0.x"
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
echo "2. Checking xterm.js files..."
|
||
|
|
echo "----------------------------"
|
||
|
|
check_file "node_modules/@xterm/xterm/lib/xterm.js"
|
||
|
|
check_file "node_modules/@xterm/xterm/css/xterm.css"
|
||
|
|
check_file "node_modules/@xterm/addon-fit/lib/addon-fit.js"
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
echo "3. Checking custom files..."
|
||
|
|
echo "----------------------------"
|
||
|
|
check_file "static/terminado-addon.js"
|
||
|
|
check_file "node_modules/terminado-addon.js"
|
||
|
|
check_file "templates/term.html"
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
echo "4. Checking documentation..."
|
||
|
|
echo "----------------------------"
|
||
|
|
check_file "XTERM_UPGRADE.md"
|
||
|
|
check_file "UPGRADE_SUMMARY.md"
|
||
|
|
check_file "test_xterm.html"
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
echo "5. Verifying HTML template..."
|
||
|
|
echo "----------------------------"
|
||
|
|
if grep -q "@xterm/xterm/lib/xterm.js" templates/term.html; then
|
||
|
|
echo -e "${GREEN}✓${NC} HTML uses new xterm path"
|
||
|
|
else
|
||
|
|
echo -e "${RED}✗${NC} HTML still using old xterm path"
|
||
|
|
FAILED=1
|
||
|
|
fi
|
||
|
|
|
||
|
|
if grep -q "FitAddon.FitAddon" templates/term.html; then
|
||
|
|
echo -e "${GREEN}✓${NC} HTML uses new FitAddon API"
|
||
|
|
else
|
||
|
|
echo -e "${RED}✗${NC} HTML still using old addon API"
|
||
|
|
FAILED=1
|
||
|
|
fi
|
||
|
|
|
||
|
|
if grep -q "TerminadoAddon" templates/term.html; then
|
||
|
|
echo -e "${GREEN}✓${NC} HTML references TerminadoAddon"
|
||
|
|
else
|
||
|
|
echo -e "${RED}✗${NC} HTML missing TerminadoAddon reference"
|
||
|
|
FAILED=1
|
||
|
|
fi
|
||
|
|
|
||
|
|
if grep -q "loadAddon" templates/term.html; then
|
||
|
|
echo -e "${GREEN}✓${NC} HTML uses loadAddon() method"
|
||
|
|
else
|
||
|
|
echo -e "${RED}✗${NC} HTML still using applyAddon()"
|
||
|
|
FAILED=1
|
||
|
|
fi
|
||
|
|
|
||
|
|
if grep -q "applyAddon" templates/term.html; then
|
||
|
|
echo -e "${YELLOW}⚠${NC} HTML contains legacy applyAddon reference (might be in comments)"
|
||
|
|
fi
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
echo "6. Checking package.json..."
|
||
|
|
echo "----------------------------"
|
||
|
|
if grep -q '"@xterm/xterm"' package.json; then
|
||
|
|
echo -e "${GREEN}✓${NC} package.json has @xterm/xterm"
|
||
|
|
else
|
||
|
|
echo -e "${RED}✗${NC} package.json missing @xterm/xterm"
|
||
|
|
FAILED=1
|
||
|
|
fi
|
||
|
|
|
||
|
|
if grep -q '"@xterm/addon-fit"' package.json; then
|
||
|
|
echo -e "${GREEN}✓${NC} package.json has @xterm/addon-fit"
|
||
|
|
else
|
||
|
|
echo -e "${RED}✗${NC} package.json missing @xterm/addon-fit"
|
||
|
|
FAILED=1
|
||
|
|
fi
|
||
|
|
|
||
|
|
if grep -q '"xterm":' package.json; then
|
||
|
|
echo -e "${YELLOW}⚠${NC} package.json still has old 'xterm' package"
|
||
|
|
fi
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
echo "7. Checking Rust build..."
|
||
|
|
echo "----------------------------"
|
||
|
|
if command -v cargo &> /dev/null; then
|
||
|
|
echo -e "${GREEN}✓${NC} cargo is installed"
|
||
|
|
|
||
|
|
if cargo check --quiet 2>&1 | grep -q "error"; then
|
||
|
|
echo -e "${RED}✗${NC} Rust code has errors"
|
||
|
|
FAILED=1
|
||
|
|
else
|
||
|
|
echo -e "${GREEN}✓${NC} Rust code compiles successfully"
|
||
|
|
fi
|
||
|
|
else
|
||
|
|
echo -e "${YELLOW}⚠${NC} cargo not found, skipping Rust check"
|
||
|
|
fi
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
echo "8. Checking static assets route..."
|
||
|
|
echo "----------------------------"
|
||
|
|
if grep -q 'Files::new("/assets", "./static")' src/server.rs; then
|
||
|
|
echo -e "${GREEN}✓${NC} /assets route configured for static folder"
|
||
|
|
else
|
||
|
|
echo -e "${YELLOW}⚠${NC} /assets route not found (custom assets may not load)"
|
||
|
|
fi
|
||
|
|
|
||
|
|
if [ -f "static/bg.png" ]; then
|
||
|
|
echo -e "${GREEN}✓${NC} Background image exists"
|
||
|
|
else
|
||
|
|
echo -e "${YELLOW}⚠${NC} No background image found (optional)"
|
||
|
|
fi
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
echo "=========================================="
|
||
|
|
if [ $FAILED -eq 0 ]; then
|
||
|
|
echo -e "${GREEN}✓ All checks passed!${NC}"
|
||
|
|
echo ""
|
||
|
|
echo "The xterm.js upgrade is complete and verified."
|
||
|
|
echo "You can now run: cargo run"
|
||
|
|
echo "Then open: http://localhost:8082/"
|
||
|
|
echo "=========================================="
|
||
|
|
exit 0
|
||
|
|
else
|
||
|
|
echo -e "${RED}✗ Some checks failed!${NC}"
|
||
|
|
echo ""
|
||
|
|
echo "Please review the errors above and fix them."
|
||
|
|
echo "Refer to XTERM_UPGRADE.md for detailed instructions."
|
||
|
|
echo "=========================================="
|
||
|
|
exit 1
|
||
|
|
fi
|