mirror of
https://github.com/tcgdex/compiler.git
synced 2025-07-03 20:29:19 +00:00
Initial Compiler
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
28
endpoints/sets/item.ts
Normal file
28
endpoints/sets/item.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { getBaseFolder, getAllSets } from "../util"
|
||||
import Set from "../../db/interfaces/Set"
|
||||
import { Langs } from "../../db/interfaces/LangList"
|
||||
import { promises as fs } from 'fs'
|
||||
import { isSetAvailable, setToSetSingle } from "../setUtil"
|
||||
|
||||
const lang = process.env.CARDLANG as Langs || "en"
|
||||
|
||||
const endpoint = getBaseFolder(lang, "sets")
|
||||
|
||||
const bootstrap = async () => {
|
||||
const list = await getAllSets()
|
||||
for (let el of list) {
|
||||
el = el.replace("./", "../../")
|
||||
const set: Set = require(el).default
|
||||
|
||||
if (!isSetAvailable(set, lang)) continue
|
||||
console.log(el)
|
||||
|
||||
await fs.mkdir(`${endpoint}/${set.code}/`, {recursive: true})
|
||||
await fs.writeFile(`${endpoint}/${set.code}/index.json`, JSON.stringify(setToSetSingle(set, lang)))
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
console.log("Building sets/item")
|
||||
|
||||
bootstrap()
|
Reference in New Issue
Block a user