@vitest-agent/plugin 2.4.10 → 2.5.1
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/index.d.ts +10 -2
- package/package.json +7 -7
- package/plugin.js +9 -2
- package/utils/discover-projects.js +5 -1
- package/utils/ensure-github-reporter.js +24 -0
package/index.d.ts
CHANGED
|
@@ -424,13 +424,16 @@ declare namespace AgentPlugin {
|
|
|
424
424
|
* };
|
|
425
425
|
* ```
|
|
426
426
|
*
|
|
427
|
-
* @param strategy - Optional strategy or options object
|
|
427
|
+
* @param strategy - Optional strategy or options object
|
|
428
|
+
* `{ strategy?, cwd?, maxDepth? }`.
|
|
428
429
|
* Pass a {@link DiscoverStrategy} directly, or an options object to also
|
|
429
|
-
* specify a custom workspace root via `cwd
|
|
430
|
+
* specify a custom workspace root via `cwd` and deeper package traversal via
|
|
431
|
+
* `maxDepth`.
|
|
430
432
|
*/
|
|
431
433
|
function discover(strategy?: DiscoverStrategy | {
|
|
432
434
|
strategy?: DiscoverStrategy;
|
|
433
435
|
cwd?: string;
|
|
436
|
+
maxDepth?: number;
|
|
434
437
|
}): DiscoverBuilder;
|
|
435
438
|
/**
|
|
436
439
|
* Run a shell command, suppressing all output unless the command fails.
|
|
@@ -1034,6 +1037,11 @@ interface DiscoverProjectsOptions {
|
|
|
1034
1037
|
* package list through. Defaults to its `nodeSyncOps` binding.
|
|
1035
1038
|
*/
|
|
1036
1039
|
readonly syncOps?: WorkspacesSyncOptions;
|
|
1040
|
+
/**
|
|
1041
|
+
* Optional traversal depth override for workspace package enumeration.
|
|
1042
|
+
* Forwarded to `@effected/workspaces`' `getWorkspacePackagesSync`.
|
|
1043
|
+
*/
|
|
1044
|
+
readonly maxDepth?: number;
|
|
1037
1045
|
}
|
|
1038
1046
|
/**
|
|
1039
1047
|
* Scan all workspace packages and additional entries through the active strategy and return projects + tags.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest-agent/plugin",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Vitest plugin for the vitest-agent ecosystem: owns persistence, classification, baselines, trends, and dispatches rendering to a configurable reporter.",
|
|
6
6
|
"keywords": [
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@effect/platform-node": "4.0.0-rc.109",
|
|
43
43
|
"@effect/sql-sqlite-node": "4.0.0-rc.109",
|
|
44
|
-
"@effected/workspaces": "^0.18.
|
|
45
|
-
"@vitest-agent/cli": "2.2.
|
|
46
|
-
"@vitest-agent/mcp": "2.4.
|
|
47
|
-
"@vitest-agent/reporter": "2.1
|
|
48
|
-
"@vitest-agent/sdk": "2.4.
|
|
44
|
+
"@effected/workspaces": "^0.18.3",
|
|
45
|
+
"@vitest-agent/cli": "2.2.12",
|
|
46
|
+
"@vitest-agent/mcp": "2.4.9",
|
|
47
|
+
"@vitest-agent/reporter": "2.2.1",
|
|
48
|
+
"@vitest-agent/sdk": "2.4.12",
|
|
49
49
|
"effect": "4.0.0-rc.109",
|
|
50
|
-
"magic-string": "^1.2.
|
|
50
|
+
"magic-string": "^1.2.3"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"@vitest/coverage-istanbul": "^4.1.0",
|
package/plugin.js
CHANGED
|
@@ -5,6 +5,7 @@ import { AgentReporter } from "./reporter.js";
|
|
|
5
5
|
import { buildModuleInfo } from "./utils/build-module-info.js";
|
|
6
6
|
import { DefaultDiscoverStrategy } from "./utils/discover-strategy.js";
|
|
7
7
|
import { discoverProjects } from "./utils/discover-projects.js";
|
|
8
|
+
import { ensureGithubActionsReporter } from "./utils/ensure-github-reporter.js";
|
|
8
9
|
import { injectTags } from "./utils/inject-tags.js";
|
|
9
10
|
import { isBenignViteSourceMapWarning } from "./utils/is-benign-vite-source-map-warning.js";
|
|
10
11
|
import { DEFAULT_BUILT_RECENTLY_MS, DEFAULT_LOCK_STALE_MS, DEFAULT_LOCK_WAIT_TIMEOUT_MS, acquireRunScriptLock, markRunScriptDone, parseLockTimingOverride, releaseRunScriptLock } from "./utils/run-script-lock.js";
|
|
@@ -100,7 +101,7 @@ const aggregatedReporterByVitest = /* @__PURE__ */ new WeakSet();
|
|
|
100
101
|
*
|
|
101
102
|
* @public
|
|
102
103
|
*/
|
|
103
|
-
const CURRENT_PLUGIN_VERSION = "2.
|
|
104
|
+
const CURRENT_PLUGIN_VERSION = "2.5.1";
|
|
104
105
|
const TEST_FILE_DIR_RE = new RegExp(`/(?:${SRC_DIR}|${TEST_DIR})/`);
|
|
105
106
|
const isTestFile = (id) => isTestFileName(id) && TEST_FILE_DIR_RE.test(id);
|
|
106
107
|
/**
|
|
@@ -180,6 +181,11 @@ function AgentPlugin(options = {}, _layer) {
|
|
|
180
181
|
coverageCfg.reporter = [];
|
|
181
182
|
}
|
|
182
183
|
}
|
|
184
|
+
if (env === "ci-github" && consoleMode !== "silent") {
|
|
185
|
+
log("ensuring github-actions reporter is present");
|
|
186
|
+
const withGithubActions = ensureGithubActionsReporter(vitest.config.reporters);
|
|
187
|
+
vitest.config.reporters = withGithubActions;
|
|
188
|
+
}
|
|
183
189
|
const githubActions = env === "ci-github" && consoleMode !== "silent";
|
|
184
190
|
log("githubActions (auto):", githubActions);
|
|
185
191
|
const validation = await Effect.runPromise(Effect.provide(Effect.flatMap(ConfigValidation, (cv) => cv.validate({
|
|
@@ -306,7 +312,8 @@ function makeDiscoverBuilder(options) {
|
|
|
306
312
|
const opts = strategy;
|
|
307
313
|
return makeDiscoverBuilder({
|
|
308
314
|
...opts.strategy !== void 0 ? { strategy: opts.strategy } : {},
|
|
309
|
-
...opts.cwd !== void 0 ? { cwd: opts.cwd } : {}
|
|
315
|
+
...opts.cwd !== void 0 ? { cwd: opts.cwd } : {},
|
|
316
|
+
...opts.maxDepth !== void 0 ? { maxDepth: opts.maxDepth } : {}
|
|
310
317
|
});
|
|
311
318
|
}
|
|
312
319
|
_AgentPlugin.discover = discover;
|
|
@@ -103,11 +103,15 @@ async function discoverProjects(options) {
|
|
|
103
103
|
const additionalEntries = options?.additionalEntries ?? [];
|
|
104
104
|
const fs = options?.fs ?? nodeWalkerFs;
|
|
105
105
|
const syncOps = options?.syncOps ?? nodeSyncOps;
|
|
106
|
+
const packageEnumerationOptions = {
|
|
107
|
+
...syncOps,
|
|
108
|
+
...options?.maxDepth !== void 0 ? { maxDepth: options.maxDepth } : {}
|
|
109
|
+
};
|
|
106
110
|
const root = findWorkspaceRootSync(cwd ?? process.cwd(), syncOps);
|
|
107
111
|
if (!root) throw new Error(`[vitest-agent] Could not find workspace root from ${cwd ?? process.cwd()}. Ensure a pnpm-workspace.yaml or package.json with "workspaces" exists.`);
|
|
108
112
|
const useCache = strategy === void 0 && additionalEntries.length === 0;
|
|
109
113
|
const resolvedStrategy = strategy ?? new DefaultDiscoverStrategy();
|
|
110
|
-
const packages = getWorkspacePackagesSync(root,
|
|
114
|
+
const packages = getWorkspacePackagesSync(root, packageEnumerationOptions);
|
|
111
115
|
let signature;
|
|
112
116
|
if (useCache) {
|
|
113
117
|
signature = await computeWorkspaceSignature(packages, fs);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/utils/ensure-github-reporter.ts
|
|
2
|
+
/**
|
|
3
|
+
* Ensure a Vitest `reporters` array contains a `github-actions` entry.
|
|
4
|
+
*
|
|
5
|
+
* @privateRemarks
|
|
6
|
+
* Vitest only auto-appends its built-in `"github-actions"` reporter when
|
|
7
|
+
* the resolved `reporters` array is EMPTY. Once any other reporter is
|
|
8
|
+
* configured (which the plugin always does), that implicit behavior no
|
|
9
|
+
* longer applies, so `AgentPlugin` calls this explicitly under
|
|
10
|
+
* `env === "ci-github"` to guarantee the entry is present.
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
function ensureGithubActionsReporter(reporters) {
|
|
15
|
+
if (reporters.some((entry) => {
|
|
16
|
+
if (typeof entry === "string") return entry === "github-actions";
|
|
17
|
+
if (Array.isArray(entry) && typeof entry[0] === "string") return entry[0] === "github-actions";
|
|
18
|
+
return false;
|
|
19
|
+
})) return reporters;
|
|
20
|
+
return [...reporters, ["github-actions", {}]];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { ensureGithubActionsReporter };
|