Skip to content

Commit

Permalink
feat: added prisma to monorepo (#209)
Browse files Browse the repository at this point in the history
* feat: added prisma to monorepo

* chore: prepared prisma client

* chore: types, websocket, formatting
  • Loading branch information
hmbanan666 authored Aug 22, 2024
1 parent 3799aa8 commit f1e40fc
Show file tree
Hide file tree
Showing 151 changed files with 4,109 additions and 3,364 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@ PRIVATE_WEBSITE_BEARER=""
# WebSocket server with event messages
PUBLIC_WEBSOCKET_URL=""

# Database
DATABASE_URL=""

# App version
VERSION=""
18 changes: 10 additions & 8 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
Expand All @@ -24,15 +24,17 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
Expand Down
15 changes: 3 additions & 12 deletions .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,10 @@
},
"packageRules": [
{
"matchUpdateTypes": [
"minor",
"patch",
"pin",
"digest"
],
"matchUpdateTypes": ["minor", "patch", "pin", "digest"],
"automerge": true,
"automergeSchedule": [
"after 1am and before 2am"
],
"schedule": [
"after 2am and before 3am"
]
"automergeSchedule": ["after 1am and before 2am"],
"schedule": ["after 2am and before 3am"]
}
]
}
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ jobs:
# Prepend any command with "nx-cloud record --" to record its logs to Nx Cloud
# - run: yarn nx-cloud record -- echo Hello World
# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected
- run: yarn run lint
- run: yarn nx affected -t build lint test
2 changes: 1 addition & 1 deletion .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ jobs:
token: '${{ github.token }}'
environment-url: ${{ steps.deployment.outputs.environment_url }}
deployment-id: ${{ steps.deployment.outputs.deployment_id }}
state: 'failure'
state: 'failure'
4 changes: 3 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"singleQuote": true
"singleQuote": true,
"semi": false,
"printWidth": 100
}
6 changes: 1 addition & 5 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
{
"recommendations": [
"nrwl.angular-console",
"esbenp.prettier-vscode",
"ms-playwright.playwright"
]
"recommendations": ["nrwl.angular-console", "esbenp.prettier-vscode", "ms-playwright.playwright"]
}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@
"pcss",
"postcss"
]
}
}
11 changes: 4 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Changelog


## v0.2.0

[compare changes](https://github.com/hmbanan666/chat-game/compare/v0.1.0...v0.2.0)
Expand All @@ -20,7 +19,7 @@

### 📦 Build

- ⚠️ Migrate npm to yarn ([b314be9](https://github.com/hmbanan666/chat-game/commit/b314be9))
- ⚠️ Migrate npm to yarn ([b314be9](https://github.com/hmbanan666/chat-game/commit/b314be9))

### 🏡 Chore

Expand All @@ -31,7 +30,7 @@

#### ⚠️ Breaking Changes

- ⚠️ Migrate npm to yarn ([b314be9](https://github.com/hmbanan666/chat-game/commit/b314be9))
- ⚠️ Migrate npm to yarn ([b314be9](https://github.com/hmbanan666/chat-game/commit/b314be9))

### ❤️ Contributors

Expand All @@ -41,13 +40,12 @@

## v0.1.0


### 🚀 Enhancements

- Tests ([8dd5cb7](https://github.com/hmbanan666/chat-game/commit/8dd5cb7))
- Conventional commits ([4cc6d9b](https://github.com/hmbanan666/chat-game/commit/4cc6d9b))
- Migrate dependabot to renovate ([31bfaca](https://github.com/hmbanan666/chat-game/commit/31bfaca))
- ⚠️ Support i18n ([a07e69e](https://github.com/hmbanan666/chat-game/commit/a07e69e))
- ⚠️ Support i18n ([a07e69e](https://github.com/hmbanan666/chat-game/commit/a07e69e))

### 🩹 Fixes

Expand Down Expand Up @@ -85,9 +83,8 @@

#### ⚠️ Breaking Changes

- ⚠️ Support i18n ([a07e69e](https://github.com/hmbanan666/chat-game/commit/a07e69e))
- ⚠️ Support i18n ([a07e69e](https://github.com/hmbanan666/chat-game/commit/a07e69e))

### ❤️ Contributors

- Hywax ([@hywax](http://github.com/hywax))

10 changes: 5 additions & 5 deletions apps/website-e2e/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { defineConfig, devices } from '@playwright/test';
import { nxE2EPreset } from '@nx/playwright/preset';
import { defineConfig, devices } from '@playwright/test'
import { nxE2EPreset } from '@nx/playwright/preset'

import { workspaceRoot } from '@nx/devkit';
import { workspaceRoot } from '@nx/devkit'

// For CI, you may want to set BASE_URL to the deployed application.
const baseURL = process.env['BASE_URL'] || 'http://localhost:4200';
const baseURL = process.env['BASE_URL'] || 'http://localhost:4200'

/**
* Read environment variables from file.
Expand Down Expand Up @@ -66,4 +66,4 @@ export default defineConfig({
use: { ...devices['Desktop Chrome'], channel: 'chrome' },
} */
],
});
})
8 changes: 4 additions & 4 deletions apps/website-e2e/src/example.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { test, expect } from '@playwright/test';
import { test, expect } from '@playwright/test'

test('has title', async ({ page }) => {
await page.goto('/');
await page.goto('/')

// Expect h1 to contain a substring.
expect(await page.locator('h1').innerText()).toContain('Welcome');
});
expect(await page.locator('h1').innerText()).toContain('Welcome')
})
20 changes: 10 additions & 10 deletions apps/website-svelte/src/app.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<!doctype html>
<!DOCTYPE html>
<html lang="%lang%">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>
12 changes: 9 additions & 3 deletions apps/website-svelte/src/hooks.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,15 @@ const handleJWT: Handle = ({ event, resolve }) => {
const handleLocale: Handle = async ({ event, resolve }) => {
const { pathname, search } = event.url

const browserLang = `${`${event.request.headers.get('accept-language')}`.match(/[a-z]+(?=[\-_,;])/i)}`.toLowerCase()
const browserLocale = supportedLocales.find((locale) => locale === browserLang) ? browserLang as Locale : defaultLocale
const locale = supportedLocales.find((locale) => locale === event.params.lang) ? event.params.lang as Locale : browserLocale
const browserLang = `${`${event.request.headers.get('accept-language')}`.match(
/[a-z]+(?=[\-_,;])/i
)}`.toLowerCase()
const browserLocale = supportedLocales.find((locale) => locale === browserLang)
? (browserLang as Locale)
: defaultLocale
const locale = supportedLocales.find((locale) => locale === event.params.lang)
? (event.params.lang as Locale)
: browserLocale

event.locals.locale = locale

Expand Down
12 changes: 7 additions & 5 deletions apps/website-svelte/src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ const allEnv = z.object({
PUBLIC_GAME_ADMIN_PLAYER_ID: z.string().default('svhjz9p5467wne9ybasf1bwy'),
PUBLIC_TWITCH_CLIENT_ID: z.string().default(''),
PUBLIC_TWITCH_URL: z.string().default('https://www.twitch.tv/hmbanan666'),
PUBLIC_TWITCH_CHANNEL_REWARDS: z.string().default(JSON.stringify({
add150ViewerPointsId: 'd8237822-c943-434f-9d7e-87a9f549f4c4',
villainStealFuelId: 'd5956de4-54ff-49e4-afbe-ee4e62718eee',
addNewIdea: '289457e8-18c2-4b68-8564-fc61dd60b2a2',
})),
PUBLIC_TWITCH_CHANNEL_REWARDS: z.string().default(
JSON.stringify({
add150ViewerPointsId: 'd8237822-c943-434f-9d7e-87a9f549f4c4',
villainStealFuelId: 'd5956de4-54ff-49e4-afbe-ee4e62718eee',
addNewIdea: '289457e8-18c2-4b68-8564-fc61dd60b2a2',
})
),
})

const ConfigSchema = allEnv.transform((value) => {
Expand Down
5 changes: 1 addition & 4 deletions apps/website-svelte/src/lib/game/actions/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,5 @@ import type { GameObjectPlayer, IGameActionResponse } from '$lib/game/types'
export interface GameAction {
command: string
commandDescription: string
live: (
player: GameObjectPlayer,
params: string[],
) => Promise<IGameActionResponse>
live: (player: GameObjectPlayer, params: string[]) => Promise<IGameActionResponse>
}
15 changes: 5 additions & 10 deletions apps/website-svelte/src/lib/game/baseGame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ import type {
GameOptions,
GameSceneType,
GameStateResponse,
IGameInventoryItem, IGameObjectRaider,
IGameInventoryItem,
IGameObjectRaider,
} from '$lib/game/types'
import { AudioManager } from '$lib/game/utils/audioManager'
import { BackgroundGenerator } from '$lib/game/utils/generators/background'
import { AssetsManager } from '$lib/game/utils/assetsManager'
import { MovingScene } from '$lib/game/scenes/movingScene'
import {
MoveOffScreenAndSelfDestroyScript,
} from '$lib/game/scripts/moveOffScreenAndSelfDestroyScript'
import { MoveOffScreenAndSelfDestroyScript } from '$lib/game/scripts/moveOffScreenAndSelfDestroyScript'
import { getRandomInRange } from '$lib/utils/random'
import { MoveToTargetScript } from '$lib/game/scripts/moveToTargetScript'
import { ChopTreeScript } from '$lib/game/scripts/chopTreeScript'
Expand Down Expand Up @@ -293,10 +292,7 @@ export class BaseGame extends Container implements Game {
if (!object.target || object.target.state === 'DESTROYED') {
object.state = 'IDLE'
if (object.target instanceof TreeObject) {
void object.inventory.addOrCreateItem(
'WOOD',
object.target?.resource,
)
void object.inventory.addOrCreateItem('WOOD', object.target?.resource)
}
return true
}
Expand Down Expand Up @@ -338,8 +334,7 @@ export class BaseGame extends Container implements Game {
const columnWidth = this.app.screen.width / 6
const rowHeight = this.app.screen.height / 6

let leftPadding
= wagon.direction === 'LEFT' ? columnWidth * 4 : columnWidth * 2
let leftPadding = wagon.direction === 'LEFT' ? columnWidth * 4 : columnWidth * 2
let topPadding = rowHeight * 3

if (wagon.speedPerSecond === 0) {
Expand Down
8 changes: 2 additions & 6 deletions apps/website-svelte/src/lib/game/common/generators/unitTop.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import type { IGameObjectUnit } from '$lib/game/types'

export function generateUnitTop(): Partial<
IGameObjectUnit['visual']['top']
> {
export function generateUnitTop(): Partial<IGameObjectUnit['visual']['top']> {
const availableTopsForUnits: IGameObjectUnit['visual']['top'][] = [
'GREEN_SHIRT',
'BLUE_SHIRT',
'DARK_SILVER_SHIRT',
]

return availableTopsForUnits[
Math.floor(Math.random() * availableTopsForUnits.length)
]
return availableTopsForUnits[Math.floor(Math.random() * availableTopsForUnits.length)]
}
7 changes: 1 addition & 6 deletions apps/website-svelte/src/lib/game/common/inventory.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import { createId } from '@paralleldrive/cuid2'
import type {
GameObject,
IGameInventory,
IGameInventoryItem,
ItemType,
} from '$lib/game/types'
import type { GameObject, IGameInventory, IGameInventoryItem, ItemType } from '$lib/game/types'

interface InventoryOptions {
object: GameObject
Expand Down
6 changes: 1 addition & 5 deletions apps/website-svelte/src/lib/game/common/poll.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { createId } from '@paralleldrive/cuid2'
import { VoteAction } from '../actions/voteAction'
import { getRandomInRange } from '$lib/utils/random'
import type {
Game,
GameObjectPlayer,
IGamePoll,
} from '$lib/game/types'
import type { Game, GameObjectPlayer, IGamePoll } from '$lib/game/types'

interface IPollOptions {
game: Game
Expand Down
16 changes: 4 additions & 12 deletions apps/website-svelte/src/lib/game/components/buildingInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,8 @@ export class BuildingInterface extends GraphicsContainer {
}

init() {
this.wood
= this.building.inventory.items.find((item) => item.type === 'WOOD')
?.amount ?? 0
this.stone
= this.building.inventory.items.find((item) => item.type === 'STONE')
?.amount ?? 0
this.wood = this.building.inventory.items.find((item) => item.type === 'WOOD')?.amount ?? 0
this.stone = this.building.inventory.items.find((item) => item.type === 'STONE')?.amount ?? 0

this.drawWood()
this.drawStone()
Expand All @@ -43,12 +39,8 @@ export class BuildingInterface extends GraphicsContainer {
}

update() {
const wood = this.building.inventory.items.find(
(item) => item.type === 'WOOD',
)?.amount
const stone = this.building.inventory.items.find(
(item) => item.type === 'STONE',
)?.amount
const wood = this.building.inventory.items.find((item) => item.type === 'WOOD')?.amount
const stone = this.building.inventory.items.find((item) => item.type === 'STONE')?.amount

if (wood !== this.wood || stone !== this.stone) {
this.wood = wood
Expand Down
Loading

0 comments on commit f1e40fc

Please sign in to comment.