Updated compiler and trying to make ci work again

Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
2020-03-16 22:40:00 +01:00
parent ab5911fae9
commit b5ce0c9b93
20 changed files with 52 additions and 57 deletions

View File

@ -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)

View File

@ -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]
}

View File

@ -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)

View File

@ -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})

View File

@ -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
}
}

View File

@ -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
}

View File

@ -16,7 +16,6 @@ const btsp = async () => {
const card: Card = require(i).default
if (!card.illustrator) continue
console.log(i)
const illustrator = card.illustrator

View File

@ -20,7 +20,6 @@ const btsp = async () => {
!card.retreat ||
count.includes(card.retreat)
) continue
console.log(file)
count.push(card.retreat)
}

View File

@ -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)
}

View File

@ -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 {

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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>
}