mirror of
https://github.com/tcgdex/compiler.git
synced 2025-08-04 18:01:59 +00:00
Initial Compiler
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
36
endpoints/retreat/index.ts
Normal file
36
endpoints/retreat/index.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import Card from "../../db/interfaces/Card"
|
||||
import { getAllCards2, getBaseFolder } from "../util"
|
||||
import { promises as fs } from 'fs'
|
||||
import { isCardAvailable } from "../cardUtil"
|
||||
import { RetreatList } from '../../sdk/dist/types/interfaces/Retreat'
|
||||
import { Langs } from "../../db/interfaces/LangList"
|
||||
|
||||
const lang = (process.env.CARDLANG || "en") as Langs
|
||||
const endpoint = getBaseFolder(lang, "retreat")
|
||||
|
||||
const btsp = async () => {
|
||||
const files = await getAllCards2()
|
||||
const count: Array<number> = []
|
||||
for (let file of files) {
|
||||
file = file.replace("./", "../../")
|
||||
const card: Card = await require(file).default
|
||||
|
||||
if (
|
||||
!isCardAvailable(card, lang) ||
|
||||
!card.retreat ||
|
||||
count.includes(card.retreat)
|
||||
) continue
|
||||
console.log(file)
|
||||
count.push(card.retreat)
|
||||
}
|
||||
|
||||
const list: RetreatList = {
|
||||
count: count.length,
|
||||
list: count
|
||||
}
|
||||
|
||||
await fs.mkdir(endpoint, {recursive: true})
|
||||
await fs.writeFile(`${endpoint}/index.json`, JSON.stringify(list))
|
||||
}
|
||||
|
||||
btsp()
|
Reference in New Issue
Block a user