-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2e6c777
Showing
22 changed files
with
5,080 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,15 @@ | ||
# http://editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
insert_final_newline = false | ||
trim_trailing_whitespace = false |
This file contains 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,56 @@ | ||
name: ci | ||
|
||
on: | ||
push: | ||
branches: | ||
- "main" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
platform: [linux/amd64, linux/arm64] | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Log in to GitHub Docker Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Extract platform info | ||
id: platform | ||
run: echo "arch=$(echo ${{ matrix.platform }} | cut -d'/' -f2)" >> $GITHUB_OUTPUT | ||
- name: Build container image | ||
uses: docker/build-push-action@v6 | ||
with: | ||
push: true | ||
platforms: ${{ matrix.platform }} | ||
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/game-server-node:buildcache-${{ steps.platform.outputs.arch }} | ||
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/game-server-node:buildcache-${{ steps.platform.outputs.arch }},mode=max | ||
tags: | | ||
ghcr.io/${{ github.repository_owner }}/game-server-node:${{ github.sha }}-${{ steps.platform.outputs.arch }} | ||
ghcr.io/${{ github.repository_owner }}/game-server-node:latest-${{ steps.platform.outputs.arch }} | ||
merge: | ||
needs: docker | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Log in to GitHub Docker Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Create manifest list and push | ||
run: | | ||
docker buildx imagetools create -t ghcr.io/${{ github.repository_owner }}/game-server-node:latest \ | ||
ghcr.io/${{ github.repository_owner }}/game-server-node:latest-amd64 \ | ||
ghcr.io/${{ github.repository_owner }}/game-server-node:latest-arm64 | ||
docker buildx imagetools create -t ghcr.io/${{ github.repository_owner }}/game-server-node:${{ github.sha }} \ | ||
ghcr.io/${{ github.repository_owner }}/game-server-node:${{ github.sha }}-amd64 \ | ||
ghcr.io/${{ github.repository_owner }}/game-server-node:${{ github.sha }}-arm64 |
This file contains 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,9 @@ | ||
lib | ||
.DS_Store | ||
node_modules | ||
coverage | ||
temp | ||
explorations | ||
TODOs.md | ||
*.log | ||
.idea |
This file contains 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,2 @@ | ||
npm test | ||
npx lint-staged |
This file contains 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,3 @@ | ||
# ~/.huskyrc | ||
export NVM_DIR="$HOME/.nvm" | ||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" |
This file contains 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 @@ | ||
22 |
This file contains 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 @@ | ||
/lib/* |
Empty file.
This file contains 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,26 @@ | ||
FROM node:22-alpine AS deps | ||
|
||
WORKDIR /build | ||
|
||
COPY package*.json ./ | ||
COPY yarn.lock ./ | ||
|
||
RUN yarn install --frozen-lockfile | ||
|
||
FROM node:22-alpine AS build | ||
|
||
WORKDIR /build | ||
|
||
COPY --from=deps /build/node_modules ./node_modules | ||
COPY . . | ||
|
||
RUN yarn build | ||
|
||
FROM node:22-alpine | ||
|
||
WORKDIR /opt/5stack | ||
|
||
COPY --from=build /build/node_modules ./node_modules | ||
COPY --from=build /build/dist ./dist | ||
|
||
CMD [ "node", "dist/cjs/index.js" ] |
This file contains 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,7 @@ | ||
namespaces: [5stack] | ||
image: node:22 | ||
deployment: dev-game-server-node-connector | ||
sync: | ||
- .:/opt/5stack | ||
ignore: | ||
- "/dist" |
This file contains 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,21 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"incremental": true, | ||
"sourceMap": true, | ||
"moduleResolution": "node", | ||
"isolatedModules": true, | ||
"strict": true, | ||
"importHelpers": true, | ||
"noUnusedLocals": true, | ||
"experimentalDecorators": true, | ||
"resolveJsonModule": true, | ||
"esModuleInterop": true, | ||
"skipLibCheck": true, | ||
"emitDecoratorMetadata": true, | ||
"allowSyntheticDefaultImports": true, | ||
"noImplicitAny": false, | ||
"declaration": true | ||
}, | ||
"include": ["../src/**/*"] | ||
} |
This file contains 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,10 @@ | ||
{ | ||
"extends": "./tsconfig.base.json", | ||
"compilerOptions": { | ||
"lib": ["es2019"], | ||
"target": "es2019", | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"outDir": "../dist/cjs" | ||
} | ||
} |
This file contains 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,10 @@ | ||
{ | ||
"extends": "./tsconfig.base.json", | ||
"compilerOptions": { | ||
"lib": ["esnext"], | ||
"target": "esnext", | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"outDir": "../dist/esm" | ||
} | ||
} |
This file contains 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,27 @@ | ||
const DOMGlobals = ["window", "document"]; | ||
const NodeGlobals = ["module", "require"]; | ||
|
||
module.exports = { | ||
parser: "@typescript-eslint/parser", | ||
extends: ["plugin:@typescript-eslint/recommended"], | ||
parserOptions: { | ||
sourceType: "module", | ||
project: "tsconfig.json", | ||
}, | ||
plugins: ["@typescript-eslint"], | ||
rules: { | ||
"@typescript-eslint/ban-ts-comment": "off", | ||
"@typescript-eslint/no-floating-promises": "error", | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"@typescript-eslint/explicit-function-return-type": "off", | ||
"@typescript-eslint/explicit-module-boundary-types": "off", | ||
"no-unused-vars": [ | ||
"error", | ||
// we are only using this rule to check for unused arguments since TS | ||
// catches unused variables but not args. | ||
{ varsIgnorePattern: ".*", args: "none" }, | ||
], | ||
// most of the codebase are expected to be env agnostic | ||
"no-restricted-globals": ["error", ...DOMGlobals, ...NodeGlobals], | ||
}, | ||
}; |
This file contains 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,17 @@ | ||
import type { JestConfigWithTsJest } from "ts-jest"; | ||
|
||
const jestConfig: JestConfigWithTsJest = { | ||
roots: ["<rootDir>"], | ||
preset: "ts-jest", | ||
testEnvironment: "node", | ||
transform: { | ||
"^.+\\.tsx?$": [ | ||
"ts-jest", | ||
{ | ||
tsconfig: "configs/tsconfig.base.json", | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
export default jestConfig; |
This file contains 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,53 @@ | ||
{ | ||
"name": "@5stack/game-server-node", | ||
"version": "0.0.2", | ||
"main": "./lib/cjs/index.js", | ||
"files": [ | ||
"src", | ||
"dist/**/*" | ||
], | ||
"scripts": { | ||
"start": "node dist/cjs/index.js", | ||
"test": "jest --ci --collect-coverage", | ||
"test:watch": "jest --watch", | ||
"clean": "rimraf ./lib", | ||
"build": "npm run clean && npm run build:cjs", | ||
"build:esm": "tsc -p ./configs/tsconfig.esm.json && mv lib/esm/index.js lib/esm/index.mjs", | ||
"build:cjs": "tsc -p ./configs/tsconfig.cjs.json", | ||
"prepack": "npm run build", | ||
"nodemon": "wait-on dist/cjs/index.js && nodemon --watch ./dist/cjs/index.js ./dist/cjs/index.js", | ||
"watch": "npm-run-all -p \"build:cjs -- --watch\" nodemon", | ||
"prepare": "husky" | ||
}, | ||
"dependencies": { | ||
"@kubernetes/client-node": "^0.22.0", | ||
"vdf-parser": "^1.2.1", | ||
"ws": "^8.18.0" | ||
}, | ||
"devDependencies": { | ||
"@jest/globals": "^29.7.0", | ||
"@types/node": "^22.8.7", | ||
"eslint": "^9.6.0", | ||
"husky": "^9.0.11", | ||
"jest": "^29.7.0", | ||
"lint-staged": "^15.2.7", | ||
"nodemon": "^3.1.4", | ||
"npm-run-all": "^4.1.5", | ||
"prettier": "^3.3.2", | ||
"pretty-quick": "^4.0.0", | ||
"rimraf": "^6.0.1", | ||
"ts-jest": "^29.2.2", | ||
"ts-node": "^10.9.2", | ||
"typescript": "^5.5.3", | ||
"wait-on": "^8.0.0" | ||
}, | ||
"lint-staged": { | ||
"*.js": [ | ||
"prettier --write" | ||
], | ||
"*.ts?(x)": [ | ||
"eslint", | ||
"prettier --parser=typescript --write" | ||
] | ||
} | ||
} |
Oops, something went wrong.