#!/bin/bash # ConnectHub Enhanced Deployment Script # سكريبت نشر ConnectHub المحسن set -e echo "🚀 ConnectHub Enhanced Deployment Script" echo "==========================================" # الألوان للمخرجات RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color # دالة طباعة ملونة print_color() { echo -e "${1}${2}${NC}" } # التحقق من المتطلبات check_requirements() { print_color $BLUE "🔍 التحقق من المتطلبات..." # التحقق من Node.js if ! command -v node &> /dev/null; then print_color $RED "❌ Node.js غير مثبت. يرجى تثبيته أولاً." exit 1 fi # التحقق من npm if ! command -v npm &> /dev/null; then print_color $RED "❌ npm غير مثبت. يرجى تثبيته أولاً." exit 1 fi print_color $GREEN "✅ جميع المتطلبات متوفرة" } # تثبيت التبعيات install_dependencies() { print_color $BLUE "📦 تثبيت التبعيات..." if [ -f "package.json" ]; then npm install print_color $GREEN "✅ تم تثبيت التبعيات بنجاح" else print_color $YELLOW "⚠️ ملف package.json غير موجود، سيتم إنشاؤه..." create_package_json fi } # إنشاء package.json إذا لم يكن موجود create_package_json() { cat > package.json << EOF { "name": "connecthub-enhanced", "version": "2.0.0", "description": "ConnectHub - منصة التواصل الاجتماعي المتقدمة المحسنة", "main": "enhanced-index.html", "scripts": { "start": "npx http-server -p 8080 -o", "dev": "npx http-server -p 3000 -o -c-1", "build": "echo 'No build step required for pure HTML/CSS/JS'", "test": "echo 'No tests specified'", "deploy": "gh-pages -d .", "validate": "node scripts/validate.js", "optimize": "node scripts/optimize.js" }, "keywords": [ "social-media", "web-app", "voice-comments", "multilingual", "javascript", "html5", "css3", "accessibility", "pwa", "dark-mode" ], "author": "MiniMax Agent", "license": "MIT", "repository": { "type": "git", "url": "https://github.com/yourusername/connecthub-enhanced.git" }, "bugs": { "url": "https://github.com/yourusername/connecthub-enhanced/issues" }, "homepage": "https://yourusername.github.io/connecthub-enhanced", "devDependencies": { "http-server": "^14.1.1", "gh-pages": "^6.1.1", "html-validator": "^10.1.0", "cssnano": "^6.0.1", "terser": "^5.24.0" }, "browserslist": [ "> 1%", "last 2 versions", "not dead" ], "engines": { "node": ">=16.0.0", "npm": ">=8.0.0" } } EOF print_color $GREEN "✅ تم إنشاء package.json" } # تحسين الملفات optimize_files() { print_color $BLUE "⚡ تحسين الملفات..." # إنشاء مجلد للملفات المحسنة mkdir -p dist # نسخ الملفات الأساسية cp enhanced-index.html dist/index.html cp enhanced-styles.css dist/styles.css cp enhanced-features.js dist/app.js cp translations.js dist/ # ضغط CSS if command -v npx &> /dev/null; then npx cssnano dist/styles.css dist/styles.min.css --replace mv dist/styles.min.css dist/styles.css fi # ضغط JavaScript if command -v npx &> /dev/null; then npx terser dist/app.js -o dist/app.min.js --compress --mangle mv dist/app.min.js dist/app.js fi print_color $GREEN "✅ تم تحسين الملفات" } # تشغيل الاختبارات run_tests() { print_color $BLUE "🧪 تشغيل الاختبارات..." # التحقق من HTML if command -v npx &> /dev/null; then npx html-validator dist/index.html --quiet || print_color $YELLOW "⚠️ تحذيرات في HTML" fi # التحقق من JavaScript syntax node -c dist/app.js || print_color $RED "❌ أخطاء في JavaScript" print_color $GREEN "✅ تم تشغيل الاختبارات" } # تشغيل التطبيق محلياً run_local() { print_color $BLUE "🚀 تشغيل التطبيق محلياً..." if command -v npx &> /dev/null; then npx http-server -p 8080 -o else print_color $YELLOW "⚠️ npx غير متوفر، افتح enhanced-index.html يدوياً" fi } # النشر على GitHub Pages deploy_github() { print_color $BLUE "📤 النشر على GitHub Pages..." if ! command -v git &> /dev/null; then print_color $RED "❌ Git غير مثبت" exit 1 fi if ! command -v gh-pages &> /dev/null; then print_color $RED "❌ gh-pages غير مثبت. قم بتثبيته: npm install -g gh-pages" exit 1 fi # التحقق من وجود مستودع git if [ ! -d ".git" ]; then print_color $YELLOW "⚠️ لا يوجد مستودع git. إنشاء مستودع جديد..." git init git add . git commit -m "Initial commit - ConnectHub Enhanced" fi # نشر على GitHub Pages gh-pages -d dist print_color $GREEN "✅ تم النشر على GitHub Pages بنجاح!" print_color $BLUE "🌐 رابط التطبيق: https://yourusername.github.io/connecthub-enhanced" } # إنشاء تقرير التحسينات generate_report() { print_color $BLUE "📊 إنشاء تقرير التحسينات..." cat > dist/report.html << 'EOF'
تم تطبيق تحسينات شاملة على منصة ConnectHub
للحصول على الدعم أو الإبلاغ عن مشاكل، يرجى زيارة: