diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b1381d6de..7aded59d1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,10 @@ on: jobs: test: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] steps: - name: Checkout diff --git a/server/compiler/utils/cardUtil.ts b/server/compiler/utils/cardUtil.ts index 78267fa0a..2d04700dc 100644 --- a/server/compiler/utils/cardUtil.ts +++ b/server/compiler/utils/cardUtil.ts @@ -1,5 +1,5 @@ /* eslint-disable sort-keys */ -import { exec } from 'child_process' +import pathLib from 'node:path' import { Card, Set, SupportedLanguages, Types } from '../../../interfaces' import { CardResume, Card as CardSingle } from '../../../meta/definitions/api' import { getSet, setToSetSimple } from './setUtil' @@ -145,7 +145,7 @@ export async function getCards(lang: SupportedLanguages, set?: Set): Promise = [] for (const path of cards) { - let items = path.split('/') + let items = path.split(pathLib.sep) items = items.slice(items.length - 3) // get the card id diff --git a/server/compiler/utils/serieUtil.ts b/server/compiler/utils/serieUtil.ts index 481b94c08..f958c1fea 100644 --- a/server/compiler/utils/serieUtil.ts +++ b/server/compiler/utils/serieUtil.ts @@ -1,3 +1,4 @@ +import path from 'node:path' import { Serie, Set, SupportedLanguages } from '../../../interfaces' import { SerieResume, Serie as SerieSingle } from '../../../meta/definitions/api' import { getSets, setToSetSimple } from './setUtil' @@ -17,6 +18,7 @@ export async function isSerieAvailable(serie: Serie, lang: SupportedLanguages): export async function getSeries(lang: SupportedLanguages): Promise> { let series: Array = (await Promise.all((await smartGlob(`${DB_PATH}/${getDataFolder(lang)}/*.ts`)) + .map((it) => it.replaceAll(path.sep, '/')) // Find Serie's name .map((it) => it.substring(it.lastIndexOf('/') + 1, it.length - 3)) // Fetch the Serie diff --git a/server/compiler/utils/setUtil.ts b/server/compiler/utils/setUtil.ts index 06a3de5c0..fc5d80d6c 100644 --- a/server/compiler/utils/setUtil.ts +++ b/server/compiler/utils/setUtil.ts @@ -3,6 +3,7 @@ import { Set, SupportedLanguages } from '../../../interfaces' import { SetResume, Set as SetSingle } from '../../../meta/definitions/api' import { cardToCardSimple, getCards } from './cardUtil' import { DB_PATH, fetchRemoteFile, getDataFolder, resolveText, setIsLegal, smartGlob } from './util' +import path from 'node:path' interface t { [key: string]: Set @@ -37,7 +38,9 @@ export async function getSet(name: string, serie = '*', lang: SupportedLanguages // Dont use cache as it wont necessary have them all export async function getSets(serie = '*', lang: SupportedLanguages): Promise> { // list sets names - const rawSets = (await smartGlob(`${DB_PATH}/${getDataFolder(lang)}/${serie}/*.ts`)).map((set) => set.substring(set.lastIndexOf('/') + 1, set.lastIndexOf('.'))) + const rawSets = (await smartGlob(`${DB_PATH}/${getDataFolder(lang)}/${serie}/*.ts`)) + .map((it) => it.replaceAll(path.sep, '/')) + .map((set) => set.substring(set.lastIndexOf('/') + 1, set.lastIndexOf('.'))) // Fetch sets const sets = (await Promise.all(rawSets.map((set) => getSet(set, serie, lang)))) // Filter sets diff --git a/server/compiler/utils/util.ts b/server/compiler/utils/util.ts index 242f5e3ae..a3279e95b 100644 --- a/server/compiler/utils/util.ts +++ b/server/compiler/utils/util.ts @@ -5,7 +5,6 @@ import { exec, spawn } from 'node:child_process' import { writeFileSync } from 'node:fs' import { Card, Languages, Set, SupportedLanguages } from '../../../interfaces' import * as legals from '../../../meta/legals' - interface fileCacheInterface { [key: string]: any } @@ -140,7 +139,8 @@ export async function loadLastEdits() { console.log('Loaded files tree', files.length, 'files') console.log('Loading their last edit time') let processed = 0 - const queue = new Queue(1000, 10) + const concurrent = process.platform === 'win32' ? 10 : 1000 + const queue = new Queue(concurrent, 10) queue.start() for await (let file of files) {