UNPKG

rxcc

Version:

A tool to pack repository contents to single file for AI consumption

46 lines 2.39 kB
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import pc from 'picocolors'; import { logger } from '../../shared/logger.js'; import { initPiscina } from '../../shared/processConcurrency.js'; const initTaskRunner = (numOfTasks) => { const pool = initPiscina(numOfTasks, new URL('./workers/securityCheckWorker.js', import.meta.url).href); return (task) => pool.run(task); }; export const runSecurityCheck = (rawFiles_1, ...args_1) => __awaiter(void 0, [rawFiles_1, ...args_1], void 0, function* (rawFiles, progressCallback = () => { }, deps = { initTaskRunner, }) { const runTask = deps.initTaskRunner(rawFiles.length); const tasks = rawFiles.map((file) => ({ filePath: file.path, content: file.content, })); try { logger.trace(`Starting security check for ${tasks.length} files`); const startTime = process.hrtime.bigint(); let completedTasks = 0; const totalTasks = tasks.length; const results = yield Promise.all(tasks.map((task) => runTask(task).then((result) => { completedTasks++; progressCallback(`Running security check... (${completedTasks}/${totalTasks}) ${pc.dim(task.filePath)}`); logger.trace(`Running security check... (${completedTasks}/${totalTasks}) ${task.filePath}`); return result; }))); const endTime = process.hrtime.bigint(); const duration = Number(endTime - startTime) / 1e6; logger.trace(`Security check completed in ${duration.toFixed(2)}ms`); return results.filter((result) => result !== null); } catch (error) { logger.error('Error during security check:', error); throw error; } }); //# sourceMappingURL=securityCheck.js.map