@andy2639/jest-context 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/LICENSE +21 -0
- package/README.md +35 -0
- package/dist/bin/console-context.cjs +685 -0
- package/dist/bin/console-context.cjs.map +1 -0
- package/dist/bin/console-context.d.mts +1 -0
- package/dist/bin/console-context.d.ts +1 -0
- package/dist/bin/console-context.mjs +12 -0
- package/dist/bin/console-context.mjs.map +1 -0
- package/dist/bin/coverage-context.cjs +496 -0
- package/dist/bin/coverage-context.cjs.map +1 -0
- package/dist/bin/coverage-context.d.mts +1 -0
- package/dist/bin/coverage-context.d.ts +1 -0
- package/dist/bin/coverage-context.mjs +12 -0
- package/dist/bin/coverage-context.mjs.map +1 -0
- package/dist/bin/test-context.cjs +585 -0
- package/dist/bin/test-context.cjs.map +1 -0
- package/dist/bin/test-context.d.mts +1 -0
- package/dist/bin/test-context.d.ts +1 -0
- package/dist/bin/test-context.mjs +12 -0
- package/dist/bin/test-context.mjs.map +1 -0
- package/dist/chunk-DEJBEL4M.mjs +168 -0
- package/dist/chunk-DEJBEL4M.mjs.map +1 -0
- package/dist/chunk-DUQBPBV4.mjs +252 -0
- package/dist/chunk-DUQBPBV4.mjs.map +1 -0
- package/dist/chunk-WPFTKCAT.mjs +169 -0
- package/dist/chunk-WPFTKCAT.mjs.map +1 -0
- package/dist/chunk-YTFA3KPD.mjs +513 -0
- package/dist/chunk-YTFA3KPD.mjs.map +1 -0
- package/dist/index.cjs +1112 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +141 -0
- package/dist/index.d.ts +141 -0
- package/dist/index.mjs +99 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/commands/coverage-context.ts","../../src/core/constants.ts","../../src/core/platform.ts","../../src/core/package-manager.ts","../../src/core/exec.ts","../../src/core/jest.ts","../../src/core/export.ts","../../src/core/cli.ts","../../src/core/ui.ts","../../src/bin/coverage-context.ts"],"sourcesContent":["import path from \"node:path\";\n\nimport {\n createProgressBar,\n displayBanner,\n displayHelp,\n exitWithError,\n handleExportOrDisplay,\n JEST_PATTERNS,\n parseExportCliArgs,\n runJest,\n shouldShowUI,\n validateCliArgs,\n logWarning,\n} from \"../core\";\n\nfunction parseCoverage(text: string) {\n const lines = text.split(\"\\n\");\n const rows: Array<{\n folder: string;\n file: string;\n stmts: number;\n branch: number;\n funcs: number;\n lines: number;\n uncovered?: string;\n }> = [];\n\n let currentFolder: string | null = null;\n\n for (const line of lines) {\n const match = line.match(JEST_PATTERNS.COVERAGE_LINE);\n if (!match) continue;\n\n const [, rawFile, stmts, branch, funcs, linesPct, uncovered] = match;\n const normalized = rawFile.trim();\n\n if (normalized === \"All files\") continue;\n\n const isFile = /\\.(ts|tsx)$/.test(normalized);\n if (!isFile) {\n currentFolder = normalized;\n continue;\n }\n\n if (/index\\.(ts|tsx)$/.test(normalized)) continue;\n if (!currentFolder) currentFolder = path.dirname(normalized);\n\n rows.push({\n folder: currentFolder,\n file: path.basename(normalized),\n stmts: Number(stmts),\n branch: Number(branch),\n funcs: Number(funcs),\n lines: Number(linesPct),\n uncovered: uncovered?.trim(),\n });\n }\n\n return rows;\n}\n\nfunction filterIncomplete(rows: ReturnType<typeof parseCoverage>, threshold = 100) {\n return rows.filter(\n (r) => !(r.stmts >= threshold && r.branch >= threshold && r.funcs >= threshold && r.lines >= threshold)\n );\n}\n\nfunction groupByFolder(rows: ReturnType<typeof parseCoverage>) {\n const grouped: Record<string, Array<{ file: string; coverage: Omit<(typeof rows)[number], \"folder\" | \"file\"> }>> = {};\n\n for (const row of rows) {\n const { folder, file, ...rest } = row;\n if (!grouped[folder]) grouped[folder] = [];\n grouped[folder].push({ file, coverage: rest });\n }\n\n return grouped;\n}\n\nfunction formatCoverageOutput(grouped: ReturnType<typeof groupByFolder>): string {\n let output = \"\";\n\n for (const folder of Object.keys(grouped)) {\n output += `đ Folder: ${folder}\\n`;\n\n for (const item of grouped[folder]) {\n const { file, coverage } = item;\n output += ` đ File: ${file}\\n`;\n output += `- Coverage:\\n`;\n output += ` - Stmts: ${coverage.stmts}\\n`;\n output += ` - Branch: ${coverage.branch}\\n`;\n output += ` - Funcs: ${coverage.funcs}\\n`;\n output += ` - Lines: ${coverage.lines}\\n`;\n output += ` - Uncovered: ${coverage.uncovered || \"N/A\"}\\n\\n`;\n }\n\n output += \"\\n\";\n }\n\n return output.trim();\n}\n\nexport async function runCoverageContext(argv = process.argv.slice(2)): Promise<void> {\n if (argv.includes(\"-h\") || argv.includes(\"--help\")) {\n displayHelp(\"Coverage Context Script\", {\n description: \"Run Jest coverage and print files below threshold.\",\n usage: [\"coverage-context\", \"coverage-context --threshold=90\"],\n options: [\n \"--threshold=0..100 Minimum percentage for stmts/branch/funcs/lines (default: 100)\",\n \"--export Export output as txt\",\n \"--export=txt|md Export output in selected format\",\n \"--no-banner Disable fancy terminal UI\",\n \"-h, --help Show this help\",\n ],\n examples: [\"coverage-context --threshold=90 --export=md\"],\n });\n }\n\n const noBanner = argv.includes(\"--no-banner\");\n const args = argv.filter((arg) => arg !== \"--no-banner\");\n\n const { exportFormat, exportArgs } = parseExportCliArgs(args);\n const { parsed, unknownArgs } = validateCliArgs(args, {\n threshold: {\n prefix: \"--threshold=\",\n allowedValues: Array.from({ length: 101 }, (_, i) => String(i)),\n },\n });\n\n const exportArgSet = new Set(exportArgs);\n const filteredUnknownArgs = unknownArgs.filter((arg) => !exportArgSet.has(arg));\n if (filteredUnknownArgs.length > 0) {\n logWarning(`Unknown arguments ignored: ${filteredUnknownArgs.join(\", \")}`);\n }\n\n const threshold = parsed.threshold ? Number(parsed.threshold) : 100;\n const showUI = shouldShowUI(exportFormat, noBanner);\n\n if (showUI) {\n displayBanner({\n text: \"COVERAGE\",\n info: {\n Threshold: `>=${threshold}%`,\n },\n colors: [\"magenta\", \"blue\"],\n });\n }\n\n const bar = showUI ? createProgressBar(100, \"Running coverage\") : null;\n bar?.update(10, { status: \"Running Jest...\" });\n\n const result = await runJest([], {\n coverage: true,\n coverageReporters: [\"text\", \"text-summary\"],\n ignoreErrors: true,\n });\n\n bar?.update(70, { status: \"Parsing output...\" });\n\n const rows = parseCoverage(result.output);\n if (rows.length === 0) {\n bar?.update(100, { status: \"Done\" });\n bar?.stop();\n\n handleExportOrDisplay(\"No coverage rows parsed from Jest output.\", {\n exportFormat,\n prefix: \"export-coverage-context\",\n title: \"Coverage Context\",\n });\n\n return;\n }\n\n const incomplete = filterIncomplete(rows, threshold);\n const grouped = groupByFolder(incomplete);\n\n bar?.update(100, { status: \"Done\" });\n bar?.stop();\n\n if (Object.keys(grouped).length === 0) {\n handleExportOrDisplay(`All files meet threshold >= ${threshold}%`, {\n exportFormat,\n prefix: \"export-coverage-context\",\n title: \"Coverage Context\",\n });\n\n return;\n }\n\n const formatted = formatCoverageOutput(grouped);\n handleExportOrDisplay(formatted, {\n exportFormat,\n prefix: \"export-coverage-context\",\n title: \"Coverage Context\",\n });\n}\n","export const VALID_MODES = [\"--all\", \"--related\", \"--tests\"] as const;\n\nexport const VALID_EXPORT_FORMATS = [\"txt\", \"md\"] as const;\n\nexport const VALID_TEST_EXTENSIONS = /\\.(test|spec)\\.(ts|tsx|js|jsx)$/;\n\nexport const CONSOLE_LOG_TYPES = {\n ERROR: \"console.error\",\n WARN: \"console.warn\",\n LOG: \"console.log\",\n DEBUG: \"console.debug\",\n} as const;\n\nexport const JEST_PATTERNS = {\n FAIL_LINE: /^FAIL\\s+/,\n PASS_LINE: /^PASS\\s+/,\n TEST_FILE: /^(PASS|FAIL)\\s+(.+\\.(test|spec)\\.tsx?)/,\n COVERAGE_LINE:\n /^(.+?)\\s+\\|\\s+([\\d.]+)\\s+\\|\\s+([\\d.]+)\\s+\\|\\s+([\\d.]+)\\s+\\|\\s+([\\d.]+)(?:\\s+\\|\\s+(.+))?$/,\n BULLET_POINT: /^â\\s+/,\n CODE_LINE: /^>?\\s*\\d*\\s*\\|/,\n STACK_TRACE: /^\\s+at\\s+/,\n};\n","export function getPlatform(): NodeJS.Platform {\n return process.platform;\n}\n\nexport function isWindows(): boolean {\n return process.platform === \"win32\";\n}\n\nexport function isMac(): boolean {\n return process.platform === \"darwin\";\n}\n\nexport function isLinux(): boolean {\n return process.platform === \"linux\";\n}\n\nexport function resolveCommand(cmd: string): string {\n if (!isWindows()) return cmd;\n\n const windowsCommands: Record<string, string> = {\n git: \"git.exe\",\n node: \"node.exe\",\n npm: \"npm.cmd\",\n npx: \"npx.cmd\",\n yarn: \"yarn.cmd\",\n pnpm: \"pnpm.cmd\",\n };\n\n return windowsCommands[cmd] ?? cmd;\n}\n","export type PackageManager = \"npm\" | \"yarn\" | \"pnpm\";\n\nexport function detectPackageManager(): PackageManager {\n if (process.env.npm_execpath?.includes(\"yarn\")) return \"yarn\";\n if (process.env.npm_execpath?.includes(\"pnpm\")) return \"pnpm\";\n\n return \"npm\";\n}\n\nexport function getJestCommand(packageManager: PackageManager | null = null): [string, string] {\n const pm = packageManager ?? detectPackageManager();\n\n switch (pm) {\n case \"yarn\":\n return [\"yarn\", \"jest\"];\n case \"pnpm\":\n return [\"pnpm\", \"jest\"];\n default:\n return [\"npx\", \"jest\"];\n }\n}\n","import { spawn } from \"node:child_process\";\n\nimport { resolveCommand } from \"./platform\";\nimport type { ExecResult } from \"../types\";\n\nexport async function execCommand(\n cmd: string,\n args: string[] = [],\n options: { shell?: boolean; ignoreErrors?: boolean } = {}\n): Promise<ExecResult> {\n return new Promise((resolve, reject) => {\n const resolvedCmd = resolveCommand(cmd);\n const child = spawn(resolvedCmd, args, {\n shell: options.shell ?? process.platform === \"win32\",\n });\n\n let stdout = \"\";\n let stderr = \"\";\n\n child.stdout?.on(\"data\", (d) => {\n stdout += d.toString();\n });\n\n child.stderr?.on(\"data\", (d) => {\n stderr += d.toString();\n });\n\n child.on(\"close\", (code) => {\n const result: ExecResult = {\n stdout,\n stderr,\n output: `${stdout}\\n${stderr}`,\n code,\n };\n\n if (code !== 0 && !options.ignoreErrors) {\n reject(new Error(`Command failed with code ${code}: ${cmd} ${args.join(\" \")}`));\n return;\n }\n\n resolve(result);\n });\n\n child.on(\"error\", (error) => {\n reject(new Error(`Failed to execute command: ${error.message}`));\n });\n });\n}\n","import { spawn } from \"node:child_process\";\n\nimport { getJestCommand, type PackageManager } from \"./package-manager\";\nimport { isWindows } from \"./platform\";\nimport { filterTestFiles, getStagedFiles } from \"./git\";\nimport type { ExecutionMode, ExecResult, RunJestOptions } from \"../types\";\n\nexport async function runJest(args: string[] = [], options: RunJestOptions = {}): Promise<ExecResult> {\n const {\n verbose = false,\n coverage = false,\n packageManager = null,\n ignoreErrors = true,\n disableVerbose = false,\n } = options;\n\n const jestCmd = getJestCommand(packageManager as PackageManager | null);\n const jestArgs = [...jestCmd.slice(1)];\n\n if (verbose && !disableVerbose) {\n jestArgs.push(\"--verbose\");\n }\n\n if (coverage) {\n jestArgs.push(\"--coverage\");\n\n if (options.coverageReporters) {\n for (const reporter of options.coverageReporters) {\n jestArgs.push(`--coverageReporters=${reporter}`);\n }\n }\n }\n\n if (isWindows()) {\n jestArgs.push(\"--no-watchman\");\n }\n\n jestArgs.push(...args);\n\n return new Promise((resolve, reject) => {\n const child = spawn(jestCmd[0], jestArgs, {\n shell: isWindows(),\n });\n\n let stdout = \"\";\n let stderr = \"\";\n\n child.stdout.on(\"data\", (d) => {\n stdout += d.toString();\n });\n\n child.stderr.on(\"data\", (d) => {\n stderr += d.toString();\n });\n\n child.on(\"close\", (code) => {\n const result: ExecResult = {\n stdout,\n stderr,\n output: `${stdout}\\n${stderr}`,\n code,\n };\n\n if (code !== 0 && !ignoreErrors) {\n reject(new Error(`Jest failed with code ${code}`));\n return;\n }\n\n resolve(result);\n });\n\n child.on(\"error\", reject);\n });\n}\n\nexport async function buildJestArgsForMode(mode: ExecutionMode): Promise<string[]> {\n if (mode === \"all\") {\n return [];\n }\n\n const staged = await getStagedFiles();\n if (staged.length === 0) {\n throw new Error(`No staged files found for mode: ${mode}`);\n }\n\n if (mode === \"tests\") {\n const testFiles = filterTestFiles(staged);\n if (testFiles.length === 0) {\n throw new Error(\"No test files found in staged files\");\n }\n\n return testFiles;\n }\n\n return [\"--findRelatedTests\", ...staged];\n}\n","import { writeFileSync } from \"node:fs\";\nimport path from \"node:path\";\n\nimport { VALID_EXPORT_FORMATS } from \"./constants\";\nimport type { ExportFormat, OutputOptions } from \"../types\";\n\nexport function getDisplayTimestamp(locale = \"en-US\"): string {\n return new Date().toLocaleString(locale, {\n year: \"numeric\",\n month: \"2-digit\",\n day: \"2-digit\",\n hour: \"2-digit\",\n minute: \"2-digit\",\n second: \"2-digit\",\n hour12: false,\n });\n}\n\nexport function getFilenameTimestamp(): string {\n const now = new Date();\n const pad = (value: number) => String(value).padStart(2, \"0\");\n\n return (\n [now.getFullYear(), pad(now.getMonth() + 1), pad(now.getDate())].join(\"-\") +\n \"_\" +\n [pad(now.getHours()), pad(now.getMinutes()), pad(now.getSeconds())].join(\"-\")\n );\n}\n\nexport function buildTimestampedPath(prefix: string, extension: string, dir = process.cwd()): string {\n const timestamp = getFilenameTimestamp();\n const filename = `${prefix}-${timestamp}.${extension}`;\n\n return path.resolve(dir, filename);\n}\n\nexport function formatAsMarkdown(content: string, title: string, timestamp: string | null = null): string {\n const lines = [`# ${title}`, \"\"];\n\n if (timestamp) {\n lines.push(`Generated: ${timestamp}`, \"\");\n }\n\n lines.push(\"```text\", content.trimEnd(), \"```\", \"\");\n\n return lines.join(\"\\n\");\n}\n\nexport function exportToFile(\n content: string,\n options: { prefix: string; format: ExportFormat; title?: string; dir?: string }\n): string {\n const { prefix, format, title, dir = process.cwd() } = options;\n const filePath = buildTimestampedPath(prefix, format, dir);\n\n let finalContent = content;\n if (format === \"md\" && title) {\n finalContent = formatAsMarkdown(content, title, getDisplayTimestamp());\n }\n\n writeFileSync(filePath, finalContent, \"utf-8\");\n\n return filePath;\n}\n\nexport function parseExportCliArgs(args: string[]): { exportFormat: ExportFormat | null; exportArgs: string[] } {\n let exportFormat: ExportFormat | null = null;\n const exportArgs: string[] = [];\n\n for (const arg of args) {\n if (arg === \"--export\") {\n exportFormat = \"txt\";\n exportArgs.push(arg);\n continue;\n }\n\n if (!arg.startsWith(\"--export=\")) {\n continue;\n }\n\n const value = arg.slice(\"--export=\".length).trim().toLowerCase();\n if (!value || !VALID_EXPORT_FORMATS.includes(value as ExportFormat)) {\n throw new Error(`Invalid value for --export: ${value || \"(empty)\"}. Valid values: txt, md`);\n }\n\n exportFormat = value as ExportFormat;\n exportArgs.push(arg);\n }\n\n return { exportFormat, exportArgs };\n}\n\nexport function handleExportOrDisplay(content: string, config: OutputOptions): string | null {\n const { exportFormat, prefix, title } = config;\n\n if (!exportFormat) {\n console.log(content);\n\n return null;\n }\n\n const outputPath = exportToFile(content, {\n prefix,\n format: exportFormat,\n title,\n });\n\n console.log(`Output exported to: ${outputPath}`);\n\n return outputPath;\n}\n","type SchemaEntry = {\n values?: string[];\n default?: string;\n exclusive?: boolean;\n prefix?: string;\n allowedValues?: string[];\n};\n\nexport function validateCliArgs(\n args: string[],\n schema: Record<string, SchemaEntry>\n): { parsed: Record<string, string | undefined>; unknownArgs: string[] } {\n const parsed: Record<string, string | undefined> = {};\n const unknownArgs: string[] = [];\n\n for (const [key, config] of Object.entries(schema)) {\n if (config.default !== undefined) {\n parsed[key] = config.default;\n }\n }\n\n for (const arg of args) {\n let matched = false;\n\n for (const [key, config] of Object.entries(schema)) {\n if (config.values?.includes(arg)) {\n if (config.exclusive && parsed[key] !== undefined && parsed[key] !== config.default) {\n throw new Error(`Multiple values provided for ${key}: ${parsed[key]} and ${arg}`);\n }\n\n parsed[key] = arg;\n matched = true;\n break;\n }\n\n if (config.prefix && arg.startsWith(config.prefix)) {\n const value = arg.slice(config.prefix.length).trim().toLowerCase();\n\n if (!value) {\n parsed[key] = \"true\";\n matched = true;\n break;\n }\n\n if (config.allowedValues && !config.allowedValues.includes(value)) {\n throw new Error(\n `Invalid value for ${config.prefix}: ${value}. Valid values: ${config.allowedValues.join(\", \")}`\n );\n }\n\n parsed[key] = value;\n matched = true;\n break;\n }\n }\n\n if (!matched && arg.startsWith(\"--\")) {\n unknownArgs.push(arg);\n }\n }\n\n return { parsed, unknownArgs };\n}\n\nexport function displayHelp(\n title: string,\n content: { description?: string; usage?: string[]; options?: string[]; examples?: string[] }\n): never {\n console.log(`\\n${title}\\n`);\n\n if (content.description) {\n console.log(`${content.description}\\n`);\n }\n\n if (content.usage?.length) {\n console.log(\"Usage:\");\n content.usage.forEach((line) => console.log(` ${line}`));\n console.log(\"\");\n }\n\n if (content.options?.length) {\n console.log(\"Options:\");\n content.options.forEach((line) => console.log(` ${line}`));\n console.log(\"\");\n }\n\n if (content.examples?.length) {\n console.log(\"Examples:\");\n content.examples.forEach((line) => console.log(` ${line}`));\n console.log(\"\");\n }\n\n process.exit(0);\n}\n\nexport function exitWithError(message: string, code = 1): never {\n console.error(`â ${message}`);\n process.exit(code);\n}\n\nexport function logWarning(message: string): void {\n console.warn(`â ī¸ ${message}`);\n}\n\nexport function logInfo(message: string): void {\n console.log(`âšī¸ ${message}`);\n}\n\nexport function logSuccess(message: string): void {\n console.log(`â
${message}`);\n}\n","import { getDisplayTimestamp } from \"./export\";\n\ntype Spinner = {\n start: () => Spinner;\n stop: () => Spinner;\n succeed: (message?: string) => Spinner;\n warn: (message?: string) => Spinner;\n fail: (message?: string) => Spinner;\n};\n\ntype ProgressBar = {\n update: (value: number, payload?: Record<string, string>) => void;\n stop: () => void;\n};\n\nexport function shouldShowUI(exportMode: string | null, noBanner = false): boolean {\n return !exportMode && !noBanner && Boolean(process.stdout.isTTY);\n}\n\nexport function displayBanner(config: {\n text: string;\n subtitle?: string;\n info?: Record<string, string>;\n colors?: string[];\n font?: string;\n}): void {\n const { text, subtitle, info = {}, colors = [\"cyan\"], font = \"block\" } = config;\n const bannerText = [text, subtitle].filter(Boolean).join(\" \").trim();\n\n // Lazy load to avoid breaking non-interactive execution.\n const cfonts = require(\"cfonts\") as {\n render: (message: string, options: Record<string, unknown>) => { string: string };\n };\n const boxenModule = require(\"boxen\") as\n | ((text: string, options: Record<string, unknown>) => string)\n | { default: (text: string, options: Record<string, unknown>) => string };\n const boxen = typeof boxenModule === \"function\" ? boxenModule : boxenModule.default;\n\n const renderedBanner = cfonts.render(bannerText, {\n font,\n colors,\n align: \"left\",\n background: \"transparent\",\n letterSpacing: 1,\n lineHeight: 1,\n space: false,\n maxLength: \"0\",\n env: \"node\",\n });\n\n const infoLine = Object.entries(info)\n .map(([key, value]) => `${key}: ${value}`)\n .join(\" | \");\n\n const contentLines = [renderedBanner.string.trimEnd()];\n if (infoLine) {\n contentLines.push(\"\", ` ${infoLine}`);\n }\n contentLines.push(` Date: ${getDisplayTimestamp()}`);\n\n const boxed = boxen(contentLines.join(\"\\n\"), {\n padding: {\n top: 0,\n right: 1,\n bottom: 0,\n left: 1,\n },\n margin: {\n top: 0,\n right: 0,\n bottom: 1,\n left: 0,\n },\n borderStyle: \"round\",\n borderColor: colors[0] ?? \"cyan\",\n });\n\n console.log(boxed);\n}\n\nexport function createSpinner(text: string, color: string = \"cyan\"): Spinner {\n const ora = require(\"ora\") as (config: Record<string, unknown>) => Spinner;\n\n return ora({ text, color, spinner: \"dots\" });\n}\n\nexport function createProgressBar(total = 100, task = \"Progress\"): ProgressBar {\n const cliProgress = require(\"cli-progress\") as {\n SingleBar: new (options: Record<string, unknown>, preset: unknown) => {\n start: (maxValue: number, startValue: number, payload?: Record<string, string>) => void;\n update: (value: number, payload?: Record<string, string>) => void;\n stop: () => void;\n };\n Presets: {\n shades_classic: unknown;\n };\n };\n\n const bar = new cliProgress.SingleBar(\n {\n format: \"{task} [{bar}] {percentage}% | {status}\",\n barCompleteChar: \"â\",\n barIncompleteChar: \"â\",\n hideCursor: true,\n barsize: 24,\n },\n cliProgress.Presets.shades_classic\n );\n\n bar.start(total, 0, {\n task,\n status: \"Starting...\",\n });\n\n return {\n update: (value: number, payload?: Record<string, string>) => bar.update(value, payload),\n stop: () => bar.stop(),\n };\n}\n","#!/usr/bin/env node\n\nimport { runCoverageContext } from \"../commands/coverage-context\";\n\nrunCoverageContext().catch((error) => {\n console.error(`â ${(error as Error).message}`);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,oBAAiB;;;ACEV,IAAM,uBAAuB,CAAC,OAAO,IAAI;AAWzC,IAAM,gBAAgB;AAAA,EAC3B,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,eACE;AAAA,EACF,cAAc;AAAA,EACd,WAAW;AAAA,EACX,aAAa;AACf;;;AClBO,SAAS,YAAqB;AACnC,SAAO,QAAQ,aAAa;AAC9B;;;ACJO,SAAS,uBAAuC;AACrD,MAAI,QAAQ,IAAI,cAAc,SAAS,MAAM,EAAG,QAAO;AACvD,MAAI,QAAQ,IAAI,cAAc,SAAS,MAAM,EAAG,QAAO;AAEvD,SAAO;AACT;AAEO,SAAS,eAAe,iBAAwC,MAAwB;AAC7F,QAAM,KAAK,kBAAkB,qBAAqB;AAElD,UAAQ,IAAI;AAAA,IACV,KAAK;AACH,aAAO,CAAC,QAAQ,MAAM;AAAA,IACxB,KAAK;AACH,aAAO,CAAC,QAAQ,MAAM;AAAA,IACxB;AACE,aAAO,CAAC,OAAO,MAAM;AAAA,EACzB;AACF;;;ACpBA,gCAAsB;;;ACAtB,IAAAC,6BAAsB;AAOtB,eAAsB,QAAQ,OAAiB,CAAC,GAAG,UAA0B,CAAC,GAAwB;AACpG,QAAM;AAAA,IACJ,UAAU;AAAA,IACV,WAAW;AAAA,IACX,iBAAiB;AAAA,IACjB,eAAe;AAAA,IACf,iBAAiB;AAAA,EACnB,IAAI;AAEJ,QAAM,UAAU,eAAe,cAAuC;AACtE,QAAM,WAAW,CAAC,GAAG,QAAQ,MAAM,CAAC,CAAC;AAErC,MAAI,WAAW,CAAC,gBAAgB;AAC9B,aA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 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
runCoverageContext
|
|
4
|
+
} from "../chunk-DEJBEL4M.mjs";
|
|
5
|
+
import "../chunk-YTFA3KPD.mjs";
|
|
6
|
+
|
|
7
|
+
// src/bin/coverage-context.ts
|
|
8
|
+
runCoverageContext().catch((error) => {
|
|
9
|
+
console.error(`\u274C ${error.message}`);
|
|
10
|
+
process.exit(1);
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=coverage-context.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/bin/coverage-context.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { runCoverageContext } from \"../commands/coverage-context\";\n\nrunCoverageContext().catch((error) => {\n console.error(`â ${(error as Error).message}`);\n process.exit(1);\n});\n"],"mappings":";;;;;;;AAIA,mBAAmB,EAAE,MAAM,CAAC,UAAU;AACpC,UAAQ,MAAM,UAAM,MAAgB,OAAO,EAAE;AAC7C,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}
|
|
@@ -0,0 +1,585 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
25
|
+
|
|
26
|
+
// src/core/constants.ts
|
|
27
|
+
var VALID_MODES = ["--all", "--related", "--tests"];
|
|
28
|
+
var VALID_EXPORT_FORMATS = ["txt", "md"];
|
|
29
|
+
var VALID_TEST_EXTENSIONS = /\.(test|spec)\.(ts|tsx|js|jsx)$/;
|
|
30
|
+
var JEST_PATTERNS = {
|
|
31
|
+
FAIL_LINE: /^FAIL\s+/,
|
|
32
|
+
PASS_LINE: /^PASS\s+/,
|
|
33
|
+
TEST_FILE: /^(PASS|FAIL)\s+(.+\.(test|spec)\.tsx?)/,
|
|
34
|
+
COVERAGE_LINE: /^(.+?)\s+\|\s+([\d.]+)\s+\|\s+([\d.]+)\s+\|\s+([\d.]+)\s+\|\s+([\d.]+)(?:\s+\|\s+(.+))?$/,
|
|
35
|
+
BULLET_POINT: /^â\s+/,
|
|
36
|
+
CODE_LINE: /^>?\s*\d*\s*\|/,
|
|
37
|
+
STACK_TRACE: /^\s+at\s+/
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// src/core/platform.ts
|
|
41
|
+
function isWindows() {
|
|
42
|
+
return process.platform === "win32";
|
|
43
|
+
}
|
|
44
|
+
function resolveCommand(cmd) {
|
|
45
|
+
if (!isWindows()) return cmd;
|
|
46
|
+
const windowsCommands = {
|
|
47
|
+
git: "git.exe",
|
|
48
|
+
node: "node.exe",
|
|
49
|
+
npm: "npm.cmd",
|
|
50
|
+
npx: "npx.cmd",
|
|
51
|
+
yarn: "yarn.cmd",
|
|
52
|
+
pnpm: "pnpm.cmd"
|
|
53
|
+
};
|
|
54
|
+
return windowsCommands[cmd] ?? cmd;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// src/core/package-manager.ts
|
|
58
|
+
function detectPackageManager() {
|
|
59
|
+
if (process.env.npm_execpath?.includes("yarn")) return "yarn";
|
|
60
|
+
if (process.env.npm_execpath?.includes("pnpm")) return "pnpm";
|
|
61
|
+
return "npm";
|
|
62
|
+
}
|
|
63
|
+
function getJestCommand(packageManager = null) {
|
|
64
|
+
const pm = packageManager ?? detectPackageManager();
|
|
65
|
+
switch (pm) {
|
|
66
|
+
case "yarn":
|
|
67
|
+
return ["yarn", "jest"];
|
|
68
|
+
case "pnpm":
|
|
69
|
+
return ["pnpm", "jest"];
|
|
70
|
+
default:
|
|
71
|
+
return ["npx", "jest"];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// src/core/exec.ts
|
|
76
|
+
var import_node_child_process = require("child_process");
|
|
77
|
+
async function execCommand(cmd, args = [], options = {}) {
|
|
78
|
+
return new Promise((resolve, reject) => {
|
|
79
|
+
const resolvedCmd = resolveCommand(cmd);
|
|
80
|
+
const child = (0, import_node_child_process.spawn)(resolvedCmd, args, {
|
|
81
|
+
shell: options.shell ?? process.platform === "win32"
|
|
82
|
+
});
|
|
83
|
+
let stdout = "";
|
|
84
|
+
let stderr = "";
|
|
85
|
+
child.stdout?.on("data", (d) => {
|
|
86
|
+
stdout += d.toString();
|
|
87
|
+
});
|
|
88
|
+
child.stderr?.on("data", (d) => {
|
|
89
|
+
stderr += d.toString();
|
|
90
|
+
});
|
|
91
|
+
child.on("close", (code) => {
|
|
92
|
+
const result = {
|
|
93
|
+
stdout,
|
|
94
|
+
stderr,
|
|
95
|
+
output: `${stdout}
|
|
96
|
+
${stderr}`,
|
|
97
|
+
code
|
|
98
|
+
};
|
|
99
|
+
if (code !== 0 && !options.ignoreErrors) {
|
|
100
|
+
reject(new Error(`Command failed with code ${code}: ${cmd} ${args.join(" ")}`));
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
resolve(result);
|
|
104
|
+
});
|
|
105
|
+
child.on("error", (error) => {
|
|
106
|
+
reject(new Error(`Failed to execute command: ${error.message}`));
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// src/core/git.ts
|
|
112
|
+
var cachedGitAvailability = null;
|
|
113
|
+
var cachedStagedFiles = null;
|
|
114
|
+
var cachedStagedFilesAt = 0;
|
|
115
|
+
var STAGED_FILES_CACHE_TTL_MS = 1e3;
|
|
116
|
+
async function hasGit() {
|
|
117
|
+
if (cachedGitAvailability !== null) {
|
|
118
|
+
return cachedGitAvailability;
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
const result = await execCommand("git", ["--version"], { ignoreErrors: true });
|
|
122
|
+
cachedGitAvailability = result.code === 0;
|
|
123
|
+
return cachedGitAvailability;
|
|
124
|
+
} catch {
|
|
125
|
+
cachedGitAvailability = false;
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
async function getStagedFiles() {
|
|
130
|
+
const now = Date.now();
|
|
131
|
+
if (cachedStagedFiles && now - cachedStagedFilesAt <= STAGED_FILES_CACHE_TTL_MS) {
|
|
132
|
+
return cachedStagedFiles;
|
|
133
|
+
}
|
|
134
|
+
const gitAvailable = await hasGit();
|
|
135
|
+
if (!gitAvailable) {
|
|
136
|
+
throw new Error("Git is not installed or not available in PATH");
|
|
137
|
+
}
|
|
138
|
+
const result = await execCommand("git", ["diff", "--name-only", "--cached"], {
|
|
139
|
+
ignoreErrors: true
|
|
140
|
+
});
|
|
141
|
+
const files = result.stdout.split("\n").map((f) => f.trim()).filter(Boolean);
|
|
142
|
+
cachedStagedFiles = files;
|
|
143
|
+
cachedStagedFilesAt = now;
|
|
144
|
+
return files;
|
|
145
|
+
}
|
|
146
|
+
function filterTestFiles(files) {
|
|
147
|
+
return files.filter((file) => VALID_TEST_EXTENSIONS.test(file));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// src/core/jest.ts
|
|
151
|
+
var import_node_child_process2 = require("child_process");
|
|
152
|
+
async function runJest(args = [], options = {}) {
|
|
153
|
+
const {
|
|
154
|
+
verbose = false,
|
|
155
|
+
coverage = false,
|
|
156
|
+
packageManager = null,
|
|
157
|
+
ignoreErrors = true,
|
|
158
|
+
disableVerbose = false
|
|
159
|
+
} = options;
|
|
160
|
+
const jestCmd = getJestCommand(packageManager);
|
|
161
|
+
const jestArgs = [...jestCmd.slice(1)];
|
|
162
|
+
if (verbose && !disableVerbose) {
|
|
163
|
+
jestArgs.push("--verbose");
|
|
164
|
+
}
|
|
165
|
+
if (coverage) {
|
|
166
|
+
jestArgs.push("--coverage");
|
|
167
|
+
if (options.coverageReporters) {
|
|
168
|
+
for (const reporter of options.coverageReporters) {
|
|
169
|
+
jestArgs.push(`--coverageReporters=${reporter}`);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (isWindows()) {
|
|
174
|
+
jestArgs.push("--no-watchman");
|
|
175
|
+
}
|
|
176
|
+
jestArgs.push(...args);
|
|
177
|
+
return new Promise((resolve, reject) => {
|
|
178
|
+
const child = (0, import_node_child_process2.spawn)(jestCmd[0], jestArgs, {
|
|
179
|
+
shell: isWindows()
|
|
180
|
+
});
|
|
181
|
+
let stdout = "";
|
|
182
|
+
let stderr = "";
|
|
183
|
+
child.stdout.on("data", (d) => {
|
|
184
|
+
stdout += d.toString();
|
|
185
|
+
});
|
|
186
|
+
child.stderr.on("data", (d) => {
|
|
187
|
+
stderr += d.toString();
|
|
188
|
+
});
|
|
189
|
+
child.on("close", (code) => {
|
|
190
|
+
const result = {
|
|
191
|
+
stdout,
|
|
192
|
+
stderr,
|
|
193
|
+
output: `${stdout}
|
|
194
|
+
${stderr}`,
|
|
195
|
+
code
|
|
196
|
+
};
|
|
197
|
+
if (code !== 0 && !ignoreErrors) {
|
|
198
|
+
reject(new Error(`Jest failed with code ${code}`));
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
resolve(result);
|
|
202
|
+
});
|
|
203
|
+
child.on("error", reject);
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
async function buildJestArgsForMode(mode) {
|
|
207
|
+
if (mode === "all") {
|
|
208
|
+
return [];
|
|
209
|
+
}
|
|
210
|
+
const staged = await getStagedFiles();
|
|
211
|
+
if (staged.length === 0) {
|
|
212
|
+
throw new Error(`No staged files found for mode: ${mode}`);
|
|
213
|
+
}
|
|
214
|
+
if (mode === "tests") {
|
|
215
|
+
const testFiles = filterTestFiles(staged);
|
|
216
|
+
if (testFiles.length === 0) {
|
|
217
|
+
throw new Error("No test files found in staged files");
|
|
218
|
+
}
|
|
219
|
+
return testFiles;
|
|
220
|
+
}
|
|
221
|
+
return ["--findRelatedTests", ...staged];
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// src/core/parsing.ts
|
|
225
|
+
function stripAnsi(text) {
|
|
226
|
+
return text.replace(/\x1b\[[0-9;]*m/g, "");
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// src/core/export.ts
|
|
230
|
+
var import_node_fs = require("fs");
|
|
231
|
+
var import_node_path = __toESM(require("path"));
|
|
232
|
+
function getDisplayTimestamp(locale = "en-US") {
|
|
233
|
+
return (/* @__PURE__ */ new Date()).toLocaleString(locale, {
|
|
234
|
+
year: "numeric",
|
|
235
|
+
month: "2-digit",
|
|
236
|
+
day: "2-digit",
|
|
237
|
+
hour: "2-digit",
|
|
238
|
+
minute: "2-digit",
|
|
239
|
+
second: "2-digit",
|
|
240
|
+
hour12: false
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
function getFilenameTimestamp() {
|
|
244
|
+
const now = /* @__PURE__ */ new Date();
|
|
245
|
+
const pad = (value) => String(value).padStart(2, "0");
|
|
246
|
+
return [now.getFullYear(), pad(now.getMonth() + 1), pad(now.getDate())].join("-") + "_" + [pad(now.getHours()), pad(now.getMinutes()), pad(now.getSeconds())].join("-");
|
|
247
|
+
}
|
|
248
|
+
function buildTimestampedPath(prefix, extension, dir = process.cwd()) {
|
|
249
|
+
const timestamp = getFilenameTimestamp();
|
|
250
|
+
const filename = `${prefix}-${timestamp}.${extension}`;
|
|
251
|
+
return import_node_path.default.resolve(dir, filename);
|
|
252
|
+
}
|
|
253
|
+
function formatAsMarkdown(content, title, timestamp = null) {
|
|
254
|
+
const lines = [`# ${title}`, ""];
|
|
255
|
+
if (timestamp) {
|
|
256
|
+
lines.push(`Generated: ${timestamp}`, "");
|
|
257
|
+
}
|
|
258
|
+
lines.push("```text", content.trimEnd(), "```", "");
|
|
259
|
+
return lines.join("\n");
|
|
260
|
+
}
|
|
261
|
+
function exportToFile(content, options) {
|
|
262
|
+
const { prefix, format, title, dir = process.cwd() } = options;
|
|
263
|
+
const filePath = buildTimestampedPath(prefix, format, dir);
|
|
264
|
+
let finalContent = content;
|
|
265
|
+
if (format === "md" && title) {
|
|
266
|
+
finalContent = formatAsMarkdown(content, title, getDisplayTimestamp());
|
|
267
|
+
}
|
|
268
|
+
(0, import_node_fs.writeFileSync)(filePath, finalContent, "utf-8");
|
|
269
|
+
return filePath;
|
|
270
|
+
}
|
|
271
|
+
function parseExportCliArgs(args) {
|
|
272
|
+
let exportFormat = null;
|
|
273
|
+
const exportArgs = [];
|
|
274
|
+
for (const arg of args) {
|
|
275
|
+
if (arg === "--export") {
|
|
276
|
+
exportFormat = "txt";
|
|
277
|
+
exportArgs.push(arg);
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
if (!arg.startsWith("--export=")) {
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
const value = arg.slice("--export=".length).trim().toLowerCase();
|
|
284
|
+
if (!value || !VALID_EXPORT_FORMATS.includes(value)) {
|
|
285
|
+
throw new Error(`Invalid value for --export: ${value || "(empty)"}. Valid values: txt, md`);
|
|
286
|
+
}
|
|
287
|
+
exportFormat = value;
|
|
288
|
+
exportArgs.push(arg);
|
|
289
|
+
}
|
|
290
|
+
return { exportFormat, exportArgs };
|
|
291
|
+
}
|
|
292
|
+
function handleExportOrDisplay(content, config) {
|
|
293
|
+
const { exportFormat, prefix, title } = config;
|
|
294
|
+
if (!exportFormat) {
|
|
295
|
+
console.log(content);
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
298
|
+
const outputPath = exportToFile(content, {
|
|
299
|
+
prefix,
|
|
300
|
+
format: exportFormat,
|
|
301
|
+
title
|
|
302
|
+
});
|
|
303
|
+
console.log(`Output exported to: ${outputPath}`);
|
|
304
|
+
return outputPath;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// src/core/cli.ts
|
|
308
|
+
function validateCliArgs(args, schema) {
|
|
309
|
+
const parsed = {};
|
|
310
|
+
const unknownArgs = [];
|
|
311
|
+
for (const [key, config] of Object.entries(schema)) {
|
|
312
|
+
if (config.default !== void 0) {
|
|
313
|
+
parsed[key] = config.default;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
for (const arg of args) {
|
|
317
|
+
let matched = false;
|
|
318
|
+
for (const [key, config] of Object.entries(schema)) {
|
|
319
|
+
if (config.values?.includes(arg)) {
|
|
320
|
+
if (config.exclusive && parsed[key] !== void 0 && parsed[key] !== config.default) {
|
|
321
|
+
throw new Error(`Multiple values provided for ${key}: ${parsed[key]} and ${arg}`);
|
|
322
|
+
}
|
|
323
|
+
parsed[key] = arg;
|
|
324
|
+
matched = true;
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
if (config.prefix && arg.startsWith(config.prefix)) {
|
|
328
|
+
const value = arg.slice(config.prefix.length).trim().toLowerCase();
|
|
329
|
+
if (!value) {
|
|
330
|
+
parsed[key] = "true";
|
|
331
|
+
matched = true;
|
|
332
|
+
break;
|
|
333
|
+
}
|
|
334
|
+
if (config.allowedValues && !config.allowedValues.includes(value)) {
|
|
335
|
+
throw new Error(
|
|
336
|
+
`Invalid value for ${config.prefix}: ${value}. Valid values: ${config.allowedValues.join(", ")}`
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
parsed[key] = value;
|
|
340
|
+
matched = true;
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
if (!matched && arg.startsWith("--")) {
|
|
345
|
+
unknownArgs.push(arg);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
return { parsed, unknownArgs };
|
|
349
|
+
}
|
|
350
|
+
function displayHelp(title, content) {
|
|
351
|
+
console.log(`
|
|
352
|
+
${title}
|
|
353
|
+
`);
|
|
354
|
+
if (content.description) {
|
|
355
|
+
console.log(`${content.description}
|
|
356
|
+
`);
|
|
357
|
+
}
|
|
358
|
+
if (content.usage?.length) {
|
|
359
|
+
console.log("Usage:");
|
|
360
|
+
content.usage.forEach((line) => console.log(` ${line}`));
|
|
361
|
+
console.log("");
|
|
362
|
+
}
|
|
363
|
+
if (content.options?.length) {
|
|
364
|
+
console.log("Options:");
|
|
365
|
+
content.options.forEach((line) => console.log(` ${line}`));
|
|
366
|
+
console.log("");
|
|
367
|
+
}
|
|
368
|
+
if (content.examples?.length) {
|
|
369
|
+
console.log("Examples:");
|
|
370
|
+
content.examples.forEach((line) => console.log(` ${line}`));
|
|
371
|
+
console.log("");
|
|
372
|
+
}
|
|
373
|
+
process.exit(0);
|
|
374
|
+
}
|
|
375
|
+
function exitWithError(message, code = 1) {
|
|
376
|
+
console.error(`\u274C ${message}`);
|
|
377
|
+
process.exit(code);
|
|
378
|
+
}
|
|
379
|
+
function logWarning(message) {
|
|
380
|
+
console.warn(`\u26A0\uFE0F ${message}`);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// src/core/ui.ts
|
|
384
|
+
function shouldShowUI(exportMode, noBanner = false) {
|
|
385
|
+
return !exportMode && !noBanner && Boolean(process.stdout.isTTY);
|
|
386
|
+
}
|
|
387
|
+
function displayBanner(config) {
|
|
388
|
+
const { text, subtitle, info = {}, colors = ["cyan"], font = "block" } = config;
|
|
389
|
+
const bannerText = [text, subtitle].filter(Boolean).join(" ").trim();
|
|
390
|
+
const cfonts = require("cfonts");
|
|
391
|
+
const boxenModule = require("boxen");
|
|
392
|
+
const boxen = typeof boxenModule === "function" ? boxenModule : boxenModule.default;
|
|
393
|
+
const renderedBanner = cfonts.render(bannerText, {
|
|
394
|
+
font,
|
|
395
|
+
colors,
|
|
396
|
+
align: "left",
|
|
397
|
+
background: "transparent",
|
|
398
|
+
letterSpacing: 1,
|
|
399
|
+
lineHeight: 1,
|
|
400
|
+
space: false,
|
|
401
|
+
maxLength: "0",
|
|
402
|
+
env: "node"
|
|
403
|
+
});
|
|
404
|
+
const infoLine = Object.entries(info).map(([key, value]) => `${key}: ${value}`).join(" | ");
|
|
405
|
+
const contentLines = [renderedBanner.string.trimEnd()];
|
|
406
|
+
if (infoLine) {
|
|
407
|
+
contentLines.push("", ` ${infoLine}`);
|
|
408
|
+
}
|
|
409
|
+
contentLines.push(` Date: ${getDisplayTimestamp()}`);
|
|
410
|
+
const boxed = boxen(contentLines.join("\n"), {
|
|
411
|
+
padding: {
|
|
412
|
+
top: 0,
|
|
413
|
+
right: 1,
|
|
414
|
+
bottom: 0,
|
|
415
|
+
left: 1
|
|
416
|
+
},
|
|
417
|
+
margin: {
|
|
418
|
+
top: 0,
|
|
419
|
+
right: 0,
|
|
420
|
+
bottom: 1,
|
|
421
|
+
left: 0
|
|
422
|
+
},
|
|
423
|
+
borderStyle: "round",
|
|
424
|
+
borderColor: colors[0] ?? "cyan"
|
|
425
|
+
});
|
|
426
|
+
console.log(boxed);
|
|
427
|
+
}
|
|
428
|
+
function createSpinner(text, color = "cyan") {
|
|
429
|
+
const ora = require("ora");
|
|
430
|
+
return ora({ text, color, spinner: "dots" });
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// src/commands/test-context.ts
|
|
434
|
+
function extractFailures(raw) {
|
|
435
|
+
const lines = raw.split("\n");
|
|
436
|
+
const temp = [];
|
|
437
|
+
let current = null;
|
|
438
|
+
for (const line of lines) {
|
|
439
|
+
if (JEST_PATTERNS.FAIL_LINE.test(line)) {
|
|
440
|
+
if (current) {
|
|
441
|
+
temp.push(current);
|
|
442
|
+
}
|
|
443
|
+
current = {
|
|
444
|
+
file: line.replace("FAIL ", "").trim(),
|
|
445
|
+
tests: []
|
|
446
|
+
};
|
|
447
|
+
continue;
|
|
448
|
+
}
|
|
449
|
+
if (JEST_PATTERNS.BULLET_POINT.test(line.trim())) {
|
|
450
|
+
current?.tests.push(line.trim().slice(1).trim());
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
if (current) {
|
|
454
|
+
temp.push(current);
|
|
455
|
+
}
|
|
456
|
+
const merged = {};
|
|
457
|
+
for (const item of temp) {
|
|
458
|
+
if (!merged[item.file]) {
|
|
459
|
+
merged[item.file] = {
|
|
460
|
+
file: item.file,
|
|
461
|
+
tests: []
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
merged[item.file].tests.push(...item.tests);
|
|
465
|
+
}
|
|
466
|
+
for (const value of Object.values(merged)) {
|
|
467
|
+
value.tests = Array.from(new Set(value.tests));
|
|
468
|
+
}
|
|
469
|
+
return Object.values(merged);
|
|
470
|
+
}
|
|
471
|
+
async function runTestContext(argv = process.argv.slice(2)) {
|
|
472
|
+
if (argv.includes("-h") || argv.includes("--help")) {
|
|
473
|
+
displayHelp("Test Context Script", {
|
|
474
|
+
description: "Run Jest and print failures in LLM-friendly format.",
|
|
475
|
+
usage: [
|
|
476
|
+
"test-context -- --all",
|
|
477
|
+
"test-context -- --related",
|
|
478
|
+
"test-context -- --tests"
|
|
479
|
+
],
|
|
480
|
+
options: [
|
|
481
|
+
"--all Run all tests (default)",
|
|
482
|
+
"--related Run tests related to staged files",
|
|
483
|
+
"--tests Run only staged test files",
|
|
484
|
+
"--export Export output as txt",
|
|
485
|
+
"--export=txt|md Export output in selected format",
|
|
486
|
+
"--no-banner Disable fancy terminal UI",
|
|
487
|
+
"-h, --help Show this help"
|
|
488
|
+
],
|
|
489
|
+
examples: ["test-context -- --related --export=md"]
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
const noBanner = argv.includes("--no-banner");
|
|
493
|
+
const args = argv.filter((arg) => arg !== "--no-banner");
|
|
494
|
+
let exportFormat;
|
|
495
|
+
let exportArgs;
|
|
496
|
+
let parsed;
|
|
497
|
+
let unknownArgs;
|
|
498
|
+
try {
|
|
499
|
+
({ exportFormat, exportArgs } = parseExportCliArgs(args));
|
|
500
|
+
({ parsed, unknownArgs } = validateCliArgs(args, {
|
|
501
|
+
mode: {
|
|
502
|
+
values: [...VALID_MODES],
|
|
503
|
+
default: "--all",
|
|
504
|
+
exclusive: true
|
|
505
|
+
}
|
|
506
|
+
}));
|
|
507
|
+
} catch (error) {
|
|
508
|
+
exitWithError(error.message);
|
|
509
|
+
}
|
|
510
|
+
const exportArgSet = new Set(exportArgs);
|
|
511
|
+
const filteredUnknownArgs = unknownArgs.filter((arg) => !exportArgSet.has(arg));
|
|
512
|
+
if (filteredUnknownArgs.length > 0) {
|
|
513
|
+
logWarning(`Unknown arguments ignored: ${filteredUnknownArgs.join(", ")}`);
|
|
514
|
+
}
|
|
515
|
+
const modeArg = parsed.mode ?? "--all";
|
|
516
|
+
const mode = modeArg === "--related" ? "related" : modeArg === "--tests" ? "tests" : "all";
|
|
517
|
+
const showUI = shouldShowUI(exportFormat, noBanner);
|
|
518
|
+
if (showUI) {
|
|
519
|
+
displayBanner({
|
|
520
|
+
text: "TEST",
|
|
521
|
+
subtitle: "CONTEXT",
|
|
522
|
+
info: {
|
|
523
|
+
Mode: mode
|
|
524
|
+
},
|
|
525
|
+
colors: ["cyan", "blue"]
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
let jestArgs = [];
|
|
529
|
+
try {
|
|
530
|
+
jestArgs = await buildJestArgsForMode(mode);
|
|
531
|
+
} catch (error) {
|
|
532
|
+
exitWithError(error.message);
|
|
533
|
+
}
|
|
534
|
+
const spinner = showUI ? createSpinner("Running Jest tests...") : null;
|
|
535
|
+
spinner?.start();
|
|
536
|
+
const result = await runJest(jestArgs, {
|
|
537
|
+
verbose: true,
|
|
538
|
+
ignoreErrors: true
|
|
539
|
+
});
|
|
540
|
+
const output = stripAnsi(result.output);
|
|
541
|
+
const hadFailures = output.includes("FAIL") || output.includes("\u25CF");
|
|
542
|
+
if (spinner) {
|
|
543
|
+
if (hadFailures) {
|
|
544
|
+
spinner.warn("Tests completed with failures");
|
|
545
|
+
} else {
|
|
546
|
+
spinner.succeed("All tests passed!");
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
if (!hadFailures) {
|
|
550
|
+
const passMessage = "All tests passed!";
|
|
551
|
+
handleExportOrDisplay(passMessage, {
|
|
552
|
+
exportFormat,
|
|
553
|
+
prefix: "export-test-context",
|
|
554
|
+
title: "Test Context"
|
|
555
|
+
});
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
const failures = extractFailures(output);
|
|
559
|
+
const lines = ["=== LLM TEST CONTEXT BEGIN ===", ""];
|
|
560
|
+
if (failures.length === 0) {
|
|
561
|
+
lines.push("No test failures could be parsed from Jest output.");
|
|
562
|
+
lines.push("This may happen if Jest failed before running tests.", "");
|
|
563
|
+
}
|
|
564
|
+
for (const fail of failures) {
|
|
565
|
+
lines.push(`File: ${fail.file}`);
|
|
566
|
+
lines.push("Failures:");
|
|
567
|
+
for (const test of fail.tests) {
|
|
568
|
+
lines.push(`- ${test}`);
|
|
569
|
+
}
|
|
570
|
+
lines.push("");
|
|
571
|
+
}
|
|
572
|
+
lines.push("=== LLM TEST CONTEXT END ===");
|
|
573
|
+
handleExportOrDisplay(lines.join("\n"), {
|
|
574
|
+
exportFormat,
|
|
575
|
+
prefix: "export-test-context",
|
|
576
|
+
title: "Test Context"
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
// src/bin/test-context.ts
|
|
581
|
+
runTestContext().catch((error) => {
|
|
582
|
+
console.error(`\u274C ${error.message}`);
|
|
583
|
+
process.exit(1);
|
|
584
|
+
});
|
|
585
|
+
//# sourceMappingURL=test-context.cjs.map
|