@connextar/house 0.23.1 → 0.24.0
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 +55 -13
- package/dist/analytics/browser.d.ts +1 -0
- package/dist/analytics/browser.d.ts.map +1 -1
- package/dist/analytics/browser.js +22 -5
- package/dist/analytics/browser.js.map +1 -1
- package/dist/analytics/config.d.ts +5 -0
- package/dist/analytics/config.d.ts.map +1 -1
- package/dist/analytics/config.js +4 -1
- package/dist/analytics/config.js.map +1 -1
- package/dist/analytics/posthog-extensions.d.ts +19 -0
- package/dist/analytics/posthog-extensions.d.ts.map +1 -0
- package/dist/analytics/posthog-extensions.js +19 -0
- package/dist/analytics/posthog-extensions.js.map +1 -0
- package/dist/analytics/react.d.ts.map +1 -1
- package/dist/analytics/react.js +4 -2
- package/dist/analytics/react.js.map +1 -1
- package/dist/analytics/redact.d.ts.map +1 -1
- package/dist/analytics/redact.js +6 -1
- package/dist/analytics/redact.js.map +1 -1
- package/dist/house.css +19 -0
- package/package.json +17 -3
- package/src/account/data-contract.ts +112 -0
- package/src/account/index.ts +11 -0
- package/src/admin/access.ts +267 -0
- package/src/admin/audit.ts +238 -0
- package/src/admin/bootstrap.ts +220 -0
- package/src/admin/client-index.ts +19 -0
- package/src/admin/client.tsx +187 -0
- package/src/admin/index.ts +91 -0
- package/src/admin/proof.ts +155 -0
- package/src/admin/second-factor-index.ts +16 -0
- package/src/admin/second-factor.ts +403 -0
- package/src/admin/testing-index.ts +13 -0
- package/src/admin/testing.ts +299 -0
- package/src/admin/view-as.ts +511 -0
- package/src/ai/config-index.ts +40 -0
- package/src/ai/config.ts +176 -0
- package/src/ai/images.ts +18 -0
- package/src/ai/index.ts +21 -0
- package/src/ai/pricing.ts +107 -0
- package/src/ai/provider.ts +403 -0
- package/src/analytics/browser.ts +400 -0
- package/src/analytics/client-index.ts +12 -0
- package/src/analytics/config.ts +89 -0
- package/src/analytics/index.ts +17 -0
- package/src/analytics/ingest.ts +81 -0
- package/src/analytics/posthog-extensions.ts +19 -0
- package/src/analytics/react-index.ts +16 -0
- package/src/analytics/react.tsx +241 -0
- package/src/analytics/redact.ts +146 -0
- package/src/analytics/server-index.ts +17 -0
- package/src/analytics/server.ts +277 -0
- package/src/auth/index.ts +30 -0
- package/src/auth/second-factor-index.ts +16 -0
- package/src/auth/second-factor-next.ts +136 -0
- package/src/auth/second-factor-routes.ts +40 -0
- package/src/auth/second-factor.ts +226 -0
- package/src/auth/step-up-client-index.ts +13 -0
- package/src/auth/step-up-client.ts +23 -0
- package/src/auth/step-up-index.ts +19 -0
- package/src/auth/step-up-routes.ts +99 -0
- package/src/auth/step-up.ts +432 -0
- package/src/auth/two-factor-policy.ts +112 -0
- package/src/changelog/changelog.tsx +367 -0
- package/src/changelog/index.ts +12 -0
- package/src/editor/block-handle.tsx +312 -0
- package/src/editor/blocks.ts +169 -0
- package/src/editor/bubble-toolbar.tsx +208 -0
- package/src/editor/collapsible.ts +159 -0
- package/src/editor/content-index.ts +1 -0
- package/src/editor/content.tsx +343 -0
- package/src/editor/editor.tsx +333 -0
- package/src/editor/emoji-index.ts +1 -0
- package/src/editor/emoji-picker.tsx +114 -0
- package/src/editor/emoji.ts +436 -0
- package/src/editor/index.ts +6 -0
- package/src/editor/sections.ts +83 -0
- package/src/editor/suggestion-popup.tsx +136 -0
- package/src/editor/suggestions.ts +309 -0
- package/src/editor/ui.tsx +171 -0
- package/src/errors/error-shell.tsx +72 -0
- package/src/errors/global-error-shell.tsx +116 -0
- package/src/errors/index.ts +2 -0
- package/src/grid/columns.ts +48 -0
- package/src/grid/compare.ts +35 -0
- package/src/grid/hidden-columns.ts +95 -0
- package/src/grid/index.ts +27 -0
- package/src/grid/use-grid.ts +282 -0
- package/src/grid/views.ts +70 -0
- package/src/guides/guide-article.tsx +92 -0
- package/src/guides/guide-figure-zoom.tsx +533 -0
- package/src/guides/guide-figure.tsx +68 -0
- package/src/guides/guide-toc.tsx +133 -0
- package/src/guides/guides-landing.tsx +57 -0
- package/src/guides/guides-search.tsx +160 -0
- package/src/guides/guides-shell.tsx +60 -0
- package/src/guides/guides-sidebar.tsx +93 -0
- package/src/guides/index.ts +28 -0
- package/src/guides/library.ts +165 -0
- package/src/health/health.ts +115 -0
- package/src/health/index.ts +11 -0
- package/src/internal/cx.ts +4 -0
- package/src/internal/next-link.ts +23 -0
- package/src/jobs/counts.ts +151 -0
- package/src/jobs/cron-auth.ts +60 -0
- package/src/jobs/health.ts +315 -0
- package/src/jobs/idle.ts +86 -0
- package/src/jobs/index.ts +120 -0
- package/src/jobs/job-health-list.tsx +316 -0
- package/src/jobs/next-index.ts +4 -0
- package/src/jobs/next.ts +65 -0
- package/src/jobs/prisma-index.ts +12 -0
- package/src/jobs/prisma.ts +170 -0
- package/src/jobs/prune.ts +79 -0
- package/src/jobs/react-index.ts +35 -0
- package/src/jobs/registry.ts +189 -0
- package/src/jobs/scheduler.ts +437 -0
- package/src/jobs/store.ts +212 -0
- package/src/jobs/windows.ts +157 -0
- package/src/maintenance/core.ts +270 -0
- package/src/maintenance/gate.ts +171 -0
- package/src/maintenance/index.ts +40 -0
- package/src/maintenance/page.ts +76 -0
- package/src/maintenance/proxy.ts +88 -0
- package/src/maintenance/react-index.ts +7 -0
- package/src/maintenance/react.tsx +190 -0
- package/src/maintenance/route.ts +82 -0
- package/src/maintenance/unavailable.ts +61 -0
- package/src/markdown/figure.tsx +132 -0
- package/src/markdown/figures.ts +237 -0
- package/src/markdown/guide.tsx +536 -0
- package/src/markdown/index.ts +53 -0
- package/src/markdown/table-view.tsx +74 -0
- package/src/markdown/table.ts +90 -0
- package/src/password/common.ts +58 -0
- package/src/password/estimate-index.ts +18 -0
- package/src/password/estimate.ts +715 -0
- package/src/password/index.ts +40 -0
- package/src/password/password-input.tsx +116 -0
- package/src/password/password-strength.tsx +157 -0
- package/src/password/reveal.ts +151 -0
- package/src/rate-limit/better-auth.ts +94 -0
- package/src/rate-limit/index.ts +32 -0
- package/src/rate-limit/keys.ts +110 -0
- package/src/rate-limit/limiter.ts +276 -0
- package/src/rate-limit/prisma-index.ts +12 -0
- package/src/rate-limit/prisma.ts +157 -0
- package/src/rate-limit/store.ts +47 -0
- package/src/release/changelog.ts +364 -0
- package/src/release/index.ts +32 -0
- package/src/release/version.ts +64 -0
- package/src/setup-guide/bits.tsx +420 -0
- package/src/setup-guide/card.tsx +358 -0
- package/src/setup-guide/class-names.ts +144 -0
- package/src/setup-guide/context.tsx +239 -0
- package/src/setup-guide/guide.ts +271 -0
- package/src/setup-guide/index.ts +76 -0
- package/src/setup-guide/launcher.tsx +207 -0
- package/src/setup-guide/strip.tsx +127 -0
- package/src/styles/house.css +403 -0
- package/src/trail/index.ts +12 -0
- package/src/trail/rules.ts +84 -0
- package/src/trail/trail.tsx +367 -0
- package/src/ux/errors.ts +32 -0
- package/src/ux/feedback.tsx +41 -0
- package/src/ux/index.ts +44 -0
- package/src/ux/navigation-index.ts +16 -0
- package/src/ux/navigation-progress.tsx +270 -0
- package/src/ux/optimistic.ts +415 -0
- package/src/ux/use-action.ts +155 -0
- package/src/ux/use-optimistic-list.ts +227 -0
- package/src/ux/use-optimistic-value.ts +136 -0
- package/src/web-search/index.ts +13 -0
- package/src/web-search/providers.ts +177 -0
- package/src/web-search/types.ts +98 -0
- package/src/whats-new/body.tsx +190 -0
- package/src/whats-new/index.ts +43 -0
- package/src/whats-new/seen.ts +40 -0
- package/src/whats-new/select.ts +230 -0
- package/src/whats-new/use-whats-new.ts +109 -0
- package/src/wizard/index.ts +61 -0
- package/src/wizard/invalid.ts +152 -0
- package/src/wizard/react-hook-form-index.ts +11 -0
- package/src/wizard/rhf-adapter.ts +67 -0
- package/src/wizard/rules.ts +137 -0
- package/src/wizard/wizard.tsx +442 -0
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import { isReleaseVersion, releaseKind } from "./version.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The shape of a product changelog: numbered, dated releases, each with a
|
|
5
|
+
* headline, a one-sentence summary and its changes grouped by product area.
|
|
6
|
+
*
|
|
7
|
+
* The data is each app's own. What is shared is the shape, the rules that keep
|
|
8
|
+
* it honest (see `releaseHistoryProblems`) and the page that draws it — so a
|
|
9
|
+
* release reads the same way in every product, and the drift between an app's
|
|
10
|
+
* package.json and its public changelog is caught the same way everywhere.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** The kind of change — drives the coloured tag. `changed` means someone may need to act. */
|
|
14
|
+
export type ChangeType = "new" | "improved" | "changed" | "fixed";
|
|
15
|
+
|
|
16
|
+
export const CHANGE_TYPES: readonly ChangeType[] = ["new", "improved", "changed", "fixed"];
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Who may read a change. The full changelog is the team's: every change, in its
|
|
20
|
+
* own words. The public changelog (`publicChangelog`) leaves `internal` changes
|
|
21
|
+
* out — operations, infrastructure, limits and security mechanics a visitor has
|
|
22
|
+
* no use for and an attacker would — and says only that work happened behind
|
|
23
|
+
* the scenes. Omitted means `public`.
|
|
24
|
+
*/
|
|
25
|
+
export type ChangeAudience = "public" | "internal";
|
|
26
|
+
|
|
27
|
+
/** One change within a release section. */
|
|
28
|
+
export interface ChangelogChange {
|
|
29
|
+
type: ChangeType;
|
|
30
|
+
/** A short headline, sentence case, no full stop. Shown in bold, so it must carry the change alone. */
|
|
31
|
+
title: string;
|
|
32
|
+
/** One to three sentences: what a person can now do, and where. May use `**bold**` for UI labels. */
|
|
33
|
+
text: string;
|
|
34
|
+
/** `internal` keeps the change to the team's changelog. */
|
|
35
|
+
audience?: ChangeAudience;
|
|
36
|
+
/** The public changelog's wording, where `title` or `text` say more than the public should read. */
|
|
37
|
+
public?: { title?: string; text?: string };
|
|
38
|
+
/**
|
|
39
|
+
* Whether the "what's new" dialog (`@connextar/house/whats-new`) shows it: `true` puts it in whatever its type
|
|
40
|
+
* or heading, `false` keeps it out. Omitted lets the dialog's own rules decide. No effect on either changelog.
|
|
41
|
+
*/
|
|
42
|
+
highlight?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* The roles the "what's new" dialog shows it to, by the app's own role names. Omitted means everyone. No effect
|
|
45
|
+
* on either changelog — this says who it is _for_, not who may read it.
|
|
46
|
+
*/
|
|
47
|
+
roles?: string[];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Changes grouped under a product area, as people name it ("Invoices", "Fixes"). */
|
|
51
|
+
export interface ChangelogSection {
|
|
52
|
+
heading: string;
|
|
53
|
+
changes: ChangelogChange[];
|
|
54
|
+
/** `internal` keeps the whole section to the team's changelog. */
|
|
55
|
+
audience?: ChangeAudience;
|
|
56
|
+
/** The public changelog's heading, where the team's names something the public shouldn't see. */
|
|
57
|
+
public?: { heading?: string };
|
|
58
|
+
/** The roles the "what's new" dialog shows the section's changes to. Omitted means everyone. */
|
|
59
|
+
roles?: string[];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** A numbered, dated release. */
|
|
63
|
+
export interface ChangelogRelease {
|
|
64
|
+
/** MAJOR.MINOR.PATCH, no "v". */
|
|
65
|
+
version: string;
|
|
66
|
+
/** ISO calendar date (YYYY-MM-DD) the release was cut. */
|
|
67
|
+
date: string;
|
|
68
|
+
/** The headline — a few words. */
|
|
69
|
+
title: string;
|
|
70
|
+
/** One sentence on why the release matters. */
|
|
71
|
+
summary: string;
|
|
72
|
+
/** Most important first; "Fixes" and "Behind the scenes" last. */
|
|
73
|
+
sections: ChangelogSection[];
|
|
74
|
+
/**
|
|
75
|
+
* The release's public review. A release reaches the public changelog only
|
|
76
|
+
* once it has one: present — even `{}` — means someone has read the release
|
|
77
|
+
* for the public, marked what is internal and reworded what says too much.
|
|
78
|
+
* `title` and `summary` replace the team's where those do.
|
|
79
|
+
*/
|
|
80
|
+
public?: { title?: string; summary?: string };
|
|
81
|
+
/**
|
|
82
|
+
* The version released just before this one in the whole history. Only
|
|
83
|
+
* `publicChangelog` sets it: the public list is cut to the newest few and skips
|
|
84
|
+
* unreviewed releases, so the release under each one in that list isn't
|
|
85
|
+
* necessarily the one it followed. `<Changelog>` uses it to label the release
|
|
86
|
+
* major, minor or patch; never write it by hand.
|
|
87
|
+
*/
|
|
88
|
+
previousVersion?: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** What a release guard compares the changelog against. Parsed JSON, so this stays free of `node:fs`. */
|
|
92
|
+
export interface ReleaseManifest {
|
|
93
|
+
/** `package.json`. */
|
|
94
|
+
pkg: { version?: string };
|
|
95
|
+
/** `package-lock.json`, when the app has one. */
|
|
96
|
+
lock?: { version?: string; packages?: Record<string, { version?: string } | undefined> };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Everything wrong with a release history, as sentences — an empty list means
|
|
103
|
+
* it is sound. An app's guard test is one assertion:
|
|
104
|
+
*
|
|
105
|
+
* ```ts
|
|
106
|
+
* expect(releaseHistoryProblems(CHANGELOG, { pkg, lock })).toEqual([]);
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* A version lives in three places — package.json, its lockfile and the newest
|
|
110
|
+
* changelog release — and a bump that touches one and forgets another is the
|
|
111
|
+
* drift this exists to catch. Returning problems rather than throwing on the
|
|
112
|
+
* first means a broken history is reported whole.
|
|
113
|
+
*/
|
|
114
|
+
export function releaseHistoryProblems(changelog: readonly ChangelogRelease[], manifest?: ReleaseManifest): string[] {
|
|
115
|
+
const problems: string[] = [];
|
|
116
|
+
const newest = changelog[0];
|
|
117
|
+
|
|
118
|
+
if (!newest) return ["the changelog has no releases"];
|
|
119
|
+
|
|
120
|
+
if (manifest) {
|
|
121
|
+
const declared = manifest.pkg.version;
|
|
122
|
+
if (declared !== newest.version) {
|
|
123
|
+
problems.push(`package.json declares ${declared ?? "no version"} but the newest release is ${newest.version}`);
|
|
124
|
+
}
|
|
125
|
+
if (manifest.lock) {
|
|
126
|
+
if (manifest.lock.version !== declared) {
|
|
127
|
+
problems.push(`package-lock.json declares ${manifest.lock.version ?? "no version"}, package.json ${declared}`);
|
|
128
|
+
}
|
|
129
|
+
const root = manifest.lock.packages?.[""]?.version;
|
|
130
|
+
if (manifest.lock.packages && root !== declared) {
|
|
131
|
+
problems.push(`package-lock.json's root package declares ${root ?? "no version"}, package.json ${declared}`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
changelog.forEach((release, i) => {
|
|
137
|
+
const label = release.version || `release #${i + 1}`;
|
|
138
|
+
|
|
139
|
+
if (!isReleaseVersion(release.version)) {
|
|
140
|
+
problems.push(`${label} is not MAJOR.MINOR.PATCH`);
|
|
141
|
+
}
|
|
142
|
+
if (!ISO_DATE.test(release.date) || Number.isNaN(new Date(`${release.date}T00:00:00Z`).getTime())) {
|
|
143
|
+
problems.push(`${label} has date "${release.date}", not YYYY-MM-DD`);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const older = changelog[i + 1];
|
|
147
|
+
if (older && isReleaseVersion(release.version) && isReleaseVersion(older.version)) {
|
|
148
|
+
if (releaseKind(older.version, release.version) === null) {
|
|
149
|
+
problems.push(`${older.version} → ${release.version} is not one step (newest first, no skipped numbers)`);
|
|
150
|
+
}
|
|
151
|
+
if (ISO_DATE.test(release.date) && ISO_DATE.test(older.date) && release.date < older.date) {
|
|
152
|
+
problems.push(`${release.version} is dated ${release.date}, before ${older.version} (${older.date})`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (!release.title.trim()) problems.push(`${label} has no title`);
|
|
157
|
+
if (!release.summary.trim()) problems.push(`${label} has no summary`);
|
|
158
|
+
if (release.sections.length === 0) problems.push(`${label} has no sections`);
|
|
159
|
+
|
|
160
|
+
const headings = release.sections.map((section) => section.heading);
|
|
161
|
+
if (new Set(headings).size !== headings.length) problems.push(`${label} repeats a section heading`);
|
|
162
|
+
|
|
163
|
+
for (const section of release.sections) {
|
|
164
|
+
if (!section.heading.trim()) problems.push(`${label} has a section with no heading`);
|
|
165
|
+
if (section.changes.length === 0) problems.push(`${label} · ${section.heading} has no changes`);
|
|
166
|
+
const sectionRoles = rolesProblem(section.roles);
|
|
167
|
+
if (sectionRoles) problems.push(`${label} · ${section.heading} ${sectionRoles}`);
|
|
168
|
+
for (const change of section.changes) {
|
|
169
|
+
if (!CHANGE_TYPES.includes(change.type)) {
|
|
170
|
+
problems.push(`${label} · ${section.heading} has a change of unknown type "${String(change.type)}"`);
|
|
171
|
+
}
|
|
172
|
+
if (!change.title.trim()) problems.push(`${label} · ${section.heading} has a change with no title`);
|
|
173
|
+
if (!change.text.trim()) problems.push(`${label} · ${section.heading} · "${change.title}" has no text`);
|
|
174
|
+
const where = `${label} · ${section.heading} · "${change.title}"`;
|
|
175
|
+
if (change.highlight !== undefined && typeof change.highlight !== "boolean") {
|
|
176
|
+
problems.push(`${where} has highlight "${String(change.highlight)}", not true or false`);
|
|
177
|
+
} else if (change.highlight === true && isInternalChange(change, section)) {
|
|
178
|
+
problems.push(`${where} is internal, so it can't be a highlight`);
|
|
179
|
+
}
|
|
180
|
+
const changeRoles = rolesProblem(change.roles);
|
|
181
|
+
if (changeRoles) problems.push(`${where} ${changeRoles}`);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
return problems;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** What is wrong with a `roles` list, finishing the sentence "… <problem>", or null when it's sound or absent. */
|
|
190
|
+
function rolesProblem(roles: unknown): string | null {
|
|
191
|
+
if (roles === undefined) return null;
|
|
192
|
+
if (!Array.isArray(roles)) return "has roles that aren't a list";
|
|
193
|
+
if (roles.length === 0) return "has an empty roles list — leave it out to mean everyone";
|
|
194
|
+
if (roles.some((role) => typeof role !== "string" || !role.trim())) return "has a blank role";
|
|
195
|
+
if (new Set(roles).size !== roles.length) return "repeats a role";
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** A fragment id without dots, so it never needs escaping as a selector: `v0-25-0`. */
|
|
200
|
+
export function releaseAnchor(version: string): string {
|
|
201
|
+
return `v${version.replaceAll(".", "-")}`;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** Format an ISO date as "29 August 2026" (or the locale's equivalent), in UTC so it never shifts a day. */
|
|
205
|
+
export function formatReleaseDate(iso: string, locale = "en-GB"): string {
|
|
206
|
+
return new Intl.DateTimeFormat(locale, { day: "numeric", month: "long", year: "numeric", timeZone: "UTC" }).format(
|
|
207
|
+
new Date(`${iso}T00:00:00Z`),
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export function countChanges(release: ChangelogRelease): number {
|
|
212
|
+
return release.sections.reduce((n, section) => n + section.changes.length, 0);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** Whether a change stays out of the public changelog, by its own audience or its section's. */
|
|
216
|
+
export function isInternalChange(change: ChangelogChange, section?: ChangelogSection): boolean {
|
|
217
|
+
return change.audience === "internal" || section?.audience === "internal";
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** A change in the public's words: its own `public` wording where it has some, the team's where not. */
|
|
221
|
+
export function publicWording(change: ChangelogChange): { title: string; text: string } {
|
|
222
|
+
return { title: change.public?.title ?? change.title, text: change.public?.text ?? change.text };
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** A section's heading as the public reads it. */
|
|
226
|
+
export function publicHeading(section: ChangelogSection): string {
|
|
227
|
+
return section.public?.heading ?? section.heading;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** What the public changelog says in place of the changes it leaves out — one line a release. */
|
|
231
|
+
export interface BehindTheScenesNote {
|
|
232
|
+
heading: string;
|
|
233
|
+
title: string;
|
|
234
|
+
text: string;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export const DEFAULT_BEHIND_THE_SCENES: BehindTheScenesNote = {
|
|
238
|
+
heading: "Behind the scenes",
|
|
239
|
+
title: "Reliability and security",
|
|
240
|
+
text: "Work behind the scenes to keep everything running smoothly and securely.",
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
export interface PublicChangelogOptions {
|
|
244
|
+
/** How many of the newest reviewed releases to show. Defaults to 5. */
|
|
245
|
+
limit?: number;
|
|
246
|
+
/** The line that stands in for internal changes. */
|
|
247
|
+
behindTheScenes?: Partial<BehindTheScenesNote>;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** How many releases a public changelog shows unless told otherwise. */
|
|
251
|
+
export const PUBLIC_RELEASE_LIMIT = 5;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* One release as the public may read it, or `null` when it hasn't had its
|
|
255
|
+
* public review. Internal sections and changes are dropped; the reworded
|
|
256
|
+
* headline, summary, headings and changes replace the team's; and when
|
|
257
|
+
* anything was dropped, one generic line under "Behind the scenes" says so.
|
|
258
|
+
* The result is a fresh object with no audience or public fields, so the
|
|
259
|
+
* team's wording of a redacted change cannot reach the page by accident.
|
|
260
|
+
*/
|
|
261
|
+
export function publicRelease(
|
|
262
|
+
release: ChangelogRelease,
|
|
263
|
+
behindTheScenes: Partial<BehindTheScenesNote> = {},
|
|
264
|
+
): ChangelogRelease | null {
|
|
265
|
+
if (!release.public) return null;
|
|
266
|
+
const note = { ...DEFAULT_BEHIND_THE_SCENES, ...behindTheScenes };
|
|
267
|
+
const byHeading = new Map<string, ChangelogChange[]>();
|
|
268
|
+
let redacted = false;
|
|
269
|
+
|
|
270
|
+
for (const section of release.sections) {
|
|
271
|
+
const changes: ChangelogChange[] = [];
|
|
272
|
+
for (const change of section.changes) {
|
|
273
|
+
if (isInternalChange(change, section)) {
|
|
274
|
+
redacted = true;
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
changes.push({ type: change.type, ...publicWording(change) });
|
|
278
|
+
}
|
|
279
|
+
if (changes.length === 0) continue;
|
|
280
|
+
const heading = publicHeading(section);
|
|
281
|
+
byHeading.set(heading, [...(byHeading.get(heading) ?? []), ...changes]);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
if (redacted) {
|
|
285
|
+
const existing = byHeading.get(note.heading) ?? [];
|
|
286
|
+
byHeading.delete(note.heading);
|
|
287
|
+
const generic: ChangelogChange = { type: "improved", title: note.title, text: note.text };
|
|
288
|
+
byHeading.set(note.heading, existing.some((c) => c.title === note.title) ? existing : [...existing, generic]);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return {
|
|
292
|
+
version: release.version,
|
|
293
|
+
date: release.date,
|
|
294
|
+
title: release.public.title ?? release.title,
|
|
295
|
+
summary: release.public.summary ?? release.summary,
|
|
296
|
+
sections: [...byHeading].map(([heading, changes]) => ({ heading, changes })),
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* The public changelog: the newest reviewed releases (5 by default), each as
|
|
302
|
+
* `publicRelease` draws it. A release not yet reviewed is left out rather than
|
|
303
|
+
* shown in the team's words, so forgetting the review hides a release instead
|
|
304
|
+
* of leaking one; `publicChangelogProblems` is the test that catches the
|
|
305
|
+
* forgetting.
|
|
306
|
+
*/
|
|
307
|
+
export function publicChangelog(
|
|
308
|
+
releases: readonly ChangelogRelease[],
|
|
309
|
+
{ limit = PUBLIC_RELEASE_LIMIT, behindTheScenes }: PublicChangelogOptions = {},
|
|
310
|
+
): ChangelogRelease[] {
|
|
311
|
+
const shown: ChangelogRelease[] = [];
|
|
312
|
+
for (const [i, release] of releases.entries()) {
|
|
313
|
+
if (shown.length >= limit) break;
|
|
314
|
+
const visible = publicRelease(release, behindTheScenes);
|
|
315
|
+
if (!visible) continue;
|
|
316
|
+
// Carry the true predecessor, so the oldest release shown still gets its kind.
|
|
317
|
+
const previous = releases[i + 1];
|
|
318
|
+
shown.push(previous ? { ...visible, previousVersion: previous.version } : visible);
|
|
319
|
+
}
|
|
320
|
+
return shown;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Everything wrong with the public side of a release history, as sentences.
|
|
325
|
+
* The newest `reviewed` releases (5 by default — the public window) must each
|
|
326
|
+
* have their public review; a reworded field can't be blank; and a release
|
|
327
|
+
* whose every change is internal must give its own public headline and
|
|
328
|
+
* summary, because its team ones are about the work being hidden. An app's
|
|
329
|
+
* release guard asserts this is empty beside `releaseHistoryProblems`.
|
|
330
|
+
*/
|
|
331
|
+
export function publicChangelogProblems(
|
|
332
|
+
changelog: readonly ChangelogRelease[],
|
|
333
|
+
{ reviewed = PUBLIC_RELEASE_LIMIT }: { reviewed?: number } = {},
|
|
334
|
+
): string[] {
|
|
335
|
+
const problems: string[] = [];
|
|
336
|
+
const blank = (value: string | undefined) => value !== undefined && !value.trim();
|
|
337
|
+
|
|
338
|
+
changelog.forEach((release, i) => {
|
|
339
|
+
const label = release.version || `release #${i + 1}`;
|
|
340
|
+
if (!release.public) {
|
|
341
|
+
if (i < reviewed) problems.push(`${label} has not been reviewed for the public changelog`);
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
if (blank(release.public.title)) problems.push(`${label} has a blank public title`);
|
|
345
|
+
if (blank(release.public.summary)) problems.push(`${label} has a blank public summary`);
|
|
346
|
+
|
|
347
|
+
const changes = release.sections.flatMap((section) => section.changes.map((change) => ({ section, change })));
|
|
348
|
+
const allInternal = changes.length > 0 && changes.every(({ section, change }) => isInternalChange(change, section));
|
|
349
|
+
if (allInternal && (!release.public.title || !release.public.summary)) {
|
|
350
|
+
problems.push(`${label} is all internal, so it needs its own public title and summary`);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
for (const section of release.sections) {
|
|
354
|
+
if (blank(section.public?.heading)) problems.push(`${label} · ${section.heading} has a blank public heading`);
|
|
355
|
+
for (const change of section.changes) {
|
|
356
|
+
if (blank(change.public?.title) || blank(change.public?.text)) {
|
|
357
|
+
problems.push(`${label} · ${section.heading} · "${change.title}" has blank public wording`);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
return problems;
|
|
364
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export {
|
|
2
|
+
compareVersions,
|
|
3
|
+
isReleaseVersion,
|
|
4
|
+
nextVersion,
|
|
5
|
+
parseVersion,
|
|
6
|
+
releaseKind,
|
|
7
|
+
type ReleaseKind,
|
|
8
|
+
type Version,
|
|
9
|
+
} from "./version.js";
|
|
10
|
+
export {
|
|
11
|
+
CHANGE_TYPES,
|
|
12
|
+
countChanges,
|
|
13
|
+
DEFAULT_BEHIND_THE_SCENES,
|
|
14
|
+
formatReleaseDate,
|
|
15
|
+
isInternalChange,
|
|
16
|
+
PUBLIC_RELEASE_LIMIT,
|
|
17
|
+
publicChangelog,
|
|
18
|
+
publicChangelogProblems,
|
|
19
|
+
publicHeading,
|
|
20
|
+
publicRelease,
|
|
21
|
+
publicWording,
|
|
22
|
+
releaseAnchor,
|
|
23
|
+
releaseHistoryProblems,
|
|
24
|
+
type BehindTheScenesNote,
|
|
25
|
+
type ChangeAudience,
|
|
26
|
+
type ChangeType,
|
|
27
|
+
type ChangelogChange,
|
|
28
|
+
type ChangelogRelease,
|
|
29
|
+
type ChangelogSection,
|
|
30
|
+
type PublicChangelogOptions,
|
|
31
|
+
type ReleaseManifest,
|
|
32
|
+
} from "./changelog.js";
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Semantic versions for an app's releases.
|
|
3
|
+
*
|
|
4
|
+
* The rules for choosing a version live in docs/ReleaseProcess.md; this file
|
|
5
|
+
* only knows the arithmetic, so a changelog page and a release guard test read
|
|
6
|
+
* versions the same way.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export type ReleaseKind = "major" | "minor" | "patch";
|
|
10
|
+
|
|
11
|
+
export interface Version {
|
|
12
|
+
major: number;
|
|
13
|
+
minor: number;
|
|
14
|
+
patch: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** MAJOR.MINOR.PATCH with no leading zeros, no "v" and no pre-release suffix. */
|
|
18
|
+
const RELEASE_VERSION = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
|
|
19
|
+
|
|
20
|
+
export function parseVersion(value: string): Version {
|
|
21
|
+
const match = RELEASE_VERSION.exec(value);
|
|
22
|
+
if (!match) throw new Error(`Not a release version (MAJOR.MINOR.PATCH): "${value}"`);
|
|
23
|
+
return { major: Number(match[1]), minor: Number(match[2]), patch: Number(match[3]) };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function isReleaseVersion(value: string): boolean {
|
|
27
|
+
return RELEASE_VERSION.test(value);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Negative when `a` is older than `b`, positive when newer, 0 when equal. */
|
|
31
|
+
export function compareVersions(a: string, b: string): number {
|
|
32
|
+
const x = parseVersion(a);
|
|
33
|
+
const y = parseVersion(b);
|
|
34
|
+
return x.major - y.major || x.minor - y.minor || x.patch - y.patch;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* What kind of release `next` is after `previous` — or null when it is not
|
|
39
|
+
* exactly one step on (a skipped number, a reset that isn't to zero, or going
|
|
40
|
+
* backwards). One step at a time is what makes every version findable.
|
|
41
|
+
*/
|
|
42
|
+
export function releaseKind(previous: string, next: string): ReleaseKind | null {
|
|
43
|
+
const p = parseVersion(previous);
|
|
44
|
+
const n = parseVersion(next);
|
|
45
|
+
if (n.major === p.major + 1 && n.minor === 0 && n.patch === 0) return "major";
|
|
46
|
+
if (n.major === p.major && n.minor === p.minor + 1 && n.patch === 0) return "minor";
|
|
47
|
+
if (n.major === p.major && n.minor === p.minor && n.patch === p.patch + 1) return "patch";
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The version after `current` for a change of the given class.
|
|
53
|
+
*
|
|
54
|
+
* Before 1.0.0 a MAJOR-class change bumps MINOR — semver treats 0.x as a period
|
|
55
|
+
* when anything may change, and leaving it is the owner's call, never a side
|
|
56
|
+
* effect of a change set. The release must then carry a `changed` entry saying
|
|
57
|
+
* what people need to do.
|
|
58
|
+
*/
|
|
59
|
+
export function nextVersion(current: string, change: ReleaseKind): string {
|
|
60
|
+
const { major, minor, patch } = parseVersion(current);
|
|
61
|
+
if (change === "patch") return `${major}.${minor}.${patch + 1}`;
|
|
62
|
+
if (change === "minor" || major === 0) return `${major}.${minor + 1}.0`;
|
|
63
|
+
return `${major + 1}.0.0`;
|
|
64
|
+
}
|