@cldmv/vitest-runner 1.4.3 → 1.4.4

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
 
@@ -299,6 +299,12 @@ This avoids the OOM crash that occurs when a single vitest process holds coverag
299
299
 
300
300
  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
301
 
302
+ ### When no files are measured
303
+
304
+ 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.
305
+
306
+ 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.
307
+
302
308
  ### Producing blobs for an external merge
303
309
 
304
310
  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 Wt,mkdirSync as Ut}from"fs";import be from"path";var Mt=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 st(e){let s=[],t=[],n=[],o,r=!0,l=!1,c,g=!1,a=!1,u=!0,f=!1,S,v=!0,h,y=!1,b,d=!1,x;for(let w=0;w<e.length;w++){let p=e[w];p==="--test-list"?o=e[++w]:p.startsWith("--test-list=")?o=p.slice(12):p==="--no-error-details"?r=!1:p==="--coverage-quiet"?l=!0:p==="--log-file"?c=e[++w]:p.startsWith("--log-file=")?c=p.slice(11):p==="--suppress-file-output"?g=!0:p==="--suppress-passing-files"?a=!0:p==="--no-top-summary"?u=!1:p==="--json"?f=!0:p==="--blobs-dir"?S=e[++w]:p.startsWith("--blobs-dir=")?S=p.slice(12):p==="--no-merge-reports"?v=!1:p==="--workers"?h=parseInt(e[++w],10):p.startsWith("--workers=")?h=parseInt(p.slice(10),10):p==="--solo-pattern"?n.push(e[++w]):p.startsWith("--solo-pattern=")?n.push(p.slice(15)):p==="--file-pattern"?b=new RegExp(e[++w],"i"):p.startsWith("--file-pattern=")?b=new RegExp(p.slice(15),"i"):p==="--keep-tmp"?d=!0:p==="--scratch-dir"?x=e[++w]:p.startsWith("--scratch-dir=")?x=p.slice(14):p==="--help"||p==="-h"?y=!0:(p.startsWith("--")||p.startsWith("-"))&&!Mt.has(p)?(s.push(p),w+1<e.length&&!e[w+1].startsWith("-")&&s.push(e[++w])):t.push(p)}return{testListFile:o,showErrorDetails:r,coverageQuiet:l,logFile:c,suppressFileOutput:g,suppressPassingFiles:a,topSummary:u,json:f,blobsDir:S,mergeReports:v,help:y,workers:h,soloPatterns:n,testFilePattern:b,vitestPassthroughArgs:s,testPatterns:t,keepTmp:d,scratchDir:x}}import Z from"chalk";function ot(){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
 
@@ -74,51 +74,50 @@ ${Z.bold("ENVIRONMENT VARIABLES:")}
74
74
 
75
75
  # Custom heap and workers
76
76
  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(`
77
+ `)}import G from"fs/promises";import ve from"path";import $ from"chalk";import{createRequire as Ot}from"module";import X from"path";import Rt from"fs/promises";import{pathToFileURL as kt}from"url";function ke(e,s,t=s){let n=Ot(kt(X.join(e,"package.json"))),o=n.resolve(`${s}/package.json`),r=n(o),l=r.bin?.[t]??r.bin;if(!l)throw new Error(`No bin "${t}" found in ${s}/package.json`);return X.join(X.dirname(o),l)}var Dt=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,s){if(s)return X.isAbsolute(s)?s:X.resolve(e,s);for(let t of Dt){let n=X.join(e,t);try{return await Rt.access(n),n}catch{}}}import Ae from"fs/promises";import C from"path";var rt=/\.test\.vitest\.(?:js|mjs|cjs)$/i;async function de(e,s,t=rt){let n=[e],o=[];for(;n.length;){let r=n.pop(),l;try{l=await Ae.readdir(r,{withFileTypes:!0})}catch{continue}for(let c of l){if(c.isDirectory()){if(c.name==="node_modules"||c.name.startsWith("."))continue;n.push(C.join(r,c.name));continue}c.isFile()&&t.test(c.name)&&o.push(C.relative(s,C.join(r,c.name)))}}return o}function ge(e,s=[]){let t=[],n=[];for(let o of e){let r=o.replace(/\\/g,"/"),l=s.findIndex(c=>r.includes(c));l!==-1?t.push({file:o,priorityIndex:l}):n.push(o)}return t.sort((o,r)=>o.priorityIndex-r.priorityIndex||o.file.localeCompare(r.file)),n.sort((o,r)=>o.localeCompare(r)),[...t.map(o=>o.file),...n]}function Ie(e){let s=e.map(n=>n.replace(/\\/g,"/")),t=new Map;for(let n=0;n<e.length;n++){let o=[];for(let r=0;r<e.length;r++)n!==r&&s[r].includes(s[n])&&o.push(e[r]);t.set(e[n],o)}return t}async function me(e){let{cwd:s,testDir:t,testPatterns:n=[],testListFile:o,testFilePattern:r=rt,earlyRunPatterns:l=[]}=e,c=t?C.isAbsolute(t)?t:C.resolve(s,t):s;if(o){let a=C.isAbsolute(o)?o:C.resolve(s,o),u;try{let f=await Ae.readFile(a,"utf8");u=JSON.parse(f)}catch(f){throw new Error(`Failed to read test list file "${a}": ${f.message}`,{cause:f})}if(!Array.isArray(u))throw new Error(`Test list file "${a}" must contain a JSON array of test file paths`);return console.log(`\u{1F4CB} Loading test list from: ${C.relative(s,a)}`),ge(u,l)}if(n.length===0){let a=await de(c,s,r);return ge(a,l)}let g=[];for(let a of n){let u=C.isAbsolute(a)?a:C.resolve(s,a),f=null;try{f=await Ae.stat(u)}catch{}if(f?.isFile())r.test(u)&&g.push(C.relative(s,u));else if(f?.isDirectory())g.push(...await de(u,s,r));else{let v=(await de(c,s,r)).filter(h=>h.replace(/\\/g,"/").includes(a.replace(/\\/g,"/")));v.length>0?g.push(...v):console.warn(`\u26A0\uFE0F No matches found for: ${a}`)}}return ge([...new Set(g)],l)}import{spawn as nt}from"child_process";function N(e){return e.replace(/\x1B\[[0-9;]*[a-zA-Z]/g,"")}function ee(e){return typeof e=="number"&&Number.isFinite(e)}function te(e,s){return ee(e)?e.toFixed(s):"Unknown"}function z(e,s){if(!ee(s))return e.dim(te(s,2).padStart(6));let t=s.toFixed(2).padStart(6);return s>=80?e.green(t):s>=50?e.yellow(t):e.red(t)}function je(e){let s=N(e),t={testFilesPass:0,testFilesFail:0,testsPass:0,testsFail:0,testsSkip:0,duration:0,heapMb:null,errors:[]},n=s.match(/Test Files\s+(.+)/);if(n){let g=n[1],a=g.match(/(\d+)\s+passed/),u=g.match(/(\d+)\s+failed/);a&&(t.testFilesPass=parseInt(a[1],10)),u&&(t.testFilesFail=parseInt(u[1],10))}let o=s.match(/^\s*Tests\s+(.+)$/m);if(o){let g=o[1],a=g.match(/(\d+)\s+passed/),u=g.match(/(\d+)\s+failed/),f=g.match(/(\d+)\s+skipped/);a&&(t.testsPass=parseInt(a[1],10)),u&&(t.testsFail=parseInt(u[1],10)),f&&(t.testsSkip=parseInt(f[1],10))}let r=s.match(/Duration\s+([\d.]+)s/);r&&(t.duration=parseFloat(r[1])*1e3);let l=s.match(/(\d+)\s*MB\s+heap\s+used/i);l&&(t.heapMb=parseInt(l[1],10));let c=e.indexOf("Failed Tests");if(c!==-1){let g=e.indexOf(`
78
+ Test Files`,c),a=g!==-1?e.substring(c,g):e.substring(c),u=/FAIL\s*(?:\x1B\[[0-9;]*[a-zA-Z]|\s)*tests\//g,f=[...a.matchAll(u)];for(let S=0;S<f.length;S++){let v=f[S].index,h=a.lastIndexOf(`
79
+ `,v),y=h===-1?0:h,b=S<f.length-1?f[S+1].index:a.length,d=a.lastIndexOf(`
80
+ `,b),x=d===-1?b:d,w=a.substring(y,x).trim();w&&t.errors.push(w)}}return t}function Ce(e){let t=e.join(`
81
81
  `).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(`
82
+ `),n=new Map,o=new Map;t.forEach((l,c)=>{if(l.includes("FAIL")&&l.includes("Config:")){o.set(l,c);let a=N(l).match(/^(.+Config:\s+)'*([^'>]+)'*(.+)$/);if(a){let[,u,f,S]=a,v=`${u.trim()}|||${S.trim()}`;n.has(v)||n.set(v,{lines:[],configs:[]}),n.get(v).lines.push(l),n.get(v).configs.push(f.replace(/'/g,""))}}});let r=new Set;for(let[,l]of n.entries())if(l.configs.length>1){for(let f=1;f<l.lines.length;f++){let S=o.get(l.lines[f]);r.add(S)}let c=l.lines[0],g=`[${l.configs.map(f=>`'${f}'`).join(",")}]`,a=N(c).replace(/(Config:\s+)'*[^'>]+'*/,`$1${g}`),u=o.get(c);t[u]=a}return t.filter((l,c)=>!r.has(c)).join(`
83
+ `)}function Ne({maxOldSpaceMb:e,conditions:s=[],base:t=process.env.NODE_OPTIONS??""}){let n=t;for(let o of s){let r=`--conditions=${o}`;n.includes(r)||(n=n?`${n} ${r}`:r)}if(e&&!n.includes("--max-old-space-size")){let o=`--max-old-space-size=${e}`;n=n?`${n} ${o}`:o}return n.trim()}function it({maxOldSpaceMb:e,conditions:s=[],nodeEnv:t="development",extraEnv:n={}}){let o={...process.env};o.NODE_ENV||(o.NODE_ENV=t);let r=Ne({maxOldSpaceMb:e,conditions:s,base:o.NODE_OPTIONS??""});return r&&(o.NODE_OPTIONS=r),Object.assign(o,n),o}function At(e,s){return[e,...s?["--config",s]:[],"run"]}function he(e,s){let{cwd:t,vitestBin:n,vitestConfig:o,maxOldSpaceMb:r,conditions:l=[],nodeEnv:c="development",vitestArgs:g=[],streamOutput:a=!0,excludePaths:u=[],extraEnv:f={}}=s;return new Promise(S=>{let v=Date.now(),h=u.flatMap(p=>["--exclude",p]),y=[...At(n,o),...g,...h,e],b=it({maxOldSpaceMb:r,conditions:l,nodeEnv:c,extraEnv:f}),d=nt(process.execPath,y,{cwd:t,stdio:["ignore","pipe","pipe"],env:b}),x="",w="";d.stdout?.on("data",p=>{x+=p.toString(),a&&process.stdout.write(p)}),d.stderr?.on("data",p=>{w+=p.toString(),a&&process.stderr.write(p)}),d.on("close",p=>{let V=Date.now()-v,_=`${x}
84
+ ${w}`,P=je(_);S({file:e,code:p??1,duration:P.duration>0?P.duration:V,testFilesPass:P.testFilesPass,testFilesFail:P.testFilesFail,testsPass:P.testsPass,testsFail:P.testsFail,testsSkip:P.testsSkip,heapMb:P.heapMb,errors:P.errors,rawOutput:_})}),d.on("error",p=>{S({file:e,code:1,duration:Date.now()-v,testFilesPass:0,testFilesFail:1,testsPass:0,testsFail:0,testsSkip:0,heapMb:null,errors:[p.message],rawOutput:p.toString()})})})}function Le(e,s){let{cwd:t,vitestBin:n,vitestConfig:o,maxOldSpaceMb:r,conditions:l=[],nodeEnv:c="development",extraCoverageArgs:g=[],quietOutput:a=!1}=s;return new Promise(u=>{let f=o?["--config",o]:[],S=a?["--color"]:[],v=[n,...f,"--mergeReports",e,"--run","--coverage",...S,...g],h=it({maxOldSpaceMb:r,conditions:l,nodeEnv:c}),y=nt(process.execPath,v,{cwd:t,stdio:a?["ignore","pipe","pipe"]:"inherit",env:h}),b="",d="";a&&(y.stdout?.on("data",x=>b+=x.toString()),y.stderr?.on("data",x=>d+=x.toString())),y.on("close",x=>u({exitCode:x??1,output:`${b}
85
+ ${d}`})),y.on("error",()=>u({exitCode:1,output:""}))})}import q from"chalk";function se(e){let s=Math.max(0,Math.floor(e/1e3)),t=Math.floor(s/3600),n=Math.floor(s%3600/60),o=s%60;return t>0?`${t}:${n.toString().padStart(2,"0")}:${o.toString().padStart(2,"0")}`:`${n}:${o.toString().padStart(2,"0")}`}function _e(e){let s=!!process.stdout.isTTY,t=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],n=26,o=Date.now(),r=0,l=0,c=0,g=0,a=0,u=0,f=null;function S(){let b=e===0?100:r/e*100,d=Date.now()-o,w=(r>0?d/r:0)*Math.max(e-r,0),p=Math.round(b/100*n),V=t[g%t.length],_=`[${"=".repeat(p)}${"-".repeat(Math.max(0,n-p))}]`,P=b.toFixed(1).padStart(5);return b<30?P=q.red(P+"%"):b<70?P=q.rgb(255,136,0)(P+"%"):b>99?P=q.green(P+"%"):P=q.yellow(P+"%"),s?`${q.green(V)} ${q.green(_)} ${q.bold(P)} ${r}/${e} | active ${l} | failed ${c} | ETA ${se(w)} | elapsed ${se(d)}`:`progress ${b.toFixed(1)}% ${r}/${e} | active ${l} | failed ${c} | eta ${se(w)} | elapsed ${se(d)}`}function v(b=!1){let d=S();if(g++,s){let w=d.replace(/\x1B\[[0-9;]*[a-zA-Z]/g,"").length;a=Math.max(a,w),process.stdout.write(`\r${d.padEnd(a," ")}`);return}let x=Date.now();(b||x-u>=2e3)&&(console.log(d),u=x)}function h(){!s||f||(f=setInterval(()=>{r>=e&&l===0||v()},120),f.unref?.())}function y(){f&&(clearInterval(f),f=null)}return v(!0),h(),{onStart(){l++,v()},onComplete(b){l=Math.max(0,l-1),r++,b&&c++,v(!0)},finish(){y(),v(!0),s&&process.stdout.write(`
86
+ `)}}}var Ve={onStart(){},onComplete(e){},finish(){}};import lt from"fs/promises";import oe from"path";import O from"chalk";function Be(e){if(e.length!==0){console.log(`
87
+ ${"=".repeat(80)}`),console.log(O.bold.red("\u2716 FAILED TEST FILES (VERBOSE OUTPUT)")),console.log("=".repeat(80));for(let s of e)console.log(`
88
+ ${O.red("\u2716")} ${O.red(s.file)} ${O.dim(`(exit ${s.code})`)}`),s.rawOutput?.trim()?console.log(s.rawOutput.trimEnd()):console.log(O.dim("(no child output captured)"));console.log(`
89
+ ${"=".repeat(80)}`)}}function We(e,s){if(e===0){let t="% Coverage report from v8",n=s.split(`
90
+ `),o=n.findIndex(r=>N(r).includes(t));if(o>=0){let r=n.length;for(let c=o+1;c<n.length;c++){let g=N(n[c]).trimStart();if(g.startsWith("stderr |")||g.startsWith("stdout |")){r=c;break}}if(n.slice(o+1,r).join(`
91
+ `).trimEnd()){let c=n.slice(o,r).join(`
92
92
  `).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})
93
+ ${c}
94
+ `)}}}else{let t=s.trimEnd();t&&console.error(t)}}function It(e){let s=(o,r)=>r===0?100:parseFloat((o/r*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[o,r]of Object.entries(e)){let l=Object.keys(r.s??{}),c=l.length,g=l.filter(d=>r.s[d]>0).length,a=Object.keys(r.f??{}),u=a.length,f=a.filter(d=>r.f[d]>0).length,S=0,v=0;for(let d of Object.values(r.b??{}))S+=d.length,v+=d.filter(x=>x>0).length;let h=new Set,y=new Set;for(let[d,x]of Object.entries(r.statementMap??{})){let w=x?.start?.line;w!=null&&(y.add(w),(r.s??{})[d]>0&&h.add(w))}let b={statements:{total:c,covered:g,pct:s(g,c)},branches:{total:S,covered:v,pct:s(v,S)},functions:{total:u,covered:f,pct:s(f,u)},lines:{total:y.size,covered:h.size,pct:s(h.size,y.size)}};t[o]=b;for(let d of["statements","branches","functions","lines"])t.total[d].total+=b[d].total,t.total[d].covered+=b[d].covered}let n=Object.keys(e).length>0;for(let o of["statements","branches","functions","lines"]){let{total:r,covered:l}=t.total[o];t.total[o].pct=n?s(l,r):"Unknown"}return t}function jt({lines:e,stmts:s,fns:t,branches:n}){let o=[e,s,t,n].filter(ee);return o.length>0?Math.min(...o):null}function at(e){return e??Number.MAX_VALUE}function Ct({lines:e,stmts:s,fns:t,branches:n}){return![e,s,t,n].every(ee)}function Nt({lines:e,stmts:s,fns:t,branches:n}){console.log(`
95
+ ${O.bold("Coverage")} ${z(O,e)}% lines ${O.dim("|")} ${z(O,s)}% statements ${O.dim("|")} ${z(O,t)}% functions ${O.dim("|")} ${z(O,n)}% branches`)}async function Ue(e,s,t=10,n={}){let{silent:o=!1}=n,r=oe.resolve(e,"coverage"),l=s.find(h=>h.startsWith("--coverage.reportsDirectory="));if(l){let h=l.split("=").slice(1).join("=");r=oe.isAbsolute(h)?h:oe.resolve(e,h)}let c;try{let h=await lt.readFile(oe.join(r,"coverage-summary.json"),"utf8");c=JSON.parse(h)}catch{try{let h=await lt.readFile(oe.join(r,"coverage-final.json"),"utf8");c=It(JSON.parse(h))}catch{return o||console.log(O.dim(" (no coverage JSON found \u2014 skipping summary)")),null}}let{total:g,...a}=c,u={lines:g.lines?.pct??0,stmts:g.statements?.pct??0,fns:g.functions?.pct??0,branches:g.branches?.pct??0},f=Object.keys(a).length===0&&!Object.values(u).some(ee),S=[],v=0;if(t>0){let h=Object.entries(a).map(([b,d])=>({file:oe.relative(e,b),lines:d.lines?.pct??0,stmts:d.statements?.pct??0,fns:d.functions?.pct??0,branches:d.branches?.pct??0})).map(b=>({row:b,worst:jt(b)})).filter(({row:b,worst:d})=>Ct(b)||d<100).sort((b,d)=>at(b.worst)-at(d.worst)),y=h.slice(0,t);o||(console.log(`
96
+ `+O.bold("\u{1F4C9} WORST COVERAGE FILES (lowest metric)")),console.log("-".repeat(80)),y.forEach(({row:{file:b,lines:d,stmts:x,fns:w,branches:p},worst:V})=>{let _=O.dim(`lines ${te(d,0)}% | stmts ${te(x,0)}% | fns ${te(w,0)}% | branches ${te(p,0)}%`);console.log(` ${z(O,V)}% ${O.dim(b)} ${_}`)}),h.length>t&&console.log(O.dim(` ... and ${h.length-t} more files`))),S=y.map(({row:b})=>b),v=h.length}return o||(Nt(u),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:r,total:g,noFilesMeasured:f,worstFiles:S,worstFilesShown:S.length,worstFilesTotal:v,summary:c}}import ce from"fs/promises";import Lt from"fs";import pe from"path";var ct="tmp/vitest-runner",_t=/^(\d+)-\d+$/;function Vt(e){try{return process.kill(e,0),!0}catch(s){return s.code!=="ESRCH"}}async function pt(e,s){let t=pe.resolve(e,s),n;try{n=await ce.readdir(t,{withFileTypes:!0})}catch{return}for(let o of n){if(!o.isDirectory())continue;let r=o.name.match(_t);if(!r)continue;let l=parseInt(r[1],10);Vt(l)||await ce.rm(pe.join(t,o.name),{recursive:!0,force:!0}).catch(()=>{})}}async function ut(e,s){let t=pe.resolve(e,s),n=pe.join(t,`${process.pid}-${Date.now()}`);return await ce.mkdir(n,{recursive:!0}),n}async function He(e,s){let t=pe.join(e,`worker-${s}`);return await ce.mkdir(t,{recursive:!0}),t}async function ft(e){await ce.rm(e,{recursive:!0,force:!0}).catch(()=>{})}function dt(e){try{Lt.rmSync(e,{recursive:!0,force:!0})}catch{}}function gt(e,s,t){let n=e.replace(/\\/g,"/"),o;for(let{pattern:r,heapMb:l}of t)if(n.includes(r)){o=l;break}if(!(o===void 0&&s===void 0))return o===void 0?s:s===void 0?o:Math.max(o,s)}async function mt(e){let s=e.cwd??process.cwd(),t=e.scratchDir??ct,n=e.keepTmp??!1;await pt(s,t);let o=await ut(s,t),r=()=>{dt(o),process.exitCode=130,process.exit()};n||(process.once("SIGINT",r),process.once("SIGTERM",r));try{return await Bt(e,o)}finally{process.removeListener("SIGINT",r),process.removeListener("SIGTERM",r),n||await ft(o)}}async function Bt(e,s){let{cwd:t=process.cwd(),testDir:n,testPatterns:o=[],testListFile:r,testFilePattern:l,vitestArgs:c=[],showErrorDetails:g=!0,coverageQuiet:a=!1,suppressFileOutput:u=!1,suppressPassingFiles:f=!1,topSummary:S=!0,json:v=!1,workers:h=parseInt(process.env.VITEST_WORKERS??"4",10),worstCoverageCount:y=10,blobsDir:b,mergeReports:d=!0,earlyRunPatterns:x=[],perFileHeapOverrides:w=[],conditions:p=[],nodeEnv:V="development",_testResultsOverride:_=null}=e,P=0,B=e.maxOldSpaceMb??(process.env.VITEST_HEAP_MB?parseInt(process.env.VITEST_HEAP_MB,10):void 0),R=!v,ht=ke(t,"vitest","vitest"),vt=await De(t,e.vitestConfig),Se={cwd:t,vitestBin:ht,vitestConfig:vt,conditions:p,nodeEnv:V},A=[...c];if(a&&!A.some(i=>i==="--coverage"||i.startsWith("--coverage."))&&A.unshift("--coverage"),A.some(i=>i==="--coverage"||i.startsWith("--coverage."))){let i=ve.resolve(t,b??".vitest-coverage-blobs"),m=ve.resolve(t,".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 T=await me({cwd:t,testDir:n,testPatterns:o,testListFile:r,testFilePattern:l,earlyRunPatterns:x}),k=Ie(T);if(T.length===0){let F=o.length>0?`\u274C No Vitest test files found matching: ${o.join(", ")}`:"\u274C No Vitest test files found";return R&&console.log(F),v?{exitCode:1,mode:"coverage",message:F,options:{cwd:t,testDir:n,testPatterns:o,testListFile:r,workers:h,coverageQuiet:a,suppressFileOutput:u,suppressPassingFiles:f,topSummary:S,vitestArgs:A}}:1}let j=A.filter(F=>F!=="--coverage"&&F.startsWith("--coverage.")),xe=A.filter(F=>F!=="--coverage"&&!F.startsWith("--coverage.")),le=T.filter(F=>x.some(M=>F.replace(/\\/g,"/").includes(M))),Te=T.filter(F=>!x.some(M=>F.replace(/\\/g,"/").includes(M))),Ee=a||u||v,Tt=a&&!v;!a&&!u&&R&&(console.log(`
97
+ \u{1F9EA} Running ${T.length} test files for coverage (blob + merge mode)`),console.log(`\u2699\uFE0F Workers: ${h} (${le.length} solo first, then parallel)`),B&&console.log(`\u{1F9E0} Heap limit: ${B} MB`),console.log(""));let ye=Tt?_e(T.length):Ve,L=[],Pe=0,Ze=async F=>{let M=ve.join(i,`run-${Pe}.blob`);Pe++,!Ee&&R&&(console.log(`
98
+ ${"=".repeat(80)}`),console.log(`\u25B6\uFE0F ${F}`),console.log("=".repeat(80))),ye.onStart();let U=ve.join(m,`run-${Pe}`),Et=[...xe,"--coverage",`--coverage.reportsDirectory=${U}`,"--reporter=default","--reporter=blob",`--outputFile=${M}`],yt=await He(s,P++),H=await he(F,{...Se,maxOldSpaceMb:gt(F,B,w),vitestArgs:Et,streamOutput:!Ee,excludePaths:k.get(F),extraEnv:{VITEST_RUNNER_TMP:yt}});if(L.push(H),ye.onComplete(H.code!==0),!Ee&&R){let tt=(H.duration/1e3).toFixed(2);if(H.code===0){let Pt=H.heapMb?` | ${H.heapMb} MB heap`:"";console.log(`
99
+ \u2705 PASSED (${tt}s${Pt})
101
100
  `)}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})
101
+ \u274C FAILED (exit code ${H.code}, ${tt}s)
102
+ `)}};for(let F of le)await Ze(F).catch(M=>{R&&console.error(`Error running ${F}:`,M)});let Me=0,Y=new Set;for(;Me<Te.length||Y.size>0;){for(;Me<Te.length&&Y.size<h;){let F=Te[Me++],M=Ze(F).catch(U=>{R&&console.error(`Error running ${F}:`,U)}).finally(()=>Y.delete(M));Y.add(M)}Y.size>0&&await Promise.race(Y)}ye.finish();let Oe=(await G.readdir(i).catch(()=>[])).filter(F=>F.endsWith(".blob"));if(Oe.length===0){let F="\u274C No coverage blobs were generated \u2014 coverage report cannot be produced";return R&&console.error(F),v?{exitCode:1,mode:"coverage",message:F,options:{cwd:t,testDir:n,testPatterns:o,testListFile:r,workers:h,coverageQuiet:a,suppressFileOutput:u,suppressPassingFiles:f,topSummary:S,showErrorDetails:g,worstCoverageCount:y,vitestArgs:A},totals:{testFiles:T.length,failedFiles:L.filter(M=>M.code!==0).length,passedFiles:L.filter(M=>M.code===0).length},results:{all:L,failed:L.filter(M=>M.code!==0)},merge:{blobFiles:0,exitCode:1,output:""},coverageSummary:null}:1}let fe=0,Re="",Xe=null;d&&(!a&&!u&&R&&(console.log(`
103
+ ${"=".repeat(80)}`),console.log(`\u{1F4CA} Merging ${Oe.length} coverage blobs into final report...`),console.log("=".repeat(80))),{exitCode:fe,output:Re}=await Le(i,{...Se,maxOldSpaceMb:B,extraCoverageArgs:j,quietOutput:a||v}),a&&R&&We(fe,Re),Xe=await Ue(t,j,y,{silent:v})),await Promise.all([...d?[G.rm(i,{recursive:!0,force:!0}).catch(()=>{})]:[],G.rm(m,{recursive:!0,force:!0}).catch(()=>{})]);let ae=L.filter(F=>F.code!==0);a&&R&&Be(ae);let et=ae.length>0?1:fe;if(v){let F=L.filter(M=>M.heapMb!==null);return{exitCode:et,mode:"coverage",options:{cwd:t,testDir:n,testPatterns:o,testListFile:r,workers:h,coverageQuiet:a,suppressFileOutput:u,suppressPassingFiles:f,topSummary:S,showErrorDetails:g,worstCoverageCount:y,vitestArgs:A},totals:{testFiles:T.length,failedFiles:ae.length,passedFiles:L.length-ae.length},results:{all:L,failed:ae},merge:{blobFiles:Oe.length,exitCode:fe,output:Re},coverageSummary:Xe,...S?{topMemoryUsers:[...F].sort((M,U)=>U.heapMb-M.heapMb).slice(0,10),topDuration:[...L].sort((M,U)=>U.duration-M.duration).slice(0,10)}:{}}}return et}let J=await me({cwd:t,testDir:n,testPatterns:o,testListFile:r,testFilePattern:l,earlyRunPatterns:x}),bt=Ie(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 R&&console.log(i),v?{exitCode:1,mode:"standard",message:i,options:{cwd:t,testDir:n,testPatterns:o,testListFile:r,workers:h,coverageQuiet:a,suppressFileOutput:u,suppressPassingFiles:f,topSummary:S,vitestArgs:A}}:1}let qe=J.filter(i=>x.some(m=>i.replace(/\\/g,"/").includes(m))),$e=J.filter(i=>!x.some(m=>i.replace(/\\/g,"/").includes(m))),St=Date.now(),Ge=new Date().toLocaleTimeString("en-US",{hour12:!1});R&&!u&&o.length>0?console.log(`
104
+ \u{1F9EA} Running ${J.length} test files matching: ${o.join(", ")}`):R&&!u&&console.log(`
105
+ \u{1F9EA} Running ${J.length} test files (${qe.length} solo first, then parallel)`),R&&!u&&(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 D=[..._??[]],Je=async i=>{!u&&R&&(console.log(`
106
+ ${"=".repeat(80)}`),console.log(`\u25B6\uFE0F ${i}`),console.log("=".repeat(80)));let m=await He(s,P++),T=await he(i,{...Se,maxOldSpaceMb:gt(i,B,w),vitestArgs:A,streamOutput:!u&&!v,excludePaths:bt.get(i),extraEnv:{VITEST_RUNNER_TMP:m}});if(!u&&R){let k=(T.duration/1e3).toFixed(2);if(T.code===0){let j=T.heapMb?` | ${T.heapMb} MB heap`:"";console.log(`
107
+ \u2705 PASSED (${k}s${j})
109
108
  `)}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)}
109
+ \u274C FAILED (exit code ${T.code}, ${k}s)
110
+ `)}return T};if(!_){for(let T of qe){let k=await Je(T).catch(j=>(R&&console.error(`Error running ${T}:`,j),null));k&&D.push(k)}let i=0,m=new Set;for(;i<$e.length||m.size>0;){for(;i<$e.length&&m.size<h;){let T=$e[i++],k=Je(T).then(j=>D.push(j)).catch(j=>{R&&console.error(`Error running ${T}:`,j)}).finally(()=>m.delete(k));m.add(k)}m.size>0&&await Promise.race(m)}}let K=D.reduce((i,m)=>i+m.testFilesPass,0),W=D.reduce((i,m)=>i+m.testFilesFail,0),re=D.reduce((i,m)=>i+m.testsPass,0),ne=D.reduce((i,m)=>i+m.testsFail,0),ie=D.reduce((i,m)=>i+(m.testsSkip||0),0),$t=D.reduce((i,m)=>i+m.duration,0),Q=D.filter(i=>i.code!==0),ue=D.filter(i=>i.code===0),wt=Q.length>0?1:0,Ke=process.memoryUsage(),we=Math.round(Ke.heapUsed/1024/1024),Fe=Math.round(Ke.rss/1024/1024),I=D.filter(i=>i.heapMb!==null),Qe=((Date.now()-St)/1e3).toFixed(2),Ye=($t/1e3).toFixed(2);if(v)return{exitCode:wt,mode:"standard",options:{cwd:t,testDir:n,testPatterns:o,testListFile:r,workers:h,coverageQuiet:a,suppressFileOutput:u,suppressPassingFiles:f,topSummary:S,showErrorDetails:g,worstCoverageCount:y,vitestArgs:A},totals:{testFilesPass:K,testFilesFail:W,testsPass:re,testsFail:ne,testsSkip:ie,totalTests:re+ne+ie},timing:{startAt:Ge,wallClockSeconds:Number(Qe),testsSeconds:Number(Ye)},heap:{scriptHeapMb:we,scriptRssMb:Fe,maxHeapMb:I.length>0?Math.max(...I.map(i=>i.heapMb)):null,avgHeapMb:I.length>0?Number((I.reduce((i,m)=>i+m.heapMb,0)/I.length).toFixed(0)):null},results:{all:D,passed:ue,failed:Q},...S?{topMemoryUsers:[...I].sort((i,m)=>m.heapMb-i.heapMb).slice(0,10),topDuration:[...D].sort((i,m)=>m.duration-i.duration).slice(0,10)}:{}};console.log(`
111
+ `+"=".repeat(80)),S&&I.length>0&&(console.log(`
112
+ `+$.bold("\u{1F9E0} TOP MEMORY USERS")),console.log("-".repeat(80)),[...I].sort((i,m)=>m.heapMb-i.heapMb).slice(0,10).forEach(i=>{console.log(` ${String(i.heapMb).padStart(4)} MB ${$.dim(i.file)}`)})),S&&D.length>0&&(console.log(`
113
+ `+$.bold("\u23F1\uFE0F TOP DURATION")),console.log("-".repeat(80)),[...D].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(`
114
+ `+"=".repeat(80)),console.log($.bold.green("\u2713 PASSED TEST FILES")),console.log("=".repeat(80)),ue.forEach(i=>{let m=(i.duration/1e3).toFixed(2),T=[...i.heapMb?[`${i.heapMb} MB`]:[],`${m}s`],k=i.testsPass>0?` - ${i.testsPass} tests`:"";console.log($.green(`\u2713 ${i.file}${k}`)+$.dim(` (${T.join(", ")})`))})),console.log(`
115
+ `+$.bold("=".repeat(80))),Q.length>0&&(console.log(`
116
+ \u274C ${Q.length} test file(s) failed`),console.log($.bold.red(`
117
+ Failed Test Files:`)),Q.forEach(i=>{let m=(i.duration/1e3).toFixed(2),T=[...i.testsFail>0?[$.red(`${i.testsFail} failed`)]:[],...i.testsPass>0?[$.green(`${i.testsPass} passed`)]:[],...i.testsSkip>0?[$.yellow(`${i.testsSkip} skipped`)]:[]],k=[...i.heapMb?[`${i.heapMb} MB`]:[],`${m}s`],j=T.length>0?` (${T.join(", ")})`:"";if(console.log(` ${$.red("\u2716")} ${i.file}${j}`+$.dim(` [${k.join(", ")}]`)),g&&i.errors.length>0){let xe=Ce(i.errors).split(`
118
+ `).map(le=>le.trim()?` ${le}`:"").join(`
119
+ `);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 Ft=re+ne+ie,xt=[...ne>0?[$.red(`${ne} failed`)]:[],...re>0?[$.green(`${re} passed`)]:[],...ie>0?[$.yellow(`${ie} skipped`)]:[]];if(console.log(` ${$.bold("Tests")} ${xt.join(` ${$.dim("|")} `)} ${$.dim(`(${Ft})`)}`),console.log(` ${$.bold("Start at")} ${Ge}`),console.log(` ${$.bold("Duration")} ${Qe}s ${$.dim(`(tests ${Ye}s)`)}`),I.length>0){let i=Math.max(...I.map(T=>T.heapMb)),m=(I.reduce((T,k)=>T+k.heapMb,0)/I.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(`
120
+ \u2705 All ${ue.length} test files passed
121
+ `),0)}var E=st(process.argv.slice(2));E.help&&(ot(),process.exit(0));if((E.coverageQuiet||E.logFile)&&!E.json){let r=function(l){let c=l.toString();return c.startsWith("\r")||/^progress \d+\.\d+%/.test(c)},e=process.cwd(),s=E.logFile?be.isAbsolute(E.logFile)?E.logFile:be.resolve(e,E.logFile):be.join(e,"coverage","coverage-run.log");Ut(be.dirname(s),{recursive:!0});let t=Wt(s,{flags:"a"}),n=process.stdout.write.bind(process.stdout),o=process.stderr.write.bind(process.stderr);process.stdout.write=(l,c,g)=>(r(l)||t.write(N(l.toString())),n(l,c,g)),process.stderr.write=(l,c,g)=>(r(l)||t.write(N(l.toString())),o(l,c,g)),process.on("exit",()=>t.end())}var Ht=process.cwd(),ze=[...E.vitestPassthroughArgs];E.coverageQuiet&&!ze.some(e=>e==="--coverage"||e.startsWith("--coverage."))&&ze.unshift("--coverage");try{let e=await mt({cwd:Ht,testPatterns:E.testPatterns,testListFile:E.testListFile,testFilePattern:E.testFilePattern,vitestArgs:ze,showErrorDetails:E.showErrorDetails,coverageQuiet:E.coverageQuiet,suppressFileOutput:E.suppressFileOutput,suppressPassingFiles:E.suppressPassingFiles,topSummary:E.topSummary,json:E.json,mergeReports:E.mergeReports,keepTmp:E.keepTmp,...E.blobsDir!==void 0&&{blobsDir:E.blobsDir},...E.workers!==void 0&&{workers:E.workers},...E.soloPatterns.length>0&&{earlyRunPatterns:E.soloPatterns},...E.scratchDir!==void 0&&{scratchDir:E.scratchDir}});E.json&&(process.stdout.write(`${JSON.stringify(e,null,2)}
123
122
  `),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
123
  //# 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 wt}from"module";import Z from"path";import Tt from"fs/promises";import{pathToFileURL as Mt}from"url";function Pe(e,t,o=t){let r=wt(Mt(Z.join(e,"package.json"))),s=r.resolve(`${t}/package.json`),n=r(s),a=n.bin?.[o]??n.bin;if(!a)throw new Error(`No bin "${o}" found in ${t}/package.json`);return Z.join(Z.dirname(s),a)}var Et=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(e,t){if(t)return Z.isAbsolute(t)?t:Z.resolve(e,t);for(let o of Et){let r=Z.join(e,o);try{return await Tt.access(r),r}catch{}}}import De from"fs/promises";import R from"path";var et=/\.test\.vitest\.(?:js|mjs|cjs)$/i;async function fe(e,t,o=et){let r=[e],s=[];for(;r.length;){let n=r.pop(),a;try{a=await De.readdir(n,{withFileTypes:!0})}catch{continue}for(let l of a){if(l.isDirectory()){if(l.name==="node_modules"||l.name.startsWith("."))continue;r.push(R.join(n,l.name));continue}l.isFile()&&o.test(l.name)&&s.push(R.relative(t,R.join(n,l.name)))}}return s}function ue(e,t=[]){let o=[],r=[];for(let s of e){let n=s.replace(/\\/g,"/"),a=t.findIndex(l=>n.includes(l));a!==-1?o.push({file:s,priorityIndex:a}):r.push(s)}return o.sort((s,n)=>s.priorityIndex-n.priorityIndex||s.file.localeCompare(n.file)),r.sort((s,n)=>s.localeCompare(n)),[...o.map(s=>s.file),...r]}function Ie(e){let t=e.map(r=>r.replace(/\\/g,"/")),o=new Map;for(let r=0;r<e.length;r++){let s=[];for(let n=0;n<e.length;n++)r!==n&&t[n].includes(t[r])&&s.push(e[n]);o.set(e[r],s)}return o}async function de(e){let{cwd:t,testDir:o,testPatterns:r=[],testListFile:s,testFilePattern:n=et,earlyRunPatterns:a=[]}=e,l=o?R.isAbsolute(o)?o:R.resolve(t,o):t;if(s){let c=R.isAbsolute(s)?s:R.resolve(t,s),p;try{let f=await De.readFile(c,"utf8");p=JSON.parse(f)}catch(f){throw new Error(`Failed to read test list file "${c}": ${f.message}`,{cause:f})}if(!Array.isArray(p))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: ${R.relative(t,c)}`),ue(p,a)}if(r.length===0){let c=await fe(l,t,n);return ue(c,a)}let g=[];for(let c of r){let p=R.isAbsolute(c)?c:R.resolve(t,c),f=null;try{f=await De.stat(p)}catch{}if(f?.isFile())n.test(p)&&g.push(R.relative(t,p));else if(f?.isDirectory())g.push(...await fe(p,t,n));else{let m=(await fe(l,t,n)).filter(h=>h.replace(/\\/g,"/").includes(c.replace(/\\/g,"/")));m.length>0?g.push(...m):console.warn(`\u26A0\uFE0F No matches found for: ${c}`)}}return ue([...new Set(g)],a)}import{spawn as Re}from"child_process";function L(e){return e.replace(/\x1B\[[0-9;]*[a-zA-Z]/g,"")}function Y(e){return typeof e=="number"&&Number.isFinite(e)}function X(e,t){return Y(e)?e.toFixed(t):"Unknown"}function H(e,t){if(!Y(t))return e.dim(X(t,2).padStart(6));let o=t.toFixed(2).padStart(6);return t>=80?e.green(o):t>=50?e.yellow(o):e.red(o)}function Ae(e){let t=L(e),o={testFilesPass:0,testFilesFail:0,testsPass:0,testsFail:0,testsSkip:0,duration:0,heapMb:null,errors:[]},r=t.match(/Test Files\s+(.+)/);if(r){let g=r[1],c=g.match(/(\d+)\s+passed/),p=g.match(/(\d+)\s+failed/);c&&(o.testFilesPass=parseInt(c[1],10)),p&&(o.testFilesFail=parseInt(p[1],10))}let s=t.match(/^\s*Tests\s+(.+)$/m);if(s){let g=s[1],c=g.match(/(\d+)\s+passed/),p=g.match(/(\d+)\s+failed/),f=g.match(/(\d+)\s+skipped/);c&&(o.testsPass=parseInt(c[1],10)),p&&(o.testsFail=parseInt(p[1],10)),f&&(o.testsSkip=parseInt(f[1],10))}let n=t.match(/Duration\s+([\d.]+)s/);n&&(o.duration=parseFloat(n[1])*1e3);let a=t.match(/(\d+)\s*MB\s+heap\s+used/i);a&&(o.heapMb=parseInt(a[1],10));let l=e.indexOf("Failed Tests");if(l!==-1){let g=e.indexOf(`
2
+ Test Files`,l),c=g!==-1?e.substring(l,g):e.substring(l),p=/FAIL\s*(?:\x1B\[[0-9;]*[a-zA-Z]|\s)*tests\//g,f=[...c.matchAll(p)];for(let v=0;v<f.length;v++){let m=f[v].index,h=c.lastIndexOf(`
3
+ `,m),w=h===-1?0:h,$=v<f.length-1?f[v+1].index:c.length,d=c.lastIndexOf(`
4
+ `,$),x=d===-1?$:d,y=c.substring(w,x).trim();y&&o.errors.push(y)}}return o}function Ce(e){let o=e.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
+ `),r=new Map,s=new Map;o.forEach((a,l)=>{if(a.includes("FAIL")&&a.includes("Config:")){s.set(a,l);let c=L(a).match(/^(.+Config:\s+)'*([^'>]+)'*(.+)$/);if(c){let[,p,f,v]=c,m=`${p.trim()}|||${v.trim()}`;r.has(m)||r.set(m,{lines:[],configs:[]}),r.get(m).lines.push(a),r.get(m).configs.push(f.replace(/'/g,""))}}});let n=new Set;for(let[,a]of r.entries())if(a.configs.length>1){for(let f=1;f<a.lines.length;f++){let v=s.get(a.lines[f]);n.add(v)}let l=a.lines[0],g=`[${a.configs.map(f=>`'${f}'`).join(",")}]`,c=L(l).replace(/(Config:\s+)'*[^'>]+'*/,`$1${g}`),p=s.get(l);o[p]=c}return o.filter((a,l)=>!n.has(l)).join(`
7
+ `)}function ke({maxOldSpaceMb:e,conditions:t=[],base:o=process.env.NODE_OPTIONS??""}){let r=o;for(let s of t){let n=`--conditions=${s}`;r.includes(n)||(r=r?`${r} ${n}`:n)}if(e&&!r.includes("--max-old-space-size")){let s=`--max-old-space-size=${e}`;r=r?`${r} ${s}`:s}return r.trim()}function je({maxOldSpaceMb:e,conditions:t=[],nodeEnv:o="development",extraEnv:r={}}){let s={...process.env};s.NODE_ENV||(s.NODE_ENV=o);let n=ke({maxOldSpaceMb:e,conditions:t,base:s.NODE_OPTIONS??""});return n&&(s.NODE_OPTIONS=n),Object.assign(s,r),s}function tt(e,t){return[e,...t?["--config",t]:[],"run"]}function ge(e,t){let{cwd:o,vitestBin:r,vitestConfig:s,maxOldSpaceMb:n,conditions:a=[],nodeEnv:l="development",vitestArgs:g=[],streamOutput:c=!0,excludePaths:p=[],extraEnv:f={}}=t;return new Promise(v=>{let m=Date.now(),h=p.flatMap(P=>["--exclude",P]),w=[...tt(r,s),...g,...h,e],$=je({maxOldSpaceMb:n,conditions:a,nodeEnv:l,extraEnv:f}),d=Re(process.execPath,w,{cwd:o,stdio:["ignore","pipe","pipe"],env:$}),x="",y="";d.stdout?.on("data",P=>{x+=P.toString(),c&&process.stdout.write(P)}),d.stderr?.on("data",P=>{y+=P.toString(),c&&process.stderr.write(P)}),d.on("close",P=>{let _=Date.now()-m,N=`${x}
8
+ ${y}`,T=Ae(N);v({file:e,code:P??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})}),d.on("error",P=>{v({file:e,code:1,duration:Date.now()-m,testFilesPass:0,testFilesFail:1,testsPass:0,testsFail:0,testsSkip:0,heapMb:null,errors:[P.message],rawOutput:P.toString()})})})}function yt(e){let{cwd:t,vitestBin:o,vitestConfig:r,maxOldSpaceMb:s,conditions:n=[],nodeEnv:a="development",vitestArgs:l=[]}=e;return new Promise(g=>{let c=[...tt(o,r),...l],p=je({maxOldSpaceMb:s,conditions:n,nodeEnv:a}),f=Re(process.execPath,c,{cwd:t,stdio:"inherit",env:p});f.on("close",v=>g(v??1)),f.on("error",()=>g(1))})}function Ne(e,t){let{cwd:o,vitestBin:r,vitestConfig:s,maxOldSpaceMb:n,conditions:a=[],nodeEnv:l="development",extraCoverageArgs:g=[],quietOutput:c=!1}=t;return new Promise(p=>{let f=s?["--config",s]:[],v=c?["--color"]:[],m=[r,...f,"--mergeReports",e,"--run","--coverage",...v,...g],h=je({maxOldSpaceMb:n,conditions:a,nodeEnv:l}),w=Re(process.execPath,m,{cwd:o,stdio:c?["ignore","pipe","pipe"]:"inherit",env:h}),$="",d="";c&&(w.stdout?.on("data",x=>$+=x.toString()),w.stderr?.on("data",x=>d+=x.toString())),w.on("close",x=>p({exitCode:x??1,output:`${$}
9
+ ${d}`})),w.on("error",()=>p({exitCode:1,output:""}))})}import W from"chalk";function ee(e){let t=Math.max(0,Math.floor(e/1e3)),o=Math.floor(t/3600),r=Math.floor(t%3600/60),s=t%60;return o>0?`${o}:${r.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`:`${r}:${s.toString().padStart(2,"0")}`}function Le(e){let t=!!process.stdout.isTTY,o=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],r=26,s=Date.now(),n=0,a=0,l=0,g=0,c=0,p=0,f=null;function v(){let $=e===0?100:n/e*100,d=Date.now()-s,y=(n>0?d/n:0)*Math.max(e-n,0),P=Math.round($/100*r),_=o[g%o.length],N=`[${"=".repeat(P)}${"-".repeat(Math.max(0,r-P))}]`,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+"%"),t?`${W.green(_)} ${W.green(N)} ${W.bold(T)} ${n}/${e} | active ${a} | failed ${l} | ETA ${ee(y)} | elapsed ${ee(d)}`:`progress ${$.toFixed(1)}% ${n}/${e} | active ${a} | failed ${l} | eta ${ee(y)} | elapsed ${ee(d)}`}function m($=!1){let d=v();if(g++,t){let y=d.replace(/\x1B\[[0-9;]*[a-zA-Z]/g,"").length;c=Math.max(c,y),process.stdout.write(`\r${d.padEnd(c," ")}`);return}let x=Date.now();($||x-p>=2e3)&&(console.log(d),p=x)}function h(){!t||f||(f=setInterval(()=>{n>=e&&a===0||m()},120),f.unref?.())}function w(){f&&(clearInterval(f),f=null)}return m(!0),h(),{onStart(){a++,m()},onComplete($){a=Math.max(0,a-1),n++,$&&l++,m(!0)},finish(){w(),m(!0),t&&process.stdout.write(`
10
+ `)}}}var _e={onStart(){},onComplete(e){},finish(){}};import ot from"fs/promises";import te from"path";import E from"chalk";function Be(e){if(e.length!==0){console.log(`
11
+ ${"=".repeat(80)}`),console.log(E.bold.red("\u2716 FAILED TEST FILES (VERBOSE OUTPUT)")),console.log("=".repeat(80));for(let t of e)console.log(`
12
+ ${E.red("\u2716")} ${E.red(t.file)} ${E.dim(`(exit ${t.code})`)}`),t.rawOutput?.trim()?console.log(t.rawOutput.trimEnd()):console.log(E.dim("(no child output captured)"));console.log(`
13
+ ${"=".repeat(80)}`)}}function Ve(e,t){if(e===0){let o="% Coverage report from v8",r=t.split(`
14
+ `),s=r.findIndex(n=>L(n).includes(o));if(s>=0){let n=r.length;for(let l=s+1;l<r.length;l++){let g=L(r[l]).trimStart();if(g.startsWith("stderr |")||g.startsWith("stdout |")){n=l;break}}if(r.slice(s+1,n).join(`
15
+ `).trimEnd()){let l=r.slice(s,n).join(`
16
16
  `).trimEnd();console.log(`
17
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})
18
+ `)}}}else{let o=t.trimEnd();o&&console.error(o)}}function Pt(e){let t=(s,n)=>n===0?100:parseFloat((s/n*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,n]of Object.entries(e)){let a=Object.keys(n.s??{}),l=a.length,g=a.filter(d=>n.s[d]>0).length,c=Object.keys(n.f??{}),p=c.length,f=c.filter(d=>n.f[d]>0).length,v=0,m=0;for(let d of Object.values(n.b??{}))v+=d.length,m+=d.filter(x=>x>0).length;let h=new Set,w=new Set;for(let[d,x]of Object.entries(n.statementMap??{})){let y=x?.start?.line;y!=null&&(w.add(y),(n.s??{})[d]>0&&h.add(y))}let $={statements:{total:l,covered:g,pct:t(g,l)},branches:{total:v,covered:m,pct:t(m,v)},functions:{total:p,covered:f,pct:t(f,p)},lines:{total:w.size,covered:h.size,pct:t(h.size,w.size)}};o[s]=$;for(let d of["statements","branches","functions","lines"])o.total[d].total+=$[d].total,o.total[d].covered+=$[d].covered}let r=Object.keys(e).length>0;for(let s of["statements","branches","functions","lines"]){let{total:n,covered:a}=o.total[s];o.total[s].pct=r?t(a,n):"Unknown"}return o}function Ot({lines:e,stmts:t,fns:o,branches:r}){let s=[e,t,o,r].filter(Y);return s.length>0?Math.min(...s):null}function st(e){return e??Number.MAX_VALUE}function Dt({lines:e,stmts:t,fns:o,branches:r}){return![e,t,o,r].every(Y)}function It({lines:e,stmts:t,fns:o,branches:r}){console.log(`
19
+ ${E.bold("Coverage")} ${H(E,e)}% lines ${E.dim("|")} ${H(E,t)}% statements ${E.dim("|")} ${H(E,o)}% functions ${E.dim("|")} ${H(E,r)}% branches`)}async function Ue(e,t,o=10,r={}){let{silent:s=!1}=r,n=te.resolve(e,"coverage"),a=t.find(h=>h.startsWith("--coverage.reportsDirectory="));if(a){let h=a.split("=").slice(1).join("=");n=te.isAbsolute(h)?h:te.resolve(e,h)}let l;try{let h=await ot.readFile(te.join(n,"coverage-summary.json"),"utf8");l=JSON.parse(h)}catch{try{let h=await ot.readFile(te.join(n,"coverage-final.json"),"utf8");l=Pt(JSON.parse(h))}catch{return s||console.log(E.dim(" (no coverage JSON found \u2014 skipping summary)")),null}}let{total:g,...c}=l,p={lines:g.lines?.pct??0,stmts:g.statements?.pct??0,fns:g.functions?.pct??0,branches:g.branches?.pct??0},f=Object.keys(c).length===0&&!Object.values(p).some(Y),v=[],m=0;if(o>0){let h=Object.entries(c).map(([$,d])=>({file:te.relative(e,$),lines:d.lines?.pct??0,stmts:d.statements?.pct??0,fns:d.functions?.pct??0,branches:d.branches?.pct??0})).map($=>({row:$,worst:Ot($)})).filter(({row:$,worst:d})=>Dt($)||d<100).sort(($,d)=>st($.worst)-st(d.worst)),w=h.slice(0,o);s||(console.log(`
20
+ `+E.bold("\u{1F4C9} WORST COVERAGE FILES (lowest metric)")),console.log("-".repeat(80)),w.forEach(({row:{file:$,lines:d,stmts:x,fns:y,branches:P},worst:_})=>{let N=E.dim(`lines ${X(d,0)}% | stmts ${X(x,0)}% | fns ${X(y,0)}% | branches ${X(P,0)}%`);console.log(` ${H(E,_)}% ${E.dim($)} ${N}`)}),h.length>o&&console.log(E.dim(` ... and ${h.length-o} more files`))),v=w.map(({row:$})=>$),m=h.length}return s||(It(p),f&&console.log(E.dim(" No files were measured (the coverage include matched nothing), so every percentage is Unknown and coverage thresholds are skipped."))),{coverageDir:n,total:g,noFilesMeasured:f,worstFiles:v,worstFilesShown:v.length,worstFilesTotal:m,summary:l}}import ae from"fs/promises";import nt from"fs";import oe from"path";var rt="tmp/vitest-runner",At=/^(\d+)-\d+$/;function Ct(e){try{return process.kill(e,0),!0}catch(t){return t.code!=="ESRCH"}}function kt(e){return String(e).replace(/[^a-zA-Z0-9_-]+/g,"-").slice(0,80)||"scratch"}async function it(e,t){let o=oe.resolve(e,t),r;try{r=await ae.readdir(o,{withFileTypes:!0})}catch{return}for(let s of r){if(!s.isDirectory())continue;let n=s.name.match(At);if(!n)continue;let a=parseInt(n[1],10);Ct(a)||await ae.rm(oe.join(o,s.name),{recursive:!0,force:!0}).catch(()=>{})}}async function ct(e,t){let o=oe.resolve(e,t),r=oe.join(o,`${process.pid}-${Date.now()}`);return await ae.mkdir(r,{recursive:!0}),r}async function ze(e,t){let o=oe.join(e,`worker-${t}`);return await ae.mkdir(o,{recursive:!0}),o}async function at(e){await ae.rm(e,{recursive:!0,force:!0}).catch(()=>{})}function lt(e){try{nt.rmSync(e,{recursive:!0,force:!0})}catch{}}function Rt(e){let t=process.env.VITEST_RUNNER_TMP;if(!t)throw new Error("makeRunTmpDir() requires VITEST_RUNNER_TMP to be set \u2014 call it from a test file run by vitest-runner.");return nt.mkdtempSync(oe.join(t,`${kt(e)}-`))}function pt(e,t,o){let r=e.replace(/\\/g,"/"),s;for(let{pattern:n,heapMb:a}of o)if(r.includes(n)){s=a;break}if(!(s===void 0&&t===void 0))return s===void 0?t:t===void 0?s:Math.max(s,t)}async function To(e){let t=e.cwd??process.cwd(),o=e.scratchDir??rt,r=e.keepTmp??!1;await it(t,o);let s=await ct(t,o),n=()=>{lt(s),process.exitCode=130,process.exit()};r||(process.once("SIGINT",n),process.once("SIGTERM",n));try{return await jt(e,s)}finally{process.removeListener("SIGINT",n),process.removeListener("SIGTERM",n),r||await at(s)}}async function jt(e,t){let{cwd:o=process.cwd(),testDir:r,testPatterns:s=[],testListFile:n,testFilePattern:a,vitestArgs:l=[],showErrorDetails:g=!0,coverageQuiet:c=!1,suppressFileOutput:p=!1,suppressPassingFiles:f=!1,topSummary:v=!0,json:m=!1,workers:h=parseInt(process.env.VITEST_WORKERS??"4",10),worstCoverageCount:w=10,blobsDir:$,mergeReports:d=!0,earlyRunPatterns:x=[],perFileHeapOverrides:y=[],conditions:P=[],nodeEnv:_="development",_testResultsOverride:N=null}=e,T=0,B=e.maxOldSpaceMb??(process.env.VITEST_HEAP_MB?parseInt(process.env.VITEST_HEAP_MB,10):void 0),O=!m,ft=Pe(o,"vitest","vitest"),ut=await Oe(o,e.vitestConfig),he={cwd:o,vitestBin:ft,vitestConfig:ut,conditions:P,nodeEnv:_},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=me.resolve(o,$??".vitest-coverage-blobs"),u=me.resolve(o,".vitest-coverage-tmp");await Promise.all([K.rm(i,{recursive:!0,force:!0}),K.rm(u,{recursive:!0,force:!0})]),await Promise.all([K.mkdir(i,{recursive:!0}),K.mkdir(u,{recursive:!0})]);let b=await de({cwd:o,testDir:r,testPatterns:s,testListFile:n,testFilePattern:a,earlyRunPatterns:x}),D=Ie(b);if(b.length===0){let F=s.length>0?`\u274C No Vitest test files found matching: ${s.join(", ")}`:"\u274C No Vitest test files found";return O&&console.log(F),m?{exitCode:1,mode:"coverage",message:F,options:{cwd:o,testDir:r,testPatterns:s,testListFile:n,workers:h,coverageQuiet:c,suppressFileOutput:p,suppressPassingFiles:f,topSummary:v,vitestArgs:A}}:1}let k=A.filter(F=>F!=="--coverage"&&F.startsWith("--coverage.")),Fe=A.filter(F=>F!=="--coverage"&&!F.startsWith("--coverage.")),ie=b.filter(F=>x.some(M=>F.replace(/\\/g,"/").includes(M))),be=b.filter(F=>!x.some(M=>F.replace(/\\/g,"/").includes(M))),xe=c||p||m,St=c&&!m;!c&&!p&&O&&(console.log(`
21
+ \u{1F9EA} Running ${b.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=St?Le(b.length):_e,j=[],Te=0,Qe=async F=>{let M=me.join(i,`run-${Te}.blob`);Te++,!xe&&O&&(console.log(`
22
+ ${"=".repeat(80)}`),console.log(`\u25B6\uFE0F ${F}`),console.log("=".repeat(80))),we.onStart();let U=me.join(u,`run-${Te}`),Ft=[...Fe,"--coverage",`--coverage.reportsDirectory=${U}`,"--reporter=default","--reporter=blob",`--outputFile=${M}`],bt=await ze(t,T++),z=await ge(F,{...he,maxOldSpaceMb:pt(F,B,y),vitestArgs:Ft,streamOutput:!xe,excludePaths:D.get(F),extraEnv:{VITEST_RUNNER_TMP:bt}});if(j.push(z),we.onComplete(z.code!==0),!xe&&O){let Xe=(z.duration/1e3).toFixed(2);if(z.code===0){let xt=z.heapMb?` | ${z.heapMb} MB heap`:"";console.log(`
23
+ \u2705 PASSED (${Xe}s${xt})
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}, ${Xe}s)
26
+ `)}};for(let F of ie)await Qe(F).catch(M=>{O&&console.error(`Error running ${F}:`,M)});let Me=0,Q=new Set;for(;Me<be.length||Q.size>0;){for(;Me<be.length&&Q.size<h;){let F=be[Me++],M=Qe(F).catch(U=>{O&&console.error(`Error running ${F}:`,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(F=>F.endsWith(".blob"));if(Ee.length===0){let F="\u274C No coverage blobs were generated \u2014 coverage report cannot be produced";return O&&console.error(F),m?{exitCode:1,mode:"coverage",message:F,options:{cwd:o,testDir:r,testPatterns:s,testListFile:n,workers:h,coverageQuiet:c,suppressFileOutput:p,suppressPassingFiles:f,topSummary:v,showErrorDetails:g,worstCoverageCount:w,vitestArgs:A},totals:{testFiles:b.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 pe=0,ye="",Ze=null;d&&(!c&&!p&&O&&(console.log(`
27
+ ${"=".repeat(80)}`),console.log(`\u{1F4CA} Merging ${Ee.length} coverage blobs into final report...`),console.log("=".repeat(80))),{exitCode:pe,output:ye}=await Ne(i,{...he,maxOldSpaceMb:B,extraCoverageArgs:k,quietOutput:c||m}),c&&O&&Ve(pe,ye),Ze=await Ue(o,k,w,{silent:m})),await Promise.all([...d?[K.rm(i,{recursive:!0,force:!0}).catch(()=>{})]:[],K.rm(u,{recursive:!0,force:!0}).catch(()=>{})]);let ce=j.filter(F=>F.code!==0);c&&O&&Be(ce);let Ye=ce.length>0?1:pe;if(m){let F=j.filter(M=>M.heapMb!==null);return{exitCode:Ye,mode:"coverage",options:{cwd:o,testDir:r,testPatterns:s,testListFile:n,workers:h,coverageQuiet:c,suppressFileOutput:p,suppressPassingFiles:f,topSummary:v,showErrorDetails:g,worstCoverageCount:w,vitestArgs:A},totals:{testFiles:b.length,failedFiles:ce.length,passedFiles:j.length-ce.length},results:{all:j,failed:ce},merge:{blobFiles:Ee.length,exitCode:pe,output:ye},coverageSummary:Ze,...v?{topMemoryUsers:[...F].sort((M,U)=>U.heapMb-M.heapMb).slice(0,10),topDuration:[...j].sort((M,U)=>U.duration-M.duration).slice(0,10)}:{}}}return Ye}let q=await de({cwd:o,testDir:r,testPatterns:s,testListFile:n,testFilePattern:a,earlyRunPatterns:x}),dt=Ie(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),m?{exitCode:1,mode:"standard",message:i,options:{cwd:o,testDir:r,testPatterns:s,testListFile:n,workers:h,coverageQuiet:c,suppressFileOutput:p,suppressPassingFiles:f,topSummary:v,vitestArgs:A}}:1}let He=q.filter(i=>x.some(u=>i.replace(/\\/g,"/").includes(u))),ve=q.filter(i=>!x.some(u=>i.replace(/\\/g,"/").includes(u))),gt=Date.now(),We=new Date().toLocaleTimeString("en-US",{hour12:!1});O&&!p&&s.length>0?console.log(`
28
+ \u{1F9EA} Running ${q.length} test files matching: ${s.join(", ")}`):O&&!p&&console.log(`
29
+ \u{1F9EA} Running ${q.length} test files (${He.length} solo first, then parallel)`),O&&!p&&(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=[...N??[]],Ke=async i=>{!p&&O&&(console.log(`
30
+ ${"=".repeat(80)}`),console.log(`\u25B6\uFE0F ${i}`),console.log("=".repeat(80)));let u=await ze(t,T++),b=await ge(i,{...he,maxOldSpaceMb:pt(i,B,y),vitestArgs:A,streamOutput:!p&&!m,excludePaths:dt.get(i),extraEnv:{VITEST_RUNNER_TMP:u}});if(!p&&O){let D=(b.duration/1e3).toFixed(2);if(b.code===0){let k=b.heapMb?` | ${b.heapMb} MB heap`:"";console.log(`
32
31
  \u2705 PASSED (${D}s${k})
33
32
  `)}else console.log(`
34
33
  \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};
34
+ `)}return b};if(!N){for(let b of He){let D=await Ke(b).catch(k=>(O&&console.error(`Error running ${b}:`,k),null));D&&I.push(D)}let i=0,u=new Set;for(;i<ve.length||u.size>0;){for(;i<ve.length&&u.size<h;){let b=ve[i++],D=Ke(b).then(k=>I.push(k)).catch(k=>{O&&console.error(`Error running ${b}:`,k)}).finally(()=>u.delete(D));u.add(D)}u.size>0&&await Promise.race(u)}}let G=I.reduce((i,u)=>i+u.testFilesPass,0),V=I.reduce((i,u)=>i+u.testFilesFail,0),se=I.reduce((i,u)=>i+u.testsPass,0),ne=I.reduce((i,u)=>i+u.testsFail,0),re=I.reduce((i,u)=>i+(u.testsSkip||0),0),mt=I.reduce((i,u)=>i+u.duration,0),J=I.filter(i=>i.code!==0),le=I.filter(i=>i.code===0),ht=J.length>0?1:0,qe=process.memoryUsage(),$e=Math.round(qe.heapUsed/1024/1024),Se=Math.round(qe.rss/1024/1024),C=I.filter(i=>i.heapMb!==null),Ge=((Date.now()-gt)/1e3).toFixed(2),Je=(mt/1e3).toFixed(2);if(m)return{exitCode:ht,mode:"standard",options:{cwd:o,testDir:r,testPatterns:s,testListFile:n,workers:h,coverageQuiet:c,suppressFileOutput:p,suppressPassingFiles:f,topSummary:v,showErrorDetails:g,worstCoverageCount:w,vitestArgs:A},totals:{testFilesPass:G,testFilesFail:V,testsPass:se,testsFail:ne,testsSkip:re,totalTests:se+ne+re},timing:{startAt:We,wallClockSeconds:Number(Ge),testsSeconds:Number(Je)},heap:{scriptHeapMb:$e,scriptRssMb:Se,maxHeapMb:C.length>0?Math.max(...C.map(i=>i.heapMb)):null,avgHeapMb:C.length>0?Number((C.reduce((i,u)=>i+u.heapMb,0)/C.length).toFixed(0)):null},results:{all:I,passed:le,failed:J},...v?{topMemoryUsers:[...C].sort((i,u)=>u.heapMb-i.heapMb).slice(0,10),topDuration:[...I].sort((i,u)=>u.duration-i.duration).slice(0,10)}:{}};console.log(`
35
+ `+"=".repeat(80)),v&&C.length>0&&(console.log(`
36
+ `+S.bold("\u{1F9E0} TOP MEMORY USERS")),console.log("-".repeat(80)),[...C].sort((i,u)=>u.heapMb-i.heapMb).slice(0,10).forEach(i=>{console.log(` ${String(i.heapMb).padStart(4)} MB ${S.dim(i.file)}`)})),v&&I.length>0&&(console.log(`
37
+ `+S.bold("\u23F1\uFE0F TOP DURATION")),console.log("-".repeat(80)),[...I].sort((i,u)=>u.duration-i.duration).slice(0,10).forEach(i=>{let u=(i.duration/1e3).toFixed(2);console.log(` ${(u+"s").padStart(8)} ${S.dim(i.file)}`)})),le.length>0&&!f&&(console.log(`
38
+ `+"=".repeat(80)),console.log(S.bold.green("\u2713 PASSED TEST FILES")),console.log("=".repeat(80)),le.forEach(i=>{let u=(i.duration/1e3).toFixed(2),b=[...i.heapMb?[`${i.heapMb} MB`]:[],`${u}s`],D=i.testsPass>0?` - ${i.testsPass} tests`:"";console.log(S.green(`\u2713 ${i.file}${D}`)+S.dim(` (${b.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 u=(i.duration/1e3).toFixed(2),b=[...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`]:[],`${u}s`],k=b.length>0?` (${b.join(", ")})`:"";if(console.log(` ${S.red("\u2716")} ${i.file}${k}`+S.dim(` [${D.join(", ")}]`)),g&&i.errors.length>0){let Fe=Ce(i.errors).split(`
42
+ `).map(ie=>ie.trim()?` ${ie}`:"").join(`
43
+ `);console.log(Fe),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 vt=se+ne+re,$t=[...ne>0?[S.red(`${ne} failed`)]:[],...se>0?[S.green(`${se} passed`)]:[],...re>0?[S.yellow(`${re} skipped`)]:[]];if(console.log(` ${S.bold("Tests")} ${$t.join(` ${S.dim("|")} `)} ${S.dim(`(${vt})`)}`),console.log(` ${S.bold("Start at")} ${We}`),console.log(` ${S.bold("Duration")} ${Ge}s ${S.dim(`(tests ${Je}s)`)}`),C.length>0){let i=Math.max(...C.map(b=>b.heapMb)),u=(C.reduce((b,D)=>b+D.heapMb,0)/C.length).toFixed(0);console.log(` ${S.bold("Heap")} max ${i} MB | avg ${u} 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,Le as createCoverageProgressTracker,Ce as deduplicateErrors,fe as discoverFilesInDir,de as discoverVitestFiles,ee as formatDuration,Rt as makeRunTmpDir,_e as noopProgressTracker,Ae as parseVitestOutput,Ue as printCoverageSummary,Ve as printMergeOutput,Be as printQuietCoverageFailureDetails,Pe as resolveBin,Oe as resolveVitestConfig,To as run,Ne as runMergeReports,ge as runSingleFile,yt 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.4.4",
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": [
@@ -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;
@@ -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;