@mark1russell7/site-pages 0.2.1 → 0.2.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 +30 -0
- package/build/{build-xJqNIzdO.js → chunks/build.js} +24 -67
- package/build/chunks/build.js.map +1 -0
- package/build/chunks/kpi.d.ts +212 -0
- package/build/chunks/kpi.d.ts.map +1 -0
- package/build/chunks/kpi.js +222 -0
- package/build/chunks/kpi.js.map +1 -0
- package/build/cli.js +1 -1
- package/build/explorer/index.d.ts +2 -0
- package/build/explorer/index.d.ts.map +1 -1
- package/build/explorer/index.js +18 -8
- package/build/explorer/index.js.map +1 -1
- package/build/index.d.ts +5 -147
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3 -1
- package/build/vite.d.ts +26 -0
- package/build/vite.d.ts.map +1 -1
- package/build/vite.js +26 -1
- package/build/vite.js.map +1 -1
- package/package.json +2 -2
- package/build/build-xJqNIzdO.js.map +0 -1
package/build/index.d.ts
CHANGED
|
@@ -1,147 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* The data shapes of `releases.json` and `status.json`. The standalone pages read them, and a site
|
|
3
|
-
* can read the same JSON with its own components.
|
|
4
|
-
*/
|
|
5
|
-
/** A link with its text, for example a pull request, a commit or a page on npm. */
|
|
6
|
-
interface Link {
|
|
7
|
-
label: string;
|
|
8
|
-
url: string;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* The kind of a version. The oldest version is "first". `X.0.0` with `X` of 1 or more is "major".
|
|
12
|
-
* A version with the PATCH number 0 is "minor". Each other version is "patch".
|
|
13
|
-
*/
|
|
14
|
-
type ReleaseKind = "first" | "major" | "minor" | "patch";
|
|
15
|
-
/** One change of a release: one commit, and the packages whose changelogs list it. */
|
|
16
|
-
interface ReleaseChange {
|
|
17
|
-
/** The short SHA of the commit, or null for an entry without a commit. */
|
|
18
|
-
commit: string | null;
|
|
19
|
-
/** The first sentence of the entry, as inline Markdown. */
|
|
20
|
-
text: string;
|
|
21
|
-
/** The npm names of the packages, sorted. */
|
|
22
|
-
packages: string[];
|
|
23
|
-
}
|
|
24
|
-
/** One version of the repository. `releases.json` holds an array of them, the newest version first. */
|
|
25
|
-
interface Release {
|
|
26
|
-
version: string;
|
|
27
|
-
/** The ISO date of the version: from the git tag, the GitHub release, npm, or the changelog commit. */
|
|
28
|
-
date: string;
|
|
29
|
-
kind: ReleaseKind;
|
|
30
|
-
/** The changes, the change with the most packages first. */
|
|
31
|
-
changes: ReleaseChange[];
|
|
32
|
-
/** The pages of the version: the GitHub release, the changelog section and the npm page. */
|
|
33
|
-
links: Link[];
|
|
34
|
-
}
|
|
35
|
-
/** A release of the GitHub repository, as `githubReleases` gives it. */
|
|
36
|
-
interface GitHubRelease {
|
|
37
|
-
tag: string;
|
|
38
|
-
name: string;
|
|
39
|
-
/** The text of the release, as Markdown. */
|
|
40
|
-
body: string;
|
|
41
|
-
/** The ISO date of the publication. */
|
|
42
|
-
publishedAt: string;
|
|
43
|
-
url: string;
|
|
44
|
-
prerelease: boolean;
|
|
45
|
-
}
|
|
46
|
-
/** The result of `githubReleases`. Without a token, or after an error, it has only the reason. */
|
|
47
|
-
type GitHubReleases = {
|
|
48
|
-
available: true;
|
|
49
|
-
releases: GitHubRelease[];
|
|
50
|
-
} | {
|
|
51
|
-
available: false;
|
|
52
|
-
reason: string;
|
|
53
|
-
};
|
|
54
|
-
/** The publication time of one version of one package on npm. */
|
|
55
|
-
interface NpmVersionTime {
|
|
56
|
-
name: string;
|
|
57
|
-
version: string;
|
|
58
|
-
date: string;
|
|
59
|
-
}
|
|
60
|
-
/** The result of `npmPublishTimes`: the times that npm gave, and a message for each package that failed. */
|
|
61
|
-
interface NpmPublishTimes {
|
|
62
|
-
times: NpmVersionTime[];
|
|
63
|
-
problems: string[];
|
|
64
|
-
}
|
|
65
|
-
/** The class of a status. The board shows the open classes in this sequence, and "done" last. */
|
|
66
|
-
type StatusClass = "waiting" | "blocked" | "progress" | "open" | "later" | "done";
|
|
67
|
-
/** One row of a table of the roadmap file. The text fields are inline Markdown. */
|
|
68
|
-
interface BoardItem {
|
|
69
|
-
id: string;
|
|
70
|
-
title: string;
|
|
71
|
-
/** The text of the Status cell, as the roadmap has it. */
|
|
72
|
-
status: string;
|
|
73
|
-
statusClass: StatusClass;
|
|
74
|
-
owner?: string;
|
|
75
|
-
area?: string;
|
|
76
|
-
/** The IDs that the item needs, as the roadmap has them. */
|
|
77
|
-
needs?: string;
|
|
78
|
-
/** The nearest heading above the table, as plain text. */
|
|
79
|
-
section: string;
|
|
80
|
-
/** The line of the row in the roadmap file. */
|
|
81
|
-
line: number;
|
|
82
|
-
links: Link[];
|
|
83
|
-
}
|
|
84
|
-
/** The combined state of the checks of the last commit of a pull request. */
|
|
85
|
-
type CheckState = "success" | "failure" | "pending" | "none";
|
|
86
|
-
/** An open pull request of the repository. */
|
|
87
|
-
interface BoardPullRequest {
|
|
88
|
-
number: number;
|
|
89
|
-
title: string;
|
|
90
|
-
url: string;
|
|
91
|
-
author: string;
|
|
92
|
-
branch: string;
|
|
93
|
-
draft: boolean;
|
|
94
|
-
createdAt: string;
|
|
95
|
-
updatedAt: string;
|
|
96
|
-
labels: string[];
|
|
97
|
-
checks: CheckState;
|
|
98
|
-
}
|
|
99
|
-
/** An open issue of the repository. */
|
|
100
|
-
interface BoardIssue {
|
|
101
|
-
number: number;
|
|
102
|
-
title: string;
|
|
103
|
-
url: string;
|
|
104
|
-
author: string;
|
|
105
|
-
createdAt: string;
|
|
106
|
-
updatedAt: string;
|
|
107
|
-
labels: string[];
|
|
108
|
-
}
|
|
109
|
-
/** The numbers of open pull requests and open issues on GitHub. A list can hold fewer than the total. */
|
|
110
|
-
interface OpenWorkTotals {
|
|
111
|
-
pullRequests: number;
|
|
112
|
-
issues: number;
|
|
113
|
-
}
|
|
114
|
-
/** The result of `githubOpenWork`. Without a token, or after an error, it has only the reason. */
|
|
115
|
-
type GitHubOpenWork = {
|
|
116
|
-
available: true;
|
|
117
|
-
pullRequests: BoardPullRequest[];
|
|
118
|
-
issues: BoardIssue[];
|
|
119
|
-
totals: OpenWorkTotals;
|
|
120
|
-
} | {
|
|
121
|
-
available: false;
|
|
122
|
-
reason: string;
|
|
123
|
-
};
|
|
124
|
-
/** The data of the status page, as `status.json` holds it. */
|
|
125
|
-
interface StatusBoardData {
|
|
126
|
-
/** The ISO time of the build that read the data. */
|
|
127
|
-
generatedAt: string;
|
|
128
|
-
/** The commit of the build, or null. */
|
|
129
|
-
commit: string | null;
|
|
130
|
-
/** The roadmap file in the repository (null without a roadmap), and the repository on GitHub ("owner/name"). */
|
|
131
|
-
source: {
|
|
132
|
-
roadmap: string | null;
|
|
133
|
-
github: string;
|
|
134
|
-
};
|
|
135
|
-
items: BoardItem[];
|
|
136
|
-
pullRequests: BoardPullRequest[];
|
|
137
|
-
issues: BoardIssue[];
|
|
138
|
-
/** The GitHub part. When GitHub was not available, the board shows the reason. */
|
|
139
|
-
github: {
|
|
140
|
-
available: boolean;
|
|
141
|
-
reason?: string;
|
|
142
|
-
totals?: OpenWorkTotals;
|
|
143
|
-
};
|
|
144
|
-
}
|
|
1
|
+
import { C as OpenWorkTotals, D as StatusBoardData, E as ReleaseKind, O as StatusClass, S as NpmVersionTime, T as ReleaseChange, _ as KpiEngine, a as kpiFile, b as Link, c as readKpi, d as BoardItem, f as BoardPullRequest, g as GitHubReleases, h as GitHubRelease, i as KpiInput, l as writeKpi, m as GitHubOpenWork, n as KPI_FORMAT, o as kpiProblems, p as CheckState, r as KpiError, s as kpiText, t as KPI_FILE, u as BoardIssue, v as KpiFile, w as Release, x as NpmPublishTimes, y as KpiMeasure } from "./chunks/kpi.js";
|
|
145
2
|
/** The parts of a SemVer 2.0.0 version. */
|
|
146
3
|
interface ParsedVersion {
|
|
147
4
|
major: number;
|
|
@@ -699,9 +556,10 @@ interface BuildResult {
|
|
|
699
556
|
}
|
|
700
557
|
/**
|
|
701
558
|
* This function reads the sources and writes `data/releases.json`, `data/status.json`,
|
|
702
|
-
* `releases/index.html` and `status/index.html` into the output folder.
|
|
559
|
+
* `releases/index.html` and `status/index.html` into the output folder. When the output folder has a
|
|
560
|
+
* `kpi.json`, the status data and the status page show it.
|
|
703
561
|
*
|
|
704
|
-
* @throws ReleaseDataError or
|
|
562
|
+
* @throws ReleaseDataError, RoadmapParseError or KpiError when a source on disk is not correct
|
|
705
563
|
*/
|
|
706
564
|
export declare function build(options: BuildOptions): Promise<BuildResult>;
|
|
707
565
|
/** The help of the CLI. */
|
|
@@ -726,5 +584,5 @@ export declare function parseBuildArgs(argv: readonly string[], io: Pick<CliIo,
|
|
|
726
584
|
* source is not correct, and 2 for an incorrect command line.
|
|
727
585
|
*/
|
|
728
586
|
export declare function runCli(argv: readonly string[], io: CliIo): Promise<number>;
|
|
729
|
-
export type
|
|
587
|
+
export { type BoardIssue, type BoardItem, type BoardPullRequest, type BoardSection, type BuildOptions, type BuildResult, type ChangelogEntry, type ChangelogSection, type ChangelogSource, type CheckState, type CliIo, type GitHubOpenWork, type GitHubOptions, type GitHubRelease, type GitHubReleases, type ItemGroup, KPI_FILE, KPI_FORMAT, type KpiEngine, KpiError, type KpiFile, type KpiInput, type KpiMeasure, type Link, type LinkOptions, type MarkdownTable, type NpmOptions, type NpmPublishTimes, type NpmVersionTime, type OpenWorkTotals, type PageOptions, type PageParts, type ParsedVersion, type ReadReleasesOptions, type ReadStatusBoardOptions, type Release, type ReleaseChange, type ReleaseKind, type ReleasePoint, type ReleaseSources, type ReleaseSummary, type StatusBoardData, type StatusBoardInput, type StatusClass, type TagDate, type TagVersion, type TimelineBand, type TimelineLayout, type TimelineMark, type TimelineOptions, kpiFile, kpiProblems, kpiText, readKpi, writeKpi };
|
|
730
588
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/data/
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/data/versions.ts","../src/data/changelog.ts","../src/data/github.ts","../src/data/npm.ts","../src/data/git.ts","../src/data/glob.ts","../src/data/releases.ts","../src/data/status.ts","../src/render/html.ts","../src/render/dates.ts","../src/render/theme.ts","../src/render/timeline.ts","../src/render/releases.ts","../src/render/status.ts","../src/check/probe.ts","../src/build.ts"],"mappings":";;UAOiB;EACf;EACA;EACA;EACA;;;wBAMc,aAAa,kBAAkB;;;;;;wBAgB/B,gBAAgB,WAAW;;;;;wBA2B3B,OAAO,iBAAiB,kBAAkB;;UASzC;EACf;EACA;;;;;;wBAOc,aAAa,cAAc;;;;;;;UCvE1B;;EAEf;;EAEA;;;UAIe;EACf;;EAEA;EACA,SAAS;;;;;;;;;wBAqBK,cAAc;;;;;;;wBA0Cd,eAAe,mBAAmB;;;;;wBAwClC,mBAAmB,eAAe;;;;;wBAqClC,cAAc;;qBCtJjB;;qBAEA;;UAKI;EACf;EACA;;EAEA;;EAEA,eAAe;;EAEf;;;wBA0Bc,aAAa;EAAU;uBAA6C;;;;;;wBA4C9D,eAAe,SAAS;EAAkB;EAAmB;IAAmB,QAAQ;;;;;;;;wBAmFxF,eAAe,SAAS;EAAkB;EAAmB;IAAsB,QAAQ;;qBCzKpG;;UAGI;;EAEf;;EAEA,eAAe;EACf;;EAEA;;;;;;;wBAgBoB,gBAAgB,SAAS,aAAa,QAAQ;;UC1BnD;EACf;EACA;;;wBAac,UAAU;;wBAKV,YAAY,kBAAkB;;;;;wBAe9B,YAAY,iBAAiB,iBAAiB;;wBAO9C,WAAW;;wBAMX,iBAAiB;;;;;wBCrCjB,UAAU,cAAc;;qBCH3B,yBAAyB;;UAGrB;;EAEf;;EAEA;EACA;;;UAIe;EACf,sBAAsB;EACtB,0BAA0B;EAC1B,gBAAgB;EAChB,eAAe;;;;;EAKf;;EAEA;;EAEA;;EAEA,gBAAgB,iBAAiB;;EAEjC;EACA,SAAS;;;;;;;;;;;;wBAqGK,cAAc,SAAS,iBAAiB;;qBAoI3C;;;;;wBAMG,eAAe,iBAAiB,mBAAmB;;UAwBlD;;EAEf;;EAEA;EACA;;EAEA;;EAEA;EACA;;EAEA;EACA,eAAe;EACf;EACA,SAAS;;;;;;;;wBASW,aAAa,SAAS,sBAAsB,QAAQ;;qBC7T7D,yBAAyB;;qBAGzB,uBAAuB;;qBAGvB,0BAA0B;;;;;wBAmBvB,cAAc,kCAAkC;;wBAWhD,SAAS;;wBA8FT,UAAU;;UAaT;;EAEf;;EAEA;;EAEA;EACA,MAAM;IAAQ;IAAc;;;;;;;wBAOd,eAAe,mBAAmB;;UAmCjC;;EAEf;;EAEA;;EAEA;;;;;;;;;wBA0Cc,QAAQ,iCAAiC,UAAS,cAAmB;;;;;;;;;;;;;wBAwIrE,aAAa,kBAAkB,UAAS,cAAmB;;UAgD1D;EACf,OAAO;;EAEP,QAAQ;;EAER;;EAEA;EACA;EACA;;;;;;;;wBASc,aAAa,kBAAkB,UAAS,cAAmB;;wBAQ3D,iBAAiB,OAAO,mBAAmB;;UAc1C;EACf;;EAEA;EACA;EACA;EACA;;EAEA;EACA,eAAe;EACf;;;;;;;;wBASoB,gBAAgB,SAAS,yBAAyB,QAAQ;;wBC5ehE,WAAW;;;;;;;;;wBAyBX,QAAQ;;;;;wBA4BR,eAAe;;wBCnDf,OAAO;;wBAKP,UAAU;;wBAMV,SAAS;;wBAQT,SAAS,eAAe;;UCnBvB;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;qBASW;;UAkJI;;EAEf;EACA;;EAEA;;EAEA;;EAEA;;;wBASc,UAAU,OAAO,WAAW,SAAS;;UCrLpC;EACf;EACA;EACA,MAAM;;;UAIS;EACf;EACA;EACA;EACA;;EAEA;EACA;;;wBAIc,eAAe,mBAAmB,iBAAiB;;wBAcnD,YAAY,UAAU,cAAc,mBAAmB,MAAM;;UAK5D;;EAEf;;EAEA;EACA;;EAEA;;EAEA;;EAEA;;;UAIe;EACf;;EAEA;EACA;EACA;EACA;EACA;EACA;;;UAIe,aAAa,UAAU,eAAe;EACrD,SAAS;EACT;EACA;;EAEA;;EAEA;;;UAIe,eAAe,UAAU,eAAe;EACvD;EACA;EACA;;EAEA;EACA;EACA;EACA,OAAO;;EAEP,OAAO,MAAM,aAAa;;;wBASZ,WAAW;EAAU;EAAoB;GAAsB;;wBAK/D,eAAe,UAAU,cAAc,mBAAmB,KAAK,SAAS,kBAAkB,eAAe;;;;;wBC5EzG,aAAa,mBAAmB;;;;;qBAuJnC;;wBA2EG,mBAAmB,mBAAmB,WAAW,SAAS;;;;;wBCtO1D,WAAW,MAAM;;wBAcjB,OAAO;;UAWN;EACf;EACA;EACA;EACA;;;wBAIc,WAAW,gBAAgB,cAAc;;UAaxC;EACf,aAAa;EACb,OAAO;;;wBAIO,WAAW,gBAAgB,cAAc;;wBAOzC,YAAY,gBAAgB,cAAc,OAAO;;;;;qBAoNpD;;wBAiFG,iBAAiB,MAAM,iBAAiB,SAAS;;qBCxXpD,kBAAkB;;;;;;wBAOf,YAAY;;qBCIf,mBAAmB;;UAGf;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;EACA;;EAEA;;EAEA;;EAEA;;EAEA;EACA,eAAe;;EAEf;EACA,SAAS;;;UAIM;;EAEf;EACA,UAAU;EACV,QAAQ;;;;;;;;;wBAgBY,MAAM,SAAS,eAAe,QAAQ;;qBA6C/C;;UA0BI;EACf;EACA,KAAK;EACL,SAAS;EACT,SAAS;EACT,eAAe;EACf;;;;;;;wBAQc,eAAe,yBAAyB,IAAI,KAAK,wBAAwB;;;;;wBAiEnE,OAAO,yBAAyB,IAAI,QAAQ"}
|
package/build/index.js
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import { $ as checkStateOf, A as safeUrl, B as roadmapItems, C as pageShell, D as utcDay, E as shortDate, F as linksOf, G as mergeReleases, H as statusClassOf, I as markdownTables, J as globFiles, K as readChangelogs, L as parseRoadmap, M as RoadmapParseError, N as STATUS_CLASSES, O as escapeHtml, P as buildStatusBoard, Q as GITHUB_GRAPHQL, R as plainText, S as BASE_CSS, T as longDate, U as DEFAULT_CHANGELOGS, V as splitRow, W as ReleaseDataError, X as npmPublishTimes, Y as NPM_REGISTRY, Z as GITHUB_API, _ as renderReleasesPage, a as runCli, at as releaseBodyEntries, b as releaseSummary, c as STATUS_SCRIPT, ct as parseVersion, d as renderStatusPage, et as githubOpenWork, f as sectionsOf, g as releasesLead, h as RELEASES_SCRIPT, i as parseBuildArgs, it as parseChangelog, j as OPEN_CLASSES, k as inlineMarkdown, l as classCounts, lt as versionOfTag, m as statusLead, n as UsageError, nt as firstSentence, o as TYPESCRIPT_PROBE, ot as compareVersions, p as slugOf, q as readReleases, r as build, rt as headingAnchor, s as probeScript, st as kindOf, t as HELP, tt as githubReleases, u as openGroups, v as laneCenter, w as dayRange, x as timelineLayout, y as oldestFirst, z as readStatusBoard } from "./chunks/build.js";
|
|
2
|
+
import { a as kpiProblems, c as writeKpi, d as headingDate, f as isShallow, i as kpiFile, l as gitTagDates, n as KPI_FORMAT, o as kpiText, p as originRepository, r as KpiError, s as readKpi, t as KPI_FILE, u as headCommit } from "./chunks/kpi.js";
|
|
3
|
+
export { BASE_CSS, DEFAULT_CHANGELOGS, GITHUB_API, GITHUB_GRAPHQL, HELP, KPI_FILE, KPI_FORMAT, KpiError, NPM_REGISTRY, OPEN_CLASSES, RELEASES_SCRIPT, ReleaseDataError, RoadmapParseError, STATUS_CLASSES, STATUS_SCRIPT, TYPESCRIPT_PROBE, UsageError, build, buildStatusBoard, checkStateOf, classCounts, compareVersions, dayRange, escapeHtml, firstSentence, gitTagDates, githubOpenWork, githubReleases, globFiles, headCommit, headingAnchor, headingDate, inlineMarkdown, isShallow, kindOf, kpiFile, kpiProblems, kpiText, laneCenter, linksOf, longDate, markdownTables, mergeReleases, npmPublishTimes, oldestFirst, openGroups, originRepository, pageShell, parseBuildArgs, parseChangelog, parseRoadmap, parseVersion, plainText, probeScript, readChangelogs, readKpi, readReleases, readStatusBoard, releaseBodyEntries, releaseSummary, releasesLead, renderReleasesPage, renderStatusPage, roadmapItems, runCli, safeUrl, sectionsOf, shortDate, slugOf, splitRow, statusClassOf, statusLead, timelineLayout, utcDay, versionOfTag, writeKpi };
|
package/build/vite.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BuildInfo } from "./chrome.js";
|
|
2
|
+
import { i as KpiInput } from "./chunks/kpi.js";
|
|
2
3
|
/** The environment variables that this module reads. */
|
|
3
4
|
export type SiteEnv = Readonly<Record<string, string | undefined>>;
|
|
4
5
|
/** The options of `siteShell`. */
|
|
@@ -41,6 +42,31 @@ export interface SiteShellPlugin {
|
|
|
41
42
|
config(config: SiteShellConfigInput): SiteShellConfig;
|
|
42
43
|
transformIndexHtml(): SiteShellTag[];
|
|
43
44
|
}
|
|
45
|
+
/** The input of `siteKpi`. Without a commit, the plugin takes `GITHUB_SHA`, else the head of the repository. */
|
|
46
|
+
export type SiteKpiInput = Omit<KpiInput, "commit"> & {
|
|
47
|
+
readonly commit?: string | undefined;
|
|
48
|
+
};
|
|
49
|
+
/** The part of the context of a Rollup hook that `siteKpi` uses. */
|
|
50
|
+
export interface SiteKpiContext {
|
|
51
|
+
emitFile(file: {
|
|
52
|
+
type: "asset";
|
|
53
|
+
fileName: string;
|
|
54
|
+
source: string;
|
|
55
|
+
}): string;
|
|
56
|
+
}
|
|
57
|
+
/** The Vite plugin that `siteKpi` gives. */
|
|
58
|
+
export interface SiteKpiPlugin {
|
|
59
|
+
readonly name: string;
|
|
60
|
+
readonly apply: "build";
|
|
61
|
+
generateBundle(this: SiteKpiContext): void;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* This function gives the Vite plugin that adds `kpi.json` to the root of a built site. A fault in the data stops the build.
|
|
65
|
+
*
|
|
66
|
+
* @param input - The data, or a function that reads it at the time of the build.
|
|
67
|
+
* @param env - The environment variables. A test gives its own.
|
|
68
|
+
*/
|
|
69
|
+
export declare function siteKpi(input: SiteKpiInput | (() => SiteKpiInput), env?: SiteEnv): SiteKpiPlugin;
|
|
44
70
|
/**
|
|
45
71
|
* This function gives the script that sets the saved theme before the first paint, so a dark page
|
|
46
72
|
* does not show white for a moment. The script reads `storageKey`, as `applyTheme` writes it.
|
package/build/vite.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.d.ts","names":[],"sources":["../src/vite.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"vite.d.ts","names":[],"sources":["../src/vite.ts"],"mappings":";;;YAiBY,UAAU,SAAS;;iBAGd;;WAEN;;;;;WAKA;;;YAIC;;iBAGK;WACN;WACA;WACA;aAAmB,SAAS;;;;iBAItB;WACN;WACA;aAAkB,QAAQ;;WAC1B,QAAQ,SAAS;;;iBAIX;WACN;WACA;WACA;;;iBAIM;WACN;EACT,OAAO,QAAQ,uBAAuB;EACtC,sBAAsB;;;YAIZ,eAAe,KAAK;WAAiC;;;iBAGhD;EACf,SAAS;IAAQ;IAAe;IAAkB;;;;iBAInC;WACN;WACA;EACT,eAAA,MAAqB;;;;;;;;wBASP,QAAQ,OAAO,sBAAsB,eAAe,MAAK,UAAwB;;;;;;;;wBAmBjF,YAAY;;;;;wBASZ,SAAS,MAAK;;wBAMd,UAAU,kBAAkB,MAAK,SAAuB,MAAK,OAAoB;;;;;;;;;;;;wBAoBjF,UAAU,SAAS,mBAAmB"}
|
package/build/vite.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { i as kpiFile, o as kpiText, t as KPI_FILE, u as headCommit } from "./chunks/kpi.js";
|
|
1
2
|
import { readFileSync } from "node:fs";
|
|
2
3
|
import { resolve } from "node:path";
|
|
3
4
|
// src/vite.ts
|
|
@@ -9,6 +10,30 @@ import { resolve } from "node:path";
|
|
|
9
10
|
* package keeps no dependency. A test examines that Vite accepts the plugin.
|
|
10
11
|
*/
|
|
11
12
|
/**
|
|
13
|
+
* This function gives the Vite plugin that adds `kpi.json` to the root of a built site. A fault in the data stops the build.
|
|
14
|
+
*
|
|
15
|
+
* @param input - The data, or a function that reads it at the time of the build.
|
|
16
|
+
* @param env - The environment variables. A test gives its own.
|
|
17
|
+
*/
|
|
18
|
+
function siteKpi(input, env = process.env) {
|
|
19
|
+
return {
|
|
20
|
+
name: "site-pages-kpi",
|
|
21
|
+
apply: "build",
|
|
22
|
+
generateBundle() {
|
|
23
|
+
const data = typeof input === "function" ? input() : input;
|
|
24
|
+
const commit = data.commit ?? env["GITHUB_SHA"] ?? headCommit(process.cwd()) ?? "";
|
|
25
|
+
this.emitFile({
|
|
26
|
+
type: "asset",
|
|
27
|
+
fileName: KPI_FILE,
|
|
28
|
+
source: kpiText(kpiFile({
|
|
29
|
+
...data,
|
|
30
|
+
commit
|
|
31
|
+
}))
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
12
37
|
* This function gives the script that sets the saved theme before the first paint, so a dark page
|
|
13
38
|
* does not show white for a moment. The script reads `storageKey`, as `applyTheme` writes it.
|
|
14
39
|
*
|
|
@@ -70,6 +95,6 @@ function siteShell(options) {
|
|
|
70
95
|
}
|
|
71
96
|
};
|
|
72
97
|
}
|
|
73
|
-
export { buildInfo, siteBase, siteShell, themeScript };
|
|
98
|
+
export { buildInfo, siteBase, siteKpi, siteShell, themeScript };
|
|
74
99
|
|
|
75
100
|
//# sourceMappingURL=vite.js.map
|
package/build/vite.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.js","names":[],"sources":["../src/vite.ts"],"sourcesContent":["/**\n * The build side of the shell of a site: a Vite plugin and its parts. Import this module from\n * `@mark1russell7/site-pages/vite`. It is for `vite.config.ts`, not for a browser.\n *\n * This module does not import Vite. The types of the plugin are the small part that it uses, so the\n * package keeps no dependency. A test examines that Vite accepts the plugin.\n */\n\nimport { readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport type { BuildInfo } from \"./chrome.ts\";\n\nexport type { BuildInfo } from \"./chrome.ts\";\n\n/** The environment variables that this module reads. */\nexport type SiteEnv = Readonly<Record<string, string | undefined>>;\n\n/** The options of `siteShell`. */\nexport interface SiteShellOptions {\n /** The `localStorage` key of the theme. Give the same key to `setupTheme` in the page. */\n readonly themeKey: string;\n /**\n * The file with the version for `__BUILD__`, relative to the folder of the site. The default is\n * `../package.json`. The value `false` gives a build with no version.\n */\n readonly packageFile?: string | false | undefined;\n}\n\n/** The value of `build.target` in a Vite config. */\nexport type SiteTarget = string | string[] | false;\n\n/** The part of the Vite config that `siteShell` reads. */\nexport interface SiteShellConfigInput {\n readonly root?: string | undefined;\n readonly base?: string | undefined;\n readonly build?: { readonly target?: SiteTarget | undefined } | null | undefined;\n}\n\n/** The part of the Vite config that `siteShell` sets. Vite merges it into the config of the site. */\nexport interface SiteShellConfig {\n readonly base: string;\n readonly build: { readonly target: SiteTarget };\n readonly define: Readonly<Record<string, string>>;\n}\n\n/** A tag for the `head` of each HTML page. */\nexport interface SiteShellTag {\n readonly tag: \"script\";\n readonly children: string;\n readonly injectTo: \"head\";\n}\n\n/** The Vite plugin that `siteShell` gives. */\nexport interface SiteShellPlugin {\n readonly name: string;\n config(config: SiteShellConfigInput): SiteShellConfig;\n transformIndexHtml(): SiteShellTag[];\n}\n\n/**\n * This function gives the script that sets the saved theme before the first paint, so a dark page\n * does not show white for a moment. The script reads `storageKey`, as `applyTheme` writes it.\n *\n * @remarks The text goes in an inline `script` element. Thus the function escapes each `<` of the\n * key, so a key cannot close the element.\n */\nexport function themeScript(storageKey: string): string {\n const key = JSON.stringify(storageKey).replaceAll(\"<\", \"\\\\u003c\");\n return `try{const t=localStorage.getItem(${key});if(t===\"light\"||t===\"dark\")document.documentElement.dataset.theme=t}catch{}`;\n}\n\n/**\n * This function gives the `base` of Vite from `SITE_BASE`, with one `/` at the end. The Pages\n * workflow sets that variable to `/<name>`. A local build has no such variable, and gets `/`.\n */\nexport function siteBase(env: SiteEnv = process.env): string {\n const base = env[\"SITE_BASE\"];\n return base ? `${base.replace(/\\/$/, \"\")}/` : \"/\";\n}\n\n/** This function gives the data of a build. Outside CI, `GITHUB_SHA` is not set, and `sha` is `local`. */\nexport function buildInfo(version?: string, env: SiteEnv = process.env, now: Date = new Date()): BuildInfo {\n return { sha: (env[\"GITHUB_SHA\"] ?? \"local\").slice(0, 7), date: now.toISOString().slice(0, 10), version };\n}\n\n/** This function reads the field `version` of a `package.json` file. */\nfunction versionIn(file: string): string | undefined {\n return (JSON.parse(readFileSync(file, \"utf8\")) as { version?: string }).version;\n}\n\n/**\n * This function makes the Vite plugin of a site. The plugin does these four operations:\n *\n * - It sets `base` from `SITE_BASE`.\n * - It sets `build.target` to `es2022`.\n * - It defines `__BUILD__`, the value that `showBuild` shows.\n * - It adds `themeScript` to the `head` of each HTML page.\n *\n * A `base` or a `build.target` in the config of the site has priority. The other values of `build`\n * and `define` in that config stay, because Vite merges them.\n */\nexport function siteShell(options: SiteShellOptions): SiteShellPlugin {\n return {\n name: \"site-pages-shell\",\n config(config) {\n const packageFile = options.packageFile ?? \"../package.json\";\n const version = packageFile === false ? undefined : versionIn(resolve(config.root ?? \".\", packageFile));\n return {\n base: config.base ?? siteBase(),\n build: { target: config.build?.target ?? \"es2022\" },\n define: { __BUILD__: JSON.stringify(buildInfo(version)) },\n };\n },\n transformIndexHtml() {\n return [{ tag: \"script\", children: themeScript(options.themeKey), injectTo: \"head\" }];\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"vite.js","names":[],"sources":["../src/vite.ts"],"sourcesContent":["/**\n * The build side of the shell of a site: a Vite plugin and its parts. Import this module from\n * `@mark1russell7/site-pages/vite`. It is for `vite.config.ts`, not for a browser.\n *\n * This module does not import Vite. The types of the plugin are the small part that it uses, so the\n * package keeps no dependency. A test examines that Vite accepts the plugin.\n */\n\nimport { readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport type { BuildInfo } from \"./chrome.ts\";\nimport { headCommit } from \"./data/git.ts\";\nimport { KPI_FILE, kpiFile, kpiText, type KpiInput } from \"./data/kpi.ts\";\n\nexport type { BuildInfo } from \"./chrome.ts\";\n\n/** The environment variables that this module reads. */\nexport type SiteEnv = Readonly<Record<string, string | undefined>>;\n\n/** The options of `siteShell`. */\nexport interface SiteShellOptions {\n /** The `localStorage` key of the theme. Give the same key to `setupTheme` in the page. */\n readonly themeKey: string;\n /**\n * The file with the version for `__BUILD__`, relative to the folder of the site. The default is\n * `../package.json`. The value `false` gives a build with no version.\n */\n readonly packageFile?: string | false | undefined;\n}\n\n/** The value of `build.target` in a Vite config. */\nexport type SiteTarget = string | string[] | false;\n\n/** The part of the Vite config that `siteShell` reads. */\nexport interface SiteShellConfigInput {\n readonly root?: string | undefined;\n readonly base?: string | undefined;\n readonly build?: { readonly target?: SiteTarget | undefined } | null | undefined;\n}\n\n/** The part of the Vite config that `siteShell` sets. Vite merges it into the config of the site. */\nexport interface SiteShellConfig {\n readonly base: string;\n readonly build: { readonly target: SiteTarget };\n readonly define: Readonly<Record<string, string>>;\n}\n\n/** A tag for the `head` of each HTML page. */\nexport interface SiteShellTag {\n readonly tag: \"script\";\n readonly children: string;\n readonly injectTo: \"head\";\n}\n\n/** The Vite plugin that `siteShell` gives. */\nexport interface SiteShellPlugin {\n readonly name: string;\n config(config: SiteShellConfigInput): SiteShellConfig;\n transformIndexHtml(): SiteShellTag[];\n}\n\n/** The input of `siteKpi`. Without a commit, the plugin takes `GITHUB_SHA`, else the head of the repository. */\nexport type SiteKpiInput = Omit<KpiInput, \"commit\"> & { readonly commit?: string | undefined };\n\n/** The part of the context of a Rollup hook that `siteKpi` uses. */\nexport interface SiteKpiContext {\n emitFile(file: { type: \"asset\"; fileName: string; source: string }): string;\n}\n\n/** The Vite plugin that `siteKpi` gives. */\nexport interface SiteKpiPlugin {\n readonly name: string;\n readonly apply: \"build\";\n generateBundle(this: SiteKpiContext): void;\n}\n\n/**\n * This function gives the Vite plugin that adds `kpi.json` to the root of a built site. A fault in the data stops the build.\n *\n * @param input - The data, or a function that reads it at the time of the build.\n * @param env - The environment variables. A test gives its own.\n */\nexport function siteKpi(input: SiteKpiInput | (() => SiteKpiInput), env: SiteEnv = process.env): SiteKpiPlugin {\n return {\n name: \"site-pages-kpi\",\n apply: \"build\",\n generateBundle() {\n const data = typeof input === \"function\" ? input() : input;\n const commit = data.commit ?? env[\"GITHUB_SHA\"] ?? headCommit(process.cwd()) ?? \"\";\n this.emitFile({ type: \"asset\", fileName: KPI_FILE, source: kpiText(kpiFile({ ...data, commit })) });\n },\n };\n}\n\n/**\n * This function gives the script that sets the saved theme before the first paint, so a dark page\n * does not show white for a moment. The script reads `storageKey`, as `applyTheme` writes it.\n *\n * @remarks The text goes in an inline `script` element. Thus the function escapes each `<` of the\n * key, so a key cannot close the element.\n */\nexport function themeScript(storageKey: string): string {\n const key = JSON.stringify(storageKey).replaceAll(\"<\", \"\\\\u003c\");\n return `try{const t=localStorage.getItem(${key});if(t===\"light\"||t===\"dark\")document.documentElement.dataset.theme=t}catch{}`;\n}\n\n/**\n * This function gives the `base` of Vite from `SITE_BASE`, with one `/` at the end. The Pages\n * workflow sets that variable to `/<name>`. A local build has no such variable, and gets `/`.\n */\nexport function siteBase(env: SiteEnv = process.env): string {\n const base = env[\"SITE_BASE\"];\n return base ? `${base.replace(/\\/$/, \"\")}/` : \"/\";\n}\n\n/** This function gives the data of a build. Outside CI, `GITHUB_SHA` is not set, and `sha` is `local`. */\nexport function buildInfo(version?: string, env: SiteEnv = process.env, now: Date = new Date()): BuildInfo {\n return { sha: (env[\"GITHUB_SHA\"] ?? \"local\").slice(0, 7), date: now.toISOString().slice(0, 10), version };\n}\n\n/** This function reads the field `version` of a `package.json` file. */\nfunction versionIn(file: string): string | undefined {\n return (JSON.parse(readFileSync(file, \"utf8\")) as { version?: string }).version;\n}\n\n/**\n * This function makes the Vite plugin of a site. The plugin does these four operations:\n *\n * - It sets `base` from `SITE_BASE`.\n * - It sets `build.target` to `es2022`.\n * - It defines `__BUILD__`, the value that `showBuild` shows.\n * - It adds `themeScript` to the `head` of each HTML page.\n *\n * A `base` or a `build.target` in the config of the site has priority. The other values of `build`\n * and `define` in that config stay, because Vite merges them.\n */\nexport function siteShell(options: SiteShellOptions): SiteShellPlugin {\n return {\n name: \"site-pages-shell\",\n config(config) {\n const packageFile = options.packageFile ?? \"../package.json\";\n const version = packageFile === false ? undefined : versionIn(resolve(config.root ?? \".\", packageFile));\n return {\n base: config.base ?? siteBase(),\n build: { target: config.build?.target ?? \"es2022\" },\n define: { __BUILD__: JSON.stringify(buildInfo(version)) },\n };\n },\n transformIndexHtml() {\n return [{ tag: \"script\", children: themeScript(options.themeKey), injectTo: \"head\" }];\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkFA,SAAgB,QAAQ,OAA4C,MAAe,QAAQ,KAAoB;CAC7G,OAAO;EACL,MAAM;EACN,OAAO;EACP,iBAAiB;GACf,MAAM,OAAO,OAAO,UAAU,aAAa,MAAM,IAAI;GACrD,MAAM,SAAS,KAAK,UAAU,IAAI,iBAAiB,WAAW,QAAQ,IAAI,CAAC,KAAK;GAChF,KAAK,SAAS;IAAE,MAAM;IAAS,UAAU;IAAU,QAAQ,QAAQ,QAAQ;KAAE,GAAG;KAAM;IAAO,CAAC,CAAC;GAAE,CAAC;EACpG;CACF;AACF;;;;;;;;AASA,SAAgB,YAAY,YAA4B;CAEtD,OAAO,oCADK,KAAK,UAAU,UAAU,CAAC,CAAC,WAAW,KAAK,SACV,EAAE;AACjD;;;;;AAMA,SAAgB,SAAS,MAAe,QAAQ,KAAa;CAC3D,MAAM,OAAO,IAAI;CACjB,OAAO,OAAO,GAAG,KAAK,QAAQ,OAAO,EAAE,EAAE,KAAK;AAChD;;AAGA,SAAgB,UAAU,SAAkB,MAAe,QAAQ,KAAK,sBAAY,IAAI,KAAK,GAAc;CACzG,OAAO;EAAE,MAAM,IAAI,iBAAiB,QAAA,CAAS,MAAM,GAAG,CAAC;EAAG,MAAM,IAAI,YAAY,CAAC,CAAC,MAAM,GAAG,EAAE;EAAG;CAAQ;AAC1G;;AAGA,SAAS,UAAU,MAAkC;CACnD,OAAQ,KAAK,MAAM,aAAa,MAAM,MAAM,CAAC,CAAC,CAA0B;AAC1E;;;;;;;;;;;;AAaA,SAAgB,UAAU,SAA4C;CACpE,OAAO;EACL,MAAM;EACN,OAAO,QAAQ;GACb,MAAM,cAAc,QAAQ,eAAe;GAC3C,MAAM,UAAU,gBAAgB,QAAQ,KAAA,IAAY,UAAU,QAAQ,OAAO,QAAQ,KAAK,WAAW,CAAC;GACtG,OAAO;IACL,MAAM,OAAO,QAAQ,SAAS;IAC9B,OAAO,EAAE,QAAQ,OAAO,OAAO,UAAU,SAAS;IAClD,QAAQ,EAAE,WAAW,KAAK,UAAU,UAAU,OAAO,CAAC,EAAE;GAC1D;EACF;EACA,qBAAqB;GACnB,OAAO,CAAC;IAAE,KAAK;IAAU,UAAU,YAAY,QAAQ,QAAQ;IAAG,UAAU;GAAO,CAAC;EACtF;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@mark1russell7/site-pages",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.3",
|
|
5
5
|
"description": "A release timeline page and a live status page for the site of a GitHub repository: JSON data and standalone HTML, made at deploy time.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"github-pages",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"node": ">=22"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@mark1russell7/rigor-statistics": "^0.1.
|
|
65
|
+
"@mark1russell7/rigor-statistics": "^0.1.9"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@mark1russell7/cue": "^2.0.0",
|