Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .prettierignore

This file was deleted.

46 changes: 46 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"$schema": "https://biomejs.dev/schemas/2.3.8/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"includes": [
"**",
"!!**/dist"
]
},
"formatter": {
"enabled": true,
"indentStyle": "space"
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"suspicious": {
"noExplicitAny":"off"
},
"complexity":{
"noStaticOnlyClass":"off"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"arrowParentheses": "always",
"semicolons": "asNeeded",
"trailingCommas": "all"
}
},
"assist": {
"enabled": true,
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
29 changes: 10 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pogo-data-generator",
"version": "1.21.2",
"version": "2.0.0",
"description": "Pokemon GO project data generator",
"author": "TurtIeSocks",
"license": "Apache-2.0",
Expand All @@ -24,9 +24,8 @@
"raw": "ts-node devWrapper.ts --test --raw",
"invasions": "ts-node devWrapper.ts --test --invasions",
"test": "tsc && ./node_modules/.bin/jest",
"format": "prettier --config .prettierrc 'src/**/*.ts' --write",
"publishBuild": "rm -r dist && tsc",
"prettier": "prettier --write \"**/*.ts\""
"format": "biome format --write ./src/**/*.ts",
"publishBuild": "rm -r dist && tsc"
},
"repository": {
"type": "git",
Expand All @@ -37,24 +36,16 @@
},
"dependencies": {
"@na-ji/pogo-protos": "<3.0.0",
"jszip": "^3.10.1",
"node-fetch": "2.6.7"
"jszip": "^3.10.1"
},
"engines": {
"node": ">=16.0.0"
},
"prettier": {
"arrowParens": "always",
"trailingComma": "all",
"semi": false,
"singleQuote": true
"node": ">=21.0.0"
},
"devDependencies": {
"@types/node": "*",
"@types/node-fetch": "^2.6.2",
"jest": "^29.2.1",
"prettier": "^2.7.1",
"ts-node": "^10.9.1",
"typescript": "^4.5.5"
"@biomejs/biome": "2.3.9",
"@types/node": "^24",
"jest": "^30.2.0",
"ts-node": "^10.9.2",
"typescript": "^5.9.3"
}
}
2 changes: 1 addition & 1 deletion src/base.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FullTemplate } from './typings/inputs'
import type { FullTemplate } from './typings/inputs'

const baseTemplate: FullTemplate = {
globalOptions: {
Expand Down
2 changes: 1 addition & 1 deletion src/classes/Apk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default class ApkReader {
}

removeEscapes(str: string) {
return str.replace(/\r/g, '').replace(/\n/g, '').replace(/\"/g, '”')
return str.replace(/\r/g, '').replace(/\n/g, '').replace(/"/g, '”')
}

async fetchApk() {
Expand Down
8 changes: 4 additions & 4 deletions src/classes/Invasion.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Rpc } from '@na-ji/pogo-protos'

import { AllInvasions } from '../typings/dataTypes'
import { Options } from '../typings/inputs'
import { InvasionInfo } from '../typings/pogoinfo'
import type { AllInvasions } from '../typings/dataTypes'
import type { Options } from '../typings/inputs'
import type { InvasionInfo } from '../typings/pogoinfo'
import Masterfile from './Masterfile'

export default class Invasion extends Masterfile {
Expand Down Expand Up @@ -97,7 +97,7 @@ export default class Invasion extends Masterfile {
secondReward: false,
thirdReward: false,
}
if (pogoInfo && pogoInfo.active) {
if (pogoInfo?.active) {
this.parsedInvasions[id].firstReward =
pogoInfo.lineup.rewards.includes(0)
this.parsedInvasions[id].secondReward =
Expand Down
9 changes: 4 additions & 5 deletions src/classes/Item.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Rpc } from '@na-ji/pogo-protos'

import type { AllItems } from '../typings/dataTypes'
import type { NiaMfObj } from '../typings/general'
import type { Options } from '../typings/inputs'
import type { ItemProto } from '../typings/protos'
import Masterfile from './Masterfile'
import { AllItems } from '../typings/dataTypes'
import { NiaMfObj } from '../typings/general'
import { ItemProto } from '../typings/protos'
import { Options } from '../typings/inputs'

export default class Item extends Masterfile {
options: Options
Expand Down
9 changes: 4 additions & 5 deletions src/classes/LocationCards.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Rpc } from '@na-ji/pogo-protos'

import type { AllLocationCards } from '../typings/dataTypes'
import type { NiaMfObj } from '../typings/general'
import type { Options } from '../typings/inputs'
import type { LocationCardProto } from '../typings/protos'
import Masterfile from './Masterfile'
import { AllLocationCards } from '../typings/dataTypes'
import { Options } from '../typings/inputs'
import { NiaMfObj } from '../typings/general'
import { LocationCardProto } from '../typings/protos'

export default class LocationCards extends Masterfile {
options: Options
Expand Down
22 changes: 9 additions & 13 deletions src/classes/Masterfile.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { Options, FullTemplate } from '../typings/inputs'
import { FinalResult } from '../typings/dataTypes'

if (typeof fetch === 'undefined') {
global.fetch = require('node-fetch')
}
import type { FinalResult } from '../typings/dataTypes'
import type { FullTemplate, Options } from '../typings/inputs'

export default class Masterfile {
customFieldNames: { [id: string]: string }
Expand Down Expand Up @@ -67,15 +63,14 @@ export default class Masterfile {

async fetch(url: string, text = false): Promise<any> {
try {
const data = await fetch(url)
if (!data.ok) {
throw new Error(`${data.status} ${data.statusText} URL: ${url}`)
const response = await fetch(url)
if (!response.ok) {
throw new Error(`${response.status} ${response.statusText} URL: ${url}`)
}
return text ? data.text() : data.json()
return text ? response.text() : response.json()
} catch (e) {
if (e instanceof Error) {
console.warn(e.message, `Unable to fetch ${url}`)
}
const message = e instanceof Error ? e.message : String(e)
throw new Error(`Unable to fetch ${url}: ${message}`)
}
}

Expand Down Expand Up @@ -246,6 +241,7 @@ export default class Masterfile {
} catch (e) {
console.warn(
`Ref or X is undefined and it probably shouldn't be for ${reference}[${fieldKey}][${x}]`,
e,
)
}
return returnedObj
Expand Down
5 changes: 2 additions & 3 deletions src/classes/Misc.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Rpc } from '@na-ji/pogo-protos'

import Masterfile from './Masterfile'
import type { MiscProto } from '../typings/dataTypes'
import Masterfile from './Masterfile'

export default class Misc extends Masterfile {
routeTypes: { [key: string]: MiscProto }
Expand All @@ -15,7 +14,7 @@ export default class Misc extends Masterfile {
this.teams = {}
}

parse(proto: typeof Rpc[keyof typeof Rpc]) {
parse(proto: (typeof Rpc)[keyof typeof Rpc]) {
return Object.fromEntries(
Object.entries(proto).map(([key, value]) => [
value,
Expand Down
12 changes: 6 additions & 6 deletions src/classes/Move.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Rpc } from '@na-ji/pogo-protos'

import { NiaMfObj } from '../typings/general'
import { AllMoves } from '../typings/dataTypes'
import type { AllMoves } from '../typings/dataTypes'
import type { NiaMfObj } from '../typings/general'
import type { MoveProto, TypeProto } from '../typings/protos'
import Masterfile from './Masterfile'
import { MoveProto, TypeProto } from '../typings/protos'

export default class Moves extends Masterfile {
parsedMoves: AllMoves
Expand Down Expand Up @@ -41,7 +40,7 @@ export default class Moves extends Masterfile {
this.parsedMoves[id] = {
moveId: id,
moveName: this.capitalize(
isMax ? moveSettings.vfxName : proto.replace('_FAST', '')
isMax ? moveSettings.vfxName : proto.replace('_FAST', ''),
),
proto,
fast: templateId.endsWith('_FAST'),
Expand All @@ -50,7 +49,8 @@ export default class Moves extends Masterfile {
this.parsedMoves[id].type =
Rpc.HoloPokemonType[moveSettings.pokemonType as TypeProto]
this.parsedMoves[id].power = isMax
? moveSettings.obMoveSettingsNumber18[2] : moveSettings.power
? moveSettings.obMoveSettingsNumber18[2]
: moveSettings.power
this.parsedMoves[id].durationMs = moveSettings.durationMs
this.parsedMoves[id].energyDelta = moveSettings.energyDelta
}
Expand Down
23 changes: 12 additions & 11 deletions src/classes/PokeApi.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { Rpc } from '@na-ji/pogo-protos'
import Masterfile from './Masterfile'
import {
import type {
AllMoves,
AllPokemon,
AllTypes,
TempEvolutions,
} from '../typings/dataTypes'
import { TypeProto, PokemonIdProto, MoveProto } from '../typings/protos'
import {
import type { SpeciesApi } from '../typings/general'
import type {
BasePokeApiStruct,
PokeApiStats,
PokeApiTypes,
} from '../typings/pokeapi'
import { SpeciesApi } from '../typings/general'
import type { MoveProto, PokemonIdProto, TypeProto } from '../typings/protos'
import Masterfile from './Masterfile'

export default class PokeApi extends Masterfile {
baseStats: AllPokemon
Expand All @@ -27,7 +27,10 @@ export default class PokeApi extends Masterfile {

constructor(baseUrl?: string) {
super()
this.apiBaseUrl = (baseUrl || 'https://pokeapi.co/api/v2').replace(/\/$/, '')
this.apiBaseUrl = (baseUrl || 'https://pokeapi.co/api/v2').replace(
/\/$/,
'',
)
this.baseStats = {}
this.tempEvos = {}
this.types = {}
Expand Down Expand Up @@ -103,7 +106,7 @@ export default class PokeApi extends Masterfile {

private normalizeUrl(url: string) {
const match = url?.match(/\/api\/v2\/(.+)/)
if (match && match[1]) {
if (match?.[1]) {
return this.buildUrl(match[1])
}
return url
Expand Down Expand Up @@ -183,7 +186,7 @@ export default class PokeApi extends Masterfile {
!parsedPokemon[id].defense ||
!parsedPokemon[id].stamina ||
parsedPokemon[id].types.length === 0 ||
(pokeApiIds && pokeApiIds.includes(+id))
(pokeApiIds?.includes(+id))
) {
await this.pokemonApi(id)
}
Expand Down Expand Up @@ -521,9 +524,7 @@ export default class PokeApi extends Masterfile {
},
}: PokeApiTypes = id
? await this.fetch(
this.buildUrl(
`type/${type.substring(13).toLowerCase()}`,
),
this.buildUrl(`type/${type.substring(13).toLowerCase()}`),
)
: { damage_relations: {} }
this.types[id] = {
Expand Down
Loading