diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 996498491..ed9527e26 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -133,6 +133,24 @@ jobs: env: CI_OS: ${{ runner.os }} + test-bun: + name: Test with Bun + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + bun-version: [latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/checkout@v4 + - name: Setup Bun ${{ matrix.bun-version }} + uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # ratchet:oven-sh/setup-bun@v2 + with: + bun-version: ${{ matrix.bun-version }} + - run: bun install + - run: bun run test + env: + CI_OS: ${{ runner.os }} + test-coverage: name: Test coverage runs-on: ubuntu-latest @@ -200,3 +218,29 @@ jobs: with: name: repomix-output-${{ matrix.os }}-${{ matrix.node-version }}.txt path: repomix-output.txt + + build-and-run-bun: + name: Build and run with Bun + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + bun-version: [latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/checkout@v4 + - name: Setup Bun ${{ matrix.bun-version }} + uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # ratchet:oven-sh/setup-bun@v2 + with: + bun-version: ${{ matrix.bun-version }} + - run: bun install + - run: bun run build + - name: Install only production dependencies + run: bun install --production + - run: bun bin/repomix.cjs + - run: bun bin/repomix.cjs --version + - run: bun bin/repomix.cjs --help + - name: Upload build artifact + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # ratchet:actions/upload-artifact@v4 + with: + name: repomix-output-bun-${{ matrix.os }}-${{ matrix.bun-version }}.txt + path: repomix-output.txt diff --git a/package-lock.json b/package-lock.json index 6d73f7b19..73d14980e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,9 +28,9 @@ "log-update": "^6.1.0", "minimatch": "^10.0.1", "picocolors": "^1.1.1", - "piscina": "^4.9.2", "strip-comments": "^2.0.1", "tiktoken": "^1.0.20", + "tinypool": "^1.1.1", "tree-sitter-wasms": "^0.1.12", "web-tree-sitter": "^0.24.7", "zod": "^3.24.3" @@ -53,7 +53,7 @@ "vitest": "^3.1.1" }, "engines": { - "node": ">=18.0.0", + "node": ">=20.0.0", "yarn": ">=1.22.22" } }, @@ -957,294 +957,6 @@ "node": ">=18" } }, - "node_modules/@napi-rs/nice": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@napi-rs/nice/-/nice-1.0.1.tgz", - "integrity": "sha512-zM0mVWSXE0a0h9aKACLwKmD6nHcRiKrPpCfvaKqG1CqDEyjEawId0ocXxVzPMCAm6kkWr2P025msfxXEnt8UGQ==", - "license": "MIT", - "optional": true, - "engines": { - "node": ">= 10" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/Brooooooklyn" - }, - "optionalDependencies": { - "@napi-rs/nice-android-arm-eabi": "1.0.1", - "@napi-rs/nice-android-arm64": "1.0.1", - "@napi-rs/nice-darwin-arm64": "1.0.1", - "@napi-rs/nice-darwin-x64": "1.0.1", - "@napi-rs/nice-freebsd-x64": "1.0.1", - "@napi-rs/nice-linux-arm-gnueabihf": "1.0.1", - "@napi-rs/nice-linux-arm64-gnu": "1.0.1", - "@napi-rs/nice-linux-arm64-musl": "1.0.1", - "@napi-rs/nice-linux-ppc64-gnu": "1.0.1", - "@napi-rs/nice-linux-riscv64-gnu": "1.0.1", - "@napi-rs/nice-linux-s390x-gnu": "1.0.1", - "@napi-rs/nice-linux-x64-gnu": "1.0.1", - "@napi-rs/nice-linux-x64-musl": "1.0.1", - "@napi-rs/nice-win32-arm64-msvc": "1.0.1", - "@napi-rs/nice-win32-ia32-msvc": "1.0.1", - "@napi-rs/nice-win32-x64-msvc": "1.0.1" - } - }, - "node_modules/@napi-rs/nice-android-arm-eabi": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@napi-rs/nice-android-arm-eabi/-/nice-android-arm-eabi-1.0.1.tgz", - "integrity": "sha512-5qpvOu5IGwDo7MEKVqqyAxF90I6aLj4n07OzpARdgDRfz8UbBztTByBp0RC59r3J1Ij8uzYi6jI7r5Lws7nn6w==", - "cpu": [ - "arm" - ], - "license": "MIT", - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@napi-rs/nice-android-arm64": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@napi-rs/nice-android-arm64/-/nice-android-arm64-1.0.1.tgz", - "integrity": "sha512-GqvXL0P8fZ+mQqG1g0o4AO9hJjQaeYG84FRfZaYjyJtZZZcMjXW5TwkL8Y8UApheJgyE13TQ4YNUssQaTgTyvA==", - "cpu": [ - "arm64" - ], - "license": "MIT", - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@napi-rs/nice-darwin-arm64": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@napi-rs/nice-darwin-arm64/-/nice-darwin-arm64-1.0.1.tgz", - "integrity": "sha512-91k3HEqUl2fsrz/sKkuEkscj6EAj3/eZNCLqzD2AA0TtVbkQi8nqxZCZDMkfklULmxLkMxuUdKe7RvG/T6s2AA==", - "cpu": [ - "arm64" - ], - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@napi-rs/nice-darwin-x64": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@napi-rs/nice-darwin-x64/-/nice-darwin-x64-1.0.1.tgz", - "integrity": "sha512-jXnMleYSIR/+TAN/p5u+NkCA7yidgswx5ftqzXdD5wgy/hNR92oerTXHc0jrlBisbd7DpzoaGY4cFD7Sm5GlgQ==", - "cpu": [ - "x64" - ], - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@napi-rs/nice-freebsd-x64": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@napi-rs/nice-freebsd-x64/-/nice-freebsd-x64-1.0.1.tgz", - "integrity": "sha512-j+iJ/ezONXRQsVIB/FJfwjeQXX7A2tf3gEXs4WUGFrJjpe/z2KB7sOv6zpkm08PofF36C9S7wTNuzHZ/Iiccfw==", - "cpu": [ - "x64" - ], - "license": "MIT", - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@napi-rs/nice-linux-arm-gnueabihf": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@napi-rs/nice-linux-arm-gnueabihf/-/nice-linux-arm-gnueabihf-1.0.1.tgz", - "integrity": "sha512-G8RgJ8FYXYkkSGQwywAUh84m946UTn6l03/vmEXBYNJxQJcD+I3B3k5jmjFG/OPiU8DfvxutOP8bi+F89MCV7Q==", - "cpu": [ - "arm" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@napi-rs/nice-linux-arm64-gnu": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@napi-rs/nice-linux-arm64-gnu/-/nice-linux-arm64-gnu-1.0.1.tgz", - "integrity": "sha512-IMDak59/W5JSab1oZvmNbrms3mHqcreaCeClUjwlwDr0m3BoR09ZiN8cKFBzuSlXgRdZ4PNqCYNeGQv7YMTjuA==", - "cpu": [ - "arm64" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@napi-rs/nice-linux-arm64-musl": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@napi-rs/nice-linux-arm64-musl/-/nice-linux-arm64-musl-1.0.1.tgz", - "integrity": "sha512-wG8fa2VKuWM4CfjOjjRX9YLIbysSVV1S3Kgm2Fnc67ap/soHBeYZa6AGMeR5BJAylYRjnoVOzV19Cmkco3QEPw==", - "cpu": [ - "arm64" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@napi-rs/nice-linux-ppc64-gnu": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@napi-rs/nice-linux-ppc64-gnu/-/nice-linux-ppc64-gnu-1.0.1.tgz", - "integrity": "sha512-lxQ9WrBf0IlNTCA9oS2jg/iAjQyTI6JHzABV664LLrLA/SIdD+I1i3Mjf7TsnoUbgopBcCuDztVLfJ0q9ubf6Q==", - "cpu": [ - "ppc64" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@napi-rs/nice-linux-riscv64-gnu": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@napi-rs/nice-linux-riscv64-gnu/-/nice-linux-riscv64-gnu-1.0.1.tgz", - "integrity": "sha512-3xs69dO8WSWBb13KBVex+yvxmUeEsdWexxibqskzoKaWx9AIqkMbWmE2npkazJoopPKX2ULKd8Fm9veEn0g4Ig==", - "cpu": [ - "riscv64" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@napi-rs/nice-linux-s390x-gnu": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@napi-rs/nice-linux-s390x-gnu/-/nice-linux-s390x-gnu-1.0.1.tgz", - "integrity": "sha512-lMFI3i9rlW7hgToyAzTaEybQYGbQHDrpRkg+1gJWEpH0PLAQoZ8jiY0IzakLfNWnVda1eTYYlxxFYzW8Rqczkg==", - "cpu": [ - "s390x" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@napi-rs/nice-linux-x64-gnu": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@napi-rs/nice-linux-x64-gnu/-/nice-linux-x64-gnu-1.0.1.tgz", - "integrity": "sha512-XQAJs7DRN2GpLN6Fb+ZdGFeYZDdGl2Fn3TmFlqEL5JorgWKrQGRUrpGKbgZ25UeZPILuTKJ+OowG2avN8mThBA==", - "cpu": [ - "x64" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@napi-rs/nice-linux-x64-musl": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@napi-rs/nice-linux-x64-musl/-/nice-linux-x64-musl-1.0.1.tgz", - "integrity": "sha512-/rodHpRSgiI9o1faq9SZOp/o2QkKQg7T+DK0R5AkbnI/YxvAIEHf2cngjYzLMQSQgUhxym+LFr+UGZx4vK4QdQ==", - "cpu": [ - "x64" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@napi-rs/nice-win32-arm64-msvc": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@napi-rs/nice-win32-arm64-msvc/-/nice-win32-arm64-msvc-1.0.1.tgz", - "integrity": "sha512-rEcz9vZymaCB3OqEXoHnp9YViLct8ugF+6uO5McifTedjq4QMQs3DHz35xBEGhH3gJWEsXMUbzazkz5KNM5YUg==", - "cpu": [ - "arm64" - ], - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@napi-rs/nice-win32-ia32-msvc": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@napi-rs/nice-win32-ia32-msvc/-/nice-win32-ia32-msvc-1.0.1.tgz", - "integrity": "sha512-t7eBAyPUrWL8su3gDxw9xxxqNwZzAqKo0Szv3IjVQd1GpXXVkb6vBBQUuxfIYaXMzZLwlxRQ7uzM2vdUE9ULGw==", - "cpu": [ - "ia32" - ], - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@napi-rs/nice-win32-x64-msvc": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@napi-rs/nice-win32-x64-msvc/-/nice-win32-x64-msvc-1.0.1.tgz", - "integrity": "sha512-JlF+uDcatt3St2ntBG8H02F1mM45i5SF9W+bIKiReVE6wiy3o16oBP/yxt+RZ+N6LbCImJXJ6bXNO2kn9AXicg==", - "cpu": [ - "x64" - ], - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 10" - } - }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -4216,15 +3928,6 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, - "node_modules/piscina": { - "version": "4.9.2", - "resolved": "https://registry.npmjs.org/piscina/-/piscina-4.9.2.tgz", - "integrity": "sha512-Fq0FERJWFEUpB4eSY59wSNwXD4RYqR+nR/WiEVcZW8IWfVBxJJafcgTEZDQo8k3w0sUarJ8RyVbbUF4GQ2LGbQ==", - "license": "MIT", - "optionalDependencies": { - "@napi-rs/nice": "^1.0.1" - } - }, "node_modules/pkce-challenge": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/pkce-challenge/-/pkce-challenge-5.0.0.tgz", @@ -5377,10 +5080,9 @@ "license": "MIT" }, "node_modules/tinypool": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.0.2.tgz", - "integrity": "sha512-al6n+QEANGFOMf/dmUMsuS5/r9B06uwlyNjZZql/zv8J7ybHCgoihBNORZCY2mzUuAnomQa2JdhyHKzZxPCrFA==", - "dev": true, + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.1.1.tgz", + "integrity": "sha512-Zba82s87IFq9A9XmjiX5uZA/ARWDrB03OHlq+Vw1fSdt0I+4/Kutwy8BP4Y/y/aORMo61FQ0vIb5j44vSo5Pkg==", "license": "MIT", "engines": { "node": "^18.0.0 || >=20.0.0" diff --git a/package.json b/package.json index 9c0ed2792..b3063645e 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,8 @@ }, "bin": "./bin/repomix.cjs", "scripts": { - "clean": "rimraf lib", - "build": "node --run clean && tsc -p tsconfig.build.json --sourceMap --declaration", + "build": "rimraf lib && tsc -p tsconfig.build.json --sourceMap --declaration", + "build-bun": "bun run build", "lint": "node --run lint-biome && node --run lint-ts && node --run lint-secretlint", "lint-biome": "biome check --write", "lint-ts": "tsc --noEmit", @@ -92,7 +92,7 @@ "log-update": "^6.1.0", "minimatch": "^10.0.1", "picocolors": "^1.1.1", - "piscina": "^4.9.2", + "tinypool": "^1.1.1", "strip-comments": "^2.0.1", "tiktoken": "^1.0.20", "tree-sitter-wasms": "^0.1.12", diff --git a/repomix-instruction.md b/repomix-instruction.md index 6f463a37e..eb97e1261 100644 --- a/repomix-instruction.md +++ b/repomix-instruction.md @@ -184,7 +184,7 @@ This release adds significant performance improvements for large repositories, m # Improvements ⚡ ## Parallel Processing Enhancement (#309) -- Implemented worker threads using [Piscina](https://github.com/piscinajs/piscina) for parallel processing +- Implemented worker threads using [Tinypool](https://github.com/tinylibs/tinypool) for parallel processing ### Benchmark Results - `yamadashy.repomix`: No significant change diff --git a/src/core/file/fileCollect.ts b/src/core/file/fileCollect.ts index 6135f6eb2..fe0b15341 100644 --- a/src/core/file/fileCollect.ts +++ b/src/core/file/fileCollect.ts @@ -1,13 +1,13 @@ import pc from 'picocolors'; import type { RepomixConfigMerged } from '../../config/configSchema.js'; import { logger } from '../../shared/logger.js'; -import { initPiscina } from '../../shared/processConcurrency.js'; +import { initWorker } from '../../shared/processConcurrency.js'; import type { RepomixProgressCallback } from '../../shared/types.js'; import type { RawFile } from './fileTypes.js'; import type { FileCollectTask } from './workers/fileCollectWorker.js'; const initTaskRunner = (numOfTasks: number) => { - const pool = initPiscina(numOfTasks, new URL('./workers/fileCollectWorker.js', import.meta.url).href); + const pool = initWorker(numOfTasks, new URL('./workers/fileCollectWorker.js', import.meta.url).href); return (task: FileCollectTask) => pool.run(task); }; diff --git a/src/core/file/fileProcess.ts b/src/core/file/fileProcess.ts index 9e018835b..52aa5ac61 100644 --- a/src/core/file/fileProcess.ts +++ b/src/core/file/fileProcess.ts @@ -1,7 +1,7 @@ import pc from 'picocolors'; import type { RepomixConfigMerged } from '../../config/configSchema.js'; import { logger } from '../../shared/logger.js'; -import { initPiscina } from '../../shared/processConcurrency.js'; +import { initWorker } from '../../shared/processConcurrency.js'; import type { RepomixProgressCallback } from '../../shared/types.js'; import { type FileManipulator, getFileManipulator } from './fileManipulate.js'; import type { ProcessedFile, RawFile } from './fileTypes.js'; @@ -10,7 +10,7 @@ import type { FileProcessTask } from './workers/fileProcessWorker.js'; type GetFileManipulator = (filePath: string) => FileManipulator | null; const initTaskRunner = (numOfTasks: number) => { - const pool = initPiscina(numOfTasks, new URL('./workers/fileProcessWorker.js', import.meta.url).href); + const pool = initWorker(numOfTasks, new URL('./workers/fileProcessWorker.js', import.meta.url).href); return (task: FileProcessTask) => pool.run(task); }; diff --git a/src/core/metrics/calculateAllFileMetrics.ts b/src/core/metrics/calculateAllFileMetrics.ts index fd6969679..c7ac3cffa 100644 --- a/src/core/metrics/calculateAllFileMetrics.ts +++ b/src/core/metrics/calculateAllFileMetrics.ts @@ -1,14 +1,14 @@ import pc from 'picocolors'; import type { TiktokenEncoding } from 'tiktoken'; import { logger } from '../../shared/logger.js'; -import { initPiscina } from '../../shared/processConcurrency.js'; +import { initWorker } from '../../shared/processConcurrency.js'; import type { RepomixProgressCallback } from '../../shared/types.js'; import type { ProcessedFile } from '../file/fileTypes.js'; import type { FileMetricsTask } from './workers/fileMetricsWorker.js'; import type { FileMetrics } from './workers/types.js'; const initTaskRunner = (numOfTasks: number) => { - const pool = initPiscina(numOfTasks, new URL('./workers/fileMetricsWorker.js', import.meta.url).href); + const pool = initWorker(numOfTasks, new URL('./workers/fileMetricsWorker.js', import.meta.url).href); return (task: FileMetricsTask) => pool.run(task); }; diff --git a/src/core/metrics/calculateOutputMetrics.ts b/src/core/metrics/calculateOutputMetrics.ts index 323a310ac..b40efc52a 100644 --- a/src/core/metrics/calculateOutputMetrics.ts +++ b/src/core/metrics/calculateOutputMetrics.ts @@ -1,13 +1,13 @@ import type { TiktokenEncoding } from 'tiktoken'; import { logger } from '../../shared/logger.js'; -import { initPiscina } from '../../shared/processConcurrency.js'; +import { initWorker } from '../../shared/processConcurrency.js'; import type { OutputMetricsTask } from './workers/outputMetricsWorker.js'; const CHUNK_SIZE = 1000; const MIN_CONTENT_LENGTH_FOR_PARALLEL = 1_000_000; // 1000KB const initTaskRunner = (numOfTasks: number) => { - const pool = initPiscina(numOfTasks, new URL('./workers/outputMetricsWorker.js', import.meta.url).href); + const pool = initWorker(numOfTasks, new URL('./workers/outputMetricsWorker.js', import.meta.url).href); return (task: OutputMetricsTask) => pool.run(task); }; diff --git a/src/core/security/securityCheck.ts b/src/core/security/securityCheck.ts index e785d9910..6cb888458 100644 --- a/src/core/security/securityCheck.ts +++ b/src/core/security/securityCheck.ts @@ -1,6 +1,6 @@ import pc from 'picocolors'; import { logger } from '../../shared/logger.js'; -import { initPiscina } from '../../shared/processConcurrency.js'; +import { initWorker } from '../../shared/processConcurrency.js'; import type { RepomixProgressCallback } from '../../shared/types.js'; import type { RawFile } from '../file/fileTypes.js'; import type { GitDiffResult } from '../git/gitDiffHandle.js'; @@ -13,7 +13,7 @@ export interface SuspiciousFileResult { } const initTaskRunner = (numOfTasks: number) => { - const pool = initPiscina(numOfTasks, new URL('./workers/securityCheckWorker.js', import.meta.url).href); + const pool = initWorker(numOfTasks, new URL('./workers/securityCheckWorker.js', import.meta.url).href); return (task: SecurityCheckTask) => pool.run(task); }; diff --git a/src/shared/processConcurrency.ts b/src/shared/processConcurrency.ts index 29a3b615e..b31d36f87 100644 --- a/src/shared/processConcurrency.ts +++ b/src/shared/processConcurrency.ts @@ -1,5 +1,5 @@ import os from 'node:os'; -import { Piscina } from 'piscina'; +import { Tinypool } from 'tinypool'; import { logger } from './logger.js'; export const getProcessConcurrency = (): number => { @@ -20,14 +20,14 @@ export const getWorkerThreadCount = (numOfTasks: number): { minThreads: number; }; }; -export const initPiscina = (numOfTasks: number, workerPath: string): Piscina => { +export const initWorker = (numOfTasks: number, workerPath: string): Tinypool => { const { minThreads, maxThreads } = getWorkerThreadCount(numOfTasks); logger.trace( `Initializing worker pool with min=${minThreads}, max=${maxThreads} threads. Worker path: ${workerPath}`, ); - return new Piscina({ + return new Tinypool({ filename: workerPath, minThreads, maxThreads, diff --git a/tests/core/security/securityCheck.test.ts b/tests/core/security/securityCheck.test.ts index df4b8e321..651a4cfc1 100644 --- a/tests/core/security/securityCheck.test.ts +++ b/tests/core/security/securityCheck.test.ts @@ -12,7 +12,7 @@ import { repomixLogLevels } from '../../../src/shared/logger.js'; vi.mock('../../../src/shared/logger'); vi.mock('../../../src/shared/processConcurrency', () => ({ - initPiscina: vi.fn(() => ({ + initWorker: vi.fn(() => ({ run: vi.fn().mockImplementation(async (task: SecurityCheckTask) => { return await securityCheckWorker(task); }), diff --git a/tests/shared/processConcurrency.test.ts b/tests/shared/processConcurrency.test.ts index fe2cf3254..50c635a6f 100644 --- a/tests/shared/processConcurrency.test.ts +++ b/tests/shared/processConcurrency.test.ts @@ -1,10 +1,10 @@ import os from 'node:os'; -import { Piscina } from 'piscina'; +import { Tinypool } from 'tinypool'; import { beforeEach, describe, expect, it, vi } from 'vitest'; -import { getProcessConcurrency, getWorkerThreadCount, initPiscina } from '../../src/shared/processConcurrency.js'; +import { getProcessConcurrency, getWorkerThreadCount, initWorker } from '../../src/shared/processConcurrency.js'; vi.mock('node:os'); -vi.mock('piscina'); +vi.mock('tinypool'); describe('processConcurrency', () => { describe('getProcessConcurrency', () => { @@ -60,17 +60,17 @@ describe('processConcurrency', () => { }); }); - describe('initPiscina', () => { + describe('initWorker', () => { beforeEach(() => { vi.mocked(os).availableParallelism = vi.fn().mockReturnValue(4); - vi.mocked(Piscina).mockImplementation(() => ({}) as Piscina); + vi.mocked(Tinypool).mockImplementation(() => ({}) as Tinypool); }); - it('should initialize Piscina with correct configuration', () => { + it('should initialize Tinypool with correct configuration', () => { const workerPath = '/path/to/worker.js'; - const piscina = initPiscina(500, workerPath); + const tinypool = initWorker(500, workerPath); - expect(Piscina).toHaveBeenCalledWith({ + expect(Tinypool).toHaveBeenCalledWith({ filename: workerPath, minThreads: 1, maxThreads: 4, @@ -80,7 +80,7 @@ describe('processConcurrency', () => { REPOMIX_LOGLEVEL: '2', }), }); - expect(piscina).toBeDefined(); + expect(tinypool).toBeDefined(); }); }); });