mirror of
https://github.com/BigBodyCobain/Shadowbroker.git
synced 2026-09-27 03:01:51 +02:00
fix: integrate AI cross-platform start scripts
Former-commit-id: 2054b6036d
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "concurrently \"npm run dev:frontend\" \"npm run dev:backend\"",
|
"dev": "concurrently \"npm run dev:frontend\" \"npm run dev:backend\"",
|
||||||
"dev:frontend": "next dev",
|
"dev:frontend": "next dev",
|
||||||
"dev:backend": "cd ../backend && python -m uvicorn main:app --reload",
|
"dev:backend": "node ../start-backend.js",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"lint": "eslint"
|
"lint": "eslint"
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
const { execSync } = require("child_process");
|
||||||
|
const path = require("path");
|
||||||
|
const fs = require("fs");
|
||||||
|
|
||||||
|
const backendDir = path.resolve(__dirname, "backend");
|
||||||
|
const venvBin = process.platform === "win32"
|
||||||
|
? path.join(backendDir, "venv", "Scripts", "python.exe")
|
||||||
|
: path.join(backendDir, "venv", "bin", "python3");
|
||||||
|
|
||||||
|
if (!fs.existsSync(venvBin)) {
|
||||||
|
console.error(`[!] Python venv not found at: ${venvBin}`);
|
||||||
|
console.error("[!] Run start.sh (Mac/Linux) or start.bat (Windows) first to create the venv.");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`[*] Starting backend with: ${venvBin}`);
|
||||||
|
execSync(`"${venvBin}" -m uvicorn main:app --reload`, {
|
||||||
|
cwd: backendDir,
|
||||||
|
stdio: "inherit",
|
||||||
|
});
|
||||||
@@ -10,31 +10,38 @@ if ! command -v npm &> /dev/null; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for Python
|
# Check for Python 3
|
||||||
if ! command -v python3 &> /dev/null; then
|
PYTHON_CMD=""
|
||||||
|
if command -v python3 &> /dev/null; then
|
||||||
|
PYTHON_CMD="python3"
|
||||||
|
elif command -v python &> /dev/null; then
|
||||||
|
PYTHON_CMD="python"
|
||||||
|
else
|
||||||
echo "[!] ERROR: python3 is not installed. Please install Python 3.10+ (https://python.org/)"
|
echo "[!] ERROR: python3 is not installed. Please install Python 3.10+ (https://python.org/)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "[*] Using Python: $PYTHON_CMD ($($PYTHON_CMD --version 2>&1))"
|
||||||
|
|
||||||
|
# Get the directory where this script lives (handles running from any location)
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
|
|
||||||
echo "[*] Setting up Backend Environment..."
|
echo "[*] Setting up Backend Environment..."
|
||||||
cd backend
|
cd "$SCRIPT_DIR/backend"
|
||||||
if [ ! -d "venv" ]; then
|
if [ ! -d "venv" ]; then
|
||||||
echo "[*] Creating Python Virtual Environment..."
|
echo "[*] Creating Python Virtual Environment..."
|
||||||
python3 -m venv venv
|
$PYTHON_CMD -m venv venv
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "[*] Installing Backend dependencies..."
|
echo "[*] Installing Backend dependencies..."
|
||||||
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
|
source venv/bin/activate
|
||||||
# In case someone runs this in Git Bash on Windows
|
pip install -q -r requirements.txt
|
||||||
source venv/Scripts/activate
|
deactivate
|
||||||
else
|
|
||||||
source venv/bin/activate
|
cd "$SCRIPT_DIR"
|
||||||
fi
|
|
||||||
pip install -r requirements.txt
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
echo "[*] Setting up Frontend Environment..."
|
echo "[*] Setting up Frontend Environment..."
|
||||||
cd frontend
|
cd "$SCRIPT_DIR/frontend"
|
||||||
if [ ! -d "node_modules" ]; then
|
if [ ! -d "node_modules" ]; then
|
||||||
echo "[*] Installing Frontend dependencies..."
|
echo "[*] Installing Frontend dependencies..."
|
||||||
npm install
|
npm install
|
||||||
@@ -42,11 +49,10 @@ fi
|
|||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "======================================================="
|
echo "======================================================="
|
||||||
echo " 🚀 Starting Services... "
|
echo " Starting Services... "
|
||||||
echo " Dashboard will be available at: http://localhost:3000"
|
echo " Dashboard will be available at: http://localhost:3000 "
|
||||||
echo " Keep this window open! Note: Initial load takes ~10s "
|
echo " Keep this window open! Initial load takes ~10s "
|
||||||
echo "======================================================="
|
echo "======================================================="
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# Start both services (npm run dev automatically calls the python backend on Mac/Linux if scripts are configured cross-platform)
|
|
||||||
npm run dev
|
npm run dev
|
||||||
|
|||||||
Reference in New Issue
Block a user