init: 初始化项目

This commit is contained in:
0264408
2026-03-10 16:26:48 +08:00
commit 57e0ef2cf6
79 changed files with 8943 additions and 0 deletions

33
scripts/build-prod.bat Normal file
View File

@@ -0,0 +1,33 @@
@echo off
echo Building Nebula for production...
echo.
echo Building frontend...
cd web
call pnpm build
if errorlevel 1 (
echo Frontend build failed!
exit /b 1
)
cd ..
echo.
echo Building backend...
go build -o nebula-server.exe ./cmd/nebula-server
if errorlevel 1 (
echo Backend build failed!
exit /b 1
)
echo.
echo ========================================
echo Build completed successfully!
echo ========================================
echo.
echo To run in production mode:
echo set SERVER_MODE=prod
echo .\nebula-server.exe
echo.
echo Or use the start script:
echo .\scripts\start.bat

33
scripts/build-prod.sh Normal file
View File

@@ -0,0 +1,33 @@
#!/bin/bash
echo "Building Nebula for production..."
echo ""
echo "Building frontend..."
cd web
pnpm build
if [ $? -ne 0 ]; then
echo "Frontend build failed!"
exit 1
fi
cd ..
echo ""
echo "Building backend..."
go build -o nebula-server ./cmd/nebula-server
if [ $? -ne 0 ]; then
echo "Backend build failed!"
exit 1
fi
echo ""
echo "========================================"
echo "Build completed successfully!"
echo "========================================"
echo ""
echo "To run in production mode:"
echo " SERVER_MODE=prod ./nebula-server"
echo ""
echo "Or use the start script:"
echo " ./scripts/start.sh"

24
scripts/build.bat Normal file
View File

@@ -0,0 +1,24 @@
@echo off
setlocal
set BINARY=nebula-server
set OUT_DIR=dist
set WEB_DIR=web
echo Building frontend...
cd %WEB_DIR%
call pnpm run build
if %ERRORLEVEL% neq 0 (
echo Frontend build failed.
exit /b 1
)
cd ..
if not exist %OUT_DIR% mkdir %OUT_DIR%
echo Building %BINARY%...
go build -o %OUT_DIR%\%BINARY%.exe ./cmd/nebula-server/
if %ERRORLEVEL% neq 0 (
echo Build failed.
exit /b 1
)
echo Build done: %OUT_DIR%\%BINARY%.exe
endlocal

16
scripts/build.sh Normal file
View File

@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -e
BINARY=nebula-server
OUT_DIR=dist
WEB_DIR=web
echo "Building frontend..."
(cd "$WEB_DIR" && pnpm run build)
[[ -d "$OUT_DIR" ]] || mkdir -p "$OUT_DIR"
SUFFIX=""
[[ "$GOOS" == "windows" ]] && SUFFIX=".exe"
echo "Building $BINARY..."
go build -o "$OUT_DIR/${BINARY}${SUFFIX}" ./cmd/nebula-server/
echo "Build done: $OUT_DIR/${BINARY}${SUFFIX}"

14
scripts/dev.bat Normal file
View File

@@ -0,0 +1,14 @@
@echo off
echo Starting Nebula development environment...
echo.
echo Starting backend server (dev mode)...
start "Nebula Backend" cmd /c "set SERVER_MODE=dev && go run ./cmd/nebula-server/main.go"
echo Waiting for backend to start...
timeout /t 3 /nobreak >nul
echo.
echo Starting frontend (Vite dev server)...
cd web
pnpm dev

27
scripts/dev.sh Normal file
View File

@@ -0,0 +1,27 @@
#!/bin/bash
echo "Starting Nebula development environment..."
echo ""
echo "Starting backend server (dev mode)..."
SERVER_MODE=dev go run ./cmd/nebula-server/main.go &
BACKEND_PID=$!
echo "Backend started with PID: $BACKEND_PID"
echo "Waiting for backend to start..."
sleep 3
echo ""
echo "Starting frontend (Vite dev server)..."
cd web
pnpm dev
# Cleanup function to kill backend when script exits
cleanup() {
echo ""
echo "Shutting down backend server..."
kill $BACKEND_PID 2>/dev/null
exit
}
trap cleanup INT TERM

5
scripts/start.bat Normal file
View File

@@ -0,0 +1,5 @@
@echo off
echo Starting Nebula in production mode...
set SERVER_MODE=prod
nebula-server.exe

5
scripts/start.sh Normal file
View File

@@ -0,0 +1,5 @@
#!/bin/bash
echo "Starting Nebula in production mode..."
SERVER_MODE=prod ./nebula-server