@staff0rd/assist 0.934.0 → 0.934.2
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/commands/sessions/web/bundle.js +292 -292
- package/dist/index.js +76 -30
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@staff0rd/assist",
|
|
9
|
-
version: "0.934.
|
|
9
|
+
version: "0.934.2",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -34043,10 +34043,10 @@ function getViolations(pattern2, options2 = {}, maxLines = DEFAULT_MAX_LINES2) {
|
|
|
34043
34043
|
}
|
|
34044
34044
|
const violations = [];
|
|
34045
34045
|
for (const filePath of sourceFiles) {
|
|
34046
|
-
const
|
|
34046
|
+
const lineCount2 = countLines(filePath);
|
|
34047
34047
|
const maxAllowed = ignoredFiles.get(filePath) ?? maxLines;
|
|
34048
|
-
if (
|
|
34049
|
-
violations.push({ file: filePath, lines:
|
|
34048
|
+
if (lineCount2 > maxAllowed) {
|
|
34049
|
+
violations.push({ file: filePath, lines: lineCount2 });
|
|
34050
34050
|
}
|
|
34051
34051
|
}
|
|
34052
34052
|
return violations;
|
|
@@ -34901,8 +34901,8 @@ function ignore2(file) {
|
|
|
34901
34901
|
process.exit(1);
|
|
34902
34902
|
}
|
|
34903
34903
|
const content = fs32.readFileSync(file, "utf8");
|
|
34904
|
-
const
|
|
34905
|
-
const maxLines =
|
|
34904
|
+
const lineCount2 = content.split("\n").length;
|
|
34905
|
+
const maxLines = lineCount2 + 10;
|
|
34906
34906
|
const entry = `- file: ${file}
|
|
34907
34907
|
maxLines: ${maxLines}
|
|
34908
34908
|
`;
|
|
@@ -36563,33 +36563,73 @@ function capHighLevelPatches(files, criticalPaths) {
|
|
|
36563
36563
|
return files.map((file) => byPath.get(file.path) ?? file);
|
|
36564
36564
|
}
|
|
36565
36565
|
|
|
36566
|
-
// src/commands/review/highLevel/
|
|
36566
|
+
// src/commands/review/highLevel/testChangeExcerpts.ts
|
|
36567
|
+
var CONTEXT_LINES = 3;
|
|
36568
|
+
function testChangeExcerpts(source, line, changedLines2) {
|
|
36569
|
+
const lines2 = source.split("\n");
|
|
36570
|
+
const windows = [];
|
|
36571
|
+
for (const changed of [...changedLines2].sort((a, b) => a - b)) {
|
|
36572
|
+
const start2 = Math.max(0, changed - line - CONTEXT_LINES);
|
|
36573
|
+
const end = Math.min(lines2.length - 1, changed - line + CONTEXT_LINES);
|
|
36574
|
+
const last = windows.at(-1);
|
|
36575
|
+
if (last && start2 <= last.end + 1) last.end = Math.max(last.end, end);
|
|
36576
|
+
else windows.push({ start: start2, end });
|
|
36577
|
+
}
|
|
36578
|
+
return windows.map(({ start: start2, end }) => ({
|
|
36579
|
+
line: line + start2,
|
|
36580
|
+
source: lines2.slice(start2, end + 1).join("\n")
|
|
36581
|
+
}));
|
|
36582
|
+
}
|
|
36583
|
+
|
|
36584
|
+
// src/commands/review/highLevel/shownForm.ts
|
|
36567
36585
|
var MAX_TEST_SOURCE_LINES = 200;
|
|
36586
|
+
function shownForm(test) {
|
|
36587
|
+
const { source, changedLines: changedLines2, ...rest } = test;
|
|
36588
|
+
if (source === void 0) return void 0;
|
|
36589
|
+
const lines2 = lineCount(source);
|
|
36590
|
+
if (lines2 <= MAX_TEST_SOURCE_LINES)
|
|
36591
|
+
return { lines: lines2, shown: { ...rest, source } };
|
|
36592
|
+
if (!changedLines2) return void 0;
|
|
36593
|
+
const excerpts = testChangeExcerpts(source, test.line, changedLines2);
|
|
36594
|
+
const excerptLines = excerpts.reduce(
|
|
36595
|
+
(sum3, excerpt2) => sum3 + lineCount(excerpt2.source),
|
|
36596
|
+
0
|
|
36597
|
+
);
|
|
36598
|
+
return excerptLines <= MAX_TEST_SOURCE_LINES ? { lines: excerptLines, shown: { ...rest, excerpts } } : void 0;
|
|
36599
|
+
}
|
|
36600
|
+
function lineCount(text17) {
|
|
36601
|
+
return text17.split("\n").length;
|
|
36602
|
+
}
|
|
36603
|
+
|
|
36604
|
+
// src/commands/review/highLevel/capHighLevelTestSources.ts
|
|
36568
36605
|
var MAX_TOTAL_SOURCE_LINES = 5e3;
|
|
36569
36606
|
function collectCases(nodes) {
|
|
36570
36607
|
return nodes.flatMap(
|
|
36571
36608
|
(node) => node.kind === "it" ? [node] : collectCases(node.children)
|
|
36572
36609
|
);
|
|
36573
36610
|
}
|
|
36574
|
-
function
|
|
36575
|
-
const sized = files.flatMap((file) => collectCases(file.tests)).flatMap(
|
|
36576
|
-
|
|
36577
|
-
|
|
36578
|
-
|
|
36611
|
+
function shippedForms(files) {
|
|
36612
|
+
const sized = files.flatMap((file) => collectCases(file.tests)).flatMap((test) => {
|
|
36613
|
+
const form = shownForm(test);
|
|
36614
|
+
return form ? [{ test, form }] : [];
|
|
36615
|
+
}).sort((a, b) => a.form.lines - b.form.lines);
|
|
36616
|
+
const shipped = /* @__PURE__ */ new Map();
|
|
36579
36617
|
let remaining = MAX_TOTAL_SOURCE_LINES;
|
|
36580
|
-
for (const { test,
|
|
36581
|
-
if (
|
|
36582
|
-
remaining -=
|
|
36583
|
-
shipped.
|
|
36618
|
+
for (const { test, form } of sized) {
|
|
36619
|
+
if (form.lines > remaining) break;
|
|
36620
|
+
remaining -= form.lines;
|
|
36621
|
+
shipped.set(test, form);
|
|
36584
36622
|
}
|
|
36585
36623
|
return shipped;
|
|
36586
36624
|
}
|
|
36587
36625
|
function capHighLevelTestSources(files) {
|
|
36588
|
-
const shipped =
|
|
36626
|
+
const shipped = shippedForms(files);
|
|
36589
36627
|
const capCase = (test) => {
|
|
36590
|
-
|
|
36591
|
-
|
|
36592
|
-
|
|
36628
|
+
const form = shipped.get(test);
|
|
36629
|
+
if (form) return form.shown;
|
|
36630
|
+
const { source, changedLines: _changedLines, ...rest } = test;
|
|
36631
|
+
if (source === void 0) return rest;
|
|
36632
|
+
return shownForm(test) ? { ...rest, overBudget: true } : { ...rest, truncated: true };
|
|
36593
36633
|
};
|
|
36594
36634
|
const capNode = (node) => node.kind === "it" ? capCase(node) : { ...node, children: node.children.map(capNode) };
|
|
36595
36635
|
return files.map((file) => ({ ...file, tests: file.tests.map(capNode) }));
|
|
@@ -36645,28 +36685,34 @@ function dedentedSource(call) {
|
|
|
36645
36685
|
|
|
36646
36686
|
// src/commands/review/highLevel/visitCase.ts
|
|
36647
36687
|
function visitCase(call, context) {
|
|
36648
|
-
if (!context.changed) return [toCase(call, context
|
|
36649
|
-
const
|
|
36650
|
-
if (
|
|
36651
|
-
const
|
|
36652
|
-
return [
|
|
36688
|
+
if (!context.changed) return [toCase(call, context)];
|
|
36689
|
+
const lines2 = changedLines(call, context.changed);
|
|
36690
|
+
if (lines2.length === 0) return [];
|
|
36691
|
+
const total2 = call.getEndLineNumber() - call.getStartLineNumber() + 1;
|
|
36692
|
+
return [
|
|
36693
|
+
toCase(
|
|
36694
|
+
call,
|
|
36695
|
+
context,
|
|
36696
|
+
lines2.length === total2 ? { change: "added" } : { change: "modified", changedLines: lines2 }
|
|
36697
|
+
)
|
|
36698
|
+
];
|
|
36653
36699
|
}
|
|
36654
|
-
function toCase(call, context, change) {
|
|
36700
|
+
function toCase(call, context, change = {}) {
|
|
36655
36701
|
const line = call.getStartLineNumber();
|
|
36656
36702
|
return {
|
|
36657
36703
|
kind: "it",
|
|
36658
36704
|
id: `${context.path}:${line}`,
|
|
36659
36705
|
name: testName(call),
|
|
36660
36706
|
line,
|
|
36661
|
-
...change
|
|
36707
|
+
...change,
|
|
36662
36708
|
source: dedentedSource(call)
|
|
36663
36709
|
};
|
|
36664
36710
|
}
|
|
36665
36711
|
function changedLines(call, changed) {
|
|
36666
|
-
|
|
36712
|
+
const lines2 = [];
|
|
36667
36713
|
for (let line = call.getStartLineNumber(); line <= call.getEndLineNumber(); line++)
|
|
36668
|
-
if (changed.has(line))
|
|
36669
|
-
return
|
|
36714
|
+
if (changed.has(line)) lines2.push(line);
|
|
36715
|
+
return lines2;
|
|
36670
36716
|
}
|
|
36671
36717
|
|
|
36672
36718
|
// src/commands/review/highLevel/extractTestHierarchy.ts
|