@blzsky/variant 0.2.1 → 0.3.0-canary.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.
Files changed (58) hide show
  1. package/README.md +222 -85
  2. package/dist/{build-3DSBMMI3.js → build-GCUFPPIB.js} +11 -10
  3. package/dist/check-AKYABBIV.js +1459 -0
  4. package/dist/{chunk-43VLELTL.js → chunk-2UVLKBLV.js} +1 -1
  5. package/dist/chunk-34VGKPEM.js +59 -0
  6. package/dist/chunk-BNACT47L.js +590 -0
  7. package/dist/chunk-C3NZIFW6.js +174 -0
  8. package/dist/{chunk-ZH2PQUNL.js → chunk-EFCMBBBT.js} +72 -110
  9. package/dist/chunk-H55GYSQ6.js +102 -0
  10. package/dist/chunk-HL65IPEQ.js +167 -0
  11. package/dist/chunk-IHXJ72XA.js +31 -0
  12. package/dist/{chunk-FZEXZBXB.js → chunk-JEJRXPCU.js} +41 -9
  13. package/dist/chunk-LUTP2TVU.js +94 -0
  14. package/dist/{chunk-7OPTWU6E.js → chunk-MKUYZIXF.js} +1 -1
  15. package/dist/chunk-MNYKLWRC.js +377 -0
  16. package/dist/{chunk-Q7RLUZSN.js → chunk-NJSTAWDM.js} +10 -3
  17. package/dist/{chunk-26DHEXGS.js → chunk-NOC53Z5Q.js} +1 -1
  18. package/dist/chunk-O6FCFZDF.js +127 -0
  19. package/dist/{chunk-6BXSZPHC.js → chunk-OON6O4S5.js} +99 -6
  20. package/dist/{chunk-FA64KWJ2.js → chunk-TPMHY4L6.js} +16 -31
  21. package/dist/chunk-TRUK3TJF.js +575 -0
  22. package/dist/chunk-WTXWEEI2.js +21 -0
  23. package/dist/{chunk-RC23JQKI.js → chunk-WULBOSG5.js} +15 -2
  24. package/dist/chunk-X3VVGTEV.js +268 -0
  25. package/dist/{chunk-TCISS2AS.js → chunk-XXMD4NC5.js} +120 -25
  26. package/dist/cli.js +89 -30
  27. package/dist/{diff-HSJBZFMC.js → diff-ST5KHT7P.js} +5 -5
  28. package/dist/{doctor-B7MHFIYJ.js → doctor-OEIY4Y5X.js} +41 -8
  29. package/dist/{env-I7JZRWDN.js → env-EQAOZCFR.js} +8 -9
  30. package/dist/git-VGHUF2SY.js +30 -0
  31. package/dist/impact-AXLZTLVT.js +266 -0
  32. package/dist/index.js +2 -2
  33. package/dist/init-QCOZWLOO.js +793 -0
  34. package/dist/{insight-JQLTGFYB.js → insight-KRWT6Z47.js} +9 -10
  35. package/dist/pr-7JXUC5BQ.js +710 -0
  36. package/dist/{run-C6VAQOVM.js → run-UOPS5FRU.js} +11 -10
  37. package/dist/stryker-host.d.ts +2 -0
  38. package/dist/stryker-host.js +135 -0
  39. package/dist/stryker-plugins.d.ts +33 -0
  40. package/dist/stryker-plugins.js +142 -0
  41. package/dist/{symbol-graph-E5GXKDFZ.js → symbol-graph-GYOI4GU4.js} +3 -3
  42. package/dist/{tsconfig-paths-E3UEDGXZ.js → tsconfig-paths-SV3PULCW.js} +3 -1
  43. package/dist/vitest.cjs +629 -0
  44. package/dist/vitest.d.cts +181 -0
  45. package/dist/vitest.d.ts +181 -0
  46. package/dist/vitest.js +358 -0
  47. package/dist/workspace-IQFLR3RY.js +65 -0
  48. package/package.json +17 -3
  49. package/dist/check-SIQJU6Z2.js +0 -44
  50. package/dist/chunk-DRMASVYN.js +0 -25
  51. package/dist/chunk-KSHWC2XN.js +0 -78
  52. package/dist/chunk-QRPI6TJE.js +0 -68
  53. package/dist/chunk-VYWPQKMS.js +0 -88
  54. package/dist/chunk-XTYVVUWW.js +0 -279
  55. package/dist/impact-PRZ6HEP5.js +0 -735
  56. package/dist/init-O2BY3FOY.js +0 -158
  57. package/dist/pr-Y724QAHE.js +0 -165
  58. package/dist/workspace-HRTFGWKN.js +0 -186
@@ -1,88 +0,0 @@
1
- // src/core/errors.ts
2
- var VariantError = class extends Error {
3
- constructor(code, message, options) {
4
- super(message, options);
5
- this.code = code;
6
- this.name = "VariantError";
7
- }
8
- code;
9
- hint;
10
- /**
11
- * Why the task that produced this failure was running. Attached by the
12
- * runner so the failure and its reason travel together; absent on errors
13
- * belonging to no task (config, CLI usage) and on successful runs.
14
- *
15
- * This says nothing about why the task FAILED — see `RunReason`.
16
- */
17
- provenance;
18
- };
19
- var ConfigError = class extends VariantError {
20
- constructor(message, options) {
21
- super("CONFIG_ERROR", message, options);
22
- this.hint = "Run `variant doctor` to diagnose configuration issues.";
23
- }
24
- };
25
- var CycleError = class extends VariantError {
26
- constructor(cycle) {
27
- super("CYCLE_ERROR", `Circular dependency detected: ${cycle.join(" -> ")}`);
28
- this.cycle = cycle;
29
- this.hint = "Remove or reorder `dependsOn` entries to break the cycle.";
30
- }
31
- cycle;
32
- };
33
- var TaskExecutionError = class extends VariantError {
34
- constructor(task, exitCode, message, options) {
35
- super(
36
- "TASK_EXECUTION_ERROR",
37
- message ?? `Task "${task}" failed with exit code ${exitCode}`,
38
- options
39
- );
40
- this.task = task;
41
- this.exitCode = exitCode;
42
- this.hint = `Check the output above, fix the failing command in task "${task}", then re-run.`;
43
- }
44
- task;
45
- exitCode;
46
- };
47
- var CacheError = class extends VariantError {
48
- constructor(message, options) {
49
- super("CACHE_ERROR", message, options);
50
- this.hint = "Delete `.variant/cache/` and retry.";
51
- }
52
- };
53
- var GraphError = class extends VariantError {
54
- constructor(message, options) {
55
- super("GRAPH_ERROR", message, options);
56
- this.hint = "Delete `.variant/graph/` and retry.";
57
- }
58
- };
59
- var GitRefError = class extends VariantError {
60
- constructor(message) {
61
- super("GIT_REF_ERROR", message);
62
- this.hint = "Check the ref with `git rev-parse --verify <ref>`. In CI, check out with `fetch-depth: 0` and pass a remote-tracking ref such as `origin/main`.";
63
- }
64
- };
65
- var ImpactReportError = class extends VariantError {
66
- constructor(message) {
67
- super("IMPACT_REPORT_ERROR", `Could not read the test report: ${message}`);
68
- this.hint = "Pass a Vitest `--reporter=json --outputFile=<path>` or Jest `--json --outputFile=<path>` report.";
69
- }
70
- };
71
- var CliUsageError = class extends VariantError {
72
- constructor(message) {
73
- super("CLI_USAGE", message);
74
- this.hint = "Run `variant --help` for usage information.";
75
- }
76
- };
77
-
78
- export {
79
- VariantError,
80
- ConfigError,
81
- CycleError,
82
- TaskExecutionError,
83
- CacheError,
84
- GraphError,
85
- GitRefError,
86
- ImpactReportError,
87
- CliUsageError
88
- };
@@ -1,279 +0,0 @@
1
- import {
2
- matchPathAlias
3
- } from "./chunk-KSHWC2XN.js";
4
-
5
- // src/core/graph/import-graph.ts
6
- import path2 from "path";
7
-
8
- // src/core/graph/package-exports.ts
9
- import path from "path";
10
- var BUILD_DIRS = ["dist", "lib", "build", "out", "es", "esm", "cjs"];
11
- var SOURCE_DIRS = ["src", "lib", "source", ""];
12
- var CONDITIONS = [
13
- "source",
14
- "development",
15
- "import",
16
- "module",
17
- "require",
18
- "types",
19
- "node",
20
- "default"
21
- ];
22
- var MAX_CONDITION_DEPTH = 8;
23
- function targetsOf(value, depth = 0) {
24
- if (depth > MAX_CONDITION_DEPTH) return [];
25
- if (typeof value === "string") return [value];
26
- if (Array.isArray(value)) {
27
- return value.flatMap((entry) => targetsOf(entry, depth + 1));
28
- }
29
- if (typeof value !== "object" || value === null) return [];
30
- const record = value;
31
- const out = [];
32
- for (const condition of CONDITIONS) {
33
- if (condition in record) {
34
- out.push(...targetsOf(record[condition], depth + 1));
35
- }
36
- }
37
- for (const [key, nested] of Object.entries(record)) {
38
- if (!CONDITIONS.includes(key) && !key.startsWith(".")) {
39
- out.push(...targetsOf(nested, depth + 1));
40
- }
41
- }
42
- return out;
43
- }
44
- function clean(target) {
45
- if (!target.startsWith("./")) return void 0;
46
- return target.slice(2);
47
- }
48
- function resolveExportsSubpath(exportsField, subpath) {
49
- if (exportsField === void 0 || exportsField === null) return [];
50
- const request = subpath === "" ? "." : `./${subpath}`;
51
- const isSubpathMap = typeof exportsField === "object" && !Array.isArray(exportsField) && Object.keys(exportsField).some(
52
- (k) => k.startsWith(".")
53
- );
54
- if (!isSubpathMap) {
55
- return request === "." ? targetsOf(exportsField).map(clean).filter((t) => t !== void 0) : [];
56
- }
57
- const map = exportsField;
58
- if (request in map) {
59
- return targetsOf(map[request]).map(clean).filter((t) => t !== void 0);
60
- }
61
- const patterns = Object.keys(map).filter((key) => key.startsWith("./") && key.includes("*")).sort((a, b) => b.length - a.length);
62
- for (const pattern of patterns) {
63
- const [prefix = "", suffix = ""] = pattern.split("*");
64
- if (request.length < prefix.length + suffix.length || !request.startsWith(prefix) || !request.endsWith(suffix)) {
65
- continue;
66
- }
67
- const captured = request.slice(
68
- prefix.length,
69
- request.length - suffix.length
70
- );
71
- const targets = targetsOf(map[pattern]).map((t) => clean(t.replace("*", captured))).filter((t) => t !== void 0);
72
- if (targets.length > 0) return targets;
73
- }
74
- return [];
75
- }
76
- function toSourceCandidates(target) {
77
- const withoutExtension = stripExtension(target);
78
- const segments = withoutExtension.split("/");
79
- const head = segments[0];
80
- const bodies = head !== void 0 && BUILD_DIRS.includes(head) && segments.length > 1 ? [segments.slice(1).join("/")] : [withoutExtension];
81
- const out = [];
82
- for (const body of bodies) {
83
- for (const dir of SOURCE_DIRS) {
84
- out.push(dir === "" ? body : `${dir}/${body}`);
85
- }
86
- }
87
- return [...new Set(out)];
88
- }
89
- function stripExtension(target) {
90
- if (target.endsWith(".d.ts")) return target.slice(0, -".d.ts".length);
91
- const ext = path.posix.extname(target);
92
- return ext === "" ? target : target.slice(0, -ext.length);
93
- }
94
- function exportsCandidates(exportsField, subpath) {
95
- const targets = resolveExportsSubpath(exportsField, subpath);
96
- if (targets.length === 0) return [];
97
- const out = [];
98
- for (const target of targets) out.push(stripExtension(target));
99
- for (const target of targets) out.push(...toSourceCandidates(target));
100
- return [...new Set(out)];
101
- }
102
-
103
- // src/core/graph/import-graph.ts
104
- var TS_EXTENSIONS = [".ts", ".tsx", ".mts", ".cts"];
105
- var JS_TO_TS = {
106
- ".js": [".ts", ".tsx"],
107
- ".mjs": [".mts"],
108
- ".cjs": [".cts"],
109
- ".jsx": [".tsx"]
110
- };
111
- function buildImportGraph(symbolGraph, options = {}) {
112
- const files = new Set(Object.keys(symbolGraph.files));
113
- const packageDirs = options.packageDirs ?? {};
114
- const pathAliases = options.pathAliases ?? [];
115
- const packageExports = options.packageExports ?? {};
116
- const imports = /* @__PURE__ */ new Map();
117
- const dependents = /* @__PURE__ */ new Map();
118
- const externals = /* @__PURE__ */ new Map();
119
- const unresolved = /* @__PURE__ */ new Map();
120
- const edges = /* @__PURE__ */ new Map();
121
- for (const file of [...files].sort()) {
122
- imports.set(file, /* @__PURE__ */ new Set());
123
- dependents.set(file, /* @__PURE__ */ new Set());
124
- externals.set(file, /* @__PURE__ */ new Set());
125
- unresolved.set(file, /* @__PURE__ */ new Set());
126
- edges.set(file, /* @__PURE__ */ new Map());
127
- }
128
- const addEdge = (from, to, imp) => {
129
- imports.get(from)?.add(to);
130
- const perFile = edges.get(from);
131
- if (perFile === void 0) return;
132
- let edge = perFile.get(to);
133
- if (edge === void 0) {
134
- edge = { names: /* @__PURE__ */ new Set(), typeOnly: true, dynamic: false };
135
- perFile.set(to, edge);
136
- }
137
- for (const name of imp.names) edge.names.add(name);
138
- if (imp.kind === "dynamic") edge.dynamic = true;
139
- edge.typeOnly = edge.typeOnly && imp.typeOnly;
140
- };
141
- for (const file of [...files].sort()) {
142
- const index = symbolGraph.files[file];
143
- if (index === void 0) continue;
144
- for (const imp of index.imports) {
145
- const spec = imp.module;
146
- if (spec.startsWith("./") || spec.startsWith("../")) {
147
- const resolved = resolveRelativeImport(file, spec, files);
148
- if (resolved === void 0) unresolved.get(file)?.add(spec);
149
- else addEdge(file, resolved, imp);
150
- continue;
151
- }
152
- if (spec.startsWith("node:")) {
153
- externals.get(file)?.add(spec);
154
- continue;
155
- }
156
- const pkg = matchWorkspacePackage(spec, packageDirs);
157
- if (pkg !== void 0) {
158
- const resolved = resolvePackageImport(
159
- pkg.dir,
160
- pkg.subpath,
161
- files,
162
- packageExports[pkg.name]
163
- );
164
- if (resolved === void 0) unresolved.get(file)?.add(spec);
165
- else addEdge(file, resolved, imp);
166
- continue;
167
- }
168
- const aliased = resolveAliasImport(spec, pathAliases, files);
169
- if (aliased !== void 0) {
170
- addEdge(file, aliased, imp);
171
- continue;
172
- }
173
- if (matchPathAlias(spec, pathAliases).length > 0) {
174
- unresolved.get(file)?.add(spec);
175
- continue;
176
- }
177
- externals.get(file)?.add(spec);
178
- }
179
- }
180
- for (const [file, targets] of imports) {
181
- for (const target of targets) {
182
- dependents.get(target)?.add(file);
183
- }
184
- }
185
- return { imports, dependents, externals, unresolved, edges };
186
- }
187
- function computeAffectedFiles(changed, graph) {
188
- const affected = /* @__PURE__ */ new Set();
189
- for (const file of changed) affected.add(toPosix(file));
190
- let frontier = new Set(affected);
191
- while (frontier.size > 0) {
192
- const next = /* @__PURE__ */ new Set();
193
- for (const file of frontier) {
194
- for (const dependent of graph.dependents.get(file) ?? []) {
195
- if (!affected.has(dependent)) {
196
- affected.add(dependent);
197
- next.add(dependent);
198
- }
199
- }
200
- }
201
- frontier = next;
202
- }
203
- return affected;
204
- }
205
- function resolveRelativeImport(fromFile, spec, files) {
206
- const base = path2.posix.normalize(
207
- path2.posix.join(path2.posix.dirname(fromFile), spec)
208
- );
209
- if (base.startsWith("../")) return void 0;
210
- return firstExisting(candidatePaths(base), files);
211
- }
212
- function resolvePackageImport(pkgDir, subpath, files, exportsField) {
213
- const fromExports = exportsCandidates(exportsField, subpath);
214
- const candidates = fromExports.flatMap(
215
- (base) => candidatePaths(path2.posix.join(pkgDir, base))
216
- );
217
- if (subpath === "") {
218
- candidates.push(
219
- ...candidatePaths(`${pkgDir}/src/index`),
220
- ...candidatePaths(`${pkgDir}/index`)
221
- );
222
- } else {
223
- candidates.push(
224
- ...candidatePaths(path2.posix.join(pkgDir, subpath)),
225
- ...candidatePaths(path2.posix.join(pkgDir, "src", subpath))
226
- );
227
- }
228
- return firstExisting(candidates, files);
229
- }
230
- function resolveAliasImport(spec, aliases, files) {
231
- for (const base of matchPathAlias(spec, aliases)) {
232
- const resolved = firstExisting(candidatePaths(base), files);
233
- if (resolved !== void 0) return resolved;
234
- }
235
- return void 0;
236
- }
237
- function matchWorkspacePackage(spec, packageDirs) {
238
- const segments = spec.split("/");
239
- const nameLength = spec.startsWith("@") ? 2 : 1;
240
- if (segments.length < nameLength) return void 0;
241
- const name = segments.slice(0, nameLength).join("/");
242
- const dir = packageDirs[name];
243
- if (dir === void 0) return void 0;
244
- return {
245
- name,
246
- dir: toPosix(dir),
247
- subpath: segments.slice(nameLength).join("/")
248
- };
249
- }
250
- function candidatePaths(base) {
251
- const ext = path2.posix.extname(base);
252
- if (TS_EXTENSIONS.includes(ext)) {
253
- return [base];
254
- }
255
- const tsExts = JS_TO_TS[ext];
256
- if (tsExts !== void 0) {
257
- const stem = base.slice(0, -ext.length);
258
- return tsExts.map((e) => stem + e);
259
- }
260
- return [
261
- ...TS_EXTENSIONS.map((e) => base + e),
262
- ...TS_EXTENSIONS.map((e) => `${base}/index${e}`)
263
- ];
264
- }
265
- function firstExisting(candidates, files) {
266
- for (const c of candidates) {
267
- if (files.has(c)) return c;
268
- }
269
- return void 0;
270
- }
271
- function toPosix(p) {
272
- return p.replace(/\\/g, "/");
273
- }
274
-
275
- export {
276
- buildImportGraph,
277
- computeAffectedFiles,
278
- resolveRelativeImport
279
- };