vitest 4.1.0-beta.2 → 4.1.0-beta.3
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/dist/browser.d.ts +1 -1
- package/dist/browser.js +1 -1
- package/dist/chunks/{base.DiopZV8F.js → base.BawQY8vy.js} +4 -4
- package/dist/chunks/{browser.d.BE4kbYok.d.ts → browser.d.CweQ2M9y.d.ts} +1 -1
- package/dist/chunks/{cac.C4jjt2RX.js → cac.Bmb60yM3.js} +259 -124
- package/dist/chunks/{cli-api.ChbI1JU9.js → cli-api.DwoCIT8I.js} +89 -85
- package/dist/chunks/{config.d.Cr1Ep39N.d.ts → config.d.pC9164XK.d.ts} +14 -1
- package/dist/chunks/{constants.B63TT-Bl.js → constants.CPYnjOGj.js} +3 -1
- package/dist/chunks/{coverage.tyqbzn4W.js → coverage.DAUQBfjL.js} +32 -5
- package/dist/chunks/{creator.yyCHuw5R.js → creator.DgVhQm5q.js} +3 -3
- package/dist/chunks/{global.d.JeWMqlOm.d.ts → global.d.DYf8kr_l.d.ts} +1 -1
- package/dist/chunks/{globals.C6Ecf1TO.js → globals.AhCakrmA.js} +3 -3
- package/dist/chunks/{index.CAN630q3.js → index.CEU66SQN.js} +2 -2
- package/dist/chunks/{index.D3XRDfWc.js → index.CMESou6r.js} +26 -1
- package/dist/chunks/{index.CouFDptX.js → index.D3wDRGBz.js} +4 -2
- package/dist/chunks/{index.B-iBE_Gx.js → index.De5aIHUc.js} +39 -18
- package/dist/chunks/{index.D4KonVSU.js → index.og1WyBLx.js} +18 -3
- package/dist/chunks/{index.CFulQRmC.js → index.qcTcl_eM.js} +1 -1
- package/dist/chunks/{plugin.d.C9o5bttz.d.ts → plugin.d.CTohQCcC.d.ts} +1 -1
- package/dist/chunks/{reporters.d.7faYdkxy.d.ts → reporters.d.DPe11uSn.d.ts} +82 -14
- package/dist/chunks/{rpc.d.CM7x9-sm.d.ts → rpc.d.CUhiUEld.d.ts} +1 -1
- package/dist/chunks/{setup-common.cvFp-ao9.js → setup-common.BoY7R7rC.js} +2 -2
- package/dist/chunks/{suite.d.BJWk38HB.d.ts → suite.d.udJtyAgw.d.ts} +1 -1
- package/dist/chunks/{test.G82XYNFk.js → test.CnO2BIt2.js} +6 -2
- package/dist/chunks/{vm.BdLtzhnj.js → vm.CMbtLg78.js} +1 -1
- package/dist/chunks/{worker.d.CPzI2ZzJ.d.ts → worker.d.CiaQ1oon.d.ts} +2 -2
- package/dist/cli.js +3 -3
- package/dist/config.d.ts +8 -8
- package/dist/config.js +1 -1
- package/dist/coverage.d.ts +5 -5
- package/dist/coverage.js +2 -2
- package/dist/index.d.ts +11 -12
- package/dist/index.js +3 -3
- package/dist/module-evaluator.d.ts +2 -1
- package/dist/module-evaluator.js +36 -26
- package/dist/node.d.ts +13 -10
- package/dist/node.js +9 -9
- package/dist/reporters.d.ts +5 -5
- package/dist/reporters.js +2 -2
- package/dist/runners.d.ts +2 -2
- package/dist/runners.js +1 -1
- package/dist/suite.d.ts +1 -1
- package/dist/worker.d.ts +3 -3
- package/dist/worker.js +5 -5
- package/dist/workers/forks.js +5 -5
- package/dist/workers/runVmTests.js +4 -4
- package/dist/workers/threads.js +5 -5
- package/dist/workers/vmForks.js +1 -1
- package/dist/workers/vmThreads.js +1 -1
- package/globals.d.ts +2 -0
- package/package.json +16 -16
package/dist/browser.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as SerializedCoverageConfig, S as SerializedConfig } from './chunks/config.d.
|
|
1
|
+
import { a as SerializedCoverageConfig, S as SerializedConfig } from './chunks/config.d.pC9164XK.js';
|
|
2
2
|
import { R as RuntimeCoverageModuleLoader } from './chunks/coverage.d.BZtK59WP.js';
|
|
3
3
|
import { SerializedDiffOptions } from '@vitest/utils/diff';
|
|
4
4
|
export { O as OTELCarrier, T as Traces } from './chunks/traces.d.402V_yFI.js';
|
package/dist/browser.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { l as loadDiffConfig,
|
|
1
|
+
export { l as loadDiffConfig, a as loadSnapshotSerializers, s as setupCommonEnv, b as startCoverageInsideWorker, c as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/setup-common.BoY7R7rC.js';
|
|
2
2
|
export { T as Traces } from './chunks/traces.CCmnQaNT.js';
|
|
3
3
|
export { collectTests, startTests } from '@vitest/runner';
|
|
4
4
|
import * as spyModule from '@vitest/spy';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { runInThisContext } from 'node:vm';
|
|
2
2
|
import * as spyModule from '@vitest/spy';
|
|
3
|
-
import { r as resolveTestRunner, a as resolveSnapshotEnvironment, s as setupChaiConfig } from './index.
|
|
3
|
+
import { r as resolveTestRunner, a as resolveSnapshotEnvironment, s as setupChaiConfig } from './index.CEU66SQN.js';
|
|
4
4
|
import { l as loadEnvironment, e as emitModuleRunner, a as listenForErrors } from './init.B95Mm0Iz.js';
|
|
5
5
|
import { N as NativeModuleRunner } from './nativeModuleRunner.BIakptoF.js';
|
|
6
6
|
import { T as Traces } from './traces.CCmnQaNT.js';
|
|
@@ -8,15 +8,15 @@ import { V as VitestEvaluatedModules } from './evaluatedModules.Dg1zASAC.js';
|
|
|
8
8
|
import { s as startVitestModuleRunner, c as createNodeImportMeta } from './startVitestModuleRunner.BK-u7y4N.js';
|
|
9
9
|
import { performance as performance$1 } from 'node:perf_hooks';
|
|
10
10
|
import { startTests, collectTests } from '@vitest/runner';
|
|
11
|
-
import {
|
|
12
|
-
import { g as globalExpect, v as vi } from './test.
|
|
11
|
+
import { s as setupCommonEnv, b as startCoverageInsideWorker, c as stopCoverageInsideWorker } from './setup-common.BoY7R7rC.js';
|
|
12
|
+
import { g as globalExpect, v as vi } from './test.CnO2BIt2.js';
|
|
13
13
|
import { c as closeInspector } from './inspector.CvyFGlXm.js';
|
|
14
14
|
import { createRequire } from 'node:module';
|
|
15
15
|
import timers from 'node:timers';
|
|
16
16
|
import timersPromises from 'node:timers/promises';
|
|
17
17
|
import util from 'node:util';
|
|
18
18
|
import { KNOWN_ASSET_TYPES } from '@vitest/utils/constants';
|
|
19
|
-
import { i as index } from './index.
|
|
19
|
+
import { i as index } from './index.D3wDRGBz.js';
|
|
20
20
|
import { g as getWorkerState, r as resetModules, p as provideWorkerState, a as getSafeWorkerState } from './utils.DT4VyRyl.js';
|
|
21
21
|
|
|
22
22
|
// this should only be used in Node
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FileSpecification } from '@vitest/runner';
|
|
2
2
|
import { O as OTELCarrier } from './traces.d.402V_yFI.js';
|
|
3
|
-
import { T as TestExecutionMethod } from './worker.d.
|
|
3
|
+
import { T as TestExecutionMethod } from './worker.d.CiaQ1oon.js';
|
|
4
4
|
|
|
5
5
|
type SerializedTestSpecification = [project: {
|
|
6
6
|
name: string | undefined;
|
|
@@ -2,8 +2,8 @@ import { toArray } from '@vitest/utils/helpers';
|
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
3
|
import { normalize } from 'pathe';
|
|
4
4
|
import c$2 from 'tinyrainbow';
|
|
5
|
-
import { b as defaultPort, d as defaultBrowserPort } from './constants.
|
|
6
|
-
import { R as ReportersMap } from './index.
|
|
5
|
+
import { b as defaultPort, d as defaultBrowserPort } from './constants.CPYnjOGj.js';
|
|
6
|
+
import { R as ReportersMap } from './index.De5aIHUc.js';
|
|
7
7
|
import assert from 'node:assert';
|
|
8
8
|
|
|
9
9
|
function toArr(any) {
|
|
@@ -620,7 +620,7 @@ class CAC extends EventEmitter {
|
|
|
620
620
|
|
|
621
621
|
const cac = (name = "") => new CAC(name);
|
|
622
622
|
|
|
623
|
-
var version = "4.1.0-beta.
|
|
623
|
+
var version = "4.1.0-beta.3";
|
|
624
624
|
|
|
625
625
|
const apiConfig = (port) => ({
|
|
626
626
|
port: {
|
|
@@ -632,6 +632,8 @@ const apiConfig = (port) => ({
|
|
|
632
632
|
argument: "[host]"
|
|
633
633
|
},
|
|
634
634
|
strictPort: { description: "Set to true to exit if port is already in use, instead of automatically trying the next available port" },
|
|
635
|
+
allowExec: { description: "Allow API to execute code. (Be careful when enabling this option in untrusted environments)" },
|
|
636
|
+
allowWrite: { description: "Allow API to edit files. (Be careful when enabling this option in untrusted environments)" },
|
|
635
637
|
middlewareMode: null
|
|
636
638
|
});
|
|
637
639
|
function watermarkTransform(value) {
|
|
@@ -657,7 +659,8 @@ const cliOptionsConfig = {
|
|
|
657
659
|
},
|
|
658
660
|
update: {
|
|
659
661
|
shorthand: "u",
|
|
660
|
-
description: "Update snapshot"
|
|
662
|
+
description: "Update snapshot (accepts boolean, \"new\" or \"all\")",
|
|
663
|
+
argument: "[type]"
|
|
661
664
|
},
|
|
662
665
|
watch: {
|
|
663
666
|
shorthand: "w",
|
|
@@ -678,7 +681,11 @@ const cliOptionsConfig = {
|
|
|
678
681
|
api: {
|
|
679
682
|
argument: "[port]",
|
|
680
683
|
description: `Specify server port. Note if the port is already being used, Vite will automatically try the next available port so this may not be the actual port the server ends up listening on. If true will be set to ${defaultPort}`,
|
|
681
|
-
subcommands: apiConfig(defaultPort)
|
|
684
|
+
subcommands: apiConfig(defaultPort),
|
|
685
|
+
transform(portOrOptions) {
|
|
686
|
+
if (typeof portOrOptions === "number") return { port: portOrOptions };
|
|
687
|
+
return portOrOptions;
|
|
688
|
+
}
|
|
682
689
|
},
|
|
683
690
|
silent: {
|
|
684
691
|
description: "Silent console output from tests. Use `'passed-only'` to see logs from failing tests only.",
|
|
@@ -846,6 +853,10 @@ const cliOptionsConfig = {
|
|
|
846
853
|
},
|
|
847
854
|
isolate: { description: "Run every browser test file in isolation. To disable isolation, use `--browser.isolate=false` (default: `true`)" },
|
|
848
855
|
ui: { description: "Show Vitest UI when running tests (default: `!process.env.CI`)" },
|
|
856
|
+
detailsPanelPosition: {
|
|
857
|
+
description: "Default position for the details panel in browser mode. Either `right` (horizontal split) or `bottom` (vertical split) (default: `right`)",
|
|
858
|
+
argument: "<position>"
|
|
859
|
+
},
|
|
849
860
|
fileParallelism: { description: "Should browser test files run in parallel. Use `--browser.fileParallelism=false` to disable (default: `true`)" },
|
|
850
861
|
connectTimeout: {
|
|
851
862
|
description: "If connection to the browser takes longer, the test suite will fail (default: `60_000`)",
|
|
@@ -1173,7 +1184,43 @@ const cliOptionsConfig = {
|
|
|
1173
1184
|
fsModuleCache: { description: "Enable caching of modules on the file system between reruns." },
|
|
1174
1185
|
fsModuleCachePath: null,
|
|
1175
1186
|
openTelemetry: null,
|
|
1176
|
-
|
|
1187
|
+
importDurations: {
|
|
1188
|
+
description: "Configure import duration collection and CLI display. Note that UI's \"Module Graph\" tab can always show import breakdown regardless of the `print` setting.",
|
|
1189
|
+
argument: "",
|
|
1190
|
+
transform(value) {
|
|
1191
|
+
if (typeof value === "boolean") return { print: value };
|
|
1192
|
+
return value;
|
|
1193
|
+
},
|
|
1194
|
+
subcommands: {
|
|
1195
|
+
print: {
|
|
1196
|
+
description: "When to print import breakdown to CLI terminal. Use `true` to always print, `false` to never print, or `on-warn` to print only when imports exceed the warn threshold (default: false).",
|
|
1197
|
+
argument: "<boolean|on-warn>",
|
|
1198
|
+
transform(value) {
|
|
1199
|
+
if (value === "on-warn") return "on-warn";
|
|
1200
|
+
return value;
|
|
1201
|
+
}
|
|
1202
|
+
},
|
|
1203
|
+
limit: {
|
|
1204
|
+
description: "Maximum number of imports to collect and display (default: 0, or 10 if print or UI is enabled).",
|
|
1205
|
+
argument: "<number>"
|
|
1206
|
+
},
|
|
1207
|
+
failOnDanger: { description: "Fail the test run if any import exceeds the danger threshold (default: false)." },
|
|
1208
|
+
thresholds: {
|
|
1209
|
+
description: "Duration thresholds in milliseconds for coloring and warnings.",
|
|
1210
|
+
argument: "",
|
|
1211
|
+
subcommands: {
|
|
1212
|
+
warn: {
|
|
1213
|
+
description: "Warning threshold - imports exceeding this are shown in yellow/orange (default: 100).",
|
|
1214
|
+
argument: "<number>"
|
|
1215
|
+
},
|
|
1216
|
+
danger: {
|
|
1217
|
+
description: "Danger threshold - imports exceeding this are shown in red (default: 500).",
|
|
1218
|
+
argument: "<number>"
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
},
|
|
1177
1224
|
viteModuleRunner: { description: "Control whether Vitest uses Vite's module runner to run the code or fallback to the native `import`. (default: `true`)" },
|
|
1178
1225
|
nodeLoader: { description: "Controls whether Vitest will use Node.js Loader API to process in-source or mocked files. This has no effect if `viteModuleRunner` is enabled. Disabling this can increase performance. (default: `true`)" }
|
|
1179
1226
|
}
|
|
@@ -1552,15 +1599,7 @@ __${n}_complete() {
|
|
|
1552
1599
|
|
|
1553
1600
|
# Register completion function
|
|
1554
1601
|
complete -F __${n}_complete ${e}
|
|
1555
|
-
`}function r(e,t){let n=e.replace(/[-:]/g,`_`);return `# fish completion for ${e} -*- shell-script -*-
|
|
1556
|
-
|
|
1557
|
-
# Define shell completion directives
|
|
1558
|
-
set -l ShellCompDirectiveError ${a.ShellCompDirectiveError}
|
|
1559
|
-
set -l ShellCompDirectiveNoSpace ${a.ShellCompDirectiveNoSpace}
|
|
1560
|
-
set -l ShellCompDirectiveNoFileComp ${a.ShellCompDirectiveNoFileComp}
|
|
1561
|
-
set -l ShellCompDirectiveFilterFileExt ${a.ShellCompDirectiveFilterFileExt}
|
|
1562
|
-
set -l ShellCompDirectiveFilterDirs ${a.ShellCompDirectiveFilterDirs}
|
|
1563
|
-
set -l ShellCompDirectiveKeepOrder ${a.ShellCompDirectiveKeepOrder}
|
|
1602
|
+
`}function r(e,t){let n=e.replace(/[-:]/g,`_`),r=a.ShellCompDirectiveError,i=a.ShellCompDirectiveNoSpace,o=a.ShellCompDirectiveNoFileComp,s=a.ShellCompDirectiveFilterFileExt,c=a.ShellCompDirectiveFilterDirs;return `# fish completion for ${e} -*- shell-script -*-
|
|
1564
1603
|
|
|
1565
1604
|
function __${n}_debug
|
|
1566
1605
|
set -l file "$BASH_COMP_DEBUG_FILE"
|
|
@@ -1572,136 +1611,229 @@ end
|
|
|
1572
1611
|
function __${n}_perform_completion
|
|
1573
1612
|
__${n}_debug "Starting __${n}_perform_completion"
|
|
1574
1613
|
|
|
1575
|
-
# Extract all args except the
|
|
1576
|
-
set -l args (
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
end
|
|
1586
|
-
|
|
1587
|
-
__${n}_debug "Current token: $current_token"
|
|
1588
|
-
__${n}_debug "All args: $args"
|
|
1614
|
+
# Extract all args except the last one
|
|
1615
|
+
set -l args (commandline -opc)
|
|
1616
|
+
# Extract the last arg and escape it in case it is a space or wildcard
|
|
1617
|
+
set -l lastArg (string escape -- (commandline -ct))
|
|
1618
|
+
|
|
1619
|
+
__${n}_debug "args: $args"
|
|
1620
|
+
__${n}_debug "last arg: $lastArg"
|
|
1621
|
+
|
|
1622
|
+
# Build the completion request command
|
|
1623
|
+
set -l requestComp "${t} complete -- (string join ' ' -- (string escape -- $args[2..-1])) $lastArg"
|
|
1589
1624
|
|
|
1590
|
-
# Call the completion program and get the results
|
|
1591
|
-
set -l requestComp "${t} complete -- $args"
|
|
1592
1625
|
__${n}_debug "Calling $requestComp"
|
|
1593
1626
|
set -l results (eval $requestComp 2> /dev/null)
|
|
1594
|
-
|
|
1627
|
+
|
|
1595
1628
|
# Some programs may output extra empty lines after the directive.
|
|
1596
1629
|
# Let's ignore them or else it will break completion.
|
|
1597
1630
|
# Ref: https://github.com/spf13/cobra/issues/1279
|
|
1598
1631
|
for line in $results[-1..1]
|
|
1599
|
-
if test (string
|
|
1600
|
-
#
|
|
1601
|
-
set
|
|
1602
|
-
|
|
1632
|
+
if test (string trim -- $line) = ""
|
|
1633
|
+
# Found an empty line, remove it
|
|
1634
|
+
set results $results[1..-2]
|
|
1635
|
+
else
|
|
1636
|
+
# Found non-empty line, we have our proper output
|
|
1603
1637
|
break
|
|
1604
1638
|
end
|
|
1605
1639
|
end
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1640
|
+
|
|
1641
|
+
set -l comps $results[1..-2]
|
|
1642
|
+
set -l directiveLine $results[-1]
|
|
1643
|
+
|
|
1644
|
+
# For Fish, when completing a flag with an = (e.g., <program> -n=<TAB>)
|
|
1645
|
+
# completions must be prefixed with the flag
|
|
1646
|
+
set -l flagPrefix (string match -r -- '-.*=' "$lastArg")
|
|
1647
|
+
|
|
1648
|
+
__${n}_debug "Comps: $comps"
|
|
1649
|
+
__${n}_debug "DirectiveLine: $directiveLine"
|
|
1650
|
+
__${n}_debug "flagPrefix: $flagPrefix"
|
|
1651
|
+
|
|
1652
|
+
for comp in $comps
|
|
1653
|
+
printf "%s%s\\n" "$flagPrefix" "$comp"
|
|
1610
1654
|
end
|
|
1611
|
-
|
|
1612
|
-
__${n}_debug "Directive: $directive_num"
|
|
1613
1655
|
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1656
|
+
printf "%s\\n" "$directiveLine"
|
|
1657
|
+
end
|
|
1658
|
+
|
|
1659
|
+
# This function limits calls to __${n}_perform_completion, by caching the result
|
|
1660
|
+
function __${n}_perform_completion_once
|
|
1661
|
+
__${n}_debug "Starting __${n}_perform_completion_once"
|
|
1662
|
+
|
|
1663
|
+
if test -n "$__${n}_perform_completion_once_result"
|
|
1664
|
+
__${n}_debug "Seems like a valid result already exists, skipping __${n}_perform_completion"
|
|
1665
|
+
return 0
|
|
1666
|
+
end
|
|
1667
|
+
|
|
1668
|
+
set --global __${n}_perform_completion_once_result (__${n}_perform_completion)
|
|
1669
|
+
if test -z "$__${n}_perform_completion_once_result"
|
|
1670
|
+
__${n}_debug "No completions, probably due to a failure"
|
|
1618
1671
|
return 1
|
|
1619
1672
|
end
|
|
1620
1673
|
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1674
|
+
__${n}_debug "Performed completions and set __${n}_perform_completion_once_result"
|
|
1675
|
+
return 0
|
|
1676
|
+
end
|
|
1677
|
+
|
|
1678
|
+
# This function is used to clear the cached result after completions are run
|
|
1679
|
+
function __${n}_clear_perform_completion_once_result
|
|
1680
|
+
__${n}_debug ""
|
|
1681
|
+
__${n}_debug "========= clearing previously set __${n}_perform_completion_once_result variable =========="
|
|
1682
|
+
set --erase __${n}_perform_completion_once_result
|
|
1683
|
+
__${n}_debug "Successfully erased the variable __${n}_perform_completion_once_result"
|
|
1684
|
+
end
|
|
1685
|
+
|
|
1686
|
+
function __${n}_requires_order_preservation
|
|
1687
|
+
__${n}_debug ""
|
|
1688
|
+
__${n}_debug "========= checking if order preservation is required =========="
|
|
1689
|
+
|
|
1690
|
+
__${n}_perform_completion_once
|
|
1691
|
+
if test -z "$__${n}_perform_completion_once_result"
|
|
1692
|
+
__${n}_debug "Error determining if order preservation is required"
|
|
1693
|
+
return 1
|
|
1624
1694
|
end
|
|
1625
1695
|
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1696
|
+
set -l directive (string sub --start 2 $__${n}_perform_completion_once_result[-1])
|
|
1697
|
+
__${n}_debug "Directive is: $directive"
|
|
1698
|
+
|
|
1699
|
+
set -l shellCompDirectiveKeepOrder ${a.ShellCompDirectiveKeepOrder}
|
|
1700
|
+
set -l keeporder (math (math --scale 0 $directive / $shellCompDirectiveKeepOrder) % 2)
|
|
1701
|
+
__${n}_debug "Keeporder is: $keeporder"
|
|
1702
|
+
|
|
1703
|
+
if test $keeporder -ne 0
|
|
1704
|
+
__${n}_debug "This does require order preservation"
|
|
1633
1705
|
return 0
|
|
1634
1706
|
end
|
|
1635
1707
|
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
return 0
|
|
1708
|
+
__${n}_debug "This doesn't require order preservation"
|
|
1709
|
+
return 1
|
|
1710
|
+
end
|
|
1711
|
+
|
|
1712
|
+
# This function does two things:
|
|
1713
|
+
# - Obtain the completions and store them in the global __${n}_comp_results
|
|
1714
|
+
# - Return false if file completion should be performed
|
|
1715
|
+
function __${n}_prepare_completions
|
|
1716
|
+
__${n}_debug ""
|
|
1717
|
+
__${n}_debug "========= starting completion logic =========="
|
|
1718
|
+
|
|
1719
|
+
# Start fresh
|
|
1720
|
+
set --erase __${n}_comp_results
|
|
1721
|
+
|
|
1722
|
+
__${n}_perform_completion_once
|
|
1723
|
+
__${n}_debug "Completion results: $__${n}_perform_completion_once_result"
|
|
1724
|
+
|
|
1725
|
+
if test -z "$__${n}_perform_completion_once_result"
|
|
1726
|
+
__${n}_debug "No completion, probably due to a failure"
|
|
1727
|
+
# Might as well do file completion, in case it helps
|
|
1728
|
+
return 1
|
|
1658
1729
|
end
|
|
1659
1730
|
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1731
|
+
set -l directive (string sub --start 2 $__${n}_perform_completion_once_result[-1])
|
|
1732
|
+
set --global __${n}_comp_results $__${n}_perform_completion_once_result[1..-2]
|
|
1733
|
+
|
|
1734
|
+
__${n}_debug "Completions are: $__${n}_comp_results"
|
|
1735
|
+
__${n}_debug "Directive is: $directive"
|
|
1736
|
+
|
|
1737
|
+
set -l shellCompDirectiveError ${r}
|
|
1738
|
+
set -l shellCompDirectiveNoSpace ${i}
|
|
1739
|
+
set -l shellCompDirectiveNoFileComp ${o}
|
|
1740
|
+
set -l shellCompDirectiveFilterFileExt ${s}
|
|
1741
|
+
set -l shellCompDirectiveFilterDirs ${c}
|
|
1742
|
+
|
|
1743
|
+
if test -z "$directive"
|
|
1744
|
+
set directive 0
|
|
1674
1745
|
end
|
|
1675
1746
|
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1747
|
+
set -l compErr (math (math --scale 0 $directive / $shellCompDirectiveError) % 2)
|
|
1748
|
+
if test $compErr -eq 1
|
|
1749
|
+
__${n}_debug "Received error directive: aborting."
|
|
1750
|
+
# Might as well do file completion, in case it helps
|
|
1751
|
+
return 1
|
|
1752
|
+
end
|
|
1753
|
+
|
|
1754
|
+
set -l filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2)
|
|
1755
|
+
set -l dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2)
|
|
1756
|
+
if test $filefilter -eq 1; or test $dirfilter -eq 1
|
|
1757
|
+
__${n}_debug "File extension filtering or directory filtering not supported"
|
|
1758
|
+
# Do full file completion instead
|
|
1759
|
+
return 1
|
|
1760
|
+
end
|
|
1761
|
+
|
|
1762
|
+
set -l nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) % 2)
|
|
1763
|
+
set -l nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) % 2)
|
|
1764
|
+
|
|
1765
|
+
__${n}_debug "nospace: $nospace, nofiles: $nofiles"
|
|
1766
|
+
|
|
1767
|
+
# If we want to prevent a space, or if file completion is NOT disabled,
|
|
1768
|
+
# we need to count the number of valid completions.
|
|
1769
|
+
# To do so, we will filter on prefix as the completions we have received
|
|
1770
|
+
# may not already be filtered so as to allow fish to match on different
|
|
1771
|
+
# criteria than the prefix.
|
|
1772
|
+
if test $nospace -ne 0; or test $nofiles -eq 0
|
|
1773
|
+
set -l prefix (commandline -t | string escape --style=regex)
|
|
1774
|
+
__${n}_debug "prefix: $prefix"
|
|
1775
|
+
|
|
1776
|
+
set -l completions (string match -r -- "^$prefix.*" $__${n}_comp_results)
|
|
1777
|
+
set --global __${n}_comp_results $completions
|
|
1778
|
+
__${n}_debug "Filtered completions are: $__${n}_comp_results"
|
|
1779
|
+
|
|
1780
|
+
# Important not to quote the variable for count to work
|
|
1781
|
+
set -l numComps (count $__${n}_comp_results)
|
|
1782
|
+
__${n}_debug "numComps: $numComps"
|
|
1783
|
+
|
|
1784
|
+
if test $numComps -eq 1; and test $nospace -ne 0
|
|
1785
|
+
# We must first split on \\t to get rid of the descriptions to be
|
|
1786
|
+
# able to check what the actual completion will be.
|
|
1787
|
+
# We don't need descriptions anyway since there is only a single
|
|
1788
|
+
# real completion which the shell will expand immediately.
|
|
1789
|
+
set -l split (string split --max 1 "\\t" $__${n}_comp_results[1])
|
|
1790
|
+
|
|
1791
|
+
# Fish won't add a space if the completion ends with any
|
|
1792
|
+
# of the following characters: @=/:.,
|
|
1793
|
+
set -l lastChar (string sub -s -1 -- $split)
|
|
1794
|
+
if not string match -r -q "[@=/:.,]" -- "$lastChar"
|
|
1795
|
+
# In other cases, to support the "nospace" directive we trick the shell
|
|
1796
|
+
# by outputting an extra, longer completion.
|
|
1797
|
+
__${n}_debug "Adding second completion to perform nospace directive"
|
|
1798
|
+
set --global __${n}_comp_results $split[1] $split[1].
|
|
1799
|
+
__${n}_debug "Completions are now: $__${n}_comp_results"
|
|
1690
1800
|
end
|
|
1691
1801
|
end
|
|
1802
|
+
|
|
1803
|
+
if test $numComps -eq 0; and test $nofiles -eq 0
|
|
1804
|
+
# To be consistent with bash and zsh, we only trigger file
|
|
1805
|
+
# completion when there are no other completions
|
|
1806
|
+
__${n}_debug "Requesting file completion"
|
|
1807
|
+
return 1
|
|
1808
|
+
end
|
|
1692
1809
|
end
|
|
1693
|
-
|
|
1694
|
-
# If directive contains NoSpace, tell fish not to add a space after completion
|
|
1695
|
-
if test (math "$directive_num & $ShellCompDirectiveNoSpace") -ne 0
|
|
1696
|
-
return 2
|
|
1697
|
-
end
|
|
1698
|
-
|
|
1810
|
+
|
|
1699
1811
|
return 0
|
|
1700
1812
|
end
|
|
1701
1813
|
|
|
1702
|
-
#
|
|
1703
|
-
|
|
1704
|
-
|
|
1814
|
+
# Since Fish completions are only loaded once the user triggers them, we trigger them ourselves
|
|
1815
|
+
# so we can properly delete any completions provided by another script.
|
|
1816
|
+
# Only do this if the program can be found, or else fish may print some errors; besides,
|
|
1817
|
+
# the existing completions will only be loaded if the program can be found.
|
|
1818
|
+
if type -q "${e}"
|
|
1819
|
+
# The space after the program name is essential to trigger completion for the program
|
|
1820
|
+
# and not completion of the program name itself.
|
|
1821
|
+
# Also, we use '> /dev/null 2>&1' since '&>' is not supported in older versions of fish.
|
|
1822
|
+
complete --do-complete "${e} " > /dev/null 2>&1
|
|
1823
|
+
end
|
|
1824
|
+
|
|
1825
|
+
# Remove any pre-existing completions for the program since we will be handling all of them.
|
|
1826
|
+
complete -c ${e} -e
|
|
1827
|
+
|
|
1828
|
+
# This will get called after the two calls below and clear the cached result
|
|
1829
|
+
complete -c ${e} -n '__${n}_clear_perform_completion_once_result'
|
|
1830
|
+
# The call to __${n}_prepare_completions will setup __${n}_comp_results
|
|
1831
|
+
# which provides the program's completion choices.
|
|
1832
|
+
# If this doesn't require order preservation, we don't use the -k flag
|
|
1833
|
+
complete -c ${e} -n 'not __${n}_requires_order_preservation && __${n}_prepare_completions' -f -a '$__${n}_comp_results'
|
|
1834
|
+
# Otherwise we use the -k flag
|
|
1835
|
+
complete -k -c ${e} -n '__${n}_requires_order_preservation && __${n}_prepare_completions' -f -a '$__${n}_comp_results'
|
|
1836
|
+
`}function i(e,t){let n=e.replace(/[-:]/g,`_`);return `# powershell completion for ${e} -*- shell-script -*-
|
|
1705
1837
|
|
|
1706
1838
|
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
|
1707
1839
|
function __${e}_debug {
|
|
@@ -1714,7 +1846,7 @@ complete -c ${e} -f -a "(eval __${n}_perform_completion)"
|
|
|
1714
1846
|
$_ -replace '\\s|#|@|\\$|;|,|''|\\{|\\}|\\(|\\)|"|\\||<|>|&','\`$&'
|
|
1715
1847
|
}
|
|
1716
1848
|
|
|
1717
|
-
[scriptblock]$__${
|
|
1849
|
+
[scriptblock]$__${n}CompleterBlock = {
|
|
1718
1850
|
param(
|
|
1719
1851
|
$WordToComplete,
|
|
1720
1852
|
$CommandAst,
|
|
@@ -1750,7 +1882,10 @@ complete -c ${e} -f -a "(eval __${n}_perform_completion)"
|
|
|
1750
1882
|
# Split the command at the first space to separate the program and arguments.
|
|
1751
1883
|
$Program, $Arguments = $Command.Split(" ", 2)
|
|
1752
1884
|
|
|
1753
|
-
$
|
|
1885
|
+
$QuotedArgs = ($Arguments -split ' ' | ForEach-Object { "'" + ($_ -replace "'", "''") + "'" }) -join ' '
|
|
1886
|
+
__${e}_debug "QuotedArgs: $QuotedArgs"
|
|
1887
|
+
|
|
1888
|
+
$RequestComp = "& ${t} complete '--' $QuotedArgs"
|
|
1754
1889
|
__${e}_debug "RequestComp: $RequestComp"
|
|
1755
1890
|
|
|
1756
1891
|
# we cannot use $WordToComplete because it
|
|
@@ -1945,8 +2080,8 @@ complete -c ${e} -f -a "(eval __${n}_perform_completion)"
|
|
|
1945
2080
|
}
|
|
1946
2081
|
}
|
|
1947
2082
|
|
|
1948
|
-
Register-ArgumentCompleter -CommandName '${e}' -ScriptBlock $__${
|
|
1949
|
-
`}const a={ShellCompDirectiveError:1,ShellCompDirectiveNoSpace:2,ShellCompDirectiveNoFileComp:4,ShellCompDirectiveFilterFileExt:8,ShellCompDirectiveFilterDirs:16,ShellCompDirectiveKeepOrder:32,ShellCompDirectiveDefault:0};var o$1=class o{name;variadic;command;handler;constructor(e,t,n,r=false){this.command=e,this.name=t,this.handler=n,this.variadic=r;}},s$1=class s{value;description;command;handler;alias;isBoolean;constructor(e,t,n,r,i,a){this.command=e,this.value=t,this.description=n,this.handler=r,this.alias=i,this.isBoolean=a;}},c$1=class c{value;description;options=new Map;arguments=new Map;parent;constructor(e,t){this.value=e,this.description=t;}option(e,t,n,r){let i,a,o;typeof n==`function`?(i=n,a=r,o=false):typeof n==`string`?(i=void 0,a=n,o=true):(i=void 0,a=void 0,o=true);let c=new s$1(this,e,t,i,a,o);return this.options.set(e,c),this}argument(e,t,n=false){let r=new o$1(this,e,t,n);return this.arguments.set(e,r),this}},l$1=class l extends c$1{commands=new Map;completions=[];directive=a.ShellCompDirectiveDefault;constructor(){super(``,``);}command(e,t){let n=new c$1(e,t);return this.commands.set(e,n),n}stripOptions(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r.startsWith(`-`)){n++;let t=false,i=this.findOption(this,r);if(i)t=i.isBoolean??false;else for(let[,e]of this.commands){let n=this.findOption(e,r);if(n){t=n.isBoolean??false;break}}!t&&n<e.length&&!e[n].startsWith(`-`)&&n++;}else t.push(r),n++;}return t}matchCommand(e){e=this.stripOptions(e);let t=[],n=[],r=null;for(let i=0;i<e.length;i++){let a=e[i];t.push(a);let o=this.commands.get(t.join(` `));if(o)r=o;else {n=e.slice(i,e.length);break}}return [r||this,n]}shouldCompleteFlags(e,t
|
|
2083
|
+
Register-ArgumentCompleter -CommandName '${e}' -ScriptBlock $__${n}CompleterBlock
|
|
2084
|
+
`}const a={ShellCompDirectiveError:1,ShellCompDirectiveNoSpace:2,ShellCompDirectiveNoFileComp:4,ShellCompDirectiveFilterFileExt:8,ShellCompDirectiveFilterDirs:16,ShellCompDirectiveKeepOrder:32,ShellCompDirectiveDefault:0};var o$1=class o{name;variadic;command;handler;constructor(e,t,n,r=false){this.command=e,this.name=t,this.handler=n,this.variadic=r;}},s$1=class s{value;description;command;handler;alias;isBoolean;constructor(e,t,n,r,i,a){this.command=e,this.value=t,this.description=n,this.handler=r,this.alias=i,this.isBoolean=a;}},c$1=class c{value;description;options=new Map;arguments=new Map;parent;constructor(e,t){this.value=e,this.description=t;}option(e,t,n,r){let i,a,o;typeof n==`function`?(i=n,a=r,o=false):typeof n==`string`?(i=void 0,a=n,o=true):(i=void 0,a=void 0,o=true);let c=new s$1(this,e,t,i,a,o);return this.options.set(e,c),this}argument(e,t,n=false){let r=new o$1(this,e,t,n);return this.arguments.set(e,r),this}},l$1=class l extends c$1{commands=new Map;completions=[];directive=a.ShellCompDirectiveDefault;constructor(){super(``,``);}command(e,t){let n=new c$1(e,t);return this.commands.set(e,n),n}stripOptions(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r.startsWith(`-`)){n++;let t=false,i=this.findOption(this,r);if(i)t=i.isBoolean??false;else for(let[,e]of this.commands){let n=this.findOption(e,r);if(n){t=n.isBoolean??false;break}}!t&&n<e.length&&!e[n].startsWith(`-`)&&n++;}else t.push(r),n++;}return t}matchCommand(e){e=this.stripOptions(e);let t=[],n=[],r=null;for(let i=0;i<e.length;i++){let a=e[i];t.push(a);let o=this.commands.get(t.join(` `));if(o)r=o;else {n=e.slice(i,e.length);break}}return [r||this,n]}shouldCompleteFlags(e,t){if(t.startsWith(`-`))return true;if(e?.startsWith(`-`)){let t=this.findOption(this,e);if(!t){for(let[,n]of this.commands)if(t=this.findOption(n,e),t)break}return !(t&&t.isBoolean)}return false}shouldCompleteCommands(e){return !e.startsWith(`-`)}handleFlagCompletion(e,t,n,r){let i;if(n.includes(`=`)){let[e]=n.split(`=`);i=e;}else if(r?.startsWith(`-`)){let t=this.findOption(e,r);t&&!t.isBoolean&&(i=r);}if(i){let t=this.findOption(e,i);if(t?.handler){let n=[];t.handler.call(t,(e,t)=>n.push({value:e,description:t}),e.options),this.completions=n;}return}if(n.startsWith(`-`)){let t=n.startsWith(`-`)&&!n.startsWith(`--`),r=n.replace(/^-+/,``);for(let[i,a]of e.options)t&&a.alias&&`-${a.alias}`.startsWith(n)?this.completions.push({value:`-${a.alias}`,description:a.description}):!t&&i.startsWith(r)&&this.completions.push({value:`--${i}`,description:a.description});}}findOption(e,t){let n=e.options.get(t);if(n||(n=e.options.get(t.replace(/^-+/,``)),n))return n;for(let[n,r]of e.options)if(r.alias&&`-${r.alias}`===t)return r}handleCommandCompletion(e,t){let n=this.stripOptions(e);for(let[e,r]of this.commands){if(e===``)continue;let i=e.split(` `);i.slice(0,n.length).every((e,t)=>e===n[t])&&i[n.length]?.startsWith(t)&&this.completions.push({value:i[n.length],description:r.description});}}handlePositionalCompletion(e,t){let n=e.value.split(` `).length,r=Math.max(0,t.length-n),i=Array.from(e.arguments.entries());if(i.length>0){let t;if(r<i.length){let[e,n]=i[r];t=n;}else {let e=i[i.length-1][1];e.variadic&&(t=e);}if(t&&t.handler&&typeof t.handler==`function`){let n=[];t.handler.call(t,(e,t)=>n.push({value:e,description:t}),e.options),this.completions.push(...n);}}}complete(e){this.directive=a.ShellCompDirectiveNoFileComp;let t=new Set;this.completions.filter(e=>t.has(e.value)?false:(t.add(e.value),true)).filter(t=>{if(e.includes(`=`)){let[,n]=e.split(`=`);return t.value.startsWith(n)}return t.value.startsWith(e)}).forEach(e=>console.log(`${e.value}\t${e.description??``}`)),console.log(`:${this.directive}`);}parse(e){this.completions=[];let t=e[e.length-1]===``;t&&e.pop();let n=e[e.length-1]||``,r=e.slice(0,-1);t&&(n!==``&&r.push(n),n=``);let[i]=this.matchCommand(r),a=r[r.length-1];if(this.shouldCompleteFlags(a,n))this.handleFlagCompletion(i,r,n,a);else {if(a?.startsWith(`-`)&&n===``&&t){let e=this.findOption(this,a);if(!e){for(let[,t]of this.commands)if(e=this.findOption(t,a),e)break}if(e&&e.isBoolean){this.complete(n);return}}this.shouldCompleteCommands(n)&&this.handleCommandCompletion(r,n),i&&i.arguments.size>0&&this.handlePositionalCompletion(i,r);}this.complete(n);}setup(a,o,s){switch(assert(s===`zsh`||s===`bash`||s===`fish`||s===`powershell`,`Unsupported shell`),s){case `zsh`:{let e=t(a,o);console.log(e);break}case `bash`:{let e=n(a,o);console.log(e);break}case `fish`:{let e=r(a,o);console.log(e);break}case `powershell`:{let e=i(a,o);console.log(e);break}}}};const u$1=new l$1;var f$1=u$1;
|
|
1950
2085
|
|
|
1951
2086
|
function e(e=`cli`){if(process.argv.indexOf(`--`)===-1){let t=`Error: You need to use -- to separate completion arguments.\nExample: ${e} complete -- <args>`;console.error(t),process.exit(1);}}
|
|
1952
2087
|
|
|
@@ -2158,11 +2293,11 @@ function normalizeCliOptions(cliFilters, argv) {
|
|
|
2158
2293
|
}
|
|
2159
2294
|
async function start(mode, cliFilters, options) {
|
|
2160
2295
|
try {
|
|
2161
|
-
const { startVitest } = await import('./cli-api.
|
|
2296
|
+
const { startVitest } = await import('./cli-api.DwoCIT8I.js').then(function (n) { return n.q; });
|
|
2162
2297
|
const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
|
|
2163
2298
|
if (!ctx.shouldKeepServer()) await ctx.exit();
|
|
2164
2299
|
} catch (e) {
|
|
2165
|
-
const { errorBanner } = await import('./index.
|
|
2300
|
+
const { errorBanner } = await import('./index.De5aIHUc.js').then(function (n) { return n.A; });
|
|
2166
2301
|
console.error(`\n${errorBanner("Startup Error")}`);
|
|
2167
2302
|
console.error(e);
|
|
2168
2303
|
console.error("\n\n");
|
|
@@ -2175,12 +2310,12 @@ async function init(project) {
|
|
|
2175
2310
|
console.error(/* @__PURE__ */ new Error("Only the \"browser\" project is supported. Use \"vitest init browser\" to create a new project."));
|
|
2176
2311
|
process.exit(1);
|
|
2177
2312
|
}
|
|
2178
|
-
const { create } = await import('./creator.
|
|
2313
|
+
const { create } = await import('./creator.DgVhQm5q.js');
|
|
2179
2314
|
await create();
|
|
2180
2315
|
}
|
|
2181
2316
|
async function collect(mode, cliFilters, options) {
|
|
2182
2317
|
try {
|
|
2183
|
-
const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.
|
|
2318
|
+
const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.DwoCIT8I.js').then(function (n) { return n.q; });
|
|
2184
2319
|
const ctx = await prepareVitest(mode, {
|
|
2185
2320
|
...normalizeCliOptions(cliFilters, options),
|
|
2186
2321
|
watch: false,
|
|
@@ -2199,7 +2334,7 @@ async function collect(mode, cliFilters, options) {
|
|
|
2199
2334
|
} else outputFileList(await ctx.getRelevantTestSpecifications(cliFilters.map(normalize)), options);
|
|
2200
2335
|
await ctx.close();
|
|
2201
2336
|
} catch (e) {
|
|
2202
|
-
const { errorBanner } = await import('./index.
|
|
2337
|
+
const { errorBanner } = await import('./index.De5aIHUc.js').then(function (n) { return n.A; });
|
|
2203
2338
|
console.error(`\n${errorBanner("Collect Error")}`);
|
|
2204
2339
|
console.error(e);
|
|
2205
2340
|
console.error("\n\n");
|