Skip to content

Commit

Permalink
Merge branch 'develop' into better-multi-domain
Browse files Browse the repository at this point in the history
  • Loading branch information
TurtIeSocks committed Feb 8, 2024
2 parents 2b9f36a + 9d37a99 commit ce0ca7f
Show file tree
Hide file tree
Showing 52 changed files with 554 additions and 290 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ public/missing-locales
public/images/custom
public/images/uicons
server/src/configs/
packages/types/**/*.d.ts
packages/**/*.d.ts
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## [1.29.7-develop.1](https://github.com/WatWowMap/ReactMap/compare/v1.29.6...v1.29.7-develop.1) (2024-02-08)


### Bug Fixes

* cache most things at process exit instead ([56eb47e](https://github.com/WatWowMap/ReactMap/commit/56eb47eca6e05f78e4b0b518b6d7fb6a5c901bc2))
* config getters ([494639a](https://github.com/WatWowMap/ReactMap/commit/494639a28289fac90e0898cf2d443ba7a2c5c41d))
* dont log golbat 404 pokemon id errors ([7292d13](https://github.com/WatWowMap/ReactMap/commit/7292d13f9b7460a7b40d1b3bcb45c751d183b953))
* express session augmentation ([35533e9](https://github.com/WatWowMap/ReactMap/commit/35533e9b86518d496e71ff6a3fb93f54ad51864c))
* favicon error catching for dummies ([b6c0fae](https://github.com/WatWowMap/ReactMap/commit/b6c0fae43ef8e4312bc61c265c8c16cd4a0c1ee5))
* more client ts checks ([5028cb2](https://github.com/WatWowMap/ReactMap/commit/5028cb2221ac44e65620927bd69a10f4958f6d9c))

## [1.29.6](https://github.com/WatWowMap/ReactMap/compare/v1.29.5...v1.29.6) (2024-02-06)


Expand Down
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "reactmap",
"version": "1.29.6",
"version": "1.29.7-develop.1",
"private": true,
"description": "React based frontend map.",
"license": "MIT",
Expand All @@ -10,6 +10,7 @@
"packages/*"
],
"scripts": {
"postinstall": "yarn masterfile",
"build": "vite build",
"config:check": "yarn workspace @rm/config run check",
"config:env": "yarn workspace @rm/config run generate",
Expand Down Expand Up @@ -45,7 +46,7 @@
},
"lint-staged": {
"*.{js,jsx,ts,tsx}": [
"eslint --fix"
"eslint \"**/*.{js,jsx}\" --fix"
],
"**/*": [
"prettier --write --ignore-unknown"
Expand Down Expand Up @@ -155,7 +156,7 @@
"morgan": "^1.10.0",
"mysql2": "^3.4.0",
"node-cache": "^5.1.2",
"node-fetch": "2",
"node-fetch": "2.6.7",
"node-geocoder": "^4.2.0",
"nodes2ts": "^2.0.0",
"objection": "^3.0.1",
Expand Down Expand Up @@ -186,6 +187,7 @@
"@sentry/vite-plugin": "2.10.3",
"@types/dlv": "^1.1.2",
"@types/node": "^18",
"@types/node-fetch": "2.6.1",
"@types/react": "^18.2.20",
"@types/react-dom": "^18.0.9",
"@vitejs/plugin-react": "4.2.1",
Expand All @@ -206,8 +208,9 @@
"prettier": "^2.8.8",
"rollup-plugin-delete": "^2.0.0",
"semantic-release": "^19.0.5",
"typescript": "^5.3.3",
"vite": "5.0.12",
"vite-plugin-checker": "0.6.0"
"vite-plugin-checker": "0.6.4"
},
"engines": {
"node": ">=18",
Expand Down
2 changes: 2 additions & 0 deletions packages/locales/lib/create.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// @ts-check
const { default: fetch } = require('node-fetch')

const config = require('@rm/config')
const { log, HELPERS } = require('@rm/logger')

Expand Down
1 change: 1 addition & 0 deletions packages/locales/lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @ts-check
const { promises: fs, readdirSync } = require('fs')
const { resolve } = require('path')
const { default: fetch } = require('node-fetch')

const { log, HELPERS } = require('@rm/logger')

Expand Down
4 changes: 4 additions & 0 deletions packages/locales/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
"@rm/config": "*",
"@rm/logger": "*",
"dotenv": "^16.3.1",
"node-fetch": "2.6.7",
"openai": "^4.24.1"
},
"devDependencies": {
"@types/node-fetch": "2.6.1"
}
}
1 change: 1 addition & 0 deletions packages/logger/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const HELPERS = /** @type {const} */ ({
fetch: chalk.hex('#880e4f')('[FETCH]'),
scanner: chalk.hex('#b39ddb')('[SCANNER]'),
build: chalk.hex('#ef6c00')('[BUILD]'),
ReactMap: chalk.hex('#ff3d00')('[ReactMap]'),

pokemon: chalk.hex('#f44336')('[POKEMON]'),
pokestops: chalk.hex('#e91e63')('[POKESTOPS]'),
Expand Down
85 changes: 85 additions & 0 deletions packages/masterfile/lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import type { AdvCategories, Rarity } from '@rm/types'

export interface MasterfileForm {
name: string
rarity?: string
isCostume?: boolean
category?: AdvCategories
}

export interface MasterfilePokemon {
name: string
pokedexId: number
defaultFormId: number
types: number[]
quickMoves: number[]
chargedMoves: number[]
genId: number
forms: {
[formId: string]: MasterfileForm
}
height?: number
weight?: number
family?: number
legendary?: boolean
mythical?: boolean
ultraBeast?: boolean
rarity?: string
historic?: string
tempEvolutions?: {
[evolutionId: string]: {}
}
}

export interface MasterfileObject {
[typeId: string]: string
}

export interface MasterfileMove {
name: string
type: number
}

export interface InvasionPokemon {
id: number
form: number
}

export interface InvasionRewards {
first: InvasionPokemon[]
second: InvasionPokemon[]
third: InvasionPokemon[]
}

export interface Invasion {
type: string
gender: number
grunt: string
firstReward: boolean
secondReward: boolean
thirdReward: boolean
encounters: InvasionRewards
}

export interface MasterfileWeather {
name: string
types: number[]
}

export interface Masterfile {
pokemon: Record<string, MasterfilePokemon>
types: MasterfileObject
items: MasterfileObject
questRewardTypes: MasterfileObject
moves: Record<string, MasterfileMove>
invasions: Record<string, Invasion>
weather: Record<string, MasterfileWeather>
}

export declare function generate(
save?: boolean,
historicRarity?: Rarity,
dbRarity?: Rarity,
): Promise<Masterfile>

export declare function read(): Masterfile
12 changes: 4 additions & 8 deletions packages/masterfile/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @ts-check
const fs = require('fs')
const { resolve } = require('path')
const { default: fetch } = require('node-fetch')

const config = require('@rm/config')
const { log, HELPERS } = require('@rm/logger')
Expand All @@ -20,13 +21,7 @@ Object.entries(defaultRarity).forEach(([tier, pokemon]) => {
}
})

/**
*
* @param {boolean} save
* @param {import('@rm/types').Rarity} historicRarity
* @param {import('@rm/types').Rarity} dbRarity
* @returns
*/
/** @type {import('.').generate} */
const generate = async (save = false, historicRarity = {}, dbRarity = {}) => {
log.info(HELPERS.masterfile, 'generating masterfile')
try {
Expand Down Expand Up @@ -91,6 +86,7 @@ if (require.main === module) {
generate(true).then(() => log.info(HELPERS.masterfile, 'OK'))
}

/** @type {import('.').read} */
const read = () => {
try {
return JSON.parse(
Expand All @@ -101,7 +97,7 @@ const read = () => {
HELPERS.masterfile,
'Unable to read masterfile, generating a new one for you now',
)
return generate(true)
generate(true)
}
}

Expand Down
7 changes: 6 additions & 1 deletion packages/masterfile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.1.0",
"private": true,
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"scripts": {
"generate": "node ./lib",
"sort": "npx sort-package-json",
Expand All @@ -15,6 +16,10 @@
"dependencies": {
"@rm/config": "*",
"@rm/logger": "*",
"@rm/types": "*"
"@rm/types": "*",
"node-fetch": "2.6.7"
},
"devDependencies": {
"@types/node-fetch": "2.6.1"
}
}
9 changes: 8 additions & 1 deletion packages/types/lib/augmentations.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ButtonProps } from '@mui/material'
import { Config, GetSafeConfig } from './config'
import { ExpressUser } from './server'
import { ExpressUser, Permissions } from './server'
import { Request } from 'express'

declare module 'config' {
Expand Down Expand Up @@ -50,6 +50,13 @@ declare module '@mui/material/styles' {
}
}

declare module 'express-session' {
interface SessionData {
cooldown?: number
perms?: Permissions
}
}

// TODO
// declare module '@mui/material/Button' {
// interface ExtendButtonTypeMap {
Expand Down
7 changes: 1 addition & 6 deletions packages/types/lib/general.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@ export type RMGeoJSON = {
features: RMFeature[]
}

import masterfile = require('packages/masterfile/lib/data/masterfile.json')
import { Config } from './config'
import { SliderProps } from '@mui/material'

export type Masterfile = typeof masterfile

export type Strategy = 'discord' | 'telegram' | 'local'

export type S2Polygon = [number, number][]
Expand Down Expand Up @@ -88,9 +85,7 @@ export interface UICONS {
egg: UiconImage[]
}
reward: {
[
key: Masterfile['questRewardTypes'][keyof Masterfile['questRewardTypes']]
]: UiconImage[]
[key: string]: UiconImage[]
}
spawnpoint: UiconImage[]
team: UiconImage[]
Expand Down
57 changes: 32 additions & 25 deletions packages/vite-plugins/lib/favicon.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,43 @@
const { resolve } = require('path')
const fs = require('fs')

const { log, HELPERS } = require('@rm/logger')

/**
* @param {boolean} isDevelopment
* @returns {import('vite').Plugin}
*/
const faviconPlugin = (isDevelopment) => {
const favicon = fs.existsSync(
resolve(__dirname, '../../../public/favicon/favicon.ico'),
)
? resolve(__dirname, '../../../public/favicon/favicon.ico')
: resolve(__dirname, '../../../public/favicon/fallback.ico')
return {
name: 'vite-plugin-locales',
generateBundle() {
if (isDevelopment) return
this.emitFile({
type: 'asset',
fileName: 'favicon.ico',
source: fs.readFileSync(favicon),
})
},
configureServer(server) {
server.middlewares.use((req, res, next) => {
if (req.url === '/favicon.ico') {
res.writeHead(200, { 'Content-Type': 'image/x-icon' })
res.end(fs.readFileSync(favicon))
return
}
next()
})
},
try {
const favicon = fs.existsSync(
resolve(__dirname, '../../../public/favicon/favicon.ico'),
)
? resolve(__dirname, '../../../public/favicon/favicon.ico')
: resolve(__dirname, '../../../public/favicon/fallback.ico')
return {
name: 'vite-plugin-favicon',
generateBundle() {
if (isDevelopment) return
this.emitFile({
type: 'asset',
fileName: 'favicon.ico',
source: fs.readFileSync(favicon),
})
},
configureServer(server) {
server.middlewares.use((req, res, next) => {
if (req.url === '/favicon.ico') {
res.writeHead(200, { 'Content-Type': 'image/x-icon' })
res.end(fs.readFileSync(favicon))
return
}
next()
})
},
}
} catch (e) {
log.error(HELPERS.build, 'Error loading favicon', e)
return { name: 'vite-plugin-favicon' }
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/vite-plugins/lib/muteWarnings.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
const muteWarningsPlugin = (warningsToIgnore) => {
const mutedMessages = new Set()
return {
name: 'mute-warnings',
name: 'vite-mute-warnings',
enforce: 'pre',
config: (userConfig) => ({
build: {
Expand Down
3 changes: 2 additions & 1 deletion packages/vite-plugins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"prettier:fix": "prettier --write \"**/*.{css,html,js,jsx,yml}\""
},
"dependencies": {
"@rm/locales": "*"
"@rm/locales": "*",
"@rm/logger": "*"
},
"devDependencies": {
"vite": "5.0.12"
Expand Down
Loading

0 comments on commit ce0ca7f

Please sign in to comment.