Merge pull request #166 from BeGj/feature/bun

Use bun as runtime
This commit is contained in:
evanpelle
2025-03-07 08:46:20 -08:00
committed by GitHub
11 changed files with 3076 additions and 18492 deletions
+15
View File
@@ -0,0 +1,15 @@
node_modules
Dockerfile*
docker-compose*
.dockerignore
.git
.gitignore
README.md
LICENSE
.vscode
Makefile
helm-charts
.env
.editorconfig
.idea
coverage*
+6 -6
View File
@@ -8,14 +8,14 @@ jobs:
uses: actions/checkout@v4
with:
submodules: false
- name: Setup node
uses: actions/setup-node@v4
- name: Setup bun
uses: oven-sh/setup-bun@v2
with:
node-version: 20
- name: Setup npm
run: npm install
bun-version: 1.2.4
- name: install packages
run: bun install
- name: Build
run: npm run build-prod
run: bun run build-prod
- uses: actions/upload-artifact@v4
with:
path: out/index.html
+4 -5
View File
@@ -10,9 +10,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: oven-sh/setup-bun@v2
with:
node-version: "20"
cache: "npm"
- run: npm ci
- run: npx prettier --check .
bun-version: 1.2.4
- run: bun i
- run: bunx prettier --check .
-16
View File
@@ -1,16 +0,0 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}/src/server/GameManager.ts",
"outFiles": ["${workspaceFolder}/**/*.js"]
}
]
}
+4 -4
View File
@@ -1,5 +1,5 @@
# Use an official Node runtime as the base image
FROM node:18
FROM oven/bun:1
# Add environment variable
ARG GAME_ENV=prod
@@ -13,18 +13,18 @@ RUN apt-get update && apt-get install -y nginx supervisor git && \
WORKDIR /usr/src/app
# Copy package.json and package-lock.json
COPY package*.json ./
COPY package.json bun.lock ./
# Install dependencies while bypassing Husky hooks
ENV HUSKY=0
ENV NPM_CONFIG_IGNORE_SCRIPTS=1
RUN mkdir -p .git && npm install --include=dev
RUN mkdir -p .git && bun install --include=dev
# Copy the rest of the application code
COPY . .
# Build the client-side application
RUN npm run build-prod
RUN bun run build-prod
ENV NODE_ENV=production
+6 -7
View File
@@ -24,8 +24,7 @@ This is a fork/rewrite of WarFront.io. Credit to https://github.com/WarFrontIO.
## 📋 Prerequisites
- [Node.js](https://nodejs.org/) (v16.x or higher)
- [npm](https://www.npmjs.com/) (v8.x or higher)
- [Bun.js](https://bun.sh/) (v1.2.4 or higher)
- A modern web browser (Chrome, Firefox, Edge, etc.)
## 🚀 Installation
@@ -40,7 +39,7 @@ This is a fork/rewrite of WarFront.io. Credit to https://github.com/WarFrontIO.
2. **Install dependencies**
```bash
npm install
bun i
```
## 🎮 Running the Game
@@ -50,7 +49,7 @@ This is a fork/rewrite of WarFront.io. Credit to https://github.com/WarFrontIO.
Run both the client and server in development mode with live reloading:
```bash
npm run dev
bun run dev
```
This will:
@@ -64,7 +63,7 @@ This will:
To run just the client with hot reloading:
```bash
npm run start:client
bun run start:client
```
### Server Only
@@ -72,14 +71,14 @@ npm run start:client
To run just the server with development settings:
```bash
npm run start:server-dev
bun run start:server-dev
```
## 🛠️ Development Tools
- **Format code**:
```bash
npm run format
bun run format
```
## 🏗️ Project Structure
+3026
View File
File diff suppressed because it is too large Load Diff
+8
View File
@@ -0,0 +1,8 @@
services:
openfront:
build: .
ports:
- "80:80"
- "443:443"
env_file:
- .env
-18447
View File
File diff suppressed because it is too large Load Diff
+6 -6
View File
@@ -1,14 +1,14 @@
{
"name": "openfront-client",
"scripts": {
"build-map": "node --loader ts-node/esm --experimental-specifier-resolution=node src/scripts/TerrainMapGenerator.ts",
"build-map": "bun src/scripts/TerrainMapGenerator.ts",
"build-dev": "webpack --config webpack.config.js --mode development",
"build-prod": "webpack --config webpack.config.js --mode production",
"start:client": "webpack serve --open --node-env development",
"start:server": "node --loader ts-node/esm --experimental-specifier-resolution=node src/server/Server.ts",
"start:server-dev": "cross-env GAME_ENV=dev node --loader ts-node/esm --experimental-specifier-resolution=node src/server/Server.ts",
"dev": "cross-env GAME_ENV=dev concurrently \"npm run start:client\" \"npm run start:server-dev\"",
"tunnel": "npm run build-prod && npm run start:server",
"start:server": "bun src/server/Server.ts",
"start:server-dev": "cross-env GAME_ENV=dev bun src/server/Server.ts",
"dev": "cross-env GAME_ENV=dev concurrently \"bun run start:client\" \"bun run start:server-dev\"",
"tunnel": "bun run build-prod && bun run start:server",
"test": "jest",
"format": "prettier --ignore-unknown --write .",
"prepare": "husky"
@@ -27,7 +27,7 @@
"@types/jest": "^29.5.12",
"@types/jquery": "^3.5.31",
"@types/mocha": "^10.0.7",
"@types/node": "^22.10.2",
"@types/bun": "latest",
"@types/pg": "^8.11.11",
"@types/sinon": "^17.0.3",
"@types/systeminformation": "^3.23.1",
+1 -1
View File
@@ -14,7 +14,7 @@ stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[program:node]
command=npm run start:server
command=bun run start:server
directory=/usr/src/app
autostart=true
autorestart=true