1
0
mirror of https://github.com/tcgdex/cards-database.git synced 2025-07-29 03:09:49 +00:00

feat: Add status Dashboard (#187)

* feat: Add status Dashboard

Still need some polishing like using the compiler instead of the live DB

Signed-off-by: Avior <github@avior.me>

* refactor: Simplified compiler files generators

Signed-off-by: Avior <florian.bouillon@delta-wings.net>

* chore: Add step to compiler for stats and optimize

Signed-off-by: Avior <github@avior.me>

* refactor: Remove unused variable

Signed-off-by: Avior <github@avior.me>
This commit is contained in:
2021-11-23 15:12:50 +00:00
committed by GitHub
parent 8ef099273e
commit 762ce389c1
18 changed files with 431 additions and 142 deletions

View File

@ -1,16 +1,18 @@
/* eslint-disable max-statements */
import { Endpoint } from './compilerInterfaces'
import { FileFunction } from './compilerInterfaces'
import { promises as fs } from 'fs'
import { fetchRemoteFile } from './utils/util'
import { objectValues } from '@dzeio/object-util'
import { SupportedLanguages } from '../../interfaces'
const LANGS = ['en', 'fr', 'es', 'it', 'pt', 'de']
const LANGS: Array<SupportedLanguages> = ['en', 'fr', 'es', 'it', 'pt', 'de']
const DIST_FOLDER = './generated'
;(async () => {
const paths = (await fs.readdir('./compiler/endpoints')).filter((p) => p.endsWith('.ts'))
// Prefetch the pictures at the start as it can bug because of bad connection
console.log('Prefetching pictures')
await fetchRemoteFile('https://assets.tcgdex.net/datas.json')
@ -35,26 +37,18 @@ const DIST_FOLDER = './generated'
await fs.mkdir(folder, {recursive: true})
// Import the """Endpoint"""
const Ep = (await import(`./endpoints/${file}`)).default
const fn = (await import(`./endpoints/${file}`)).default as FileFunction
const endpoint = new Ep(lang) as Endpoint
console.log(file, 'Running Common')
let common: any | null = null
if (endpoint.common) {
common = await endpoint.common()
}
console.log(file, 'Running Item')
const item = await endpoint.item(common)
// Run the function
console.log(file, 'Running...')
const item = await fn(lang)
// Write to file
await fs.writeFile(`${folder}/${file.replace('.ts', '')}.json`, JSON.stringify(
objectValues(item)
item
))
console.log(file, 'Finished Item')
console.log(file, 'Finished!')
}
}