@mark1russell7/site-pages 0.3.1 → 0.3.2
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 +1 -1
- package/build/chunks/build.js +13 -12
- package/build/chunks/build.js.map +1 -1
- package/build/index.d.ts +7 -4
- package/build/index.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -495,7 +495,7 @@ Two functions read a measure from GitHub at the build. Each result has the `at`
|
|
|
495
495
|
| Function | Measure |
|
|
496
496
|
| --- | --- |
|
|
497
497
|
| `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
|
|
498
|
+
| `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
499
|
|
|
500
500
|
## The shell of a site
|
|
501
501
|
|
package/build/chunks/build.js
CHANGED
|
@@ -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
|
-
*
|
|
528
|
-
* version that most users get. It gives `{ available: false, reason }` without a token, after an error,
|
|
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
|
|
531
|
-
* commit on each page
|
|
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
|
|
556
|
+
const compare = `${endpoint}/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/compare/${encodeURIComponent(release.tag)}...${encodeURIComponent(branch)}?per_page=1`;
|
|
554
557
|
try {
|
|
555
|
-
|
|
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
|
|
567
|
-
if (!Array.isArray(
|
|
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 =
|
|
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"
|