Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/Aquaticat/Monochromatic. TypeScript and Rust monorepo: Claude Code and Pi coding-agent plugins, a m
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129#!/usr/bin/env node
/** Host CLI entrypoint for the yuku-based mutation tester. @example ```bash mutation-test --package package/module/fs-path mutation-test --package package/module/fs-path --dry-run src/trim.ts ``` */
import { writeFile, } from 'node:fs/promises';import { join, } from 'node:path';import { cwd, } from 'node:process';
import { tagged, } from '@monochromatic-dev/module-logger/ts';
import { parseCliOptions, type CliOptions,} from './host/cli-options.ts';import { enumeratePackage, } from './host/enumerate-package.ts';import { orchestrateRun, } from './host/orchestrate.ts';import { buildRunReport, formatTerminalSummary,} from './host/report.ts';
/** Module logger for the CLI entrypoint. */const l = tagged({ tag: 'mutation-test', },);
/** Runs the CLI flow for parsed options. @param options - Parsed CLI options. @throws Error on infra failure (red baseline, unresolved mutants). @mutates options - `JSON.stringify` may invoke hooks on report data derived from options. @example ```ts await runCli(parseCliOptions(['--package', 'package/module/fs-path'])); ``` */export async function runCli(options: CliOptions,): Promise<void> { /** Logger scoped to this invocation. */ const rl = tagged({ tag: runCli.name, l, },);
if (options.dryRun) { /** Enumeration-only view for the dry run. */ const { groups, ignored, } = await enumeratePackage(options,);
for (const group of groups) { // Raw console: user-facing CLI summary output. console.log( `${group.file}: ${String(group.mutants .length,)} mutants, tests: ${ group.tests .join(', ',) }`, ); }
console.log(`Ignored by suppression: ${String(ignored.length,)}`,); return; }
/** Full orchestration outcome. */ const outcome = await orchestrateRun(options,); /** Native JSON run report. */ const report = buildRunReport({ outcome, packagePath: options.packagePath, },); /** Report destination, defaulting beside the current directory. */ const reportFile = options.reportFile === '' ? join( cwd(), 'mutation-report.json', ) : options.reportFile; await writeFile( reportFile, `${JSON.stringify( report, null, 2, )}\n`, 'utf8', ); rl.info(`report written to ${reportFile}`,);
// Raw console: user-facing CLI summary output. console.log(formatTerminalSummary(report,),);
if (report.infraErrors .length > 0) throw new Error( `${String(report.infraErrors .length,)} infrastructure errors; see report ${reportFile}`, );}
await runCli( parseCliOptions(process.argv .slice(2,),),);