@cldmv/vitest-runner 1.4.3 → 1.5.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/README.md CHANGED
@@ -17,18 +17,18 @@ Sequential Vitest runner that spawns each test file in its own child process to
17
17
 
18
18
  ## ✨ What's New
19
19
 
20
- ### Latest: v1.4.3 (September 2026)
20
+ ### Latest: v1.4.4 (September 2026)
21
21
 
22
- - **The published build is actually minified now** — `dist/index.mjs` drops from ~50KB to ~25KB and `bin/vitest-runner.mjs` from ~58KB to ~30KB; sourcemaps stay generated for local debugging regardless.
23
- - **`dist/index.cjs` is a thin shim instead of a duplicate bundle** — it used to contain a full second copy of the module's logic (27.5KB); it's now a 912-byte `require(esm)` wrapper around the real ESM build, matching `@cldmv/uuid`'s `index.cjs` pattern, and it can't drift from `runner.mjs`'s actual exports.
24
- - [View full v1.4.3 Changelog](https://github.com/CLDMV/vitest-runner/blob/master/docs/changelog/v1/v1.4.3.md)
22
+ - **Dropped the `prepack` workaround** — the underlying gap (CI's publish job invoking lifecycle scripts against a bare, already-built artifact directory) is now fixed upstream in `CLDMV/.github`, so `prepack` goes back to a plain `npm run build`.
23
+ - **Fixed a release-automation gap** — the release-merge gate now re-evaluates after every check-producing workflow finishes, not just CI, so an approval landing before a slower check (CodeQL and similar) can't leave a release PR stuck approved and green with nothing re-triggering the merge.
24
+ - [View full v1.4.4 Changelog](https://github.com/CLDMV/vitest-runner/blob/master/docs/changelog/v1/v1.4.4.md)
25
25
 
26
26
  ### Recent Releases
27
27
 
28
+ - **v1.4.3** (September 2026) — The published build is actually minified now, and `dist/index.cjs` is a thin shim instead of a duplicate bundle ([Changelog](https://github.com/CLDMV/vitest-runner/blob/master/docs/changelog/v1/v1.4.3.md))
28
29
  - **v1.4.2** (September 2026) — Fixed npm publish rejecting every release over missing `repository`/`bugs`/`homepage` fields ([Changelog](https://github.com/CLDMV/vitest-runner/blob/master/docs/changelog/v1/v1.4.2.md))
29
30
  - **v1.4.1** (September 2026) — Completed the vitest 5 upgrade, fixed the README npm badges, and fixed a `prepack` bug crashing every publish job ([Changelog](https://github.com/CLDMV/vitest-runner/blob/master/docs/changelog/v1/v1.4.1.md))
30
31
  - **v1.4.0** (September 2026) — Real bundled `dist/`/`bin/` build, a working CLI, and a runner-owned scratch-directory lifecycle ([Changelog](https://github.com/CLDMV/vitest-runner/blob/master/docs/changelog/v1/v1.4.0.md))
31
- - **v1.3.3** (September 2026) — Dependency bump (`brace-expansion`, `postcss`) via Dependabot.
32
32
 
33
33
  ---
34
34
 
@@ -68,6 +68,7 @@ vitest-runner [OPTIONS] [PATTERNS...]
68
68
  | `--file-pattern <regex>` | Override the file discovery regex (default: `\.test\.vitest\.(?:js\|mjs\|cjs)$`) |
69
69
  | `--workers <n>` | Number of parallel workers (default: `4` or `VITEST_WORKERS`) |
70
70
  | `--solo-pattern <pat>` | Run files matching this path substring solo (one at a time) before the worker pool; repeatable |
71
+ | `--exclude <glob>` | Directory / file glob, relative to `cwd`, that discovery never enters (e.g. `tmp/**`); repeatable |
71
72
  | `--no-error-details` | Hide inline error blocks — show only counts in the summary |
72
73
  | `--coverage-quiet` | Implies `--coverage`; suppress per-file output and show only a live progress bar and final summaries |
73
74
  | `--log-file <path>` | Write a clean (ANSI-stripped) copy of all output to this file. Defaults to `coverage/coverage-run.log` when `--coverage-quiet` is active |
@@ -148,6 +149,9 @@ vitest-runner --file-pattern '\.spec\.ts$'
148
149
  # Run 2 workers, with certain files running solo first
149
150
  vitest-runner --workers 2 --solo-pattern heavy/ --solo-pattern listener-cleanup/
150
151
 
152
+ # Skip scratch worktrees / build output when discovery walks the repo root
153
+ vitest-runner --exclude 'tmp/**' --exclude 'dist/**'
154
+
151
155
  # Custom heap and worker count
152
156
  VITEST_HEAP_MB=8192 vitest-runner --workers 2 src/tests/heavy
153
157
 
@@ -196,6 +200,7 @@ process.exit(code);
196
200
  | `testPatterns` | `string[]` | `[]` | File / folder patterns to filter — empty means all files in `testDir` |
197
201
  | `testListFile` | `string` | `undefined` | Path to a JSON array of test file paths; when set, scanning is skipped entirely |
198
202
  | `testFilePattern` | `RegExp` | `DEFAULT_TEST_FILE_PATTERN` | Regex matched against file names during discovery (`*.test.vitest.{js,mjs,cjs}` by default) |
203
+ | `exclude` | `string[]` | `[]` | Directory / file globs, relative to `cwd`, that discovery never enters (e.g. `['tmp/**']`). Applies to both the default scan and partial-path pattern resolution |
199
204
  | `vitestArgs` | `string[]` | `[]` | Extra CLI args forwarded verbatim to every vitest invocation |
200
205
  | `showErrorDetails` | `boolean` | `true` | Print inline error blocks under each failed file in the summary |
201
206
  | `coverageQuiet` | `boolean` | `false` | Suppress per-file output; show only the progress bar and final summaries |
@@ -299,6 +304,12 @@ This avoids the OOM crash that occurs when a single vitest process holds coverag
299
304
 
300
305
  The log file path can be overridden with `--log-file <path>`. Passing `--log-file` by itself only enables log mirroring (it does not enable coverage mode).
301
306
 
307
+ ### When no files are measured
308
+
309
+ If the coverage `include` matches no files (for example, a scaffold repo with a test but no source yet), istanbul reports every percentage as `Unknown` rather than a number. The runner prints those metrics as `Unknown` — `Coverage Unknown% lines | Unknown% statements | …` — adds a note that no files were measured, and exits `0` if the tests passed. The same applies to any individual non-numeric percentage in the worst-coverage table.
310
+
311
+ Coverage thresholds are skipped in this case, because there is nothing to measure: vitest's own threshold check does not fail on an `Unknown` percentage, and the runner does not add a check of its own. Thresholds apply again as soon as at least one file is measured. The JSON report's `coverageSummary.noFilesMeasured` is `true` for such a run.
312
+
302
313
  ### Producing blobs for an external merge
303
314
 
304
315
  Set `mergeReports: false` (CLI: `--no-merge-reports`) to stop the run after the per-file blobs are written. The internal `vitest --mergeReports` call and the coverage summary are skipped, and `blobsDir` is left intact instead of being deleted. The blobs directory is still cleared at the **start** of each run, so it only ever contains the current run's output.
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{createWriteStream as jt,mkdirSync as Nt}from"fs";import he from"path";var Et=new Set(["--test-list","--no-error-details","--coverage-quiet","--log-file","--suppress-file-output","--suppress-passing-files","--no-top-summary","--json","--blobs-dir","--no-merge-reports","--workers","--solo-pattern","--file-pattern","--keep-tmp","--scratch-dir","--help","-h"]);function tt(e){let o=[],s=[],r=[],t,n=!0,a=!1,p,u=!1,c=!1,f=!0,d=!1,b,h=!0,m,M=!1,v,w=!1,F;for(let E=0;E<e.length;E++){let l=e[E];l==="--test-list"?t=e[++E]:l.startsWith("--test-list=")?t=l.slice(12):l==="--no-error-details"?n=!1:l==="--coverage-quiet"?a=!0:l==="--log-file"?p=e[++E]:l.startsWith("--log-file=")?p=l.slice(11):l==="--suppress-file-output"?u=!0:l==="--suppress-passing-files"?c=!0:l==="--no-top-summary"?f=!1:l==="--json"?d=!0:l==="--blobs-dir"?b=e[++E]:l.startsWith("--blobs-dir=")?b=l.slice(12):l==="--no-merge-reports"?h=!1:l==="--workers"?m=parseInt(e[++E],10):l.startsWith("--workers=")?m=parseInt(l.slice(10),10):l==="--solo-pattern"?r.push(e[++E]):l.startsWith("--solo-pattern=")?r.push(l.slice(15)):l==="--file-pattern"?v=new RegExp(e[++E],"i"):l.startsWith("--file-pattern=")?v=new RegExp(l.slice(15),"i"):l==="--keep-tmp"?w=!0:l==="--scratch-dir"?F=e[++E]:l.startsWith("--scratch-dir=")?F=l.slice(14):l==="--help"||l==="-h"?M=!0:(l.startsWith("--")||l.startsWith("-"))&&!Et.has(l)?(o.push(l),E+1<e.length&&!e[E+1].startsWith("-")&&o.push(e[++E])):s.push(l)}return{testListFile:t,showErrorDetails:n,coverageQuiet:a,logFile:p,suppressFileOutput:u,suppressPassingFiles:c,topSummary:f,json:d,blobsDir:b,mergeReports:h,help:M,workers:m,soloPatterns:r,testFilePattern:v,vitestPassthroughArgs:o,testPatterns:s,keepTmp:w,scratchDir:F}}import Z from"chalk";function st(){console.log(`
2
+ import{createWriteStream as zt,mkdirSync as qt}from"fs";import be from"path";var Ot=new Set(["--test-list","--no-error-details","--coverage-quiet","--log-file","--suppress-file-output","--suppress-passing-files","--no-top-summary","--json","--blobs-dir","--no-merge-reports","--workers","--solo-pattern","--exclude","--file-pattern","--keep-tmp","--scratch-dir","--help","-h"]);function rt(e){let t=[],s=[],r=[],o=[],n,l=!0,u=!1,c,a=!1,p=!1,f=!0,h=!1,b,v=!0,y,S=!1,d,T=!1,P;for(let w=0;w<e.length;w++){let g=e[w];g==="--test-list"?n=e[++w]:g.startsWith("--test-list=")?n=g.slice(12):g==="--no-error-details"?l=!1:g==="--coverage-quiet"?u=!0:g==="--log-file"?c=e[++w]:g.startsWith("--log-file=")?c=g.slice(11):g==="--suppress-file-output"?a=!0:g==="--suppress-passing-files"?p=!0:g==="--no-top-summary"?f=!1:g==="--json"?h=!0:g==="--blobs-dir"?b=e[++w]:g.startsWith("--blobs-dir=")?b=g.slice(12):g==="--no-merge-reports"?v=!1:g==="--workers"?y=parseInt(e[++w],10):g.startsWith("--workers=")?y=parseInt(g.slice(10),10):g==="--solo-pattern"?r.push(e[++w]):g.startsWith("--solo-pattern=")?r.push(g.slice(15)):g==="--exclude"?o.push(e[++w]):g.startsWith("--exclude=")?o.push(g.slice(10)):g==="--file-pattern"?d=new RegExp(e[++w],"i"):g.startsWith("--file-pattern=")?d=new RegExp(g.slice(15),"i"):g==="--keep-tmp"?T=!0:g==="--scratch-dir"?P=e[++w]:g.startsWith("--scratch-dir=")?P=g.slice(14):g==="--help"||g==="-h"?S=!0:(g.startsWith("--")||g.startsWith("-"))&&!Ot.has(g)?(t.push(g),w+1<e.length&&!e[w+1].startsWith("-")&&t.push(e[++w])):s.push(g)}return{testListFile:n,showErrorDetails:l,coverageQuiet:u,logFile:c,suppressFileOutput:a,suppressPassingFiles:p,topSummary:f,json:h,blobsDir:b,mergeReports:v,help:S,workers:y,soloPatterns:r,exclude:o,testFilePattern:d,vitestPassthroughArgs:t,testPatterns:s,keepTmp:T,scratchDir:P}}import Z from"chalk";function nt(){console.log(`
3
3
  ${Z.bold("Vitest Sequential Runner")}
4
4
  Runs each test file in its own Vitest process to avoid OOM issues.
5
5
 
@@ -11,6 +11,7 @@ ${Z.bold("SPECIAL FLAGS:")}
11
11
  --file-pattern <regex> Override the file discovery regex (default: \\.test\\.vitest\\.(?:js|mjs|cjs)$)
12
12
  --workers <n> Number of parallel workers (default: 4 or VITEST_WORKERS)
13
13
  --solo-pattern <pat> Run files matching this path substring solo first (repeatable)
14
+ --exclude <glob> Directory / file glob discovery never enters, relative to cwd (repeatable)
14
15
  --no-error-details Hide detailed error output (show only counts)
15
16
  --coverage-quiet Implies --coverage; show progress bar + final summaries only
16
17
  --log-file <path> Path for mirrored runner output (default: coverage/coverage-run.log with --coverage-quiet)
@@ -66,6 +67,9 @@ ${Z.bold("ENVIRONMENT VARIABLES:")}
66
67
  # Run files matching a pattern solo first, then the rest in parallel
67
68
  vitest-runner --solo-pattern listener-cleanup/ --solo-pattern heavy/
68
69
 
70
+ # Skip scratch worktrees when discovery walks the repo root
71
+ vitest-runner --exclude 'tmp/**' --exclude 'dist/**'
72
+
69
73
  # Hide detailed errors
70
74
  vitest-runner --no-error-details
71
75
 
@@ -74,51 +78,50 @@ ${Z.bold("ENVIRONMENT VARIABLES:")}
74
78
 
75
79
  # Custom heap and workers
76
80
  VITEST_HEAP_MB=8192 vitest-runner --workers 2 src/tests/heavy
77
- `)}import G from"fs/promises";import me from"path";import $ from"chalk";import{createRequire as yt}from"module";import X from"path";import Mt from"fs/promises";import{pathToFileURL as Pt}from"url";function Oe(e,o,s=o){let r=yt(Pt(X.join(e,"package.json"))),t=r.resolve(`${o}/package.json`),n=r(t),a=n.bin?.[s]??n.bin;if(!a)throw new Error(`No bin "${s}" found in ${o}/package.json`);return X.join(X.dirname(t),a)}var Rt=Object.freeze(["vitest.config.ts","vitest.config.mts","vitest.config.cts","vitest.config.mjs","vitest.config.js","vitest.config.cjs","vite.config.ts","vite.config.mts","vite.config.mjs","vite.config.js"]);async function De(e,o){if(o)return X.isAbsolute(o)?o:X.resolve(e,o);for(let s of Rt){let r=X.join(e,s);try{return await Mt.access(r),r}catch{}}}import Ae from"fs/promises";import N from"path";var ot=/\.test\.vitest\.(?:js|mjs|cjs)$/i;async function ue(e,o,s=ot){let r=[e],t=[];for(;r.length;){let n=r.pop(),a;try{a=await Ae.readdir(n,{withFileTypes:!0})}catch{continue}for(let p of a){if(p.isDirectory()){if(p.name==="node_modules"||p.name.startsWith("."))continue;r.push(N.join(n,p.name));continue}p.isFile()&&s.test(p.name)&&t.push(N.relative(o,N.join(n,p.name)))}}return t}function fe(e,o=[]){let s=[],r=[];for(let t of e){let n=t.replace(/\\/g,"/"),a=o.findIndex(p=>n.includes(p));a!==-1?s.push({file:t,priorityIndex:a}):r.push(t)}return s.sort((t,n)=>t.priorityIndex-n.priorityIndex||t.file.localeCompare(n.file)),r.sort((t,n)=>t.localeCompare(n)),[...s.map(t=>t.file),...r]}function Ie(e){let o=e.map(r=>r.replace(/\\/g,"/")),s=new Map;for(let r=0;r<e.length;r++){let t=[];for(let n=0;n<e.length;n++)r!==n&&o[n].includes(o[r])&&t.push(e[n]);s.set(e[r],t)}return s}async function de(e){let{cwd:o,testDir:s,testPatterns:r=[],testListFile:t,testFilePattern:n=ot,earlyRunPatterns:a=[]}=e,p=s?N.isAbsolute(s)?s:N.resolve(o,s):o;if(t){let c=N.isAbsolute(t)?t:N.resolve(o,t),f;try{let d=await Ae.readFile(c,"utf8");f=JSON.parse(d)}catch(d){throw new Error(`Failed to read test list file "${c}": ${d.message}`,{cause:d})}if(!Array.isArray(f))throw new Error(`Test list file "${c}" must contain a JSON array of test file paths`);return console.log(`\u{1F4CB} Loading test list from: ${N.relative(o,c)}`),fe(f,a)}if(r.length===0){let c=await ue(p,o,n);return fe(c,a)}let u=[];for(let c of r){let f=N.isAbsolute(c)?c:N.resolve(o,c),d=null;try{d=await Ae.stat(f)}catch{}if(d?.isFile())n.test(f)&&u.push(N.relative(o,f));else if(d?.isDirectory())u.push(...await ue(f,o,n));else{let h=(await ue(p,o,n)).filter(m=>m.replace(/\\/g,"/").includes(c.replace(/\\/g,"/")));h.length>0?u.push(...h):console.warn(`\u26A0\uFE0F No matches found for: ${c}`)}}return fe([...new Set(u)],a)}import{spawn as rt}from"child_process";function L(e){return e.replace(/\x1B\[[0-9;]*[a-zA-Z]/g,"")}function _(e,o){let s=o.toFixed(2).padStart(6);return o>=80?e.green(s):o>=50?e.yellow(s):e.red(s)}function ke(e){let o=L(e),s={testFilesPass:0,testFilesFail:0,testsPass:0,testsFail:0,testsSkip:0,duration:0,heapMb:null,errors:[]},r=o.match(/Test Files\s+(.+)/);if(r){let u=r[1],c=u.match(/(\d+)\s+passed/),f=u.match(/(\d+)\s+failed/);c&&(s.testFilesPass=parseInt(c[1],10)),f&&(s.testFilesFail=parseInt(f[1],10))}let t=o.match(/^\s*Tests\s+(.+)$/m);if(t){let u=t[1],c=u.match(/(\d+)\s+passed/),f=u.match(/(\d+)\s+failed/),d=u.match(/(\d+)\s+skipped/);c&&(s.testsPass=parseInt(c[1],10)),f&&(s.testsFail=parseInt(f[1],10)),d&&(s.testsSkip=parseInt(d[1],10))}let n=o.match(/Duration\s+([\d.]+)s/);n&&(s.duration=parseFloat(n[1])*1e3);let a=o.match(/(\d+)\s*MB\s+heap\s+used/i);a&&(s.heapMb=parseInt(a[1],10));let p=e.indexOf("Failed Tests");if(p!==-1){let u=e.indexOf(`
78
- Test Files`,p),c=u!==-1?e.substring(p,u):e.substring(p),f=/FAIL\s*(?:\x1B\[[0-9;]*[a-zA-Z]|\s)*tests\//g,d=[...c.matchAll(f)];for(let b=0;b<d.length;b++){let h=d[b].index,m=c.lastIndexOf(`
79
- `,h),M=m===-1?0:m,v=b<d.length-1?d[b+1].index:c.length,w=c.lastIndexOf(`
80
- `,v),F=w===-1?v:w,E=c.substring(M,F).trim();E&&s.errors.push(E)}}return s}function Ce(e){let s=e.join(`
81
+ `)}import G from"fs/promises";import ve from"path";import $ from"chalk";import{createRequire as kt}from"module";import X from"path";import Dt from"fs/promises";import{pathToFileURL as At}from"url";function ke(e,t,s=t){let r=kt(At(X.join(e,"package.json"))),o=r.resolve(`${t}/package.json`),n=r(o),l=n.bin?.[s]??n.bin;if(!l)throw new Error(`No bin "${s}" found in ${t}/package.json`);return X.join(X.dirname(o),l)}var It=Object.freeze(["vitest.config.ts","vitest.config.mts","vitest.config.cts","vitest.config.mjs","vitest.config.js","vitest.config.cjs","vite.config.ts","vite.config.mts","vite.config.mjs","vite.config.js"]);async function De(e,t){if(t)return X.isAbsolute(t)?t:X.resolve(e,t);for(let s of It){let r=X.join(e,s);try{return await Dt.access(r),r}catch{}}}import Ie from"fs/promises";import j from"path";var it=/\.test\.vitest\.(?:js|mjs|cjs)$/i;function jt(e){let t=e.replace(/\\/g,"/"),s="";for(let r=0;r<t.length;r++){let o=t[r];o==="*"&&t[r+1]==="*"?(s+=".*",r++):o==="*"?s+="[^/]*":o==="?"?s+="[^/]":s+=o.replace(/[.+^${}()|[\]\\]/g,"\\$&")}return new RegExp(`^${s}$`)}function Ae(e,t){return!t||t.length===0?!1:t.some(s=>jt(s).test(e))}async function de(e,t,s=it,r=[]){let o=[e],n=[];for(;o.length;){let l=o.pop(),u;try{u=await Ie.readdir(l,{withFileTypes:!0})}catch{continue}for(let c of u){let a=j.relative(t,j.join(l,c.name)).replace(/\\/g,"/");if(c.isDirectory()){if(c.name==="node_modules"||c.name.startsWith(".")||Ae(a,r)||Ae(`${a}/`,r))continue;o.push(j.join(l,c.name));continue}if(c.isFile()&&s.test(c.name)){if(Ae(a,r))continue;n.push(j.relative(t,j.join(l,c.name)))}}}return n}function ge(e,t=[]){let s=[],r=[];for(let o of e){let n=o.replace(/\\/g,"/"),l=t.findIndex(u=>n.includes(u));l!==-1?s.push({file:o,priorityIndex:l}):r.push(o)}return s.sort((o,n)=>o.priorityIndex-n.priorityIndex||o.file.localeCompare(n.file)),r.sort((o,n)=>o.localeCompare(n)),[...s.map(o=>o.file),...r]}function je(e){let t=e.map(r=>r.replace(/\\/g,"/")),s=new Map;for(let r=0;r<e.length;r++){let o=[];for(let n=0;n<e.length;n++)r!==n&&t[n].includes(t[r])&&o.push(e[n]);s.set(e[r],o)}return s}async function me(e){let{cwd:t,testDir:s,testPatterns:r=[],testListFile:o,testFilePattern:n=it,earlyRunPatterns:l=[],exclude:u=[]}=e,c=s?j.isAbsolute(s)?s:j.resolve(t,s):t;if(o){let p=j.isAbsolute(o)?o:j.resolve(t,o),f;try{let h=await Ie.readFile(p,"utf8");f=JSON.parse(h)}catch(h){throw new Error(`Failed to read test list file "${p}": ${h.message}`,{cause:h})}if(!Array.isArray(f))throw new Error(`Test list file "${p}" must contain a JSON array of test file paths`);return console.log(`\u{1F4CB} Loading test list from: ${j.relative(t,p)}`),ge(f,l)}if(r.length===0){let p=await de(c,t,n,u);return ge(p,l)}let a=[];for(let p of r){let f=j.isAbsolute(p)?p:j.resolve(t,p),h=null;try{h=await Ie.stat(f)}catch{}if(h?.isFile())n.test(f)&&a.push(j.relative(t,f));else if(h?.isDirectory())a.push(...await de(f,t,n,u));else{let v=(await de(c,t,n,u)).filter(y=>y.replace(/\\/g,"/").includes(p.replace(/\\/g,"/")));v.length>0?a.push(...v):console.warn(`\u26A0\uFE0F No matches found for: ${p}`)}}return ge([...new Set(a)],l)}import{spawn as lt}from"child_process";function L(e){return e.replace(/\x1B\[[0-9;]*[a-zA-Z]/g,"")}function ee(e){return typeof e=="number"&&Number.isFinite(e)}function te(e,t){return ee(e)?e.toFixed(t):"Unknown"}function z(e,t){if(!ee(t))return e.dim(te(t,2).padStart(6));let s=t.toFixed(2).padStart(6);return t>=80?e.green(s):t>=50?e.yellow(s):e.red(s)}function Ce(e){let t=L(e),s={testFilesPass:0,testFilesFail:0,testsPass:0,testsFail:0,testsSkip:0,duration:0,heapMb:null,errors:[]},r=t.match(/Test Files\s+(.+)/);if(r){let c=r[1],a=c.match(/(\d+)\s+passed/),p=c.match(/(\d+)\s+failed/);a&&(s.testFilesPass=parseInt(a[1],10)),p&&(s.testFilesFail=parseInt(p[1],10))}let o=t.match(/^\s*Tests\s+(.+)$/m);if(o){let c=o[1],a=c.match(/(\d+)\s+passed/),p=c.match(/(\d+)\s+failed/),f=c.match(/(\d+)\s+skipped/);a&&(s.testsPass=parseInt(a[1],10)),p&&(s.testsFail=parseInt(p[1],10)),f&&(s.testsSkip=parseInt(f[1],10))}let n=t.match(/Duration\s+([\d.]+)s/);n&&(s.duration=parseFloat(n[1])*1e3);let l=t.match(/(\d+)\s*MB\s+heap\s+used/i);l&&(s.heapMb=parseInt(l[1],10));let u=e.indexOf("Failed Tests");if(u!==-1){let c=e.indexOf(`
82
+ Test Files`,u),a=c!==-1?e.substring(u,c):e.substring(u),p=/FAIL\s*(?:\x1B\[[0-9;]*[a-zA-Z]|\s)*tests\//g,f=[...a.matchAll(p)];for(let h=0;h<f.length;h++){let b=f[h].index,v=a.lastIndexOf(`
83
+ `,b),y=v===-1?0:v,S=h<f.length-1?f[h+1].index:a.length,d=a.lastIndexOf(`
84
+ `,S),T=d===-1?S:d,P=a.substring(y,T).trim();P&&s.errors.push(P)}}return s}function Ne(e){let s=e.join(`
81
85
  `).split(`
82
- `),r=new Map,t=new Map;s.forEach((a,p)=>{if(a.includes("FAIL")&&a.includes("Config:")){t.set(a,p);let c=L(a).match(/^(.+Config:\s+)'*([^'>]+)'*(.+)$/);if(c){let[,f,d,b]=c,h=`${f.trim()}|||${b.trim()}`;r.has(h)||r.set(h,{lines:[],configs:[]}),r.get(h).lines.push(a),r.get(h).configs.push(d.replace(/'/g,""))}}});let n=new Set;for(let[,a]of r.entries())if(a.configs.length>1){for(let d=1;d<a.lines.length;d++){let b=t.get(a.lines[d]);n.add(b)}let p=a.lines[0],u=`[${a.configs.map(d=>`'${d}'`).join(",")}]`,c=L(p).replace(/(Config:\s+)'*[^'>]+'*/,`$1${u}`),f=t.get(p);s[f]=c}return s.filter((a,p)=>!n.has(p)).join(`
83
- `)}function je({maxOldSpaceMb:e,conditions:o=[],base:s=process.env.NODE_OPTIONS??""}){let r=s;for(let t of o){let n=`--conditions=${t}`;r.includes(n)||(r=r?`${r} ${n}`:n)}if(e&&!r.includes("--max-old-space-size")){let t=`--max-old-space-size=${e}`;r=r?`${r} ${t}`:t}return r.trim()}function nt({maxOldSpaceMb:e,conditions:o=[],nodeEnv:s="development",extraEnv:r={}}){let t={...process.env};t.NODE_ENV||(t.NODE_ENV=s);let n=je({maxOldSpaceMb:e,conditions:o,base:t.NODE_OPTIONS??""});return n&&(t.NODE_OPTIONS=n),Object.assign(t,r),t}function Ot(e,o){return[e,...o?["--config",o]:[],"run"]}function ge(e,o){let{cwd:s,vitestBin:r,vitestConfig:t,maxOldSpaceMb:n,conditions:a=[],nodeEnv:p="development",vitestArgs:u=[],streamOutput:c=!0,excludePaths:f=[],extraEnv:d={}}=o;return new Promise(b=>{let h=Date.now(),m=f.flatMap(l=>["--exclude",l]),M=[...Ot(r,t),...u,...m,e],v=nt({maxOldSpaceMb:n,conditions:a,nodeEnv:p,extraEnv:d}),w=rt(process.execPath,M,{cwd:s,stdio:["ignore","pipe","pipe"],env:v}),F="",E="";w.stdout?.on("data",l=>{F+=l.toString(),c&&process.stdout.write(l)}),w.stderr?.on("data",l=>{E+=l.toString(),c&&process.stderr.write(l)}),w.on("close",l=>{let D=Date.now()-h,V=`${F}
84
- ${E}`,P=ke(V);b({file:e,code:l??1,duration:P.duration>0?P.duration:D,testFilesPass:P.testFilesPass,testFilesFail:P.testFilesFail,testsPass:P.testsPass,testsFail:P.testsFail,testsSkip:P.testsSkip,heapMb:P.heapMb,errors:P.errors,rawOutput:V})}),w.on("error",l=>{b({file:e,code:1,duration:Date.now()-h,testFilesPass:0,testFilesFail:1,testsPass:0,testsFail:0,testsSkip:0,heapMb:null,errors:[l.message],rawOutput:l.toString()})})})}function Ne(e,o){let{cwd:s,vitestBin:r,vitestConfig:t,maxOldSpaceMb:n,conditions:a=[],nodeEnv:p="development",extraCoverageArgs:u=[],quietOutput:c=!1}=o;return new Promise(f=>{let d=t?["--config",t]:[],b=c?["--color"]:[],h=[r,...d,"--mergeReports",e,"--run","--coverage",...b,...u],m=nt({maxOldSpaceMb:n,conditions:a,nodeEnv:p}),M=rt(process.execPath,h,{cwd:s,stdio:c?["ignore","pipe","pipe"]:"inherit",env:m}),v="",w="";c&&(M.stdout?.on("data",F=>v+=F.toString()),M.stderr?.on("data",F=>w+=F.toString())),M.on("close",F=>f({exitCode:F??1,output:`${v}
85
- ${w}`})),M.on("error",()=>f({exitCode:1,output:""}))})}import q from"chalk";function ee(e){let o=Math.max(0,Math.floor(e/1e3)),s=Math.floor(o/3600),r=Math.floor(o%3600/60),t=o%60;return s>0?`${s}:${r.toString().padStart(2,"0")}:${t.toString().padStart(2,"0")}`:`${r}:${t.toString().padStart(2,"0")}`}function Le(e){let o=!!process.stdout.isTTY,s=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],r=26,t=Date.now(),n=0,a=0,p=0,u=0,c=0,f=0,d=null;function b(){let v=e===0?100:n/e*100,w=Date.now()-t,E=(n>0?w/n:0)*Math.max(e-n,0),l=Math.round(v/100*r),D=s[u%s.length],V=`[${"=".repeat(l)}${"-".repeat(Math.max(0,r-l))}]`,P=v.toFixed(1).padStart(5);return v<30?P=q.red(P+"%"):v<70?P=q.rgb(255,136,0)(P+"%"):v>99?P=q.green(P+"%"):P=q.yellow(P+"%"),o?`${q.green(D)} ${q.green(V)} ${q.bold(P)} ${n}/${e} | active ${a} | failed ${p} | ETA ${ee(E)} | elapsed ${ee(w)}`:`progress ${v.toFixed(1)}% ${n}/${e} | active ${a} | failed ${p} | eta ${ee(E)} | elapsed ${ee(w)}`}function h(v=!1){let w=b();if(u++,o){let E=w.replace(/\x1B\[[0-9;]*[a-zA-Z]/g,"").length;c=Math.max(c,E),process.stdout.write(`\r${w.padEnd(c," ")}`);return}let F=Date.now();(v||F-f>=2e3)&&(console.log(w),f=F)}function m(){!o||d||(d=setInterval(()=>{n>=e&&a===0||h()},120),d.unref?.())}function M(){d&&(clearInterval(d),d=null)}return h(!0),m(),{onStart(){a++,h()},onComplete(v){a=Math.max(0,a-1),n++,v&&p++,h(!0)},finish(){M(),h(!0),o&&process.stdout.write(`
86
- `)}}}var _e={onStart(){},onComplete(e){},finish(){}};import it from"fs/promises";import te from"path";import y from"chalk";function Ve(e){if(e.length!==0){console.log(`
87
- ${"=".repeat(80)}`),console.log(y.bold.red("\u2716 FAILED TEST FILES (VERBOSE OUTPUT)")),console.log("=".repeat(80));for(let o of e)console.log(`
88
- ${y.red("\u2716")} ${y.red(o.file)} ${y.dim(`(exit ${o.code})`)}`),o.rawOutput?.trim()?console.log(o.rawOutput.trimEnd()):console.log(y.dim("(no child output captured)"));console.log(`
89
- ${"=".repeat(80)}`)}}function Be(e,o){if(e===0){let s="% Coverage report from v8",r=o.split(`
90
- `),t=r.findIndex(n=>L(n).includes(s));if(t>=0){let n=r.length;for(let p=t+1;p<r.length;p++){let u=L(r[p]).trimStart();if(u.startsWith("stderr |")||u.startsWith("stdout |")){n=p;break}}if(r.slice(t+1,n).join(`
91
- `).trimEnd()){let p=r.slice(t,n).join(`
86
+ `),r=new Map,o=new Map;s.forEach((l,u)=>{if(l.includes("FAIL")&&l.includes("Config:")){o.set(l,u);let a=L(l).match(/^(.+Config:\s+)'*([^'>]+)'*(.+)$/);if(a){let[,p,f,h]=a,b=`${p.trim()}|||${h.trim()}`;r.has(b)||r.set(b,{lines:[],configs:[]}),r.get(b).lines.push(l),r.get(b).configs.push(f.replace(/'/g,""))}}});let n=new Set;for(let[,l]of r.entries())if(l.configs.length>1){for(let f=1;f<l.lines.length;f++){let h=o.get(l.lines[f]);n.add(h)}let u=l.lines[0],c=`[${l.configs.map(f=>`'${f}'`).join(",")}]`,a=L(u).replace(/(Config:\s+)'*[^'>]+'*/,`$1${c}`),p=o.get(u);s[p]=a}return s.filter((l,u)=>!n.has(u)).join(`
87
+ `)}function Le({maxOldSpaceMb:e,conditions:t=[],base:s=process.env.NODE_OPTIONS??""}){let r=s;for(let o of t){let n=`--conditions=${o}`;r.includes(n)||(r=r?`${r} ${n}`:n)}if(e&&!r.includes("--max-old-space-size")){let o=`--max-old-space-size=${e}`;r=r?`${r} ${o}`:o}return r.trim()}function at({maxOldSpaceMb:e,conditions:t=[],nodeEnv:s="development",extraEnv:r={}}){let o={...process.env};o.NODE_ENV||(o.NODE_ENV=s);let n=Le({maxOldSpaceMb:e,conditions:t,base:o.NODE_OPTIONS??""});return n&&(o.NODE_OPTIONS=n),Object.assign(o,r),o}function Ct(e,t){return[e,...t?["--config",t]:[],"run"]}function he(e,t){let{cwd:s,vitestBin:r,vitestConfig:o,maxOldSpaceMb:n,conditions:l=[],nodeEnv:u="development",vitestArgs:c=[],streamOutput:a=!0,excludePaths:p=[],extraEnv:f={}}=t;return new Promise(h=>{let b=Date.now(),v=p.flatMap(w=>["--exclude",w]),y=[...Ct(r,o),...c,...v,e],S=at({maxOldSpaceMb:n,conditions:l,nodeEnv:u,extraEnv:f}),d=lt(process.execPath,y,{cwd:s,stdio:["ignore","pipe","pipe"],env:S}),T="",P="";d.stdout?.on("data",w=>{T+=w.toString(),a&&process.stdout.write(w)}),d.stderr?.on("data",w=>{P+=w.toString(),a&&process.stderr.write(w)}),d.on("close",w=>{let g=Date.now()-b,V=`${T}
88
+ ${P}`,M=Ce(V);h({file:e,code:w??1,duration:M.duration>0?M.duration:g,testFilesPass:M.testFilesPass,testFilesFail:M.testFilesFail,testsPass:M.testsPass,testsFail:M.testsFail,testsSkip:M.testsSkip,heapMb:M.heapMb,errors:M.errors,rawOutput:V})}),d.on("error",w=>{h({file:e,code:1,duration:Date.now()-b,testFilesPass:0,testFilesFail:1,testsPass:0,testsFail:0,testsSkip:0,heapMb:null,errors:[w.message],rawOutput:w.toString()})})})}function _e(e,t){let{cwd:s,vitestBin:r,vitestConfig:o,maxOldSpaceMb:n,conditions:l=[],nodeEnv:u="development",extraCoverageArgs:c=[],quietOutput:a=!1}=t;return new Promise(p=>{let f=o?["--config",o]:[],h=a?["--color"]:[],b=[r,...f,"--mergeReports",e,"--run","--coverage",...h,...c],v=at({maxOldSpaceMb:n,conditions:l,nodeEnv:u}),y=lt(process.execPath,b,{cwd:s,stdio:a?["ignore","pipe","pipe"]:"inherit",env:v}),S="",d="";a&&(y.stdout?.on("data",T=>S+=T.toString()),y.stderr?.on("data",T=>d+=T.toString())),y.on("close",T=>p({exitCode:T??1,output:`${S}
89
+ ${d}`})),y.on("error",()=>p({exitCode:1,output:""}))})}import q from"chalk";function se(e){let t=Math.max(0,Math.floor(e/1e3)),s=Math.floor(t/3600),r=Math.floor(t%3600/60),o=t%60;return s>0?`${s}:${r.toString().padStart(2,"0")}:${o.toString().padStart(2,"0")}`:`${r}:${o.toString().padStart(2,"0")}`}function Ve(e){let t=!!process.stdout.isTTY,s=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],r=26,o=Date.now(),n=0,l=0,u=0,c=0,a=0,p=0,f=null;function h(){let S=e===0?100:n/e*100,d=Date.now()-o,P=(n>0?d/n:0)*Math.max(e-n,0),w=Math.round(S/100*r),g=s[c%s.length],V=`[${"=".repeat(w)}${"-".repeat(Math.max(0,r-w))}]`,M=S.toFixed(1).padStart(5);return S<30?M=q.red(M+"%"):S<70?M=q.rgb(255,136,0)(M+"%"):S>99?M=q.green(M+"%"):M=q.yellow(M+"%"),t?`${q.green(g)} ${q.green(V)} ${q.bold(M)} ${n}/${e} | active ${l} | failed ${u} | ETA ${se(P)} | elapsed ${se(d)}`:`progress ${S.toFixed(1)}% ${n}/${e} | active ${l} | failed ${u} | eta ${se(P)} | elapsed ${se(d)}`}function b(S=!1){let d=h();if(c++,t){let P=d.replace(/\x1B\[[0-9;]*[a-zA-Z]/g,"").length;a=Math.max(a,P),process.stdout.write(`\r${d.padEnd(a," ")}`);return}let T=Date.now();(S||T-p>=2e3)&&(console.log(d),p=T)}function v(){!t||f||(f=setInterval(()=>{n>=e&&l===0||b()},120),f.unref?.())}function y(){f&&(clearInterval(f),f=null)}return b(!0),v(),{onStart(){l++,b()},onComplete(S){l=Math.max(0,l-1),n++,S&&u++,b(!0)},finish(){y(),b(!0),t&&process.stdout.write(`
90
+ `)}}}var Be={onStart(){},onComplete(e){},finish(){}};import ct from"fs/promises";import oe from"path";import O from"chalk";function We(e){if(e.length!==0){console.log(`
91
+ ${"=".repeat(80)}`),console.log(O.bold.red("\u2716 FAILED TEST FILES (VERBOSE OUTPUT)")),console.log("=".repeat(80));for(let t of e)console.log(`
92
+ ${O.red("\u2716")} ${O.red(t.file)} ${O.dim(`(exit ${t.code})`)}`),t.rawOutput?.trim()?console.log(t.rawOutput.trimEnd()):console.log(O.dim("(no child output captured)"));console.log(`
93
+ ${"=".repeat(80)}`)}}function Ue(e,t){if(e===0){let s="% Coverage report from v8",r=t.split(`
94
+ `),o=r.findIndex(n=>L(n).includes(s));if(o>=0){let n=r.length;for(let u=o+1;u<r.length;u++){let c=L(r[u]).trimStart();if(c.startsWith("stderr |")||c.startsWith("stdout |")){n=u;break}}if(r.slice(o+1,n).join(`
95
+ `).trimEnd()){let u=r.slice(o,n).join(`
92
96
  `).trimEnd();console.log(`
93
- ${p}
94
- `)}}}else{let s=o.trimEnd();s&&console.error(s)}}function Dt(e){let o=(r,t)=>t===0?100:parseFloat((r/t*100).toFixed(2)),s={total:{statements:{total:0,covered:0,pct:0},branches:{total:0,covered:0,pct:0},functions:{total:0,covered:0,pct:0},lines:{total:0,covered:0,pct:0}}};for(let[r,t]of Object.entries(e)){let n=Object.keys(t.s??{}),a=n.length,p=n.filter(v=>t.s[v]>0).length,u=Object.keys(t.f??{}),c=u.length,f=u.filter(v=>t.f[v]>0).length,d=0,b=0;for(let v of Object.values(t.b??{}))d+=v.length,b+=v.filter(w=>w>0).length;let h=new Set,m=new Set;for(let[v,w]of Object.entries(t.statementMap??{})){let F=w?.start?.line;F!=null&&(m.add(F),(t.s??{})[v]>0&&h.add(F))}let M={statements:{total:a,covered:p,pct:o(p,a)},branches:{total:d,covered:b,pct:o(b,d)},functions:{total:c,covered:f,pct:o(f,c)},lines:{total:m.size,covered:h.size,pct:o(h.size,m.size)}};s[r]=M;for(let v of["statements","branches","functions","lines"])s.total[v].total+=M[v].total,s.total[v].covered+=M[v].covered}for(let r of["statements","branches","functions","lines"]){let{total:t,covered:n}=s.total[r];s.total[r].pct=o(n,t)}return s}async function We(e,o,s=10,r={}){let{silent:t=!1}=r,n=te.resolve(e,"coverage"),a=o.find(m=>m.startsWith("--coverage.reportsDirectory="));if(a){let m=a.split("=").slice(1).join("=");n=te.isAbsolute(m)?m:te.resolve(e,m)}let p;try{let m=await it.readFile(te.join(n,"coverage-summary.json"),"utf8");p=JSON.parse(m)}catch{try{let m=await it.readFile(te.join(n,"coverage-final.json"),"utf8");p=Dt(JSON.parse(m))}catch{return t||console.log(y.dim(" (no coverage JSON found \u2014 skipping summary)")),null}}let{total:u,...c}=p;if(s>0){let m=Object.entries(c).map(([l,D])=>({file:te.relative(e,l),lines:D.lines?.pct??0,stmts:D.statements?.pct??0,fns:D.functions?.pct??0,branches:D.branches?.pct??0})).filter(l=>Math.min(l.lines,l.stmts,l.fns,l.branches)<100).sort((l,D)=>Math.min(l.lines,l.stmts,l.fns,l.branches)-Math.min(D.lines,D.stmts,D.fns,D.branches)),M=m.slice(0,s);t||(console.log(`
95
- `+y.bold("\u{1F4C9} WORST COVERAGE FILES (lowest metric)")),console.log("-".repeat(80)),M.forEach(({file:l,lines:D,stmts:V,fns:P,branches:B})=>{let O=Math.min(D,V,P,B),ve=y.dim(`lines ${D.toFixed(0)}% | stmts ${V.toFixed(0)}% | fns ${P.toFixed(0)}% | branches ${B.toFixed(0)}%`);console.log(` ${_(y,O)}% ${y.dim(l)} ${ve}`)}),m.length>s&&console.log(y.dim(` ... and ${m.length-s} more files`)));let v=u.lines?.pct??0,w=u.statements?.pct??0,F=u.functions?.pct??0,E=u.branches?.pct??0;return t||console.log(`
96
- ${y.bold("Coverage")} ${_(y,v)}% lines ${y.dim("|")} ${_(y,w)}% statements ${y.dim("|")} ${_(y,F)}% functions ${y.dim("|")} ${_(y,E)}% branches`),{coverageDir:n,total:u,worstFiles:M,worstFilesShown:M.length,worstFilesTotal:m.length,summary:p}}let f=u.lines?.pct??0,d=u.statements?.pct??0,b=u.functions?.pct??0,h=u.branches?.pct??0;return t||console.log(`
97
- ${y.bold("Coverage")} ${_(y,f)}% lines ${y.dim("|")} ${_(y,d)}% statements ${y.dim("|")} ${_(y,b)}% functions ${y.dim("|")} ${_(y,h)}% branches`),{coverageDir:n,total:u,worstFiles:[],worstFilesShown:0,worstFilesTotal:0,summary:p}}import le from"fs/promises";import At from"fs";import ae from"path";var lt="tmp/vitest-runner",It=/^(\d+)-\d+$/;function kt(e){try{return process.kill(e,0),!0}catch(o){return o.code!=="ESRCH"}}async function at(e,o){let s=ae.resolve(e,o),r;try{r=await le.readdir(s,{withFileTypes:!0})}catch{return}for(let t of r){if(!t.isDirectory())continue;let n=t.name.match(It);if(!n)continue;let a=parseInt(n[1],10);kt(a)||await le.rm(ae.join(s,t.name),{recursive:!0,force:!0}).catch(()=>{})}}async function ct(e,o){let s=ae.resolve(e,o),r=ae.join(s,`${process.pid}-${Date.now()}`);return await le.mkdir(r,{recursive:!0}),r}async function He(e,o){let s=ae.join(e,`worker-${o}`);return await le.mkdir(s,{recursive:!0}),s}async function pt(e){await le.rm(e,{recursive:!0,force:!0}).catch(()=>{})}function ut(e){try{At.rmSync(e,{recursive:!0,force:!0})}catch{}}function ft(e,o,s){let r=e.replace(/\\/g,"/"),t;for(let{pattern:n,heapMb:a}of s)if(r.includes(n)){t=a;break}if(!(t===void 0&&o===void 0))return t===void 0?o:o===void 0?t:Math.max(t,o)}async function dt(e){let o=e.cwd??process.cwd(),s=e.scratchDir??lt,r=e.keepTmp??!1;await at(o,s);let t=await ct(o,s),n=()=>{ut(t),process.exitCode=130,process.exit()};r||(process.once("SIGINT",n),process.once("SIGTERM",n));try{return await Ct(e,t)}finally{process.removeListener("SIGINT",n),process.removeListener("SIGTERM",n),r||await pt(t)}}async function Ct(e,o){let{cwd:s=process.cwd(),testDir:r,testPatterns:t=[],testListFile:n,testFilePattern:a,vitestArgs:p=[],showErrorDetails:u=!0,coverageQuiet:c=!1,suppressFileOutput:f=!1,suppressPassingFiles:d=!1,topSummary:b=!0,json:h=!1,workers:m=parseInt(process.env.VITEST_WORKERS??"4",10),worstCoverageCount:M=10,blobsDir:v,mergeReports:w=!0,earlyRunPatterns:F=[],perFileHeapOverrides:E=[],conditions:l=[],nodeEnv:D="development",_testResultsOverride:V=null}=e,P=0,B=e.maxOldSpaceMb??(process.env.VITEST_HEAP_MB?parseInt(process.env.VITEST_HEAP_MB,10):void 0),O=!h,ve=Oe(s,"vitest","vitest"),gt=await De(s,e.vitestConfig),be={cwd:s,vitestBin:ve,vitestConfig:gt,conditions:l,nodeEnv:D},k=[...p];if(c&&!k.some(i=>i==="--coverage"||i.startsWith("--coverage."))&&k.unshift("--coverage"),k.some(i=>i==="--coverage"||i.startsWith("--coverage."))){let i=me.resolve(s,v??".vitest-coverage-blobs"),g=me.resolve(s,".vitest-coverage-tmp");await Promise.all([G.rm(i,{recursive:!0,force:!0}),G.rm(g,{recursive:!0,force:!0})]),await Promise.all([G.mkdir(i,{recursive:!0}),G.mkdir(g,{recursive:!0})]);let x=await de({cwd:s,testDir:r,testPatterns:t,testListFile:n,testFilePattern:a,earlyRunPatterns:F}),A=Ie(x);if(x.length===0){let S=t.length>0?`\u274C No Vitest test files found matching: ${t.join(", ")}`:"\u274C No Vitest test files found";return O&&console.log(S),h?{exitCode:1,mode:"coverage",message:S,options:{cwd:s,testDir:r,testPatterns:t,testListFile:n,workers:m,coverageQuiet:c,suppressFileOutput:f,suppressPassingFiles:d,topSummary:b,vitestArgs:k}}:1}let j=k.filter(S=>S!=="--coverage"&&S.startsWith("--coverage.")),we=k.filter(S=>S!=="--coverage"&&!S.startsWith("--coverage.")),ne=x.filter(S=>F.some(R=>S.replace(/\\/g,"/").includes(R))),xe=x.filter(S=>!F.some(R=>S.replace(/\\/g,"/").includes(R))),Te=c||f||h,Ft=c&&!h;!c&&!f&&O&&(console.log(`
98
- \u{1F9EA} Running ${x.length} test files for coverage (blob + merge mode)`),console.log(`\u2699\uFE0F Workers: ${m} (${ne.length} solo first, then parallel)`),B&&console.log(`\u{1F9E0} Heap limit: ${B} MB`),console.log(""));let Ee=Ft?Le(x.length):_e,W=[],ye=0,Ye=async S=>{let R=me.join(i,`run-${ye}.blob`);ye++,!Te&&O&&(console.log(`
99
- ${"=".repeat(80)}`),console.log(`\u25B6\uFE0F ${S}`),console.log("=".repeat(80))),Ee.onStart();let U=me.join(g,`run-${ye}`),wt=[...we,"--coverage",`--coverage.reportsDirectory=${U}`,"--reporter=default","--reporter=blob",`--outputFile=${R}`],xt=await He(o,P++),z=await ge(S,{...be,maxOldSpaceMb:ft(S,B,E),vitestArgs:wt,streamOutput:!Te,excludePaths:A.get(S),extraEnv:{VITEST_RUNNER_TMP:xt}});if(W.push(z),Ee.onComplete(z.code!==0),!Te&&O){let et=(z.duration/1e3).toFixed(2);if(z.code===0){let Tt=z.heapMb?` | ${z.heapMb} MB heap`:"";console.log(`
100
- \u2705 PASSED (${et}s${Tt})
97
+ ${u}
98
+ `)}}}else{let s=t.trimEnd();s&&console.error(s)}}function Nt(e){let t=(o,n)=>n===0?100:parseFloat((o/n*100).toFixed(2)),s={total:{statements:{total:0,covered:0,pct:0},branches:{total:0,covered:0,pct:0},functions:{total:0,covered:0,pct:0},lines:{total:0,covered:0,pct:0}}};for(let[o,n]of Object.entries(e)){let l=Object.keys(n.s??{}),u=l.length,c=l.filter(d=>n.s[d]>0).length,a=Object.keys(n.f??{}),p=a.length,f=a.filter(d=>n.f[d]>0).length,h=0,b=0;for(let d of Object.values(n.b??{}))h+=d.length,b+=d.filter(T=>T>0).length;let v=new Set,y=new Set;for(let[d,T]of Object.entries(n.statementMap??{})){let P=T?.start?.line;P!=null&&(y.add(P),(n.s??{})[d]>0&&v.add(P))}let S={statements:{total:u,covered:c,pct:t(c,u)},branches:{total:h,covered:b,pct:t(b,h)},functions:{total:p,covered:f,pct:t(f,p)},lines:{total:y.size,covered:v.size,pct:t(v.size,y.size)}};s[o]=S;for(let d of["statements","branches","functions","lines"])s.total[d].total+=S[d].total,s.total[d].covered+=S[d].covered}let r=Object.keys(e).length>0;for(let o of["statements","branches","functions","lines"]){let{total:n,covered:l}=s.total[o];s.total[o].pct=r?t(l,n):"Unknown"}return s}function Lt({lines:e,stmts:t,fns:s,branches:r}){let o=[e,t,s,r].filter(ee);return o.length>0?Math.min(...o):null}function pt(e){return e??Number.MAX_VALUE}function _t({lines:e,stmts:t,fns:s,branches:r}){return![e,t,s,r].every(ee)}function Vt({lines:e,stmts:t,fns:s,branches:r}){console.log(`
99
+ ${O.bold("Coverage")} ${z(O,e)}% lines ${O.dim("|")} ${z(O,t)}% statements ${O.dim("|")} ${z(O,s)}% functions ${O.dim("|")} ${z(O,r)}% branches`)}async function He(e,t,s=10,r={}){let{silent:o=!1}=r,n=oe.resolve(e,"coverage"),l=t.find(v=>v.startsWith("--coverage.reportsDirectory="));if(l){let v=l.split("=").slice(1).join("=");n=oe.isAbsolute(v)?v:oe.resolve(e,v)}let u;try{let v=await ct.readFile(oe.join(n,"coverage-summary.json"),"utf8");u=JSON.parse(v)}catch{try{let v=await ct.readFile(oe.join(n,"coverage-final.json"),"utf8");u=Nt(JSON.parse(v))}catch{return o||console.log(O.dim(" (no coverage JSON found \u2014 skipping summary)")),null}}let{total:c,...a}=u,p={lines:c.lines?.pct??0,stmts:c.statements?.pct??0,fns:c.functions?.pct??0,branches:c.branches?.pct??0},f=Object.keys(a).length===0&&!Object.values(p).some(ee),h=[],b=0;if(s>0){let v=Object.entries(a).map(([S,d])=>({file:oe.relative(e,S),lines:d.lines?.pct??0,stmts:d.statements?.pct??0,fns:d.functions?.pct??0,branches:d.branches?.pct??0})).map(S=>({row:S,worst:Lt(S)})).filter(({row:S,worst:d})=>_t(S)||d<100).sort((S,d)=>pt(S.worst)-pt(d.worst)),y=v.slice(0,s);o||(console.log(`
100
+ `+O.bold("\u{1F4C9} WORST COVERAGE FILES (lowest metric)")),console.log("-".repeat(80)),y.forEach(({row:{file:S,lines:d,stmts:T,fns:P,branches:w},worst:g})=>{let V=O.dim(`lines ${te(d,0)}% | stmts ${te(T,0)}% | fns ${te(P,0)}% | branches ${te(w,0)}%`);console.log(` ${z(O,g)}% ${O.dim(S)} ${V}`)}),v.length>s&&console.log(O.dim(` ... and ${v.length-s} more files`))),h=y.map(({row:S})=>S),b=v.length}return o||(Vt(p),f&&console.log(O.dim(" No files were measured (the coverage include matched nothing), so every percentage is Unknown and coverage thresholds are skipped."))),{coverageDir:n,total:c,noFilesMeasured:f,worstFiles:h,worstFilesShown:h.length,worstFilesTotal:b,summary:u}}import ce from"fs/promises";import Bt from"fs";import pe from"path";var ut="tmp/vitest-runner",Wt=/^(\d+)-\d+$/;function Ut(e){try{return process.kill(e,0),!0}catch(t){return t.code!=="ESRCH"}}async function ft(e,t){let s=pe.resolve(e,t),r;try{r=await ce.readdir(s,{withFileTypes:!0})}catch{return}for(let o of r){if(!o.isDirectory())continue;let n=o.name.match(Wt);if(!n)continue;let l=parseInt(n[1],10);Ut(l)||await ce.rm(pe.join(s,o.name),{recursive:!0,force:!0}).catch(()=>{})}}async function dt(e,t){let s=pe.resolve(e,t),r=pe.join(s,`${process.pid}-${Date.now()}`);return await ce.mkdir(r,{recursive:!0}),r}async function ze(e,t){let s=pe.join(e,`worker-${t}`);return await ce.mkdir(s,{recursive:!0}),s}async function gt(e){await ce.rm(e,{recursive:!0,force:!0}).catch(()=>{})}function mt(e){try{Bt.rmSync(e,{recursive:!0,force:!0})}catch{}}function ht(e,t,s){let r=e.replace(/\\/g,"/"),o;for(let{pattern:n,heapMb:l}of s)if(r.includes(n)){o=l;break}if(!(o===void 0&&t===void 0))return o===void 0?t:t===void 0?o:Math.max(o,t)}async function vt(e){let t=e.cwd??process.cwd(),s=e.scratchDir??ut,r=e.keepTmp??!1;await ft(t,s);let o=await dt(t,s),n=()=>{mt(o),process.exitCode=130,process.exit()};r||(process.once("SIGINT",n),process.once("SIGTERM",n));try{return await Ht(e,o)}finally{process.removeListener("SIGINT",n),process.removeListener("SIGTERM",n),r||await gt(o)}}async function Ht(e,t){let{cwd:s=process.cwd(),testDir:r,testPatterns:o=[],testListFile:n,testFilePattern:l,vitestArgs:u=[],showErrorDetails:c=!0,coverageQuiet:a=!1,suppressFileOutput:p=!1,suppressPassingFiles:f=!1,topSummary:h=!0,json:b=!1,workers:v=parseInt(process.env.VITEST_WORKERS??"4",10),worstCoverageCount:y=10,blobsDir:S,mergeReports:d=!0,earlyRunPatterns:T=[],exclude:P=[],perFileHeapOverrides:w=[],conditions:g=[],nodeEnv:V="development",_testResultsOverride:M=null}=e,Ge=0,B=e.maxOldSpaceMb??(process.env.VITEST_HEAP_MB?parseInt(process.env.VITEST_HEAP_MB,10):void 0),k=!b,bt=ke(s,"vitest","vitest"),St=await De(s,e.vitestConfig),Se={cwd:s,vitestBin:bt,vitestConfig:St,conditions:g,nodeEnv:V},I=[...u];if(a&&!I.some(i=>i==="--coverage"||i.startsWith("--coverage."))&&I.unshift("--coverage"),I.some(i=>i==="--coverage"||i.startsWith("--coverage."))){let i=ve.resolve(s,S??".vitest-coverage-blobs"),m=ve.resolve(s,".vitest-coverage-tmp");await Promise.all([G.rm(i,{recursive:!0,force:!0}),G.rm(m,{recursive:!0,force:!0})]),await Promise.all([G.mkdir(i,{recursive:!0}),G.mkdir(m,{recursive:!0})]);let E=await me({cwd:s,testDir:r,testPatterns:o,testListFile:n,testFilePattern:l,earlyRunPatterns:T,exclude:P}),D=je(E);if(E.length===0){let F=o.length>0?`\u274C No Vitest test files found matching: ${o.join(", ")}`:"\u274C No Vitest test files found";return k&&console.log(F),b?{exitCode:1,mode:"coverage",message:F,options:{cwd:s,testDir:r,testPatterns:o,testListFile:n,workers:v,coverageQuiet:a,suppressFileOutput:p,suppressPassingFiles:f,topSummary:h,vitestArgs:I}}:1}let N=I.filter(F=>F!=="--coverage"&&F.startsWith("--coverage.")),xe=I.filter(F=>F!=="--coverage"&&!F.startsWith("--coverage.")),le=E.filter(F=>T.some(R=>F.replace(/\\/g,"/").includes(R))),Te=E.filter(F=>!T.some(R=>F.replace(/\\/g,"/").includes(R))),Ee=a||p||b,yt=a&&!b;!a&&!p&&k&&(console.log(`
101
+ \u{1F9EA} Running ${E.length} test files for coverage (blob + merge mode)`),console.log(`\u2699\uFE0F Workers: ${v} (${le.length} solo first, then parallel)`),B&&console.log(`\u{1F9E0} Heap limit: ${B} MB`),console.log(""));let ye=yt?Ve(E.length):Be,_=[],Pe=0,et=async F=>{let R=ve.join(i,`run-${Pe}.blob`);Pe++,!Ee&&k&&(console.log(`
102
+ ${"=".repeat(80)}`),console.log(`\u25B6\uFE0F ${F}`),console.log("=".repeat(80))),ye.onStart();let U=ve.join(m,`run-${Pe}`),Pt=[...xe,"--coverage",`--coverage.reportsDirectory=${U}`,"--reporter=default","--reporter=blob",`--outputFile=${R}`],Mt=await ze(t,Ge++),H=await he(F,{...Se,maxOldSpaceMb:ht(F,B,w),vitestArgs:Pt,streamOutput:!Ee,excludePaths:D.get(F),extraEnv:{VITEST_RUNNER_TMP:Mt}});if(_.push(H),ye.onComplete(H.code!==0),!Ee&&k){let ot=(H.duration/1e3).toFixed(2);if(H.code===0){let Rt=H.heapMb?` | ${H.heapMb} MB heap`:"";console.log(`
103
+ \u2705 PASSED (${ot}s${Rt})
101
104
  `)}else console.log(`
102
- \u274C FAILED (exit code ${z.code}, ${et}s)
103
- `)}};for(let S of ne)await Ye(S).catch(R=>{O&&console.error(`Error running ${S}:`,R)});let Me=0,Y=new Set;for(;Me<xe.length||Y.size>0;){for(;Me<xe.length&&Y.size<m;){let S=xe[Me++],R=Ye(S).catch(U=>{O&&console.error(`Error running ${S}:`,U)}).finally(()=>Y.delete(R));Y.add(R)}Y.size>0&&await Promise.race(Y)}Ee.finish();let Pe=(await G.readdir(i).catch(()=>[])).filter(S=>S.endsWith(".blob"));if(Pe.length===0){let S="\u274C No coverage blobs were generated \u2014 coverage report cannot be produced";return O&&console.error(S),h?{exitCode:1,mode:"coverage",message:S,options:{cwd:s,testDir:r,testPatterns:t,testListFile:n,workers:m,coverageQuiet:c,suppressFileOutput:f,suppressPassingFiles:d,topSummary:b,showErrorDetails:u,worstCoverageCount:M,vitestArgs:k},totals:{testFiles:x.length,failedFiles:W.filter(R=>R.code!==0).length,passedFiles:W.filter(R=>R.code===0).length},results:{all:W,failed:W.filter(R=>R.code!==0)},merge:{blobFiles:0,exitCode:1,output:""},coverageSummary:null}:1}let pe=0,Re="",Ze=null;w&&(!c&&!f&&O&&(console.log(`
104
- ${"=".repeat(80)}`),console.log(`\u{1F4CA} Merging ${Pe.length} coverage blobs into final report...`),console.log("=".repeat(80))),{exitCode:pe,output:Re}=await Ne(i,{...be,maxOldSpaceMb:B,extraCoverageArgs:j,quietOutput:c||h}),c&&O&&Be(pe,Re),Ze=await We(s,j,M,{silent:h})),await Promise.all([...w?[G.rm(i,{recursive:!0,force:!0}).catch(()=>{})]:[],G.rm(g,{recursive:!0,force:!0}).catch(()=>{})]);let ie=W.filter(S=>S.code!==0);c&&O&&Ve(ie);let Xe=ie.length>0?1:pe;if(h){let S=W.filter(R=>R.heapMb!==null);return{exitCode:Xe,mode:"coverage",options:{cwd:s,testDir:r,testPatterns:t,testListFile:n,workers:m,coverageQuiet:c,suppressFileOutput:f,suppressPassingFiles:d,topSummary:b,showErrorDetails:u,worstCoverageCount:M,vitestArgs:k},totals:{testFiles:x.length,failedFiles:ie.length,passedFiles:W.length-ie.length},results:{all:W,failed:ie},merge:{blobFiles:Pe.length,exitCode:pe,output:Re},coverageSummary:Ze,...b?{topMemoryUsers:[...S].sort((R,U)=>U.heapMb-R.heapMb).slice(0,10),topDuration:[...W].sort((R,U)=>U.duration-R.duration).slice(0,10)}:{}}}return Xe}let J=await de({cwd:s,testDir:r,testPatterns:t,testListFile:n,testFilePattern:a,earlyRunPatterns:F}),mt=Ie(J);if(J.length===0){let i=t.length>0?`\u274C No Vitest test files found matching: ${t.join(", ")}`:"\u274C No Vitest test files found";return O&&console.log(i),h?{exitCode:1,mode:"standard",message:i,options:{cwd:s,testDir:r,testPatterns:t,testListFile:n,workers:m,coverageQuiet:c,suppressFileOutput:f,suppressPassingFiles:d,topSummary:b,vitestArgs:k}}:1}let ze=J.filter(i=>F.some(g=>i.replace(/\\/g,"/").includes(g))),$e=J.filter(i=>!F.some(g=>i.replace(/\\/g,"/").includes(g))),ht=Date.now(),qe=new Date().toLocaleTimeString("en-US",{hour12:!1});O&&!f&&t.length>0?console.log(`
105
- \u{1F9EA} Running ${J.length} test files matching: ${t.join(", ")}`):O&&!f&&console.log(`
106
- \u{1F9EA} Running ${J.length} test files (${ze.length} solo first, then parallel)`),O&&!f&&(console.log(`\u2699\uFE0F Workers: ${m}`),B&&console.log(`\u{1F9E0} Heap limit: ${B} MB`),k.length>0&&console.log(`\u{1F527} Vitest args: ${k.join(" ")}`),console.log(""));let I=[...V??[]],Ge=async i=>{!f&&O&&(console.log(`
107
- ${"=".repeat(80)}`),console.log(`\u25B6\uFE0F ${i}`),console.log("=".repeat(80)));let g=await He(o,P++),x=await ge(i,{...be,maxOldSpaceMb:ft(i,B,E),vitestArgs:k,streamOutput:!f&&!h,excludePaths:mt.get(i),extraEnv:{VITEST_RUNNER_TMP:g}});if(!f&&O){let A=(x.duration/1e3).toFixed(2);if(x.code===0){let j=x.heapMb?` | ${x.heapMb} MB heap`:"";console.log(`
108
- \u2705 PASSED (${A}s${j})
105
+ \u274C FAILED (exit code ${H.code}, ${ot}s)
106
+ `)}};for(let F of le)await et(F).catch(R=>{k&&console.error(`Error running ${F}:`,R)});let Me=0,Y=new Set;for(;Me<Te.length||Y.size>0;){for(;Me<Te.length&&Y.size<v;){let F=Te[Me++],R=et(F).catch(U=>{k&&console.error(`Error running ${F}:`,U)}).finally(()=>Y.delete(R));Y.add(R)}Y.size>0&&await Promise.race(Y)}ye.finish();let Re=(await G.readdir(i).catch(()=>[])).filter(F=>F.endsWith(".blob"));if(Re.length===0){let F="\u274C No coverage blobs were generated \u2014 coverage report cannot be produced";return k&&console.error(F),b?{exitCode:1,mode:"coverage",message:F,options:{cwd:s,testDir:r,testPatterns:o,testListFile:n,workers:v,coverageQuiet:a,suppressFileOutput:p,suppressPassingFiles:f,topSummary:h,showErrorDetails:c,worstCoverageCount:y,vitestArgs:I},totals:{testFiles:E.length,failedFiles:_.filter(R=>R.code!==0).length,passedFiles:_.filter(R=>R.code===0).length},results:{all:_,failed:_.filter(R=>R.code!==0)},merge:{blobFiles:0,exitCode:1,output:""},coverageSummary:null}:1}let fe=0,Oe="",tt=null;d&&(!a&&!p&&k&&(console.log(`
107
+ ${"=".repeat(80)}`),console.log(`\u{1F4CA} Merging ${Re.length} coverage blobs into final report...`),console.log("=".repeat(80))),{exitCode:fe,output:Oe}=await _e(i,{...Se,maxOldSpaceMb:B,extraCoverageArgs:N,quietOutput:a||b}),a&&k&&Ue(fe,Oe),tt=await He(s,N,y,{silent:b})),await Promise.all([...d?[G.rm(i,{recursive:!0,force:!0}).catch(()=>{})]:[],G.rm(m,{recursive:!0,force:!0}).catch(()=>{})]);let ae=_.filter(F=>F.code!==0);a&&k&&We(ae);let st=ae.length>0?1:fe;if(b){let F=_.filter(R=>R.heapMb!==null);return{exitCode:st,mode:"coverage",options:{cwd:s,testDir:r,testPatterns:o,testListFile:n,workers:v,coverageQuiet:a,suppressFileOutput:p,suppressPassingFiles:f,topSummary:h,showErrorDetails:c,worstCoverageCount:y,vitestArgs:I},totals:{testFiles:E.length,failedFiles:ae.length,passedFiles:_.length-ae.length},results:{all:_,failed:ae},merge:{blobFiles:Re.length,exitCode:fe,output:Oe},coverageSummary:tt,...h?{topMemoryUsers:[...F].sort((R,U)=>U.heapMb-R.heapMb).slice(0,10),topDuration:[..._].sort((R,U)=>U.duration-R.duration).slice(0,10)}:{}}}return st}let J=await me({cwd:s,testDir:r,testPatterns:o,testListFile:n,testFilePattern:l,earlyRunPatterns:T,exclude:P}),$t=je(J);if(J.length===0){let i=o.length>0?`\u274C No Vitest test files found matching: ${o.join(", ")}`:"\u274C No Vitest test files found";return k&&console.log(i),b?{exitCode:1,mode:"standard",message:i,options:{cwd:s,testDir:r,testPatterns:o,testListFile:n,workers:v,coverageQuiet:a,suppressFileOutput:p,suppressPassingFiles:f,topSummary:h,vitestArgs:I}}:1}let Je=J.filter(i=>T.some(m=>i.replace(/\\/g,"/").includes(m))),$e=J.filter(i=>!T.some(m=>i.replace(/\\/g,"/").includes(m))),wt=Date.now(),Ke=new Date().toLocaleTimeString("en-US",{hour12:!1});k&&!p&&o.length>0?console.log(`
108
+ \u{1F9EA} Running ${J.length} test files matching: ${o.join(", ")}`):k&&!p&&console.log(`
109
+ \u{1F9EA} Running ${J.length} test files (${Je.length} solo first, then parallel)`),k&&!p&&(console.log(`\u2699\uFE0F Workers: ${v}`),B&&console.log(`\u{1F9E0} Heap limit: ${B} MB`),I.length>0&&console.log(`\u{1F527} Vitest args: ${I.join(" ")}`),console.log(""));let A=[...M??[]],Qe=async i=>{!p&&k&&(console.log(`
110
+ ${"=".repeat(80)}`),console.log(`\u25B6\uFE0F ${i}`),console.log("=".repeat(80)));let m=await ze(t,Ge++),E=await he(i,{...Se,maxOldSpaceMb:ht(i,B,w),vitestArgs:I,streamOutput:!p&&!b,excludePaths:$t.get(i),extraEnv:{VITEST_RUNNER_TMP:m}});if(!p&&k){let D=(E.duration/1e3).toFixed(2);if(E.code===0){let N=E.heapMb?` | ${E.heapMb} MB heap`:"";console.log(`
111
+ \u2705 PASSED (${D}s${N})
109
112
  `)}else console.log(`
110
- \u274C FAILED (exit code ${x.code}, ${A}s)
111
- `)}return x};if(!V){for(let x of ze){let A=await Ge(x).catch(j=>(O&&console.error(`Error running ${x}:`,j),null));A&&I.push(A)}let i=0,g=new Set;for(;i<$e.length||g.size>0;){for(;i<$e.length&&g.size<m;){let x=$e[i++],A=Ge(x).then(j=>I.push(j)).catch(j=>{O&&console.error(`Error running ${x}:`,j)}).finally(()=>g.delete(A));g.add(A)}g.size>0&&await Promise.race(g)}}let Q=I.reduce((i,g)=>i+g.testFilesPass,0),H=I.reduce((i,g)=>i+g.testFilesFail,0),se=I.reduce((i,g)=>i+g.testsPass,0),oe=I.reduce((i,g)=>i+g.testsFail,0),re=I.reduce((i,g)=>i+(g.testsSkip||0),0),vt=I.reduce((i,g)=>i+g.duration,0),K=I.filter(i=>i.code!==0),ce=I.filter(i=>i.code===0),bt=K.length>0?1:0,Je=process.memoryUsage(),Se=Math.round(Je.heapUsed/1024/1024),Fe=Math.round(Je.rss/1024/1024),C=I.filter(i=>i.heapMb!==null),Qe=((Date.now()-ht)/1e3).toFixed(2),Ke=(vt/1e3).toFixed(2);if(h)return{exitCode:bt,mode:"standard",options:{cwd:s,testDir:r,testPatterns:t,testListFile:n,workers:m,coverageQuiet:c,suppressFileOutput:f,suppressPassingFiles:d,topSummary:b,showErrorDetails:u,worstCoverageCount:M,vitestArgs:k},totals:{testFilesPass:Q,testFilesFail:H,testsPass:se,testsFail:oe,testsSkip:re,totalTests:se+oe+re},timing:{startAt:qe,wallClockSeconds:Number(Qe),testsSeconds:Number(Ke)},heap:{scriptHeapMb:Se,scriptRssMb:Fe,maxHeapMb:C.length>0?Math.max(...C.map(i=>i.heapMb)):null,avgHeapMb:C.length>0?Number((C.reduce((i,g)=>i+g.heapMb,0)/C.length).toFixed(0)):null},results:{all:I,passed:ce,failed:K},...b?{topMemoryUsers:[...C].sort((i,g)=>g.heapMb-i.heapMb).slice(0,10),topDuration:[...I].sort((i,g)=>g.duration-i.duration).slice(0,10)}:{}};console.log(`
112
- `+"=".repeat(80)),b&&C.length>0&&(console.log(`
113
- `+$.bold("\u{1F9E0} TOP MEMORY USERS")),console.log("-".repeat(80)),[...C].sort((i,g)=>g.heapMb-i.heapMb).slice(0,10).forEach(i=>{console.log(` ${String(i.heapMb).padStart(4)} MB ${$.dim(i.file)}`)})),b&&I.length>0&&(console.log(`
114
- `+$.bold("\u23F1\uFE0F TOP DURATION")),console.log("-".repeat(80)),[...I].sort((i,g)=>g.duration-i.duration).slice(0,10).forEach(i=>{let g=(i.duration/1e3).toFixed(2);console.log(` ${(g+"s").padStart(8)} ${$.dim(i.file)}`)})),ce.length>0&&!d&&(console.log(`
115
- `+"=".repeat(80)),console.log($.bold.green("\u2713 PASSED TEST FILES")),console.log("=".repeat(80)),ce.forEach(i=>{let g=(i.duration/1e3).toFixed(2),x=[...i.heapMb?[`${i.heapMb} MB`]:[],`${g}s`],A=i.testsPass>0?` - ${i.testsPass} tests`:"";console.log($.green(`\u2713 ${i.file}${A}`)+$.dim(` (${x.join(", ")})`))})),console.log(`
116
- `+$.bold("=".repeat(80))),K.length>0&&(console.log(`
117
- \u274C ${K.length} test file(s) failed`),console.log($.bold.red(`
118
- Failed Test Files:`)),K.forEach(i=>{let g=(i.duration/1e3).toFixed(2),x=[...i.testsFail>0?[$.red(`${i.testsFail} failed`)]:[],...i.testsPass>0?[$.green(`${i.testsPass} passed`)]:[],...i.testsSkip>0?[$.yellow(`${i.testsSkip} skipped`)]:[]],A=[...i.heapMb?[`${i.heapMb} MB`]:[],`${g}s`],j=x.length>0?` (${x.join(", ")})`:"";if(console.log(` ${$.red("\u2716")} ${i.file}${j}`+$.dim(` [${A.join(", ")}]`)),u&&i.errors.length>0){let we=Ce(i.errors).split(`
119
- `).map(ne=>ne.trim()?` ${ne}`:"").join(`
120
- `);console.log(we),console.log("")}}),console.log("")),console.log($.bold("=".repeat(80))),H>0&&Q>0?console.log(` ${$.bold("Test Files")} ${$.red(`${H} failed`)} ${$.dim("|")} ${$.green(`${Q} passed`)} ${$.dim(`(${Q+H})`)}`):H>0?console.log(` ${$.bold("Test Files")} ${$.red(`${H} failed`)} ${$.dim(`(${H})`)}`):console.log(` ${$.bold("Test Files")} ${$.green(`${Q} passed`)} ${$.dim(`(${Q})`)}`);let $t=se+oe+re,St=[...oe>0?[$.red(`${oe} failed`)]:[],...se>0?[$.green(`${se} passed`)]:[],...re>0?[$.yellow(`${re} skipped`)]:[]];if(console.log(` ${$.bold("Tests")} ${St.join(` ${$.dim("|")} `)} ${$.dim(`(${$t})`)}`),console.log(` ${$.bold("Start at")} ${qe}`),console.log(` ${$.bold("Duration")} ${Qe}s ${$.dim(`(tests ${Ke}s)`)}`),C.length>0){let i=Math.max(...C.map(x=>x.heapMb)),g=(C.reduce((x,A)=>x+A.heapMb,0)/C.length).toFixed(0);console.log(` ${$.bold("Heap")} max ${i} MB | avg ${g} MB | script ${Se} MB (RSS ${Fe} MB)`)}else console.log(` ${$.bold("Heap")} script ${Se} MB (RSS ${Fe} MB)`);return K.length>0?1:(console.log(`
121
- \u2705 All ${ce.length} test files passed
122
- `),0)}var T=tt(process.argv.slice(2));T.help&&(st(),process.exit(0));if((T.coverageQuiet||T.logFile)&&!T.json){let n=function(a){let p=a.toString();return p.startsWith("\r")||/^progress \d+\.\d+%/.test(p)},e=process.cwd(),o=T.logFile?he.isAbsolute(T.logFile)?T.logFile:he.resolve(e,T.logFile):he.join(e,"coverage","coverage-run.log");Nt(he.dirname(o),{recursive:!0});let s=jt(o,{flags:"a"}),r=process.stdout.write.bind(process.stdout),t=process.stderr.write.bind(process.stderr);process.stdout.write=(a,p,u)=>(n(a)||s.write(L(a.toString())),r(a,p,u)),process.stderr.write=(a,p,u)=>(n(a)||s.write(L(a.toString())),t(a,p,u)),process.on("exit",()=>s.end())}var Lt=process.cwd(),Ue=[...T.vitestPassthroughArgs];T.coverageQuiet&&!Ue.some(e=>e==="--coverage"||e.startsWith("--coverage."))&&Ue.unshift("--coverage");try{let e=await dt({cwd:Lt,testPatterns:T.testPatterns,testListFile:T.testListFile,testFilePattern:T.testFilePattern,vitestArgs:Ue,showErrorDetails:T.showErrorDetails,coverageQuiet:T.coverageQuiet,suppressFileOutput:T.suppressFileOutput,suppressPassingFiles:T.suppressPassingFiles,topSummary:T.topSummary,json:T.json,mergeReports:T.mergeReports,keepTmp:T.keepTmp,...T.blobsDir!==void 0&&{blobsDir:T.blobsDir},...T.workers!==void 0&&{workers:T.workers},...T.soloPatterns.length>0&&{earlyRunPatterns:T.soloPatterns},...T.scratchDir!==void 0&&{scratchDir:T.scratchDir}});T.json&&(process.stdout.write(`${JSON.stringify(e,null,2)}
113
+ \u274C FAILED (exit code ${E.code}, ${D}s)
114
+ `)}return E};if(!M){for(let E of Je){let D=await Qe(E).catch(N=>(k&&console.error(`Error running ${E}:`,N),null));D&&A.push(D)}let i=0,m=new Set;for(;i<$e.length||m.size>0;){for(;i<$e.length&&m.size<v;){let E=$e[i++],D=Qe(E).then(N=>A.push(N)).catch(N=>{k&&console.error(`Error running ${E}:`,N)}).finally(()=>m.delete(D));m.add(D)}m.size>0&&await Promise.race(m)}}let K=A.reduce((i,m)=>i+m.testFilesPass,0),W=A.reduce((i,m)=>i+m.testFilesFail,0),re=A.reduce((i,m)=>i+m.testsPass,0),ne=A.reduce((i,m)=>i+m.testsFail,0),ie=A.reduce((i,m)=>i+(m.testsSkip||0),0),Ft=A.reduce((i,m)=>i+m.duration,0),Q=A.filter(i=>i.code!==0),ue=A.filter(i=>i.code===0),xt=Q.length>0?1:0,Ye=process.memoryUsage(),we=Math.round(Ye.heapUsed/1024/1024),Fe=Math.round(Ye.rss/1024/1024),C=A.filter(i=>i.heapMb!==null),Ze=((Date.now()-wt)/1e3).toFixed(2),Xe=(Ft/1e3).toFixed(2);if(b)return{exitCode:xt,mode:"standard",options:{cwd:s,testDir:r,testPatterns:o,testListFile:n,workers:v,coverageQuiet:a,suppressFileOutput:p,suppressPassingFiles:f,topSummary:h,showErrorDetails:c,worstCoverageCount:y,vitestArgs:I},totals:{testFilesPass:K,testFilesFail:W,testsPass:re,testsFail:ne,testsSkip:ie,totalTests:re+ne+ie},timing:{startAt:Ke,wallClockSeconds:Number(Ze),testsSeconds:Number(Xe)},heap:{scriptHeapMb:we,scriptRssMb:Fe,maxHeapMb:C.length>0?Math.max(...C.map(i=>i.heapMb)):null,avgHeapMb:C.length>0?Number((C.reduce((i,m)=>i+m.heapMb,0)/C.length).toFixed(0)):null},results:{all:A,passed:ue,failed:Q},...h?{topMemoryUsers:[...C].sort((i,m)=>m.heapMb-i.heapMb).slice(0,10),topDuration:[...A].sort((i,m)=>m.duration-i.duration).slice(0,10)}:{}};console.log(`
115
+ `+"=".repeat(80)),h&&C.length>0&&(console.log(`
116
+ `+$.bold("\u{1F9E0} TOP MEMORY USERS")),console.log("-".repeat(80)),[...C].sort((i,m)=>m.heapMb-i.heapMb).slice(0,10).forEach(i=>{console.log(` ${String(i.heapMb).padStart(4)} MB ${$.dim(i.file)}`)})),h&&A.length>0&&(console.log(`
117
+ `+$.bold("\u23F1\uFE0F TOP DURATION")),console.log("-".repeat(80)),[...A].sort((i,m)=>m.duration-i.duration).slice(0,10).forEach(i=>{let m=(i.duration/1e3).toFixed(2);console.log(` ${(m+"s").padStart(8)} ${$.dim(i.file)}`)})),ue.length>0&&!f&&(console.log(`
118
+ `+"=".repeat(80)),console.log($.bold.green("\u2713 PASSED TEST FILES")),console.log("=".repeat(80)),ue.forEach(i=>{let m=(i.duration/1e3).toFixed(2),E=[...i.heapMb?[`${i.heapMb} MB`]:[],`${m}s`],D=i.testsPass>0?` - ${i.testsPass} tests`:"";console.log($.green(`\u2713 ${i.file}${D}`)+$.dim(` (${E.join(", ")})`))})),console.log(`
119
+ `+$.bold("=".repeat(80))),Q.length>0&&(console.log(`
120
+ \u274C ${Q.length} test file(s) failed`),console.log($.bold.red(`
121
+ Failed Test Files:`)),Q.forEach(i=>{let m=(i.duration/1e3).toFixed(2),E=[...i.testsFail>0?[$.red(`${i.testsFail} failed`)]:[],...i.testsPass>0?[$.green(`${i.testsPass} passed`)]:[],...i.testsSkip>0?[$.yellow(`${i.testsSkip} skipped`)]:[]],D=[...i.heapMb?[`${i.heapMb} MB`]:[],`${m}s`],N=E.length>0?` (${E.join(", ")})`:"";if(console.log(` ${$.red("\u2716")} ${i.file}${N}`+$.dim(` [${D.join(", ")}]`)),c&&i.errors.length>0){let xe=Ne(i.errors).split(`
122
+ `).map(le=>le.trim()?` ${le}`:"").join(`
123
+ `);console.log(xe),console.log("")}}),console.log("")),console.log($.bold("=".repeat(80))),W>0&&K>0?console.log(` ${$.bold("Test Files")} ${$.red(`${W} failed`)} ${$.dim("|")} ${$.green(`${K} passed`)} ${$.dim(`(${K+W})`)}`):W>0?console.log(` ${$.bold("Test Files")} ${$.red(`${W} failed`)} ${$.dim(`(${W})`)}`):console.log(` ${$.bold("Test Files")} ${$.green(`${K} passed`)} ${$.dim(`(${K})`)}`);let Tt=re+ne+ie,Et=[...ne>0?[$.red(`${ne} failed`)]:[],...re>0?[$.green(`${re} passed`)]:[],...ie>0?[$.yellow(`${ie} skipped`)]:[]];if(console.log(` ${$.bold("Tests")} ${Et.join(` ${$.dim("|")} `)} ${$.dim(`(${Tt})`)}`),console.log(` ${$.bold("Start at")} ${Ke}`),console.log(` ${$.bold("Duration")} ${Ze}s ${$.dim(`(tests ${Xe}s)`)}`),C.length>0){let i=Math.max(...C.map(E=>E.heapMb)),m=(C.reduce((E,D)=>E+D.heapMb,0)/C.length).toFixed(0);console.log(` ${$.bold("Heap")} max ${i} MB | avg ${m} MB | script ${we} MB (RSS ${Fe} MB)`)}else console.log(` ${$.bold("Heap")} script ${we} MB (RSS ${Fe} MB)`);return Q.length>0?1:(console.log(`
124
+ \u2705 All ${ue.length} test files passed
125
+ `),0)}var x=rt(process.argv.slice(2));x.help&&(nt(),process.exit(0));if((x.coverageQuiet||x.logFile)&&!x.json){let n=function(l){let u=l.toString();return u.startsWith("\r")||/^progress \d+\.\d+%/.test(u)},e=process.cwd(),t=x.logFile?be.isAbsolute(x.logFile)?x.logFile:be.resolve(e,x.logFile):be.join(e,"coverage","coverage-run.log");qt(be.dirname(t),{recursive:!0});let s=zt(t,{flags:"a"}),r=process.stdout.write.bind(process.stdout),o=process.stderr.write.bind(process.stderr);process.stdout.write=(l,u,c)=>(n(l)||s.write(L(l.toString())),r(l,u,c)),process.stderr.write=(l,u,c)=>(n(l)||s.write(L(l.toString())),o(l,u,c)),process.on("exit",()=>s.end())}var Gt=process.cwd(),qe=[...x.vitestPassthroughArgs];x.coverageQuiet&&!qe.some(e=>e==="--coverage"||e.startsWith("--coverage."))&&qe.unshift("--coverage");try{let e=await vt({cwd:Gt,testPatterns:x.testPatterns,testListFile:x.testListFile,testFilePattern:x.testFilePattern,vitestArgs:qe,showErrorDetails:x.showErrorDetails,coverageQuiet:x.coverageQuiet,suppressFileOutput:x.suppressFileOutput,suppressPassingFiles:x.suppressPassingFiles,topSummary:x.topSummary,json:x.json,mergeReports:x.mergeReports,keepTmp:x.keepTmp,...x.blobsDir!==void 0&&{blobsDir:x.blobsDir},...x.workers!==void 0&&{workers:x.workers},...x.soloPatterns.length>0&&{earlyRunPatterns:x.soloPatterns},...x.exclude.length>0&&{exclude:x.exclude},...x.scratchDir!==void 0&&{scratchDir:x.scratchDir}});x.json&&(process.stdout.write(`${JSON.stringify(e,null,2)}
123
126
  `),process.exit(typeof e=="object"&&e!==null&&"exitCode"in e?e.exitCode:1)),process.exit(typeof e=="number"?e:1)}catch(e){console.error("Fatal error:",e),process.exit(1)}
124
127
  //# sourceMappingURL=vitest-runner.mjs.map
package/dist/index.mjs CHANGED
@@ -1,47 +1,46 @@
1
- import q from"fs/promises";import de from"path";import h from"chalk";import{createRequire as St}from"module";import K from"path";import bt from"fs/promises";import{pathToFileURL as xt}from"url";function ye(s,o,t=o){let n=St(xt(K.join(s,"package.json"))),e=n.resolve(`${o}/package.json`),r=n(e),a=r.bin?.[t]??r.bin;if(!a)throw new Error(`No bin "${t}" found in ${o}/package.json`);return K.join(K.dirname(e),a)}var wt=Object.freeze(["vitest.config.ts","vitest.config.mts","vitest.config.cts","vitest.config.mjs","vitest.config.js","vitest.config.cjs","vite.config.ts","vite.config.mts","vite.config.mjs","vite.config.js"]);async function Pe(s,o){if(o)return K.isAbsolute(o)?o:K.resolve(s,o);for(let t of wt){let n=K.join(s,t);try{return await bt.access(n),n}catch{}}}import Oe from"fs/promises";import j from"path";var Xe=/\.test\.vitest\.(?:js|mjs|cjs)$/i;async function le(s,o,t=Xe){let n=[s],e=[];for(;n.length;){let r=n.pop(),a;try{a=await Oe.readdir(r,{withFileTypes:!0})}catch{continue}for(let l of a){if(l.isDirectory()){if(l.name==="node_modules"||l.name.startsWith("."))continue;n.push(j.join(r,l.name));continue}l.isFile()&&t.test(l.name)&&e.push(j.relative(o,j.join(r,l.name)))}}return e}function pe(s,o=[]){let t=[],n=[];for(let e of s){let r=e.replace(/\\/g,"/"),a=o.findIndex(l=>r.includes(l));a!==-1?t.push({file:e,priorityIndex:a}):n.push(e)}return t.sort((e,r)=>e.priorityIndex-r.priorityIndex||e.file.localeCompare(r.file)),n.sort((e,r)=>e.localeCompare(r)),[...t.map(e=>e.file),...n]}function De(s){let o=s.map(n=>n.replace(/\\/g,"/")),t=new Map;for(let n=0;n<s.length;n++){let e=[];for(let r=0;r<s.length;r++)n!==r&&o[r].includes(o[n])&&e.push(s[r]);t.set(s[n],e)}return t}async function fe(s){let{cwd:o,testDir:t,testPatterns:n=[],testListFile:e,testFilePattern:r=Xe,earlyRunPatterns:a=[]}=s,l=t?j.isAbsolute(t)?t:j.resolve(o,t):o;if(e){let c=j.isAbsolute(e)?e:j.resolve(o,e),f;try{let p=await Oe.readFile(c,"utf8");f=JSON.parse(p)}catch(p){throw new Error(`Failed to read test list file "${c}": ${p.message}`,{cause:p})}if(!Array.isArray(f))throw new Error(`Test list file "${c}" must contain a JSON array of test file paths`);return console.log(`\u{1F4CB} Loading test list from: ${j.relative(o,c)}`),pe(f,a)}if(n.length===0){let c=await le(l,o,r);return pe(c,a)}let u=[];for(let c of n){let f=j.isAbsolute(c)?c:j.resolve(o,c),p=null;try{p=await Oe.stat(f)}catch{}if(p?.isFile())r.test(f)&&u.push(j.relative(o,f));else if(p?.isDirectory())u.push(...await le(f,o,r));else{let m=(await le(l,o,r)).filter(g=>g.replace(/\\/g,"/").includes(c.replace(/\\/g,"/")));m.length>0?u.push(...m):console.warn(`\u26A0\uFE0F No matches found for: ${c}`)}}return pe([...new Set(u)],a)}import{spawn as Re}from"child_process";function V(s){return s.replace(/\x1B\[[0-9;]*[a-zA-Z]/g,"")}function N(s,o){let t=o.toFixed(2).padStart(6);return o>=80?s.green(t):o>=50?s.yellow(t):s.red(t)}function Ie(s){let o=V(s),t={testFilesPass:0,testFilesFail:0,testsPass:0,testsFail:0,testsSkip:0,duration:0,heapMb:null,errors:[]},n=o.match(/Test Files\s+(.+)/);if(n){let u=n[1],c=u.match(/(\d+)\s+passed/),f=u.match(/(\d+)\s+failed/);c&&(t.testFilesPass=parseInt(c[1],10)),f&&(t.testFilesFail=parseInt(f[1],10))}let e=o.match(/^\s*Tests\s+(.+)$/m);if(e){let u=e[1],c=u.match(/(\d+)\s+passed/),f=u.match(/(\d+)\s+failed/),p=u.match(/(\d+)\s+skipped/);c&&(t.testsPass=parseInt(c[1],10)),f&&(t.testsFail=parseInt(f[1],10)),p&&(t.testsSkip=parseInt(p[1],10))}let r=o.match(/Duration\s+([\d.]+)s/);r&&(t.duration=parseFloat(r[1])*1e3);let a=o.match(/(\d+)\s*MB\s+heap\s+used/i);a&&(t.heapMb=parseInt(a[1],10));let l=s.indexOf("Failed Tests");if(l!==-1){let u=s.indexOf(`
2
- Test Files`,l),c=u!==-1?s.substring(l,u):s.substring(l),f=/FAIL\s*(?:\x1B\[[0-9;]*[a-zA-Z]|\s)*tests\//g,p=[...c.matchAll(f)];for(let $=0;$<p.length;$++){let m=p[$].index,g=c.lastIndexOf(`
3
- `,m),E=g===-1?0:g,v=$<p.length-1?p[$+1].index:c.length,x=c.lastIndexOf(`
4
- `,v),w=x===-1?v:x,I=c.substring(E,w).trim();I&&t.errors.push(I)}}return t}function Ce(s){let t=s.join(`
1
+ import K from"fs/promises";import me from"path";import S from"chalk";import{createRequire as Mt}from"module";import Z from"path";import Et from"fs/promises";import{pathToFileURL as yt}from"url";function Pe(t,e,o=e){let n=Mt(yt(Z.join(t,"package.json"))),s=n.resolve(`${e}/package.json`),r=n(s),c=r.bin?.[o]??r.bin;if(!c)throw new Error(`No bin "${o}" found in ${e}/package.json`);return Z.join(Z.dirname(s),c)}var Pt=Object.freeze(["vitest.config.ts","vitest.config.mts","vitest.config.cts","vitest.config.mjs","vitest.config.js","vitest.config.cjs","vite.config.ts","vite.config.mts","vite.config.mjs","vite.config.js"]);async function Oe(t,e){if(e)return Z.isAbsolute(e)?e:Z.resolve(t,e);for(let o of Pt){let n=Z.join(t,o);try{return await Et.access(n),n}catch{}}}import Ie from"fs/promises";import C from"path";var ot=/\.test\.vitest\.(?:js|mjs|cjs)$/i;function Ot(t){let e=t.replace(/\\/g,"/"),o="";for(let n=0;n<e.length;n++){let s=e[n];s==="*"&&e[n+1]==="*"?(o+=".*",n++):s==="*"?o+="[^/]*":s==="?"?o+="[^/]":o+=s.replace(/[.+^${}()|[\]\\]/g,"\\$&")}return new RegExp(`^${o}$`)}function De(t,e){return!e||e.length===0?!1:e.some(o=>Ot(o).test(t))}async function pe(t,e,o=ot,n=[]){let s=[t],r=[];for(;s.length;){let c=s.pop(),u;try{u=await Ie.readdir(c,{withFileTypes:!0})}catch{continue}for(let f of u){let a=C.relative(e,C.join(c,f.name)).replace(/\\/g,"/");if(f.isDirectory()){if(f.name==="node_modules"||f.name.startsWith(".")||De(a,n)||De(`${a}/`,n))continue;s.push(C.join(c,f.name));continue}if(f.isFile()&&o.test(f.name)){if(De(a,n))continue;r.push(C.relative(e,C.join(c,f.name)))}}}return r}function ue(t,e=[]){let o=[],n=[];for(let s of t){let r=s.replace(/\\/g,"/"),c=e.findIndex(u=>r.includes(u));c!==-1?o.push({file:s,priorityIndex:c}):n.push(s)}return o.sort((s,r)=>s.priorityIndex-r.priorityIndex||s.file.localeCompare(r.file)),n.sort((s,r)=>s.localeCompare(r)),[...o.map(s=>s.file),...n]}function Ae(t){let e=t.map(n=>n.replace(/\\/g,"/")),o=new Map;for(let n=0;n<t.length;n++){let s=[];for(let r=0;r<t.length;r++)n!==r&&e[r].includes(e[n])&&s.push(t[r]);o.set(t[n],s)}return o}async function de(t){let{cwd:e,testDir:o,testPatterns:n=[],testListFile:s,testFilePattern:r=ot,earlyRunPatterns:c=[],exclude:u=[]}=t,f=o?C.isAbsolute(o)?o:C.resolve(e,o):e;if(s){let l=C.isAbsolute(s)?s:C.resolve(e,s),p;try{let m=await Ie.readFile(l,"utf8");p=JSON.parse(m)}catch(m){throw new Error(`Failed to read test list file "${l}": ${m.message}`,{cause:m})}if(!Array.isArray(p))throw new Error(`Test list file "${l}" must contain a JSON array of test file paths`);return console.log(`\u{1F4CB} Loading test list from: ${C.relative(e,l)}`),ue(p,c)}if(n.length===0){let l=await pe(f,e,r,u);return ue(l,c)}let a=[];for(let l of n){let p=C.isAbsolute(l)?l:C.resolve(e,l),m=null;try{m=await Ie.stat(p)}catch{}if(m?.isFile())r.test(p)&&a.push(C.relative(e,p));else if(m?.isDirectory())a.push(...await pe(p,e,r,u));else{let h=(await pe(f,e,r,u)).filter(w=>w.replace(/\\/g,"/").includes(l.replace(/\\/g,"/")));h.length>0?a.push(...h):console.warn(`\u26A0\uFE0F No matches found for: ${l}`)}}return ue([...new Set(a)],c)}import{spawn as je}from"child_process";function L(t){return t.replace(/\x1B\[[0-9;]*[a-zA-Z]/g,"")}function Y(t){return typeof t=="number"&&Number.isFinite(t)}function X(t,e){return Y(t)?t.toFixed(e):"Unknown"}function H(t,e){if(!Y(e))return t.dim(X(e,2).padStart(6));let o=e.toFixed(2).padStart(6);return e>=80?t.green(o):e>=50?t.yellow(o):t.red(o)}function Ce(t){let e=L(t),o={testFilesPass:0,testFilesFail:0,testsPass:0,testsFail:0,testsSkip:0,duration:0,heapMb:null,errors:[]},n=e.match(/Test Files\s+(.+)/);if(n){let f=n[1],a=f.match(/(\d+)\s+passed/),l=f.match(/(\d+)\s+failed/);a&&(o.testFilesPass=parseInt(a[1],10)),l&&(o.testFilesFail=parseInt(l[1],10))}let s=e.match(/^\s*Tests\s+(.+)$/m);if(s){let f=s[1],a=f.match(/(\d+)\s+passed/),l=f.match(/(\d+)\s+failed/),p=f.match(/(\d+)\s+skipped/);a&&(o.testsPass=parseInt(a[1],10)),l&&(o.testsFail=parseInt(l[1],10)),p&&(o.testsSkip=parseInt(p[1],10))}let r=e.match(/Duration\s+([\d.]+)s/);r&&(o.duration=parseFloat(r[1])*1e3);let c=e.match(/(\d+)\s*MB\s+heap\s+used/i);c&&(o.heapMb=parseInt(c[1],10));let u=t.indexOf("Failed Tests");if(u!==-1){let f=t.indexOf(`
2
+ Test Files`,u),a=f!==-1?t.substring(u,f):t.substring(u),l=/FAIL\s*(?:\x1B\[[0-9;]*[a-zA-Z]|\s)*tests\//g,p=[...a.matchAll(l)];for(let m=0;m<p.length;m++){let v=p[m].index,h=a.lastIndexOf(`
3
+ `,v),w=h===-1?0:h,$=m<p.length-1?p[m+1].index:a.length,g=a.lastIndexOf(`
4
+ `,$),x=g===-1?$:g,P=a.substring(w,x).trim();P&&o.errors.push(P)}}return o}function Re(t){let o=t.join(`
5
5
  `).split(`
6
- `),n=new Map,e=new Map;t.forEach((a,l)=>{if(a.includes("FAIL")&&a.includes("Config:")){e.set(a,l);let c=V(a).match(/^(.+Config:\s+)'*([^'>]+)'*(.+)$/);if(c){let[,f,p,$]=c,m=`${f.trim()}|||${$.trim()}`;n.has(m)||n.set(m,{lines:[],configs:[]}),n.get(m).lines.push(a),n.get(m).configs.push(p.replace(/'/g,""))}}});let r=new Set;for(let[,a]of n.entries())if(a.configs.length>1){for(let p=1;p<a.lines.length;p++){let $=e.get(a.lines[p]);r.add($)}let l=a.lines[0],u=`[${a.configs.map(p=>`'${p}'`).join(",")}]`,c=V(l).replace(/(Config:\s+)'*[^'>]+'*/,`$1${u}`),f=e.get(l);t[f]=c}return t.filter((a,l)=>!r.has(l)).join(`
7
- `)}function Ae({maxOldSpaceMb:s,conditions:o=[],base:t=process.env.NODE_OPTIONS??""}){let n=t;for(let e of o){let r=`--conditions=${e}`;n.includes(r)||(n=n?`${n} ${r}`:r)}if(s&&!n.includes("--max-old-space-size")){let e=`--max-old-space-size=${s}`;n=n?`${n} ${e}`:e}return n.trim()}function ke({maxOldSpaceMb:s,conditions:o=[],nodeEnv:t="development",extraEnv:n={}}){let e={...process.env};e.NODE_ENV||(e.NODE_ENV=t);let r=Ae({maxOldSpaceMb:s,conditions:o,base:e.NODE_OPTIONS??""});return r&&(e.NODE_OPTIONS=r),Object.assign(e,n),e}function et(s,o){return[s,...o?["--config",o]:[],"run"]}function ue(s,o){let{cwd:t,vitestBin:n,vitestConfig:e,maxOldSpaceMb:r,conditions:a=[],nodeEnv:l="development",vitestArgs:u=[],streamOutput:c=!0,excludePaths:f=[],extraEnv:p={}}=o;return new Promise($=>{let m=Date.now(),g=f.flatMap(S=>["--exclude",S]),E=[...et(n,e),...u,...g,s],v=ke({maxOldSpaceMb:r,conditions:a,nodeEnv:l,extraEnv:p}),x=Re(process.execPath,E,{cwd:t,stdio:["ignore","pipe","pipe"],env:v}),w="",I="";x.stdout?.on("data",S=>{w+=S.toString(),c&&process.stdout.write(S)}),x.stderr?.on("data",S=>{I+=S.toString(),c&&process.stderr.write(S)}),x.on("close",S=>{let O=Date.now()-m,L=`${w}
8
- ${I}`,T=Ie(L);$({file:s,code:S??1,duration:T.duration>0?T.duration:O,testFilesPass:T.testFilesPass,testFilesFail:T.testFilesFail,testsPass:T.testsPass,testsFail:T.testsFail,testsSkip:T.testsSkip,heapMb:T.heapMb,errors:T.errors,rawOutput:L})}),x.on("error",S=>{$({file:s,code:1,duration:Date.now()-m,testFilesPass:0,testFilesFail:1,testsPass:0,testsFail:0,testsSkip:0,heapMb:null,errors:[S.message],rawOutput:S.toString()})})})}function Mt(s){let{cwd:o,vitestBin:t,vitestConfig:n,maxOldSpaceMb:e,conditions:r=[],nodeEnv:a="development",vitestArgs:l=[]}=s;return new Promise(u=>{let c=[...et(t,n),...l],f=ke({maxOldSpaceMb:e,conditions:r,nodeEnv:a}),p=Re(process.execPath,c,{cwd:o,stdio:"inherit",env:f});p.on("close",$=>u($??1)),p.on("error",()=>u(1))})}function je(s,o){let{cwd:t,vitestBin:n,vitestConfig:e,maxOldSpaceMb:r,conditions:a=[],nodeEnv:l="development",extraCoverageArgs:u=[],quietOutput:c=!1}=o;return new Promise(f=>{let p=e?["--config",e]:[],$=c?["--color"]:[],m=[n,...p,"--mergeReports",s,"--run","--coverage",...$,...u],g=ke({maxOldSpaceMb:r,conditions:a,nodeEnv:l}),E=Re(process.execPath,m,{cwd:t,stdio:c?["ignore","pipe","pipe"]:"inherit",env:g}),v="",x="";c&&(E.stdout?.on("data",w=>v+=w.toString()),E.stderr?.on("data",w=>x+=w.toString())),E.on("close",w=>f({exitCode:w??1,output:`${v}
9
- ${x}`})),E.on("error",()=>f({exitCode:1,output:""}))})}import W from"chalk";function Y(s){let o=Math.max(0,Math.floor(s/1e3)),t=Math.floor(o/3600),n=Math.floor(o%3600/60),e=o%60;return t>0?`${t}:${n.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`:`${n}:${e.toString().padStart(2,"0")}`}function Ne(s){let o=!!process.stdout.isTTY,t=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],n=26,e=Date.now(),r=0,a=0,l=0,u=0,c=0,f=0,p=null;function $(){let v=s===0?100:r/s*100,x=Date.now()-e,I=(r>0?x/r:0)*Math.max(s-r,0),S=Math.round(v/100*n),O=t[u%t.length],L=`[${"=".repeat(S)}${"-".repeat(Math.max(0,n-S))}]`,T=v.toFixed(1).padStart(5);return v<30?T=W.red(T+"%"):v<70?T=W.rgb(255,136,0)(T+"%"):v>99?T=W.green(T+"%"):T=W.yellow(T+"%"),o?`${W.green(O)} ${W.green(L)} ${W.bold(T)} ${r}/${s} | active ${a} | failed ${l} | ETA ${Y(I)} | elapsed ${Y(x)}`:`progress ${v.toFixed(1)}% ${r}/${s} | active ${a} | failed ${l} | eta ${Y(I)} | elapsed ${Y(x)}`}function m(v=!1){let x=$();if(u++,o){let I=x.replace(/\x1B\[[0-9;]*[a-zA-Z]/g,"").length;c=Math.max(c,I),process.stdout.write(`\r${x.padEnd(c," ")}`);return}let w=Date.now();(v||w-f>=2e3)&&(console.log(x),f=w)}function g(){!o||p||(p=setInterval(()=>{r>=s&&a===0||m()},120),p.unref?.())}function E(){p&&(clearInterval(p),p=null)}return m(!0),g(),{onStart(){a++,m()},onComplete(v){a=Math.max(0,a-1),r++,v&&l++,m(!0)},finish(){E(),m(!0),o&&process.stdout.write(`
10
- `)}}}var Le={onStart(){},onComplete(s){},finish(){}};import tt from"fs/promises";import X from"path";import M from"chalk";function _e(s){if(s.length!==0){console.log(`
11
- ${"=".repeat(80)}`),console.log(M.bold.red("\u2716 FAILED TEST FILES (VERBOSE OUTPUT)")),console.log("=".repeat(80));for(let o of s)console.log(`
12
- ${M.red("\u2716")} ${M.red(o.file)} ${M.dim(`(exit ${o.code})`)}`),o.rawOutput?.trim()?console.log(o.rawOutput.trimEnd()):console.log(M.dim("(no child output captured)"));console.log(`
13
- ${"=".repeat(80)}`)}}function Be(s,o){if(s===0){let t="% Coverage report from v8",n=o.split(`
14
- `),e=n.findIndex(r=>V(r).includes(t));if(e>=0){let r=n.length;for(let l=e+1;l<n.length;l++){let u=V(n[l]).trimStart();if(u.startsWith("stderr |")||u.startsWith("stdout |")){r=l;break}}if(n.slice(e+1,r).join(`
15
- `).trimEnd()){let l=n.slice(e,r).join(`
6
+ `),n=new Map,s=new Map;o.forEach((c,u)=>{if(c.includes("FAIL")&&c.includes("Config:")){s.set(c,u);let a=L(c).match(/^(.+Config:\s+)'*([^'>]+)'*(.+)$/);if(a){let[,l,p,m]=a,v=`${l.trim()}|||${m.trim()}`;n.has(v)||n.set(v,{lines:[],configs:[]}),n.get(v).lines.push(c),n.get(v).configs.push(p.replace(/'/g,""))}}});let r=new Set;for(let[,c]of n.entries())if(c.configs.length>1){for(let p=1;p<c.lines.length;p++){let m=s.get(c.lines[p]);r.add(m)}let u=c.lines[0],f=`[${c.configs.map(p=>`'${p}'`).join(",")}]`,a=L(u).replace(/(Config:\s+)'*[^'>]+'*/,`$1${f}`),l=s.get(u);o[l]=a}return o.filter((c,u)=>!r.has(u)).join(`
7
+ `)}function ke({maxOldSpaceMb:t,conditions:e=[],base:o=process.env.NODE_OPTIONS??""}){let n=o;for(let s of e){let r=`--conditions=${s}`;n.includes(r)||(n=n?`${n} ${r}`:r)}if(t&&!n.includes("--max-old-space-size")){let s=`--max-old-space-size=${t}`;n=n?`${n} ${s}`:s}return n.trim()}function Ne({maxOldSpaceMb:t,conditions:e=[],nodeEnv:o="development",extraEnv:n={}}){let s={...process.env};s.NODE_ENV||(s.NODE_ENV=o);let r=ke({maxOldSpaceMb:t,conditions:e,base:s.NODE_OPTIONS??""});return r&&(s.NODE_OPTIONS=r),Object.assign(s,n),s}function st(t,e){return[t,...e?["--config",e]:[],"run"]}function ge(t,e){let{cwd:o,vitestBin:n,vitestConfig:s,maxOldSpaceMb:r,conditions:c=[],nodeEnv:u="development",vitestArgs:f=[],streamOutput:a=!0,excludePaths:l=[],extraEnv:p={}}=e;return new Promise(m=>{let v=Date.now(),h=l.flatMap(E=>["--exclude",E]),w=[...st(n,s),...f,...h,t],$=Ne({maxOldSpaceMb:r,conditions:c,nodeEnv:u,extraEnv:p}),g=je(process.execPath,w,{cwd:o,stdio:["ignore","pipe","pipe"],env:$}),x="",P="";g.stdout?.on("data",E=>{x+=E.toString(),a&&process.stdout.write(E)}),g.stderr?.on("data",E=>{P+=E.toString(),a&&process.stderr.write(E)}),g.on("close",E=>{let _=Date.now()-v,N=`${x}
8
+ ${P}`,T=Ce(N);m({file:t,code:E??1,duration:T.duration>0?T.duration:_,testFilesPass:T.testFilesPass,testFilesFail:T.testFilesFail,testsPass:T.testsPass,testsFail:T.testsFail,testsSkip:T.testsSkip,heapMb:T.heapMb,errors:T.errors,rawOutput:N})}),g.on("error",E=>{m({file:t,code:1,duration:Date.now()-v,testFilesPass:0,testFilesFail:1,testsPass:0,testsFail:0,testsSkip:0,heapMb:null,errors:[E.message],rawOutput:E.toString()})})})}function Dt(t){let{cwd:e,vitestBin:o,vitestConfig:n,maxOldSpaceMb:s,conditions:r=[],nodeEnv:c="development",vitestArgs:u=[]}=t;return new Promise(f=>{let a=[...st(o,n),...u],l=Ne({maxOldSpaceMb:s,conditions:r,nodeEnv:c}),p=je(process.execPath,a,{cwd:e,stdio:"inherit",env:l});p.on("close",m=>f(m??1)),p.on("error",()=>f(1))})}function Le(t,e){let{cwd:o,vitestBin:n,vitestConfig:s,maxOldSpaceMb:r,conditions:c=[],nodeEnv:u="development",extraCoverageArgs:f=[],quietOutput:a=!1}=e;return new Promise(l=>{let p=s?["--config",s]:[],m=a?["--color"]:[],v=[n,...p,"--mergeReports",t,"--run","--coverage",...m,...f],h=Ne({maxOldSpaceMb:r,conditions:c,nodeEnv:u}),w=je(process.execPath,v,{cwd:o,stdio:a?["ignore","pipe","pipe"]:"inherit",env:h}),$="",g="";a&&(w.stdout?.on("data",x=>$+=x.toString()),w.stderr?.on("data",x=>g+=x.toString())),w.on("close",x=>l({exitCode:x??1,output:`${$}
9
+ ${g}`})),w.on("error",()=>l({exitCode:1,output:""}))})}import W from"chalk";function ee(t){let e=Math.max(0,Math.floor(t/1e3)),o=Math.floor(e/3600),n=Math.floor(e%3600/60),s=e%60;return o>0?`${o}:${n.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`:`${n}:${s.toString().padStart(2,"0")}`}function _e(t){let e=!!process.stdout.isTTY,o=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],n=26,s=Date.now(),r=0,c=0,u=0,f=0,a=0,l=0,p=null;function m(){let $=t===0?100:r/t*100,g=Date.now()-s,P=(r>0?g/r:0)*Math.max(t-r,0),E=Math.round($/100*n),_=o[f%o.length],N=`[${"=".repeat(E)}${"-".repeat(Math.max(0,n-E))}]`,T=$.toFixed(1).padStart(5);return $<30?T=W.red(T+"%"):$<70?T=W.rgb(255,136,0)(T+"%"):$>99?T=W.green(T+"%"):T=W.yellow(T+"%"),e?`${W.green(_)} ${W.green(N)} ${W.bold(T)} ${r}/${t} | active ${c} | failed ${u} | ETA ${ee(P)} | elapsed ${ee(g)}`:`progress ${$.toFixed(1)}% ${r}/${t} | active ${c} | failed ${u} | eta ${ee(P)} | elapsed ${ee(g)}`}function v($=!1){let g=m();if(f++,e){let P=g.replace(/\x1B\[[0-9;]*[a-zA-Z]/g,"").length;a=Math.max(a,P),process.stdout.write(`\r${g.padEnd(a," ")}`);return}let x=Date.now();($||x-l>=2e3)&&(console.log(g),l=x)}function h(){!e||p||(p=setInterval(()=>{r>=t&&c===0||v()},120),p.unref?.())}function w(){p&&(clearInterval(p),p=null)}return v(!0),h(),{onStart(){c++,v()},onComplete($){c=Math.max(0,c-1),r++,$&&u++,v(!0)},finish(){w(),v(!0),e&&process.stdout.write(`
10
+ `)}}}var Be={onStart(){},onComplete(t){},finish(){}};import nt from"fs/promises";import te from"path";import y from"chalk";function Ve(t){if(t.length!==0){console.log(`
11
+ ${"=".repeat(80)}`),console.log(y.bold.red("\u2716 FAILED TEST FILES (VERBOSE OUTPUT)")),console.log("=".repeat(80));for(let e of t)console.log(`
12
+ ${y.red("\u2716")} ${y.red(e.file)} ${y.dim(`(exit ${e.code})`)}`),e.rawOutput?.trim()?console.log(e.rawOutput.trimEnd()):console.log(y.dim("(no child output captured)"));console.log(`
13
+ ${"=".repeat(80)}`)}}function Ue(t,e){if(t===0){let o="% Coverage report from v8",n=e.split(`
14
+ `),s=n.findIndex(r=>L(r).includes(o));if(s>=0){let r=n.length;for(let u=s+1;u<n.length;u++){let f=L(n[u]).trimStart();if(f.startsWith("stderr |")||f.startsWith("stdout |")){r=u;break}}if(n.slice(s+1,r).join(`
15
+ `).trimEnd()){let u=n.slice(s,r).join(`
16
16
  `).trimEnd();console.log(`
17
- ${l}
18
- `)}}}else{let t=o.trimEnd();t&&console.error(t)}}function Tt(s){let o=(n,e)=>e===0?100:parseFloat((n/e*100).toFixed(2)),t={total:{statements:{total:0,covered:0,pct:0},branches:{total:0,covered:0,pct:0},functions:{total:0,covered:0,pct:0},lines:{total:0,covered:0,pct:0}}};for(let[n,e]of Object.entries(s)){let r=Object.keys(e.s??{}),a=r.length,l=r.filter(v=>e.s[v]>0).length,u=Object.keys(e.f??{}),c=u.length,f=u.filter(v=>e.f[v]>0).length,p=0,$=0;for(let v of Object.values(e.b??{}))p+=v.length,$+=v.filter(x=>x>0).length;let m=new Set,g=new Set;for(let[v,x]of Object.entries(e.statementMap??{})){let w=x?.start?.line;w!=null&&(g.add(w),(e.s??{})[v]>0&&m.add(w))}let E={statements:{total:a,covered:l,pct:o(l,a)},branches:{total:p,covered:$,pct:o($,p)},functions:{total:c,covered:f,pct:o(f,c)},lines:{total:g.size,covered:m.size,pct:o(m.size,g.size)}};t[n]=E;for(let v of["statements","branches","functions","lines"])t.total[v].total+=E[v].total,t.total[v].covered+=E[v].covered}for(let n of["statements","branches","functions","lines"]){let{total:e,covered:r}=t.total[n];t.total[n].pct=o(r,e)}return t}async function Ve(s,o,t=10,n={}){let{silent:e=!1}=n,r=X.resolve(s,"coverage"),a=o.find(g=>g.startsWith("--coverage.reportsDirectory="));if(a){let g=a.split("=").slice(1).join("=");r=X.isAbsolute(g)?g:X.resolve(s,g)}let l;try{let g=await tt.readFile(X.join(r,"coverage-summary.json"),"utf8");l=JSON.parse(g)}catch{try{let g=await tt.readFile(X.join(r,"coverage-final.json"),"utf8");l=Tt(JSON.parse(g))}catch{return e||console.log(M.dim(" (no coverage JSON found \u2014 skipping summary)")),null}}let{total:u,...c}=l;if(t>0){let g=Object.entries(c).map(([S,O])=>({file:X.relative(s,S),lines:O.lines?.pct??0,stmts:O.statements?.pct??0,fns:O.functions?.pct??0,branches:O.branches?.pct??0})).filter(S=>Math.min(S.lines,S.stmts,S.fns,S.branches)<100).sort((S,O)=>Math.min(S.lines,S.stmts,S.fns,S.branches)-Math.min(O.lines,O.stmts,O.fns,O.branches)),E=g.slice(0,t);e||(console.log(`
19
- `+M.bold("\u{1F4C9} WORST COVERAGE FILES (lowest metric)")),console.log("-".repeat(80)),E.forEach(({file:S,lines:O,stmts:L,fns:T,branches:_})=>{let P=Math.min(O,L,T,_),ge=M.dim(`lines ${O.toFixed(0)}% | stmts ${L.toFixed(0)}% | fns ${T.toFixed(0)}% | branches ${_.toFixed(0)}%`);console.log(` ${N(M,P)}% ${M.dim(S)} ${ge}`)}),g.length>t&&console.log(M.dim(` ... and ${g.length-t} more files`)));let v=u.lines?.pct??0,x=u.statements?.pct??0,w=u.functions?.pct??0,I=u.branches?.pct??0;return e||console.log(`
20
- ${M.bold("Coverage")} ${N(M,v)}% lines ${M.dim("|")} ${N(M,x)}% statements ${M.dim("|")} ${N(M,w)}% functions ${M.dim("|")} ${N(M,I)}% branches`),{coverageDir:r,total:u,worstFiles:E,worstFilesShown:E.length,worstFilesTotal:g.length,summary:l}}let f=u.lines?.pct??0,p=u.statements?.pct??0,$=u.functions?.pct??0,m=u.branches?.pct??0;return e||console.log(`
21
- ${M.bold("Coverage")} ${N(M,f)}% lines ${M.dim("|")} ${N(M,p)}% statements ${M.dim("|")} ${N(M,$)}% functions ${M.dim("|")} ${N(M,m)}% branches`),{coverageDir:r,total:u,worstFiles:[],worstFilesShown:0,worstFilesTotal:0,summary:l}}import ie from"fs/promises";import ot from"fs";import ee from"path";var st="tmp/vitest-runner",Et=/^(\d+)-\d+$/;function yt(s){try{return process.kill(s,0),!0}catch(o){return o.code!=="ESRCH"}}function Pt(s){return String(s).replace(/[^a-zA-Z0-9_-]+/g,"-").slice(0,80)||"scratch"}async function nt(s,o){let t=ee.resolve(s,o),n;try{n=await ie.readdir(t,{withFileTypes:!0})}catch{return}for(let e of n){if(!e.isDirectory())continue;let r=e.name.match(Et);if(!r)continue;let a=parseInt(r[1],10);yt(a)||await ie.rm(ee.join(t,e.name),{recursive:!0,force:!0}).catch(()=>{})}}async function rt(s,o){let t=ee.resolve(s,o),n=ee.join(t,`${process.pid}-${Date.now()}`);return await ie.mkdir(n,{recursive:!0}),n}async function ze(s,o){let t=ee.join(s,`worker-${o}`);return await ie.mkdir(t,{recursive:!0}),t}async function it(s){await ie.rm(s,{recursive:!0,force:!0}).catch(()=>{})}function ct(s){try{ot.rmSync(s,{recursive:!0,force:!0})}catch{}}function Ot(s){let o=process.env.VITEST_RUNNER_TMP;if(!o)throw new Error("makeRunTmpDir() requires VITEST_RUNNER_TMP to be set \u2014 call it from a test file run by vitest-runner.");return ot.mkdtempSync(ee.join(o,`${Pt(s)}-`))}function at(s,o,t){let n=s.replace(/\\/g,"/"),e;for(let{pattern:r,heapMb:a}of t)if(n.includes(r)){e=a;break}if(!(e===void 0&&o===void 0))return e===void 0?o:o===void 0?e:Math.max(e,o)}async function $o(s){let o=s.cwd??process.cwd(),t=s.scratchDir??st,n=s.keepTmp??!1;await nt(o,t);let e=await rt(o,t),r=()=>{ct(e),process.exitCode=130,process.exit()};n||(process.once("SIGINT",r),process.once("SIGTERM",r));try{return await Dt(s,e)}finally{process.removeListener("SIGINT",r),process.removeListener("SIGTERM",r),n||await it(e)}}async function Dt(s,o){let{cwd:t=process.cwd(),testDir:n,testPatterns:e=[],testListFile:r,testFilePattern:a,vitestArgs:l=[],showErrorDetails:u=!0,coverageQuiet:c=!1,suppressFileOutput:f=!1,suppressPassingFiles:p=!1,topSummary:$=!0,json:m=!1,workers:g=parseInt(process.env.VITEST_WORKERS??"4",10),worstCoverageCount:E=10,blobsDir:v,mergeReports:x=!0,earlyRunPatterns:w=[],perFileHeapOverrides:I=[],conditions:S=[],nodeEnv:O="development",_testResultsOverride:L=null}=s,T=0,_=s.maxOldSpaceMb??(process.env.VITEST_HEAP_MB?parseInt(process.env.VITEST_HEAP_MB,10):void 0),P=!m,ge=ye(t,"vitest","vitest"),lt=await Pe(t,s.vitestConfig),me={cwd:t,vitestBin:ge,vitestConfig:lt,conditions:S,nodeEnv:O},A=[...l];if(c&&!A.some(i=>i==="--coverage"||i.startsWith("--coverage."))&&A.unshift("--coverage"),A.some(i=>i==="--coverage"||i.startsWith("--coverage."))){let i=de.resolve(t,v??".vitest-coverage-blobs"),d=de.resolve(t,".vitest-coverage-tmp");await Promise.all([q.rm(i,{recursive:!0,force:!0}),q.rm(d,{recursive:!0,force:!0})]),await Promise.all([q.mkdir(i,{recursive:!0}),q.mkdir(d,{recursive:!0})]);let b=await fe({cwd:t,testDir:n,testPatterns:e,testListFile:r,testFilePattern:a,earlyRunPatterns:w}),D=De(b);if(b.length===0){let F=e.length>0?`\u274C No Vitest test files found matching: ${e.join(", ")}`:"\u274C No Vitest test files found";return P&&console.log(F),m?{exitCode:1,mode:"coverage",message:F,options:{cwd:t,testDir:n,testPatterns:e,testListFile:r,workers:g,coverageQuiet:c,suppressFileOutput:f,suppressPassingFiles:p,topSummary:$,vitestArgs:A}}:1}let k=A.filter(F=>F!=="--coverage"&&F.startsWith("--coverage.")),Fe=A.filter(F=>F!=="--coverage"&&!F.startsWith("--coverage.")),ne=b.filter(F=>w.some(y=>F.replace(/\\/g,"/").includes(y))),Se=b.filter(F=>!w.some(y=>F.replace(/\\/g,"/").includes(y))),be=c||f||m,ht=c&&!m;!c&&!f&&P&&(console.log(`
22
- \u{1F9EA} Running ${b.length} test files for coverage (blob + merge mode)`),console.log(`\u2699\uFE0F Workers: ${g} (${ne.length} solo first, then parallel)`),_&&console.log(`\u{1F9E0} Heap limit: ${_} MB`),console.log(""));let xe=ht?Ne(b.length):Le,B=[],we=0,Qe=async F=>{let y=de.join(i,`run-${we}.blob`);we++,!be&&P&&(console.log(`
23
- ${"=".repeat(80)}`),console.log(`\u25B6\uFE0F ${F}`),console.log("=".repeat(80))),xe.onStart();let U=de.join(d,`run-${we}`),vt=[...Fe,"--coverage",`--coverage.reportsDirectory=${U}`,"--reporter=default","--reporter=blob",`--outputFile=${y}`],$t=await ze(o,T++),H=await ue(F,{...me,maxOldSpaceMb:at(F,_,I),vitestArgs:vt,streamOutput:!be,excludePaths:D.get(F),extraEnv:{VITEST_RUNNER_TMP:$t}});if(B.push(H),xe.onComplete(H.code!==0),!be&&P){let Ye=(H.duration/1e3).toFixed(2);if(H.code===0){let Ft=H.heapMb?` | ${H.heapMb} MB heap`:"";console.log(`
24
- \u2705 PASSED (${Ye}s${Ft})
17
+ ${u}
18
+ `)}}}else{let o=e.trimEnd();o&&console.error(o)}}function It(t){let e=(s,r)=>r===0?100:parseFloat((s/r*100).toFixed(2)),o={total:{statements:{total:0,covered:0,pct:0},branches:{total:0,covered:0,pct:0},functions:{total:0,covered:0,pct:0},lines:{total:0,covered:0,pct:0}}};for(let[s,r]of Object.entries(t)){let c=Object.keys(r.s??{}),u=c.length,f=c.filter(g=>r.s[g]>0).length,a=Object.keys(r.f??{}),l=a.length,p=a.filter(g=>r.f[g]>0).length,m=0,v=0;for(let g of Object.values(r.b??{}))m+=g.length,v+=g.filter(x=>x>0).length;let h=new Set,w=new Set;for(let[g,x]of Object.entries(r.statementMap??{})){let P=x?.start?.line;P!=null&&(w.add(P),(r.s??{})[g]>0&&h.add(P))}let $={statements:{total:u,covered:f,pct:e(f,u)},branches:{total:m,covered:v,pct:e(v,m)},functions:{total:l,covered:p,pct:e(p,l)},lines:{total:w.size,covered:h.size,pct:e(h.size,w.size)}};o[s]=$;for(let g of["statements","branches","functions","lines"])o.total[g].total+=$[g].total,o.total[g].covered+=$[g].covered}let n=Object.keys(t).length>0;for(let s of["statements","branches","functions","lines"]){let{total:r,covered:c}=o.total[s];o.total[s].pct=n?e(c,r):"Unknown"}return o}function At({lines:t,stmts:e,fns:o,branches:n}){let s=[t,e,o,n].filter(Y);return s.length>0?Math.min(...s):null}function rt(t){return t??Number.MAX_VALUE}function Ct({lines:t,stmts:e,fns:o,branches:n}){return![t,e,o,n].every(Y)}function Rt({lines:t,stmts:e,fns:o,branches:n}){console.log(`
19
+ ${y.bold("Coverage")} ${H(y,t)}% lines ${y.dim("|")} ${H(y,e)}% statements ${y.dim("|")} ${H(y,o)}% functions ${y.dim("|")} ${H(y,n)}% branches`)}async function ze(t,e,o=10,n={}){let{silent:s=!1}=n,r=te.resolve(t,"coverage"),c=e.find(h=>h.startsWith("--coverage.reportsDirectory="));if(c){let h=c.split("=").slice(1).join("=");r=te.isAbsolute(h)?h:te.resolve(t,h)}let u;try{let h=await nt.readFile(te.join(r,"coverage-summary.json"),"utf8");u=JSON.parse(h)}catch{try{let h=await nt.readFile(te.join(r,"coverage-final.json"),"utf8");u=It(JSON.parse(h))}catch{return s||console.log(y.dim(" (no coverage JSON found \u2014 skipping summary)")),null}}let{total:f,...a}=u,l={lines:f.lines?.pct??0,stmts:f.statements?.pct??0,fns:f.functions?.pct??0,branches:f.branches?.pct??0},p=Object.keys(a).length===0&&!Object.values(l).some(Y),m=[],v=0;if(o>0){let h=Object.entries(a).map(([$,g])=>({file:te.relative(t,$),lines:g.lines?.pct??0,stmts:g.statements?.pct??0,fns:g.functions?.pct??0,branches:g.branches?.pct??0})).map($=>({row:$,worst:At($)})).filter(({row:$,worst:g})=>Ct($)||g<100).sort(($,g)=>rt($.worst)-rt(g.worst)),w=h.slice(0,o);s||(console.log(`
20
+ `+y.bold("\u{1F4C9} WORST COVERAGE FILES (lowest metric)")),console.log("-".repeat(80)),w.forEach(({row:{file:$,lines:g,stmts:x,fns:P,branches:E},worst:_})=>{let N=y.dim(`lines ${X(g,0)}% | stmts ${X(x,0)}% | fns ${X(P,0)}% | branches ${X(E,0)}%`);console.log(` ${H(y,_)}% ${y.dim($)} ${N}`)}),h.length>o&&console.log(y.dim(` ... and ${h.length-o} more files`))),m=w.map(({row:$})=>$),v=h.length}return s||(Rt(l),p&&console.log(y.dim(" No files were measured (the coverage include matched nothing), so every percentage is Unknown and coverage thresholds are skipped."))),{coverageDir:r,total:f,noFilesMeasured:p,worstFiles:m,worstFilesShown:m.length,worstFilesTotal:v,summary:u}}import ae from"fs/promises";import it from"fs";import oe from"path";var ct="tmp/vitest-runner",kt=/^(\d+)-\d+$/;function jt(t){try{return process.kill(t,0),!0}catch(e){return e.code!=="ESRCH"}}function Nt(t){return String(t).replace(/[^a-zA-Z0-9_-]+/g,"-").slice(0,80)||"scratch"}async function at(t,e){let o=oe.resolve(t,e),n;try{n=await ae.readdir(o,{withFileTypes:!0})}catch{return}for(let s of n){if(!s.isDirectory())continue;let r=s.name.match(kt);if(!r)continue;let c=parseInt(r[1],10);jt(c)||await ae.rm(oe.join(o,s.name),{recursive:!0,force:!0}).catch(()=>{})}}async function lt(t,e){let o=oe.resolve(t,e),n=oe.join(o,`${process.pid}-${Date.now()}`);return await ae.mkdir(n,{recursive:!0}),n}async function He(t,e){let o=oe.join(t,`worker-${e}`);return await ae.mkdir(o,{recursive:!0}),o}async function ft(t){await ae.rm(t,{recursive:!0,force:!0}).catch(()=>{})}function pt(t){try{it.rmSync(t,{recursive:!0,force:!0})}catch{}}function Lt(t){let e=process.env.VITEST_RUNNER_TMP;if(!e)throw new Error("makeRunTmpDir() requires VITEST_RUNNER_TMP to be set \u2014 call it from a test file run by vitest-runner.");return it.mkdtempSync(oe.join(e,`${Nt(t)}-`))}function ut(t,e,o){let n=t.replace(/\\/g,"/"),s;for(let{pattern:r,heapMb:c}of o)if(n.includes(r)){s=c;break}if(!(s===void 0&&e===void 0))return s===void 0?e:e===void 0?s:Math.max(s,e)}async function yo(t){let e=t.cwd??process.cwd(),o=t.scratchDir??ct,n=t.keepTmp??!1;await at(e,o);let s=await lt(e,o),r=()=>{pt(s),process.exitCode=130,process.exit()};n||(process.once("SIGINT",r),process.once("SIGTERM",r));try{return await _t(t,s)}finally{process.removeListener("SIGINT",r),process.removeListener("SIGTERM",r),n||await ft(s)}}async function _t(t,e){let{cwd:o=process.cwd(),testDir:n,testPatterns:s=[],testListFile:r,testFilePattern:c,vitestArgs:u=[],showErrorDetails:f=!0,coverageQuiet:a=!1,suppressFileOutput:l=!1,suppressPassingFiles:p=!1,topSummary:m=!0,json:v=!1,workers:h=parseInt(process.env.VITEST_WORKERS??"4",10),worstCoverageCount:w=10,blobsDir:$,mergeReports:g=!0,earlyRunPatterns:x=[],exclude:P=[],perFileHeapOverrides:E=[],conditions:_=[],nodeEnv:N="development",_testResultsOverride:T=null}=t,We=0,B=t.maxOldSpaceMb??(process.env.VITEST_HEAP_MB?parseInt(process.env.VITEST_HEAP_MB,10):void 0),O=!v,dt=Pe(o,"vitest","vitest"),gt=await Oe(o,t.vitestConfig),he={cwd:o,vitestBin:dt,vitestConfig:gt,conditions:_,nodeEnv:N},A=[...u];if(a&&!A.some(i=>i==="--coverage"||i.startsWith("--coverage."))&&A.unshift("--coverage"),A.some(i=>i==="--coverage"||i.startsWith("--coverage."))){let i=me.resolve(o,$??".vitest-coverage-blobs"),d=me.resolve(o,".vitest-coverage-tmp");await Promise.all([K.rm(i,{recursive:!0,force:!0}),K.rm(d,{recursive:!0,force:!0})]),await Promise.all([K.mkdir(i,{recursive:!0}),K.mkdir(d,{recursive:!0})]);let F=await de({cwd:o,testDir:n,testPatterns:s,testListFile:r,testFilePattern:c,earlyRunPatterns:x,exclude:P}),D=Ae(F);if(F.length===0){let b=s.length>0?`\u274C No Vitest test files found matching: ${s.join(", ")}`:"\u274C No Vitest test files found";return O&&console.log(b),v?{exitCode:1,mode:"coverage",message:b,options:{cwd:o,testDir:n,testPatterns:s,testListFile:r,workers:h,coverageQuiet:a,suppressFileOutput:l,suppressPassingFiles:p,topSummary:m,vitestArgs:A}}:1}let k=A.filter(b=>b!=="--coverage"&&b.startsWith("--coverage.")),be=A.filter(b=>b!=="--coverage"&&!b.startsWith("--coverage.")),ie=F.filter(b=>x.some(M=>b.replace(/\\/g,"/").includes(M))),Fe=F.filter(b=>!x.some(M=>b.replace(/\\/g,"/").includes(M))),xe=a||l||v,Ft=a&&!v;!a&&!l&&O&&(console.log(`
21
+ \u{1F9EA} Running ${F.length} test files for coverage (blob + merge mode)`),console.log(`\u2699\uFE0F Workers: ${h} (${ie.length} solo first, then parallel)`),B&&console.log(`\u{1F9E0} Heap limit: ${B} MB`),console.log(""));let we=Ft?_e(F.length):Be,j=[],Te=0,Ye=async b=>{let M=me.join(i,`run-${Te}.blob`);Te++,!xe&&O&&(console.log(`
22
+ ${"=".repeat(80)}`),console.log(`\u25B6\uFE0F ${b}`),console.log("=".repeat(80))),we.onStart();let U=me.join(d,`run-${Te}`),xt=[...be,"--coverage",`--coverage.reportsDirectory=${U}`,"--reporter=default","--reporter=blob",`--outputFile=${M}`],wt=await He(e,We++),z=await ge(b,{...he,maxOldSpaceMb:ut(b,B,E),vitestArgs:xt,streamOutput:!xe,excludePaths:D.get(b),extraEnv:{VITEST_RUNNER_TMP:wt}});if(j.push(z),we.onComplete(z.code!==0),!xe&&O){let tt=(z.duration/1e3).toFixed(2);if(z.code===0){let Tt=z.heapMb?` | ${z.heapMb} MB heap`:"";console.log(`
23
+ \u2705 PASSED (${tt}s${Tt})
25
24
  `)}else console.log(`
26
- \u274C FAILED (exit code ${H.code}, ${Ye}s)
27
- `)}};for(let F of ne)await Qe(F).catch(y=>{P&&console.error(`Error running ${F}:`,y)});let Me=0,Z=new Set;for(;Me<Se.length||Z.size>0;){for(;Me<Se.length&&Z.size<g;){let F=Se[Me++],y=Qe(F).catch(U=>{P&&console.error(`Error running ${F}:`,U)}).finally(()=>Z.delete(y));Z.add(y)}Z.size>0&&await Promise.race(Z)}xe.finish();let Te=(await q.readdir(i).catch(()=>[])).filter(F=>F.endsWith(".blob"));if(Te.length===0){let F="\u274C No coverage blobs were generated \u2014 coverage report cannot be produced";return P&&console.error(F),m?{exitCode:1,mode:"coverage",message:F,options:{cwd:t,testDir:n,testPatterns:e,testListFile:r,workers:g,coverageQuiet:c,suppressFileOutput:f,suppressPassingFiles:p,topSummary:$,showErrorDetails:u,worstCoverageCount:E,vitestArgs:A},totals:{testFiles:b.length,failedFiles:B.filter(y=>y.code!==0).length,passedFiles:B.filter(y=>y.code===0).length},results:{all:B,failed:B.filter(y=>y.code!==0)},merge:{blobFiles:0,exitCode:1,output:""},coverageSummary:null}:1}let ae=0,Ee="",Ze=null;x&&(!c&&!f&&P&&(console.log(`
28
- ${"=".repeat(80)}`),console.log(`\u{1F4CA} Merging ${Te.length} coverage blobs into final report...`),console.log("=".repeat(80))),{exitCode:ae,output:Ee}=await je(i,{...me,maxOldSpaceMb:_,extraCoverageArgs:k,quietOutput:c||m}),c&&P&&Be(ae,Ee),Ze=await Ve(t,k,E,{silent:m})),await Promise.all([...x?[q.rm(i,{recursive:!0,force:!0}).catch(()=>{})]:[],q.rm(d,{recursive:!0,force:!0}).catch(()=>{})]);let re=B.filter(F=>F.code!==0);c&&P&&_e(re);let Ke=re.length>0?1:ae;if(m){let F=B.filter(y=>y.heapMb!==null);return{exitCode:Ke,mode:"coverage",options:{cwd:t,testDir:n,testPatterns:e,testListFile:r,workers:g,coverageQuiet:c,suppressFileOutput:f,suppressPassingFiles:p,topSummary:$,showErrorDetails:u,worstCoverageCount:E,vitestArgs:A},totals:{testFiles:b.length,failedFiles:re.length,passedFiles:B.length-re.length},results:{all:B,failed:re},merge:{blobFiles:Te.length,exitCode:ae,output:Ee},coverageSummary:Ze,...$?{topMemoryUsers:[...F].sort((y,U)=>U.heapMb-y.heapMb).slice(0,10),topDuration:[...B].sort((y,U)=>U.duration-y.duration).slice(0,10)}:{}}}return Ke}let G=await fe({cwd:t,testDir:n,testPatterns:e,testListFile:r,testFilePattern:a,earlyRunPatterns:w}),pt=De(G);if(G.length===0){let i=e.length>0?`\u274C No Vitest test files found matching: ${e.join(", ")}`:"\u274C No Vitest test files found";return P&&console.log(i),m?{exitCode:1,mode:"standard",message:i,options:{cwd:t,testDir:n,testPatterns:e,testListFile:r,workers:g,coverageQuiet:c,suppressFileOutput:f,suppressPassingFiles:p,topSummary:$,vitestArgs:A}}:1}let Ue=G.filter(i=>w.some(d=>i.replace(/\\/g,"/").includes(d))),he=G.filter(i=>!w.some(d=>i.replace(/\\/g,"/").includes(d))),ft=Date.now(),He=new Date().toLocaleTimeString("en-US",{hour12:!1});P&&!f&&e.length>0?console.log(`
29
- \u{1F9EA} Running ${G.length} test files matching: ${e.join(", ")}`):P&&!f&&console.log(`
30
- \u{1F9EA} Running ${G.length} test files (${Ue.length} solo first, then parallel)`),P&&!f&&(console.log(`\u2699\uFE0F Workers: ${g}`),_&&console.log(`\u{1F9E0} Heap limit: ${_} MB`),A.length>0&&console.log(`\u{1F527} Vitest args: ${A.join(" ")}`),console.log(""));let C=[...L??[]],We=async i=>{!f&&P&&(console.log(`
31
- ${"=".repeat(80)}`),console.log(`\u25B6\uFE0F ${i}`),console.log("=".repeat(80)));let d=await ze(o,T++),b=await ue(i,{...me,maxOldSpaceMb:at(i,_,I),vitestArgs:A,streamOutput:!f&&!m,excludePaths:pt.get(i),extraEnv:{VITEST_RUNNER_TMP:d}});if(!f&&P){let D=(b.duration/1e3).toFixed(2);if(b.code===0){let k=b.heapMb?` | ${b.heapMb} MB heap`:"";console.log(`
25
+ \u274C FAILED (exit code ${z.code}, ${tt}s)
26
+ `)}};for(let b of ie)await Ye(b).catch(M=>{O&&console.error(`Error running ${b}:`,M)});let Me=0,Q=new Set;for(;Me<Fe.length||Q.size>0;){for(;Me<Fe.length&&Q.size<h;){let b=Fe[Me++],M=Ye(b).catch(U=>{O&&console.error(`Error running ${b}:`,U)}).finally(()=>Q.delete(M));Q.add(M)}Q.size>0&&await Promise.race(Q)}we.finish();let Ee=(await K.readdir(i).catch(()=>[])).filter(b=>b.endsWith(".blob"));if(Ee.length===0){let b="\u274C No coverage blobs were generated \u2014 coverage report cannot be produced";return O&&console.error(b),v?{exitCode:1,mode:"coverage",message:b,options:{cwd:o,testDir:n,testPatterns:s,testListFile:r,workers:h,coverageQuiet:a,suppressFileOutput:l,suppressPassingFiles:p,topSummary:m,showErrorDetails:f,worstCoverageCount:w,vitestArgs:A},totals:{testFiles:F.length,failedFiles:j.filter(M=>M.code!==0).length,passedFiles:j.filter(M=>M.code===0).length},results:{all:j,failed:j.filter(M=>M.code!==0)},merge:{blobFiles:0,exitCode:1,output:""},coverageSummary:null}:1}let fe=0,ye="",Xe=null;g&&(!a&&!l&&O&&(console.log(`
27
+ ${"=".repeat(80)}`),console.log(`\u{1F4CA} Merging ${Ee.length} coverage blobs into final report...`),console.log("=".repeat(80))),{exitCode:fe,output:ye}=await Le(i,{...he,maxOldSpaceMb:B,extraCoverageArgs:k,quietOutput:a||v}),a&&O&&Ue(fe,ye),Xe=await ze(o,k,w,{silent:v})),await Promise.all([...g?[K.rm(i,{recursive:!0,force:!0}).catch(()=>{})]:[],K.rm(d,{recursive:!0,force:!0}).catch(()=>{})]);let ce=j.filter(b=>b.code!==0);a&&O&&Ve(ce);let et=ce.length>0?1:fe;if(v){let b=j.filter(M=>M.heapMb!==null);return{exitCode:et,mode:"coverage",options:{cwd:o,testDir:n,testPatterns:s,testListFile:r,workers:h,coverageQuiet:a,suppressFileOutput:l,suppressPassingFiles:p,topSummary:m,showErrorDetails:f,worstCoverageCount:w,vitestArgs:A},totals:{testFiles:F.length,failedFiles:ce.length,passedFiles:j.length-ce.length},results:{all:j,failed:ce},merge:{blobFiles:Ee.length,exitCode:fe,output:ye},coverageSummary:Xe,...m?{topMemoryUsers:[...b].sort((M,U)=>U.heapMb-M.heapMb).slice(0,10),topDuration:[...j].sort((M,U)=>U.duration-M.duration).slice(0,10)}:{}}}return et}let q=await de({cwd:o,testDir:n,testPatterns:s,testListFile:r,testFilePattern:c,earlyRunPatterns:x,exclude:P}),mt=Ae(q);if(q.length===0){let i=s.length>0?`\u274C No Vitest test files found matching: ${s.join(", ")}`:"\u274C No Vitest test files found";return O&&console.log(i),v?{exitCode:1,mode:"standard",message:i,options:{cwd:o,testDir:n,testPatterns:s,testListFile:r,workers:h,coverageQuiet:a,suppressFileOutput:l,suppressPassingFiles:p,topSummary:m,vitestArgs:A}}:1}let Ke=q.filter(i=>x.some(d=>i.replace(/\\/g,"/").includes(d))),ve=q.filter(i=>!x.some(d=>i.replace(/\\/g,"/").includes(d))),ht=Date.now(),qe=new Date().toLocaleTimeString("en-US",{hour12:!1});O&&!l&&s.length>0?console.log(`
28
+ \u{1F9EA} Running ${q.length} test files matching: ${s.join(", ")}`):O&&!l&&console.log(`
29
+ \u{1F9EA} Running ${q.length} test files (${Ke.length} solo first, then parallel)`),O&&!l&&(console.log(`\u2699\uFE0F Workers: ${h}`),B&&console.log(`\u{1F9E0} Heap limit: ${B} MB`),A.length>0&&console.log(`\u{1F527} Vitest args: ${A.join(" ")}`),console.log(""));let I=[...T??[]],Ge=async i=>{!l&&O&&(console.log(`
30
+ ${"=".repeat(80)}`),console.log(`\u25B6\uFE0F ${i}`),console.log("=".repeat(80)));let d=await He(e,We++),F=await ge(i,{...he,maxOldSpaceMb:ut(i,B,E),vitestArgs:A,streamOutput:!l&&!v,excludePaths:mt.get(i),extraEnv:{VITEST_RUNNER_TMP:d}});if(!l&&O){let D=(F.duration/1e3).toFixed(2);if(F.code===0){let k=F.heapMb?` | ${F.heapMb} MB heap`:"";console.log(`
32
31
  \u2705 PASSED (${D}s${k})
33
32
  `)}else console.log(`
34
- \u274C FAILED (exit code ${b.code}, ${D}s)
35
- `)}return b};if(!L){for(let b of Ue){let D=await We(b).catch(k=>(P&&console.error(`Error running ${b}:`,k),null));D&&C.push(D)}let i=0,d=new Set;for(;i<he.length||d.size>0;){for(;i<he.length&&d.size<g;){let b=he[i++],D=We(b).then(k=>C.push(k)).catch(k=>{P&&console.error(`Error running ${b}:`,k)}).finally(()=>d.delete(D));d.add(D)}d.size>0&&await Promise.race(d)}}let J=C.reduce((i,d)=>i+d.testFilesPass,0),z=C.reduce((i,d)=>i+d.testFilesFail,0),te=C.reduce((i,d)=>i+d.testsPass,0),oe=C.reduce((i,d)=>i+d.testsFail,0),se=C.reduce((i,d)=>i+(d.testsSkip||0),0),ut=C.reduce((i,d)=>i+d.duration,0),Q=C.filter(i=>i.code!==0),ce=C.filter(i=>i.code===0),dt=Q.length>0?1:0,qe=process.memoryUsage(),ve=Math.round(qe.heapUsed/1024/1024),$e=Math.round(qe.rss/1024/1024),R=C.filter(i=>i.heapMb!==null),Ge=((Date.now()-ft)/1e3).toFixed(2),Je=(ut/1e3).toFixed(2);if(m)return{exitCode:dt,mode:"standard",options:{cwd:t,testDir:n,testPatterns:e,testListFile:r,workers:g,coverageQuiet:c,suppressFileOutput:f,suppressPassingFiles:p,topSummary:$,showErrorDetails:u,worstCoverageCount:E,vitestArgs:A},totals:{testFilesPass:J,testFilesFail:z,testsPass:te,testsFail:oe,testsSkip:se,totalTests:te+oe+se},timing:{startAt:He,wallClockSeconds:Number(Ge),testsSeconds:Number(Je)},heap:{scriptHeapMb:ve,scriptRssMb:$e,maxHeapMb:R.length>0?Math.max(...R.map(i=>i.heapMb)):null,avgHeapMb:R.length>0?Number((R.reduce((i,d)=>i+d.heapMb,0)/R.length).toFixed(0)):null},results:{all:C,passed:ce,failed:Q},...$?{topMemoryUsers:[...R].sort((i,d)=>d.heapMb-i.heapMb).slice(0,10),topDuration:[...C].sort((i,d)=>d.duration-i.duration).slice(0,10)}:{}};console.log(`
36
- `+"=".repeat(80)),$&&R.length>0&&(console.log(`
37
- `+h.bold("\u{1F9E0} TOP MEMORY USERS")),console.log("-".repeat(80)),[...R].sort((i,d)=>d.heapMb-i.heapMb).slice(0,10).forEach(i=>{console.log(` ${String(i.heapMb).padStart(4)} MB ${h.dim(i.file)}`)})),$&&C.length>0&&(console.log(`
38
- `+h.bold("\u23F1\uFE0F TOP DURATION")),console.log("-".repeat(80)),[...C].sort((i,d)=>d.duration-i.duration).slice(0,10).forEach(i=>{let d=(i.duration/1e3).toFixed(2);console.log(` ${(d+"s").padStart(8)} ${h.dim(i.file)}`)})),ce.length>0&&!p&&(console.log(`
39
- `+"=".repeat(80)),console.log(h.bold.green("\u2713 PASSED TEST FILES")),console.log("=".repeat(80)),ce.forEach(i=>{let d=(i.duration/1e3).toFixed(2),b=[...i.heapMb?[`${i.heapMb} MB`]:[],`${d}s`],D=i.testsPass>0?` - ${i.testsPass} tests`:"";console.log(h.green(`\u2713 ${i.file}${D}`)+h.dim(` (${b.join(", ")})`))})),console.log(`
40
- `+h.bold("=".repeat(80))),Q.length>0&&(console.log(`
41
- \u274C ${Q.length} test file(s) failed`),console.log(h.bold.red(`
42
- Failed Test Files:`)),Q.forEach(i=>{let d=(i.duration/1e3).toFixed(2),b=[...i.testsFail>0?[h.red(`${i.testsFail} failed`)]:[],...i.testsPass>0?[h.green(`${i.testsPass} passed`)]:[],...i.testsSkip>0?[h.yellow(`${i.testsSkip} skipped`)]:[]],D=[...i.heapMb?[`${i.heapMb} MB`]:[],`${d}s`],k=b.length>0?` (${b.join(", ")})`:"";if(console.log(` ${h.red("\u2716")} ${i.file}${k}`+h.dim(` [${D.join(", ")}]`)),u&&i.errors.length>0){let Fe=Ce(i.errors).split(`
43
- `).map(ne=>ne.trim()?` ${ne}`:"").join(`
44
- `);console.log(Fe),console.log("")}}),console.log("")),console.log(h.bold("=".repeat(80))),z>0&&J>0?console.log(` ${h.bold("Test Files")} ${h.red(`${z} failed`)} ${h.dim("|")} ${h.green(`${J} passed`)} ${h.dim(`(${J+z})`)}`):z>0?console.log(` ${h.bold("Test Files")} ${h.red(`${z} failed`)} ${h.dim(`(${z})`)}`):console.log(` ${h.bold("Test Files")} ${h.green(`${J} passed`)} ${h.dim(`(${J})`)}`);let gt=te+oe+se,mt=[...oe>0?[h.red(`${oe} failed`)]:[],...te>0?[h.green(`${te} passed`)]:[],...se>0?[h.yellow(`${se} skipped`)]:[]];if(console.log(` ${h.bold("Tests")} ${mt.join(` ${h.dim("|")} `)} ${h.dim(`(${gt})`)}`),console.log(` ${h.bold("Start at")} ${He}`),console.log(` ${h.bold("Duration")} ${Ge}s ${h.dim(`(tests ${Je}s)`)}`),R.length>0){let i=Math.max(...R.map(b=>b.heapMb)),d=(R.reduce((b,D)=>b+D.heapMb,0)/R.length).toFixed(0);console.log(` ${h.bold("Heap")} max ${i} MB | avg ${d} MB | script ${ve} MB (RSS ${$e} MB)`)}else console.log(` ${h.bold("Heap")} script ${ve} MB (RSS ${$e} MB)`);return Q.length>0?1:(console.log(`
45
- \u2705 All ${ce.length} test files passed
46
- `),0)}export{Ae as buildNodeOptions,N as colourPct,Ne as createCoverageProgressTracker,Ce as deduplicateErrors,le as discoverFilesInDir,fe as discoverVitestFiles,Y as formatDuration,Ot as makeRunTmpDir,Le as noopProgressTracker,Ie as parseVitestOutput,Ve as printCoverageSummary,Be as printMergeOutput,_e as printQuietCoverageFailureDetails,ye as resolveBin,Pe as resolveVitestConfig,$o as run,je as runMergeReports,ue as runSingleFile,Mt as runVitestDirect,pe as sortWithPriority,V as stripAnsi};
33
+ \u274C FAILED (exit code ${F.code}, ${D}s)
34
+ `)}return F};if(!T){for(let F of Ke){let D=await Ge(F).catch(k=>(O&&console.error(`Error running ${F}:`,k),null));D&&I.push(D)}let i=0,d=new Set;for(;i<ve.length||d.size>0;){for(;i<ve.length&&d.size<h;){let F=ve[i++],D=Ge(F).then(k=>I.push(k)).catch(k=>{O&&console.error(`Error running ${F}:`,k)}).finally(()=>d.delete(D));d.add(D)}d.size>0&&await Promise.race(d)}}let G=I.reduce((i,d)=>i+d.testFilesPass,0),V=I.reduce((i,d)=>i+d.testFilesFail,0),se=I.reduce((i,d)=>i+d.testsPass,0),ne=I.reduce((i,d)=>i+d.testsFail,0),re=I.reduce((i,d)=>i+(d.testsSkip||0),0),vt=I.reduce((i,d)=>i+d.duration,0),J=I.filter(i=>i.code!==0),le=I.filter(i=>i.code===0),$t=J.length>0?1:0,Je=process.memoryUsage(),$e=Math.round(Je.heapUsed/1024/1024),Se=Math.round(Je.rss/1024/1024),R=I.filter(i=>i.heapMb!==null),Qe=((Date.now()-ht)/1e3).toFixed(2),Ze=(vt/1e3).toFixed(2);if(v)return{exitCode:$t,mode:"standard",options:{cwd:o,testDir:n,testPatterns:s,testListFile:r,workers:h,coverageQuiet:a,suppressFileOutput:l,suppressPassingFiles:p,topSummary:m,showErrorDetails:f,worstCoverageCount:w,vitestArgs:A},totals:{testFilesPass:G,testFilesFail:V,testsPass:se,testsFail:ne,testsSkip:re,totalTests:se+ne+re},timing:{startAt:qe,wallClockSeconds:Number(Qe),testsSeconds:Number(Ze)},heap:{scriptHeapMb:$e,scriptRssMb:Se,maxHeapMb:R.length>0?Math.max(...R.map(i=>i.heapMb)):null,avgHeapMb:R.length>0?Number((R.reduce((i,d)=>i+d.heapMb,0)/R.length).toFixed(0)):null},results:{all:I,passed:le,failed:J},...m?{topMemoryUsers:[...R].sort((i,d)=>d.heapMb-i.heapMb).slice(0,10),topDuration:[...I].sort((i,d)=>d.duration-i.duration).slice(0,10)}:{}};console.log(`
35
+ `+"=".repeat(80)),m&&R.length>0&&(console.log(`
36
+ `+S.bold("\u{1F9E0} TOP MEMORY USERS")),console.log("-".repeat(80)),[...R].sort((i,d)=>d.heapMb-i.heapMb).slice(0,10).forEach(i=>{console.log(` ${String(i.heapMb).padStart(4)} MB ${S.dim(i.file)}`)})),m&&I.length>0&&(console.log(`
37
+ `+S.bold("\u23F1\uFE0F TOP DURATION")),console.log("-".repeat(80)),[...I].sort((i,d)=>d.duration-i.duration).slice(0,10).forEach(i=>{let d=(i.duration/1e3).toFixed(2);console.log(` ${(d+"s").padStart(8)} ${S.dim(i.file)}`)})),le.length>0&&!p&&(console.log(`
38
+ `+"=".repeat(80)),console.log(S.bold.green("\u2713 PASSED TEST FILES")),console.log("=".repeat(80)),le.forEach(i=>{let d=(i.duration/1e3).toFixed(2),F=[...i.heapMb?[`${i.heapMb} MB`]:[],`${d}s`],D=i.testsPass>0?` - ${i.testsPass} tests`:"";console.log(S.green(`\u2713 ${i.file}${D}`)+S.dim(` (${F.join(", ")})`))})),console.log(`
39
+ `+S.bold("=".repeat(80))),J.length>0&&(console.log(`
40
+ \u274C ${J.length} test file(s) failed`),console.log(S.bold.red(`
41
+ Failed Test Files:`)),J.forEach(i=>{let d=(i.duration/1e3).toFixed(2),F=[...i.testsFail>0?[S.red(`${i.testsFail} failed`)]:[],...i.testsPass>0?[S.green(`${i.testsPass} passed`)]:[],...i.testsSkip>0?[S.yellow(`${i.testsSkip} skipped`)]:[]],D=[...i.heapMb?[`${i.heapMb} MB`]:[],`${d}s`],k=F.length>0?` (${F.join(", ")})`:"";if(console.log(` ${S.red("\u2716")} ${i.file}${k}`+S.dim(` [${D.join(", ")}]`)),f&&i.errors.length>0){let be=Re(i.errors).split(`
42
+ `).map(ie=>ie.trim()?` ${ie}`:"").join(`
43
+ `);console.log(be),console.log("")}}),console.log("")),console.log(S.bold("=".repeat(80))),V>0&&G>0?console.log(` ${S.bold("Test Files")} ${S.red(`${V} failed`)} ${S.dim("|")} ${S.green(`${G} passed`)} ${S.dim(`(${G+V})`)}`):V>0?console.log(` ${S.bold("Test Files")} ${S.red(`${V} failed`)} ${S.dim(`(${V})`)}`):console.log(` ${S.bold("Test Files")} ${S.green(`${G} passed`)} ${S.dim(`(${G})`)}`);let St=se+ne+re,bt=[...ne>0?[S.red(`${ne} failed`)]:[],...se>0?[S.green(`${se} passed`)]:[],...re>0?[S.yellow(`${re} skipped`)]:[]];if(console.log(` ${S.bold("Tests")} ${bt.join(` ${S.dim("|")} `)} ${S.dim(`(${St})`)}`),console.log(` ${S.bold("Start at")} ${qe}`),console.log(` ${S.bold("Duration")} ${Qe}s ${S.dim(`(tests ${Ze}s)`)}`),R.length>0){let i=Math.max(...R.map(F=>F.heapMb)),d=(R.reduce((F,D)=>F+D.heapMb,0)/R.length).toFixed(0);console.log(` ${S.bold("Heap")} max ${i} MB | avg ${d} MB | script ${$e} MB (RSS ${Se} MB)`)}else console.log(` ${S.bold("Heap")} script ${$e} MB (RSS ${Se} MB)`);return J.length>0?1:(console.log(`
44
+ \u2705 All ${le.length} test files passed
45
+ `),0)}export{ke as buildNodeOptions,H as colourPct,_e as createCoverageProgressTracker,Re as deduplicateErrors,pe as discoverFilesInDir,de as discoverVitestFiles,ee as formatDuration,Lt as makeRunTmpDir,Be as noopProgressTracker,Ce as parseVitestOutput,ze as printCoverageSummary,Ue as printMergeOutput,Ve as printQuietCoverageFailureDetails,Pe as resolveBin,Oe as resolveVitestConfig,yo as run,Le as runMergeReports,ge as runSingleFile,Dt as runVitestDirect,ue as sortWithPriority,L as stripAnsi};
47
46
  //# sourceMappingURL=index.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cldmv/vitest-runner",
3
- "version": "1.4.3",
3
+ "version": "1.5.0",
4
4
  "description": "Sequential Vitest runner to avoid OOM issues with large test suites",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -39,7 +39,7 @@
39
39
  "types:check": "tsc -p .configs/tsconfig.json --noEmit",
40
40
  "build": "tsup",
41
41
  "build:ci": "npm run lint && npm run format:check && npm run types:build && npm run build",
42
- "prepack": "node -e \"const fs=require('node:fs');const hasTsup=fs.existsSync('node_modules/.bin/tsup')||fs.existsSync('node_modules/.bin/tsup.cmd');if(hasTsup){require('node:child_process').execSync('npm run build',{stdio:'inherit'})}else if(!fs.existsSync('dist/index.mjs')){throw new Error('dist/ is missing and tsup is unavailable to build it (expected in a bare package-contents publish dir with a prebuilt dist/; unexpected anywhere else)')}\"",
42
+ "prepack": "npm run build",
43
43
  "fix:headers": "node tools/fix-headers.mjs"
44
44
  },
45
45
  "keywords": [
@@ -65,6 +65,10 @@ export type ParsedArgs = {
65
65
  * - Path substrings from `--solo-pattern <pattern>` (repeatable).
66
66
  */
67
67
  soloPatterns: string[];
68
+ /**
69
+ * - Directory / file globs from `--exclude <glob>` (repeatable), relative to `cwd`, that discovery never enters.
70
+ */
71
+ exclude: string[];
68
72
  /**
69
73
  * - Compiled regex from `--file-pattern <regex>`, or undefined.
70
74
  */
@@ -1,15 +1,34 @@
1
+ /**
2
+ * Test whether a cwd-relative path matches any of the given exclude globs.
3
+ * Callers checking a directory should also test the path with a trailing
4
+ * slash appended, so a pattern like `tmp/**` prunes the `tmp` directory
5
+ * itself rather than only the files found inside it.
6
+ *
7
+ * @param {string} relPath - Path relative to `cwd`, forward-slash-normalised.
8
+ * @param {string[]} excludePatterns - Glob patterns relative to `cwd`.
9
+ * @returns {boolean}
10
+ * @example
11
+ * isExcluded("tmp/worktree/a.test.vitest.mjs", ["tmp/**"]); // true
12
+ * isExcluded("tmp/", ["tmp/**"]); // true — prunes the directory itself
13
+ */
14
+ export function isExcluded(relPath: string, excludePatterns: string[]): boolean;
1
15
  /**
2
16
  * Recursively discover all Vitest test files under a directory.
3
- * Skips `node_modules` and hidden directories (names starting with `.`).
17
+ * Skips `node_modules` and hidden directories (names starting with `.`),
18
+ * plus any directory or file matching an `exclude` glob.
4
19
  *
5
20
  * @param {string} dir - Absolute path of the directory to scan.
6
21
  * @param {string} cwd - Project root used to compute relative paths.
7
22
  * @param {RegExp} [pattern=DEFAULT_TEST_FILE_PATTERN] - Regex tested against the file name.
23
+ * @param {string[]} [exclude=[]] - Directory / file globs, relative to `cwd`, that discovery never enters.
8
24
  * @returns {Promise<string[]>} Paths relative to `cwd`.
9
25
  * @example
10
26
  * const files = await discoverFilesInDir('/project/src/tests', '/project');
27
+ * @example
28
+ * // Skip scratch worktrees carrying their own copy of the suite
29
+ * const files = await discoverFilesInDir('/project', '/project', DEFAULT_TEST_FILE_PATTERN, ['tmp/**']);
11
30
  */
12
- export function discoverFilesInDir(dir: string, cwd: string, pattern?: RegExp): Promise<string[]>;
31
+ export function discoverFilesInDir(dir: string, cwd: string, pattern?: RegExp, exclude?: string[]): Promise<string[]>;
13
32
  /**
14
33
  * Sort test files alphabetically while hoisting files matching `earlyRunPatterns`
15
34
  * to the front (in pattern-declaration order, then alphabetically within each group).
@@ -52,6 +71,7 @@ export function computeFilterConflicts(files: string[]): Map<string, string[]>;
52
71
  * @property {string} [testListFile] - Path to a JSON array of test file paths to run instead of scanning.
53
72
  * @property {RegExp} [testFilePattern] - Regex to match file names (default: `DEFAULT_TEST_FILE_PATTERN`).
54
73
  * @property {string[]} [earlyRunPatterns=[]] - Path substrings for files that must run solo first.
74
+ * @property {string[]} [exclude=[]] - Directory / file globs, relative to `cwd`, that discovery never enters. Applies to both the default scan and partial-path pattern resolution.
55
75
  */
56
76
  /**
57
77
  * Discover Vitest test files according to the provided options.
@@ -95,4 +115,8 @@ export type DiscoverOptions = {
95
115
  * - Path substrings for files that must run solo first.
96
116
  */
97
117
  earlyRunPatterns?: string[];
118
+ /**
119
+ * - Directory / file globs, relative to `cwd`, that discovery never enters. Applies to both the default scan and partial-path pattern resolution.
120
+ */
121
+ exclude?: string[];
98
122
  };
@@ -25,6 +25,10 @@ export function printMergeOutput(exitCode: number, output: string): void;
25
25
  /**
26
26
  * Compute a coverage-summary-style object from a raw V8/Istanbul `coverage-final.json`.
27
27
  *
28
+ * Matches istanbul's own summary: a file with no entries for a metric counts as
29
+ * 100% for that metric, and when there are no files at all every total `pct` is
30
+ * the string `"Unknown"`.
31
+ *
28
32
  * @param {Record<string, object>} finalData - Parsed `coverage-final.json` contents.
29
33
  * @returns {{ total: object, [filePath: string]: object }} Istanbul coverage-summary format.
30
34
  */
@@ -39,6 +43,11 @@ export function computeSummaryFromFinal(finalData: Record<string, object>): {
39
43
  * Tries `coverage-summary.json` first; falls back to computing from
40
44
  * `coverage-final.json` if that is not present.
41
45
  *
46
+ * A non-numeric `pct` (istanbul reports `"Unknown"` when the coverage `include`
47
+ * matched no files) is printed as `Unknown` and never throws. When no files were
48
+ * measured at all, a note says so: there is nothing for a coverage threshold to
49
+ * measure, and vitest's own threshold check does not fail on an `Unknown` value.
50
+ *
42
51
  * @param {string} cwd - Project root (used to make absolute file paths relative).
43
52
  * @param {string[]} extraCoverageArgs - Passthrough `--coverage.*` args (checked for `reportsDirectory`).
44
53
  * @param {number} [worstCount=10] - Number of worst-coverage files to show (0 = skip table).
@@ -46,7 +55,8 @@ export function computeSummaryFromFinal(finalData: Record<string, object>): {
46
55
  * @returns {Promise<{
47
56
  * coverageDir: string,
48
57
  * total: object,
49
- * worstFiles: Array<{file: string, lines: number, stmts: number, fns: number, branches: number}>,
58
+ * noFilesMeasured: boolean,
59
+ * worstFiles: Array<{file: string, lines: number|string, stmts: number|string, fns: number|string, branches: number|string}>,
50
60
  * worstFilesShown: number,
51
61
  * worstFilesTotal: number,
52
62
  * summary: object
@@ -57,12 +67,13 @@ export function printCoverageSummary(cwd: string, extraCoverageArgs: string[], w
57
67
  }): Promise<{
58
68
  coverageDir: string;
59
69
  total: object;
70
+ noFilesMeasured: boolean;
60
71
  worstFiles: Array<{
61
72
  file: string;
62
- lines: number;
63
- stmts: number;
64
- fns: number;
65
- branches: number;
73
+ lines: number | string;
74
+ stmts: number | string;
75
+ fns: number | string;
76
+ branches: number | string;
66
77
  }>;
67
78
  worstFilesShown: number;
68
79
  worstFilesTotal: number;
@@ -102,6 +102,10 @@ export type RunOptions = {
102
102
  * - Path substrings — matching files run solo before the worker pool.
103
103
  */
104
104
  earlyRunPatterns?: string[];
105
+ /**
106
+ * - Directory / file globs, relative to `cwd`, that discovery never enters (e.g. `['tmp/**']`). Applies to both the default scan and partial-path pattern resolution.
107
+ */
108
+ exclude?: string[];
105
109
  /**
106
110
  * - Per-file minimum heap overrides.
107
111
  */
@@ -22,13 +22,39 @@
22
22
  * stripAnsi('\x1B[32mhello\x1B[0m'); // 'hello'
23
23
  */
24
24
  export function stripAnsi(text: string): string;
25
+ /**
26
+ * Check whether a coverage percentage is a real number.
27
+ *
28
+ * Istanbul reports a metric's `pct` as the string `"Unknown"` when nothing was
29
+ * measured (e.g. the coverage `include` matched no files), so a `pct` cannot be
30
+ * assumed to be numeric.
31
+ * @param {unknown} pct - Coverage percentage as read from a coverage summary.
32
+ * @returns {pct is number} `true` when `pct` is a finite number.
33
+ * @example
34
+ * isKnownPct(75.5); // true
35
+ * isKnownPct("Unknown"); // false
36
+ */
37
+ export function isKnownPct(pct: unknown): pct is number;
38
+ /**
39
+ * Format a coverage percentage with a fixed number of decimals, or `Unknown`
40
+ * when the value is not a number.
41
+ * @param {unknown} pct - Coverage percentage as read from a coverage summary.
42
+ * @param {number} digits - Decimal places for a numeric value.
43
+ * @returns {string} The formatted percentage (without a `%` sign).
44
+ * @example
45
+ * formatPct(75.5, 0); // '76'
46
+ * formatPct("Unknown", 0); // 'Unknown'
47
+ */
48
+ export function formatPct(pct: unknown, digits: number): string;
25
49
  /**
26
50
  * Colour-code a coverage percentage value using chalk.
27
- * ≥ 80 % → green, ≥ 50 % → yellow, < 50 % → red.
51
+ * ≥ 80 % → green, ≥ 50 % → yellow, < 50 % → red. A non-numeric value
52
+ * (istanbul's `"Unknown"`) is rendered as a dim `Unknown`.
28
53
  * @param {import('chalk').ChalkInstance} chalk - Chalk instance supplied by the caller.
29
- * @param {number} pct - Coverage percentage 0–100.
54
+ * @param {unknown} pct - Coverage percentage 0–100, or a non-numeric value such as `"Unknown"`.
30
55
  * @returns {string} Chalk-coloured, right-aligned percentage string.
31
56
  * @example
32
57
  * colourPct(chalk, 75.5); // yellow ' 75.50'
58
+ * colourPct(chalk, "Unknown"); // dim 'Unknown'
33
59
  */
34
- export function colourPct(chalk: import("chalk").ChalkInstance, pct: number): string;
60
+ export function colourPct(chalk: import("chalk").ChalkInstance, pct: unknown): string;