Skip to content

Commit

Permalink
Merge pull request #55 from WatWowMap/make-browser-friendly
Browse files Browse the repository at this point in the history
Enable Browser Compatibility
  • Loading branch information
TurtIeSocks committed Feb 20, 2022
2 parents 0bb6211 + 3ed75b3 commit b3ee837
Show file tree
Hide file tree
Showing 15 changed files with 636 additions and 527 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Pogo Data Generator

[![npm version](https://badge.fury.io/js/pogo-data-generator.svg)](https://badge.fury.io/js/pogo-data-generator)
[![Discord](https://img.shields.io/discord/552003258000998401.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/zZ9h9Xa)
[![Discord](https://img.shields.io/discord/552003258000998401.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/zZ9h9Xa)

Generates templated data for Pokemon GO related projects, including:

Expand All @@ -20,9 +21,9 @@ Generates templated data for Pokemon GO related projects, including:

## Installing/Usage

**Package**
### Package

```
```markdown
// with npm
npm install pogo-data-generator

Expand Down Expand Up @@ -107,14 +108,14 @@ const tr = await invasions()
// returns the default settings
```

**Local Usage/Testing**
### Local Usage/Testing

1. Clone the repo
2. Install TypeScript compiler `npm install -g typescript`
3. `tsc` will compile the TS into JS, then you can run `npm run generate`, which will generate a local `masterfile.json` for you to checkout

- `tsc -w` will auto recompile the TypeScript during development
- You can play with the input options by changing the scripts in `package.json` or modifying the `base.json` file.
- You can play with the input options by changing the scripts in `package.json` or modifying the `base.ts` file.
- `npm run pokeapi`, which will generate a local `masterfile.json` and refresh the data in the `static` folder from PokeAPI
- `npm run raw` will generate a local `masterfile.json` and with the raw data format

Expand Down
37 changes: 37 additions & 0 deletions devWrapper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import * as fs from 'fs'
import { generate, invasions } from './src/index'
import baseStats from './static/baseStats.json'
import tempEvos from './static/tempEvos.json'
import types from './static/types.json'

const main = async () => {
const start: number = Date.now()

const data = await generate({
raw: process.argv.includes('--raw'),
test: process.argv.includes('--test'),
pokeApi: process.argv.includes('--pokeapi')
|| { baseStats, tempEvos, types },
})

if (process.argv.includes('--test')) {
if (process.argv.includes('--invasions')) {
fs.writeFile('./invasions.json', JSON.stringify(await invasions(), null, 2), 'utf8', () => { })
}
if (data?.AllPokeApi) {
const { baseStats, tempEvos, types } = data.AllPokeApi
fs.writeFile('./static/baseStats.json', JSON.stringify(baseStats, null, 2), 'utf8', () => { })
fs.writeFile('./static/tempEvos.json', JSON.stringify(tempEvos, null, 2), 'utf8', () => { })
fs.writeFile('./static/types.json', JSON.stringify(types, null, 2), 'utf8', () => { })
delete data.AllPokeApi
}
if (data) {
fs.writeFile('./masterfile.json', JSON.stringify(data, null, 2), 'utf8', () => { })
}
}
return Date.now() - start
}

main()
.catch((e) => console.log(e))
.then((time) => console.log('Generated in ', time, 'ms'))
120 changes: 115 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pogo-data-generator",
"version": "1.3.9",
"version": "1.4.0",
"description": "Pokemon GO project data generator",
"author": "TurtIeSocks",
"license": "Apache-2.0",
Expand All @@ -18,10 +18,10 @@
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"generate": "node -e 'require(\"./dist/index\").generate({ test: true })'",
"pokeapi": "node -e 'require(\"./dist/index\").generate({ test: true, pokeApi: true })'",
"raw": "node -e 'require(\"./dist/index\").generate({ test: true, raw: true })'",
"invasions": "node -e 'require(\"./dist/index\").invasions({ test: true })'",
"generate": "ts-node devWrapper.ts --test",
"pokeapi": "ts-node devWrapper.ts --test --pokeapi",
"raw": "ts-node devWrapper.ts --test --raw",
"invasions": "ts-node devWrapper.ts --test --invasions",
"test": "./node_modules/.bin/jest"
},
"repository": {
Expand All @@ -36,7 +36,9 @@
"pogo-protos": "github:Furtif/pogo-protos"
},
"devDependencies": {
"@types/node-fetch": "^2.5.12",
"jest": "^27.4.7"
"@types/node-fetch": "^2.6.1",
"jest": "^27.4.7",
"ts-node": "^10.5.0",
"typescript": "^4.5.5"
}
}
Loading

0 comments on commit b3ee837

Please sign in to comment.