The minimalistic document archiving platform.
refactor(tests): replace tinyglobby with native Node.js glob (#1060)
Corentin Thomasset854739382dd9
diff --git a/apps/papra-client/package.json b/apps/papra-client/package.jsonindex 577f8c57..1b19297e 100644--- a/apps/papra-client/package.json+++ b/apps/papra-client/package.json@@ -63,7 +63,6 @@"@types/node": "catalog:","eslint": "catalog:","eslint-plugin-solid": "^0.14.5",- "tinyglobby": "^0.2.14","tsx": "catalog:","typescript": "catalog:","unocss": "catalog:",diff --git a/apps/papra-client/src/modules/i18n/locales.test.ts b/apps/papra-client/src/modules/i18n/locales.test.tsindex aa23820d..cdc5779f 100644--- a/apps/papra-client/src/modules/i18n/locales.test.ts+++ b/apps/papra-client/src/modules/i18n/locales.test.ts@@ -1,7 +1,6 @@-import { readFile } from 'node:fs/promises';+import { glob, readFile } from 'node:fs/promises';import { dirname, join } from 'node:path';import { fileURLToPath } from 'node:url';-import { glob } from 'tinyglobby';import { describe, expect, test } from 'vitest';import { locales as registeredLocales } from './i18n.constants';@@ -44,7 +43,10 @@ describe('locales', () => {}test('all keys in en.yml must be used in the app (dynamic keys are manually excluded)', async () => {- const srcFileNames = await glob(['src/**/*.{ts,tsx}', '!src/**/*.test.*', '!src/modules/i18n/locales.types.ts'], { cwd: packageRoot });+ const srcFileNames = await Array.fromAsync(glob('src/**/*.{ts,tsx}', {+ cwd: packageRoot,+ exclude: ['src/**/*.test.*', 'src/modules/i18n/locales.types.ts'],+ }));// Exclude keys that are used in dynamic contextsconst dynamicKeysMatchers = [diff --git a/packages/lecture/package.json b/packages/lecture/package.jsonindex bca60e74..b845a84c 100644--- a/packages/lecture/package.json+++ b/packages/lecture/package.json@@ -61,7 +61,6 @@"@vitest/coverage-v8": "catalog:","eslint": "catalog:","mime": "^4.0.6",- "tinyglobby": "^0.2.10","tsdown": "catalog:","typescript": "catalog:","vitest": "catalog:"diff --git a/packages/lecture/src/extractors.usecases.test.ts b/packages/lecture/src/extractors.usecases.test.tsindex 2b11d1d3..ee411e6d 100644--- a/packages/lecture/src/extractors.usecases.test.ts+++ b/packages/lecture/src/extractors.usecases.test.ts@@ -1,15 +1,17 @@-import fs from 'node:fs/promises';+import fs, { glob } from 'node:fs/promises';import { dirname, join } from 'node:path';import { fileURLToPath } from 'node:url';import mime from 'mime';-import { glob } from 'tinyglobby';import { describe, expect, test } from 'vitest';import { extractText, extractTextFromBlob, extractTextFromFile } from './extractors.usecases';const currentFile = fileURLToPath(import.meta.url);const packageRoot = join(dirname(currentFile), '..');-const fixturesDir = await glob(['fixtures/*', '!fixtures/_*'], { onlyDirectories: true, cwd: packageRoot, absolute: true });+const fixturesDir = await Array.fromAsync(+ glob('fixtures/*', { cwd: packageRoot, exclude: ['fixtures/_*'] }),+ name => join(packageRoot, name),+);describe('extractors usecases', () => {describe('extractText', () => {@@ -46,7 +48,10 @@ describe('extractors usecases', () => {// use test.concurrent to run the tests in parallel -> need to use the provided expecttest(`fixture ${fixtureName}`, { timeout: 20_000, concurrent: true }, async ({ expect }) => {- const fixtureFilesPaths = await glob(['*'], { cwd: fixtureDir, absolute: true });+ const fixtureFilesPaths = await Array.fromAsync(+ glob('*', { cwd: fixtureDir }),+ name => join(fixtureDir, name),+ );const inputFilePath = fixtureFilesPaths.find(name => name.match(/\/\d{3}\.input\.\w+$/));const configFilePath = fixtureFilesPaths.find(name => name.match(/\/\d{3}\.config\.ts$/));diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 01b788be..90820597 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -416,9 +416,6 @@ importers:eslint-plugin-solid:specifier: ^0.14.5- tinyglobby:- specifier: ^0.2.14- version: 0.2.15tsx:specifier: 'catalog:'version: 4.20.6@@ -843,9 +840,6 @@ importers:mime:specifier: ^4.0.6version: 4.0.7- tinyglobby:- specifier: ^0.2.10- version: 0.2.15tsdown:specifier: 'catalog:'version: 0.13.4([email protected])