mirror of
https://github.com/tcgdex/cards-database.git
synced 2025-08-04 21:32:03 +00:00
feat: Add support for Asians Pokémon Cards (#481)
This commit is contained in:
@@ -4,7 +4,10 @@ import { SupportedLanguages } from '../../interfaces'
|
||||
import { FileFunction } from './compilerInterfaces'
|
||||
import { fetchRemoteFile, loadLastEdits } from './utils/util'
|
||||
|
||||
const LANGS: Array<SupportedLanguages> = ['en', 'fr', 'es', 'it', 'pt', 'de']
|
||||
const LANGS: Array<SupportedLanguages> = [
|
||||
'en', 'fr', 'es', 'it', 'pt', 'pt-br', 'pt-pt', 'de', 'nl', 'pl', 'ru',
|
||||
'ja', 'ko', 'zh-tw', 'id', 'th', 'zh-cn'
|
||||
]
|
||||
|
||||
const DIST_FOLDER = './generated'
|
||||
|
||||
@@ -12,7 +15,7 @@ const DIST_FOLDER = './generated'
|
||||
const paths = (await fs.readdir('./compiler/endpoints')).filter((p) => p.endsWith('.ts'))
|
||||
|
||||
// Prefetch the pictures at the start as it can bug because of bad connection
|
||||
console.log('Prefetching pictures')
|
||||
console.log('1. Prefetching pictures datas')
|
||||
await fetchRemoteFile('https://assets.tcgdex.net/datas.json')
|
||||
|
||||
// Delete dist folder to be sure to have a clean base
|
||||
@@ -20,14 +23,14 @@ const DIST_FOLDER = './generated'
|
||||
await fs.rm(DIST_FOLDER, {recursive: true})
|
||||
} catch {}
|
||||
|
||||
console.log('Loading files last edit')
|
||||
console.log('\n2. Loading informations from GIT')
|
||||
await loadLastEdits()
|
||||
|
||||
console.log('Let\'s GO !')
|
||||
console.log('\n3. Compiling Files')
|
||||
|
||||
// Process each languages
|
||||
let progressIndex = 0
|
||||
for await (const lang of LANGS) {
|
||||
console.log('Processing', lang)
|
||||
// loop through """endpoints"""
|
||||
for await (const file of paths) {
|
||||
|
||||
@@ -41,7 +44,7 @@ const DIST_FOLDER = './generated'
|
||||
const fn = (await import(`./endpoints/${file}`)).default as FileFunction
|
||||
|
||||
// Run the function
|
||||
console.log(file, 'Running...')
|
||||
console.log(' ', 'Compiling', lang, file)
|
||||
const item = await fn(lang)
|
||||
|
||||
// Write to file
|
||||
@@ -49,10 +52,11 @@ const DIST_FOLDER = './generated'
|
||||
item
|
||||
))
|
||||
|
||||
console.log(file, 'Finished!')
|
||||
console.log(`${(++progressIndex / (LANGS.length * paths.length) * 100).toFixed(2).padStart(5, '0')}%`, 'Compiled ', lang, file)
|
||||
}
|
||||
}
|
||||
|
||||
console.log('4. Copying static files to public folder')
|
||||
// Finally copy definitions files to the public folder :D
|
||||
for await (const file of await fs.readdir('../meta/definitions')) {
|
||||
await fs.copyFile('../meta/definitions/' + file, './public/v2/' + file)
|
||||
|
Reference in New Issue
Block a user