-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add PWA support and local launch scripts #1422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| @echo off | ||
| REM VOIDSTRIKE — Local Play Launcher (Windows) | ||
| REM Double-click this file to launch the game | ||
|
|
||
| setlocal enabledelayedexpansion | ||
|
|
||
| set "SCRIPT_DIR=%~dp0" | ||
| set "PROJECT_DIR=%SCRIPT_DIR%.." | ||
| set "PORT=3000" | ||
| if defined VOIDSTRIKE_PORT set "PORT=%VOIDSTRIKE_PORT%" | ||
| set "URL=http://localhost:%PORT%" | ||
|
|
||
| cd /d "%PROJECT_DIR%" | ||
|
|
||
| echo. | ||
| echo ======================================== | ||
| echo V O I D S T R I K E | ||
| echo Local Play Launcher | ||
| echo ======================================== | ||
| echo. | ||
|
|
||
| REM ============================================ | ||
| REM Check Node.js | ||
| REM ============================================ | ||
| where node >nul 2>nul | ||
| if %errorlevel% neq 0 ( | ||
| echo [ERROR] Node.js not found. Install it from https://nodejs.org | ||
| pause | ||
| exit /b 1 | ||
| ) | ||
|
|
||
| for /f "tokens=1 delims=v." %%a in ('node -v') do set "NODE_MAJOR=%%a" | ||
| REM node -v returns "v20.x.x" — strip the 'v' prefix | ||
| for /f "tokens=1 delims=." %%a in ('node -v') do set "NODE_VER=%%a" | ||
| set "NODE_VER=%NODE_VER:v=%" | ||
|
|
||
| if %NODE_VER% lss 18 ( | ||
| echo [ERROR] Node.js 18+ required | ||
| pause | ||
| exit /b 1 | ||
| ) | ||
|
|
||
| REM ============================================ | ||
| REM Install dependencies if needed | ||
| REM ============================================ | ||
| if not exist "node_modules" ( | ||
| echo Installing dependencies... | ||
| call npm install | ||
| echo. | ||
| ) | ||
|
|
||
| REM ============================================ | ||
| REM Determine mode (dev or prod) | ||
| REM ============================================ | ||
| set "MODE=dev" | ||
| if "%~1"=="build" set "MODE=build" | ||
| if "%~1"=="prod" set "MODE=build" | ||
|
|
||
| if "%MODE%"=="build" ( | ||
| echo Building for production... | ||
| call npm run build | ||
| echo. | ||
| echo Starting production server on port %PORT%... | ||
| start "VOIDSTRIKE Server" /b cmd /c "npx next start -p %PORT%" | ||
| ) else ( | ||
| echo Starting dev server on port %PORT%... | ||
| start "VOIDSTRIKE Server" /b cmd /c "npx next dev -p %PORT%" | ||
| ) | ||
|
|
||
| REM ============================================ | ||
| REM Wait for server to be ready | ||
| REM ============================================ | ||
| echo Waiting for server... | ||
| set "RETRIES=0" | ||
| :wait_loop | ||
| timeout /t 1 /nobreak >nul | ||
| curl -s "%URL%" >nul 2>nul | ||
| if %errorlevel% equ 0 goto server_ready | ||
| set /a RETRIES+=1 | ||
| if %RETRIES% geq 60 ( | ||
| echo [ERROR] Server failed to start after 60s | ||
| pause | ||
| exit /b 1 | ||
| ) | ||
| goto wait_loop | ||
|
|
||
| :server_ready | ||
| echo Server ready! | ||
| echo. | ||
|
|
||
| REM ============================================ | ||
| REM Open browser in app mode | ||
| REM ============================================ | ||
| echo Launching VOIDSTRIKE... | ||
|
|
||
| REM Try Chrome first (app mode for native-feeling window) | ||
| set "CHROME_PATH=" | ||
| for %%p in ( | ||
| "%ProgramFiles%\Google\Chrome\Application\chrome.exe" | ||
| "%ProgramFiles(x86)%\Google\Chrome\Application\chrome.exe" | ||
| "%LocalAppData%\Google\Chrome\Application\chrome.exe" | ||
| ) do ( | ||
| if exist %%p ( | ||
| set "CHROME_PATH=%%~p" | ||
| goto found_chrome | ||
| ) | ||
| ) | ||
|
|
||
| REM Try Edge (also supports app mode) | ||
| for %%p in ( | ||
| "%ProgramFiles(x86)%\Microsoft\Edge\Application\msedge.exe" | ||
| "%ProgramFiles%\Microsoft\Edge\Application\msedge.exe" | ||
| ) do ( | ||
| if exist %%p ( | ||
| set "CHROME_PATH=%%~p" | ||
| goto found_chrome | ||
| ) | ||
| ) | ||
|
|
||
| REM Fallback: open default browser | ||
| echo No Chrome/Edge found, opening default browser... | ||
| start "" "%URL%" | ||
| goto after_launch | ||
|
|
||
| :found_chrome | ||
| start "" "%CHROME_PATH%" --app="%URL%" --start-maximized | ||
|
|
||
| :after_launch | ||
| echo. | ||
| echo Game running at: %URL% | ||
| echo. | ||
| echo Press any key to stop the server and exit... | ||
| pause >nul | ||
|
|
||
| REM Kill the server | ||
| taskkill /fi "WINDOWTITLE eq VOIDSTRIKE Server" >nul 2>nul | ||
| taskkill /f /im node.exe >nul 2>nul | ||
|
|
||
| echo Shutting down. | ||
| exit /b 0 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,161 @@ | ||
| #!/usr/bin/env bash | ||
| # VOIDSTRIKE — Local Play Launcher (macOS / Linux) | ||
| # Double-click or run: ./launch/play.sh | ||
|
|
||
| set -e | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| PROJECT_DIR="$(dirname "$SCRIPT_DIR")" | ||
| PORT="${VOIDSTRIKE_PORT:-3000}" | ||
| URL="http://localhost:$PORT" | ||
|
|
||
| cd "$PROJECT_DIR" | ||
|
|
||
| # ============================================ | ||
| # Colors | ||
| # ============================================ | ||
| RED='\033[0;31m' | ||
| GREEN='\033[0;32m' | ||
| PURPLE='\033[0;35m' | ||
| BOLD='\033[1m' | ||
| NC='\033[0m' | ||
|
|
||
| echo -e "${PURPLE}${BOLD}" | ||
| echo " ╔═══════════════════════════════════╗" | ||
| echo " ║ V O I D S T R I K E ║" | ||
| echo " ║ Local Play Launcher ║" | ||
| echo " ╚═══════════════════════════════════╝" | ||
| echo -e "${NC}" | ||
|
|
||
| # ============================================ | ||
| # Check Node.js | ||
| # ============================================ | ||
| if ! command -v node &>/dev/null; then | ||
| echo -e "${RED}Node.js not found. Install it from https://nodejs.org${NC}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| NODE_VERSION=$(node -v | sed 's/v//' | cut -d. -f1) | ||
| if [ "$NODE_VERSION" -lt 18 ]; then | ||
| echo -e "${RED}Node.js 18+ required (found $(node -v))${NC}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # ============================================ | ||
| # Install dependencies if needed | ||
| # ============================================ | ||
| if [ ! -d "node_modules" ]; then | ||
| echo -e "${PURPLE}Installing dependencies...${NC}" | ||
| npm install | ||
| echo "" | ||
| fi | ||
|
|
||
| # ============================================ | ||
| # Build or Dev mode | ||
| # ============================================ | ||
| MODE="${1:-dev}" | ||
|
|
||
| if [ "$MODE" = "build" ] || [ "$MODE" = "prod" ]; then | ||
| echo -e "${PURPLE}Building for production...${NC}" | ||
| npm run build | ||
| echo "" | ||
| echo -e "${GREEN}Starting production server on port $PORT...${NC}" | ||
| # Start server in background | ||
| npx next start -p "$PORT" & | ||
| SERVER_PID=$! | ||
| else | ||
| echo -e "${GREEN}Starting dev server on port $PORT...${NC}" | ||
| # Start dev server in background | ||
| npx next dev -p "$PORT" & | ||
| SERVER_PID=$! | ||
| fi | ||
|
|
||
| # ============================================ | ||
| # Wait for server to be ready | ||
| # ============================================ | ||
| echo -n "Waiting for server" | ||
| RETRIES=0 | ||
| MAX_RETRIES=60 | ||
| while ! curl -s "$URL" >/dev/null 2>&1; do | ||
| echo -n "." | ||
| sleep 1 | ||
| RETRIES=$((RETRIES + 1)) | ||
| if [ "$RETRIES" -ge "$MAX_RETRIES" ]; then | ||
| echo "" | ||
| echo -e "${RED}Server failed to start after ${MAX_RETRIES}s${NC}" | ||
| kill "$SERVER_PID" 2>/dev/null | ||
| exit 1 | ||
| fi | ||
| done | ||
| echo "" | ||
| echo -e "${GREEN}Server ready!${NC}" | ||
| echo "" | ||
|
|
||
| # ============================================ | ||
| # Open browser in app mode | ||
| # ============================================ | ||
| open_app_mode() { | ||
| local url="$1" | ||
|
|
||
| # Try Chrome first (app mode for native-feeling window) | ||
| if command -v google-chrome &>/dev/null; then | ||
| google-chrome --app="$url" --start-maximized 2>/dev/null & | ||
| return 0 | ||
| fi | ||
| if command -v google-chrome-stable &>/dev/null; then | ||
| google-chrome-stable --app="$url" --start-maximized 2>/dev/null & | ||
| return 0 | ||
| fi | ||
| if command -v chromium &>/dev/null; then | ||
| chromium --app="$url" --start-maximized 2>/dev/null & | ||
| return 0 | ||
| fi | ||
| if command -v chromium-browser &>/dev/null; then | ||
| chromium-browser --app="$url" --start-maximized 2>/dev/null & | ||
| return 0 | ||
| fi | ||
|
|
||
| # macOS: try Chrome, then Edge, then default browser | ||
| if [ "$(uname)" = "Darwin" ]; then | ||
| if [ -d "/Applications/Google Chrome.app" ]; then | ||
| open -a "Google Chrome" --args --app="$url" --start-maximized 2>/dev/null | ||
| return 0 | ||
| fi | ||
| if [ -d "/Applications/Microsoft Edge.app" ]; then | ||
| open -a "Microsoft Edge" --args --app="$url" --start-maximized 2>/dev/null | ||
| return 0 | ||
| fi | ||
| # Fallback to default browser | ||
| open "$url" | ||
| return 0 | ||
| fi | ||
|
|
||
| # Try Edge on Linux | ||
| if command -v microsoft-edge &>/dev/null; then | ||
| microsoft-edge --app="$url" --start-maximized 2>/dev/null & | ||
| return 0 | ||
| fi | ||
|
|
||
| # Fallback: xdg-open | ||
| if command -v xdg-open &>/dev/null; then | ||
| xdg-open "$url" 2>/dev/null & | ||
| return 0 | ||
| fi | ||
|
|
||
| echo -e "${PURPLE}Open manually: $url${NC}" | ||
| return 1 | ||
| } | ||
|
|
||
| echo -e "${PURPLE}Launching VOIDSTRIKE...${NC}" | ||
| open_app_mode "$URL" | ||
|
|
||
| echo "" | ||
| echo -e "${BOLD}Game running at: ${PURPLE}$URL${NC}" | ||
| echo -e "Press ${BOLD}Ctrl+C${NC} to stop the server." | ||
| echo "" | ||
|
|
||
| # ============================================ | ||
| # Cleanup on exit | ||
| # ============================================ | ||
| trap "echo ''; echo 'Shutting down...'; kill $SERVER_PID 2>/dev/null; exit 0" INT TERM | ||
| wait "$SERVER_PID" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shutdown command kills every
node.exeprocess on the machine, not just the VOIDSTRIKE server started by this script. In practice, pressing a key to exit the launcher will also terminate unrelated local Node services (other apps, dev servers, tooling), which is destructive behavior for users who run multiple Node processes.Useful? React with 👍 / 👎.