@mark1russell7/site-pages 0.4.0 → 0.4.1
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 +14 -0
- package/build/chunks/build.js +97 -15
- package/build/chunks/build.js.map +1 -1
- package/build/chunks/freshness.d.ts +25 -1
- package/build/chunks/freshness.d.ts.map +1 -1
- package/build/index.d.ts +24 -7
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -219,6 +219,20 @@ For a monorepo with one version for all its packages, give `--group` and the nam
|
|
|
219
219
|
|
|
220
220
|
The option `from` leaves out older sections. The option `fixedGroup` passes a section with no change or with only PATCH changes, because its raise comes from another package of the group.
|
|
221
221
|
|
|
222
|
+
### The changelog gate
|
|
223
|
+
|
|
224
|
+
The command `build` reads each changelog with `changelogReading`. A repository puts the oldest version of its gate in its root `package.json`:
|
|
225
|
+
|
|
226
|
+
```json
|
|
227
|
+
{ "sitePages": { "changelogFrom": "0.1.0" } }
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
- With the field, a fault in a section of that version or newer stops the build with code 1. The error names each section and its fault.
|
|
231
|
+
- Without the field, the build gives a warning with the count of the sections with a fault, and it does not fail.
|
|
232
|
+
- In both cases, `status.json` holds the reading in the field `changelog`, and the Status page shows the count. A reader of all the sites can thus list each repository, also a repository with no gate.
|
|
233
|
+
|
|
234
|
+
To join the gate, a repository adds the field with no change to its code. Older sections can follow older habits, so the repository picks the first version that has no fault.
|
|
235
|
+
|
|
222
236
|
`sectionMarksBreak(section)` tells if the text of a section marks a break. The marks are the heading `### Breaking` and the words "has breaking changes". A page that counts breaks uses this function.
|
|
223
237
|
|
|
224
238
|
A repository can have no changelog and no GitHub release. Then each npm version of each package of `--packages` is a release:
|
package/build/chunks/build.js
CHANGED
|
@@ -229,6 +229,47 @@ function changelogFaults(markdown, options = {}) {
|
|
|
229
229
|
return faults;
|
|
230
230
|
}
|
|
231
231
|
/**
|
|
232
|
+
* This function reads the changelog files of a repository against the rules of a version section.
|
|
233
|
+
* With a `from` version, it examines the sections of that version and newer. With null, it examines all the sections.
|
|
234
|
+
*
|
|
235
|
+
* @throws RangeError when `from` is not a version
|
|
236
|
+
*/
|
|
237
|
+
function changelogReading(changelogs, from) {
|
|
238
|
+
const core = from === null ? null : versionCore(from);
|
|
239
|
+
if (from !== null && core === null) throw new RangeError(`"${from}" is not a version.`);
|
|
240
|
+
let sections = 0;
|
|
241
|
+
const faults = [];
|
|
242
|
+
for (const { file, markdown } of changelogs) {
|
|
243
|
+
for (const section of versionSections(markdown)) {
|
|
244
|
+
const own = versionCore(section.version);
|
|
245
|
+
if (own !== null && (core === null || compareCores(own, core) >= 0)) sections += 1;
|
|
246
|
+
}
|
|
247
|
+
for (const fault of changelogFaults(markdown, from === null ? {} : { from })) faults.push({
|
|
248
|
+
file,
|
|
249
|
+
...fault
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
return {
|
|
253
|
+
from,
|
|
254
|
+
sections,
|
|
255
|
+
faults
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* This function gives the problem of a changelog reading for the build, or null. A reading with a
|
|
260
|
+
* `from` version and a fault fails the build. A reading with no `from` version only reports.
|
|
261
|
+
*/
|
|
262
|
+
function changelogGateProblem(reading, limit = 20) {
|
|
263
|
+
if (reading.from === null || reading.faults.length === 0) return null;
|
|
264
|
+
const lines = reading.faults.slice(0, limit).map((fault) => ` ${fault.file} ${fault.version}: ${fault.kind}${fault.statement === "" ? "" : ` ("${fault.statement.slice(0, 80)}")`}`);
|
|
265
|
+
const more = reading.faults.length > limit ? [` and ${reading.faults.length - limit} more`] : [];
|
|
266
|
+
return [
|
|
267
|
+
`${reading.faults.length} of ${reading.sections} version sections from ${reading.from} break the rules of a changelog section:`,
|
|
268
|
+
...lines,
|
|
269
|
+
...more
|
|
270
|
+
].join("\n");
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
232
273
|
* This function gives the changes of the text of a GitHub release: one change for each top-level
|
|
233
274
|
* list item. Fenced code is not read.
|
|
234
275
|
*/
|
|
@@ -1063,6 +1104,28 @@ function releaseReading(listed, sources, now = Date.now()) {
|
|
|
1063
1104
|
inFlight
|
|
1064
1105
|
};
|
|
1065
1106
|
}
|
|
1107
|
+
/**
|
|
1108
|
+
* This function gives the oldest version that the changelog gate of a repository examines: the field
|
|
1109
|
+
* `sitePages.changelogFrom` of its root `package.json`. It gives null when the file or the field is not there.
|
|
1110
|
+
*
|
|
1111
|
+
* @throws ReleaseDataError when the field is not a version
|
|
1112
|
+
*/
|
|
1113
|
+
function readChangelogFrom(repoDir) {
|
|
1114
|
+
const path = join(repoDir, "package.json");
|
|
1115
|
+
if (!existsSync(path)) return null;
|
|
1116
|
+
let manifest;
|
|
1117
|
+
try {
|
|
1118
|
+
manifest = JSON.parse(readFileSync(path, "utf8"));
|
|
1119
|
+
} catch {
|
|
1120
|
+
return null;
|
|
1121
|
+
}
|
|
1122
|
+
const settings = manifest.sitePages;
|
|
1123
|
+
if (settings === void 0 || settings === null || typeof settings !== "object") return null;
|
|
1124
|
+
const from = settings.changelogFrom;
|
|
1125
|
+
if (from === void 0) return null;
|
|
1126
|
+
if (typeof from !== "string" || !/^v?\d+\.\d+\.\d+$/.test(from)) throw new ReleaseDataError(`the field sitePages.changelogFrom of package.json must be a version, for example "0.1.0", not ${JSON.stringify(from)}.`);
|
|
1127
|
+
return from;
|
|
1128
|
+
}
|
|
1066
1129
|
/** The default patterns of the changelog files: the first pattern that finds a file wins. */
|
|
1067
1130
|
const DEFAULT_CHANGELOGS = ["packages/*/CHANGELOG.md", "CHANGELOG.md"];
|
|
1068
1131
|
/**
|
|
@@ -2369,6 +2432,20 @@ function measures(data) {
|
|
|
2369
2432
|
const commit = link(`https://github.com/${data.source.github}/commit/${kpi.commit}`, `<code>${kpi.commit.slice(0, 7)}</code>`);
|
|
2370
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>";
|
|
2371
2434
|
}
|
|
2435
|
+
/**
|
|
2436
|
+
* This function renders the reading of the changelogs. It shows the count of the version sections that break
|
|
2437
|
+
* the rules, and the version that the gate starts from. A repository with no gate sees its count, so the gap stays in view.
|
|
2438
|
+
*/
|
|
2439
|
+
function changelog(data) {
|
|
2440
|
+
const { changelog: reading } = data;
|
|
2441
|
+
if (reading === void 0) return "";
|
|
2442
|
+
const count = reading.faults.length;
|
|
2443
|
+
const scope = reading.from === null ? `of the ${plural(reading.sections, "version section")} of the changelogs` : `of the ${plural(reading.sections, "version section")} from ${escapeHtml(reading.from)}`;
|
|
2444
|
+
const gate = reading.from === null ? "The build does not fail on a fault, because <code>package.json</code> has no field <code>sitePages.changelogFrom</code>." : `The build fails on a fault in a section from ${escapeHtml(reading.from)}, the field <code>sitePages.changelogFrom</code> of <code>package.json</code>.`;
|
|
2445
|
+
const shown = reading.faults.slice(0, 10);
|
|
2446
|
+
const list = shown.length === 0 ? "" : `<ul>${shown.map((fault) => `<li><code>${escapeHtml(fault.file)}</code> ${escapeHtml(fault.version)}: ${escapeHtml(fault.kind)}</li>`).join("")}</ul>` + (count > shown.length ? `<p class="sp-small sp-muted">The list shows the first ${shown.length}.</p>` : "");
|
|
2447
|
+
return `<section class="sp-section" aria-labelledby="changelog"><h2 id="changelog">Changelog</h2><p data-sp-changelog-faults="${count}">${count === 0 ? "No section" : plural(count, "section")} ${scope} ${count <= 1 ? "breaks" : "break"} the rules of a changelog section. ${gate}</p>` + list + "</section>";
|
|
2448
|
+
}
|
|
2372
2449
|
function when(date) {
|
|
2373
2450
|
const text = escapeHtml(longDate(date));
|
|
2374
2451
|
return `<time datetime="${escapeHtml(date)}" title="${text}" data-sp-rel>${text}</time>`;
|
|
@@ -2505,7 +2582,7 @@ function renderStatusPage(data, options) {
|
|
|
2505
2582
|
title: "Status",
|
|
2506
2583
|
description: lead,
|
|
2507
2584
|
current: "status",
|
|
2508
|
-
main: `<h1>Status</h1><p class="sp-lead">${escapeHtml(lead)}</p><p class="sp-small sp-muted">The build reads the roadmap file and GitHub again after each commit and on a schedule.</p>` + measures(data) + (data.source.roadmap ? openWork(data) : "") + pullRequests(data) + issues(data),
|
|
2585
|
+
main: `<h1>Status</h1><p class="sp-lead">${escapeHtml(lead)}</p><p class="sp-small sp-muted">The build reads the roadmap file and GitHub again after each commit and on a schedule.</p>` + measures(data) + changelog(data) + (data.source.roadmap ? openWork(data) : "") + pullRequests(data) + issues(data),
|
|
2509
2586
|
script: STATUS_SCRIPT
|
|
2510
2587
|
}, options);
|
|
2511
2588
|
}
|
|
@@ -2550,6 +2627,11 @@ async function build(options) {
|
|
|
2550
2627
|
const [owner = "", repo = ""] = repository.split("/");
|
|
2551
2628
|
const out = isAbsolute(options.out) ? options.out : resolve(repoDir, options.out);
|
|
2552
2629
|
const fetcher = options.fetch ? { fetch: options.fetch } : {};
|
|
2630
|
+
const changelogs = readChangelogs(repoDir, options.changesets);
|
|
2631
|
+
const reading = changelogs.length === 0 ? void 0 : changelogReading(changelogs, readChangelogFrom(repoDir));
|
|
2632
|
+
const problem = reading === void 0 ? null : changelogGateProblem(reading);
|
|
2633
|
+
if (problem !== null) throw new ReleaseDataError(problem);
|
|
2634
|
+
if (reading !== void 0 && reading.from === null && reading.faults.length > 0) warn(`${reading.faults.length} of ${reading.sections} version sections of the changelogs break the rules of a changelog section. The build does not fail, because package.json has no field sitePages.changelogFrom.`);
|
|
2553
2635
|
const releases = await readReleases({
|
|
2554
2636
|
repoDir,
|
|
2555
2637
|
repository,
|
|
@@ -2564,19 +2646,19 @@ async function build(options) {
|
|
|
2564
2646
|
});
|
|
2565
2647
|
const kpiPath = join(out, KPI_FILE);
|
|
2566
2648
|
const kpi = existsSync(kpiPath) ? readKpi(readFileSync(kpiPath, "utf8"), Date.parse(now)) : void 0;
|
|
2567
|
-
const
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
...
|
|
2579
|
-
|
|
2649
|
+
const status = {
|
|
2650
|
+
...await readStatusBoard({
|
|
2651
|
+
repoDir,
|
|
2652
|
+
roadmap: options.roadmap ?? null,
|
|
2653
|
+
owner,
|
|
2654
|
+
repo,
|
|
2655
|
+
token: options.token,
|
|
2656
|
+
commit,
|
|
2657
|
+
generatedAt: now,
|
|
2658
|
+
...fetcher
|
|
2659
|
+
}),
|
|
2660
|
+
...kpi === void 0 ? {} : { kpi },
|
|
2661
|
+
...reading === void 0 ? {} : { changelog: reading }
|
|
2580
2662
|
};
|
|
2581
2663
|
if (!status.github.available) warn(`the status page has no GitHub data: ${status.github.reason ?? "no reason"}.`);
|
|
2582
2664
|
const files = [];
|
|
@@ -2732,6 +2814,6 @@ async function runCli(argv, io) {
|
|
|
2732
2814
|
throw error;
|
|
2733
2815
|
}
|
|
2734
2816
|
}
|
|
2735
|
-
export {
|
|
2817
|
+
export { githubReleaseLag as $, STATUS_CLASSES as A, DEFAULT_CHANGELOGS as B, pageShell as C, utcDay as D, shortDate as E, plainText as F, readReleases as G, mergeReleases as H, readStatusBoard as I, GITHUB_API as J, releaseReading as K, roadmapItems as L, linksOf as M, markdownTables as N, OPEN_CLASSES as O, parseRoadmap as P, githubOpenWork as Q, splitRow as R, BASE_CSS as S, longDate as T, readChangelogFrom as U, ReleaseDataError as V, readChangelogs as W, checkStateOf as X, GITHUB_GRAPHQL as Y, githubGreenRun as Z, renderReleasesPage as _, runCli as a, changelogReading as at, releaseSummary as b, STATUS_SCRIPT as c, headingAnchor as ct, renderStatusPage as d, sectionMarksBreak as dt, githubReleases as et, sectionsOf as f, releasesLead as g, RELEASES_SCRIPT as h, parseBuildArgs as i, changelogGateProblem as it, buildStatusBoard as j, RoadmapParseError as k, classCounts as l, parseChangelog as lt, statusLead as m, UsageError as n, releaseLagOf as nt, TYPESCRIPT_PROBE as o, changelogVersions as ot, slugOf as p, globFiles as q, build as r, changelogFaults as rt, probeScript as s, firstSentence as st, HELP as t, greenRunOf as tt, openGroups as u, releaseBodyEntries as ut, laneCenter as v, dayRange as w, timelineLayout as x, oldestFirst as y, statusClassOf as z };
|
|
2736
2818
|
|
|
2737
2819
|
//# sourceMappingURL=build.js.map
|