@mark1russell7/site-pages 0.4.3 → 0.4.4
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 +3 -2
- package/build/chunks/build.js +18 -2
- package/build/chunks/build.js.map +1 -1
- package/build/chunks/freshness.d.ts +10 -1
- package/build/chunks/freshness.d.ts.map +1 -1
- package/build/chunks/freshness.js +37 -3
- package/build/chunks/freshness.js.map +1 -1
- package/build/index.d.ts +2 -2
- package/build/index.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -560,16 +560,17 @@ interface KpiFile {
|
|
|
560
560
|
project: string;
|
|
561
561
|
at: string; // the ISO time of the data in UTC, never the time of the build
|
|
562
562
|
commit: string; // the full commit of the build
|
|
563
|
-
measures: Array<{ id: string; value: number; unit?: string; at?: string; notCounted?: string }>;
|
|
563
|
+
measures: Array<{ id: string; value: number; unit?: string; at?: string; notCounted?: string; targets?: Array<{ value: number; by: string }> }>;
|
|
564
564
|
engines?: Array<{ name: string; version: string }>; // the Status page shows them
|
|
565
565
|
}
|
|
566
566
|
```
|
|
567
567
|
|
|
568
568
|
- Give `at` from the record of the data. The writer has no default for this field, because a build time hides old data.
|
|
569
569
|
- Give `at` on a measure when its data is from another time than the file. The Status page then shows a date for each measure.
|
|
570
|
+
- Give `targets` on a measure with a plan. Each target has a value of 0 or more and a date `by` as `YYYY-MM-DD`. The dates go up from the first target to the last. The Status page shows the first target on or after the date of the data, with the unit of the measure. Without such a target, it shows the last target with the word "(past)".
|
|
570
571
|
- Give `notCounted` on a count of faults, for example a count of old text. The text names what the count does not read, so a 0 does not seem to tell more than it measured. The Status page shows the text.
|
|
571
572
|
- Without `commit`, the plugin takes `GITHUB_SHA`, else the head of the repository.
|
|
572
|
-
- A fault in the data stops the build, and the old site stays. A fault is a wrong form, a value that is not finite, a repeated id
|
|
573
|
+
- A fault in the data stops the build, and the old site stays. A fault is a wrong form, a value that is not finite, a repeated id, a time after the check or a wrong target. The time rules apply to the file and to each measure.
|
|
573
574
|
- A site with no Vite build calls `writeKpi(out, input)` from the root entry, before `site-pages build`.
|
|
574
575
|
- `site-pages build` reads the file from the output folder. It adds the file to `data/status.json`, and the Status page shows the measures, the data date and the engines.
|
|
575
576
|
|
package/build/chunks/build.js
CHANGED
|
@@ -2420,17 +2420,33 @@ function openWork(data) {
|
|
|
2420
2420
|
* This function renders the measures of `kpi.json`: their values, the date of the data and the engines that made it.
|
|
2421
2421
|
* A measure with its own date shows that date in a column, so that the line above the table stays true.
|
|
2422
2422
|
* A measure that names what it does not count shows that text under the table.
|
|
2423
|
+
* A measure with targets shows its next target with its unit: the first target on or after the date of its data.
|
|
2424
|
+
* Without such a target, the cell shows the last target with the word "(past)".
|
|
2423
2425
|
*/
|
|
2424
2426
|
function measures(data) {
|
|
2425
2427
|
const { kpi } = data;
|
|
2426
2428
|
if (kpi === void 0) return "";
|
|
2427
2429
|
const ownDates = kpi.measures.some((measure) => measure.at !== void 0);
|
|
2430
|
+
const anyTargets = kpi.measures.some((measure) => measure.targets !== void 0);
|
|
2428
2431
|
const dateCell = (at) => ownDates ? `<td><time datetime="${escapeHtml(at)}">${escapeHtml(longDate(at))}</time></td>` : "";
|
|
2429
|
-
const
|
|
2432
|
+
const targetCell = (measure, at) => {
|
|
2433
|
+
if (!anyTargets) return "";
|
|
2434
|
+
const targets = measure.targets ?? [];
|
|
2435
|
+
const next = targets.find((target) => target.by >= at.slice(0, 10)) ?? targets.at(-1);
|
|
2436
|
+
if (next === void 0) return "<td></td>";
|
|
2437
|
+
const day = `${shortDate(next.by)}, ${next.by.slice(0, 4)}`;
|
|
2438
|
+
const unit = measure.unit === void 0 ? "" : ` ${escapeHtml(measure.unit)}`;
|
|
2439
|
+
const past = next.by < at.slice(0, 10) ? " (past)" : "";
|
|
2440
|
+
return `<td>${next.value}${unit} by <time datetime="${escapeHtml(next.by)}">${escapeHtml(day)}</time>${past}</td>`;
|
|
2441
|
+
};
|
|
2442
|
+
const rows = kpi.measures.map((measure) => {
|
|
2443
|
+
const at = measure.at ?? kpi.at;
|
|
2444
|
+
return `<tr><th scope="row">${escapeHtml(measure.id)}</th><td>${measure.value}${measure.unit === void 0 ? "" : ` ${escapeHtml(measure.unit)}`}</td>${targetCell(measure, at)}${dateCell(at)}</tr>`;
|
|
2445
|
+
}).join("");
|
|
2430
2446
|
const limits = kpi.measures.filter((measure) => measure.notCounted !== void 0).map((measure) => `<p><code>${escapeHtml(measure.id)}</code> does not count: ${escapeHtml(measure.notCounted ?? "")}</p>`).join("");
|
|
2431
2447
|
const engines = kpi.engines ?? [];
|
|
2432
2448
|
const commit = link(`https://github.com/${data.source.github}/commit/${kpi.commit}`, `<code>${kpi.commit.slice(0, 7)}</code>`);
|
|
2433
|
-
return `<section class="sp-section" aria-labelledby="measures"><h2 id="measures">Measures</h2><p>${ownDates ? "The data date of the file is" : "The data of these numbers is from"} <time datetime="${escapeHtml(kpi.at)}" data-sp-data-date>${escapeHtml(longDate(kpi.at))}</time>. The build of ${commit} published them.</p>` + (engines.length > 0 ? `<p>The engines of the data: ${listText(engines.map((engine) => `<code>${escapeHtml(engine.name)}</code> ${escapeHtml(engine.version)}`))}.</p>` : "") + `<div class="sp-table-box" tabindex="0" role="region" aria-label="Measures"><table class="sp-table"><thead><tr><th scope="col">Measure</th><th scope="col">Value</th>${ownDates ? "<th scope=\"col\">Data date</th>" : ""}</tr></thead><tbody>${rows}</tbody></table></div>` + limits + "</section>";
|
|
2449
|
+
return `<section class="sp-section" aria-labelledby="measures"><h2 id="measures">Measures</h2><p>${ownDates ? "The data date of the file is" : "The data of these numbers is from"} <time datetime="${escapeHtml(kpi.at)}" data-sp-data-date>${escapeHtml(longDate(kpi.at))}</time>. The build of ${commit} published them.</p>` + (engines.length > 0 ? `<p>The engines of the data: ${listText(engines.map((engine) => `<code>${escapeHtml(engine.name)}</code> ${escapeHtml(engine.version)}`))}.</p>` : "") + `<div class="sp-table-box" tabindex="0" role="region" aria-label="Measures"><table class="sp-table"><thead><tr><th scope="col">Measure</th><th scope="col">Value</th>${anyTargets ? "<th scope=\"col\">Next target</th>" : ""}${ownDates ? "<th scope=\"col\">Data date</th>" : ""}</tr></thead><tbody>${rows}</tbody></table></div>` + limits + "</section>";
|
|
2434
2450
|
}
|
|
2435
2451
|
/**
|
|
2436
2452
|
* This function renders the reading of the changelogs. It shows the count of the version sections that break
|