@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.
- package/README.md +222 -85
- package/dist/{build-3DSBMMI3.js → build-GCUFPPIB.js} +11 -10
- package/dist/check-AKYABBIV.js +1459 -0
- package/dist/{chunk-43VLELTL.js → chunk-2UVLKBLV.js} +1 -1
- package/dist/chunk-34VGKPEM.js +59 -0
- package/dist/chunk-BNACT47L.js +590 -0
- package/dist/chunk-C3NZIFW6.js +174 -0
- package/dist/{chunk-ZH2PQUNL.js → chunk-EFCMBBBT.js} +72 -110
- package/dist/chunk-H55GYSQ6.js +102 -0
- package/dist/chunk-HL65IPEQ.js +167 -0
- package/dist/chunk-IHXJ72XA.js +31 -0
- package/dist/{chunk-FZEXZBXB.js → chunk-JEJRXPCU.js} +41 -9
- package/dist/chunk-LUTP2TVU.js +94 -0
- package/dist/{chunk-7OPTWU6E.js → chunk-MKUYZIXF.js} +1 -1
- package/dist/chunk-MNYKLWRC.js +377 -0
- package/dist/{chunk-Q7RLUZSN.js → chunk-NJSTAWDM.js} +10 -3
- package/dist/{chunk-26DHEXGS.js → chunk-NOC53Z5Q.js} +1 -1
- package/dist/chunk-O6FCFZDF.js +127 -0
- package/dist/{chunk-6BXSZPHC.js → chunk-OON6O4S5.js} +99 -6
- package/dist/{chunk-FA64KWJ2.js → chunk-TPMHY4L6.js} +16 -31
- package/dist/chunk-TRUK3TJF.js +575 -0
- package/dist/chunk-WTXWEEI2.js +21 -0
- package/dist/{chunk-RC23JQKI.js → chunk-WULBOSG5.js} +15 -2
- package/dist/chunk-X3VVGTEV.js +268 -0
- package/dist/{chunk-TCISS2AS.js → chunk-XXMD4NC5.js} +120 -25
- package/dist/cli.js +89 -30
- package/dist/{diff-HSJBZFMC.js → diff-ST5KHT7P.js} +5 -5
- package/dist/{doctor-B7MHFIYJ.js → doctor-OEIY4Y5X.js} +41 -8
- package/dist/{env-I7JZRWDN.js → env-EQAOZCFR.js} +8 -9
- package/dist/git-VGHUF2SY.js +30 -0
- package/dist/impact-AXLZTLVT.js +266 -0
- package/dist/index.js +2 -2
- package/dist/init-QCOZWLOO.js +793 -0
- package/dist/{insight-JQLTGFYB.js → insight-KRWT6Z47.js} +9 -10
- package/dist/pr-7JXUC5BQ.js +710 -0
- package/dist/{run-C6VAQOVM.js → run-UOPS5FRU.js} +11 -10
- package/dist/stryker-host.d.ts +2 -0
- package/dist/stryker-host.js +135 -0
- package/dist/stryker-plugins.d.ts +33 -0
- package/dist/stryker-plugins.js +142 -0
- package/dist/{symbol-graph-E5GXKDFZ.js → symbol-graph-GYOI4GU4.js} +3 -3
- package/dist/{tsconfig-paths-E3UEDGXZ.js → tsconfig-paths-SV3PULCW.js} +3 -1
- package/dist/vitest.cjs +629 -0
- package/dist/vitest.d.cts +181 -0
- package/dist/vitest.d.ts +181 -0
- package/dist/vitest.js +358 -0
- package/dist/workspace-IQFLR3RY.js +65 -0
- package/package.json +17 -3
- package/dist/check-SIQJU6Z2.js +0 -44
- package/dist/chunk-DRMASVYN.js +0 -25
- package/dist/chunk-KSHWC2XN.js +0 -78
- package/dist/chunk-QRPI6TJE.js +0 -68
- package/dist/chunk-VYWPQKMS.js +0 -88
- package/dist/chunk-XTYVVUWW.js +0 -279
- package/dist/impact-PRZ6HEP5.js +0 -735
- package/dist/init-O2BY3FOY.js +0 -158
- package/dist/pr-Y724QAHE.js +0 -165
- package/dist/workspace-HRTFGWKN.js +0 -186
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defaultBranchRef,
|
|
3
|
+
mergeBase,
|
|
4
|
+
resolveCommit
|
|
5
|
+
} from "./chunk-OON6O4S5.js";
|
|
6
|
+
import {
|
|
7
|
+
GitRefError,
|
|
8
|
+
NoBaseCommitError
|
|
9
|
+
} from "./chunk-C3NZIFW6.js";
|
|
10
|
+
|
|
11
|
+
// src/core/vcs/change-base.ts
|
|
12
|
+
import { readFile } from "fs/promises";
|
|
13
|
+
function changeBaseDeps(cwd) {
|
|
14
|
+
return {
|
|
15
|
+
env: process.env,
|
|
16
|
+
readEvent: async (path) => {
|
|
17
|
+
try {
|
|
18
|
+
return JSON.parse(await readFile(path, "utf8"));
|
|
19
|
+
} catch {
|
|
20
|
+
return void 0;
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
resolveCommit: (ref) => resolveCommit(cwd, ref),
|
|
24
|
+
mergeBase: (a, b) => mergeBase(cwd, a, b),
|
|
25
|
+
defaultBranch: () => defaultBranchRef(cwd)
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
var ZERO_SHA = /^0+$/;
|
|
29
|
+
function field(value, ...keys) {
|
|
30
|
+
let current = value;
|
|
31
|
+
for (const key of keys) {
|
|
32
|
+
if (typeof current !== "object" || current === null) return void 0;
|
|
33
|
+
current = current[key];
|
|
34
|
+
}
|
|
35
|
+
return current;
|
|
36
|
+
}
|
|
37
|
+
function isPullRequest(env) {
|
|
38
|
+
const event = env["GITHUB_EVENT_NAME"];
|
|
39
|
+
return env["GITHUB_ACTIONS"] === "true" && (event === "pull_request" || event === "pull_request_target") && (env["GITHUB_BASE_REF"] ?? "") !== "";
|
|
40
|
+
}
|
|
41
|
+
async function readEvent(deps) {
|
|
42
|
+
const path = deps.env["GITHUB_EVENT_PATH"];
|
|
43
|
+
return path === void 0 || path === "" ? void 0 : deps.readEvent(path);
|
|
44
|
+
}
|
|
45
|
+
async function resolveChangeBase(explicit, deps) {
|
|
46
|
+
if (explicit !== void 0) {
|
|
47
|
+
return { ref: explicit, source: "flag", label: explicit };
|
|
48
|
+
}
|
|
49
|
+
const fromEnvironment = deps.env["VARIANT_BASE"];
|
|
50
|
+
if (fromEnvironment !== void 0 && fromEnvironment !== "") {
|
|
51
|
+
return {
|
|
52
|
+
ref: fromEnvironment,
|
|
53
|
+
source: "environment",
|
|
54
|
+
label: `${fromEnvironment} (VARIANT_BASE)`
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
if (isPullRequest(deps.env)) {
|
|
58
|
+
const target = `origin/${deps.env["GITHUB_BASE_REF"]}`;
|
|
59
|
+
if (await deps.resolveCommit(target) === null) {
|
|
60
|
+
throw new GitRefError(
|
|
61
|
+
`The pull request's target branch, "${target}", is not in this clone`
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
const fork = await deps.mergeBase("HEAD", target);
|
|
65
|
+
if (fork === null) {
|
|
66
|
+
throw new GitRefError(
|
|
67
|
+
`"${target}" shares no history with HEAD in this clone`
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
const pushed = field(await readEvent(deps), "pull_request", "head", "sha");
|
|
71
|
+
return {
|
|
72
|
+
ref: fork,
|
|
73
|
+
source: "pull-request",
|
|
74
|
+
label: `merge base with ${target}`,
|
|
75
|
+
...typeof pushed === "string" && pushed !== "" && { headSha: pushed }
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if (deps.env["GITHUB_ACTIONS"] === "true" && deps.env["GITHUB_EVENT_NAME"] === "push") {
|
|
79
|
+
const before = field(await readEvent(deps), "before");
|
|
80
|
+
if (typeof before !== "string" || before === "" || ZERO_SHA.test(before) || await deps.resolveCommit(before) === null) {
|
|
81
|
+
throw new NoBaseCommitError();
|
|
82
|
+
}
|
|
83
|
+
const pushed = deps.env["GITHUB_SHA"];
|
|
84
|
+
return {
|
|
85
|
+
ref: before,
|
|
86
|
+
source: "push",
|
|
87
|
+
label: "the commit this push replaced",
|
|
88
|
+
...pushed !== void 0 && pushed !== "" && { headSha: pushed }
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
const branch = await deps.defaultBranch();
|
|
92
|
+
if (branch !== null) {
|
|
93
|
+
const [fork, head] = await Promise.all([
|
|
94
|
+
deps.mergeBase("HEAD", branch),
|
|
95
|
+
deps.resolveCommit("HEAD")
|
|
96
|
+
]);
|
|
97
|
+
if (fork !== null && fork !== head) {
|
|
98
|
+
return {
|
|
99
|
+
ref: fork,
|
|
100
|
+
source: "default-branch",
|
|
101
|
+
label: `merge base with ${branch}`
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return { ref: "HEAD~1", source: "previous-commit", label: "previous commit" };
|
|
106
|
+
}
|
|
107
|
+
async function resolvePullRequestBase(explicit, deps) {
|
|
108
|
+
if (explicit !== void 0) return explicit;
|
|
109
|
+
if (isPullRequest(deps.env)) return `origin/${deps.env["GITHUB_BASE_REF"]}`;
|
|
110
|
+
return await deps.defaultBranch() ?? "main";
|
|
111
|
+
}
|
|
112
|
+
async function detectHeadSha(deps) {
|
|
113
|
+
if (deps.env["GITHUB_ACTIONS"] !== "true") return void 0;
|
|
114
|
+
if (isPullRequest(deps.env)) {
|
|
115
|
+
const pushed = field(await readEvent(deps), "pull_request", "head", "sha");
|
|
116
|
+
return typeof pushed === "string" && pushed !== "" ? pushed : void 0;
|
|
117
|
+
}
|
|
118
|
+
const sha = deps.env["GITHUB_SHA"];
|
|
119
|
+
return deps.env["GITHUB_EVENT_NAME"] === "push" && sha !== void 0 && sha !== "" ? sha : void 0;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export {
|
|
123
|
+
changeBaseDeps,
|
|
124
|
+
resolveChangeBase,
|
|
125
|
+
resolvePullRequestBase,
|
|
126
|
+
detectHeadSha
|
|
127
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/core/vcs/git.ts
|
|
2
|
+
import path from "path";
|
|
2
3
|
function toPosix(relPath) {
|
|
3
4
|
return relPath.replace(/\\/g, "/");
|
|
4
5
|
}
|
|
@@ -16,11 +17,26 @@ function isOptionLike(ref) {
|
|
|
16
17
|
}
|
|
17
18
|
function toFileList(stdout) {
|
|
18
19
|
if (stdout === null) return null;
|
|
19
|
-
return stdout.split("\
|
|
20
|
+
return stdout.split("\0").filter((file) => file.length > 0);
|
|
21
|
+
}
|
|
22
|
+
async function listDiff(cwd, range) {
|
|
23
|
+
const [stdout, prefix] = await Promise.all([
|
|
24
|
+
git(cwd, ["diff", "--name-only", "-z", "--no-renames", range, "--"]),
|
|
25
|
+
git(cwd, ["rev-parse", "--show-prefix"])
|
|
26
|
+
]);
|
|
27
|
+
const files = toFileList(stdout);
|
|
28
|
+
const cwdFromRoot = prefix?.trim() ?? "";
|
|
29
|
+
if (files === null || cwdFromRoot === "") return files;
|
|
30
|
+
return files.map(
|
|
31
|
+
(file) => path.posix.relative(`/${cwdFromRoot}`, `/${file}`)
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
function blobAt(ref, relPath) {
|
|
35
|
+
return `${ref}:./${toPosix(relPath)}`;
|
|
20
36
|
}
|
|
21
37
|
async function readFileAtRef(cwd, ref, relPath) {
|
|
22
38
|
if (isOptionLike(ref)) return null;
|
|
23
|
-
return git(cwd, ["show",
|
|
39
|
+
return git(cwd, ["show", blobAt(ref, relPath)]);
|
|
24
40
|
}
|
|
25
41
|
var CAT_FILE_BATCH_SIZE = 256;
|
|
26
42
|
async function readFilesAtRef(cwd, ref, relPaths) {
|
|
@@ -34,7 +50,7 @@ async function readFilesAtRef(cwd, ref, relPaths) {
|
|
|
34
50
|
try {
|
|
35
51
|
const result = await execa("git", ["cat-file", "--batch"], {
|
|
36
52
|
cwd,
|
|
37
|
-
input: `${chunk.map((p) =>
|
|
53
|
+
input: `${chunk.map((p) => blobAt(ref, p)).join("\n")}
|
|
38
54
|
`,
|
|
39
55
|
encoding: "buffer",
|
|
40
56
|
// The response framing is byte-exact; execa's default of
|
|
@@ -97,22 +113,99 @@ async function resolveCommit(cwd, ref) {
|
|
|
97
113
|
const sha = stdout?.trim();
|
|
98
114
|
return sha === void 0 || sha === "" ? null : sha;
|
|
99
115
|
}
|
|
116
|
+
async function listRepositoryFiles(cwd, patterns) {
|
|
117
|
+
return toFileList(
|
|
118
|
+
await git(cwd, [
|
|
119
|
+
"ls-files",
|
|
120
|
+
"-z",
|
|
121
|
+
"--cached",
|
|
122
|
+
"--others",
|
|
123
|
+
"--exclude-standard",
|
|
124
|
+
"--",
|
|
125
|
+
...patterns
|
|
126
|
+
])
|
|
127
|
+
);
|
|
128
|
+
}
|
|
100
129
|
async function listChangedFiles(cwd, ref) {
|
|
101
130
|
if (isOptionLike(ref)) return null;
|
|
102
|
-
return
|
|
131
|
+
return listDiff(cwd, ref);
|
|
103
132
|
}
|
|
104
133
|
async function listChangedFilesSinceMergeBase(cwd, ref) {
|
|
105
134
|
if (isOptionLike(ref)) return null;
|
|
135
|
+
return listDiff(cwd, `${ref}...HEAD`);
|
|
136
|
+
}
|
|
137
|
+
async function mergeBase(cwd, a, b) {
|
|
138
|
+
if (isOptionLike(a) || isOptionLike(b)) return null;
|
|
139
|
+
const sha = (await git(cwd, ["merge-base", a, b]))?.trim();
|
|
140
|
+
return sha === void 0 || sha === "" ? null : sha;
|
|
141
|
+
}
|
|
142
|
+
var DEFAULT_BRANCH_GUESSES = [
|
|
143
|
+
"origin/main",
|
|
144
|
+
"origin/master",
|
|
145
|
+
"main",
|
|
146
|
+
"master"
|
|
147
|
+
];
|
|
148
|
+
async function defaultBranchRef(cwd) {
|
|
149
|
+
const head = (await git(cwd, [
|
|
150
|
+
"symbolic-ref",
|
|
151
|
+
"--quiet",
|
|
152
|
+
"--short",
|
|
153
|
+
"refs/remotes/origin/HEAD"
|
|
154
|
+
]))?.trim();
|
|
155
|
+
if (head !== void 0 && head !== "") return head;
|
|
156
|
+
for (const guess of DEFAULT_BRANCH_GUESSES) {
|
|
157
|
+
if (await resolveCommit(cwd, guess) !== null) return guess;
|
|
158
|
+
}
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
async function hasLocalChanges(cwd) {
|
|
162
|
+
const stdout = await git(cwd, ["status", "--porcelain", "-z", "--", "."]);
|
|
163
|
+
return stdout === null ? null : stdout.length > 0;
|
|
164
|
+
}
|
|
165
|
+
async function listUntrackedFiles(cwd) {
|
|
106
166
|
return toFileList(
|
|
107
|
-
await git(cwd, [
|
|
167
|
+
await git(cwd, [
|
|
168
|
+
"ls-files",
|
|
169
|
+
"-z",
|
|
170
|
+
"--others",
|
|
171
|
+
"--exclude-standard",
|
|
172
|
+
"--",
|
|
173
|
+
"."
|
|
174
|
+
])
|
|
108
175
|
);
|
|
109
176
|
}
|
|
177
|
+
async function readZeroContextDiff(cwd, ref, relPath) {
|
|
178
|
+
if (isOptionLike(ref)) return null;
|
|
179
|
+
return git(cwd, [
|
|
180
|
+
"diff",
|
|
181
|
+
"-U0",
|
|
182
|
+
"--no-color",
|
|
183
|
+
"--no-ext-diff",
|
|
184
|
+
"--no-textconv",
|
|
185
|
+
"--no-relative",
|
|
186
|
+
"--no-renames",
|
|
187
|
+
ref,
|
|
188
|
+
"--",
|
|
189
|
+
toPosix(relPath)
|
|
190
|
+
]);
|
|
191
|
+
}
|
|
192
|
+
async function repositoryRoot(cwd) {
|
|
193
|
+
const top = (await git(cwd, ["rev-parse", "--show-toplevel"]))?.trim();
|
|
194
|
+
return top === void 0 || top === "" ? null : top;
|
|
195
|
+
}
|
|
110
196
|
|
|
111
197
|
export {
|
|
112
198
|
readFileAtRef,
|
|
113
199
|
readFilesAtRef,
|
|
114
200
|
readHeadSha,
|
|
115
201
|
resolveCommit,
|
|
202
|
+
listRepositoryFiles,
|
|
116
203
|
listChangedFiles,
|
|
117
|
-
listChangedFilesSinceMergeBase
|
|
204
|
+
listChangedFilesSinceMergeBase,
|
|
205
|
+
mergeBase,
|
|
206
|
+
defaultBranchRef,
|
|
207
|
+
hasLocalChanges,
|
|
208
|
+
listUntrackedFiles,
|
|
209
|
+
readZeroContextDiff,
|
|
210
|
+
repositoryRoot
|
|
118
211
|
};
|
|
@@ -4,30 +4,37 @@ import {
|
|
|
4
4
|
readCache,
|
|
5
5
|
writeCache,
|
|
6
6
|
writeCacheSync
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import {
|
|
9
|
-
renderInsights
|
|
10
|
-
} from "./chunk-QRPI6TJE.js";
|
|
7
|
+
} from "./chunk-2UVLKBLV.js";
|
|
11
8
|
import {
|
|
12
9
|
recordCacheMiss,
|
|
10
|
+
renderInsights,
|
|
13
11
|
runScheduled
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import {
|
|
16
|
-
getColors
|
|
17
|
-
} from "./chunk-YYGCSKIQ.js";
|
|
12
|
+
} from "./chunk-EFCMBBBT.js";
|
|
18
13
|
import {
|
|
19
14
|
mapLimit
|
|
20
15
|
} from "./chunk-GDSZFIHM.js";
|
|
16
|
+
import {
|
|
17
|
+
CLEAR_LINE,
|
|
18
|
+
HIDE_CURSOR,
|
|
19
|
+
SHOW_CURSOR,
|
|
20
|
+
SYNC_END,
|
|
21
|
+
SYNC_START,
|
|
22
|
+
cursorUp,
|
|
23
|
+
fitWidth
|
|
24
|
+
} from "./chunk-IHXJ72XA.js";
|
|
21
25
|
import {
|
|
22
26
|
lines
|
|
23
27
|
} from "./chunk-6J4XDG44.js";
|
|
28
|
+
import {
|
|
29
|
+
getColors
|
|
30
|
+
} from "./chunk-YYGCSKIQ.js";
|
|
24
31
|
import {
|
|
25
32
|
getPrinter
|
|
26
33
|
} from "./chunk-EISTWXDW.js";
|
|
27
34
|
import {
|
|
28
35
|
TaskExecutionError,
|
|
29
36
|
VariantError
|
|
30
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-C3NZIFW6.js";
|
|
31
38
|
|
|
32
39
|
// src/core/execution/runner.ts
|
|
33
40
|
import { createHash as createHash2 } from "crypto";
|
|
@@ -283,28 +290,6 @@ async function runTasksWithDeps(target, graph, options, executor = executeTask)
|
|
|
283
290
|
return results;
|
|
284
291
|
}
|
|
285
292
|
|
|
286
|
-
// src/cli/visuals/ansi.ts
|
|
287
|
-
var ESC = "\x1B";
|
|
288
|
-
var HIDE_CURSOR = `${ESC}[?25l`;
|
|
289
|
-
var SHOW_CURSOR = `${ESC}[?25h`;
|
|
290
|
-
var CLEAR_LINE = `${ESC}[2K`;
|
|
291
|
-
var SYNC_START = `${ESC}[?2026h`;
|
|
292
|
-
var SYNC_END = `${ESC}[?2026l`;
|
|
293
|
-
function cursorUp(lines2) {
|
|
294
|
-
return lines2 > 0 ? `${ESC}[${lines2}A` : "";
|
|
295
|
-
}
|
|
296
|
-
var STYLE_PATTERN = new RegExp(`${ESC}\\[[0-9;]*m`, "g");
|
|
297
|
-
function stripStyles(text) {
|
|
298
|
-
return text.replace(STYLE_PATTERN, "");
|
|
299
|
-
}
|
|
300
|
-
function visibleLength(line) {
|
|
301
|
-
return stripStyles(line).length;
|
|
302
|
-
}
|
|
303
|
-
function fitWidth(line, columns) {
|
|
304
|
-
if (visibleLength(line) <= columns) return line;
|
|
305
|
-
return stripStyles(line).slice(0, Math.max(0, columns - 1));
|
|
306
|
-
}
|
|
307
|
-
|
|
308
293
|
// src/cli/visuals/progress.ts
|
|
309
294
|
var SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
310
295
|
var TICK_MS = 80;
|