@quikit/quikpilot-runner 9.3.0-rc.4 → 9.3.0-rc.5
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/index.js +47 -21
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2505,29 +2505,60 @@ function onlyImports(text) {
|
|
|
2505
2505
|
const lines = text.split("\n").filter((l) => l.trim().length > 0);
|
|
2506
2506
|
return lines.length > 0 && lines.every((l) => IMPORT_LINE.test(l));
|
|
2507
2507
|
}
|
|
2508
|
-
function
|
|
2509
|
-
|
|
2510
|
-
}
|
|
2511
|
-
function placementOk(find, k, added) {
|
|
2512
|
-
if (added === "") return true;
|
|
2508
|
+
function placementWhy(find, k, added) {
|
|
2509
|
+
if (added === "") return null;
|
|
2513
2510
|
const wholeLines = k === 0 ? added.endsWith("\n") : k === find.length ? find.endsWith("\n") || added.startsWith("\n") : find[k - 1] === "\n" && added.endsWith("\n");
|
|
2514
|
-
|
|
2511
|
+
if (!wholeLines) return "inside_a_line";
|
|
2512
|
+
if (onlyImports(added)) return null;
|
|
2513
|
+
if (!DECLARES_TEST.test(added)) return "not_a_test_or_import";
|
|
2514
|
+
return bracketsBalance(added) ? null : "unbalanced_block";
|
|
2515
|
+
}
|
|
2516
|
+
function isSubsequence(part, whole2) {
|
|
2517
|
+
let i2 = 0;
|
|
2518
|
+
for (let j = 0; j < whole2.length && i2 < part.length; j++) if (whole2.charCodeAt(j) === part.charCodeAt(i2)) i2++;
|
|
2519
|
+
return i2 === part.length;
|
|
2520
|
+
}
|
|
2521
|
+
function lostTextWhy(find, replace) {
|
|
2522
|
+
return replace.length < find.length && isSubsequence(replace, find) ? "removed_text" : "changed_text";
|
|
2515
2523
|
}
|
|
2516
2524
|
function strictEndsRule(find, replace) {
|
|
2517
2525
|
return replace.startsWith(find) || replace.endsWith(find);
|
|
2518
2526
|
}
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2527
|
+
var LEAD = {
|
|
2528
|
+
removed_text: "Your edit removes text that is already in the test file.",
|
|
2529
|
+
changed_text: "Your edit changes text that is already in the test file.",
|
|
2530
|
+
inside_a_line: "Your edit puts new text inside an existing line.",
|
|
2531
|
+
several_places: "Your new text is spread over more than one place: send one block.",
|
|
2532
|
+
not_a_test_or_import: "Your new lines are not a new test (it, test or describe) or import lines.",
|
|
2533
|
+
unbalanced_block: "Your new test is not self-contained: its brackets do not balance."
|
|
2534
|
+
};
|
|
2535
|
+
var GUIDANCE = "An existing test can only be added to: keep every character you matched, in order, and add only whole new lines (a new test or import lines), before the text, after it, or between its lines. To add a test to a block, match the last lines of that block and put the new test after them. To use a name the file does not import yet, do not change its import line: add a new import line after the last one.";
|
|
2536
|
+
function protectedMessage(why) {
|
|
2537
|
+
return `${LEAD[why]} ${GUIDANCE}`;
|
|
2538
|
+
}
|
|
2539
|
+
var OK = { ok: true };
|
|
2540
|
+
function addOnlyVerdict(path, find, replace) {
|
|
2541
|
+
if (replace === find) return OK;
|
|
2542
|
+
if (!usesLooseRule(path)) {
|
|
2543
|
+
if (strictEndsRule(find, replace)) return OK;
|
|
2544
|
+
return { ok: false, why: lostTextWhy(find, replace) };
|
|
2545
|
+
}
|
|
2546
|
+
if (replace.length <= find.length || !isSubsequence(find, replace)) {
|
|
2547
|
+
return { ok: false, why: lostTextWhy(find, replace) };
|
|
2548
|
+
}
|
|
2523
2549
|
const addedLength = replace.length - find.length;
|
|
2524
2550
|
let common = 0;
|
|
2525
2551
|
while (common < find.length && find.charCodeAt(common) === replace.charCodeAt(common)) common++;
|
|
2552
|
+
let contentWhy = null;
|
|
2553
|
+
let placementOnlyWhy = null;
|
|
2526
2554
|
for (let k = common; k >= 0; k--) {
|
|
2527
2555
|
if (!replace.endsWith(find.slice(k))) continue;
|
|
2528
|
-
|
|
2556
|
+
const why = placementWhy(find, k, replace.slice(k, k + addedLength));
|
|
2557
|
+
if (why === null) return OK;
|
|
2558
|
+
if (why === "inside_a_line") placementOnlyWhy ??= why;
|
|
2559
|
+
else contentWhy ??= why;
|
|
2529
2560
|
}
|
|
2530
|
-
return false;
|
|
2561
|
+
return { ok: false, why: contentWhy ?? placementOnlyWhy ?? "several_places" };
|
|
2531
2562
|
}
|
|
2532
2563
|
|
|
2533
2564
|
// ../../node_modules/acorn/dist/acorn.mjs
|
|
@@ -11309,14 +11340,9 @@ function createCodegenWorkspace(args) {
|
|
|
11309
11340
|
lf = loaded.lf;
|
|
11310
11341
|
base = { ending: loaded.ending, bom: loaded.bom, originalLf: loaded.lf };
|
|
11311
11342
|
}
|
|
11312
|
-
|
|
11313
|
-
|
|
11314
|
-
|
|
11315
|
-
status: "protected",
|
|
11316
|
-
reason: "existing_test",
|
|
11317
|
-
message: "An existing test can only be added to. Keep every character of the text you matched, in the same order, and add only whole new lines that declare a new test (it, test or describe), before the text, after it, or between two of its lines. To add a test to a block, match the last lines of that block and put the new test after them. To use a name the file does not import yet, do not change its import line: add a new import line after the last one."
|
|
11318
|
-
}
|
|
11319
|
-
};
|
|
11343
|
+
const verdict = protectedTests.has(path) ? addOnlyVerdict(path, find, replace) : null;
|
|
11344
|
+
if (verdict && !verdict.ok) {
|
|
11345
|
+
return { result: { status: "protected", reason: verdict.why, message: protectedMessage(verdict.why) } };
|
|
11320
11346
|
}
|
|
11321
11347
|
const applied = applyEdits(lf, [{ find, replace }]);
|
|
11322
11348
|
if (!applied.ok) {
|
|
@@ -13363,7 +13389,7 @@ var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
|
|
|
13363
13389
|
var REPORT_COPY = "final-test-report.xml";
|
|
13364
13390
|
var MAX_REPORT_BYTES = 5 * 1024 * 1024;
|
|
13365
13391
|
var MAX_FILES = 200;
|
|
13366
|
-
var RUNNER_VERSION = true ? "9.3.0-rc.
|
|
13392
|
+
var RUNNER_VERSION = true ? "9.3.0-rc.5" : "dev";
|
|
13367
13393
|
function safeDestination(base, repoPath) {
|
|
13368
13394
|
if (!repoPath || (0, import_node_path12.isAbsolute)(repoPath)) return null;
|
|
13369
13395
|
const destination = (0, import_node_path12.resolve)(base, repoPath);
|