mirror of
https://github.com/tcgdex/compiler.git
synced 2025-07-03 04:09:19 +00:00
Updated compiler and trying to make ci work again
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
@ -1,9 +1,8 @@
|
||||
import Tag from "@tcgdex/sdk/interfaces/Tag";
|
||||
import Tag, { TagSimple } from "@tcgdex/sdk/interfaces/Tag";
|
||||
import { Langs } from "@tcgdex/sdk/interfaces/LangList";
|
||||
import { tagSimple } from "./tags/tag";
|
||||
import TranslationUtil from "@tcgdex/sdk/TranslationUtil";
|
||||
|
||||
export function tagToTagSimple(tag: Tag, lang: Langs): tagSimple {
|
||||
export function tagToTagSimple(tag: Tag, lang: Langs): TagSimple {
|
||||
return {
|
||||
id: tag,
|
||||
name: TranslationUtil.translate("tag", tag, lang)
|
||||
|
@ -9,12 +9,13 @@ import { abilityToAbilitySingle } from "./abilityUtil";
|
||||
import { getExpansion } from "./expansionUtil";
|
||||
import { getSet } from "./setUtil";
|
||||
import Expansion from "@tcgdex/sdk/interfaces/Expansion";
|
||||
import { fetchIllustrators, fetchIllustratorsSync } from "./illustratorUtil";
|
||||
import { fetchIllustratorsSync } from "./illustratorUtil";
|
||||
import TranslationUtil from "@tcgdex/sdk/TranslationUtil";
|
||||
|
||||
export function cardToCardSimple(card: Card, lang: Langs): CardSimple {
|
||||
return {
|
||||
id: card.id,
|
||||
localId: card.localId,
|
||||
name: card.name[lang],
|
||||
image: card.image && card.image.low[lang]
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ const bootstrap = async () => {
|
||||
el = el.replace("./", "../../")
|
||||
const card: Card = require(el).default
|
||||
|
||||
console.log(el)
|
||||
if (!isCardAvailable(card, lang)) continue
|
||||
items.push(
|
||||
cardToCardSimple(card, lang)
|
||||
|
@ -10,12 +10,10 @@ const endpoint = getBaseFolder(lang, "cards")
|
||||
|
||||
const bootstrap = async () => {
|
||||
const list = await getAllCards2()
|
||||
console.log(list)
|
||||
for (let el of list) {
|
||||
el = el.replace("./", "../../")
|
||||
const card: Card = require(el).default
|
||||
|
||||
console.log(el)
|
||||
if (!isCardAvailable(card, lang)) continue
|
||||
|
||||
await fs.mkdir(`${endpoint}/${card.id}/`, {recursive: true})
|
||||
|
@ -27,9 +27,15 @@ export function expansionToExpansionSimple(expansion: Expansion, lang: Langs) {
|
||||
}
|
||||
|
||||
export function expansionToExpansionSingle(expansion: Expansion, lang: Langs): ExpansionSingle {
|
||||
const sets = getAllSets(expansion.code, true)
|
||||
.map(el => fetchSet(expansion.code, el))
|
||||
.sort((a, b) => {
|
||||
return a.releaseDate > b.releaseDate ? 1 : -1
|
||||
})
|
||||
.map(el => setToSetSimple(el, lang))
|
||||
return {
|
||||
code: expansion.code,
|
||||
name: typeof expansion.name === "string" ? expansion.name : expansion.name[lang],
|
||||
sets: getAllSets(expansion.code, true).map(el => setToSetSimple(fetchSet(expansion.code, el), lang))
|
||||
sets
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ const btsp = async () => {
|
||||
expansion.sets = sets
|
||||
let oldestRelease = "9999-99-99"
|
||||
for (const j of sets) {
|
||||
console.log(j)
|
||||
const set = fetchSet(expansion.code, j)
|
||||
oldestRelease = set.releaseDate < oldestRelease ? set.releaseDate : oldestRelease
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ const btsp = async () => {
|
||||
const card: Card = require(i).default
|
||||
|
||||
if (!card.illustrator) continue
|
||||
console.log(i)
|
||||
|
||||
const illustrator = card.illustrator
|
||||
|
||||
|
@ -20,7 +20,6 @@ const btsp = async () => {
|
||||
!card.retreat ||
|
||||
count.includes(card.retreat)
|
||||
) continue
|
||||
console.log(file)
|
||||
count.push(card.retreat)
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,6 @@ const btsp = async () => {
|
||||
!isCardAvailable(card, lang) ||
|
||||
!card.retreat
|
||||
) continue
|
||||
console.log(file)
|
||||
if (!(card.retreat in count)) count[card.retreat] = []
|
||||
count[card.retreat].push(card)
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ export function isSet(set: Set | {name: string, code: string}): set is Set {
|
||||
export function getSet(card: Card): Set {
|
||||
if (!(card.set.code in setCache)) {
|
||||
if (isSet(card.set)) setCache[card.set.code] = card.set
|
||||
console.log(card.set.code)
|
||||
let setPath = glob.sync(`./db/sets/**/${card.set.code}.js`)[0]
|
||||
setPath = setPath.replace('./', '../')
|
||||
setCache[card.set.code] = require(setPath).default
|
||||
@ -40,24 +39,31 @@ export function isSetAvailable(set: Set, lang: Langs) {
|
||||
export function setToSetSimple(set: Set, lang: Langs): SetSimple {
|
||||
return {
|
||||
code: set.code,
|
||||
logo: set.images && set.images.logo,
|
||||
symbol: set.images && set.images.symbol,
|
||||
name: typeof set.name === "string" ? set.name : set.name[lang],
|
||||
total: set.cardCount.total
|
||||
}
|
||||
}
|
||||
|
||||
export function getSetCards(set: Set, lang: Langs): Array<CardSimple> {
|
||||
const cards = getAllCards2(set.code)
|
||||
const items: Array<CardSimple> = []
|
||||
for (let el of cards) {
|
||||
const cardes = getAllCards2(set.code)
|
||||
const cards: Array<Card> = []
|
||||
for (let el of cardes) {
|
||||
el = el.replace("./", "../")
|
||||
const card: Card = require(el).default
|
||||
|
||||
items.push(
|
||||
cardToCardSimple(card, lang)
|
||||
cards.push(
|
||||
card
|
||||
)
|
||||
}
|
||||
|
||||
return items
|
||||
return cards.sort((a, b) => {
|
||||
if (!isNaN(parseInt(a.localId + "")) && !isNaN(parseInt(b.localId + ""))) {
|
||||
return parseInt(a.localId + "") - parseInt(b.localId + "")
|
||||
}
|
||||
return a.localId > b.localId ? 1 : -1
|
||||
}).map(el => cardToCardSimple(el, lang))
|
||||
}
|
||||
|
||||
export function setToSetSingle(set: Set, lang: Langs): SetSingle {
|
||||
|
@ -16,7 +16,6 @@ const bootstrap = async () => {
|
||||
el = el.replace("./", "../../")
|
||||
const set: Set = require(el).default
|
||||
|
||||
console.log(el)
|
||||
if (!isSetAvailable(set, lang)) continue
|
||||
items.push(
|
||||
set
|
||||
@ -37,6 +36,4 @@ const bootstrap = async () => {
|
||||
|
||||
}
|
||||
|
||||
console.log("Building sets/index")
|
||||
|
||||
bootstrap()
|
||||
|
@ -15,7 +15,6 @@ const bootstrap = async () => {
|
||||
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)))
|
||||
@ -23,6 +22,5 @@ const bootstrap = async () => {
|
||||
|
||||
|
||||
}
|
||||
console.log("Building sets/item")
|
||||
|
||||
bootstrap()
|
||||
|
@ -17,7 +17,6 @@ const bootstrap = async () => {
|
||||
el = el.replace("./", "../../")
|
||||
const set: Set = require(el).default
|
||||
|
||||
console.log(el)
|
||||
if (!isSetAvailable(set, lang)) continue
|
||||
|
||||
const lit = await getAllCards2(set.code)
|
||||
@ -26,7 +25,6 @@ const bootstrap = async () => {
|
||||
const card: Card = require(i).default
|
||||
|
||||
if (!isCardAvailable(card, lang)) continue
|
||||
console.log(i)
|
||||
|
||||
await fs.mkdir(`${endpoint}/${set.code}/${card.localId}`, {recursive: true})
|
||||
await fs.writeFile(`${endpoint}/${set.code}/${card.localId}/index.json`, JSON.stringify(cardToCardSingle(card, lang)))
|
||||
@ -37,6 +35,4 @@ const bootstrap = async () => {
|
||||
|
||||
}
|
||||
|
||||
console.log("Building sets/subitem")
|
||||
|
||||
bootstrap()
|
||||
|
@ -1,15 +0,0 @@
|
||||
import { cardSimple } from "../cards/card";
|
||||
|
||||
export interface tagSimple {
|
||||
id: number
|
||||
name: string
|
||||
}
|
||||
|
||||
export interface tagSingle extends tagSimple {
|
||||
cards: Array<cardSimple>
|
||||
}
|
||||
|
||||
export interface tagList {
|
||||
count: number
|
||||
list: Array<tagSimple>
|
||||
}
|
Reference in New Issue
Block a user