package page→ /base/checks.html
pages/base/checks.html
86 lines, 4.9 KB. Open as is (in a project other files lie next to it; they may be missing here).
- <!--
- ---
- type: Lens
- title: "Project checks"
- icon: "✅"
- description: "All checks that the packages brought, with the norm that each one enforces; and the norms that no check enforces."
- template: custom
- lensType: report
- render: live
- sources: [".shtukbase/packages.lock", ".shtukbase/packages/*/package.md"]
- generator: "shtuk run lenses build"
- ---
- A service lens of the `lenses` package. A check is a package action marked `check: true`; `shtuk check` runs them all.
- The data is the same as in the "Project packages" lens: `lib/base/packages.data.js`, built by `shtuk run lenses build`.
- On top are the checks by package: the name, what it checks, the norm and its strictness, the command to run it. Below are the package norms
- that no check refers to. This is not necessarily a mistake: a principle or a default is often enforced by something other than a program.
- Clicking a norm opens its record.
- -->
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>Project checks</title>
- <link rel="stylesheet" href="../lib/kit.css">
- <script src="../lib/data.js"></script>
- <script src="../lib/base/packages.data.js"></script>
- <script src="../lib/kit.js"></script>
- <style>
- .pc { max-width: 1100px; padding: 32px 48px 80px; display: flex; flex-direction: column; gap: 28px; color: var(--ink); }
- .pc h2 { margin: 0 0 4px; font-size: 22px; }
- .pc > section > p { margin: 0 0 12px; font-size: 14px; opacity: .65; }
- .pc table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
- .pc th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; opacity: .6; font-weight: 600; padding: 6px 10px; border-bottom: 1px solid var(--line); }
- .pc td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; line-height: 1.35; }
- .pc td.pkg { font-family: ui-monospace, monospace; font-size: 12.5px; white-space: nowrap; }
- .pc code { font-size: 12px; }
- .pc .norm { cursor: pointer; }
- .pc .norm:hover { text-decoration: underline; }
- .pc .norm em, .pc .muted { font-style: normal; opacity: .6; font-size: 12px; }
- .pc .warn { color: var(--c-red); }
- </style>
- <script>
- (function () {
- const { h } = Lens;
- Lens.templates.custom = function (cfg) {
- const ui = Lens.page(cfg);
- const D = window.SHTUK_PACKAGES;
- if (!D) {
- ui.main.append(h("div", { class: "pc" }, h("p", {}, "There is no package data. Build it from the project root: shtuk run lenses build")));
- return;
- }
- const norms = {};
- for (const p of D.packages) for (const n of p.norms) norms[n.path] = Object.assign({ pkg: p.id }, n);
- const open = (path) => () => { if (Lens.rec(path)) Lens.open(path); };
- const mode = (n) => (n.mode === "enforce" ? "blocks" : n.mode === "observe" ? "observes" : "");
- const normCell = (path) => {
- if (!path) return h("span", { class: "muted" }, "no norm named");
- const n = norms[path];
- if (!n) return h("span", { class: "warn", title: path }, "no such norm: " + path);
- return h("div", { class: "norm", onclick: open(path), title: path }, n.id + " — " + n.title, " ",
- h("em", {}, [n.level, n.floor ? "floor" : "", mode(n)].filter(Boolean).join(" · ")));
- };
- const rows = D.packages.flatMap((p) => p.actions.filter((a) => a.check).map((a) => h("tr", {},
- h("td", { class: "pkg" }, p.id), h("td", {}, h("code", {}, a.name)), h("td", {}, a.title || a.run),
- h("td", {}, normCell(a.norm)), h("td", {}, h("code", {}, "shtuk run " + p.id + " " + a.name)))));
- const held = new Set(D.packages.flatMap((p) => p.actions.filter((a) => a.check && a.norm).map((a) => a.norm)));
- const loose = Object.values(norms).filter((n) => !held.has(n.path));
- ui.main.append(h("div", { class: "pc" },
- h("section", {}, h("h2", {}, "Checks · " + rows.length),
- h("p", {}, "shtuk check runs them all; one of them by the command in the last column. Code 0 means the norm is kept, 1 means it is broken."),
- rows.length ? h("table", {}, h("tr", {}, ["Package", "Check", "What it checks", "Norm", "Run"].map((t) => h("th", {}, t))), rows)
- : h("p", {}, "The project has no checks.")),
- h("section", {}, h("h2", {}, "Norms without a check · " + loose.length),
- h("p", {}, "No check refers to these package norms. Their enforcer may be another one: a gate, a hook or a person."),
- loose.length ? h("table", {}, h("tr", {}, ["Package", "Norm", "Enforcers"].map((t) => h("th", {}, t))),
- loose.map((n) => h("tr", {}, h("td", { class: "pkg" }, n.pkg), h("td", {}, normCell(n.path)),
- h("td", {}, n.enforcers.length ? n.enforcers.map((e) => h("div", {}, h("code", {}, e))) : h("span", { class: "muted" }, "none")))))
- : h("p", {}, "There are no such norms."))));
- };
- })();
- </script>
- </head>
- <body><p class="lx-missing">The lens "Project checks". There is no data yet: build it with the command <code>shtuk run lenses build</code> in the project root.</p></body>
- </html>