ShtukbaseStandard
página del paquete→ /base/checks.html

pages/base/checks.html

86 líneas, 4.9 KB. Abrir tal cual (en un proyecto hay otros archivos a su lado; aquí pueden faltar).

El archivo tal como está en el paquete: el código y sus comentarios no se traducen.

  1. <!--
  2. ---
  3. type: Lens
  4. title: "Project checks"
  5. icon: "✅"
  6. description: "All checks that the packages brought, with the norm that each one enforces; and the norms that no check enforces."
  7. template: custom
  8. lensType: report
  9. render: live
  10. sources: [".shtukbase/packages.lock", ".shtukbase/packages/*/package.md"]
  11. generator: "shtuk run lenses build"
  12. ---
  13. A service lens of the `lenses` package. A check is a package action marked `check: true`; `shtuk check` runs them all.
  14. The data is the same as in the "Project packages" lens: `lib/base/packages.data.js`, built by `shtuk run lenses build`.
  15. 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
  16. 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.
  17. Clicking a norm opens its record.
  18. -->
  19. <!doctype html>
  20. <html lang="en">
  21. <head>
  22. <meta charset="utf-8">
  23. <meta name="viewport" content="width=device-width, initial-scale=1">
  24. <title>Project checks</title>
  25. <link rel="stylesheet" href="../lib/kit.css">
  26. <script src="../lib/data.js"></script>
  27. <script src="../lib/base/packages.data.js"></script>
  28. <script src="../lib/kit.js"></script>
  29. <style>
  30. .pc { max-width: 1100px; padding: 32px 48px 80px; display: flex; flex-direction: column; gap: 28px; color: var(--ink); }
  31. .pc h2 { margin: 0 0 4px; font-size: 22px; }
  32. .pc > section > p { margin: 0 0 12px; font-size: 14px; opacity: .65; }
  33. .pc table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
  34. .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); }
  35. .pc td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; line-height: 1.35; }
  36. .pc td.pkg { font-family: ui-monospace, monospace; font-size: 12.5px; white-space: nowrap; }
  37. .pc code { font-size: 12px; }
  38. .pc .norm { cursor: pointer; }
  39. .pc .norm:hover { text-decoration: underline; }
  40. .pc .norm em, .pc .muted { font-style: normal; opacity: .6; font-size: 12px; }
  41. .pc .warn { color: var(--c-red); }
  42. </style>
  43. <script>
  44. (function () {
  45. const { h } = Lens;
  46. Lens.templates.custom = function (cfg) {
  47. const ui = Lens.page(cfg);
  48. const D = window.SHTUK_PACKAGES;
  49. if (!D) {
  50. ui.main.append(h("div", { class: "pc" }, h("p", {}, "There is no package data. Build it from the project root: shtuk run lenses build")));
  51. return;
  52. }
  53. const norms = {};
  54. for (const p of D.packages) for (const n of p.norms) norms[n.path] = Object.assign({ pkg: p.id }, n);
  55. const open = (path) => () => { if (Lens.rec(path)) Lens.open(path); };
  56. const mode = (n) => (n.mode === "enforce" ? "blocks" : n.mode === "observe" ? "observes" : "");
  57. const normCell = (path) => {
  58. if (!path) return h("span", { class: "muted" }, "no norm named");
  59. const n = norms[path];
  60. if (!n) return h("span", { class: "warn", title: path }, "no such norm: " + path);
  61. return h("div", { class: "norm", onclick: open(path), title: path }, n.id + " — " + n.title, " ",
  62. h("em", {}, [n.level, n.floor ? "floor" : "", mode(n)].filter(Boolean).join(" · ")));
  63. };
  64. const rows = D.packages.flatMap((p) => p.actions.filter((a) => a.check).map((a) => h("tr", {},
  65. h("td", { class: "pkg" }, p.id), h("td", {}, h("code", {}, a.name)), h("td", {}, a.title || a.run),
  66. h("td", {}, normCell(a.norm)), h("td", {}, h("code", {}, "shtuk run " + p.id + " " + a.name)))));
  67. const held = new Set(D.packages.flatMap((p) => p.actions.filter((a) => a.check && a.norm).map((a) => a.norm)));
  68. const loose = Object.values(norms).filter((n) => !held.has(n.path));
  69. ui.main.append(h("div", { class: "pc" },
  70. h("section", {}, h("h2", {}, "Checks · " + rows.length),
  71. 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."),
  72. rows.length ? h("table", {}, h("tr", {}, ["Package", "Check", "What it checks", "Norm", "Run"].map((t) => h("th", {}, t))), rows)
  73. : h("p", {}, "The project has no checks.")),
  74. h("section", {}, h("h2", {}, "Norms without a check · " + loose.length),
  75. h("p", {}, "No check refers to these package norms. Their enforcer may be another one: a gate, a hook or a person."),
  76. loose.length ? h("table", {}, h("tr", {}, ["Package", "Norm", "Enforcers"].map((t) => h("th", {}, t))),
  77. loose.map((n) => h("tr", {}, h("td", { class: "pkg" }, n.pkg), h("td", {}, normCell(n.path)),
  78. h("td", {}, n.enforcers.length ? n.enforcers.map((e) => h("div", {}, h("code", {}, e))) : h("span", { class: "muted" }, "none")))))
  79. : h("p", {}, "There are no such norms."))));
  80. };
  81. })();
  82. </script>
  83. </head>
  84. <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>
  85. </html>