mirror of
https://github.com/tcgdex/compiler.git
synced 2025-07-03 04:09:19 +00:00
Initial Compiler
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
10
endpoints/RarityUtil.ts
Normal file
10
endpoints/RarityUtil.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import Rarity from "../db/interfaces/Rarity";
|
||||
import { Langs } from "../db/interfaces/LangList";
|
||||
import { raritySimple } from "./rarities/rarity";
|
||||
|
||||
export function rarityToRaritySimple(rarity: Rarity, lang: Langs): raritySimple {
|
||||
return {
|
||||
id: rarity,
|
||||
name: Rarity.toLang(rarity, lang)
|
||||
}
|
||||
}
|
10
endpoints/TagUtil.ts
Normal file
10
endpoints/TagUtil.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import Tag from "../db/interfaces/Tag";
|
||||
import { Langs } from "../db/interfaces/LangList";
|
||||
import { tagSimple } from "./tags/tag";
|
||||
|
||||
export function tagToTagSimple(tag: Tag, lang: Langs): tagSimple {
|
||||
return {
|
||||
id: tag,
|
||||
name: Tag.toLang(tag, lang)
|
||||
}
|
||||
}
|
0
endpoints/abilities-type/.gitkeep
Normal file
0
endpoints/abilities-type/.gitkeep
Normal file
0
endpoints/abilities/.gitkeep
Normal file
0
endpoints/abilities/.gitkeep
Normal file
21
endpoints/abilityUtil.ts
Normal file
21
endpoints/abilityUtil.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import Ability from "../db/interfaces/Ability";
|
||||
import { Langs } from "../db/interfaces/LangList";
|
||||
import { abilitySimple, abilitySingle } from "./abilities/ability";
|
||||
import AbilityType from "../db/interfaces/AbilityType";
|
||||
|
||||
export function abilityToAbilitySimple(ability: Ability, lang: Langs): abilitySimple {
|
||||
return {
|
||||
name: ability.name[lang]
|
||||
}
|
||||
}
|
||||
|
||||
export function abilityToAbilitySingle(ability: Ability, lang: Langs): abilitySingle {
|
||||
return {
|
||||
name: ability.name[lang],
|
||||
text: ability.text[lang],
|
||||
type: {
|
||||
id: ability.type,
|
||||
name: AbilityType.toLang(ability.type, lang)
|
||||
}
|
||||
}
|
||||
}
|
13
endpoints/attackUtil.ts
Normal file
13
endpoints/attackUtil.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import Attack from "../db/interfaces/Attack";
|
||||
import { Langs } from "../db/interfaces/LangList";
|
||||
import { attackSingle } from "./attacks/attack";
|
||||
import Type from "../db/interfaces/Type";
|
||||
|
||||
export function attackToAttackSingle(attack: Attack, lang: Langs): attackSingle {
|
||||
return {
|
||||
name: attack.name[lang],
|
||||
cost: attack.cost && attack.cost.map(el => Type.toLang(el, lang)),
|
||||
text: attack.text && attack.text[lang],
|
||||
damage: attack.damage && attack.damage
|
||||
}
|
||||
}
|
0
endpoints/attacks-by-cost/.gitkeep
Normal file
0
endpoints/attacks-by-cost/.gitkeep
Normal file
0
endpoints/attacks-by-type/.gitkeep
Normal file
0
endpoints/attacks-by-type/.gitkeep
Normal file
0
endpoints/attacks/.gitkeep
Normal file
0
endpoints/attacks/.gitkeep
Normal file
90
endpoints/cardUtil.ts
Normal file
90
endpoints/cardUtil.ts
Normal file
@ -0,0 +1,90 @@
|
||||
import { CardSimple, CardSingle } from "../sdk/dist/types/interfaces/Card";
|
||||
import Card from "../db/interfaces/Card";
|
||||
import { Langs } from "../db/interfaces/LangList";
|
||||
import { typeToTypeSimple } from "./typeUtil";
|
||||
import { rarityToRaritySimple } from "./RarityUtil";
|
||||
import { tagToTagSimple } from "./TagUtil";
|
||||
import Category from "../db/interfaces/Category";
|
||||
import { attackToAttackSingle } from "./attackUtil";
|
||||
import { abilityToAbilitySingle } from "./abilityUtil";
|
||||
import { getExpansion } from "./expansionUtil";
|
||||
import { getSet } from "./setUtil";
|
||||
import Expansion from "../db/interfaces/Expansion";
|
||||
|
||||
export function cardToCardSimple(card: Card, lang: Langs): CardSimple {
|
||||
return {
|
||||
id: card.id,
|
||||
name: card.name[lang],
|
||||
image: card.image && card.image.low[lang]
|
||||
}
|
||||
}
|
||||
|
||||
export function getCardExpansion(card: Card): Expansion {
|
||||
return getExpansion(getSet(card))
|
||||
}
|
||||
|
||||
export function cardToCardSingle(card: Card, lang: Langs): CardSingle {
|
||||
|
||||
const images: {
|
||||
low: string,
|
||||
high?: string
|
||||
} = card.image && {
|
||||
low: card.image.low[lang],
|
||||
high: card.image.high && card.image.high[lang]
|
||||
}
|
||||
|
||||
return {
|
||||
id: card.id,
|
||||
localId: card.localId,
|
||||
dexId: card.dexId,
|
||||
|
||||
name: card.name[lang],
|
||||
hp: card.hp,
|
||||
type: card.type && card.type.map((el) => typeToTypeSimple(el, lang)),
|
||||
|
||||
image: images,
|
||||
|
||||
evolveFrom: card.evolveFrom && card.evolveFrom[lang],
|
||||
evolveTo: card.evolveTo && card.evolveTo.map((el) => el[lang]),
|
||||
tags: card.tags.map((el) => tagToTagSimple(el, lang)),
|
||||
illustrator: {
|
||||
id: 0,
|
||||
name: typeof card.illustrator === "object" ? card.illustrator.name : card.illustrator,
|
||||
},
|
||||
|
||||
abilities: card.abilities && card.abilities.map((el) => abilityToAbilitySingle(el, lang)),
|
||||
|
||||
attacks: card.attacks && card.attacks.map(el => attackToAttackSingle(el, lang)),
|
||||
|
||||
effect: card.effect && card.effect[lang],
|
||||
|
||||
weaknesses: card.weaknesses && card.weaknesses.map(el => {return {type: typeToTypeSimple(el.type, lang), value: el.value}}),
|
||||
resistances: card.resistances && card.resistances.map(el => {return {type: typeToTypeSimple(el.type, lang), value: el.value}}),
|
||||
|
||||
retreat: card.retreat && card.retreat,
|
||||
|
||||
rarity: rarityToRaritySimple(card.rarity, lang),
|
||||
|
||||
category: {
|
||||
id: card.category,
|
||||
name: Category.toLang(card.category, lang)
|
||||
},
|
||||
|
||||
set: {
|
||||
name: typeof card.set.name === "object" ? card.set.name[lang] : card.set.name,
|
||||
code: card.set.code
|
||||
},
|
||||
|
||||
cardTypes: card.cardTypes && card.cardTypes
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export function isCardAvailable(card: Card, lang: Langs): boolean {
|
||||
if (!(lang in card.name)) return false
|
||||
const set = getSet(card)
|
||||
if ("availability" in set && (lang in set.availability)) {
|
||||
return set.availability[lang]
|
||||
}
|
||||
return true
|
||||
}
|
38
endpoints/cards/index.ts
Normal file
38
endpoints/cards/index.ts
Normal file
@ -0,0 +1,38 @@
|
||||
import Card from "../../db/interfaces/Card"
|
||||
import { Langs } from "../../db/interfaces/LangList"
|
||||
import { promises as fs } from 'fs'
|
||||
import { CardList, CardSimple } from "../../sdk/dist/types/interfaces/Card"
|
||||
import { cardToCardSimple, isCardAvailable } from "../cardUtil"
|
||||
import { getBaseFolder, getAllCards2 } from "../util"
|
||||
|
||||
const lang = process.env.CARDLANG as Langs || "en"
|
||||
|
||||
const endpoint = getBaseFolder(lang, "cards")
|
||||
|
||||
const bootstrap = async () => {
|
||||
const list = await getAllCards2()
|
||||
const items: Array<CardSimple> = []
|
||||
for (let el of list) {
|
||||
el = el.replace("./", "../../")
|
||||
const card: Card = require(el).default
|
||||
|
||||
console.log(el)
|
||||
if (!isCardAvailable(card, lang)) continue
|
||||
items.push(
|
||||
cardToCardSimple(card, lang)
|
||||
)
|
||||
|
||||
// if (if (typeof card.set.availability === "undefined"))
|
||||
}
|
||||
|
||||
const cardList: CardList = {
|
||||
count: items.length,
|
||||
list: items
|
||||
}
|
||||
|
||||
await fs.mkdir(`${endpoint}`, {recursive: true})
|
||||
await fs.writeFile(`${endpoint}/index.json`, JSON.stringify(cardList))
|
||||
|
||||
}
|
||||
|
||||
bootstrap()
|
28
endpoints/cards/item.ts
Normal file
28
endpoints/cards/item.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { getAllCards2, getBaseFolder } from "..//util"
|
||||
import Card from "../../db/interfaces/Card"
|
||||
import { Langs } from "../../db/interfaces/LangList"
|
||||
import { promises as fs } from 'fs'
|
||||
import { cardToCardSingle, isCardAvailable } from "../cardUtil"
|
||||
|
||||
const lang = process.env.CARDLANG as Langs || "en"
|
||||
|
||||
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})
|
||||
await fs.writeFile(`${endpoint}/${card.id}/index.json`, JSON.stringify(cardToCardSingle(card, lang)))
|
||||
|
||||
// if (if (typeof card.set.availability === "undefined"))
|
||||
}
|
||||
}
|
||||
|
||||
bootstrap()
|
7
endpoints/expansionUtil.ts
Normal file
7
endpoints/expansionUtil.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import Expansion from "../db/interfaces/Expansion"
|
||||
import Set from "../db/interfaces/Set"
|
||||
|
||||
export function getExpansion(set: Set): Expansion {
|
||||
if ("expansion" in set) return set.expansion
|
||||
return require(`../../db/expansions/${set.expansionCode}`)
|
||||
}
|
0
endpoints/resistances/.gitkeep
Normal file
0
endpoints/resistances/.gitkeep
Normal file
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()
|
42
endpoints/retreat/item.ts
Normal file
42
endpoints/retreat/item.ts
Normal file
@ -0,0 +1,42 @@
|
||||
import Card from "../../db/interfaces/Card"
|
||||
import { getAllCards2, getBaseFolder } from "../util"
|
||||
import { promises as fs } from 'fs'
|
||||
import { isCardAvailable, cardToCardSimple } from "../cardUtil"
|
||||
import { RetreatSingle } 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<Array<Card>> = []
|
||||
for (let file of files) {
|
||||
file = file.replace("./", "../../")
|
||||
const card: Card = await require(file).default
|
||||
|
||||
if (
|
||||
!isCardAvailable(card, lang) ||
|
||||
!card.retreat
|
||||
) continue
|
||||
console.log(file)
|
||||
if (!(card.retreat in count)) count[card.retreat] = []
|
||||
count[card.retreat].push(card)
|
||||
}
|
||||
|
||||
for (const retreat in count) {
|
||||
if (count.hasOwnProperty(retreat)) {
|
||||
const cardArr = count[retreat];
|
||||
|
||||
const item: RetreatSingle = {
|
||||
id: retreat as unknown as number,
|
||||
cards: cardArr.map((val) => cardToCardSimple(val, lang))
|
||||
}
|
||||
|
||||
await fs.mkdir(`${endpoint}/${item.id}`, {recursive: true})
|
||||
await fs.writeFile(`${endpoint}/${item.id}/index.json`, JSON.stringify(item))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
btsp()
|
80
endpoints/setUtil.ts
Normal file
80
endpoints/setUtil.ts
Normal file
@ -0,0 +1,80 @@
|
||||
import Set from "../db/interfaces/Set"
|
||||
import Card from "../db/interfaces/Card"
|
||||
import * as glob from 'glob'
|
||||
import { Langs } from "../db/interfaces/LangList"
|
||||
import { SetSimple, SetSingle } from "../sdk/dist/types/interfaces/Set"
|
||||
import { cardToCardSimple } from "./cardUtil"
|
||||
import { CardSimple } from "../sdk/dist/types/interfaces/Card"
|
||||
import { getAllCards2 } from "./util"
|
||||
|
||||
interface t<T = Set> {
|
||||
[key: string]: T
|
||||
}
|
||||
|
||||
const setCache: t = {}
|
||||
|
||||
export function isSet(set: Set | {name: string, code: string}): set is Set {
|
||||
return "releaseDate" in 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
|
||||
}
|
||||
return setCache[card.set.code]
|
||||
}
|
||||
|
||||
export function isSetAvailable(set: Set, lang: Langs) {
|
||||
if (!set.availability || !(lang in set.availability)) return true
|
||||
return set.availability
|
||||
}
|
||||
|
||||
export function setToSetSimple(set: Set, lang: Langs): SetSimple {
|
||||
return {
|
||||
code: set.code,
|
||||
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) {
|
||||
el = el.replace("./", "../")
|
||||
const card: Card = require(el).default
|
||||
|
||||
items.push(
|
||||
cardToCardSimple(card, lang)
|
||||
)
|
||||
}
|
||||
|
||||
return items
|
||||
}
|
||||
|
||||
export function setToSetSingle(set: Set, lang: Langs): SetSingle {
|
||||
return {
|
||||
name: set.name[lang],
|
||||
code: set.code,
|
||||
expansionCode: set.expansion && set.expansion.code || set.expansionCode || undefined,
|
||||
tcgoCode: set.tcgoCode,
|
||||
cardCount: {
|
||||
total: set.cardCount.total,
|
||||
official: set.cardCount.official
|
||||
},
|
||||
releaseDate: set.releaseDate,
|
||||
legal: set.legal && {
|
||||
standard: set.legal.standard,
|
||||
expanded: set.legal.expanded
|
||||
},
|
||||
images: set.images && {
|
||||
symbol: set.images.symbol,
|
||||
logo: set.images.logo
|
||||
},
|
||||
list: getSetCards(set, lang)
|
||||
}
|
||||
}
|
38
endpoints/sets/index.ts
Normal file
38
endpoints/sets/index.ts
Normal file
@ -0,0 +1,38 @@
|
||||
import Set from "../../db/interfaces/Set"
|
||||
import { Langs } from "../../db/interfaces/LangList"
|
||||
import { promises as fs } from 'fs'
|
||||
import { SetSimple, SetList } from "../../sdk/dist/types/interfaces/Set"
|
||||
import { getAllSets, getBaseFolder } from "../util"
|
||||
import { isSetAvailable, setToSetSimple } from "../setUtil"
|
||||
|
||||
const lang = process.env.CARDLANG as Langs || "en"
|
||||
|
||||
const endpoint = getBaseFolder(lang, "sets")
|
||||
|
||||
const bootstrap = async () => {
|
||||
const list = await getAllSets()
|
||||
const items: Array<SetSimple> = []
|
||||
for (let el of list) {
|
||||
el = el.replace("./", "../../")
|
||||
const set: Set = require(el).default
|
||||
|
||||
console.log(el)
|
||||
if (!isSetAvailable(set, lang)) continue
|
||||
items.push(
|
||||
setToSetSimple(set, lang)
|
||||
)
|
||||
}
|
||||
|
||||
const cardList: SetList = {
|
||||
count: items.length,
|
||||
list: items
|
||||
}
|
||||
|
||||
await fs.mkdir(`${endpoint}`, {recursive: true})
|
||||
await fs.writeFile(`${endpoint}/index.json`, JSON.stringify(cardList))
|
||||
|
||||
}
|
||||
|
||||
console.log("Building sets/index")
|
||||
|
||||
bootstrap()
|
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()
|
42
endpoints/sets/subitem.ts
Normal file
42
endpoints/sets/subitem.ts
Normal file
@ -0,0 +1,42 @@
|
||||
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 } from "../setUtil"
|
||||
import { getAllCards2 } from "../util"
|
||||
import Card from "../../db/interfaces/Card"
|
||||
import { cardToCardSingle, isCardAvailable } from "../cardUtil"
|
||||
|
||||
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
|
||||
|
||||
console.log(el)
|
||||
if (!isSetAvailable(set, lang)) continue
|
||||
|
||||
const lit = await getAllCards2(set.code)
|
||||
for (let i of lit) {
|
||||
i = i.replace("./", "../../")
|
||||
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)))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
console.log("Building sets/subitem")
|
||||
|
||||
bootstrap()
|
10
endpoints/typeUtil.ts
Normal file
10
endpoints/typeUtil.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import Type from "../db/interfaces/Type";
|
||||
import LangList, { Langs } from "../db/interfaces/LangList";
|
||||
import { typeSimple } from "./types/type";
|
||||
|
||||
export function typeToTypeSimple(type: Type, lang: Langs): typeSimple {
|
||||
return {
|
||||
id: type,
|
||||
name: Type.toLang(type, lang)
|
||||
}
|
||||
}
|
65
endpoints/util.ts
Normal file
65
endpoints/util.ts
Normal file
@ -0,0 +1,65 @@
|
||||
import { promises as fs, promises } from 'fs'
|
||||
import * as glob from 'glob'
|
||||
|
||||
export function getAllCards() {
|
||||
return listFolder("./assets")
|
||||
}
|
||||
|
||||
export function getAllCards2(set = "**", expansion = "**") {
|
||||
return glob.sync(`./db/cards/${expansion}/${set}/*.js`)
|
||||
}
|
||||
|
||||
export function getAllSets() {
|
||||
return glob.sync('./db/sets/**/*.js')
|
||||
}
|
||||
|
||||
export function getAllCardsJSON() {
|
||||
return glob.sync("./db/cards/**/**/*.json")
|
||||
}
|
||||
|
||||
async function listFolder(folder: string): Promise<Array<string>> {
|
||||
const files = await fs.readdir(folder)
|
||||
const res = []
|
||||
for (const file of files) {
|
||||
if (file.endsWith(".json")) res.push(`${folder}/${file}`)
|
||||
if ((await fs.stat(`${folder}/${file}`)).isDirectory()) {
|
||||
res.push(...await listFolder(`${folder}/${file}`))
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
export function getBaseFolder(lang: string, endpoint: string) {
|
||||
return `./dist/${lang}/${endpoint}`
|
||||
}
|
||||
|
||||
export async function del(path: string) {
|
||||
let files = []
|
||||
const promiseArr = []
|
||||
try {
|
||||
files = await promises.readdir(path)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
if (files.length > 0) {
|
||||
for (const file of files) {
|
||||
const fPath = `${path}/${file}`
|
||||
if ((await promises.stat(fPath)).isDirectory()) {
|
||||
promiseArr.push(
|
||||
del(fPath)
|
||||
)
|
||||
} else {
|
||||
promiseArr.push(
|
||||
promises.unlink(fPath)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
await Promise.all(promiseArr)
|
||||
await promises.rmdir(path)
|
||||
}
|
||||
|
||||
export function urlize(str: string): string {
|
||||
str = str.normalize('NFD').replace(/[\u0300-\u036f]/g, "")
|
||||
return str.replace(/ /g, "-").toLowerCase()
|
||||
}
|
0
endpoints/weaknesses/.gitkeep
Normal file
0
endpoints/weaknesses/.gitkeep
Normal file
Reference in New Issue
Block a user