@antelopejs/tooling-configs 0.2.17 → 0.2.18
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 +27 -18
- package/dist/bin/api-diff.mjs +25 -14
- package/dist/bin/body-check.mjs +3 -3
- package/dist/bin/capture.d.mts +1 -0
- package/dist/bin/capture.mjs +559 -0
- package/dist/bin/check-size.mjs +3 -3
- package/dist/bin/checks.mjs +2 -2
- package/dist/bin/comment-proof.mjs +3 -3
- package/dist/bin/garden.mjs +1 -1
- package/dist/bin/ratchet.mjs +146 -100
- package/dist/bin/suppressions.mjs +5 -5
- package/dist/bin/sync.mjs +115 -169
- package/dist/bin/verify.mjs +238 -125
- package/dist/capture/index.d.mts +50 -0
- package/dist/capture/index.mjs +2 -0
- package/dist/{files-Bc036sJW.mjs → files-DJ0TeaTU.mjs} +10 -4
- package/dist/formal/index.d.mts +40 -0
- package/dist/formal/index.mjs +205 -0
- package/dist/oxc/anti-slop/index.mjs +717 -16
- package/dist/oxc/fmt.mjs +1 -1
- package/dist/oxc/guardrails/index.d.mts +1 -1
- package/dist/oxc/guardrails/index.mjs +93 -5
- package/dist/oxc/lint.d.mts +9 -0
- package/dist/oxc/lint.mjs +14 -3
- package/dist/{oxlint-Bltmk8-6.mjs → oxlint-DIV-lLSS.mjs} +7 -3
- package/dist/{package-DTxLPNDu.mjs → package-BRTjkzt5.mjs} +26 -1
- package/dist/{proof-stamp-w-3j47A-.mjs → proof-stamp-DDDC0J6l.mjs} +3 -3
- package/dist/{ratchet-DwRj9h4L.mjs → ratchet-BAcLRYuM.mjs} +194 -21
- package/dist/scenes-DZVXkcxS.mjs +104 -0
- package/dist/shared-igPpEDpS.mjs +622 -0
- package/dist/{size-DNtWruCO.mjs → size-DBatLT-F.mjs} +2 -2
- package/dist/{suppression-base-DAfCXwjL.mjs → suppression-base-9L8dlMQK.mjs} +36 -11
- package/dist/{suppression-budget-Bd2GqMYb.mjs → suppression-budget-C0SkPO5R.mjs} +56 -19
- package/dist/{suppressions-BD_f8f7L.mjs → suppressions-DM60NkvL.mjs} +1 -1
- package/dist/templates-CypDm-j9.mjs +121 -0
- package/dist/{typescript-BmS5BmrS.mjs → typescript-CM0LrVP7.mjs} +2 -2
- package/dist/verify/index.d.mts +6 -1
- package/package.json +28 -4
- package/dist/shared-CoUt4GUm.mjs +0 -73
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { i as isObject, l as optNum, n as children, o as list, u as optStr } from "./json-CG2L7YFl.mjs";
|
|
2
|
+
//#region src/capture/scenes.ts
|
|
3
|
+
const KEBAB_CASE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
4
|
+
const GUIDE_VIEWPORT = {
|
|
5
|
+
width: 1440,
|
|
6
|
+
height: 900
|
|
7
|
+
};
|
|
8
|
+
/** Types the `docs/captures.ts` default export: `export default defineScenes([...])`. */
|
|
9
|
+
function defineScenes(scenes) {
|
|
10
|
+
return scenes;
|
|
11
|
+
}
|
|
12
|
+
function required(value, message) {
|
|
13
|
+
if (value === void 0 || value === "") throw new Error(message);
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
function parseStep(step, index) {
|
|
17
|
+
const label = `step ${index + 1}`;
|
|
18
|
+
const action = optStr(step, "action");
|
|
19
|
+
if (action === "press") return {
|
|
20
|
+
action,
|
|
21
|
+
key: required(optStr(step, "key"), `${label} needs a key`)
|
|
22
|
+
};
|
|
23
|
+
if (action !== "click" && action !== "fill" && action !== "wait") throw new Error(`${label} has an unknown action ${JSON.stringify(action)}`);
|
|
24
|
+
const selector = required(optStr(step, "selector"), `${label} needs a selector`);
|
|
25
|
+
if (action !== "fill") return {
|
|
26
|
+
action,
|
|
27
|
+
selector
|
|
28
|
+
};
|
|
29
|
+
const value = optStr(step, "value");
|
|
30
|
+
if (value === void 0) throw new Error(`${label} needs a value`);
|
|
31
|
+
return {
|
|
32
|
+
action,
|
|
33
|
+
selector,
|
|
34
|
+
value
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function parseViewport(source) {
|
|
38
|
+
if (!Object.hasOwn(source, "viewport")) return GUIDE_VIEWPORT;
|
|
39
|
+
const { viewport } = source;
|
|
40
|
+
const [width, height] = isObject(viewport) ? [optNum(viewport, "width"), optNum(viewport, "height")] : [void 0, void 0];
|
|
41
|
+
if (width === void 0 || height === void 0 || !Number.isInteger(width) || !Number.isInteger(height) || width <= 0 || height <= 0) throw new Error("viewport needs a positive width and height");
|
|
42
|
+
return {
|
|
43
|
+
width,
|
|
44
|
+
height
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function parseOutput(source, setup) {
|
|
48
|
+
const output = optStr(source, "output");
|
|
49
|
+
if (setup) {
|
|
50
|
+
if (Object.hasOwn(source, "output")) throw new Error("a setup scene takes no output");
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (output === void 0 || output === "") throw new Error("a screenshot scene needs an output");
|
|
54
|
+
if (!output.endsWith(".webp")) throw new Error("output must be a .webp path");
|
|
55
|
+
if (output.startsWith("/") || output.split("/").includes("..")) throw new Error("output must stay inside the repository");
|
|
56
|
+
return output;
|
|
57
|
+
}
|
|
58
|
+
function parseScene(entry, position) {
|
|
59
|
+
if (!isObject(entry)) throw new Error(`scene ${position} is not an object`);
|
|
60
|
+
const id = optStr(entry, "id");
|
|
61
|
+
if (id === void 0 || !KEBAB_CASE.test(id)) throw new Error(`scene id ${JSON.stringify(id)} is not kebab-case`);
|
|
62
|
+
try {
|
|
63
|
+
const route = optStr(entry, "route");
|
|
64
|
+
if (route === void 0 || !route.startsWith("/")) throw new Error("route must start with \"/\"");
|
|
65
|
+
const setup = entry.setup === true;
|
|
66
|
+
const scene = {
|
|
67
|
+
id,
|
|
68
|
+
route,
|
|
69
|
+
viewport: parseViewport(entry),
|
|
70
|
+
steps: Object.hasOwn(entry, "steps") ? children(entry, "steps").map(parseStep) : [],
|
|
71
|
+
setup
|
|
72
|
+
};
|
|
73
|
+
const crop = optStr(entry, "crop");
|
|
74
|
+
if (crop !== void 0 && crop !== "") scene.crop = crop;
|
|
75
|
+
const output = parseOutput(entry, setup);
|
|
76
|
+
if (output !== void 0) scene.output = output;
|
|
77
|
+
return scene;
|
|
78
|
+
} catch (error) {
|
|
79
|
+
throw new Error(`scene ${JSON.stringify(id)}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/** Validates what `docs/captures.ts` exports, so a mistyped scene fails with its id and field. */
|
|
83
|
+
function parseScenes(raw) {
|
|
84
|
+
if (!Array.isArray(raw)) throw new Error("docs/captures.ts must export an array of scenes");
|
|
85
|
+
const scenes = list(raw, "scenes").map((entry, index) => parseScene(entry, index + 1));
|
|
86
|
+
const ids = /* @__PURE__ */ new Map();
|
|
87
|
+
const outputs = /* @__PURE__ */ new Map();
|
|
88
|
+
for (const scene of scenes) {
|
|
89
|
+
if (ids.has(scene.id)) throw new Error(`scene id ${JSON.stringify(scene.id)} appears twice`);
|
|
90
|
+
ids.set(scene.id, scene);
|
|
91
|
+
if (scene.output === void 0) continue;
|
|
92
|
+
const other = outputs.get(scene.output);
|
|
93
|
+
if (other) throw new Error(`scenes ${JSON.stringify(other.id)} and ${JSON.stringify(scene.id)} both write ${scene.output}`);
|
|
94
|
+
outputs.set(scene.output, scene);
|
|
95
|
+
}
|
|
96
|
+
return scenes;
|
|
97
|
+
}
|
|
98
|
+
/** The scenes a run executes: every setup scene first, then the screenshot scene asked for, or all of them. */
|
|
99
|
+
function selectScenes(scenes, id) {
|
|
100
|
+
if (id !== void 0 && !scenes.some((scene) => scene.id === id)) throw new Error(`no scene ${JSON.stringify(id)}; the scenes are ${scenes.map((scene) => scene.id).sort().join(", ")}`);
|
|
101
|
+
return [...scenes.filter((scene) => scene.setup), ...scenes.filter((scene) => !scene.setup && (id === void 0 || scene.id === id))];
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
export { parseScenes as n, selectScenes as r, defineScenes as t };
|