vitest 0.0.62 → 0.0.66
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/LICENSE +2 -1
- package/README.gh.md +11 -15
- package/dist/chunk-5TNYWP3O.js +81 -0
- package/dist/chunk-ANPMHBIF.js +253 -0
- package/dist/chunk-APGELTDH.js +19 -0
- package/dist/chunk-R2SMNEBL.js +95 -0
- package/dist/chunk-VLGIKNLC.js +78 -0
- package/dist/chunk-XUIDSY4V.js +35 -0
- package/dist/chunk-YPKHVZRP.js +86 -0
- package/dist/global-PRFYLY7P.js +22 -0
- package/dist/index.d.ts +33 -10
- package/dist/index.js +46 -1
- package/dist/node/cli.d.ts +0 -12
- package/dist/node/cli.js +2609 -19
- package/dist/{types-c0d293d3.d.ts → options-63a726fa.d.ts} +133 -148
- package/dist/runtime/entry.d.ts +1 -3
- package/dist/runtime/entry.js +2535 -9
- package/dist/{node → runtime}/worker.d.ts +4 -5
- package/dist/runtime/worker.js +263 -0
- package/package.json +40 -27
- package/dist/chunk-4HLM7BTV.js +0 -1
- package/dist/chunk-JKSYS65D.js +0 -1
- package/dist/chunk-LNO4ZIPT.js +0 -1
- package/dist/chunk-NTRHKVSE.js +0 -1
- package/dist/global-GT6TCEAH.js +0 -1
- package/dist/node/worker.js +0 -4
package/dist/node/cli.js
CHANGED
|
@@ -1,22 +1,2612 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {
|
|
2
|
+
addSnapshotResult,
|
|
3
|
+
emptySummary
|
|
4
|
+
} from "../chunk-VLGIKNLC.js";
|
|
5
|
+
import {
|
|
6
|
+
getNames,
|
|
7
|
+
getSuites,
|
|
8
|
+
getTests,
|
|
9
|
+
hasFailed,
|
|
10
|
+
notNullish,
|
|
11
|
+
slash,
|
|
12
|
+
toArray
|
|
13
|
+
} from "../chunk-5TNYWP3O.js";
|
|
14
|
+
import {
|
|
15
|
+
defaultExcludes,
|
|
16
|
+
defaultIncludes,
|
|
17
|
+
distDir
|
|
18
|
+
} from "../chunk-XUIDSY4V.js";
|
|
19
|
+
import {
|
|
20
|
+
__commonJS,
|
|
21
|
+
__privateAdd,
|
|
22
|
+
__privateGet,
|
|
23
|
+
__privateSet,
|
|
24
|
+
__privateWrapper,
|
|
25
|
+
__spreadProps,
|
|
26
|
+
__spreadValues,
|
|
27
|
+
__toModule,
|
|
28
|
+
init_esm_shims
|
|
29
|
+
} from "../chunk-R2SMNEBL.js";
|
|
30
|
+
|
|
31
|
+
// node_modules/.pnpm/emoji-regex@9.2.2/node_modules/emoji-regex/index.js
|
|
32
|
+
var require_emoji_regex = __commonJS({
|
|
33
|
+
"node_modules/.pnpm/emoji-regex@9.2.2/node_modules/emoji-regex/index.js"(exports, module) {
|
|
34
|
+
init_esm_shims();
|
|
35
|
+
"use strict";
|
|
36
|
+
module.exports = function() {
|
|
37
|
+
return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// src/node/cli.ts
|
|
43
|
+
init_esm_shims();
|
|
44
|
+
|
|
45
|
+
// node_modules/.pnpm/cac@6.7.12/node_modules/cac/dist/index.mjs
|
|
46
|
+
init_esm_shims();
|
|
47
|
+
import { EventEmitter } from "events";
|
|
48
|
+
function toArr(any) {
|
|
49
|
+
return any == null ? [] : Array.isArray(any) ? any : [any];
|
|
50
|
+
}
|
|
51
|
+
function toVal(out, key, val, opts) {
|
|
52
|
+
var x, old = out[key], nxt = !!~opts.string.indexOf(key) ? val == null || val === true ? "" : String(val) : typeof val === "boolean" ? val : !!~opts.boolean.indexOf(key) ? val === "false" ? false : val === "true" || (out._.push((x = +val, x * 0 === 0) ? x : val), !!val) : (x = +val, x * 0 === 0) ? x : val;
|
|
53
|
+
out[key] = old == null ? nxt : Array.isArray(old) ? old.concat(nxt) : [old, nxt];
|
|
54
|
+
}
|
|
55
|
+
function mri2(args, opts) {
|
|
56
|
+
args = args || [];
|
|
57
|
+
opts = opts || {};
|
|
58
|
+
var k, arr, arg, name, val, out = { _: [] };
|
|
59
|
+
var i = 0, j = 0, idx = 0, len = args.length;
|
|
60
|
+
const alibi = opts.alias !== void 0;
|
|
61
|
+
const strict = opts.unknown !== void 0;
|
|
62
|
+
const defaults = opts.default !== void 0;
|
|
63
|
+
opts.alias = opts.alias || {};
|
|
64
|
+
opts.string = toArr(opts.string);
|
|
65
|
+
opts.boolean = toArr(opts.boolean);
|
|
66
|
+
if (alibi) {
|
|
67
|
+
for (k in opts.alias) {
|
|
68
|
+
arr = opts.alias[k] = toArr(opts.alias[k]);
|
|
69
|
+
for (i = 0; i < arr.length; i++) {
|
|
70
|
+
(opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
for (i = opts.boolean.length; i-- > 0; ) {
|
|
75
|
+
arr = opts.alias[opts.boolean[i]] || [];
|
|
76
|
+
for (j = arr.length; j-- > 0; )
|
|
77
|
+
opts.boolean.push(arr[j]);
|
|
78
|
+
}
|
|
79
|
+
for (i = opts.string.length; i-- > 0; ) {
|
|
80
|
+
arr = opts.alias[opts.string[i]] || [];
|
|
81
|
+
for (j = arr.length; j-- > 0; )
|
|
82
|
+
opts.string.push(arr[j]);
|
|
83
|
+
}
|
|
84
|
+
if (defaults) {
|
|
85
|
+
for (k in opts.default) {
|
|
86
|
+
name = typeof opts.default[k];
|
|
87
|
+
arr = opts.alias[k] = opts.alias[k] || [];
|
|
88
|
+
if (opts[name] !== void 0) {
|
|
89
|
+
opts[name].push(k);
|
|
90
|
+
for (i = 0; i < arr.length; i++) {
|
|
91
|
+
opts[name].push(arr[i]);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const keys = strict ? Object.keys(opts.alias) : [];
|
|
97
|
+
for (i = 0; i < len; i++) {
|
|
98
|
+
arg = args[i];
|
|
99
|
+
if (arg === "--") {
|
|
100
|
+
out._ = out._.concat(args.slice(++i));
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
for (j = 0; j < arg.length; j++) {
|
|
104
|
+
if (arg.charCodeAt(j) !== 45)
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
if (j === 0) {
|
|
108
|
+
out._.push(arg);
|
|
109
|
+
} else if (arg.substring(j, j + 3) === "no-") {
|
|
110
|
+
name = arg.substring(j + 3);
|
|
111
|
+
if (strict && !~keys.indexOf(name)) {
|
|
112
|
+
return opts.unknown(arg);
|
|
113
|
+
}
|
|
114
|
+
out[name] = false;
|
|
115
|
+
} else {
|
|
116
|
+
for (idx = j + 1; idx < arg.length; idx++) {
|
|
117
|
+
if (arg.charCodeAt(idx) === 61)
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
name = arg.substring(j, idx);
|
|
121
|
+
val = arg.substring(++idx) || (i + 1 === len || ("" + args[i + 1]).charCodeAt(0) === 45 || args[++i]);
|
|
122
|
+
arr = j === 2 ? [name] : name;
|
|
123
|
+
for (idx = 0; idx < arr.length; idx++) {
|
|
124
|
+
name = arr[idx];
|
|
125
|
+
if (strict && !~keys.indexOf(name))
|
|
126
|
+
return opts.unknown("-".repeat(j) + name);
|
|
127
|
+
toVal(out, name, idx + 1 < arr.length || val, opts);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (defaults) {
|
|
132
|
+
for (k in opts.default) {
|
|
133
|
+
if (out[k] === void 0) {
|
|
134
|
+
out[k] = opts.default[k];
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (alibi) {
|
|
139
|
+
for (k in out) {
|
|
140
|
+
arr = opts.alias[k] || [];
|
|
141
|
+
while (arr.length > 0) {
|
|
142
|
+
out[arr.shift()] = out[k];
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return out;
|
|
147
|
+
}
|
|
148
|
+
var removeBrackets = (v) => v.replace(/[<[].+/, "").trim();
|
|
149
|
+
var findAllBrackets = (v) => {
|
|
150
|
+
const ANGLED_BRACKET_RE_GLOBAL = /<([^>]+)>/g;
|
|
151
|
+
const SQUARE_BRACKET_RE_GLOBAL = /\[([^\]]+)\]/g;
|
|
152
|
+
const res = [];
|
|
153
|
+
const parse = (match) => {
|
|
154
|
+
let variadic = false;
|
|
155
|
+
let value = match[1];
|
|
156
|
+
if (value.startsWith("...")) {
|
|
157
|
+
value = value.slice(3);
|
|
158
|
+
variadic = true;
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
required: match[0].startsWith("<"),
|
|
162
|
+
value,
|
|
163
|
+
variadic
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
let angledMatch;
|
|
167
|
+
while (angledMatch = ANGLED_BRACKET_RE_GLOBAL.exec(v)) {
|
|
168
|
+
res.push(parse(angledMatch));
|
|
169
|
+
}
|
|
170
|
+
let squareMatch;
|
|
171
|
+
while (squareMatch = SQUARE_BRACKET_RE_GLOBAL.exec(v)) {
|
|
172
|
+
res.push(parse(squareMatch));
|
|
173
|
+
}
|
|
174
|
+
return res;
|
|
175
|
+
};
|
|
176
|
+
var getMriOptions = (options) => {
|
|
177
|
+
const result = { alias: {}, boolean: [] };
|
|
178
|
+
for (const [index, option] of options.entries()) {
|
|
179
|
+
if (option.names.length > 1) {
|
|
180
|
+
result.alias[option.names[0]] = option.names.slice(1);
|
|
181
|
+
}
|
|
182
|
+
if (option.isBoolean) {
|
|
183
|
+
if (option.negated) {
|
|
184
|
+
const hasStringTypeOption = options.some((o, i) => {
|
|
185
|
+
return i !== index && o.names.some((name) => option.names.includes(name)) && typeof o.required === "boolean";
|
|
186
|
+
});
|
|
187
|
+
if (!hasStringTypeOption) {
|
|
188
|
+
result.boolean.push(option.names[0]);
|
|
189
|
+
}
|
|
190
|
+
} else {
|
|
191
|
+
result.boolean.push(option.names[0]);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return result;
|
|
196
|
+
};
|
|
197
|
+
var findLongest = (arr) => {
|
|
198
|
+
return arr.sort((a, b) => {
|
|
199
|
+
return a.length > b.length ? -1 : 1;
|
|
200
|
+
})[0];
|
|
201
|
+
};
|
|
202
|
+
var padRight = (str, length) => {
|
|
203
|
+
return str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`;
|
|
204
|
+
};
|
|
205
|
+
var camelcase = (input) => {
|
|
206
|
+
return input.replace(/([a-z])-([a-z])/g, (_, p1, p2) => {
|
|
207
|
+
return p1 + p2.toUpperCase();
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
var setDotProp = (obj, keys, val) => {
|
|
211
|
+
let i = 0;
|
|
212
|
+
let length = keys.length;
|
|
213
|
+
let t = obj;
|
|
214
|
+
let x;
|
|
215
|
+
for (; i < length; ++i) {
|
|
216
|
+
x = t[keys[i]];
|
|
217
|
+
t = t[keys[i]] = i === length - 1 ? val : x != null ? x : !!~keys[i + 1].indexOf(".") || !(+keys[i + 1] > -1) ? {} : [];
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
var setByType = (obj, transforms) => {
|
|
221
|
+
for (const key of Object.keys(transforms)) {
|
|
222
|
+
const transform = transforms[key];
|
|
223
|
+
if (transform.shouldTransform) {
|
|
224
|
+
obj[key] = Array.prototype.concat.call([], obj[key]);
|
|
225
|
+
if (typeof transform.transformFunction === "function") {
|
|
226
|
+
obj[key] = obj[key].map(transform.transformFunction);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
var getFileName = (input) => {
|
|
232
|
+
const m = /([^\\\/]+)$/.exec(input);
|
|
233
|
+
return m ? m[1] : "";
|
|
234
|
+
};
|
|
235
|
+
var camelcaseOptionName = (name) => {
|
|
236
|
+
return name.split(".").map((v, i) => {
|
|
237
|
+
return i === 0 ? camelcase(v) : v;
|
|
238
|
+
}).join(".");
|
|
239
|
+
};
|
|
240
|
+
var CACError = class extends Error {
|
|
241
|
+
constructor(message) {
|
|
242
|
+
super(message);
|
|
243
|
+
this.name = this.constructor.name;
|
|
244
|
+
if (typeof Error.captureStackTrace === "function") {
|
|
245
|
+
Error.captureStackTrace(this, this.constructor);
|
|
246
|
+
} else {
|
|
247
|
+
this.stack = new Error(message).stack;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
var Option = class {
|
|
252
|
+
constructor(rawName, description, config) {
|
|
253
|
+
this.rawName = rawName;
|
|
254
|
+
this.description = description;
|
|
255
|
+
this.config = Object.assign({}, config);
|
|
256
|
+
rawName = rawName.replace(/\.\*/g, "");
|
|
257
|
+
this.negated = false;
|
|
258
|
+
this.names = removeBrackets(rawName).split(",").map((v) => {
|
|
259
|
+
let name = v.trim().replace(/^-{1,2}/, "");
|
|
260
|
+
if (name.startsWith("no-")) {
|
|
261
|
+
this.negated = true;
|
|
262
|
+
name = name.replace(/^no-/, "");
|
|
263
|
+
}
|
|
264
|
+
return camelcaseOptionName(name);
|
|
265
|
+
}).sort((a, b) => a.length > b.length ? 1 : -1);
|
|
266
|
+
this.name = this.names[this.names.length - 1];
|
|
267
|
+
if (this.negated && this.config.default == null) {
|
|
268
|
+
this.config.default = true;
|
|
269
|
+
}
|
|
270
|
+
if (rawName.includes("<")) {
|
|
271
|
+
this.required = true;
|
|
272
|
+
} else if (rawName.includes("[")) {
|
|
273
|
+
this.required = false;
|
|
274
|
+
} else {
|
|
275
|
+
this.isBoolean = true;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
var processArgs = process.argv;
|
|
280
|
+
var platformInfo = `${process.platform}-${process.arch} node-${process.version}`;
|
|
281
|
+
var Command = class {
|
|
282
|
+
constructor(rawName, description, config = {}, cli2) {
|
|
283
|
+
this.rawName = rawName;
|
|
284
|
+
this.description = description;
|
|
285
|
+
this.config = config;
|
|
286
|
+
this.cli = cli2;
|
|
287
|
+
this.options = [];
|
|
288
|
+
this.aliasNames = [];
|
|
289
|
+
this.name = removeBrackets(rawName);
|
|
290
|
+
this.args = findAllBrackets(rawName);
|
|
291
|
+
this.examples = [];
|
|
292
|
+
}
|
|
293
|
+
usage(text) {
|
|
294
|
+
this.usageText = text;
|
|
295
|
+
return this;
|
|
296
|
+
}
|
|
297
|
+
allowUnknownOptions() {
|
|
298
|
+
this.config.allowUnknownOptions = true;
|
|
299
|
+
return this;
|
|
300
|
+
}
|
|
301
|
+
ignoreOptionDefaultValue() {
|
|
302
|
+
this.config.ignoreOptionDefaultValue = true;
|
|
303
|
+
return this;
|
|
304
|
+
}
|
|
305
|
+
version(version2, customFlags = "-v, --version") {
|
|
306
|
+
this.versionNumber = version2;
|
|
307
|
+
this.option(customFlags, "Display version number");
|
|
308
|
+
return this;
|
|
309
|
+
}
|
|
310
|
+
example(example) {
|
|
311
|
+
this.examples.push(example);
|
|
312
|
+
return this;
|
|
313
|
+
}
|
|
314
|
+
option(rawName, description, config) {
|
|
315
|
+
const option = new Option(rawName, description, config);
|
|
316
|
+
this.options.push(option);
|
|
317
|
+
return this;
|
|
318
|
+
}
|
|
319
|
+
alias(name) {
|
|
320
|
+
this.aliasNames.push(name);
|
|
321
|
+
return this;
|
|
322
|
+
}
|
|
323
|
+
action(callback) {
|
|
324
|
+
this.commandAction = callback;
|
|
325
|
+
return this;
|
|
326
|
+
}
|
|
327
|
+
isMatched(name) {
|
|
328
|
+
return this.name === name || this.aliasNames.includes(name);
|
|
329
|
+
}
|
|
330
|
+
get isDefaultCommand() {
|
|
331
|
+
return this.name === "" || this.aliasNames.includes("!");
|
|
332
|
+
}
|
|
333
|
+
get isGlobalCommand() {
|
|
334
|
+
return this instanceof GlobalCommand;
|
|
335
|
+
}
|
|
336
|
+
hasOption(name) {
|
|
337
|
+
name = name.split(".")[0];
|
|
338
|
+
return this.options.find((option) => {
|
|
339
|
+
return option.names.includes(name);
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
outputHelp() {
|
|
343
|
+
const { name, commands } = this.cli;
|
|
344
|
+
const {
|
|
345
|
+
versionNumber,
|
|
346
|
+
options: globalOptions,
|
|
347
|
+
helpCallback
|
|
348
|
+
} = this.cli.globalCommand;
|
|
349
|
+
let sections = [
|
|
350
|
+
{
|
|
351
|
+
body: `${name}${versionNumber ? `/${versionNumber}` : ""}`
|
|
352
|
+
}
|
|
353
|
+
];
|
|
354
|
+
sections.push({
|
|
355
|
+
title: "Usage",
|
|
356
|
+
body: ` $ ${name} ${this.usageText || this.rawName}`
|
|
357
|
+
});
|
|
358
|
+
const showCommands = (this.isGlobalCommand || this.isDefaultCommand) && commands.length > 0;
|
|
359
|
+
if (showCommands) {
|
|
360
|
+
const longestCommandName = findLongest(commands.map((command) => command.rawName));
|
|
361
|
+
sections.push({
|
|
362
|
+
title: "Commands",
|
|
363
|
+
body: commands.map((command) => {
|
|
364
|
+
return ` ${padRight(command.rawName, longestCommandName.length)} ${command.description}`;
|
|
365
|
+
}).join("\n")
|
|
366
|
+
});
|
|
367
|
+
sections.push({
|
|
368
|
+
title: `For more info, run any command with the \`--help\` flag`,
|
|
369
|
+
body: commands.map((command) => ` $ ${name}${command.name === "" ? "" : ` ${command.name}`} --help`).join("\n")
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
let options = this.isGlobalCommand ? globalOptions : [...this.options, ...globalOptions || []];
|
|
373
|
+
if (!this.isGlobalCommand && !this.isDefaultCommand) {
|
|
374
|
+
options = options.filter((option) => option.name !== "version");
|
|
375
|
+
}
|
|
376
|
+
if (options.length > 0) {
|
|
377
|
+
const longestOptionName = findLongest(options.map((option) => option.rawName));
|
|
378
|
+
sections.push({
|
|
379
|
+
title: "Options",
|
|
380
|
+
body: options.map((option) => {
|
|
381
|
+
return ` ${padRight(option.rawName, longestOptionName.length)} ${option.description} ${option.config.default === void 0 ? "" : `(default: ${option.config.default})`}`;
|
|
382
|
+
}).join("\n")
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
if (this.examples.length > 0) {
|
|
386
|
+
sections.push({
|
|
387
|
+
title: "Examples",
|
|
388
|
+
body: this.examples.map((example) => {
|
|
389
|
+
if (typeof example === "function") {
|
|
390
|
+
return example(name);
|
|
391
|
+
}
|
|
392
|
+
return example;
|
|
393
|
+
}).join("\n")
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
if (helpCallback) {
|
|
397
|
+
sections = helpCallback(sections) || sections;
|
|
398
|
+
}
|
|
399
|
+
console.log(sections.map((section) => {
|
|
400
|
+
return section.title ? `${section.title}:
|
|
401
|
+
${section.body}` : section.body;
|
|
402
|
+
}).join("\n\n"));
|
|
403
|
+
}
|
|
404
|
+
outputVersion() {
|
|
405
|
+
const { name } = this.cli;
|
|
406
|
+
const { versionNumber } = this.cli.globalCommand;
|
|
407
|
+
if (versionNumber) {
|
|
408
|
+
console.log(`${name}/${versionNumber} ${platformInfo}`);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
checkRequiredArgs() {
|
|
412
|
+
const minimalArgsCount = this.args.filter((arg) => arg.required).length;
|
|
413
|
+
if (this.cli.args.length < minimalArgsCount) {
|
|
414
|
+
throw new CACError(`missing required args for command \`${this.rawName}\``);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
checkUnknownOptions() {
|
|
418
|
+
const { options, globalCommand } = this.cli;
|
|
419
|
+
if (!this.config.allowUnknownOptions) {
|
|
420
|
+
for (const name of Object.keys(options)) {
|
|
421
|
+
if (name !== "--" && !this.hasOption(name) && !globalCommand.hasOption(name)) {
|
|
422
|
+
throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
checkOptionValue() {
|
|
428
|
+
const { options: parsedOptions, globalCommand } = this.cli;
|
|
429
|
+
const options = [...globalCommand.options, ...this.options];
|
|
430
|
+
for (const option of options) {
|
|
431
|
+
const value = parsedOptions[option.name.split(".")[0]];
|
|
432
|
+
if (option.required) {
|
|
433
|
+
const hasNegated = options.some((o) => o.negated && o.names.includes(option.name));
|
|
434
|
+
if (value === true || value === false && !hasNegated) {
|
|
435
|
+
throw new CACError(`option \`${option.rawName}\` value is missing`);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
var GlobalCommand = class extends Command {
|
|
442
|
+
constructor(cli2) {
|
|
443
|
+
super("@@global@@", "", {}, cli2);
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
var __assign = Object.assign;
|
|
447
|
+
var CAC = class extends EventEmitter {
|
|
448
|
+
constructor(name = "") {
|
|
449
|
+
super();
|
|
450
|
+
this.name = name;
|
|
451
|
+
this.commands = [];
|
|
452
|
+
this.rawArgs = [];
|
|
453
|
+
this.args = [];
|
|
454
|
+
this.options = {};
|
|
455
|
+
this.globalCommand = new GlobalCommand(this);
|
|
456
|
+
this.globalCommand.usage("<command> [options]");
|
|
457
|
+
}
|
|
458
|
+
usage(text) {
|
|
459
|
+
this.globalCommand.usage(text);
|
|
460
|
+
return this;
|
|
461
|
+
}
|
|
462
|
+
command(rawName, description, config) {
|
|
463
|
+
const command = new Command(rawName, description || "", config, this);
|
|
464
|
+
command.globalCommand = this.globalCommand;
|
|
465
|
+
this.commands.push(command);
|
|
466
|
+
return command;
|
|
467
|
+
}
|
|
468
|
+
option(rawName, description, config) {
|
|
469
|
+
this.globalCommand.option(rawName, description, config);
|
|
470
|
+
return this;
|
|
471
|
+
}
|
|
472
|
+
help(callback) {
|
|
473
|
+
this.globalCommand.option("-h, --help", "Display this message");
|
|
474
|
+
this.globalCommand.helpCallback = callback;
|
|
475
|
+
this.showHelpOnExit = true;
|
|
476
|
+
return this;
|
|
477
|
+
}
|
|
478
|
+
version(version2, customFlags = "-v, --version") {
|
|
479
|
+
this.globalCommand.version(version2, customFlags);
|
|
480
|
+
this.showVersionOnExit = true;
|
|
481
|
+
return this;
|
|
482
|
+
}
|
|
483
|
+
example(example) {
|
|
484
|
+
this.globalCommand.example(example);
|
|
485
|
+
return this;
|
|
486
|
+
}
|
|
487
|
+
outputHelp() {
|
|
488
|
+
if (this.matchedCommand) {
|
|
489
|
+
this.matchedCommand.outputHelp();
|
|
490
|
+
} else {
|
|
491
|
+
this.globalCommand.outputHelp();
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
outputVersion() {
|
|
495
|
+
this.globalCommand.outputVersion();
|
|
496
|
+
}
|
|
497
|
+
setParsedInfo({ args, options }, matchedCommand, matchedCommandName) {
|
|
498
|
+
this.args = args;
|
|
499
|
+
this.options = options;
|
|
500
|
+
if (matchedCommand) {
|
|
501
|
+
this.matchedCommand = matchedCommand;
|
|
502
|
+
}
|
|
503
|
+
if (matchedCommandName) {
|
|
504
|
+
this.matchedCommandName = matchedCommandName;
|
|
505
|
+
}
|
|
506
|
+
return this;
|
|
507
|
+
}
|
|
508
|
+
unsetMatchedCommand() {
|
|
509
|
+
this.matchedCommand = void 0;
|
|
510
|
+
this.matchedCommandName = void 0;
|
|
511
|
+
}
|
|
512
|
+
parse(argv = processArgs, {
|
|
513
|
+
run: run2 = true
|
|
514
|
+
} = {}) {
|
|
515
|
+
this.rawArgs = argv;
|
|
516
|
+
if (!this.name) {
|
|
517
|
+
this.name = argv[1] ? getFileName(argv[1]) : "cli";
|
|
518
|
+
}
|
|
519
|
+
let shouldParse = true;
|
|
520
|
+
for (const command of this.commands) {
|
|
521
|
+
const parsed = this.mri(argv.slice(2), command);
|
|
522
|
+
const commandName = parsed.args[0];
|
|
523
|
+
if (command.isMatched(commandName)) {
|
|
524
|
+
shouldParse = false;
|
|
525
|
+
const parsedInfo = __assign(__assign({}, parsed), {
|
|
526
|
+
args: parsed.args.slice(1)
|
|
527
|
+
});
|
|
528
|
+
this.setParsedInfo(parsedInfo, command, commandName);
|
|
529
|
+
this.emit(`command:${commandName}`, command);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
if (shouldParse) {
|
|
533
|
+
for (const command of this.commands) {
|
|
534
|
+
if (command.name === "") {
|
|
535
|
+
shouldParse = false;
|
|
536
|
+
const parsed = this.mri(argv.slice(2), command);
|
|
537
|
+
this.setParsedInfo(parsed, command);
|
|
538
|
+
this.emit(`command:!`, command);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
if (shouldParse) {
|
|
543
|
+
const parsed = this.mri(argv.slice(2));
|
|
544
|
+
this.setParsedInfo(parsed);
|
|
545
|
+
}
|
|
546
|
+
if (this.options.help && this.showHelpOnExit) {
|
|
547
|
+
this.outputHelp();
|
|
548
|
+
run2 = false;
|
|
549
|
+
this.unsetMatchedCommand();
|
|
550
|
+
}
|
|
551
|
+
if (this.options.version && this.showVersionOnExit && this.matchedCommandName == null) {
|
|
552
|
+
this.outputVersion();
|
|
553
|
+
run2 = false;
|
|
554
|
+
this.unsetMatchedCommand();
|
|
555
|
+
}
|
|
556
|
+
const parsedArgv = { args: this.args, options: this.options };
|
|
557
|
+
if (run2) {
|
|
558
|
+
this.runMatchedCommand();
|
|
559
|
+
}
|
|
560
|
+
if (!this.matchedCommand && this.args[0]) {
|
|
561
|
+
this.emit("command:*");
|
|
562
|
+
}
|
|
563
|
+
return parsedArgv;
|
|
564
|
+
}
|
|
565
|
+
mri(argv, command) {
|
|
566
|
+
const cliOptions = [
|
|
567
|
+
...this.globalCommand.options,
|
|
568
|
+
...command ? command.options : []
|
|
569
|
+
];
|
|
570
|
+
const mriOptions = getMriOptions(cliOptions);
|
|
571
|
+
let argsAfterDoubleDashes = [];
|
|
572
|
+
const doubleDashesIndex = argv.indexOf("--");
|
|
573
|
+
if (doubleDashesIndex > -1) {
|
|
574
|
+
argsAfterDoubleDashes = argv.slice(doubleDashesIndex + 1);
|
|
575
|
+
argv = argv.slice(0, doubleDashesIndex);
|
|
576
|
+
}
|
|
577
|
+
let parsed = mri2(argv, mriOptions);
|
|
578
|
+
parsed = Object.keys(parsed).reduce((res, name) => {
|
|
579
|
+
return __assign(__assign({}, res), {
|
|
580
|
+
[camelcaseOptionName(name)]: parsed[name]
|
|
581
|
+
});
|
|
582
|
+
}, { _: [] });
|
|
583
|
+
const args = parsed._;
|
|
584
|
+
const options = {
|
|
585
|
+
"--": argsAfterDoubleDashes
|
|
586
|
+
};
|
|
587
|
+
const ignoreDefault = command && command.config.ignoreOptionDefaultValue ? command.config.ignoreOptionDefaultValue : this.globalCommand.config.ignoreOptionDefaultValue;
|
|
588
|
+
let transforms = Object.create(null);
|
|
589
|
+
for (const cliOption of cliOptions) {
|
|
590
|
+
if (!ignoreDefault && cliOption.config.default !== void 0) {
|
|
591
|
+
for (const name of cliOption.names) {
|
|
592
|
+
options[name] = cliOption.config.default;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
if (Array.isArray(cliOption.config.type)) {
|
|
596
|
+
if (transforms[cliOption.name] === void 0) {
|
|
597
|
+
transforms[cliOption.name] = Object.create(null);
|
|
598
|
+
transforms[cliOption.name]["shouldTransform"] = true;
|
|
599
|
+
transforms[cliOption.name]["transformFunction"] = cliOption.config.type[0];
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
for (const key of Object.keys(parsed)) {
|
|
604
|
+
if (key !== "_") {
|
|
605
|
+
const keys = key.split(".");
|
|
606
|
+
setDotProp(options, keys, parsed[key]);
|
|
607
|
+
setByType(options, transforms);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
return {
|
|
611
|
+
args,
|
|
612
|
+
options
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
runMatchedCommand() {
|
|
616
|
+
const { args, options, matchedCommand: command } = this;
|
|
617
|
+
if (!command || !command.commandAction)
|
|
618
|
+
return;
|
|
619
|
+
command.checkUnknownOptions();
|
|
620
|
+
command.checkOptionValue();
|
|
621
|
+
command.checkRequiredArgs();
|
|
622
|
+
const actionArgs = [];
|
|
623
|
+
command.args.forEach((arg, index) => {
|
|
624
|
+
if (arg.variadic) {
|
|
625
|
+
actionArgs.push(args.slice(index));
|
|
626
|
+
} else {
|
|
627
|
+
actionArgs.push(args[index]);
|
|
628
|
+
}
|
|
629
|
+
});
|
|
630
|
+
actionArgs.push(options);
|
|
631
|
+
return command.commandAction.apply(this, actionArgs);
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
var cac = (name = "") => new CAC(name);
|
|
635
|
+
var dist_default = cac;
|
|
636
|
+
|
|
637
|
+
// src/node/cli.ts
|
|
638
|
+
import c4 from "picocolors";
|
|
639
|
+
|
|
640
|
+
// package.json
|
|
641
|
+
var version = "0.0.66";
|
|
642
|
+
|
|
643
|
+
// src/reporters/default.ts
|
|
644
|
+
init_esm_shims();
|
|
645
|
+
import { performance } from "perf_hooks";
|
|
646
|
+
import { relative as relative2 } from "path";
|
|
647
|
+
import c3 from "picocolors";
|
|
648
|
+
|
|
649
|
+
// src/reporters/error.ts
|
|
650
|
+
init_esm_shims();
|
|
651
|
+
import { promises as fs, existsSync } from "fs";
|
|
652
|
+
import c from "picocolors";
|
|
653
|
+
|
|
654
|
+
// node_modules/.pnpm/diff@5.0.0/node_modules/diff/lib/index.mjs
|
|
655
|
+
init_esm_shims();
|
|
656
|
+
function Diff() {
|
|
657
|
+
}
|
|
658
|
+
Diff.prototype = {
|
|
659
|
+
diff: function diff(oldString, newString) {
|
|
660
|
+
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
661
|
+
var callback = options.callback;
|
|
662
|
+
if (typeof options === "function") {
|
|
663
|
+
callback = options;
|
|
664
|
+
options = {};
|
|
665
|
+
}
|
|
666
|
+
this.options = options;
|
|
667
|
+
var self = this;
|
|
668
|
+
function done(value) {
|
|
669
|
+
if (callback) {
|
|
670
|
+
setTimeout(function() {
|
|
671
|
+
callback(void 0, value);
|
|
672
|
+
}, 0);
|
|
673
|
+
return true;
|
|
674
|
+
} else {
|
|
675
|
+
return value;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
oldString = this.castInput(oldString);
|
|
679
|
+
newString = this.castInput(newString);
|
|
680
|
+
oldString = this.removeEmpty(this.tokenize(oldString));
|
|
681
|
+
newString = this.removeEmpty(this.tokenize(newString));
|
|
682
|
+
var newLen = newString.length, oldLen = oldString.length;
|
|
683
|
+
var editLength = 1;
|
|
684
|
+
var maxEditLength = newLen + oldLen;
|
|
685
|
+
var bestPath = [{
|
|
686
|
+
newPos: -1,
|
|
687
|
+
components: []
|
|
688
|
+
}];
|
|
689
|
+
var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
|
|
690
|
+
if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
|
|
691
|
+
return done([{
|
|
692
|
+
value: this.join(newString),
|
|
693
|
+
count: newString.length
|
|
694
|
+
}]);
|
|
695
|
+
}
|
|
696
|
+
function execEditLength() {
|
|
697
|
+
for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
|
|
698
|
+
var basePath = void 0;
|
|
699
|
+
var addPath = bestPath[diagonalPath - 1], removePath = bestPath[diagonalPath + 1], _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
|
|
700
|
+
if (addPath) {
|
|
701
|
+
bestPath[diagonalPath - 1] = void 0;
|
|
702
|
+
}
|
|
703
|
+
var canAdd = addPath && addPath.newPos + 1 < newLen, canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
|
|
704
|
+
if (!canAdd && !canRemove) {
|
|
705
|
+
bestPath[diagonalPath] = void 0;
|
|
706
|
+
continue;
|
|
707
|
+
}
|
|
708
|
+
if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
|
|
709
|
+
basePath = clonePath(removePath);
|
|
710
|
+
self.pushComponent(basePath.components, void 0, true);
|
|
711
|
+
} else {
|
|
712
|
+
basePath = addPath;
|
|
713
|
+
basePath.newPos++;
|
|
714
|
+
self.pushComponent(basePath.components, true, void 0);
|
|
715
|
+
}
|
|
716
|
+
_oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath);
|
|
717
|
+
if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
|
|
718
|
+
return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
|
|
719
|
+
} else {
|
|
720
|
+
bestPath[diagonalPath] = basePath;
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
editLength++;
|
|
724
|
+
}
|
|
725
|
+
if (callback) {
|
|
726
|
+
(function exec() {
|
|
727
|
+
setTimeout(function() {
|
|
728
|
+
if (editLength > maxEditLength) {
|
|
729
|
+
return callback();
|
|
730
|
+
}
|
|
731
|
+
if (!execEditLength()) {
|
|
732
|
+
exec();
|
|
733
|
+
}
|
|
734
|
+
}, 0);
|
|
735
|
+
})();
|
|
736
|
+
} else {
|
|
737
|
+
while (editLength <= maxEditLength) {
|
|
738
|
+
var ret = execEditLength();
|
|
739
|
+
if (ret) {
|
|
740
|
+
return ret;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
},
|
|
745
|
+
pushComponent: function pushComponent(components, added, removed) {
|
|
746
|
+
var last = components[components.length - 1];
|
|
747
|
+
if (last && last.added === added && last.removed === removed) {
|
|
748
|
+
components[components.length - 1] = {
|
|
749
|
+
count: last.count + 1,
|
|
750
|
+
added,
|
|
751
|
+
removed
|
|
752
|
+
};
|
|
753
|
+
} else {
|
|
754
|
+
components.push({
|
|
755
|
+
count: 1,
|
|
756
|
+
added,
|
|
757
|
+
removed
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
},
|
|
761
|
+
extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
|
|
762
|
+
var newLen = newString.length, oldLen = oldString.length, newPos = basePath.newPos, oldPos = newPos - diagonalPath, commonCount = 0;
|
|
763
|
+
while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
|
|
764
|
+
newPos++;
|
|
765
|
+
oldPos++;
|
|
766
|
+
commonCount++;
|
|
767
|
+
}
|
|
768
|
+
if (commonCount) {
|
|
769
|
+
basePath.components.push({
|
|
770
|
+
count: commonCount
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
basePath.newPos = newPos;
|
|
774
|
+
return oldPos;
|
|
775
|
+
},
|
|
776
|
+
equals: function equals(left, right) {
|
|
777
|
+
if (this.options.comparator) {
|
|
778
|
+
return this.options.comparator(left, right);
|
|
779
|
+
} else {
|
|
780
|
+
return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
|
|
781
|
+
}
|
|
782
|
+
},
|
|
783
|
+
removeEmpty: function removeEmpty(array) {
|
|
784
|
+
var ret = [];
|
|
785
|
+
for (var i = 0; i < array.length; i++) {
|
|
786
|
+
if (array[i]) {
|
|
787
|
+
ret.push(array[i]);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
return ret;
|
|
791
|
+
},
|
|
792
|
+
castInput: function castInput(value) {
|
|
793
|
+
return value;
|
|
794
|
+
},
|
|
795
|
+
tokenize: function tokenize(value) {
|
|
796
|
+
return value.split("");
|
|
797
|
+
},
|
|
798
|
+
join: function join(chars) {
|
|
799
|
+
return chars.join("");
|
|
800
|
+
}
|
|
801
|
+
};
|
|
802
|
+
function buildValues(diff2, components, newString, oldString, useLongestToken) {
|
|
803
|
+
var componentPos = 0, componentLen = components.length, newPos = 0, oldPos = 0;
|
|
804
|
+
for (; componentPos < componentLen; componentPos++) {
|
|
805
|
+
var component = components[componentPos];
|
|
806
|
+
if (!component.removed) {
|
|
807
|
+
if (!component.added && useLongestToken) {
|
|
808
|
+
var value = newString.slice(newPos, newPos + component.count);
|
|
809
|
+
value = value.map(function(value2, i) {
|
|
810
|
+
var oldValue = oldString[oldPos + i];
|
|
811
|
+
return oldValue.length > value2.length ? oldValue : value2;
|
|
812
|
+
});
|
|
813
|
+
component.value = diff2.join(value);
|
|
814
|
+
} else {
|
|
815
|
+
component.value = diff2.join(newString.slice(newPos, newPos + component.count));
|
|
816
|
+
}
|
|
817
|
+
newPos += component.count;
|
|
818
|
+
if (!component.added) {
|
|
819
|
+
oldPos += component.count;
|
|
820
|
+
}
|
|
821
|
+
} else {
|
|
822
|
+
component.value = diff2.join(oldString.slice(oldPos, oldPos + component.count));
|
|
823
|
+
oldPos += component.count;
|
|
824
|
+
if (componentPos && components[componentPos - 1].added) {
|
|
825
|
+
var tmp = components[componentPos - 1];
|
|
826
|
+
components[componentPos - 1] = components[componentPos];
|
|
827
|
+
components[componentPos] = tmp;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
var lastComponent = components[componentLen - 1];
|
|
832
|
+
if (componentLen > 1 && typeof lastComponent.value === "string" && (lastComponent.added || lastComponent.removed) && diff2.equals("", lastComponent.value)) {
|
|
833
|
+
components[componentLen - 2].value += lastComponent.value;
|
|
834
|
+
components.pop();
|
|
835
|
+
}
|
|
836
|
+
return components;
|
|
837
|
+
}
|
|
838
|
+
function clonePath(path3) {
|
|
839
|
+
return {
|
|
840
|
+
newPos: path3.newPos,
|
|
841
|
+
components: path3.components.slice(0)
|
|
842
|
+
};
|
|
843
|
+
}
|
|
844
|
+
var characterDiff = new Diff();
|
|
845
|
+
var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
|
|
846
|
+
var reWhitespace = /\S/;
|
|
847
|
+
var wordDiff = new Diff();
|
|
848
|
+
wordDiff.equals = function(left, right) {
|
|
849
|
+
if (this.options.ignoreCase) {
|
|
850
|
+
left = left.toLowerCase();
|
|
851
|
+
right = right.toLowerCase();
|
|
852
|
+
}
|
|
853
|
+
return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right);
|
|
854
|
+
};
|
|
855
|
+
wordDiff.tokenize = function(value) {
|
|
856
|
+
var tokens = value.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/);
|
|
857
|
+
for (var i = 0; i < tokens.length - 1; i++) {
|
|
858
|
+
if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) {
|
|
859
|
+
tokens[i] += tokens[i + 2];
|
|
860
|
+
tokens.splice(i + 1, 2);
|
|
861
|
+
i--;
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
return tokens;
|
|
865
|
+
};
|
|
866
|
+
var lineDiff = new Diff();
|
|
867
|
+
lineDiff.tokenize = function(value) {
|
|
868
|
+
var retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
|
|
869
|
+
if (!linesAndNewlines[linesAndNewlines.length - 1]) {
|
|
870
|
+
linesAndNewlines.pop();
|
|
871
|
+
}
|
|
872
|
+
for (var i = 0; i < linesAndNewlines.length; i++) {
|
|
873
|
+
var line = linesAndNewlines[i];
|
|
874
|
+
if (i % 2 && !this.options.newlineIsToken) {
|
|
875
|
+
retLines[retLines.length - 1] += line;
|
|
876
|
+
} else {
|
|
877
|
+
if (this.options.ignoreWhitespace) {
|
|
878
|
+
line = line.trim();
|
|
879
|
+
}
|
|
880
|
+
retLines.push(line);
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
return retLines;
|
|
884
|
+
};
|
|
885
|
+
function diffLines(oldStr, newStr, callback) {
|
|
886
|
+
return lineDiff.diff(oldStr, newStr, callback);
|
|
887
|
+
}
|
|
888
|
+
var sentenceDiff = new Diff();
|
|
889
|
+
sentenceDiff.tokenize = function(value) {
|
|
890
|
+
return value.split(/(\S.+?[.!?])(?=\s+|$)/);
|
|
891
|
+
};
|
|
892
|
+
var cssDiff = new Diff();
|
|
893
|
+
cssDiff.tokenize = function(value) {
|
|
894
|
+
return value.split(/([{}:;,]|\s+)/);
|
|
895
|
+
};
|
|
896
|
+
function _typeof(obj) {
|
|
897
|
+
"@babel/helpers - typeof";
|
|
898
|
+
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
899
|
+
_typeof = function(obj2) {
|
|
900
|
+
return typeof obj2;
|
|
901
|
+
};
|
|
902
|
+
} else {
|
|
903
|
+
_typeof = function(obj2) {
|
|
904
|
+
return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
return _typeof(obj);
|
|
908
|
+
}
|
|
909
|
+
function _toConsumableArray(arr) {
|
|
910
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
911
|
+
}
|
|
912
|
+
function _arrayWithoutHoles(arr) {
|
|
913
|
+
if (Array.isArray(arr))
|
|
914
|
+
return _arrayLikeToArray(arr);
|
|
915
|
+
}
|
|
916
|
+
function _iterableToArray(iter) {
|
|
917
|
+
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter))
|
|
918
|
+
return Array.from(iter);
|
|
919
|
+
}
|
|
920
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
921
|
+
if (!o)
|
|
922
|
+
return;
|
|
923
|
+
if (typeof o === "string")
|
|
924
|
+
return _arrayLikeToArray(o, minLen);
|
|
925
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
926
|
+
if (n === "Object" && o.constructor)
|
|
927
|
+
n = o.constructor.name;
|
|
928
|
+
if (n === "Map" || n === "Set")
|
|
929
|
+
return Array.from(o);
|
|
930
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
931
|
+
return _arrayLikeToArray(o, minLen);
|
|
932
|
+
}
|
|
933
|
+
function _arrayLikeToArray(arr, len) {
|
|
934
|
+
if (len == null || len > arr.length)
|
|
935
|
+
len = arr.length;
|
|
936
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
937
|
+
arr2[i] = arr[i];
|
|
938
|
+
return arr2;
|
|
939
|
+
}
|
|
940
|
+
function _nonIterableSpread() {
|
|
941
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
942
|
+
}
|
|
943
|
+
var objectPrototypeToString = Object.prototype.toString;
|
|
944
|
+
var jsonDiff = new Diff();
|
|
945
|
+
jsonDiff.useLongestToken = true;
|
|
946
|
+
jsonDiff.tokenize = lineDiff.tokenize;
|
|
947
|
+
jsonDiff.castInput = function(value) {
|
|
948
|
+
var _this$options = this.options, undefinedReplacement = _this$options.undefinedReplacement, _this$options$stringi = _this$options.stringifyReplacer, stringifyReplacer = _this$options$stringi === void 0 ? function(k, v) {
|
|
949
|
+
return typeof v === "undefined" ? undefinedReplacement : v;
|
|
950
|
+
} : _this$options$stringi;
|
|
951
|
+
return typeof value === "string" ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, " ");
|
|
952
|
+
};
|
|
953
|
+
jsonDiff.equals = function(left, right) {
|
|
954
|
+
return Diff.prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, "$1"), right.replace(/,([\r\n])/g, "$1"));
|
|
955
|
+
};
|
|
956
|
+
function canonicalize(obj, stack, replacementStack, replacer, key) {
|
|
957
|
+
stack = stack || [];
|
|
958
|
+
replacementStack = replacementStack || [];
|
|
959
|
+
if (replacer) {
|
|
960
|
+
obj = replacer(key, obj);
|
|
961
|
+
}
|
|
962
|
+
var i;
|
|
963
|
+
for (i = 0; i < stack.length; i += 1) {
|
|
964
|
+
if (stack[i] === obj) {
|
|
965
|
+
return replacementStack[i];
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
var canonicalizedObj;
|
|
969
|
+
if (objectPrototypeToString.call(obj) === "[object Array]") {
|
|
970
|
+
stack.push(obj);
|
|
971
|
+
canonicalizedObj = new Array(obj.length);
|
|
972
|
+
replacementStack.push(canonicalizedObj);
|
|
973
|
+
for (i = 0; i < obj.length; i += 1) {
|
|
974
|
+
canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key);
|
|
975
|
+
}
|
|
976
|
+
stack.pop();
|
|
977
|
+
replacementStack.pop();
|
|
978
|
+
return canonicalizedObj;
|
|
979
|
+
}
|
|
980
|
+
if (obj && obj.toJSON) {
|
|
981
|
+
obj = obj.toJSON();
|
|
982
|
+
}
|
|
983
|
+
if (_typeof(obj) === "object" && obj !== null) {
|
|
984
|
+
stack.push(obj);
|
|
985
|
+
canonicalizedObj = {};
|
|
986
|
+
replacementStack.push(canonicalizedObj);
|
|
987
|
+
var sortedKeys = [], _key;
|
|
988
|
+
for (_key in obj) {
|
|
989
|
+
if (obj.hasOwnProperty(_key)) {
|
|
990
|
+
sortedKeys.push(_key);
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
sortedKeys.sort();
|
|
994
|
+
for (i = 0; i < sortedKeys.length; i += 1) {
|
|
995
|
+
_key = sortedKeys[i];
|
|
996
|
+
canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key);
|
|
997
|
+
}
|
|
998
|
+
stack.pop();
|
|
999
|
+
replacementStack.pop();
|
|
1000
|
+
} else {
|
|
1001
|
+
canonicalizedObj = obj;
|
|
1002
|
+
}
|
|
1003
|
+
return canonicalizedObj;
|
|
1004
|
+
}
|
|
1005
|
+
var arrayDiff = new Diff();
|
|
1006
|
+
arrayDiff.tokenize = function(value) {
|
|
1007
|
+
return value.slice();
|
|
1008
|
+
};
|
|
1009
|
+
arrayDiff.join = arrayDiff.removeEmpty = function(value) {
|
|
1010
|
+
return value;
|
|
1011
|
+
};
|
|
1012
|
+
function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
|
|
1013
|
+
if (!options) {
|
|
1014
|
+
options = {};
|
|
1015
|
+
}
|
|
1016
|
+
if (typeof options.context === "undefined") {
|
|
1017
|
+
options.context = 4;
|
|
1018
|
+
}
|
|
1019
|
+
var diff2 = diffLines(oldStr, newStr, options);
|
|
1020
|
+
diff2.push({
|
|
1021
|
+
value: "",
|
|
1022
|
+
lines: []
|
|
1023
|
+
});
|
|
1024
|
+
function contextLines(lines) {
|
|
1025
|
+
return lines.map(function(entry) {
|
|
1026
|
+
return " " + entry;
|
|
1027
|
+
});
|
|
1028
|
+
}
|
|
1029
|
+
var hunks = [];
|
|
1030
|
+
var oldRangeStart = 0, newRangeStart = 0, curRange = [], oldLine = 1, newLine = 1;
|
|
1031
|
+
var _loop = function _loop2(i2) {
|
|
1032
|
+
var current = diff2[i2], lines = current.lines || current.value.replace(/\n$/, "").split("\n");
|
|
1033
|
+
current.lines = lines;
|
|
1034
|
+
if (current.added || current.removed) {
|
|
1035
|
+
var _curRange;
|
|
1036
|
+
if (!oldRangeStart) {
|
|
1037
|
+
var prev = diff2[i2 - 1];
|
|
1038
|
+
oldRangeStart = oldLine;
|
|
1039
|
+
newRangeStart = newLine;
|
|
1040
|
+
if (prev) {
|
|
1041
|
+
curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
|
|
1042
|
+
oldRangeStart -= curRange.length;
|
|
1043
|
+
newRangeStart -= curRange.length;
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
(_curRange = curRange).push.apply(_curRange, _toConsumableArray(lines.map(function(entry) {
|
|
1047
|
+
return (current.added ? "+" : "-") + entry;
|
|
1048
|
+
})));
|
|
1049
|
+
if (current.added) {
|
|
1050
|
+
newLine += lines.length;
|
|
1051
|
+
} else {
|
|
1052
|
+
oldLine += lines.length;
|
|
1053
|
+
}
|
|
1054
|
+
} else {
|
|
1055
|
+
if (oldRangeStart) {
|
|
1056
|
+
if (lines.length <= options.context * 2 && i2 < diff2.length - 2) {
|
|
1057
|
+
var _curRange2;
|
|
1058
|
+
(_curRange2 = curRange).push.apply(_curRange2, _toConsumableArray(contextLines(lines)));
|
|
1059
|
+
} else {
|
|
1060
|
+
var _curRange3;
|
|
1061
|
+
var contextSize = Math.min(lines.length, options.context);
|
|
1062
|
+
(_curRange3 = curRange).push.apply(_curRange3, _toConsumableArray(contextLines(lines.slice(0, contextSize))));
|
|
1063
|
+
var hunk = {
|
|
1064
|
+
oldStart: oldRangeStart,
|
|
1065
|
+
oldLines: oldLine - oldRangeStart + contextSize,
|
|
1066
|
+
newStart: newRangeStart,
|
|
1067
|
+
newLines: newLine - newRangeStart + contextSize,
|
|
1068
|
+
lines: curRange
|
|
1069
|
+
};
|
|
1070
|
+
if (i2 >= diff2.length - 2 && lines.length <= options.context) {
|
|
1071
|
+
var oldEOFNewline = /\n$/.test(oldStr);
|
|
1072
|
+
var newEOFNewline = /\n$/.test(newStr);
|
|
1073
|
+
var noNlBeforeAdds = lines.length == 0 && curRange.length > hunk.oldLines;
|
|
1074
|
+
if (!oldEOFNewline && noNlBeforeAdds && oldStr.length > 0) {
|
|
1075
|
+
curRange.splice(hunk.oldLines, 0, "\");
|
|
1076
|
+
}
|
|
1077
|
+
if (!oldEOFNewline && !noNlBeforeAdds || !newEOFNewline) {
|
|
1078
|
+
curRange.push("\");
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
hunks.push(hunk);
|
|
1082
|
+
oldRangeStart = 0;
|
|
1083
|
+
newRangeStart = 0;
|
|
1084
|
+
curRange = [];
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
oldLine += lines.length;
|
|
1088
|
+
newLine += lines.length;
|
|
1089
|
+
}
|
|
1090
|
+
};
|
|
1091
|
+
for (var i = 0; i < diff2.length; i++) {
|
|
1092
|
+
_loop(i);
|
|
1093
|
+
}
|
|
1094
|
+
return {
|
|
1095
|
+
oldFileName,
|
|
1096
|
+
newFileName,
|
|
1097
|
+
oldHeader,
|
|
1098
|
+
newHeader,
|
|
1099
|
+
hunks
|
|
1100
|
+
};
|
|
1101
|
+
}
|
|
1102
|
+
function formatPatch(diff2) {
|
|
1103
|
+
var ret = [];
|
|
1104
|
+
if (diff2.oldFileName == diff2.newFileName) {
|
|
1105
|
+
ret.push("Index: " + diff2.oldFileName);
|
|
1106
|
+
}
|
|
1107
|
+
ret.push("===================================================================");
|
|
1108
|
+
ret.push("--- " + diff2.oldFileName + (typeof diff2.oldHeader === "undefined" ? "" : " " + diff2.oldHeader));
|
|
1109
|
+
ret.push("+++ " + diff2.newFileName + (typeof diff2.newHeader === "undefined" ? "" : " " + diff2.newHeader));
|
|
1110
|
+
for (var i = 0; i < diff2.hunks.length; i++) {
|
|
1111
|
+
var hunk = diff2.hunks[i];
|
|
1112
|
+
if (hunk.oldLines === 0) {
|
|
1113
|
+
hunk.oldStart -= 1;
|
|
1114
|
+
}
|
|
1115
|
+
if (hunk.newLines === 0) {
|
|
1116
|
+
hunk.newStart -= 1;
|
|
1117
|
+
}
|
|
1118
|
+
ret.push("@@ -" + hunk.oldStart + "," + hunk.oldLines + " +" + hunk.newStart + "," + hunk.newLines + " @@");
|
|
1119
|
+
ret.push.apply(ret, hunk.lines);
|
|
1120
|
+
}
|
|
1121
|
+
return ret.join("\n") + "\n";
|
|
1122
|
+
}
|
|
1123
|
+
function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
|
|
1124
|
+
return formatPatch(structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options));
|
|
1125
|
+
}
|
|
1126
|
+
function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
|
|
1127
|
+
return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
// src/reporters/error.ts
|
|
1131
|
+
import { SourceMapConsumer } from "source-map";
|
|
1132
|
+
|
|
1133
|
+
// node_modules/.pnpm/cli-truncate@3.1.0/node_modules/cli-truncate/index.js
|
|
1134
|
+
init_esm_shims();
|
|
1135
|
+
|
|
1136
|
+
// node_modules/.pnpm/slice-ansi@5.0.0/node_modules/slice-ansi/index.js
|
|
1137
|
+
init_esm_shims();
|
|
1138
|
+
|
|
1139
|
+
// node_modules/.pnpm/is-fullwidth-code-point@4.0.0/node_modules/is-fullwidth-code-point/index.js
|
|
1140
|
+
init_esm_shims();
|
|
1141
|
+
function isFullwidthCodePoint(codePoint) {
|
|
1142
|
+
if (!Number.isInteger(codePoint)) {
|
|
1143
|
+
return false;
|
|
1144
|
+
}
|
|
1145
|
+
return codePoint >= 4352 && (codePoint <= 4447 || codePoint === 9001 || codePoint === 9002 || 11904 <= codePoint && codePoint <= 12871 && codePoint !== 12351 || 12880 <= codePoint && codePoint <= 19903 || 19968 <= codePoint && codePoint <= 42182 || 43360 <= codePoint && codePoint <= 43388 || 44032 <= codePoint && codePoint <= 55203 || 63744 <= codePoint && codePoint <= 64255 || 65040 <= codePoint && codePoint <= 65049 || 65072 <= codePoint && codePoint <= 65131 || 65281 <= codePoint && codePoint <= 65376 || 65504 <= codePoint && codePoint <= 65510 || 110592 <= codePoint && codePoint <= 110593 || 127488 <= codePoint && codePoint <= 127569 || 131072 <= codePoint && codePoint <= 262141);
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
// node_modules/.pnpm/ansi-styles@6.1.0/node_modules/ansi-styles/index.js
|
|
1149
|
+
init_esm_shims();
|
|
1150
|
+
var ANSI_BACKGROUND_OFFSET = 10;
|
|
1151
|
+
var wrapAnsi16 = (offset = 0) => (code) => `[${code + offset}m`;
|
|
1152
|
+
var wrapAnsi256 = (offset = 0) => (code) => `[${38 + offset};5;${code}m`;
|
|
1153
|
+
var wrapAnsi16m = (offset = 0) => (red, green, blue) => `[${38 + offset};2;${red};${green};${blue}m`;
|
|
1154
|
+
function assembleStyles() {
|
|
1155
|
+
const codes = /* @__PURE__ */ new Map();
|
|
1156
|
+
const styles = {
|
|
1157
|
+
modifier: {
|
|
1158
|
+
reset: [0, 0],
|
|
1159
|
+
bold: [1, 22],
|
|
1160
|
+
dim: [2, 22],
|
|
1161
|
+
italic: [3, 23],
|
|
1162
|
+
underline: [4, 24],
|
|
1163
|
+
overline: [53, 55],
|
|
1164
|
+
inverse: [7, 27],
|
|
1165
|
+
hidden: [8, 28],
|
|
1166
|
+
strikethrough: [9, 29]
|
|
1167
|
+
},
|
|
1168
|
+
color: {
|
|
1169
|
+
black: [30, 39],
|
|
1170
|
+
red: [31, 39],
|
|
1171
|
+
green: [32, 39],
|
|
1172
|
+
yellow: [33, 39],
|
|
1173
|
+
blue: [34, 39],
|
|
1174
|
+
magenta: [35, 39],
|
|
1175
|
+
cyan: [36, 39],
|
|
1176
|
+
white: [37, 39],
|
|
1177
|
+
blackBright: [90, 39],
|
|
1178
|
+
redBright: [91, 39],
|
|
1179
|
+
greenBright: [92, 39],
|
|
1180
|
+
yellowBright: [93, 39],
|
|
1181
|
+
blueBright: [94, 39],
|
|
1182
|
+
magentaBright: [95, 39],
|
|
1183
|
+
cyanBright: [96, 39],
|
|
1184
|
+
whiteBright: [97, 39]
|
|
1185
|
+
},
|
|
1186
|
+
bgColor: {
|
|
1187
|
+
bgBlack: [40, 49],
|
|
1188
|
+
bgRed: [41, 49],
|
|
1189
|
+
bgGreen: [42, 49],
|
|
1190
|
+
bgYellow: [43, 49],
|
|
1191
|
+
bgBlue: [44, 49],
|
|
1192
|
+
bgMagenta: [45, 49],
|
|
1193
|
+
bgCyan: [46, 49],
|
|
1194
|
+
bgWhite: [47, 49],
|
|
1195
|
+
bgBlackBright: [100, 49],
|
|
1196
|
+
bgRedBright: [101, 49],
|
|
1197
|
+
bgGreenBright: [102, 49],
|
|
1198
|
+
bgYellowBright: [103, 49],
|
|
1199
|
+
bgBlueBright: [104, 49],
|
|
1200
|
+
bgMagentaBright: [105, 49],
|
|
1201
|
+
bgCyanBright: [106, 49],
|
|
1202
|
+
bgWhiteBright: [107, 49]
|
|
1203
|
+
}
|
|
1204
|
+
};
|
|
1205
|
+
styles.color.gray = styles.color.blackBright;
|
|
1206
|
+
styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
|
|
1207
|
+
styles.color.grey = styles.color.blackBright;
|
|
1208
|
+
styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
|
|
1209
|
+
for (const [groupName, group] of Object.entries(styles)) {
|
|
1210
|
+
for (const [styleName, style] of Object.entries(group)) {
|
|
1211
|
+
styles[styleName] = {
|
|
1212
|
+
open: `[${style[0]}m`,
|
|
1213
|
+
close: `[${style[1]}m`
|
|
1214
|
+
};
|
|
1215
|
+
group[styleName] = styles[styleName];
|
|
1216
|
+
codes.set(style[0], style[1]);
|
|
1217
|
+
}
|
|
1218
|
+
Object.defineProperty(styles, groupName, {
|
|
1219
|
+
value: group,
|
|
1220
|
+
enumerable: false
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1223
|
+
Object.defineProperty(styles, "codes", {
|
|
1224
|
+
value: codes,
|
|
1225
|
+
enumerable: false
|
|
1226
|
+
});
|
|
1227
|
+
styles.color.close = "[39m";
|
|
1228
|
+
styles.bgColor.close = "[49m";
|
|
1229
|
+
styles.color.ansi = wrapAnsi16();
|
|
1230
|
+
styles.color.ansi256 = wrapAnsi256();
|
|
1231
|
+
styles.color.ansi16m = wrapAnsi16m();
|
|
1232
|
+
styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
|
|
1233
|
+
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
|
|
1234
|
+
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
|
1235
|
+
Object.defineProperties(styles, {
|
|
1236
|
+
rgbToAnsi256: {
|
|
1237
|
+
value: (red, green, blue) => {
|
|
1238
|
+
if (red === green && green === blue) {
|
|
1239
|
+
if (red < 8) {
|
|
1240
|
+
return 16;
|
|
1241
|
+
}
|
|
1242
|
+
if (red > 248) {
|
|
1243
|
+
return 231;
|
|
1244
|
+
}
|
|
1245
|
+
return Math.round((red - 8) / 247 * 24) + 232;
|
|
1246
|
+
}
|
|
1247
|
+
return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
|
|
1248
|
+
},
|
|
1249
|
+
enumerable: false
|
|
1250
|
+
},
|
|
1251
|
+
hexToRgb: {
|
|
1252
|
+
value: (hex) => {
|
|
1253
|
+
const matches = /(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(hex.toString(16));
|
|
1254
|
+
if (!matches) {
|
|
1255
|
+
return [0, 0, 0];
|
|
1256
|
+
}
|
|
1257
|
+
let { colorString } = matches.groups;
|
|
1258
|
+
if (colorString.length === 3) {
|
|
1259
|
+
colorString = colorString.split("").map((character) => character + character).join("");
|
|
1260
|
+
}
|
|
1261
|
+
const integer = Number.parseInt(colorString, 16);
|
|
1262
|
+
return [
|
|
1263
|
+
integer >> 16 & 255,
|
|
1264
|
+
integer >> 8 & 255,
|
|
1265
|
+
integer & 255
|
|
1266
|
+
];
|
|
1267
|
+
},
|
|
1268
|
+
enumerable: false
|
|
1269
|
+
},
|
|
1270
|
+
hexToAnsi256: {
|
|
1271
|
+
value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
|
|
1272
|
+
enumerable: false
|
|
1273
|
+
},
|
|
1274
|
+
ansi256ToAnsi: {
|
|
1275
|
+
value: (code) => {
|
|
1276
|
+
if (code < 8) {
|
|
1277
|
+
return 30 + code;
|
|
1278
|
+
}
|
|
1279
|
+
if (code < 16) {
|
|
1280
|
+
return 90 + (code - 8);
|
|
1281
|
+
}
|
|
1282
|
+
let red;
|
|
1283
|
+
let green;
|
|
1284
|
+
let blue;
|
|
1285
|
+
if (code >= 232) {
|
|
1286
|
+
red = ((code - 232) * 10 + 8) / 255;
|
|
1287
|
+
green = red;
|
|
1288
|
+
blue = red;
|
|
1289
|
+
} else {
|
|
1290
|
+
code -= 16;
|
|
1291
|
+
const remainder = code % 36;
|
|
1292
|
+
red = Math.floor(code / 36) / 5;
|
|
1293
|
+
green = Math.floor(remainder / 6) / 5;
|
|
1294
|
+
blue = remainder % 6 / 5;
|
|
1295
|
+
}
|
|
1296
|
+
const value = Math.max(red, green, blue) * 2;
|
|
1297
|
+
if (value === 0) {
|
|
1298
|
+
return 30;
|
|
1299
|
+
}
|
|
1300
|
+
let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
|
|
1301
|
+
if (value === 2) {
|
|
1302
|
+
result += 60;
|
|
1303
|
+
}
|
|
1304
|
+
return result;
|
|
1305
|
+
},
|
|
1306
|
+
enumerable: false
|
|
1307
|
+
},
|
|
1308
|
+
rgbToAnsi: {
|
|
1309
|
+
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
|
|
1310
|
+
enumerable: false
|
|
1311
|
+
},
|
|
1312
|
+
hexToAnsi: {
|
|
1313
|
+
value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
|
|
1314
|
+
enumerable: false
|
|
1315
|
+
}
|
|
1316
|
+
});
|
|
1317
|
+
return styles;
|
|
1318
|
+
}
|
|
1319
|
+
var ansiStyles = assembleStyles();
|
|
1320
|
+
var ansi_styles_default = ansiStyles;
|
|
1321
|
+
|
|
1322
|
+
// node_modules/.pnpm/slice-ansi@5.0.0/node_modules/slice-ansi/index.js
|
|
1323
|
+
var astralRegex = /^[\uD800-\uDBFF][\uDC00-\uDFFF]$/;
|
|
1324
|
+
var ESCAPES = [
|
|
1325
|
+
"",
|
|
1326
|
+
"\x9B"
|
|
1327
|
+
];
|
|
1328
|
+
var wrapAnsi = (code) => `${ESCAPES[0]}[${code}m`;
|
|
1329
|
+
var checkAnsi = (ansiCodes, isEscapes, endAnsiCode) => {
|
|
1330
|
+
let output = [];
|
|
1331
|
+
ansiCodes = [...ansiCodes];
|
|
1332
|
+
for (let ansiCode of ansiCodes) {
|
|
1333
|
+
const ansiCodeOrigin = ansiCode;
|
|
1334
|
+
if (ansiCode.includes(";")) {
|
|
1335
|
+
ansiCode = ansiCode.split(";")[0][0] + "0";
|
|
1336
|
+
}
|
|
1337
|
+
const item = ansi_styles_default.codes.get(Number.parseInt(ansiCode, 10));
|
|
1338
|
+
if (item) {
|
|
1339
|
+
const indexEscape = ansiCodes.indexOf(item.toString());
|
|
1340
|
+
if (indexEscape === -1) {
|
|
1341
|
+
output.push(wrapAnsi(isEscapes ? item : ansiCodeOrigin));
|
|
1342
|
+
} else {
|
|
1343
|
+
ansiCodes.splice(indexEscape, 1);
|
|
1344
|
+
}
|
|
1345
|
+
} else if (isEscapes) {
|
|
1346
|
+
output.push(wrapAnsi(0));
|
|
1347
|
+
break;
|
|
1348
|
+
} else {
|
|
1349
|
+
output.push(wrapAnsi(ansiCodeOrigin));
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
if (isEscapes) {
|
|
1353
|
+
output = output.filter((element, index) => output.indexOf(element) === index);
|
|
1354
|
+
if (endAnsiCode !== void 0) {
|
|
1355
|
+
const fistEscapeCode = wrapAnsi(ansi_styles_default.codes.get(Number.parseInt(endAnsiCode, 10)));
|
|
1356
|
+
output = output.reduce((current, next) => next === fistEscapeCode ? [next, ...current] : [...current, next], []);
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
return output.join("");
|
|
1360
|
+
};
|
|
1361
|
+
function sliceAnsi(string, begin, end) {
|
|
1362
|
+
const characters = [...string];
|
|
1363
|
+
const ansiCodes = [];
|
|
1364
|
+
let stringEnd = typeof end === "number" ? end : characters.length;
|
|
1365
|
+
let isInsideEscape = false;
|
|
1366
|
+
let ansiCode;
|
|
1367
|
+
let visible = 0;
|
|
1368
|
+
let output = "";
|
|
1369
|
+
for (const [index, character] of characters.entries()) {
|
|
1370
|
+
let leftEscape = false;
|
|
1371
|
+
if (ESCAPES.includes(character)) {
|
|
1372
|
+
const code = /\d[^m]*/.exec(string.slice(index, index + 18));
|
|
1373
|
+
ansiCode = code && code.length > 0 ? code[0] : void 0;
|
|
1374
|
+
if (visible < stringEnd) {
|
|
1375
|
+
isInsideEscape = true;
|
|
1376
|
+
if (ansiCode !== void 0) {
|
|
1377
|
+
ansiCodes.push(ansiCode);
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
} else if (isInsideEscape && character === "m") {
|
|
1381
|
+
isInsideEscape = false;
|
|
1382
|
+
leftEscape = true;
|
|
1383
|
+
}
|
|
1384
|
+
if (!isInsideEscape && !leftEscape) {
|
|
1385
|
+
visible++;
|
|
1386
|
+
}
|
|
1387
|
+
if (!astralRegex.test(character) && isFullwidthCodePoint(character.codePointAt())) {
|
|
1388
|
+
visible++;
|
|
1389
|
+
if (typeof end !== "number") {
|
|
1390
|
+
stringEnd++;
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
if (visible > begin && visible <= stringEnd) {
|
|
1394
|
+
output += character;
|
|
1395
|
+
} else if (visible === begin && !isInsideEscape && ansiCode !== void 0) {
|
|
1396
|
+
output = checkAnsi(ansiCodes);
|
|
1397
|
+
} else if (visible >= stringEnd) {
|
|
1398
|
+
output += checkAnsi(ansiCodes, true, ansiCode);
|
|
1399
|
+
break;
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
return output;
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
// node_modules/.pnpm/string-width@5.0.1/node_modules/string-width/index.js
|
|
1406
|
+
init_esm_shims();
|
|
1407
|
+
|
|
1408
|
+
// node_modules/.pnpm/strip-ansi@7.0.1/node_modules/strip-ansi/index.js
|
|
1409
|
+
init_esm_shims();
|
|
1410
|
+
|
|
1411
|
+
// node_modules/.pnpm/ansi-regex@6.0.1/node_modules/ansi-regex/index.js
|
|
1412
|
+
init_esm_shims();
|
|
1413
|
+
function ansiRegex({ onlyFirst = false } = {}) {
|
|
1414
|
+
const pattern = [
|
|
1415
|
+
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
|
1416
|
+
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"
|
|
1417
|
+
].join("|");
|
|
1418
|
+
return new RegExp(pattern, onlyFirst ? void 0 : "g");
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
// node_modules/.pnpm/strip-ansi@7.0.1/node_modules/strip-ansi/index.js
|
|
1422
|
+
function stripAnsi(string) {
|
|
1423
|
+
if (typeof string !== "string") {
|
|
1424
|
+
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
1425
|
+
}
|
|
1426
|
+
return string.replace(ansiRegex(), "");
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
// node_modules/.pnpm/string-width@5.0.1/node_modules/string-width/index.js
|
|
1430
|
+
var import_emoji_regex = __toModule(require_emoji_regex());
|
|
1431
|
+
function stringWidth(string) {
|
|
1432
|
+
if (typeof string !== "string" || string.length === 0) {
|
|
1433
|
+
return 0;
|
|
1434
|
+
}
|
|
1435
|
+
string = stripAnsi(string);
|
|
1436
|
+
if (string.length === 0) {
|
|
1437
|
+
return 0;
|
|
1438
|
+
}
|
|
1439
|
+
string = string.replace((0, import_emoji_regex.default)(), " ");
|
|
1440
|
+
let width = 0;
|
|
1441
|
+
for (let index = 0; index < string.length; index++) {
|
|
1442
|
+
const codePoint = string.codePointAt(index);
|
|
1443
|
+
if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) {
|
|
1444
|
+
continue;
|
|
1445
|
+
}
|
|
1446
|
+
if (codePoint >= 768 && codePoint <= 879) {
|
|
1447
|
+
continue;
|
|
1448
|
+
}
|
|
1449
|
+
if (codePoint > 65535) {
|
|
1450
|
+
index++;
|
|
1451
|
+
}
|
|
1452
|
+
width += isFullwidthCodePoint(codePoint) ? 2 : 1;
|
|
1453
|
+
}
|
|
1454
|
+
return width;
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
// node_modules/.pnpm/cli-truncate@3.1.0/node_modules/cli-truncate/index.js
|
|
1458
|
+
function getIndexOfNearestSpace(string, wantedIndex, shouldSearchRight) {
|
|
1459
|
+
if (string.charAt(wantedIndex) === " ") {
|
|
1460
|
+
return wantedIndex;
|
|
1461
|
+
}
|
|
1462
|
+
for (let index = 1; index <= 3; index++) {
|
|
1463
|
+
if (shouldSearchRight) {
|
|
1464
|
+
if (string.charAt(wantedIndex + index) === " ") {
|
|
1465
|
+
return wantedIndex + index;
|
|
1466
|
+
}
|
|
1467
|
+
} else if (string.charAt(wantedIndex - index) === " ") {
|
|
1468
|
+
return wantedIndex - index;
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
return wantedIndex;
|
|
1472
|
+
}
|
|
1473
|
+
function cliTruncate(text, columns, options) {
|
|
1474
|
+
options = __spreadValues({
|
|
1475
|
+
position: "end",
|
|
1476
|
+
preferTruncationOnSpace: false,
|
|
1477
|
+
truncationCharacter: "\u2026"
|
|
1478
|
+
}, options);
|
|
1479
|
+
const { position, space, preferTruncationOnSpace } = options;
|
|
1480
|
+
let { truncationCharacter } = options;
|
|
1481
|
+
if (typeof text !== "string") {
|
|
1482
|
+
throw new TypeError(`Expected \`input\` to be a string, got ${typeof text}`);
|
|
1483
|
+
}
|
|
1484
|
+
if (typeof columns !== "number") {
|
|
1485
|
+
throw new TypeError(`Expected \`columns\` to be a number, got ${typeof columns}`);
|
|
1486
|
+
}
|
|
1487
|
+
if (columns < 1) {
|
|
1488
|
+
return "";
|
|
1489
|
+
}
|
|
1490
|
+
if (columns === 1) {
|
|
1491
|
+
return truncationCharacter;
|
|
1492
|
+
}
|
|
1493
|
+
const length = stringWidth(text);
|
|
1494
|
+
if (length <= columns) {
|
|
1495
|
+
return text;
|
|
1496
|
+
}
|
|
1497
|
+
if (position === "start") {
|
|
1498
|
+
if (preferTruncationOnSpace) {
|
|
1499
|
+
const nearestSpace = getIndexOfNearestSpace(text, length - columns + 1, true);
|
|
1500
|
+
return truncationCharacter + sliceAnsi(text, nearestSpace, length).trim();
|
|
1501
|
+
}
|
|
1502
|
+
if (space === true) {
|
|
1503
|
+
truncationCharacter += " ";
|
|
1504
|
+
}
|
|
1505
|
+
return truncationCharacter + sliceAnsi(text, length - columns + stringWidth(truncationCharacter), length);
|
|
1506
|
+
}
|
|
1507
|
+
if (position === "middle") {
|
|
1508
|
+
if (space === true) {
|
|
1509
|
+
truncationCharacter = ` ${truncationCharacter} `;
|
|
1510
|
+
}
|
|
1511
|
+
const half = Math.floor(columns / 2);
|
|
1512
|
+
if (preferTruncationOnSpace) {
|
|
1513
|
+
const spaceNearFirstBreakPoint = getIndexOfNearestSpace(text, half);
|
|
1514
|
+
const spaceNearSecondBreakPoint = getIndexOfNearestSpace(text, length - (columns - half) + 1, true);
|
|
1515
|
+
return sliceAnsi(text, 0, spaceNearFirstBreakPoint) + truncationCharacter + sliceAnsi(text, spaceNearSecondBreakPoint, length).trim();
|
|
1516
|
+
}
|
|
1517
|
+
return sliceAnsi(text, 0, half) + truncationCharacter + sliceAnsi(text, length - (columns - half) + stringWidth(truncationCharacter), length);
|
|
1518
|
+
}
|
|
1519
|
+
if (position === "end") {
|
|
1520
|
+
if (preferTruncationOnSpace) {
|
|
1521
|
+
const nearestSpace = getIndexOfNearestSpace(text, columns - 1);
|
|
1522
|
+
return sliceAnsi(text, 0, nearestSpace) + truncationCharacter;
|
|
1523
|
+
}
|
|
1524
|
+
if (space === true) {
|
|
1525
|
+
truncationCharacter = ` ${truncationCharacter}`;
|
|
1526
|
+
}
|
|
1527
|
+
return sliceAnsi(text, 0, columns - stringWidth(truncationCharacter)) + truncationCharacter;
|
|
1528
|
+
}
|
|
1529
|
+
throw new Error(`Expected \`options.position\` to be either \`start\`, \`middle\` or \`end\`, got ${position}`);
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
// src/reporters/figures.ts
|
|
1533
|
+
init_esm_shims();
|
|
1534
|
+
var F_RIGHT = "\u2192";
|
|
1535
|
+
var F_DOWN = "\u2193";
|
|
1536
|
+
var F_UP = "\u2191";
|
|
1537
|
+
var F_DOWN_RIGHT = "\u21B3";
|
|
1538
|
+
var F_POINTER = "\u276F";
|
|
1539
|
+
var F_DOT = "\xB7";
|
|
1540
|
+
var F_CHECK = "\u221A";
|
|
1541
|
+
var F_CROSS = "\xD7";
|
|
1542
|
+
|
|
1543
|
+
// src/reporters/error.ts
|
|
1544
|
+
async function printError(error) {
|
|
1545
|
+
const { server } = process.__vitest__;
|
|
1546
|
+
let e = error;
|
|
1547
|
+
if (typeof error === "string") {
|
|
1548
|
+
e = {
|
|
1549
|
+
message: error.split(/\n/g)[0],
|
|
1550
|
+
stack: error
|
|
1551
|
+
};
|
|
1552
|
+
}
|
|
1553
|
+
let codeFramePrinted = false;
|
|
1554
|
+
const stacks = parseStack(e.stack || e.stackStr || "");
|
|
1555
|
+
const nearest = stacks.find((stack) => server.moduleGraph.getModuleById(stack.file));
|
|
1556
|
+
if (nearest) {
|
|
1557
|
+
const mod = server.moduleGraph.getModuleById(nearest.file);
|
|
1558
|
+
const transformResult = mod == null ? void 0 : mod.ssrTransformResult;
|
|
1559
|
+
const pos = await getOriginalPos(transformResult == null ? void 0 : transformResult.map, nearest);
|
|
1560
|
+
if (pos && existsSync(nearest.file)) {
|
|
1561
|
+
const sourceCode = await fs.readFile(nearest.file, "utf-8");
|
|
1562
|
+
displayErrorMessage(e);
|
|
1563
|
+
displayFilePath(nearest.file, pos);
|
|
1564
|
+
displayCodeFrame(sourceCode, pos);
|
|
1565
|
+
codeFramePrinted = true;
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
if (!codeFramePrinted)
|
|
1569
|
+
console.error(e);
|
|
1570
|
+
if (e.showDiff)
|
|
1571
|
+
displayDiff(e.actual, e.expected);
|
|
1572
|
+
}
|
|
1573
|
+
function displayDiff(actual, expected) {
|
|
1574
|
+
console.error(c.gray(generateDiff(stringify(actual), stringify(expected))));
|
|
1575
|
+
}
|
|
1576
|
+
function displayErrorMessage(error) {
|
|
1577
|
+
const errorName = error.name || error.nameStr || "Unknown Error";
|
|
1578
|
+
console.error(c.red(`${c.bold(errorName)}: ${error.message}`));
|
|
1579
|
+
}
|
|
1580
|
+
function displayFilePath(filePath, pos) {
|
|
1581
|
+
console.log(c.gray(`${filePath}:${pos.line}:${pos.column}`));
|
|
1582
|
+
}
|
|
1583
|
+
function displayCodeFrame(sourceCode, pos) {
|
|
1584
|
+
console.log(c.yellow(generateCodeFrame(sourceCode, pos)));
|
|
1585
|
+
}
|
|
1586
|
+
function getOriginalPos(map, { line, column }) {
|
|
1587
|
+
return new Promise((resolve2) => {
|
|
1588
|
+
if (!map)
|
|
1589
|
+
return resolve2(null);
|
|
1590
|
+
SourceMapConsumer.with(map, null, (consumer) => {
|
|
1591
|
+
const pos = consumer.originalPositionFor({ line, column });
|
|
1592
|
+
if (pos.line != null && pos.column != null)
|
|
1593
|
+
resolve2(pos);
|
|
1594
|
+
else
|
|
1595
|
+
resolve2(null);
|
|
1596
|
+
});
|
|
1597
|
+
});
|
|
1598
|
+
}
|
|
1599
|
+
var splitRE = /\r?\n/;
|
|
1600
|
+
function posToNumber(source, pos) {
|
|
1601
|
+
if (typeof pos === "number")
|
|
1602
|
+
return pos;
|
|
1603
|
+
const lines = source.split(splitRE);
|
|
1604
|
+
const { line, column } = pos;
|
|
1605
|
+
let start2 = 0;
|
|
1606
|
+
for (let i = 0; i < line - 1; i++)
|
|
1607
|
+
start2 += lines[i].length + 1;
|
|
1608
|
+
return start2 + column;
|
|
1609
|
+
}
|
|
1610
|
+
function generateCodeFrame(source, start2 = 0, end, range = 2) {
|
|
1611
|
+
start2 = posToNumber(source, start2);
|
|
1612
|
+
end = end || start2;
|
|
1613
|
+
const lines = source.split(splitRE);
|
|
1614
|
+
let count = 0;
|
|
1615
|
+
const res = [];
|
|
1616
|
+
function lineNo(no = "") {
|
|
1617
|
+
return c.gray(`${String(no).padStart(3, " ")}| `);
|
|
1618
|
+
}
|
|
1619
|
+
for (let i = 0; i < lines.length; i++) {
|
|
1620
|
+
count += lines[i].length + 1;
|
|
1621
|
+
if (count >= start2) {
|
|
1622
|
+
for (let j = i - range; j <= i + range || end > count; j++) {
|
|
1623
|
+
if (j < 0 || j >= lines.length)
|
|
1624
|
+
continue;
|
|
1625
|
+
const lineLength = lines[j].length;
|
|
1626
|
+
if (lineLength > 200)
|
|
1627
|
+
return "";
|
|
1628
|
+
res.push(lineNo(j + 1) + cliTruncate(lines[j], process.stdout.columns - 5));
|
|
1629
|
+
if (j === i) {
|
|
1630
|
+
const pad = start2 - (count - lineLength);
|
|
1631
|
+
const length = Math.max(1, end > count ? lineLength - pad : end - start2);
|
|
1632
|
+
res.push(lineNo() + " ".repeat(pad) + F_UP.repeat(length));
|
|
1633
|
+
} else if (j > i) {
|
|
1634
|
+
if (end > count) {
|
|
1635
|
+
const length = Math.max(1, Math.min(end - count, lineLength));
|
|
1636
|
+
res.push(lineNo() + F_UP.repeat(length));
|
|
1637
|
+
}
|
|
1638
|
+
count += lineLength + 1;
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
break;
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
return res.join("\n");
|
|
1645
|
+
}
|
|
1646
|
+
function stringify(obj) {
|
|
1647
|
+
return String(obj);
|
|
1648
|
+
}
|
|
1649
|
+
var stackFnCallRE = /at (.*) \((.+):(\d+):(\d+)\)$/;
|
|
1650
|
+
var stackBarePathRE = /at ()(.+):(\d+):(\d+)$/;
|
|
1651
|
+
function parseStack(stack) {
|
|
1652
|
+
const lines = stack.split("\n");
|
|
1653
|
+
const stackFrames = lines.map((raw) => {
|
|
1654
|
+
const line = raw.trim();
|
|
1655
|
+
const match = line.match(stackFnCallRE) || line.match(stackBarePathRE);
|
|
1656
|
+
if (!match)
|
|
1657
|
+
return null;
|
|
1658
|
+
let file = match[2];
|
|
1659
|
+
if (file.startsWith("file://"))
|
|
1660
|
+
file = file.slice(7);
|
|
1661
|
+
return {
|
|
1662
|
+
method: match[1],
|
|
1663
|
+
file: match[2],
|
|
1664
|
+
line: parseInt(match[3]),
|
|
1665
|
+
column: parseInt(match[4])
|
|
1666
|
+
};
|
|
1667
|
+
});
|
|
1668
|
+
return stackFrames.filter(notNullish);
|
|
1669
|
+
}
|
|
1670
|
+
function generateDiff(actual, expected) {
|
|
1671
|
+
const diffSize = 2048;
|
|
1672
|
+
if (actual.length > diffSize)
|
|
1673
|
+
actual = `${actual.substring(0, diffSize)} ... Lines skipped`;
|
|
1674
|
+
if (expected.length > diffSize)
|
|
1675
|
+
expected = `${expected.substring(0, diffSize)} ... Lines skipped`;
|
|
1676
|
+
return unifiedDiff(actual, expected);
|
|
1677
|
+
}
|
|
1678
|
+
function unifiedDiff(actual, expected) {
|
|
1679
|
+
const indent = " ";
|
|
1680
|
+
function cleanUp(line) {
|
|
1681
|
+
if (line[0] === "+")
|
|
1682
|
+
return indent + c.green(`${line[0]}${line.slice(1)}`);
|
|
1683
|
+
if (line[0] === "-")
|
|
1684
|
+
return indent + c.red(`${line[0]}${line.slice(1)}`);
|
|
1685
|
+
if (line.match(/@@/))
|
|
1686
|
+
return "--";
|
|
1687
|
+
if (line.match(/\\ No newline/))
|
|
1688
|
+
return null;
|
|
1689
|
+
return indent + line;
|
|
1690
|
+
}
|
|
1691
|
+
const msg = createPatch("string", actual, expected);
|
|
1692
|
+
const lines = msg.split("\n").splice(5);
|
|
1693
|
+
return `
|
|
5
1694
|
${indent}${c.red("- actual")}
|
|
6
1695
|
${indent}${c.green("+ expected")}
|
|
7
1696
|
|
|
8
|
-
${lines.map(cleanUp).filter(notBlank).join(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1697
|
+
${lines.map(cleanUp).filter(notBlank).join("\n")}`;
|
|
1698
|
+
}
|
|
1699
|
+
function notBlank(line) {
|
|
1700
|
+
return typeof line !== "undefined" && line !== null;
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
// src/reporters/renderer.ts
|
|
1704
|
+
init_esm_shims();
|
|
1705
|
+
import { basename, dirname, isAbsolute, relative } from "path";
|
|
1706
|
+
import { createLogUpdate } from "log-update";
|
|
1707
|
+
import c2 from "picocolors";
|
|
1708
|
+
var DURATION_LONG = 300;
|
|
1709
|
+
var MAX_HEIGHT = 20;
|
|
1710
|
+
var spinnerMap = new WeakMap();
|
|
1711
|
+
var outputMap = new WeakMap();
|
|
1712
|
+
var pointer = c2.yellow(F_POINTER);
|
|
1713
|
+
var skipped = c2.yellow(F_DOWN);
|
|
1714
|
+
function formatTestPath(root, path3) {
|
|
1715
|
+
var _a;
|
|
1716
|
+
if (isAbsolute(path3))
|
|
1717
|
+
path3 = relative(root, path3);
|
|
1718
|
+
const dir = dirname(path3);
|
|
1719
|
+
const ext = ((_a = path3.match(/(\.(spec|test)\.[cm]?[tj]sx?)$/)) == null ? void 0 : _a[0]) || "";
|
|
1720
|
+
const base = basename(path3, ext);
|
|
1721
|
+
return slash(c2.dim(`${dir}/`) + c2.bold(base)) + c2.dim(ext);
|
|
1722
|
+
}
|
|
1723
|
+
function renderSnapshotSummary(rootDir, snapshots) {
|
|
1724
|
+
const summary = [];
|
|
1725
|
+
if (snapshots.added)
|
|
1726
|
+
summary.push(c2.bold(c2.green(`${snapshots.added} written`)));
|
|
1727
|
+
if (snapshots.unmatched)
|
|
1728
|
+
summary.push(c2.bold(c2.red(`${snapshots.unmatched} failed`)));
|
|
1729
|
+
if (snapshots.updated)
|
|
1730
|
+
summary.push(c2.bold(c2.green(`${snapshots.updated} updated `)));
|
|
1731
|
+
if (snapshots.filesRemoved) {
|
|
1732
|
+
if (snapshots.didUpdate)
|
|
1733
|
+
summary.push(c2.bold(c2.green(`${snapshots.filesRemoved} files removed `)));
|
|
1734
|
+
else
|
|
1735
|
+
summary.push(c2.bold(c2.yellow(`${snapshots.filesRemoved} files obsolete `)));
|
|
1736
|
+
}
|
|
1737
|
+
if (snapshots.filesRemovedList && snapshots.filesRemovedList.length) {
|
|
1738
|
+
const [head, ...tail] = snapshots.filesRemovedList;
|
|
1739
|
+
summary.push(`${c2.gray(F_DOWN_RIGHT)} ${formatTestPath(rootDir, head)}`);
|
|
1740
|
+
tail.forEach((key) => {
|
|
1741
|
+
summary.push(` ${c2.gray(F_DOT)} ${formatTestPath(rootDir, key)}`);
|
|
1742
|
+
});
|
|
1743
|
+
}
|
|
1744
|
+
if (snapshots.unchecked) {
|
|
1745
|
+
if (snapshots.didUpdate)
|
|
1746
|
+
summary.push(c2.bold(c2.green(`${snapshots.unchecked} removed`)));
|
|
1747
|
+
else
|
|
1748
|
+
summary.push(c2.bold(c2.yellow(`${snapshots.unchecked} obsolete`)));
|
|
1749
|
+
snapshots.uncheckedKeysByFile.forEach((uncheckedFile) => {
|
|
1750
|
+
summary.push(`${c2.gray(F_DOWN_RIGHT)} ${formatTestPath(rootDir, uncheckedFile.filePath)}`);
|
|
1751
|
+
uncheckedFile.keys.forEach((key) => summary.push(` ${c2.gray(F_DOT)} ${key}`));
|
|
1752
|
+
});
|
|
1753
|
+
}
|
|
1754
|
+
return summary;
|
|
1755
|
+
}
|
|
1756
|
+
function getStateString(tasks, name = "tests") {
|
|
1757
|
+
if (tasks.length === 0)
|
|
1758
|
+
return c2.dim(`no ${name}`);
|
|
1759
|
+
const passed = tasks.filter((i) => {
|
|
1760
|
+
var _a;
|
|
1761
|
+
return ((_a = i.result) == null ? void 0 : _a.state) === "pass";
|
|
1762
|
+
});
|
|
1763
|
+
const failed = tasks.filter((i) => {
|
|
1764
|
+
var _a;
|
|
1765
|
+
return ((_a = i.result) == null ? void 0 : _a.state) === "fail";
|
|
1766
|
+
});
|
|
1767
|
+
const skipped2 = tasks.filter((i) => i.mode === "skip");
|
|
1768
|
+
const todo = tasks.filter((i) => i.mode === "todo");
|
|
1769
|
+
return [
|
|
1770
|
+
failed.length ? c2.bold(c2.red(`${failed.length} failed`)) : null,
|
|
1771
|
+
passed.length ? c2.bold(c2.green(`${passed.length} passed`)) : null,
|
|
1772
|
+
skipped2.length ? c2.yellow(`${skipped2.length} skipped`) : null,
|
|
1773
|
+
todo.length ? c2.gray(`${todo.length} todo`) : null
|
|
1774
|
+
].filter(Boolean).join(c2.dim(" | ")) + c2.gray(` (${tasks.length})`);
|
|
1775
|
+
}
|
|
1776
|
+
function getStateSymbol(task) {
|
|
1777
|
+
if (task.mode === "skip" || task.mode === "todo")
|
|
1778
|
+
return skipped;
|
|
1779
|
+
if (!task.result)
|
|
1780
|
+
return c2.gray("\xB7");
|
|
1781
|
+
if (task.result.state === "run") {
|
|
1782
|
+
if (task.type === "suite")
|
|
1783
|
+
return pointer;
|
|
1784
|
+
let spinner = spinnerMap.get(task);
|
|
1785
|
+
if (!spinner) {
|
|
1786
|
+
spinner = elegantSpinner();
|
|
1787
|
+
spinnerMap.set(task, spinner);
|
|
1788
|
+
}
|
|
1789
|
+
return c2.yellow(spinner());
|
|
1790
|
+
}
|
|
1791
|
+
if (task.result.state === "pass")
|
|
1792
|
+
return c2.green(F_CHECK);
|
|
1793
|
+
if (task.result.state === "fail") {
|
|
1794
|
+
return task.type === "suite" ? pointer : c2.red(F_CROSS);
|
|
1795
|
+
}
|
|
1796
|
+
return " ";
|
|
1797
|
+
}
|
|
1798
|
+
function renderTree(tasks, level = 0) {
|
|
1799
|
+
var _a, _b, _c, _d;
|
|
1800
|
+
let output = [];
|
|
1801
|
+
for (const task of tasks) {
|
|
1802
|
+
let delta = 1;
|
|
1803
|
+
let suffix = task.mode === "skip" || task.mode === "todo" ? ` ${c2.dim("[skipped]")}` : "";
|
|
1804
|
+
const prefix = ` ${getStateSymbol(task)} `;
|
|
1805
|
+
if (task.type === "suite")
|
|
1806
|
+
suffix += c2.dim(` (${getTests(task).length})`);
|
|
1807
|
+
if ((_a = task.result) == null ? void 0 : _a.end) {
|
|
1808
|
+
const duration = task.result.end - task.result.start;
|
|
1809
|
+
if (duration > DURATION_LONG)
|
|
1810
|
+
suffix += c2.yellow(` ${Math.round(duration)}${c2.dim("ms")}`);
|
|
1811
|
+
}
|
|
1812
|
+
if (task.name)
|
|
1813
|
+
output.push(" ".repeat(level) + prefix + task.name + suffix);
|
|
1814
|
+
else
|
|
1815
|
+
delta = 0;
|
|
1816
|
+
if (((_b = task.result) == null ? void 0 : _b.state) !== "pass" && outputMap.get(task) != null) {
|
|
1817
|
+
let data = outputMap.get(task);
|
|
1818
|
+
if (typeof data === "string") {
|
|
1819
|
+
data = stripAnsi(data.trim().split("\n").filter(Boolean).pop());
|
|
1820
|
+
if (data === "")
|
|
1821
|
+
data = void 0;
|
|
1822
|
+
}
|
|
1823
|
+
if (data != null) {
|
|
1824
|
+
const out = `${" ".repeat(level)}${F_RIGHT} ${data}`;
|
|
1825
|
+
output.push(` ${c2.gray(cliTruncate(out, process.stdout.columns - 3))}`);
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
if ((((_c = task.result) == null ? void 0 : _c.state) === "fail" || ((_d = task.result) == null ? void 0 : _d.state) === "run") && task.type === "suite" && task.tasks.length > 0)
|
|
1829
|
+
output = output.concat(renderTree(task.tasks, level + delta));
|
|
1830
|
+
}
|
|
1831
|
+
return output.slice(0, MAX_HEIGHT).join("\n");
|
|
1832
|
+
}
|
|
1833
|
+
var createRenderer = (_tasks) => {
|
|
1834
|
+
let tasks = _tasks;
|
|
1835
|
+
let timer;
|
|
1836
|
+
const log = createLogUpdate(process.stdout);
|
|
1837
|
+
function update() {
|
|
1838
|
+
log(renderTree(tasks));
|
|
1839
|
+
}
|
|
1840
|
+
return {
|
|
1841
|
+
start() {
|
|
1842
|
+
if (timer)
|
|
1843
|
+
return this;
|
|
1844
|
+
timer = setInterval(update, 200);
|
|
1845
|
+
return this;
|
|
1846
|
+
},
|
|
1847
|
+
update(_tasks2) {
|
|
1848
|
+
tasks = _tasks2;
|
|
1849
|
+
update();
|
|
1850
|
+
return this;
|
|
1851
|
+
},
|
|
1852
|
+
async stop() {
|
|
1853
|
+
if (timer) {
|
|
1854
|
+
clearInterval(timer);
|
|
1855
|
+
timer = void 0;
|
|
1856
|
+
}
|
|
1857
|
+
log.clear();
|
|
1858
|
+
console.log(renderTree(tasks));
|
|
1859
|
+
return this;
|
|
1860
|
+
}
|
|
1861
|
+
};
|
|
1862
|
+
};
|
|
1863
|
+
function getFullName(task) {
|
|
1864
|
+
return getNames(task).join(c2.gray(" > "));
|
|
1865
|
+
}
|
|
1866
|
+
var spinnerFrames = process.platform === "win32" ? ["-", "\\", "|", "/"] : ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
1867
|
+
function elegantSpinner() {
|
|
1868
|
+
let index = 0;
|
|
1869
|
+
return () => {
|
|
1870
|
+
index = ++index % spinnerFrames.length;
|
|
1871
|
+
return spinnerFrames[index];
|
|
1872
|
+
};
|
|
1873
|
+
}
|
|
1874
|
+
|
|
1875
|
+
// src/reporters/default.ts
|
|
1876
|
+
var isTTY = process.stdout.isTTY && !process.env.CI;
|
|
1877
|
+
var DefaultReporter = class {
|
|
1878
|
+
constructor(ctx) {
|
|
1879
|
+
this.ctx = ctx;
|
|
1880
|
+
const mode = ctx.config.watch ? c3.yellow(" DEV ") : c3.cyan(" RUN ");
|
|
1881
|
+
console.log(`${c3.inverse(c3.bold(mode))} ${c3.gray(this.ctx.config.root)}
|
|
1882
|
+
`);
|
|
1883
|
+
this.start = performance.now();
|
|
1884
|
+
}
|
|
1885
|
+
start = 0;
|
|
1886
|
+
end = 0;
|
|
1887
|
+
renderer;
|
|
1888
|
+
watchFilters;
|
|
1889
|
+
relative(path3) {
|
|
1890
|
+
return relative2(this.ctx.config.root, path3);
|
|
1891
|
+
}
|
|
1892
|
+
onStart() {
|
|
1893
|
+
if (isTTY) {
|
|
1894
|
+
const files = this.ctx.state.getFiles(this.watchFilters);
|
|
1895
|
+
if (!this.renderer)
|
|
1896
|
+
this.renderer = createRenderer(files).start();
|
|
1897
|
+
else
|
|
1898
|
+
this.renderer.update(files);
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
onTaskUpdate(pack) {
|
|
1902
|
+
var _a, _b, _c;
|
|
1903
|
+
if (isTTY)
|
|
1904
|
+
return;
|
|
1905
|
+
const task = this.ctx.state.idMap[pack[0]];
|
|
1906
|
+
if (task.type === "test" && ((_a = task.result) == null ? void 0 : _a.state) && ((_b = task.result) == null ? void 0 : _b.state) !== "run") {
|
|
1907
|
+
console.log(` ${getStateSymbol(task)} ${getFullName(task)}`);
|
|
1908
|
+
if (task.result.state === "fail")
|
|
1909
|
+
console.log(c3.red(` ${F_RIGHT} ${(_c = task.result.error) == null ? void 0 : _c.message}`));
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
async onFinished(files = this.ctx.state.getFiles()) {
|
|
1913
|
+
var _a, _b;
|
|
1914
|
+
this.end = performance.now();
|
|
1915
|
+
await this.stopListRender();
|
|
1916
|
+
console.log();
|
|
1917
|
+
const suites = getSuites(files);
|
|
1918
|
+
const tests = getTests(files);
|
|
1919
|
+
const failedSuites = suites.filter((i) => {
|
|
1920
|
+
var _a2;
|
|
1921
|
+
return (_a2 = i.result) == null ? void 0 : _a2.error;
|
|
1922
|
+
});
|
|
1923
|
+
const failedTests = tests.filter((i) => {
|
|
1924
|
+
var _a2;
|
|
1925
|
+
return ((_a2 = i.result) == null ? void 0 : _a2.state) === "fail";
|
|
1926
|
+
});
|
|
1927
|
+
if (failedSuites.length) {
|
|
1928
|
+
console.error(c3.bold(c3.red(`
|
|
1929
|
+
Failed to run ${failedSuites.length} suites:`)));
|
|
1930
|
+
for (const suite of failedSuites) {
|
|
1931
|
+
console.error(c3.red(`
|
|
1932
|
+
- ${getFullName(suite)}`));
|
|
1933
|
+
await printError((_a = suite.result) == null ? void 0 : _a.error);
|
|
1934
|
+
console.log();
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
if (failedTests.length) {
|
|
1938
|
+
console.error(c3.bold(c3.red(`
|
|
1939
|
+
Failed Tests (${failedTests.length})`)));
|
|
1940
|
+
for (const test of failedTests) {
|
|
1941
|
+
console.error(`${c3.red(`
|
|
1942
|
+
${c3.inverse(" FAIL ")}`)} ${getFullName(test)}`);
|
|
1943
|
+
await printError((_b = test.result) == null ? void 0 : _b.error);
|
|
1944
|
+
console.log();
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1947
|
+
const executionTime = this.end - this.start;
|
|
1948
|
+
const threadTime = tests.reduce((acc, test) => {
|
|
1949
|
+
var _a2;
|
|
1950
|
+
return acc + (((_a2 = test.result) == null ? void 0 : _a2.end) ? test.result.end - test.result.start : 0);
|
|
1951
|
+
}, 0);
|
|
1952
|
+
const padTitle = (str) => c3.dim(`${str.padStart(10)} `);
|
|
1953
|
+
const time = (time2) => {
|
|
1954
|
+
if (time2 > 1e3)
|
|
1955
|
+
return `${(time2 / 1e3).toFixed(2)}s`;
|
|
1956
|
+
return `${Math.round(time2)}ms`;
|
|
1957
|
+
};
|
|
1958
|
+
const snapshotOutput = renderSnapshotSummary(this.ctx.config.root, this.ctx.snapshot.summary);
|
|
1959
|
+
if (snapshotOutput.length) {
|
|
1960
|
+
console.log(snapshotOutput.map((t, i) => i === 0 ? `${padTitle("Snapshots")} ${t}` : `${padTitle("")} ${t}`).join("\n"));
|
|
1961
|
+
if (snapshotOutput.length > 1)
|
|
1962
|
+
console.log();
|
|
1963
|
+
}
|
|
1964
|
+
console.log(padTitle("Test Files"), getStateString(files));
|
|
1965
|
+
console.log(padTitle("Tests"), getStateString(tests));
|
|
1966
|
+
if (this.watchFilters)
|
|
1967
|
+
console.log(padTitle("Time"), time(threadTime));
|
|
1968
|
+
else
|
|
1969
|
+
console.log(padTitle("Time"), time(executionTime) + c3.gray(` (in thread ${time(threadTime)}, ${(executionTime / threadTime * 100).toFixed(2)}%)`));
|
|
1970
|
+
console.log();
|
|
1971
|
+
}
|
|
1972
|
+
async onWatcherStart() {
|
|
1973
|
+
await this.stopListRender();
|
|
1974
|
+
const failed = getTests(this.ctx.state.getFiles()).filter((i) => {
|
|
1975
|
+
var _a;
|
|
1976
|
+
return ((_a = i.result) == null ? void 0 : _a.state) === "fail";
|
|
1977
|
+
});
|
|
1978
|
+
if (failed.length)
|
|
1979
|
+
console.log(`
|
|
1980
|
+
${c3.bold(c3.inverse(c3.red(" FAIL ")))}${c3.red(` ${failed.length} tests failed. Watching for file changes...`)}`);
|
|
1981
|
+
else
|
|
1982
|
+
console.log(`
|
|
1983
|
+
${c3.bold(c3.inverse(c3.green(" PASS ")))}${c3.green(" Watching for file changes...")}`);
|
|
1984
|
+
}
|
|
1985
|
+
async onWatcherRerun(files, trigger) {
|
|
1986
|
+
await this.stopListRender();
|
|
1987
|
+
this.watchFilters = files;
|
|
1988
|
+
console.clear();
|
|
1989
|
+
console.log(c3.blue("Re-running tests...") + c3.dim(` [ ${this.relative(trigger)} ]
|
|
1990
|
+
`));
|
|
1991
|
+
}
|
|
1992
|
+
async stopListRender() {
|
|
1993
|
+
var _a;
|
|
1994
|
+
(_a = this.renderer) == null ? void 0 : _a.stop();
|
|
1995
|
+
this.renderer = void 0;
|
|
1996
|
+
await new Promise((resolve2) => setTimeout(resolve2, 100));
|
|
1997
|
+
}
|
|
1998
|
+
};
|
|
1999
|
+
|
|
2000
|
+
// src/integrations/snapshot/manager.ts
|
|
2001
|
+
init_esm_shims();
|
|
2002
|
+
var SnapshotManager = class {
|
|
2003
|
+
constructor(config) {
|
|
2004
|
+
this.config = config;
|
|
2005
|
+
this.clear();
|
|
2006
|
+
}
|
|
2007
|
+
summary = void 0;
|
|
2008
|
+
clear() {
|
|
2009
|
+
this.summary = emptySummary(this.config.snapshotOptions);
|
|
2010
|
+
}
|
|
2011
|
+
add(result) {
|
|
2012
|
+
addSnapshotResult(this.summary, result);
|
|
2013
|
+
}
|
|
2014
|
+
};
|
|
2015
|
+
|
|
2016
|
+
// src/node/init.ts
|
|
2017
|
+
init_esm_shims();
|
|
2018
|
+
import { resolve } from "path";
|
|
2019
|
+
|
|
2020
|
+
// node_modules/.pnpm/find-up@6.2.0/node_modules/find-up/index.js
|
|
2021
|
+
init_esm_shims();
|
|
2022
|
+
import path2 from "path";
|
|
2023
|
+
|
|
2024
|
+
// node_modules/.pnpm/locate-path@7.0.0/node_modules/locate-path/index.js
|
|
2025
|
+
init_esm_shims();
|
|
2026
|
+
import process2 from "process";
|
|
2027
|
+
import path from "path";
|
|
2028
|
+
import fs2, { promises as fsPromises } from "fs";
|
|
2029
|
+
|
|
2030
|
+
// node_modules/.pnpm/p-locate@6.0.0/node_modules/p-locate/index.js
|
|
2031
|
+
init_esm_shims();
|
|
2032
|
+
|
|
2033
|
+
// node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js
|
|
2034
|
+
init_esm_shims();
|
|
2035
|
+
|
|
2036
|
+
// node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js
|
|
2037
|
+
init_esm_shims();
|
|
2038
|
+
var Node = class {
|
|
2039
|
+
value;
|
|
2040
|
+
next;
|
|
2041
|
+
constructor(value) {
|
|
2042
|
+
this.value = value;
|
|
2043
|
+
}
|
|
2044
|
+
};
|
|
2045
|
+
var _head, _tail, _size;
|
|
2046
|
+
var Queue = class {
|
|
2047
|
+
constructor() {
|
|
2048
|
+
__privateAdd(this, _head, void 0);
|
|
2049
|
+
__privateAdd(this, _tail, void 0);
|
|
2050
|
+
__privateAdd(this, _size, void 0);
|
|
2051
|
+
this.clear();
|
|
2052
|
+
}
|
|
2053
|
+
enqueue(value) {
|
|
2054
|
+
const node = new Node(value);
|
|
2055
|
+
if (__privateGet(this, _head)) {
|
|
2056
|
+
__privateGet(this, _tail).next = node;
|
|
2057
|
+
__privateSet(this, _tail, node);
|
|
2058
|
+
} else {
|
|
2059
|
+
__privateSet(this, _head, node);
|
|
2060
|
+
__privateSet(this, _tail, node);
|
|
2061
|
+
}
|
|
2062
|
+
__privateWrapper(this, _size)._++;
|
|
2063
|
+
}
|
|
2064
|
+
dequeue() {
|
|
2065
|
+
const current = __privateGet(this, _head);
|
|
2066
|
+
if (!current) {
|
|
2067
|
+
return;
|
|
2068
|
+
}
|
|
2069
|
+
__privateSet(this, _head, __privateGet(this, _head).next);
|
|
2070
|
+
__privateWrapper(this, _size)._--;
|
|
2071
|
+
return current.value;
|
|
2072
|
+
}
|
|
2073
|
+
clear() {
|
|
2074
|
+
__privateSet(this, _head, void 0);
|
|
2075
|
+
__privateSet(this, _tail, void 0);
|
|
2076
|
+
__privateSet(this, _size, 0);
|
|
2077
|
+
}
|
|
2078
|
+
get size() {
|
|
2079
|
+
return __privateGet(this, _size);
|
|
2080
|
+
}
|
|
2081
|
+
*[Symbol.iterator]() {
|
|
2082
|
+
let current = __privateGet(this, _head);
|
|
2083
|
+
while (current) {
|
|
2084
|
+
yield current.value;
|
|
2085
|
+
current = current.next;
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
};
|
|
2089
|
+
_head = new WeakMap();
|
|
2090
|
+
_tail = new WeakMap();
|
|
2091
|
+
_size = new WeakMap();
|
|
2092
|
+
|
|
2093
|
+
// node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js
|
|
2094
|
+
function pLimit(concurrency) {
|
|
2095
|
+
if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
|
|
2096
|
+
throw new TypeError("Expected `concurrency` to be a number from 1 and up");
|
|
2097
|
+
}
|
|
2098
|
+
const queue = new Queue();
|
|
2099
|
+
let activeCount = 0;
|
|
2100
|
+
const next = () => {
|
|
2101
|
+
activeCount--;
|
|
2102
|
+
if (queue.size > 0) {
|
|
2103
|
+
queue.dequeue()();
|
|
2104
|
+
}
|
|
2105
|
+
};
|
|
2106
|
+
const run2 = async (fn, resolve2, args) => {
|
|
2107
|
+
activeCount++;
|
|
2108
|
+
const result = (async () => fn(...args))();
|
|
2109
|
+
resolve2(result);
|
|
2110
|
+
try {
|
|
2111
|
+
await result;
|
|
2112
|
+
} catch {
|
|
2113
|
+
}
|
|
2114
|
+
next();
|
|
2115
|
+
};
|
|
2116
|
+
const enqueue = (fn, resolve2, args) => {
|
|
2117
|
+
queue.enqueue(run2.bind(void 0, fn, resolve2, args));
|
|
2118
|
+
(async () => {
|
|
2119
|
+
await Promise.resolve();
|
|
2120
|
+
if (activeCount < concurrency && queue.size > 0) {
|
|
2121
|
+
queue.dequeue()();
|
|
2122
|
+
}
|
|
2123
|
+
})();
|
|
2124
|
+
};
|
|
2125
|
+
const generator = (fn, ...args) => new Promise((resolve2) => {
|
|
2126
|
+
enqueue(fn, resolve2, args);
|
|
2127
|
+
});
|
|
2128
|
+
Object.defineProperties(generator, {
|
|
2129
|
+
activeCount: {
|
|
2130
|
+
get: () => activeCount
|
|
2131
|
+
},
|
|
2132
|
+
pendingCount: {
|
|
2133
|
+
get: () => queue.size
|
|
2134
|
+
},
|
|
2135
|
+
clearQueue: {
|
|
2136
|
+
value: () => {
|
|
2137
|
+
queue.clear();
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2140
|
+
});
|
|
2141
|
+
return generator;
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
// node_modules/.pnpm/p-locate@6.0.0/node_modules/p-locate/index.js
|
|
2145
|
+
var EndError = class extends Error {
|
|
2146
|
+
constructor(value) {
|
|
2147
|
+
super();
|
|
2148
|
+
this.value = value;
|
|
2149
|
+
}
|
|
2150
|
+
};
|
|
2151
|
+
var testElement = async (element, tester) => tester(await element);
|
|
2152
|
+
var finder = async (element) => {
|
|
2153
|
+
const values = await Promise.all(element);
|
|
2154
|
+
if (values[1] === true) {
|
|
2155
|
+
throw new EndError(values[0]);
|
|
2156
|
+
}
|
|
2157
|
+
return false;
|
|
2158
|
+
};
|
|
2159
|
+
async function pLocate(iterable, tester, {
|
|
2160
|
+
concurrency = Number.POSITIVE_INFINITY,
|
|
2161
|
+
preserveOrder = true
|
|
2162
|
+
} = {}) {
|
|
2163
|
+
const limit = pLimit(concurrency);
|
|
2164
|
+
const items = [...iterable].map((element) => [element, limit(testElement, element, tester)]);
|
|
2165
|
+
const checkLimit = pLimit(preserveOrder ? 1 : Number.POSITIVE_INFINITY);
|
|
2166
|
+
try {
|
|
2167
|
+
await Promise.all(items.map((element) => checkLimit(finder, element)));
|
|
2168
|
+
} catch (error) {
|
|
2169
|
+
if (error instanceof EndError) {
|
|
2170
|
+
return error.value;
|
|
2171
|
+
}
|
|
2172
|
+
throw error;
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
2175
|
+
|
|
2176
|
+
// node_modules/.pnpm/locate-path@7.0.0/node_modules/locate-path/index.js
|
|
2177
|
+
var typeMappings = {
|
|
2178
|
+
directory: "isDirectory",
|
|
2179
|
+
file: "isFile"
|
|
2180
|
+
};
|
|
2181
|
+
function checkType(type) {
|
|
2182
|
+
if (type in typeMappings) {
|
|
2183
|
+
return;
|
|
2184
|
+
}
|
|
2185
|
+
throw new Error(`Invalid type specified: ${type}`);
|
|
2186
|
+
}
|
|
2187
|
+
var matchType = (type, stat) => type === void 0 || stat[typeMappings[type]]();
|
|
2188
|
+
async function locatePath(paths, {
|
|
2189
|
+
cwd = process2.cwd(),
|
|
2190
|
+
type = "file",
|
|
2191
|
+
allowSymlinks = true,
|
|
2192
|
+
concurrency,
|
|
2193
|
+
preserveOrder
|
|
2194
|
+
} = {}) {
|
|
2195
|
+
checkType(type);
|
|
2196
|
+
const statFunction = allowSymlinks ? fsPromises.stat : fsPromises.lstat;
|
|
2197
|
+
return pLocate(paths, async (path_) => {
|
|
2198
|
+
try {
|
|
2199
|
+
const stat = await statFunction(path.resolve(cwd, path_));
|
|
2200
|
+
return matchType(type, stat);
|
|
2201
|
+
} catch {
|
|
2202
|
+
return false;
|
|
2203
|
+
}
|
|
2204
|
+
}, { concurrency, preserveOrder });
|
|
2205
|
+
}
|
|
2206
|
+
|
|
2207
|
+
// node_modules/.pnpm/path-exists@5.0.0/node_modules/path-exists/index.js
|
|
2208
|
+
init_esm_shims();
|
|
2209
|
+
import fs3, { promises as fsPromises2 } from "fs";
|
|
2210
|
+
|
|
2211
|
+
// node_modules/.pnpm/find-up@6.2.0/node_modules/find-up/index.js
|
|
2212
|
+
var findUpStop = Symbol("findUpStop");
|
|
2213
|
+
async function findUpMultiple(name, options = {}) {
|
|
2214
|
+
let directory = path2.resolve(options.cwd || "");
|
|
2215
|
+
const { root } = path2.parse(directory);
|
|
2216
|
+
const stopAt = path2.resolve(directory, options.stopAt || root);
|
|
2217
|
+
const limit = options.limit || Number.POSITIVE_INFINITY;
|
|
2218
|
+
const paths = [name].flat();
|
|
2219
|
+
const runMatcher = async (locateOptions) => {
|
|
2220
|
+
if (typeof name !== "function") {
|
|
2221
|
+
return locatePath(paths, locateOptions);
|
|
2222
|
+
}
|
|
2223
|
+
const foundPath = await name(locateOptions.cwd);
|
|
2224
|
+
if (typeof foundPath === "string") {
|
|
2225
|
+
return locatePath([foundPath], locateOptions);
|
|
2226
|
+
}
|
|
2227
|
+
return foundPath;
|
|
2228
|
+
};
|
|
2229
|
+
const matches = [];
|
|
2230
|
+
while (true) {
|
|
2231
|
+
const foundPath = await runMatcher(__spreadProps(__spreadValues({}, options), { cwd: directory }));
|
|
2232
|
+
if (foundPath === findUpStop) {
|
|
2233
|
+
break;
|
|
2234
|
+
}
|
|
2235
|
+
if (foundPath) {
|
|
2236
|
+
matches.push(path2.resolve(directory, foundPath));
|
|
2237
|
+
}
|
|
2238
|
+
if (directory === stopAt || matches.length >= limit) {
|
|
2239
|
+
break;
|
|
2240
|
+
}
|
|
2241
|
+
directory = path2.dirname(directory);
|
|
2242
|
+
}
|
|
2243
|
+
return matches;
|
|
2244
|
+
}
|
|
2245
|
+
async function findUp(name, options = {}) {
|
|
2246
|
+
const matches = await findUpMultiple(name, __spreadProps(__spreadValues({}, options), { limit: 1 }));
|
|
2247
|
+
return matches[0];
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2250
|
+
// src/node/init.ts
|
|
2251
|
+
import { createServer } from "vite";
|
|
2252
|
+
var configFiles = [
|
|
2253
|
+
"vitest.config.ts",
|
|
2254
|
+
"vitest.config.js",
|
|
2255
|
+
"vitest.config.mjs",
|
|
2256
|
+
"vite.config.ts",
|
|
2257
|
+
"vite.config.js",
|
|
2258
|
+
"vite.config.mjs"
|
|
2259
|
+
];
|
|
2260
|
+
async function initViteServer(options = {}) {
|
|
2261
|
+
var _a, _b;
|
|
2262
|
+
const root = resolve(options.root || process.cwd());
|
|
2263
|
+
process.chdir(root);
|
|
2264
|
+
if (options.dom)
|
|
2265
|
+
options.environment = "happy-dom";
|
|
2266
|
+
const configPath = options.config ? resolve(root, options.config) : await findUp(configFiles, { cwd: root });
|
|
2267
|
+
const resolved = __spreadValues({}, options);
|
|
2268
|
+
resolved.config = configPath;
|
|
2269
|
+
resolved.root = root;
|
|
2270
|
+
if (options.cliFilters)
|
|
2271
|
+
resolved.cliFilters = toArray(options.cliFilters);
|
|
2272
|
+
const server = await createServer({
|
|
2273
|
+
root,
|
|
2274
|
+
logLevel: "error",
|
|
2275
|
+
clearScreen: false,
|
|
2276
|
+
configFile: resolved.config,
|
|
2277
|
+
optimizeDeps: {
|
|
2278
|
+
exclude: [
|
|
2279
|
+
"vitest"
|
|
2280
|
+
]
|
|
2281
|
+
}
|
|
2282
|
+
});
|
|
2283
|
+
await server.pluginContainer.buildStart({});
|
|
2284
|
+
Object.assign(resolved, server.config.test);
|
|
2285
|
+
resolved.depsInline = ((_a = resolved.deps) == null ? void 0 : _a.inline) || [];
|
|
2286
|
+
resolved.depsExternal = ((_b = resolved.deps) == null ? void 0 : _b.external) || [];
|
|
2287
|
+
resolved.environment = resolved.environment || "node";
|
|
2288
|
+
resolved.threads = resolved.threads ?? true;
|
|
2289
|
+
resolved.interpretDefault = resolved.interpretDefault ?? true;
|
|
2290
|
+
resolved.includes = resolved.includes ?? defaultIncludes;
|
|
2291
|
+
resolved.excludes = resolved.excludes ?? defaultExcludes;
|
|
2292
|
+
const CI = !!process.env.CI;
|
|
2293
|
+
const UPDATE_SNAPSHOT = resolved.update || process.env.UPDATE_SNAPSHOT;
|
|
2294
|
+
resolved.snapshotOptions = {
|
|
2295
|
+
updateSnapshot: CI && !UPDATE_SNAPSHOT ? "none" : UPDATE_SNAPSHOT ? "all" : "new"
|
|
2296
|
+
};
|
|
2297
|
+
if (process.env.VITEST_MAX_THREADS)
|
|
2298
|
+
resolved.maxThreads = parseInt(process.env.VITEST_MAX_THREADS);
|
|
2299
|
+
if (process.env.VITEST_MIN_THREADS)
|
|
2300
|
+
resolved.minThreads = parseInt(process.env.VITEST_MIN_THREADS);
|
|
2301
|
+
return {
|
|
2302
|
+
server,
|
|
2303
|
+
config: resolved
|
|
2304
|
+
};
|
|
2305
|
+
}
|
|
2306
|
+
|
|
2307
|
+
// src/node/run.ts
|
|
2308
|
+
init_esm_shims();
|
|
2309
|
+
|
|
2310
|
+
// src/node/pool.ts
|
|
2311
|
+
init_esm_shims();
|
|
2312
|
+
import { MessageChannel } from "worker_threads";
|
|
2313
|
+
import { pathToFileURL } from "url";
|
|
2314
|
+
import Piscina from "piscina";
|
|
2315
|
+
|
|
2316
|
+
// src/node/transform.ts
|
|
2317
|
+
init_esm_shims();
|
|
2318
|
+
async function transformRequest(server, id) {
|
|
2319
|
+
if (id.match(/\.(?:[cm]?[jt]sx?|json)$/)) {
|
|
2320
|
+
return await server.transformRequest(id, { ssr: true });
|
|
2321
|
+
} else {
|
|
2322
|
+
const result = await server.transformRequest(id);
|
|
2323
|
+
if (!result)
|
|
2324
|
+
return void 0;
|
|
2325
|
+
return await server.ssrTransform(result.code, result.map, id);
|
|
2326
|
+
}
|
|
2327
|
+
}
|
|
2328
|
+
|
|
2329
|
+
// src/node/pool.ts
|
|
2330
|
+
function createPool(ctx) {
|
|
2331
|
+
if (ctx.config.threads)
|
|
2332
|
+
return createWorkerPool(ctx);
|
|
2333
|
+
else
|
|
2334
|
+
return createFakePool(ctx);
|
|
2335
|
+
}
|
|
2336
|
+
var workerPath = new URL("./dist/runtime/worker.js", pathToFileURL(distDir)).href;
|
|
2337
|
+
function createFakePool(ctx) {
|
|
2338
|
+
const runTestFiles = async (files, invalidates) => {
|
|
2339
|
+
const { default: run2 } = await import(workerPath);
|
|
2340
|
+
const { workerPort, port } = createChannel(ctx);
|
|
2341
|
+
const data = {
|
|
2342
|
+
port: workerPort,
|
|
2343
|
+
config: ctx.config,
|
|
2344
|
+
files,
|
|
2345
|
+
invalidates
|
|
2346
|
+
};
|
|
2347
|
+
await run2(data, { transferList: [workerPort] });
|
|
2348
|
+
port.close();
|
|
2349
|
+
workerPort.close();
|
|
2350
|
+
};
|
|
2351
|
+
return {
|
|
2352
|
+
runTestFiles,
|
|
2353
|
+
close: async () => {
|
|
2354
|
+
}
|
|
2355
|
+
};
|
|
2356
|
+
}
|
|
2357
|
+
function createWorkerPool(ctx) {
|
|
2358
|
+
const options = {
|
|
2359
|
+
filename: workerPath
|
|
2360
|
+
};
|
|
2361
|
+
if (ctx.config.maxThreads != null)
|
|
2362
|
+
options.maxThreads = ctx.config.maxThreads;
|
|
2363
|
+
if (ctx.config.minThreads != null)
|
|
2364
|
+
options.minThreads = ctx.config.minThreads;
|
|
2365
|
+
const piscina = new Piscina(options);
|
|
2366
|
+
const runTestFiles = async (files, invalidates) => {
|
|
2367
|
+
await Promise.all(files.map(async (file) => {
|
|
2368
|
+
const { workerPort, port } = createChannel(ctx);
|
|
2369
|
+
const data = {
|
|
2370
|
+
port: workerPort,
|
|
2371
|
+
config: ctx.config,
|
|
2372
|
+
files: [file],
|
|
2373
|
+
invalidates
|
|
2374
|
+
};
|
|
2375
|
+
await piscina.run(data, { transferList: [workerPort] });
|
|
2376
|
+
port.close();
|
|
2377
|
+
workerPort.close();
|
|
2378
|
+
}));
|
|
2379
|
+
};
|
|
2380
|
+
return {
|
|
2381
|
+
runTestFiles,
|
|
2382
|
+
close: () => piscina.destroy()
|
|
2383
|
+
};
|
|
2384
|
+
}
|
|
2385
|
+
function createChannel(ctx) {
|
|
2386
|
+
const channel = new MessageChannel();
|
|
2387
|
+
const port = channel.port2;
|
|
2388
|
+
const workerPort = channel.port1;
|
|
2389
|
+
port.on("message", async ({ id, method, args = [] }) => {
|
|
2390
|
+
var _a, _b, _c, _d;
|
|
2391
|
+
async function send(fn) {
|
|
2392
|
+
try {
|
|
2393
|
+
port.postMessage({ id, result: await fn() });
|
|
2394
|
+
} catch (e) {
|
|
2395
|
+
port.postMessage({ id, error: e });
|
|
2396
|
+
}
|
|
2397
|
+
}
|
|
2398
|
+
switch (method) {
|
|
2399
|
+
case "snapshotSaved":
|
|
2400
|
+
return send(() => ctx.snapshot.add(args[0]));
|
|
2401
|
+
case "fetch":
|
|
2402
|
+
return send(() => transformRequest(ctx.server, ...args));
|
|
2403
|
+
case "onCollected":
|
|
2404
|
+
ctx.state.collectFiles(args[0]);
|
|
2405
|
+
(_b = (_a = ctx.reporter).onStart) == null ? void 0 : _b.call(_a, args[0].map((i) => i.filepath));
|
|
2406
|
+
return;
|
|
2407
|
+
case "onTaskUpdate":
|
|
2408
|
+
ctx.state.updateTasks([args[0]]);
|
|
2409
|
+
(_d = (_c = ctx.reporter).onTaskUpdate) == null ? void 0 : _d.call(_c, args[0]);
|
|
2410
|
+
return;
|
|
2411
|
+
}
|
|
2412
|
+
console.error("Unhandled message", method, args);
|
|
2413
|
+
});
|
|
2414
|
+
return { workerPort, port };
|
|
2415
|
+
}
|
|
2416
|
+
|
|
2417
|
+
// src/node/glob.ts
|
|
2418
|
+
init_esm_shims();
|
|
2419
|
+
import fg from "fast-glob";
|
|
2420
|
+
import mm from "micromatch";
|
|
2421
|
+
function isTargetFile(id, config) {
|
|
2422
|
+
if (mm.isMatch(id, config.excludes))
|
|
2423
|
+
return false;
|
|
2424
|
+
return mm.isMatch(id, config.includes);
|
|
2425
|
+
}
|
|
2426
|
+
async function globTestFiles(config) {
|
|
2427
|
+
var _a;
|
|
2428
|
+
let testFilepaths = await fg(config.includes, {
|
|
2429
|
+
absolute: true,
|
|
2430
|
+
cwd: config.root,
|
|
2431
|
+
ignore: config.excludes
|
|
2432
|
+
});
|
|
2433
|
+
if ((_a = config.cliFilters) == null ? void 0 : _a.length)
|
|
2434
|
+
testFilepaths = testFilepaths.filter((i) => config.cliFilters.some((f) => i.includes(f)));
|
|
2435
|
+
return testFilepaths;
|
|
2436
|
+
}
|
|
2437
|
+
|
|
2438
|
+
// src/node/watcher.ts
|
|
2439
|
+
init_esm_shims();
|
|
2440
|
+
var WATCHER_DEBOUNCE = 50;
|
|
2441
|
+
async function startWatcher(ctx, pool) {
|
|
2442
|
+
var _a;
|
|
2443
|
+
const { reporter, server } = ctx;
|
|
2444
|
+
(_a = reporter.onWatcherStart) == null ? void 0 : _a.call(reporter);
|
|
2445
|
+
let timer;
|
|
2446
|
+
const changedTests = /* @__PURE__ */ new Set();
|
|
2447
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2448
|
+
let promise;
|
|
2449
|
+
server.watcher.on("change", (id) => {
|
|
2450
|
+
id = slash(id);
|
|
2451
|
+
getAffectedTests(ctx, id, changedTests, seen);
|
|
2452
|
+
if (changedTests.size === 0)
|
|
2453
|
+
return;
|
|
2454
|
+
rerunFile(id);
|
|
2455
|
+
});
|
|
2456
|
+
server.watcher.on("unlink", (id) => {
|
|
2457
|
+
id = slash(id);
|
|
2458
|
+
seen.add(id);
|
|
2459
|
+
if (id in ctx.state.filesMap) {
|
|
2460
|
+
delete ctx.state.filesMap[id];
|
|
2461
|
+
changedTests.delete(id);
|
|
2462
|
+
}
|
|
2463
|
+
});
|
|
2464
|
+
server.watcher.on("add", async (id) => {
|
|
2465
|
+
id = slash(id);
|
|
2466
|
+
if (isTargetFile(id, ctx.config)) {
|
|
2467
|
+
changedTests.add(id);
|
|
2468
|
+
rerunFile(id);
|
|
2469
|
+
}
|
|
2470
|
+
});
|
|
2471
|
+
async function rerunFile(id) {
|
|
2472
|
+
await promise;
|
|
2473
|
+
clearTimeout(timer);
|
|
2474
|
+
timer = setTimeout(async () => {
|
|
2475
|
+
if (changedTests.size === 0) {
|
|
2476
|
+
seen.clear();
|
|
2477
|
+
return;
|
|
2478
|
+
}
|
|
2479
|
+
ctx.state.getFiles().forEach((file) => {
|
|
2480
|
+
var _a2;
|
|
2481
|
+
if (((_a2 = file.result) == null ? void 0 : _a2.state) === "fail")
|
|
2482
|
+
changedTests.add(file.filepath);
|
|
2483
|
+
});
|
|
2484
|
+
const invalidates = Array.from(seen);
|
|
2485
|
+
const tests = Array.from(changedTests);
|
|
2486
|
+
changedTests.clear();
|
|
2487
|
+
seen.clear();
|
|
2488
|
+
promise = start2(tests, id, invalidates);
|
|
2489
|
+
await promise;
|
|
2490
|
+
}, WATCHER_DEBOUNCE);
|
|
2491
|
+
}
|
|
2492
|
+
async function start2(tests, id, invalidates) {
|
|
2493
|
+
var _a2, _b, _c;
|
|
2494
|
+
await ((_a2 = reporter.onWatcherRerun) == null ? void 0 : _a2.call(reporter, tests, id));
|
|
2495
|
+
await pool.runTestFiles(tests, invalidates);
|
|
2496
|
+
await ((_b = reporter.onFinished) == null ? void 0 : _b.call(reporter, ctx.state.getFiles(tests)));
|
|
2497
|
+
await ((_c = reporter.onWatcherStart) == null ? void 0 : _c.call(reporter));
|
|
2498
|
+
}
|
|
2499
|
+
await new Promise(() => {
|
|
2500
|
+
});
|
|
2501
|
+
}
|
|
2502
|
+
function getAffectedTests(ctx, id, set = /* @__PURE__ */ new Set(), seen = /* @__PURE__ */ new Set()) {
|
|
2503
|
+
if (seen.has(id) || set.has(id) || id.includes("/node_modules/") || id.includes("/vitest/dist/"))
|
|
2504
|
+
return set;
|
|
2505
|
+
seen.add(id);
|
|
2506
|
+
if (id in ctx.state.filesMap) {
|
|
2507
|
+
set.add(id);
|
|
2508
|
+
return set;
|
|
2509
|
+
}
|
|
2510
|
+
const mod = ctx.server.moduleGraph.getModuleById(id);
|
|
2511
|
+
if (mod) {
|
|
2512
|
+
mod.importers.forEach((i) => {
|
|
2513
|
+
if (i.id)
|
|
2514
|
+
getAffectedTests(ctx, i.id, set, seen);
|
|
2515
|
+
});
|
|
2516
|
+
}
|
|
2517
|
+
return set;
|
|
2518
|
+
}
|
|
2519
|
+
|
|
2520
|
+
// src/node/run.ts
|
|
2521
|
+
async function start(ctx) {
|
|
2522
|
+
var _a, _b;
|
|
2523
|
+
const { config } = ctx;
|
|
2524
|
+
const testFilepaths = await globTestFiles(config);
|
|
2525
|
+
if (!testFilepaths.length) {
|
|
2526
|
+
console.error("No test files found");
|
|
2527
|
+
process.exitCode = 1;
|
|
2528
|
+
return;
|
|
2529
|
+
}
|
|
2530
|
+
const pool = createPool(ctx);
|
|
2531
|
+
await pool.runTestFiles(testFilepaths);
|
|
2532
|
+
if (hasFailed(ctx.state.getFiles()))
|
|
2533
|
+
process.exitCode = 1;
|
|
2534
|
+
await ((_b = (_a = ctx.reporter).onFinished) == null ? void 0 : _b.call(_a, ctx.state.getFiles()));
|
|
2535
|
+
if (config.watch)
|
|
2536
|
+
await startWatcher(ctx, pool);
|
|
2537
|
+
else
|
|
2538
|
+
await pool.close();
|
|
2539
|
+
}
|
|
2540
|
+
|
|
2541
|
+
// src/node/state.ts
|
|
2542
|
+
init_esm_shims();
|
|
2543
|
+
var StateManager = class {
|
|
2544
|
+
filesMap = {};
|
|
2545
|
+
idMap = {};
|
|
2546
|
+
taskFileMap = new WeakMap();
|
|
2547
|
+
getFiles(keys) {
|
|
2548
|
+
if (keys)
|
|
2549
|
+
return keys.map((key) => this.filesMap[key]);
|
|
2550
|
+
return Object.values(this.filesMap);
|
|
2551
|
+
}
|
|
2552
|
+
collectFiles(files) {
|
|
2553
|
+
files.forEach((file) => {
|
|
2554
|
+
this.filesMap[file.filepath] = file;
|
|
2555
|
+
this.updateId(file);
|
|
2556
|
+
});
|
|
2557
|
+
}
|
|
2558
|
+
updateId(task) {
|
|
2559
|
+
if (this.idMap[task.id] === task)
|
|
2560
|
+
return;
|
|
2561
|
+
this.idMap[task.id] = task;
|
|
2562
|
+
if (task.type === "suite") {
|
|
2563
|
+
task.tasks.forEach((task2) => {
|
|
2564
|
+
this.updateId(task2);
|
|
2565
|
+
});
|
|
2566
|
+
}
|
|
2567
|
+
}
|
|
2568
|
+
updateTasks(packs) {
|
|
2569
|
+
for (const [id, result] of packs) {
|
|
2570
|
+
if (this.idMap[id])
|
|
2571
|
+
this.idMap[id].result = result;
|
|
2572
|
+
}
|
|
2573
|
+
}
|
|
2574
|
+
};
|
|
2575
|
+
|
|
2576
|
+
// src/node/cli.ts
|
|
2577
|
+
var cli = dist_default("vitest");
|
|
2578
|
+
cli.version(version).option("-r, --root <path>", "root path").option("-c, --config <path>", "path to config file").option("-u, --update", "update snapshot").option("--global", "inject apis globally").option("--dom", "mock browser api with happy-dom").option("--environment <env>", "runner environment", {
|
|
2579
|
+
default: "node"
|
|
2580
|
+
}).help();
|
|
2581
|
+
cli.command("run [...filters]").action(run);
|
|
2582
|
+
cli.command("watch [...filters]").action(dev);
|
|
2583
|
+
cli.command("dev [...filters]").action(dev);
|
|
2584
|
+
cli.command("[...filters]").action(dev);
|
|
2585
|
+
cli.parse();
|
|
2586
|
+
async function dev(cliFilters, argv) {
|
|
2587
|
+
argv.watch = !process.env.CI;
|
|
2588
|
+
await run(cliFilters, argv);
|
|
2589
|
+
}
|
|
2590
|
+
async function run(cliFilters, argv) {
|
|
2591
|
+
process.env.VITEST = "true";
|
|
2592
|
+
console.log(c4.magenta(c4.bold("\nVitest is in closed beta exclusively for Sponsors")));
|
|
2593
|
+
console.log(c4.yellow("Learn more at https://vitest.dev\n"));
|
|
2594
|
+
const { config, server } = await initViteServer(__spreadProps(__spreadValues({}, argv), { cliFilters }));
|
|
2595
|
+
const ctx = process.__vitest__ = {
|
|
2596
|
+
server,
|
|
2597
|
+
config,
|
|
2598
|
+
state: new StateManager(),
|
|
2599
|
+
snapshot: new SnapshotManager(config),
|
|
2600
|
+
reporter: config.reporter
|
|
2601
|
+
};
|
|
2602
|
+
ctx.reporter = ctx.reporter || new DefaultReporter(ctx);
|
|
2603
|
+
try {
|
|
2604
|
+
await start(ctx);
|
|
2605
|
+
} catch (e) {
|
|
2606
|
+
process.exitCode = 1;
|
|
2607
|
+
throw e;
|
|
2608
|
+
} finally {
|
|
2609
|
+
if (!config.watch)
|
|
2610
|
+
await server.close();
|
|
2611
|
+
}
|
|
2612
|
+
}
|