@mark1russell7/site-pages 0.3.1 → 0.3.3

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 CHANGED
@@ -130,7 +130,11 @@ check("the linter finds a word", await until(() => $$(".finding").length === 1),
130
130
 
131
131
  For a TypeScript probe, the check removes the types and the line `export {};` before it runs the probe. Thus the typecheck of the site examines the probe, and the site needs no build step for it. Each line stays at its position, so the line of an error is the line of the source. Declare the functions of the table with `declare const`, and add `export {};` at the end, so the file is a module. `probeScript` does the same operation for a script of your own.
132
132
 
133
- The check runs the probe on the first page, in the first scheme, at each width. The folder of `--shots` gets a screenshot of each view, `report.json` and `summary.md`. The exit code is 0 when each view passes, 1 when a view fails, and 2 for an incorrect command line.
133
+ The check runs the probe on the first page, in the first scheme, at each width.
134
+
135
+ To probe other pages, give `--page-probe <page>=<file>` one time for each page, for example `--page-probe /structures/=structures-probe.ts`. A page with no probe has none. The first page takes `--probe` or `--page-probe`, not both. In `checkSite`, the option `probes` is the same map, from a page to the code of its probe.
136
+
137
+ The folder of `--shots` gets a screenshot of each view, `report.json` and `summary.md`. The exit code is 0 when each view passes, 1 when a view fails, and 2 for an incorrect command line.
134
138
 
135
139
  The check finds a browser in this order: `--browser`, `$SITE_CHECK_BROWSER`, the newest Chromium of Playwright, and then Chrome or Edge. The folder `src/check` imports only Node.js. Thus Node.js 22.18 or later can start `src/check/main.ts` with no install. The workflow `reusable-pages.yml` of the template uses it this way.
136
140
 
@@ -495,7 +499,7 @@ Two functions read a measure from GitHub at the build. Each result has the `at`
495
499
  | Function | Measure |
496
500
  | --- | --- |
497
501
  | `githubGreenRun({ owner, repo, token, workflow })` | The scheduled runs of a workflow that passed in a row, from the newest run |
498
- | `githubReleaseLag({ owner, repo, token, tagPrefix, branch })` | The age in days of the oldest commit of the branch after the newest release of the tag prefix. Drafts and pre-releases do not count. |
502
+ | `githubReleaseLag({ owner, repo, token, tagPrefix, branch })` | The age in days of the oldest commit of the branch that is not in the newest release of the tag prefix. Drafts and pre-releases do not count. |
499
503
 
500
504
  ## The shell of a site
501
505
 
@@ -524,11 +524,14 @@ function releaseLagOf(oldest, now) {
524
524
  }
525
525
  /**
526
526
  * This function reads how many days a branch is ahead of its newest release. That is the age of the oldest commit of the branch
527
- * after the newest release whose tag starts with `tagPrefix`. It skips drafts and pre-releases, because a pre-release is not the
528
- * version that most users get. It gives `{ available: false, reason }` without a token, after an error, or with no such release.
527
+ * that is not in the newest release of the tag prefix `tagPrefix`. It skips drafts and pre-releases, because
528
+ * a pre-release is not the version that most users get. It gives `{ available: false, reason }` without a token, after an error,
529
+ * or with no such release.
529
530
  *
530
- * @remarks The function reads the releases until it finds one, at most `maxPages` pages of 100 (default 10). It then reads one
531
- * commit on each page of the branch since that release, and asks GitHub for the last page only.
531
+ * @remarks The function reads the releases until it finds one, at most `maxPages` pages of 100 (default 10). It then compares the
532
+ * tag with the branch, with one commit on each page. GitHub gives the commits of a comparison from the oldest, so the first page
533
+ * holds the oldest commit. A commit that is merged after the tag and before the release is published counts, because it is not
534
+ * in the release. The time of the release does not decide.
532
535
  */
533
536
  async function githubReleaseLag(options) {
534
537
  const { owner, repo, token = "", tagPrefix, branch = "main", endpoint = GITHUB_API, timeoutMs = 15e3 } = options;
@@ -550,25 +553,23 @@ async function githubReleaseLag(options) {
550
553
  headers: restHeaders(token),
551
554
  signal: AbortSignal.timeout(timeoutMs)
552
555
  });
553
- const first = `${endpoint}/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/commits?sha=${encodeURIComponent(branch)}&since=${encodeURIComponent(release.publishedAt)}&per_page=1`;
556
+ const compare = `${endpoint}/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/compare/${encodeURIComponent(release.tag)}...${encodeURIComponent(branch)}?per_page=1`;
554
557
  try {
555
- let response = await read(first);
556
- const last = response.ok ? linkedPage(response.headers.get("link"), "last") : null;
557
- if (last !== null) response = await read(last);
558
+ const response = await read(compare);
558
559
  if (response.status === 404) return {
559
560
  available: false,
560
- reason: `GitHub has no branch ${branch} in ${owner}/${repo}`
561
+ reason: `GitHub has no tag ${release.tag} or no branch ${branch} in ${owner}/${repo}`
561
562
  };
562
563
  if (!response.ok) return {
563
564
  available: false,
564
565
  reason: `GitHub answered with HTTP ${response.status}`
565
566
  };
566
- const body = await response.json();
567
- if (!Array.isArray(body)) return {
567
+ const commits = object(await response.json())["commits"];
568
+ if (!Array.isArray(commits)) return {
568
569
  available: false,
569
570
  reason: "GitHub gave no list of commits"
570
571
  };
571
- const commit = body.length === 0 ? void 0 : text(object(object(object(body.at(-1))["commit"])["committer"])["date"]);
572
+ const commit = commits.length === 0 ? void 0 : text(object(object(object(commits[0])["commit"])["committer"])["date"]);
572
573
  if (commit === "") return {
573
574
  available: false,
574
575
  reason: "the oldest commit has no date"