mirror of
https://github.com/tcgdex/compiler.git
synced 2025-08-01 16:41:58 +00:00
Updated
Signed-off-by: Florian BOUILLON <florian.bouillon@delta-wings.net>
This commit is contained in:
@@ -3,11 +3,14 @@ import { IllustratorsList } from "@tcgdex/sdk/interfaces/Illustrator"
|
||||
import { getBaseFolder } from "../util"
|
||||
import { promises as fs} from "fs"
|
||||
|
||||
import Logger from '@dzeio/logger'
|
||||
const logger = new Logger('illustrators/index')
|
||||
|
||||
const lang = process.env.CARDLANG || "en"
|
||||
const endpoint = getBaseFolder(lang, "illustrators")
|
||||
|
||||
export default async () => {
|
||||
console.log(endpoint)
|
||||
logger.log('Fetching illustrators')
|
||||
|
||||
const db = await fetchIllustrators()
|
||||
|
||||
@@ -18,5 +21,5 @@ export default async () => {
|
||||
|
||||
await fs.mkdir(endpoint, {recursive: true})
|
||||
await fs.writeFile(`${endpoint}/index.json`, JSON.stringify(res))
|
||||
console.log('ended ' + endpoint)
|
||||
logger.log('Finished')
|
||||
}
|
||||
|
@@ -6,6 +6,9 @@ import Card from "@tcgdex/sdk/interfaces/Card"
|
||||
import { isCardAvailable, cardToCardSimple } from "../cardUtil"
|
||||
import { Langs } from "@tcgdex/sdk/interfaces/LangList"
|
||||
|
||||
import Logger from '@dzeio/logger'
|
||||
const logger = new Logger('illustrators/item')
|
||||
|
||||
const lang = process.env.CARDLANG as Langs || "en"
|
||||
const endpoint = getBaseFolder(lang, "illustrators")
|
||||
|
||||
@@ -14,18 +17,18 @@ interface t {
|
||||
}
|
||||
|
||||
export default async () => {
|
||||
console.log(endpoint)
|
||||
logger.log('Fetching Illustrators/Cards')
|
||||
|
||||
const db = await fetchIllustrators()
|
||||
const cards = getAllCards()
|
||||
const cards = await getAllCards()
|
||||
|
||||
const tmp: t = {}
|
||||
|
||||
|
||||
for (const i of cards) {
|
||||
const card: Card = require(`../../db/cards/${i}`).default
|
||||
const card: Card = (await import(i)).default
|
||||
|
||||
if (!isCardAvailable(card, lang) || !card.illustrator) continue
|
||||
if (!(await isCardAvailable(card, lang)) || !card.illustrator) continue
|
||||
|
||||
if (!(card.illustrator in tmp)) tmp[card.illustrator] = []
|
||||
tmp[card.illustrator].push(card)
|
||||
@@ -33,6 +36,7 @@ export default async () => {
|
||||
|
||||
for (const illustrator in tmp) {
|
||||
if (tmp.hasOwnProperty(illustrator)) {
|
||||
logger.log('Processing illustrator', illustrator)
|
||||
const list = tmp[illustrator];
|
||||
|
||||
const toSave: IllustratorSingle = {
|
||||
@@ -45,5 +49,5 @@ export default async () => {
|
||||
await fs.writeFile(`${endpoint}/${toSave.id}/index.json`, JSON.stringify(toSave))
|
||||
}
|
||||
}
|
||||
console.log('ended ' + endpoint)
|
||||
logger.log('Finished')
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { getAllCards2 } from "../util"
|
||||
import { getAllCards, getAllCards2 } from "../util"
|
||||
import Card from "@tcgdex/sdk/interfaces/Card"
|
||||
|
||||
import { promises as fs} from "fs"
|
||||
@@ -10,10 +10,9 @@ export default async () => {
|
||||
const db = await fetchIllustrators()
|
||||
|
||||
|
||||
const list = getAllCards2()
|
||||
const list = await getAllCards()
|
||||
for (let i of list) {
|
||||
i = i.replace("./", "../../")
|
||||
const card: Card = require(i).default
|
||||
const card: Card = (await import(i)).default
|
||||
|
||||
if (!card.illustrator) continue
|
||||
|
||||
|
Reference in New Issue
Block a user