Skip to content

Commit

Permalink
Refactor (#270) Remains of previous PR
Browse files Browse the repository at this point in the history
* 🔀 Fix merge conflict remains

* 🐛 Duplicate Files

* 🔨 Added scripts to root

* 👷 CI Workflow

* 👷 Removed sourcemap and declaration for server
  • Loading branch information
SagnikPradhan authored Apr 17, 2021
1 parent a7714d1 commit 7d48373
Show file tree
Hide file tree
Showing 24 changed files with 75 additions and 188 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
web/src/typings/vendor.d.ts
next.config.js

server/source/prisma/
8 changes: 3 additions & 5 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,20 @@
],

"parserOptions": {
"project": "./tsconfig.json"
"project": ["./server/tsconfig.json", "./web/src/tsconfig.json"]
},

"settings": {
"react": { "version": "detect" }
"react": { "version": "^16.8.0" }
},

"ignorePatterns": ["typings/vendor/*", "next.config.js", "dist/*", "docs/*"],

"rules": {
"@typescript-eslint/explicit-module-boundary-types": "off",

"jsdoc/require-param-type": "off",
"jsdoc/require-returns-type": "off",
"jsdoc/check-param-names": ["warn", { "checkDestructured": false }],
"jsdoc/require-param": ["warn", { "checkDestructured": false }],
"jsdoc/check-tag-names": ["warn", { "definedTags": ["remarks"] }]
"jsdoc/check-tag-names": ["warn", { "definedTags": ["link"] }]
}
}
18 changes: 7 additions & 11 deletions .github/workflows/prettier.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
name: Prettier
name: CI

on:
push:
branches:
- rewrite
workflow_dispatch:
branches: [rewrite]
pull_request:
branches: [rewrite]

jobs:
format:
name: Run Prettier
if: github.event.pusher.name != 'd-zone-maintenance'
lint-format:
runs-on: ubuntu-latest
steps:
- uses: tibdex/github-app-token@v1
Expand Down Expand Up @@ -37,8 +35,6 @@ jobs:

- run: yarn install

- run: yarn run format
- run: yarn prettier . -c

- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: 🎨 Auto format by prettier
- run: yarn eslint .
42 changes: 0 additions & 42 deletions .github/workflows/dependency_updates.yml

This file was deleted.

33 changes: 0 additions & 33 deletions .github/workflows/yarn_bleeding_edge.yml

This file was deleted.

1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
5 changes: 5 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn prettier . -c
yarn eslint .
5 changes: 2 additions & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
.yarn/*
.next/*
dist/*
docs/*
**/.next/*
.vscode/*
.pnp.js
**/coverage/*
**/build/*
yarn.lock
**/patches/*
public/img/*
server/source/prisma/*
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: yarn start
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
],
"scripts": {
"commit": "gitmoji --commit",
"format": "prettier --write ."
"lint": "eslint .",
"format": "prettier --write .",
"postinstall": "husky install",
"dev": "yarn workspace server dev",
"start": "yarn workspace server start"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "latest",
Expand All @@ -20,6 +24,7 @@
"eslint-plugin-jsdoc": "^30.7.9",
"eslint-plugin-react": "latest",
"gitmoji-cli": "^3.2.12",
"husky": "^6.0.0",
"prettier": "^2.2.1",
"prettier-plugin-jsdoc": "^0.2.12",
"typescript": "^4.1.3"
Expand All @@ -30,7 +35,9 @@
"tabWidth": 2,
"semi": false,
"singleQuote": true,
"jsdocParser": true
"plugins": [
"prettier-plugin-jsdoc"
]
},
"homepage": "https://github.com/vegeta897/d-zone#readme",
"repository": {
Expand Down
5 changes: 4 additions & 1 deletion server/source/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ import { createSocketServer, connectSocketChat } from './socket'

import { createNextServer } from './next'

/** Main entry point for runtime */
async function main() {
const DISCORD_TOKEN = process.env['DISCORD_TOKEN']
const PORT = process.env['PORT'] || 8080
const DEV = !process.env['PRODUCTION']

if (!DISCORD_TOKEN) throw new Error('DISCORD_TOKEN not set')

const logger = new Logger()
const prisma = new PrismaClient()

Expand All @@ -27,7 +30,7 @@ async function main() {
const socketServer = createSocketServer(httpServer, logger.getChildLogger())

const chatModules = [
await createDiscordModule(DISCORD_TOKEN!, prisma, logger.getChildLogger()),
await createDiscordModule(DISCORD_TOKEN, prisma, logger.getChildLogger()),
]

connectSocketChat(chatModules, socketServer)
Expand Down
6 changes: 6 additions & 0 deletions server/source/socket/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ export const createSocketServer = (httpServer: http.Server, logger: Logger) => {
return server
}

/**
* Connects socket to chat modules
*
* @param chatModules - Chat modules
* @param socket - Socket server
*/
export function connectSocketChat(
chatModules: ChatModule[],
socket: Server<ClientEvents, ServerEvents>
Expand Down
2 changes: 1 addition & 1 deletion server/source/socket/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ type ServerChatEvents = {
[K in keyof ChatEvents]: (argument: ChatEvents[K][0]) => void
}

export interface ServerEvents extends ServerChatEvents {}
export type ServerEvents = ServerChatEvents
5 changes: 1 addition & 4 deletions server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
"module": "commonjs",
"lib": ["es2020"],

"rootDir": "./source",
"sourceMap": true,

"declaration": true
"rootDir": "./source"
}
}
2 changes: 0 additions & 2 deletions web/next-env.d.ts

This file was deleted.

29 changes: 0 additions & 29 deletions web/server.js

This file was deleted.

8 changes: 4 additions & 4 deletions web/src/modules/game/engine/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ export default class Engine {
}

/**
* Starts the game loop.
<<<<<<< HEAD:src/modules/game/engine/index.ts
* Starts the game loop. <<<<<<< HEAD:src/modules/game/engine/index.ts
*
* Note: `setInterval` is used instead of `requestAnimationFrame` because all
* logic runs at a fixed rate.
*
=======
* =======
*
* Note: `setInterval` is used instead of `requestAnimationFrame` because all
* logic runs at a fixed rate.
*
>>>>>>> feat/comms:web/src/modules/game/engine/index.ts
* >>>>>>> feat/comms:web/src/modules/game/engine/index.ts
*
* @param fps - The target number of times per second to run the interval at.
*/
start(fps: number): void {
Expand Down
4 changes: 0 additions & 4 deletions web/src/modules/game/renderer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ export default class Renderer {
/** The PIXI application itself */
app!: PIXI.Application
/** The viewport container which manages camera movement. */
<<<<<<< HEAD:src/modules/game/renderer/index.ts
view!: Viewport<IPlugins>
=======
view!: Viewport
>>>>>>> feat/comms:web/src/modules/game/renderer/index.ts
/** The culler which prevents off-camera objects from rendering. */
cull!: SpatialHash

Expand Down
16 changes: 8 additions & 8 deletions web/src/modules/game/renderer/wheel-stepped.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ const wheelSteppedOptions = {
steps: [0.25, 0.5, 1, 2, 3, 4, 5, 6, 8],
}

function getClosestIndex(arr: number[], target: number): number {
let closest = 0
arr.forEach((value, index) => {
if (Math.abs(value - target) < Math.abs(arr[closest] - target))
closest = index
})
return closest
}
const getClosestIndex = (arr: number[], target: number) =>
arr.reduce(
(closest, value, index) =>
Math.abs(value - target) < Math.abs(arr[closest] - target)
? index
: closest,
0
)

export default class WheelStepped extends Plugin {
private options: {
Expand Down
4 changes: 0 additions & 4 deletions web/src/modules/game/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import { initLoader, runLoader } from './loader'
import { Animations, IResources, Sheet } from '../typings'
import { LoaderResource } from 'pixi.js-legacy'
import { SPRITE_JSON_PATH } from '../config/sprite'
<<<<<<< HEAD:web/src/modules/game/resources/index.ts
import { buildAnimations } from 'web/modules/game/resources/animations'
=======
import { buildAnimations } from 'root/modules/game/resources/animations'
>>>>>>> feat/comms:src/modules/game/renderer/resources/resources.ts

/** A manager for sprite-related resources. */
export default class Resources implements IResources {
Expand Down
1 change: 1 addition & 0 deletions web/src/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'
import { AppProps } from 'next/app'

// eslint-disable-next-line jsdoc/require-jsdoc
export default function App({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />
}
16 changes: 8 additions & 8 deletions web/src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"extends": "../../tsconfig.json",

"compilerOptions": {
"target": "es5",
"module": "esnext",

"lib": ["dom", "dom.iterable", "esnext"],

"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],

"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.d.ts"],

"exclude": ["node_modules"]
}
Loading

0 comments on commit 7d48373

Please sign in to comment.