Compare commits
16
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
58cadbf472 | ||
|
|
f6a536ad64 | ||
|
|
05d808b74c | ||
|
|
20a23a3ba8 | ||
|
|
9c9c96dd2c | ||
|
|
f73761f956 | ||
|
|
62441ad437 | ||
|
|
7814a64cf7 | ||
|
|
679f61febf | ||
|
|
723bb15a5e | ||
|
|
dd0e5e17b3 | ||
|
|
7216035e49 | ||
|
|
9bf1739734 | ||
|
|
0b99686ca7 | ||
|
|
6ffad24db1 | ||
|
|
268c9cde88 |
@@ -2,6 +2,29 @@
|
||||
|
||||
Each package and app has its own section and its own tags (`contracts@1.0.0`, `accounts@1.0.0`, …).
|
||||
|
||||
## accounts@1.7.1 + website@1.0.2 + events@3.7.1 - 2026-11-26
|
||||
|
||||
Found installing the Website for cross-demo2. Details in each app's CHANGELOG.md. No migrations.
|
||||
|
||||
- **Linking right after an install** (all three): a connect involving an install that isn't in the
|
||||
cached copy of the Hub's list yet asks the Hub for a fresh list (one heartbeat, at most once a
|
||||
minute) instead of refusing. Before, a new product and its siblings only learned of each other at
|
||||
their 15-minute heartbeats, so a new Website's admin couldn't sign in for up to 30 minutes.
|
||||
- **Accounts 1.7.1:** also a heartbeat on every start.
|
||||
- **Website 1.0.2:** opening `/admin` without a link to Accounts links on the spot; the problem page
|
||||
says "not linked yet" (`ACCOUNTS_NOT_LINKED`) instead of "can't reach your sign-in". Preview no
|
||||
longer redirects to the server's own `http://localhost:<web port>` (relative redirects).
|
||||
- **Events 3.7.1:** a new Website can connect for the event feed straight away.
|
||||
|
||||
## website@1.0.1 + crosscode script - 2026-11-26
|
||||
|
||||
Details in `apps/website/CHANGELOG.md`.
|
||||
|
||||
- **Website 1.0.1:** the messages' YouTube thumbnails are served from the site
|
||||
(`/api/thumbnails/<id>.jpg`), so visitors ask nothing of YouTube until they press play; the
|
||||
Calendar events' dates read "Sun · November", not "Sun (month: November)". No migration.
|
||||
- **crosscode script:** a Website's export leaves out `uploads/.thumbnails` (the kept thumbnails).
|
||||
|
||||
## contracts@1.18.0 - 2026-11-25
|
||||
|
||||
"Get more storage" for the Church Website (WEBSITE-1.0-PLAN §10, decision 12), with Hub 2.22.0.
|
||||
|
||||
@@ -1,5 +1,21 @@
|
||||
# Changelog — Accounts
|
||||
|
||||
## [1.7.1] - 2026-11-26
|
||||
|
||||
No migrations, no new settings.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **A product installed after Accounts' last heartbeat links straight away.** Accounts accepted a
|
||||
connect only from installs in its cached copy of the Hub's list, which it refreshed every 15
|
||||
minutes. A new Church Website (or Events) was refused ("doesn't know that install yet") and tried
|
||||
again only at its own next heartbeat, so its admin couldn't sign in for up to 30 minutes after the
|
||||
install (found on cross-demo2). Now, for an install it doesn't know, Accounts sends the Hub a
|
||||
heartbeat to get a fresh list and looks again (at most one such heartbeat a minute, so unknown
|
||||
installs can't make it call the Hub more often). The same applies when an Accounts admin connects.
|
||||
- **A heartbeat on every start**, not only the first: after a restart the list of the church's
|
||||
products is fresh at once.
|
||||
|
||||
## [1.7.0] - 2026-11-24
|
||||
|
||||
Needs contracts 1.17.0. The first part of the Church Website 1.0.0 (WEBSITE-1.0-PLAN §11).
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
What each version changes for the church, in plain language (read by the Hub like Cross Events'
|
||||
WHATS-NEW.md; a section shows once its version is tagged).
|
||||
|
||||
## 1.7.1
|
||||
|
||||
- **New sites connect to your sign-in straight away.** A Church Website or Cross Events installed
|
||||
for your church can be signed in to within moments, instead of after up to half an hour.
|
||||
|
||||
## 1.7.0
|
||||
|
||||
- **Choose your church's fonts and corners.** Admin → Church profile → **Brand style** has 8 font
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@crosscode/accounts-backend",
|
||||
"version": "1.7.0",
|
||||
"version": "1.7.1",
|
||||
"description": "Cross Code Accounts: the church's sign-in (OpenID Connect provider), account pages API and admin API",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
|
||||
@@ -23,8 +23,10 @@ async function main() {
|
||||
const server = app.listen(config.port, () => console.log(`[accounts] Listening on ${config.port} (${config.publicUrl}).`));
|
||||
const stopJobs = await startJobs(ctx, url);
|
||||
|
||||
// 1.7.1: a heartbeat on every start, not only the first (as the Website), so the list of the
|
||||
// church's products is fresh after a restart.
|
||||
connectFromEnv(ctx).then((r) => {
|
||||
if (r.connected) heartbeat(ctx).catch(() => {});
|
||||
if (r.connected || r.reason === 'already') heartbeat(ctx).catch(() => {});
|
||||
}).catch(() => {});
|
||||
|
||||
const stop = async () => {
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
import { newLinkNonce, newLinkSecret, signLink, verifyLink } from '@crosscode/contracts/signing';
|
||||
import type { Request } from 'express';
|
||||
import type { Ctx } from '../context.js';
|
||||
import { heartbeat } from '../hub/client.js';
|
||||
import { audit, clientIp } from '../lib/audit.js';
|
||||
import { callSibling, LinkCallError, siblingUrl } from './http.js';
|
||||
import { keyPair, listedProduct } from './store.js';
|
||||
@@ -24,6 +25,29 @@ export class LinkError extends Error {
|
||||
/** Products that sign people in through Accounts. */
|
||||
const CLIENT_PRODUCTS = new Set(['events', 'website', 'app']);
|
||||
const NONCE_KEEP_MS = 60 * 60 * 1000;
|
||||
const REFRESH_EVERY_MS = 60 * 1000;
|
||||
|
||||
const refreshes = new WeakMap<Ctx, { at: number; run: Promise<unknown> }>();
|
||||
|
||||
/**
|
||||
* 1.7.1: the install as the Hub listed it. If the cached list doesn't have it yet (it was installed
|
||||
* after Accounts' last heartbeat), Accounts asks the Hub for a fresh list with a heartbeat and looks
|
||||
* again, so a new Website links straight away instead of up to 30 minutes later. There's at most
|
||||
* one such heartbeat a minute, so a message from an unknown install can't make Accounts call the Hub
|
||||
* more often than that.
|
||||
*/
|
||||
async function listedOrRefreshed(ctx: Ctx, installId: string) {
|
||||
const found = await listedProduct(ctx, installId);
|
||||
if (found) return found;
|
||||
const now = ctx.now().getTime();
|
||||
let r = refreshes.get(ctx);
|
||||
if (!r || now - r.at >= REFRESH_EVERY_MS) {
|
||||
r = { at: now, run: heartbeat(ctx).catch((e) => console.warn('[links] Asking the Hub for a fresh list failed:', (e as Error).message)) };
|
||||
refreshes.set(ctx, r);
|
||||
}
|
||||
await r.run;
|
||||
return listedProduct(ctx, installId);
|
||||
}
|
||||
|
||||
async function self(ctx: Ctx) {
|
||||
const installId = await ctx.settings.get('hub_install_id');
|
||||
@@ -55,8 +79,8 @@ const logLink = (ctx: Ctx, action: string, link: { installId: string; product: s
|
||||
audit(ctx, { actorId: actor?.id ?? null, actorRole: actor?.role ?? 'linked_product', action, targetType: 'product_link', targetId: link.installId, metadata: { product: link.product, by }, ip: clientIp(req) });
|
||||
|
||||
export async function connectTo(ctx: Ctx, installId: string, actor: { id: string; role: string }, req?: Request) {
|
||||
const sibling = await listedProduct(ctx, installId);
|
||||
if (!sibling || !CLIENT_PRODUCTS.has(sibling.product)) throw new LinkError('That product isn\'t in the list the Hub gave Accounts. Wait for the next Hub heartbeat (up to 15 minutes).', 'NOT_LINKED', 404);
|
||||
const sibling = await listedOrRefreshed(ctx, installId);
|
||||
if (!sibling || !CLIENT_PRODUCTS.has(sibling.product)) throw new LinkError('The Hub doesn\'t list that product for this church.', 'NOT_LINKED', 404);
|
||||
const me = await self(ctx);
|
||||
const secret = newLinkSecret();
|
||||
const message = signLink<Omit<LinkConnect, 'signature'>>({
|
||||
@@ -86,9 +110,9 @@ export async function acceptConnect(ctx: Ctx, body: unknown, req?: Request): Pro
|
||||
const m = parsed.data;
|
||||
const me = await self(ctx);
|
||||
if (m.to.installId !== me.installId) throw new LinkError('That message is for another install.', 'WRONG_INSTALL', 400);
|
||||
const sibling = await listedProduct(ctx, m.from.installId);
|
||||
const sibling = await listedOrRefreshed(ctx, m.from.installId);
|
||||
if (!sibling || sibling.product !== m.from.product || !CLIENT_PRODUCTS.has(sibling.product)) {
|
||||
throw new LinkError('Accounts doesn\'t know that install yet: the Hub lists the church\'s products in its next heartbeat (up to 15 minutes).', 'NOT_LINKED', 403);
|
||||
throw new LinkError('The Hub doesn\'t list that install for this church (Accounts asks it again at most once a minute).', 'NOT_LINKED', 403);
|
||||
}
|
||||
const check = verifyLink(m as unknown as Record<string, unknown>, sibling.publicKey, { now: ctx.now() });
|
||||
if (!check.ok) throw new LinkError(check.code === 'STALE_REQUEST' ? 'The message is too old, or a clock is wrong.' : 'The signature doesn\'t match the key the Hub listed.', check.code, 401);
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// signed back-channel calls, deletion with a product that says "not yet", "download my data", the
|
||||
// church profile, Connect, and admin and setup rules.
|
||||
import assert from 'node:assert/strict';
|
||||
import http from 'node:http';
|
||||
import type { AddressInfo } from 'node:net';
|
||||
import { after, before, beforeEach, describe, test } from 'node:test';
|
||||
import { churchSchema, IDENTITY_SCHEMA, LINK_SCHEMA, OIDC_CLIENT_PATHS } from '@crosscode/contracts';
|
||||
import { generateEd25519, ed25519PublicToPem, newLinkNonce, newLinkSecret, signLink } from '@crosscode/contracts/signing';
|
||||
@@ -156,6 +158,44 @@ describe('Connect from a product', () => {
|
||||
const client = await h.provider.Client.find(APP_ID);
|
||||
assert.deepEqual(client?.redirectUris, ['http://127.0.0.1:7/api/auth/callback']);
|
||||
});
|
||||
|
||||
test('1.7.1: a product installed after the last heartbeat is found in a fresh list from the Hub, at most once a minute', async () => {
|
||||
let clock = new Date('2026-11-26T15:00:00Z');
|
||||
const own = await startHarness({ now: () => clock });
|
||||
const appKey = generateEd25519();
|
||||
const NEW_ID = '5c1d7e2f-8a3b-4c4d-9e5f-6a7b8c9d0e1f';
|
||||
const listed = { product: 'website', installId: NEW_ID, url: 'http://127.0.0.1:7', publicKey: ed25519PublicToPem(appKey.publicKey) };
|
||||
// A Hub whose list has the new Website; Accounts' cached list doesn't yet.
|
||||
const hubCalls: string[] = [];
|
||||
const hub = http.createServer((req, res) => {
|
||||
hubCalls.push(String(req.url));
|
||||
res.setHeader('content-type', 'application/json');
|
||||
res.end(JSON.stringify({ ok: true, licence: '', linkedProducts: [listed] }));
|
||||
});
|
||||
await new Promise<void>((r) => hub.listen(0, '127.0.0.1', () => r()));
|
||||
try {
|
||||
own.ctx.config.hubUrl = `http://127.0.0.1:${(hub.address() as AddressInfo).port}`;
|
||||
await own.ctx.settings.setMany({ hub_install_secret: 'secret', hub_linked_products: '[]' });
|
||||
const msg = (installId: string) => signLink({ schema: LINK_SCHEMA, type: 'link.connect', from: { product: 'website', installId, url: 'http://127.0.0.1:7' }, to: { installId: ACCOUNTS_ID }, secret: newLinkSecret(), issuedAt: clock.toISOString(), nonce: newLinkNonce() }, appKey.privateKeyPem);
|
||||
const send = (installId: string) => fetch(`${own.publicUrl}/api/links/v1/connect`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(msg(installId)) });
|
||||
|
||||
assert.equal((await send(NEW_ID)).status, 200, 'linked at once');
|
||||
assert.deepEqual(hubCalls, ['/api/installs/heartbeat']);
|
||||
assert.equal(await own.db.productLink.count({ where: { installId: NEW_ID } }), 1);
|
||||
|
||||
// An install the Hub doesn't list: refused, and within the minute the Hub isn't asked again.
|
||||
const UNKNOWN = '7e3f9a4b-0c5d-4e6f-8a7b-9c0d1e2f3a4b';
|
||||
assert.equal((await send(UNKNOWN)).status, 403);
|
||||
assert.equal((await send(UNKNOWN)).status, 403);
|
||||
assert.equal(hubCalls.length, 1);
|
||||
clock = new Date(clock.getTime() + 61_000);
|
||||
assert.equal((await send(UNKNOWN)).status, 403);
|
||||
assert.equal(hubCalls.length, 2);
|
||||
} finally {
|
||||
await new Promise((r) => hub.close(r));
|
||||
await own.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('admin and setup', () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@crosscode/accounts-frontend",
|
||||
"version": "1.7.0",
|
||||
"version": "1.7.1",
|
||||
"private": true,
|
||||
"description": "Cross Code Accounts: the church's sign-in pages, the account page and admin",
|
||||
"scripts": {
|
||||
|
||||
@@ -5,6 +5,19 @@ All notable changes to this project are documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project follows [Semantic Versioning](https://semver.org/).
|
||||
|
||||
## [3.7.1] - 2026-11-26
|
||||
|
||||
No migrations, no new settings.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **A product installed after this site's last heartbeat can connect straight away.** A connect
|
||||
(in either direction) was refused while the other install wasn't in the cached copy of the Hub's
|
||||
list, refreshed every 15 minutes. So a new Church Website couldn't connect for the event feed
|
||||
until then. Now, for an install it doesn't know, the site sends the Hub a heartbeat to get a fresh
|
||||
list and looks again (at most one such heartbeat a minute, so unknown installs can't make it call
|
||||
the Hub more often). Same change as Accounts 1.7.1 and Website 1.0.2.
|
||||
|
||||
## [3.7.0] - 2026-11-24
|
||||
|
||||
The church's look from its Accounts (docs/WEBSITE-1.0-PLAN.md §9). **Requires Accounts 1.7.0**
|
||||
|
||||
@@ -12,6 +12,11 @@ Write for church admins, not developers: no environment variables, endpoints or
|
||||
developer log is CHANGELOG.md. A tagged version without a section here shows "No details given".
|
||||
-->
|
||||
|
||||
## 3.7.1
|
||||
|
||||
- **Connecting to your new Church Website works straight away**, so its events page can show your
|
||||
Cross Events events as soon as it's installed, instead of after up to 15 minutes.
|
||||
|
||||
## 3.7.0 — requires accounts 1.7.0
|
||||
|
||||
- **Your public pages look like the rest of your church's sites.** With sign-in through your
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@crosscode/events-backend",
|
||||
"version": "3.7.0",
|
||||
"version": "3.7.1",
|
||||
"description": "Event Management System Backend",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -35,6 +35,34 @@ export class LinkError extends Error {
|
||||
}
|
||||
|
||||
const NONCE_KEEP_MS = 60 * 60 * 1000;
|
||||
const REFRESH_EVERY_MS = 60 * 1000;
|
||||
|
||||
let refresh: { at: number; run: Promise<unknown> } | null = null;
|
||||
|
||||
/** For tests. */
|
||||
export function forgetRefresh(): void {
|
||||
refresh = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 3.7.1: the install as the Hub listed it. If the cached list doesn't have it yet (it was installed
|
||||
* after this site's last heartbeat, like a new Church Website), the site asks the Hub for a fresh
|
||||
* list with a heartbeat and looks again, instead of refusing for up to 15 minutes. There's at most
|
||||
* one such heartbeat a minute, so a message from an unknown install can't make this site call the
|
||||
* Hub more often than that.
|
||||
*/
|
||||
async function listedOrRefreshed(installId: string, now: Date) {
|
||||
const found = await listedProduct(installId);
|
||||
if (found) return found;
|
||||
if (!refresh || now.getTime() - refresh.at >= REFRESH_EVERY_MS) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports -- CommonJS, and hub/client.js needs this module's siblings
|
||||
const run = Promise.resolve().then(() => require('../hub/client').heartbeat())
|
||||
.catch((e: Error) => console.warn('[links] Asking the Hub for a fresh list failed:', e?.message || e));
|
||||
refresh = { at: now.getTime(), run };
|
||||
}
|
||||
await refresh.run;
|
||||
return listedProduct(installId);
|
||||
}
|
||||
|
||||
type Self = { installId: string; url: string; privateKeyPem: string };
|
||||
|
||||
@@ -81,8 +109,8 @@ async function saveLink(sibling: hub.LinkedProduct, secret: string, connectedByI
|
||||
// ─── This site connects (an admin clicked Connect) ─────────────────────────────
|
||||
|
||||
export async function connectTo(installId: string, actor: { id: string | null; role: string }, ip: string | null, now = new Date()) {
|
||||
const sibling = await listedProduct(installId);
|
||||
if (!sibling) throw new LinkError('That product isn\'t in the list the Hub gave this site. Wait for the next Hub heartbeat (up to 15 minutes).', 'NOT_LINKED', 404);
|
||||
const sibling = await listedOrRefreshed(installId, now);
|
||||
if (!sibling) throw new LinkError('The Hub doesn\'t list that product for this church.', 'NOT_LINKED', 404);
|
||||
const me = await self();
|
||||
const secret = newLinkSecret();
|
||||
const message = signLink<Omit<LinkConnect, 'signature'>>({
|
||||
@@ -123,9 +151,9 @@ export async function acceptConnect(body: unknown, ip: string | null, now = new
|
||||
const m = parsed.data;
|
||||
const me = await self();
|
||||
if (m.to.installId !== me.installId) throw new LinkError('That message is for another install.', 'WRONG_INSTALL', 400);
|
||||
const sibling = await listedProduct(m.from.installId);
|
||||
const sibling = await listedOrRefreshed(m.from.installId, now);
|
||||
if (!sibling || sibling.product !== m.from.product) {
|
||||
throw new LinkError('This site doesn\'t know that install yet: the Hub lists the church\'s products in its next heartbeat (up to 15 minutes).', 'NOT_LINKED', 403);
|
||||
throw new LinkError('The Hub doesn\'t list that install for this church (this site asks it again at most once a minute).', 'NOT_LINKED', 403);
|
||||
}
|
||||
const check = verifyLink(m as unknown as Record<string, unknown>, sibling.publicKey, { now });
|
||||
if (!check.ok) throw new LinkError(check.code === 'STALE_REQUEST' ? 'The message is too old, or a clock is wrong.' : 'The signature doesn\'t match the key the Hub listed.', check.code, 401);
|
||||
|
||||
@@ -87,6 +87,7 @@ const pem = (k) => signing.ed25519PublicToPem(k.publicKey);
|
||||
async function setUpSite({ linked = true } = {}) {
|
||||
db.reset();
|
||||
store.forgetKeyPair();
|
||||
connect.forgetRefresh();
|
||||
db.t.appSetting.set('hub_install_id', { key: 'hub_install_id', value: EVENTS_ID });
|
||||
db.t.appSetting.set('hub_private_key', { key: 'hub_private_key', value: encrypt(keys.events.privateKeyPem) });
|
||||
db.t.appSetting.set('hub_public_key', { key: 'hub_public_key', value: pem(keys.events) });
|
||||
@@ -286,6 +287,29 @@ describe('Connect from a linked product', () => {
|
||||
await expect(connect.acceptConnect(m, null)).rejects.toMatchObject({ code: 'REPLAYED' });
|
||||
});
|
||||
|
||||
test('3.7.1: a product installed after the last heartbeat is found in a fresh list from the Hub, at most once a minute', async () => {
|
||||
await store.saveLinkedProducts([]);
|
||||
const hubClient = require('../src/hub/client');
|
||||
let listed = [{ product: 'website', installId: WEBSITE_ID, url: WEBSITE_URL, publicKey: pem(keys.website) }];
|
||||
const spy = jest.spyOn(hubClient, 'heartbeat').mockImplementation(async () => { await store.saveLinkedProducts(listed); return { ok: true }; });
|
||||
try {
|
||||
await connect.acceptConnect(connectMessage(), null, new Date());
|
||||
expect(spy).toHaveBeenCalledTimes(1);
|
||||
expect(db.t.productLink.get(WEBSITE_ID)).toMatchObject({ product: 'website' });
|
||||
|
||||
// An install the Hub doesn't list: refused, and the Hub isn't asked again within the minute.
|
||||
listed = [];
|
||||
await store.saveLinkedProducts([]);
|
||||
const t = new Date();
|
||||
await expect(connect.acceptConnect(connectMessage(), null, t)).rejects.toMatchObject({ code: 'NOT_LINKED' });
|
||||
expect(spy).toHaveBeenCalledTimes(1);
|
||||
await expect(connect.acceptConnect(connectMessage(), null, new Date(t.getTime() + 61_000))).rejects.toMatchObject({ code: 'NOT_LINKED' });
|
||||
expect(spy).toHaveBeenCalledTimes(2);
|
||||
} finally {
|
||||
spy.mockRestore();
|
||||
}
|
||||
});
|
||||
|
||||
test('disconnect from the sibling removes the link and its events; a forged one doesn\'t', async () => {
|
||||
await connect.acceptConnect(connectMessage(), null);
|
||||
db.t.importedEvent.set('website:x', { key: 'website:x', linkId: WEBSITE_ID });
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@crosscode/events-frontend",
|
||||
"version": "3.7.0",
|
||||
"version": "3.7.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@crosscode/events",
|
||||
"version": "3.7.0",
|
||||
"version": "3.7.1",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"dev:backend": "cd backend && npm run dev",
|
||||
|
||||
@@ -1,6 +1,46 @@
|
||||
# Changelog — Church Website
|
||||
|
||||
## [Unreleased]
|
||||
## [1.0.2] — 2026-11-26
|
||||
|
||||
No migration, no new settings. Works with Accounts 1.7.0; with Accounts 1.7.1 the first sign-in
|
||||
after an install links at once.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **Preview sent admins to the server's own address** (`http://localhost:<web port>`, found on
|
||||
cross-demo2). `/preview/start`, `/preview/exit` and shared preview links redirected to
|
||||
`new URL(path, request.url)`, and behind the proxy `request.url` is the address Next.js is reached
|
||||
on. They now answer with a relative `Location` (`src/lib/localRedirect.ts`), so the browser stays
|
||||
on the site's address.
|
||||
- **The admin couldn't be signed in to for up to 30 minutes after an install.** The Website links
|
||||
itself to the church's Accounts, but only at a heartbeat, and Accounts refused it until Accounts'
|
||||
own next heartbeat. Now opening `/admin` without a link links on the spot (asking the Hub for a
|
||||
fresh list first when it has no Accounts in it; tried at most every 15 seconds). A connect
|
||||
involving an install that isn't in the cached list yet (Accounts, or Events for the event feed)
|
||||
also asks the Hub for a fresh list (at most once a minute) instead of refusing. Only one connect to
|
||||
Accounts runs at a time, so a heartbeat and a sign-in can't leave the two sides with different
|
||||
secrets.
|
||||
- **The sign-in problem page says when the site isn't linked yet** (`ACCOUNTS_NOT_LINKED`: "This
|
||||
website isn't linked to your church's sign-in yet"), instead of "can't reach your church's
|
||||
sign-in", which read like an outage.
|
||||
|
||||
## [1.0.1] — 2026-11-26
|
||||
|
||||
### Fixed
|
||||
|
||||
- **The messages' thumbnails come from the site** (WEBSITE-1.0-PLAN §7): they loaded from YouTube
|
||||
(`i.ytimg.com`) with the page, so every visitor was in touch with YouTube before pressing play.
|
||||
The backend now fetches a message's thumbnail once and keeps it (`/api/thumbnails/<id>.jpg`,
|
||||
kept in `uploads/.thumbnails/`, not counted as storage and left out of the export); only the
|
||||
site's own messages' videos are fetched, and only a JPEG is kept. The messages page asks for the
|
||||
first one from the `<head>` (it's the largest thing on screen), and the e2e checks that nothing
|
||||
is asked of YouTube or Spotify until play is clicked.
|
||||
- **Calendar events' dates** read "Sun (month: November)": a weekday and month without a day is
|
||||
printed that way by `Intl`. Now "Sun · November".
|
||||
- **The variant screenshots no longer flake** (e2e only): a section starting at a fractional
|
||||
position came out a pixel taller or shorter from run to run. The header's and each section's
|
||||
height is rounded up before the screenshot; the baselines were taken again with it.
|
||||
## [1.0.0] — 2026-11-26
|
||||
|
||||
### Added
|
||||
|
||||
@@ -39,6 +79,22 @@
|
||||
`e2e/screens/`; the admin's flows (edit, preview, publish; discard; a shared link, revoked;
|
||||
restore; a template switch; a Viewer; signing in from a deep admin page) and axe on every admin
|
||||
screen.
|
||||
- **The release checks** (§13): **every section variant in every template** (`e2e/variants.spec.ts`:
|
||||
26 × 4, axe on each, and 312 screenshots at phone, tablet and desktop compared with the last
|
||||
baselines, kept on the machine that runs them, not in git); **Lighthouse on a phone**
|
||||
(`e2e/lighthouse.spec.ts`: home, an event and the messages in each template, the median of three
|
||||
runs with the CPU slowdown calibrated to the machine: SEO 100, accessibility 95+, performance
|
||||
90+); and **the same suite on real Postgres**
|
||||
(`E2E_DATABASE_URL=postgresql://…/<name>_e2e`: the database made again, the migrations applied with
|
||||
`prisma migrate deploy`). The e2e server's clock is frozen, so the demo's dates are the same every
|
||||
run.
|
||||
- **The map loads only once it's on screen** (the With map service times): until then, a link to
|
||||
it. The iframe's own lazy loading fetched OpenStreetMap's 300 KB script with the page on a phone,
|
||||
and told OpenStreetMap about every visitor. **The messages page's first thumbnail isn't lazy**
|
||||
(it's the largest thing on screen), and the page connects to its host at once.
|
||||
- **Contrast on Bold** (found by the variant checks): the service times' notes on Bold's dark panel
|
||||
(Panel and With map), and the dates of the Calendar events on a dark band, are light now
|
||||
(`cc-dark` on the panel; `cc-brand-text`, which the dark rules can override, for the dates).
|
||||
- **The admin** (§4, §10): a dashboard with the setup checklist, pending changes, storage and notes
|
||||
about the church's colours; Template and style (the template, each homepage section's layout with
|
||||
the recommended ones first, the homepage order, the style settings); Pages (details, search
|
||||
|
||||
@@ -2,3 +2,40 @@
|
||||
|
||||
What each version changes for the church, in plain language (read by the Hub like Cross Events'
|
||||
WHATS-NEW.md; a section shows once its version is tagged).
|
||||
|
||||
## 1.0.2
|
||||
|
||||
- **Preview works:** pressing Preview in the admin shows your site with your changes, instead of
|
||||
an error page.
|
||||
- **Signing in right after your website is installed** works straight away, instead of after up to
|
||||
half an hour. If it isn't connected to your church's sign-in yet, the page now says so.
|
||||
|
||||
## 1.0.1
|
||||
|
||||
- **Your visitors' privacy:** the pictures on your messages now come from your own website, so
|
||||
nothing is loaded from YouTube until someone presses play. The Messages page also shows a little
|
||||
sooner.
|
||||
- **Event dates in the Calendar layout** read properly ("Sun · November").
|
||||
|
||||
## 1.0.0 — requires accounts 1.7.0
|
||||
|
||||
- **Your church's own website**, managed by you. Choose one of four templates (Heritage, Bold,
|
||||
Community or Clean), then make it yours: each homepage section has two or three layouts, and you
|
||||
pick the fonts, corners, colours and spacing. Your logo, colours and details come from your
|
||||
church profile, so the website, Cross Events and your sign-in pages look like one church.
|
||||
- **Nothing goes live until you say so.** Every change is a draft. Preview the whole site at phone,
|
||||
tablet and desktop size (and share a preview link), then press **Publish** once. Every published
|
||||
version is kept, and you can go back to any of them. Until your first Publish, visitors see a
|
||||
"Coming soon" page.
|
||||
- **Pages for everything a visitor looks for:** Plan your visit, About, Ministries, Leadership,
|
||||
Events, Messages, Give and Contact, plus your own pages built from blocks.
|
||||
- **Messages straight from YouTube:** link your channel or playlist and each new video appears by
|
||||
itself, or add messages by hand with a YouTube or Spotify link.
|
||||
- **Events:** add simple events here, and show the events from your Cross Events (with a link to
|
||||
register there).
|
||||
- **People and roles:** Owners, Admins, Editors, Ministry leaders (only their own ministry) and
|
||||
Viewers, all signing in with their church account. An audit log shows who changed what.
|
||||
- **Found by search engines:** titles and descriptions you can edit, share images, your church on
|
||||
maps and in local search, and your Google and Bing verification codes.
|
||||
- **Photos made safe and fast:** location details removed from every photo, and the right size
|
||||
sent to each screen. 5 GB of uploads included; ask for more under Media library.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@crosscode/website-backend",
|
||||
"version": "0.1.0",
|
||||
"version": "1.0.2",
|
||||
"description": "Church Website: the public site's content API, the admin API, publishing and uploads",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
|
||||
@@ -8,7 +8,7 @@ import { z } from 'zod';
|
||||
import type { Ctx } from '../context.js';
|
||||
import { ApiError } from '../http.js';
|
||||
import { audit } from '../lib/audit.js';
|
||||
import { youtubeId, spotifyEmbed } from '../site/content.js';
|
||||
import { youtubeId, spotifyEmbed, messageThumbnail } from '../site/content.js';
|
||||
import { mediaUrl } from '../site/snapshot.js';
|
||||
import { getSource, setSource, syncYoutube, uniqueSlug } from '../site/youtube.js';
|
||||
import { markRemoved, notifyLinks } from '../feed/feed.js';
|
||||
@@ -58,7 +58,7 @@ export async function listMessages(ctx: Ctx) {
|
||||
youtube: { source, lastSync, lastError },
|
||||
items: rows.map((m) => ({
|
||||
id: m.id, title: m.title, date: m.date.toISOString(), mediaUrl: m.mediaUrl, source: m.source, speaker: m.speaker, passage: m.passage, notes: m.notes,
|
||||
series: m.series?.title ?? null, hidden: m.hidden, published: m.publishedAt !== null, thumbnail: m.thumbnailUrl,
|
||||
series: m.series?.title ?? null, hidden: m.hidden, published: m.publishedAt !== null, thumbnail: messageThumbnail(m),
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* /api/health version and database, for monitoring, `crosscode deploy` and the Hub
|
||||
* /api/v1/site/… the public site (what visitors see: the latest published version)
|
||||
* /api/uploads/… the church's uploaded images
|
||||
* /api/thumbnails/<id>.jpg its messages' YouTube thumbnails, kept here (visitors never ask YouTube)
|
||||
* /api/auth/… signing in to the admin through the church's Accounts
|
||||
* /api/accounts/v1/events Accounts' signed calls (user.updated / export / deleted)
|
||||
* /api/links/v1/… Connect and Disconnect with the church's other products
|
||||
@@ -27,6 +28,7 @@ import { linksRouter } from './links/routes.js';
|
||||
import { defaultUploadDir } from './demo/demoChurch.js';
|
||||
import { previewContent, siteContent } from './site/content.js';
|
||||
import { siteStatus } from './site/status.js';
|
||||
import { thumbnail } from './site/thumbnails.js';
|
||||
|
||||
export function createApp(ctx: Ctx) {
|
||||
const app = express();
|
||||
@@ -75,6 +77,23 @@ export function createApp(ctx: Ctx) {
|
||||
},
|
||||
}));
|
||||
|
||||
// A message's YouTube thumbnail, fetched once by the backend and kept (site/thumbnails.ts).
|
||||
app.get('/api/thumbnails/:file', async (req, res, next) => {
|
||||
try {
|
||||
const id = /^([A-Za-z0-9_-]+)\.jpg$/.exec(req.params.file)?.[1];
|
||||
const body = id ? await thumbnail(ctx, id) : null;
|
||||
if (!body) {
|
||||
res.set('Cache-Control', 'no-store');
|
||||
return sendError(res, new ApiError(404, 'NOT_FOUND', 'There is no such file.'));
|
||||
}
|
||||
res.set('Content-Type', 'image/jpeg');
|
||||
res.set('Cache-Control', 'public, max-age=604800');
|
||||
res.send(body);
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
});
|
||||
|
||||
app.use('/api', authRouter(ctx));
|
||||
app.use('/api', linksRouter(ctx));
|
||||
|
||||
|
||||
@@ -8,13 +8,15 @@ import type * as AuthClient from '@crosscode/auth-client';
|
||||
import type { AccountsClient } from '@crosscode/auth-client';
|
||||
import type { Ctx } from '../context.js';
|
||||
import { ApiError } from '../http.js';
|
||||
import { linkAccountsNow } from '../links/connect.js';
|
||||
|
||||
export type AuthClientModule = typeof AuthClient;
|
||||
|
||||
export const loadAuthClient = (): Promise<AuthClientModule> => import('@crosscode/auth-client');
|
||||
|
||||
export class AccountsUnavailable extends ApiError {
|
||||
constructor(message: string) {
|
||||
/** 1.0.2: `not_linked` (no link to Accounts yet) or `unreachable` (linked, but it didn't answer). */
|
||||
constructor(message: string, public reason: 'not_linked' | 'unreachable' = 'unreachable') {
|
||||
super(503, 'ACCOUNTS_UNAVAILABLE', message);
|
||||
}
|
||||
}
|
||||
@@ -28,10 +30,15 @@ const cache = new WeakMap<Ctx, { key: string; client: Promise<AccountsClient> }>
|
||||
|
||||
/** The client for the church's Accounts (discovery done once per link). Throws AccountsUnavailable. */
|
||||
export async function accounts(ctx: Ctx): Promise<AccountsClient> {
|
||||
const link = await accountsLink(ctx);
|
||||
if (!link) throw new AccountsUnavailable('The Website isn\'t linked to the church\'s Accounts yet. It links by itself within 15 minutes of being installed.');
|
||||
let link = await accountsLink(ctx);
|
||||
if (!link) {
|
||||
// 1.0.2: link now rather than wait for the next heartbeat.
|
||||
await linkAccountsNow(ctx);
|
||||
link = await accountsLink(ctx);
|
||||
}
|
||||
if (!link) throw new AccountsUnavailable('The Website isn\'t linked to the church\'s Accounts yet.', 'not_linked');
|
||||
const clientId = await ctx.settings.get('hub_install_id');
|
||||
if (!clientId) throw new AccountsUnavailable('The Website isn\'t connected to the Hub yet.');
|
||||
if (!clientId) throw new AccountsUnavailable('The Website isn\'t connected to the Hub yet.', 'not_linked');
|
||||
const key = `${link.installId}|${link.updatedAt.getTime()}|${clientId}|${ctx.config.publicUrl}`;
|
||||
let hit = cache.get(ctx);
|
||||
if (!hit || hit.key !== key) {
|
||||
|
||||
@@ -34,6 +34,9 @@ const page = (ctx: Ctx, path: string) => `${ctx.config.publicUrl}${path}`;
|
||||
const problem = (ctx: Ctx, res: Response, code: string, returnTo = '/admin') =>
|
||||
res.redirect(303, page(ctx, `/auth/problem?code=${encodeURIComponent(code)}&returnTo=${encodeURIComponent(safeReturnPath(returnTo))}`));
|
||||
|
||||
/** 1.0.2: the problem page says which it is: not linked to Accounts yet, or Accounts not answering. */
|
||||
const unavailableCode = (e: AccountsUnavailable) => (e.reason === 'not_linked' ? 'ACCOUNTS_NOT_LINKED' : 'ACCOUNTS_UNAVAILABLE');
|
||||
|
||||
type UserRow = { id: string; name: string; email: string; role: WebsiteRole };
|
||||
|
||||
/**
|
||||
@@ -70,7 +73,7 @@ export function authRouter(ctx: Ctx) {
|
||||
else res.clearCookie(MFA_COOKIE, cookieOptions(ctx, COOKIE_PATH));
|
||||
return res.redirect(303, url);
|
||||
} catch (e) {
|
||||
if (e instanceof AccountsUnavailable) return problem(ctx, res, 'ACCOUNTS_UNAVAILABLE', returnTo);
|
||||
if (e instanceof AccountsUnavailable) return problem(ctx, res, unavailableCode(e), returnTo);
|
||||
console.error('[auth] Starting a sign-in failed:', e);
|
||||
return problem(ctx, res, 'SIGNIN_FAILED', returnTo);
|
||||
}
|
||||
@@ -86,7 +89,7 @@ export function authRouter(ctx: Ctx) {
|
||||
const auth = await accounts(ctx);
|
||||
result = await auth.finishSignIn(new URL(req.originalUrl, ctx.config.publicUrl), cookies[PENDING_COOKIE]);
|
||||
} catch (e) {
|
||||
if (e instanceof AccountsUnavailable) return problem(ctx, res, 'ACCOUNTS_UNAVAILABLE');
|
||||
if (e instanceof AccountsUnavailable) return problem(ctx, res, unavailableCode(e));
|
||||
const code = (e as { code?: string }).code;
|
||||
// The person pressed Cancel at Accounts, or the pending cookie expired.
|
||||
if (req.query.error === 'access_denied') return res.redirect(303, page(ctx, '/'));
|
||||
|
||||
@@ -18,13 +18,16 @@ export type Ctx = {
|
||||
/** `@crosscode/auth-client` (tests give a stand-in). */
|
||||
authClient: () => Promise<AuthClientModule>;
|
||||
now: () => Date;
|
||||
/** Fetches what visitors are shown from outside (YouTube's thumbnails); tests give a stand-in. */
|
||||
fetch?: (url: string) => Promise<Response>;
|
||||
};
|
||||
|
||||
export function createCtx(config: Config, db: Db, opts: { now?: () => Date; authClient?: () => Promise<AuthClientModule> } = {}): Ctx {
|
||||
export function createCtx(config: Config, db: Db, opts: { now?: () => Date; authClient?: () => Promise<AuthClientModule>; fetch?: (url: string) => Promise<Response> } = {}): Ctx {
|
||||
const secrets = new Secrets(config.secret);
|
||||
const partial = { config, db, secrets } as Ctx;
|
||||
partial.settings = new Settings(partial);
|
||||
partial.authClient = opts.authClient ?? loadAuthClient;
|
||||
partial.now = opts.now ?? (() => new Date());
|
||||
if (opts.fetch) partial.fetch = opts.fetch;
|
||||
return partial;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ export function demoProfile(publicUrl: string): Church {
|
||||
}
|
||||
|
||||
/** An illustrated "photo": hills, a sun and a path in the church's colours (SVG, no people). */
|
||||
function illustration(seed: number, w = 1600, h = 1000): string {
|
||||
export function illustration(seed: number, w = 1600, h = 1000): string {
|
||||
const hues = [DEMO_COLOURS.primary, DEMO_COLOURS.accent, '#7fb7be', '#f3e3c3', '#284b52'];
|
||||
const c = (i: number) => hues[(seed + i) % hues.length];
|
||||
const y = (f: number) => Math.round(h * f);
|
||||
|
||||
@@ -27,6 +27,37 @@ export class LinkError extends Error {
|
||||
/** The products the Website links to. */
|
||||
const LINKABLE = new Set(['accounts', 'events', 'app']);
|
||||
const NONCE_KEEP_MS = 60 * 60 * 1000;
|
||||
const REFRESH_EVERY_MS = 60 * 1000;
|
||||
const SIGN_IN_TRY_EVERY_MS = 15 * 1000;
|
||||
|
||||
const refreshes = new WeakMap<Ctx, { at: number; run: Promise<unknown> }>();
|
||||
|
||||
/**
|
||||
* 1.0.2: a fresh list of the church's products from the Hub (a heartbeat), at most once a minute,
|
||||
* so a message from an unknown install can't make the Website call the Hub more often than that.
|
||||
* Several callers inside that minute share one heartbeat. Never throws.
|
||||
*/
|
||||
async function refreshList(ctx: Ctx): Promise<void> {
|
||||
const now = ctx.now().getTime();
|
||||
let r = refreshes.get(ctx);
|
||||
if (!r || now - r.at >= REFRESH_EVERY_MS) {
|
||||
// Imported here: hub/client.ts imports this file (it links to Accounts after each heartbeat).
|
||||
r = { at: now, run: import('../hub/client.js').then((m) => m.heartbeat(ctx)).catch((e) => console.warn('[links] Asking the Hub for a fresh list failed:', (e as Error).message)) };
|
||||
refreshes.set(ctx, r);
|
||||
}
|
||||
await r.run;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1.0.2: the install as the Hub listed it. If the cached list doesn't have it yet (it was installed
|
||||
* after this site's last heartbeat), the Website asks the Hub for a fresh list and looks again.
|
||||
*/
|
||||
async function listedOrRefreshed(ctx: Ctx, installId: string) {
|
||||
const found = await listedProduct(ctx, installId);
|
||||
if (found) return found;
|
||||
await refreshList(ctx);
|
||||
return listedProduct(ctx, installId);
|
||||
}
|
||||
|
||||
type Actor = { id: string | null; role: string };
|
||||
|
||||
@@ -61,8 +92,8 @@ const logLink = (ctx: Ctx, action: string, link: { installId: string; product: s
|
||||
|
||||
/** This site connects (an admin pressed Connect, or the automatic connect to Accounts below). */
|
||||
export async function connectTo(ctx: Ctx, installId: string, actor: Actor, req?: Request) {
|
||||
const sibling = await listedProduct(ctx, installId);
|
||||
if (!sibling || !LINKABLE.has(sibling.product)) throw new LinkError('That product isn\'t in the list the Hub gave this site. Wait for the next Hub heartbeat (up to 15 minutes).', 'NOT_LINKED', 404);
|
||||
const sibling = await listedOrRefreshed(ctx, installId);
|
||||
if (!sibling || !LINKABLE.has(sibling.product)) throw new LinkError('The Hub doesn\'t list that product for this church.', 'NOT_LINKED', 404);
|
||||
const me = await self(ctx);
|
||||
const secret = newLinkSecret();
|
||||
const message = signLink<Omit<LinkConnect, 'signature'>>({
|
||||
@@ -93,9 +124,9 @@ export async function acceptConnect(ctx: Ctx, body: unknown, req?: Request): Pro
|
||||
const m = parsed.data;
|
||||
const me = await self(ctx);
|
||||
if (m.to.installId !== me.installId) throw new LinkError('That message is for another install.', 'WRONG_INSTALL', 400);
|
||||
const sibling = await listedProduct(ctx, m.from.installId);
|
||||
const sibling = await listedOrRefreshed(ctx, m.from.installId);
|
||||
if (!sibling || sibling.product !== m.from.product || !LINKABLE.has(sibling.product)) {
|
||||
throw new LinkError('This site doesn\'t know that install yet: the Hub lists the church\'s products in its next heartbeat (up to 15 minutes).', 'NOT_LINKED', 403);
|
||||
throw new LinkError('The Hub doesn\'t list that install for this church (the Website asks it again at most once a minute).', 'NOT_LINKED', 403);
|
||||
}
|
||||
const check = verifyLink(m as unknown as Record<string, unknown>, sibling.publicKey, { now: ctx.now() });
|
||||
if (!check.ok) throw new LinkError(check.code === 'STALE_REQUEST' ? 'The message is too old, or a clock is wrong.' : 'The signature doesn\'t match the key the Hub listed.', check.code, 401);
|
||||
@@ -146,7 +177,20 @@ export async function acceptDisconnect(ctx: Ctx, body: unknown, req?: Request):
|
||||
* Hub lists one and nothing is linked yet (as Events 3.x's autoConnect). Run after each heartbeat.
|
||||
* Never throws: a failure is tried again at the next heartbeat.
|
||||
*/
|
||||
export async function connectAccountsIfListed(ctx: Ctx): Promise<'connected' | 'skipped' | 'failed'> {
|
||||
export function connectAccountsIfListed(ctx: Ctx): Promise<'connected' | 'skipped' | 'failed'> {
|
||||
// 1.0.2: one connect at a time (a heartbeat and a sign-in can both try): two at once would each
|
||||
// send Accounts a different secret, and the one each side kept last might not be the same.
|
||||
let run = connecting.get(ctx);
|
||||
if (!run) {
|
||||
run = connectAccountsOnce(ctx).finally(() => connecting.delete(ctx));
|
||||
connecting.set(ctx, run);
|
||||
}
|
||||
return run;
|
||||
}
|
||||
|
||||
const connecting = new WeakMap<Ctx, Promise<'connected' | 'skipped' | 'failed'>>();
|
||||
|
||||
async function connectAccountsOnce(ctx: Ctx): Promise<'connected' | 'skipped' | 'failed'> {
|
||||
if (await ctx.db.productLink.findFirst({ where: { product: 'accounts' } })) return 'skipped';
|
||||
const listed = (await linkedProducts(ctx)).find((p) => p.product === 'accounts');
|
||||
if (!listed) return 'skipped';
|
||||
@@ -158,3 +202,21 @@ export async function connectAccountsIfListed(ctx: Ctx): Promise<'connected' | '
|
||||
return 'failed';
|
||||
}
|
||||
}
|
||||
|
||||
const signInTries = new WeakMap<Ctx, number>();
|
||||
|
||||
/**
|
||||
* 1.0.2: someone wants to sign in and there's no link to Accounts yet: link now instead of waiting
|
||||
* for the next heartbeat. If the cached list has no Accounts, the Hub is asked for a fresh one first
|
||||
* (which links by itself when it lists one). Tried at most every 15 seconds, so visitors opening
|
||||
* /admin can't make the Website call Accounts or the Hub more often than that.
|
||||
*/
|
||||
export async function linkAccountsNow(ctx: Ctx): Promise<void> {
|
||||
if (await ctx.db.productLink.findFirst({ where: { product: 'accounts' } })) return;
|
||||
const now = ctx.now().getTime();
|
||||
const last = signInTries.get(ctx);
|
||||
if (last !== undefined && now - last < SIGN_IN_TRY_EVERY_MS) return;
|
||||
signInTries.set(ctx, now);
|
||||
if (!(await linkedProducts(ctx)).some((p) => p.product === 'accounts')) await refreshList(ctx);
|
||||
await connectAccountsIfListed(ctx);
|
||||
}
|
||||
|
||||
@@ -77,6 +77,15 @@ function brandFor(church: Church | null, template: WebsiteTemplate) {
|
||||
};
|
||||
}
|
||||
|
||||
/** Where the site serves a YouTube video's thumbnail from (site/thumbnails.ts): visitors never ask YouTube. */
|
||||
export const thumbnailPath = (videoId: string) => `/api/thumbnails/${videoId}.jpg`;
|
||||
|
||||
/** A message's thumbnail on the site: its YouTube video's, served from here; none for Spotify. */
|
||||
export function messageThumbnail(m: { source: string; mediaUrl: string }) {
|
||||
const yt = m.source === 'spotify' ? null : youtubeId(m.mediaUrl);
|
||||
return yt ? thumbnailPath(yt) : null;
|
||||
}
|
||||
|
||||
/** `https://www.youtube.com/watch?v=abc` → its id; null for anything else. */
|
||||
export function youtubeId(url: string): string | null {
|
||||
try {
|
||||
@@ -104,7 +113,7 @@ async function liveMessages(ctx: Ctx): Promise<SiteMessage[]> {
|
||||
source: m.source === 'spotify' ? 'spotify' : 'youtube',
|
||||
embedUrl: yt ? `https://www.youtube-nocookie.com/embed/${yt}?autoplay=1` : spotifyEmbed(m.mediaUrl),
|
||||
url: m.mediaUrl,
|
||||
thumbnail: m.thumbnailUrl ?? (yt ? `https://i.ytimg.com/vi/${yt}/hqdefault.jpg` : null),
|
||||
thumbnail: messageThumbnail(m),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* A message's YouTube thumbnail, served from the site (WEBSITE-1.0-PLAN §7: nothing loads from
|
||||
* YouTube until a visitor clicks play). The backend fetches `i.ytimg.com/vi/<id>/hqdefault.jpg`
|
||||
* once and keeps it in `<uploads>/.thumbnails/` (not served from /api/uploads, which denies dot
|
||||
* folders, and not counted as the church's storage). Only the ids of the site's own messages are
|
||||
* fetched, so the route is never a proxy for anything else.
|
||||
*/
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import type { Ctx } from '../context.js';
|
||||
import { defaultUploadDir } from '../demo/demoChurch.js';
|
||||
import { youtubeId } from './content.js';
|
||||
|
||||
export { thumbnailPath } from './content.js';
|
||||
export type Fetcher = (url: string) => Promise<Response>;
|
||||
|
||||
const ID = /^[A-Za-z0-9_-]{6,20}$/;
|
||||
const MAX_BYTES = 1024 * 1024;
|
||||
|
||||
const cacheDir = (ctx: Ctx) => path.join(path.resolve(ctx.config.uploadDir ?? defaultUploadDir()), '.thumbnails');
|
||||
|
||||
const defaultFetcher: Fetcher = (url) => fetch(url, { signal: AbortSignal.timeout(10_000) });
|
||||
|
||||
/** One fetch per video at a time, however many visitors ask at once. */
|
||||
const inFlight = new Map<string, Promise<Buffer | null>>();
|
||||
|
||||
async function isOurVideo(ctx: Ctx, videoId: string) {
|
||||
const rows = await ctx.db.message.findMany({ where: { mediaUrl: { contains: videoId } }, select: { mediaUrl: true, source: true }, take: 5 });
|
||||
return rows.some((m) => m.source !== 'spotify' && youtubeId(m.mediaUrl) === videoId);
|
||||
}
|
||||
|
||||
async function download(fetcher: Fetcher, videoId: string): Promise<Buffer | null> {
|
||||
try {
|
||||
const res = await fetcher(`https://i.ytimg.com/vi/${videoId}/hqdefault.jpg`);
|
||||
if (!res.ok || !/^image\/jpe?g/.test(res.headers.get('content-type') ?? '')) return null;
|
||||
const body = Buffer.from(await res.arrayBuffer());
|
||||
// A JPEG by its bytes, and a sensible size.
|
||||
if (body.length > MAX_BYTES || body.length < 3 || body[0] !== 0xff || body[1] !== 0xd8 || body[2] !== 0xff) return null;
|
||||
return body;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** The thumbnail's bytes, from the cache or YouTube; null when it isn't one of the site's videos or YouTube has none. */
|
||||
export async function thumbnail(ctx: Ctx, videoId: string, fetcher: Fetcher = ctx.fetch ?? defaultFetcher): Promise<Buffer | null> {
|
||||
if (!ID.test(videoId)) return null;
|
||||
const file = path.join(cacheDir(ctx), `${videoId}.jpg`);
|
||||
try {
|
||||
return await fs.readFile(file);
|
||||
} catch {
|
||||
// Not cached yet.
|
||||
}
|
||||
if (!(await isOurVideo(ctx, videoId))) return null;
|
||||
let pending = inFlight.get(videoId);
|
||||
if (!pending) {
|
||||
pending = (async () => {
|
||||
const body = await download(fetcher, videoId);
|
||||
if (body) {
|
||||
await fs.mkdir(path.dirname(file), { recursive: true });
|
||||
const tmp = `${file}.${process.pid}.tmp`;
|
||||
await fs.writeFile(tmp, body);
|
||||
await fs.rename(tmp, file);
|
||||
}
|
||||
return body;
|
||||
})().finally(() => inFlight.delete(videoId));
|
||||
inFlight.set(videoId, pending);
|
||||
}
|
||||
return pending;
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import { buildExport } from '../src/export/churchExport.js';
|
||||
import { stats } from '../src/hub/client.js';
|
||||
import { connectAccountsIfListed } from '../src/links/connect.js';
|
||||
import { keyPair, saveLinkedProducts } from '../src/links/store.js';
|
||||
import { ACCOUNTS_INSTALL_ID, harness, INSTALL_ID } from './support/harness.js';
|
||||
import { ACCOUNTS_INSTALL_ID, harness, INSTALL_ID, SITE } from './support/harness.js';
|
||||
|
||||
const accountsKeys = generateEd25519();
|
||||
const accountsPublic = ed25519PublicToPem(accountsKeys.publicKey);
|
||||
@@ -88,6 +88,72 @@ describe('linking to the church\'s Accounts', () => {
|
||||
});
|
||||
});
|
||||
|
||||
/** A Hub answering heartbeats with `list` as the church's products (only what the Website reads). */
|
||||
async function fakeHub(list: () => unknown[]) {
|
||||
const calls: string[] = [];
|
||||
const server = http.createServer((req, res) => {
|
||||
calls.push(String(req.url));
|
||||
res.setHeader('content-type', 'application/json');
|
||||
res.end(JSON.stringify({ ok: true, licence: '', linkedProducts: list() }));
|
||||
});
|
||||
await new Promise<void>((r) => server.listen(0, '127.0.0.1', () => r()));
|
||||
const url = `http://127.0.0.1:${(server.address() as AddressInfo).port}`;
|
||||
closers.push(() => new Promise((r) => server.close(r)));
|
||||
return { url, calls };
|
||||
}
|
||||
|
||||
describe('1.0.2: linking right after an install', () => {
|
||||
it('links to Accounts when someone opens /admin, asking the Hub for a fresh list first', async () => {
|
||||
let accountsUrl = '';
|
||||
const hubServer = await fakeHub(() => [{ product: 'accounts', installId: ACCOUNTS_INSTALL_ID, url: accountsUrl, publicKey: accountsPublic }]);
|
||||
const h = await harness({ linked: false, env: { LINKS_ALLOW_PRIVATE: 'true', HUB_URL: hubServer.url } });
|
||||
await h.ctx.settings.set('hub_install_secret', 'secret');
|
||||
const accounts = await fakeAccounts(async () => (await keyPair(h.ctx)).publicKeyPem);
|
||||
closers.push(accounts.close);
|
||||
accountsUrl = accounts.url;
|
||||
|
||||
// The Website's cached list has no Accounts yet (it registered before the Hub knew of one).
|
||||
const res = await request(h.app).get('/api/auth/signin?returnTo=%2Fadmin');
|
||||
assert.equal(res.status, 303);
|
||||
assert.match(res.headers.location!, /^https:\/\/accounts\.hope\.test\//, 'off to Accounts, not the problem page');
|
||||
assert.deepEqual(hubServer.calls, ['/api/installs/heartbeat']);
|
||||
assert.equal(accounts.seen.length, 1, 'one connect, not one from the heartbeat and another from the sign-in');
|
||||
assert.equal(await h.db.productLink.count({ where: { product: 'accounts' } }), 1);
|
||||
});
|
||||
|
||||
it('tries again at most every 15 seconds while it can\'t link', async () => {
|
||||
let clock = new Date('2026-11-26T15:00:00Z');
|
||||
const hubServer = await fakeHub(() => []);
|
||||
const h = await harness({ linked: false, env: { HUB_URL: hubServer.url } });
|
||||
h.ctx.now = () => clock;
|
||||
await h.ctx.settings.set('hub_install_secret', 'secret');
|
||||
const problem = `${SITE}/auth/problem?code=ACCOUNTS_NOT_LINKED&returnTo=%2Fadmin`;
|
||||
assert.equal((await request(h.app).get('/api/auth/signin?returnTo=%2Fadmin')).headers.location, problem);
|
||||
assert.equal((await request(h.app).get('/api/auth/signin?returnTo=%2Fadmin')).headers.location, problem);
|
||||
assert.equal(hubServer.calls.length, 1);
|
||||
clock = new Date(clock.getTime() + 61_000);
|
||||
await request(h.app).get('/api/auth/signin?returnTo=%2Fadmin');
|
||||
assert.equal(hubServer.calls.length, 2);
|
||||
});
|
||||
|
||||
it('accepts a connect from a product installed after its last heartbeat (Events, for the event feed)', async () => {
|
||||
const EVENTS_INSTALL_ID = '4d2e8f3a-9b1c-4d0e-8f7a-6b5c4d3e2f1a';
|
||||
const eventsKeys = generateEd25519();
|
||||
const events = { product: 'events', installId: EVENTS_INSTALL_ID, url: 'https://events.hope.test', publicKey: ed25519PublicToPem(eventsKeys.publicKey) };
|
||||
const hubServer = await fakeHub(() => [events]);
|
||||
const h = await harness({ env: { HUB_URL: hubServer.url } });
|
||||
await h.ctx.settings.set('hub_install_secret', 'secret');
|
||||
const m = signLink({
|
||||
schema: LINK_SCHEMA, type: 'link.connect', from: { product: 'events', installId: EVENTS_INSTALL_ID, url: events.url },
|
||||
to: { installId: INSTALL_ID }, secret: newLinkSecret(), issuedAt: new Date().toISOString(), nonce: newLinkNonce(),
|
||||
}, eventsKeys.privateKeyPem);
|
||||
const res = await request(h.app).post('/api/links/v1/connect').send(m);
|
||||
assert.equal(res.status, 200, JSON.stringify(res.body));
|
||||
assert.equal(hubServer.calls.length, 1);
|
||||
assert.equal(await h.db.productLink.count({ where: { product: 'events' } }), 1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('the heartbeat and the export', () => {
|
||||
it('reports aggregate counts the Hub accepts', async () => {
|
||||
const h = await harness();
|
||||
|
||||
@@ -35,7 +35,7 @@ describe('signing in to the admin through Accounts', () => {
|
||||
const h = await harness({ linked: false });
|
||||
const res = await request(h.app).get('/api/auth/signin?returnTo=%2Fadmin');
|
||||
assert.equal(res.status, 303);
|
||||
assert.equal(res.headers.location, `${SITE}/auth/problem?code=ACCOUNTS_UNAVAILABLE&returnTo=%2Fadmin`);
|
||||
assert.equal(res.headers.location, `${SITE}/auth/problem?code=ACCOUNTS_NOT_LINKED&returnTo=%2Fadmin`);
|
||||
});
|
||||
|
||||
it('makes the Hub\'s admin email (verified) the first Owner and lands on the page they started from', async () => {
|
||||
|
||||
@@ -10,6 +10,7 @@ import { siteContent, spotifyEmbed, youtubeId } from '../src/site/content.js';
|
||||
import { buildPalette, contrast, hexToRgb } from '../src/site/palette.js';
|
||||
import { parseSectionData } from '../src/site/sections.js';
|
||||
import { buildSnapshot, cleanDesign, publish } from '../src/site/snapshot.js';
|
||||
import { thumbnail } from '../src/site/thumbnails.js';
|
||||
import { defaultDesign } from '../src/site/variants.js';
|
||||
import { harness } from './support/harness.js';
|
||||
|
||||
@@ -137,6 +138,60 @@ describe('the public site\'s content', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("the messages' thumbnails, served from the site (§7)", () => {
|
||||
const jpeg = Buffer.from([0xff, 0xd8, 0xff, 0xe0, 1, 2, 3]);
|
||||
const youtube = (body: Buffer | string, type = 'image/jpeg', status = 200) => {
|
||||
const asked: string[] = [];
|
||||
const fetcher = async (url: string) => { asked.push(url); return new Response(typeof body === 'string' ? body : new Uint8Array(body), { status, headers: { 'content-type': type } }); };
|
||||
return { asked, fetcher };
|
||||
};
|
||||
|
||||
it("gives visitors the site's own address, never YouTube's", async () => {
|
||||
const dir = tmp();
|
||||
const h = await harness({ linked: false, env: { UPLOAD_DIR: dir } });
|
||||
await loadDemo(h.ctx, 'heritage', { uploadDir: dir });
|
||||
const content = await siteContent(h.ctx);
|
||||
assert.ok(content.mode === 'published' && content.messages.length > 0);
|
||||
for (const m of content.messages) assert.equal(m.thumbnail, '/api/thumbnails/aqz-KE-bpKQ.jpg');
|
||||
});
|
||||
|
||||
it("fetches a message's thumbnail once and keeps it; nothing for a video that isn't the site's", async () => {
|
||||
const dir = tmp();
|
||||
const h = await harness({ linked: false, env: { UPLOAD_DIR: dir } });
|
||||
await loadDemo(h.ctx, 'heritage', { uploadDir: dir });
|
||||
const yt = youtube(jpeg);
|
||||
assert.deepEqual(await thumbnail(h.ctx, 'aqz-KE-bpKQ', yt.fetcher), jpeg);
|
||||
assert.deepEqual(await thumbnail(h.ctx, 'aqz-KE-bpKQ', yt.fetcher), jpeg);
|
||||
assert.deepEqual(yt.asked, ['https://i.ytimg.com/vi/aqz-KE-bpKQ/hqdefault.jpg']);
|
||||
assert.ok(fs.existsSync(path.join(dir, '.thumbnails', 'aqz-KE-bpKQ.jpg')));
|
||||
// Kept out of /api/uploads (a dot folder).
|
||||
assert.ok([403, 404].includes((await request(h.app).get('/api/uploads/.thumbnails/aqz-KE-bpKQ.jpg')).status));
|
||||
// Not one of the site's messages, or not an id: YouTube isn't asked.
|
||||
assert.equal(await thumbnail(h.ctx, 'someoneElse1', yt.fetcher), null);
|
||||
assert.equal(await thumbnail(h.ctx, '../../etc/x', yt.fetcher), null);
|
||||
assert.equal(yt.asked.length, 1);
|
||||
});
|
||||
|
||||
it("keeps nothing that isn't a JPEG, and says 404 when YouTube has none", async () => {
|
||||
const dir = tmp();
|
||||
const h = await harness({ linked: false, env: { UPLOAD_DIR: dir } });
|
||||
await loadDemo(h.ctx, 'heritage', { uploadDir: dir });
|
||||
assert.equal(await thumbnail(h.ctx, 'aqz-KE-bpKQ', youtube('<html>', 'text/html').fetcher), null);
|
||||
assert.equal(await thumbnail(h.ctx, 'aqz-KE-bpKQ', youtube(Buffer.from('GIF89a'), 'image/jpeg').fetcher), null);
|
||||
assert.equal(await thumbnail(h.ctx, 'aqz-KE-bpKQ', youtube('', 'image/jpeg', 404).fetcher), null);
|
||||
assert.ok(!fs.existsSync(path.join(dir, '.thumbnails', 'aqz-KE-bpKQ.jpg')));
|
||||
h.ctx.fetch = youtube('', 'image/jpeg', 404).fetcher;
|
||||
const missing = await request(h.app).get('/api/thumbnails/aqz-KE-bpKQ.jpg');
|
||||
assert.equal(missing.status, 404);
|
||||
assert.equal(missing.headers['cache-control'], 'no-store');
|
||||
h.ctx.fetch = youtube(jpeg).fetcher;
|
||||
const ok = await request(h.app).get('/api/thumbnails/aqz-KE-bpKQ.jpg');
|
||||
assert.equal(ok.status, 200);
|
||||
assert.equal(ok.headers['content-type'], 'image/jpeg');
|
||||
assert.equal((await request(h.app).get('/api/thumbnails/aqz-KE-bpKQ.png')).status, 404);
|
||||
});
|
||||
});
|
||||
|
||||
describe('message links', () => {
|
||||
it('finds YouTube ids and Spotify embeds', () => {
|
||||
assert.equal(youtubeId('https://www.youtube.com/watch?v=aqz-KE-bpKQ'), 'aqz-KE-bpKQ');
|
||||
|
||||
@@ -2,3 +2,5 @@ test-results/
|
||||
playwright-report/
|
||||
.uploads/
|
||||
screens/
|
||||
lighthouse/
|
||||
variants.spec.ts-snapshots/
|
||||
|
||||
@@ -100,6 +100,8 @@ test("restore an older version, then publish it", async ({ page, context }) => {
|
||||
await page.getByRole("button", { name: "Restore" }).click();
|
||||
await expect(page.getByText("Version 1 is back in your drafts")).toBeVisible();
|
||||
await page.getByRole("button", { name: "Publish all changes" }).click();
|
||||
// Wait for it, as above: on real Postgres the publish takes long enough to race the page load.
|
||||
await expect(page.getByText("Published: visitors see it now.")).toBeVisible();
|
||||
await page.goto("/about");
|
||||
await expect(page.getByRole("heading", { level: 1, name: "About us" })).toBeVisible();
|
||||
});
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
/**
|
||||
* Lighthouse, mobile (WEBSITE-1.0-PLAN §13, ROADMAP §11 "Checks"): the demo church's home page, an
|
||||
* event and the messages page in each template, with the template's defaults. SEO 100,
|
||||
* accessibility 95+, performance 90+. Lighthouse's default run is a phone on a throttled
|
||||
* connection (simulated), against the production build the other specs use; each page is measured
|
||||
* three times (LIGHTHOUSE_RUNS), with the CPU slowdown calibrated to this machine
|
||||
* (calibratedSlowdown), and the median run counts. Its reports go to
|
||||
* e2e/lighthouse/ (not kept in git) for a look when a score drops.
|
||||
*/
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { chromium, expect, test } from "@playwright/test";
|
||||
import * as chromeLauncher from "chrome-launcher";
|
||||
import lighthouse from "lighthouse";
|
||||
|
||||
const BACKEND = "http://127.0.0.1:5310";
|
||||
const SITE = "http://localhost:3310";
|
||||
const TEMPLATES = ["heritage", "bold", "community", "clean"] as const;
|
||||
const MIN = { seo: 1, accessibility: 0.95, performance: 0.9 } as const;
|
||||
const RUNS = Number(process.env.LIGHTHOUSE_RUNS ?? 3);
|
||||
|
||||
/**
|
||||
* Lighthouse's 4× CPU slowdown stands a fast desktop (its benchmark about 1500) in for a mid-range
|
||||
* phone. On a slower or busy machine the same 4× makes a far slower phone than the target, and the
|
||||
* score measures the machine: here the benchmark moved from 1450 to 460 between runs a minute
|
||||
* apart. So a quick probe reads the benchmark first and the slowdown is scaled to it (at least ×1),
|
||||
* as Lighthouse's throttling notes advise; the thresholds stay the same.
|
||||
*/
|
||||
const slowdownFor = (index: number) => Math.round(Math.min(4, Math.max(1, (4 * index) / 1500)) * 10) / 10;
|
||||
|
||||
async function calibratedSlowdown(url: string): Promise<number> {
|
||||
const probe = await lighthouse(`${SITE}${url}`, { port: chrome.port, logLevel: "error", onlyAudits: ["viewport"] });
|
||||
return slowdownFor(probe?.lhr.environment.benchmarkIndex ?? 1500);
|
||||
}
|
||||
|
||||
/**
|
||||
* One measured run, calibrated. The machine can slow down between the probe and the run; a run
|
||||
* whose own benchmark called for a much smaller slowdown than it used is taken again (twice at most).
|
||||
*/
|
||||
async function measure(url: string) {
|
||||
let r;
|
||||
for (let attempt = 0; attempt < 3; attempt++) {
|
||||
const slowdown = await calibratedSlowdown(url);
|
||||
r = await lighthouse(`${SITE}${url}`, { port: chrome.port, output: "html", logLevel: "error", onlyCategories: Object.keys(MIN), throttling: { cpuSlowdownMultiplier: slowdown } as never });
|
||||
if (!r || slowdown <= slowdownFor(r.lhr.environment.benchmarkIndex) * 1.3) break;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
const reports = path.join(path.dirname(fileURLToPath(import.meta.url)), "lighthouse");
|
||||
|
||||
test.describe.configure({ timeout: 600_000 });
|
||||
|
||||
let chrome: chromeLauncher.LaunchedChrome;
|
||||
test.beforeAll(async () => {
|
||||
fs.mkdirSync(reports, { recursive: true });
|
||||
chrome = await chromeLauncher.launch({ chromePath: chromium.executablePath(), chromeFlags: ["--headless=new", "--no-first-run"] });
|
||||
});
|
||||
test.afterAll(async () => { await chrome?.kill(); });
|
||||
|
||||
for (const template of TEMPLATES) {
|
||||
test(`${template}: home, an event and the messages, on a phone`, async ({ request, page }) => {
|
||||
expect((await request.post(`${BACKEND}/test/demo?template=${template}`)).ok()).toBeTruthy();
|
||||
await page.goto("/events");
|
||||
const event = await page.locator('main a[href^="/events/"]').first().getAttribute("href");
|
||||
expect(event).toBeTruthy();
|
||||
|
||||
const failed: string[] = [];
|
||||
for (const [name, url] of [["home", "/"], ["event", event!], ["messages", "/messages"]] as const) {
|
||||
// Once to warm the server, then measured RUNS times; the median run (by performance) counts,
|
||||
// as Lighthouse advises: one run's total blocking time moves by 200ms+ on a busy machine.
|
||||
await request.get(url);
|
||||
const runs = [];
|
||||
for (let n = 0; n < RUNS; n++) {
|
||||
const r = await measure(url);
|
||||
expect(r, `${template} ${name}`).toBeTruthy();
|
||||
runs.push(r!);
|
||||
}
|
||||
runs.sort((a, b) => (a.lhr.categories.performance?.score ?? 0) - (b.lhr.categories.performance?.score ?? 0));
|
||||
const result = runs[Math.floor(RUNS / 2)];
|
||||
fs.writeFileSync(path.join(reports, `${template}-${name}.html`), String(result!.report));
|
||||
const scores = Object.fromEntries(Object.keys(MIN).map((c) => [c, result!.lhr.categories[c]?.score ?? 0]));
|
||||
const env = result!.lhr.environment;
|
||||
console.log(`[lighthouse] ${template} ${name}: ${Object.entries(scores).map(([c, s]) => `${c} ${Math.round(s * 100)}`).join(", ")} (benchmark ${Math.round(env.benchmarkIndex)}, CPU ×${result!.lhr.configSettings.throttling.cpuSlowdownMultiplier})`);
|
||||
for (const [c, min] of Object.entries(MIN)) {
|
||||
if (scores[c]! < min) {
|
||||
const audits = Object.values(result!.lhr.audits).filter((a) => a.score !== null && a.score < 0.9 && (result!.lhr.categories[c]?.auditRefs ?? []).some((r) => r.id === a.id && r.weight > 0));
|
||||
failed.push(`${template} ${name} ${c} ${Math.round(scores[c]! * 100)} < ${min * 100}: ${audits.map((a) => `${a.id}${a.displayValue ? ` (${a.displayValue})` : ""}`).join(", ")}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
expect(failed).toEqual([]);
|
||||
});
|
||||
}
|
||||
@@ -1,30 +1,68 @@
|
||||
/**
|
||||
* The e2e backend (playwright.config.ts): the Website's backend on port 5310 with the in-memory
|
||||
* database from the backend tests (no Postgres needed) and the demo church published. The pages
|
||||
* run with `next dev` on 3310 and send /api here.
|
||||
* database from the backend tests (no Postgres needed), or a real Postgres with E2E_DATABASE_URL
|
||||
* (freshPostgres, below), and the demo church published. The pages run as a production build on
|
||||
* 3310 and send /api here.
|
||||
*
|
||||
* Test helpers: POST /test/demo?template=<id> loads the demo church on that template;
|
||||
* POST /test/design { variants?, style?, home? } changes the design and publishes again.
|
||||
*/
|
||||
import { execSync } from 'node:child_process';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import express from 'express';
|
||||
import pg from 'pg';
|
||||
import sharp from 'sharp';
|
||||
import { PrismaPg } from '@prisma/adapter-pg';
|
||||
import { websiteTemplateSchema } from '@crosscode/contracts';
|
||||
import { PrismaClient } from '../backend/src/generated/prisma/client.js';
|
||||
import { createApp } from '../backend/src/app.js';
|
||||
import { createCtx } from '../backend/src/context.js';
|
||||
import { loadDemo } from '../backend/src/demo/demoChurch.js';
|
||||
import { illustration, loadDemo } from '../backend/src/demo/demoChurch.js';
|
||||
import { loadConfig } from '../backend/src/lib/config.js';
|
||||
import { hashToken } from '../backend/src/lib/crypto.js';
|
||||
import { publish } from '../backend/src/site/snapshot.js';
|
||||
import { memoryDb } from '../backend/tests/support/memoryDb.js';
|
||||
|
||||
const { Client } = pg;
|
||||
const here = path.dirname(fileURLToPath(import.meta.url));
|
||||
const uploads = path.join(here, '.uploads');
|
||||
fs.mkdirSync(uploads, { recursive: true });
|
||||
|
||||
const db = memoryDb();
|
||||
const ctx = createCtx(loadConfig({ WEBSITE_URL: 'http://localhost:3310', NODE_ENV: 'test', JOBS_ENABLED: 'false', HUB_URL: 'http://127.0.0.1:1', UPLOAD_DIR: uploads, TRUST_PROXY: 'true' }), db as never);
|
||||
const db = process.env.E2E_DATABASE_URL ? await freshPostgres(process.env.E2E_DATABASE_URL) : memoryDb();
|
||||
|
||||
/**
|
||||
* The real-Postgres run (WEBSITE-1.0-PLAN §13): `E2E_DATABASE_URL=postgresql://…/ccw_website_e2e npx
|
||||
* playwright test`. The database is dropped and made again, the migrations applied with `prisma
|
||||
* migrate deploy` (as `crosscode deploy` does), and the same suite runs on it. The name must end in
|
||||
* `_e2e`, so a real site's database is never dropped.
|
||||
*/
|
||||
async function freshPostgres(url: string) {
|
||||
const target = new URL(url);
|
||||
const name = target.pathname.slice(1);
|
||||
if (!/^[a-z0-9_]+_e2e$/.test(name)) throw new Error(`E2E_DATABASE_URL must name a database ending in _e2e (got "${name}").`);
|
||||
const admin = new URL(url);
|
||||
admin.pathname = '/postgres';
|
||||
const pg = new Client({ connectionString: admin.toString() });
|
||||
await pg.connect();
|
||||
await pg.query(`DROP DATABASE IF EXISTS ${name} WITH (FORCE)`);
|
||||
await pg.query(`CREATE DATABASE ${name}`);
|
||||
await pg.end();
|
||||
execSync('npx prisma migrate deploy', { cwd: path.join(here, '../backend'), env: { ...process.env, DATABASE_URL: url }, stdio: 'inherit' });
|
||||
console.log(`[e2e] On Postgres: ${name}, migrations applied.`);
|
||||
return new PrismaClient({ adapter: new PrismaPg({ connectionString: url }) });
|
||||
}
|
||||
// A frozen clock (a Monday morning), so the demo's dates, and so the screenshots, are the same every
|
||||
// run (variants.spec.ts). E2E_NOW changes it.
|
||||
const frozen = new Date(process.env.E2E_NOW ?? '2026-11-23T06:00:00Z');
|
||||
// YouTube's thumbnails (site/thumbnails.ts) without the network: one of the demo's illustrations,
|
||||
// as a JPEG the size of YouTube's, for every video.
|
||||
const thumb = await sharp(Buffer.from(illustration(4, 480, 360))).jpeg().toBuffer();
|
||||
const fakeYoutube = async (url: string) => url.startsWith('https://i.ytimg.com/')
|
||||
? new Response(new Uint8Array(thumb), { headers: { 'content-type': 'image/jpeg' } })
|
||||
: new Response('not here', { status: 404 });
|
||||
const ctx = createCtx(loadConfig({ WEBSITE_URL: 'http://localhost:3310', NODE_ENV: 'test', JOBS_ENABLED: 'false', HUB_URL: 'http://127.0.0.1:1', UPLOAD_DIR: uploads, TRUST_PROXY: 'true' }), db as never, { now: () => new Date(frozen), fetch: fakeYoutube });
|
||||
await loadDemo(ctx, websiteTemplateSchema.parse(process.env.DEMO_TEMPLATE ?? 'heritage'), { uploadDir: uploads });
|
||||
|
||||
const app = express();
|
||||
|
||||
@@ -64,6 +64,19 @@ test("the home page has the church's JSON-LD; unknown pages are a real 404", asy
|
||||
expect((await page.goto("/no-such-page"))?.status()).toBe(404);
|
||||
});
|
||||
|
||||
test("the messages ask nothing of YouTube until play is clicked; their thumbnails come from the site", async ({ page }) => {
|
||||
await useTemplate(page, "heritage");
|
||||
const outside: string[] = [];
|
||||
page.on("request", (r) => { if (/youtube|ytimg|spotify/.test(new URL(r.url()).hostname)) outside.push(r.url()); });
|
||||
await page.goto("/messages");
|
||||
const thumb = page.locator("main img").first();
|
||||
await expect(thumb).toHaveAttribute("src", /^\/api\/thumbnails\/[\w-]+\.jpg$/);
|
||||
await expect.poll(() => thumb.evaluate((i: HTMLImageElement) => i.naturalWidth)).toBeGreaterThan(0);
|
||||
await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
|
||||
await page.waitForLoadState("networkidle");
|
||||
expect(outside).toEqual([]);
|
||||
});
|
||||
|
||||
test("robots.txt keeps the admin out; the sitemap lists the pages", async ({ page }) => {
|
||||
const robots = await (await page.request.get("/robots.txt")).text();
|
||||
expect(robots).toContain("Disallow: /admin");
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
/**
|
||||
* Every section variant in every template (WEBSITE-1.0-PLAN §3, "Checks per variant", and §13): the
|
||||
* demo church's homepage with all eight sections showing, one variant changed at a time. For each,
|
||||
* axe finds no violations (WCAG 2.2 AA) and the section looks as it did last time at phone, tablet
|
||||
* and desktop width: 26 variants × 4 templates × 3 widths = 312 screenshots, compared with
|
||||
* `toHaveScreenshot` against the baselines in e2e/variants.spec.ts-snapshots/.
|
||||
*
|
||||
* The baselines aren't in git (about 20 MB, and each operating system draws text a little
|
||||
* differently): they're kept on the machine that runs the release checks. Take them at a release
|
||||
* (`npx playwright test variants --update-snapshots`, then look through them), and the next
|
||||
* release's run shows every section that changed. The e2e server freezes the clock (E2E_NOW), so
|
||||
* the demo's dates never change between runs. What comes from outside is masked: the video, the
|
||||
* map (OpenStreetMap) and the messages' thumbnails.
|
||||
*/
|
||||
import AxeBuilder from "@axe-core/playwright";
|
||||
import { expect, test, type Page } from "@playwright/test";
|
||||
import { SECTION_TYPES, SECTION_VARIANTS, TEMPLATE_VARIANTS } from "../backend/src/site/variants.js";
|
||||
|
||||
const BACKEND = "http://127.0.0.1:5310";
|
||||
const TEMPLATES = Object.keys(TEMPLATE_VARIANTS) as (keyof typeof TEMPLATE_VARIANTS)[];
|
||||
const WIDTHS = [["phone", { width: 390, height: 844 }], ["tablet", { width: 820, height: 1180 }], ["desktop", { width: 1366, height: 900 }]] as const;
|
||||
// Every section showing, in a fixed order, so the nth <section> in <main> is the nth type here.
|
||||
const HOME = SECTION_TYPES.map((section) => ({ section, hidden: false }));
|
||||
|
||||
async function design(page: Page, variants: Record<string, string>) {
|
||||
const res = await page.request.post(`${BACKEND}/test/design`, { data: { variants, home: HOME } });
|
||||
expect(res.ok()).toBeTruthy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Lazy images load only once scrolled to: go through the page, then wait for every image. The
|
||||
* site's own images must really have loaded (a broken one is "complete" too).
|
||||
*/
|
||||
async function loadImages(page: Page) {
|
||||
await page.evaluate(async () => {
|
||||
for (let y = 0; y < document.body.scrollHeight; y += 500) { window.scrollTo(0, y); await new Promise((r) => setTimeout(r, 40)); }
|
||||
window.scrollTo(0, 0);
|
||||
});
|
||||
await page.waitForFunction(() => Array.from(document.images).every((i) => i.complete), null, { timeout: 30_000 });
|
||||
const broken = await page.evaluate(() => Array.from(document.images)
|
||||
.filter((i) => new URL(i.currentSrc || i.src, location.href).origin === location.origin && i.naturalWidth === 0)
|
||||
.map((i) => i.currentSrc || i.src));
|
||||
expect(broken, "images that didn't load").toEqual([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* A section's screenshot is as big as its box, rounded where it starts and ends on the page. With
|
||||
* fractional heights above it (text, aspect ratios), the same section came out a pixel taller or
|
||||
* shorter from run to run, which fails `toHaveScreenshot` however small the difference. So the
|
||||
* header and every section get their own height rounded up first: each section then starts on a
|
||||
* whole pixel and is the same size every run.
|
||||
*/
|
||||
async function wholePixels(page: Page) {
|
||||
await page.evaluate(() => {
|
||||
// The header and the sections, not what holds them (main grows to fit).
|
||||
const blocks = Array.from(document.querySelectorAll<HTMLElement>("header:not(main header), main > section"));
|
||||
for (const b of blocks) b.style.height = "";
|
||||
const heights = blocks.map((b) => b.getBoundingClientRect().height);
|
||||
blocks.forEach((b, n) => { if (getComputedStyle(b).position !== "fixed") b.style.height = `${Math.ceil(heights[n]!)}px`; });
|
||||
});
|
||||
}
|
||||
|
||||
for (const template of TEMPLATES) {
|
||||
test.describe(`${template} variants`, () => {
|
||||
test.beforeAll(async ({ request }) => {
|
||||
expect((await request.post(`${BACKEND}/test/demo?template=${template}`)).ok()).toBeTruthy();
|
||||
});
|
||||
|
||||
for (const [i, type] of SECTION_TYPES.entries()) {
|
||||
for (const variant of SECTION_VARIANTS[type]) {
|
||||
test(`${type}: ${variant}`, async ({ page }) => {
|
||||
await design(page, { [type]: variant });
|
||||
await page.setViewportSize(WIDTHS[2][1]);
|
||||
expect((await page.goto("/"))?.status()).toBe(200);
|
||||
await expect(page.locator("html")).toHaveAttribute("data-template", template);
|
||||
const sections = page.locator("main > section");
|
||||
await expect(sections).toHaveCount(SECTION_TYPES.length);
|
||||
await loadImages(page);
|
||||
|
||||
const axe = await new AxeBuilder({ page }).withTags(["wcag2a", "wcag2aa", "wcag21aa", "wcag22aa"]).analyze();
|
||||
expect(axe.violations.map((v) => `${v.id} (${v.nodes.length}) ${v.nodes[0]?.target}`)).toEqual([]);
|
||||
|
||||
const section = sections.nth(i);
|
||||
for (const [name, size] of WIDTHS) {
|
||||
await page.setViewportSize(size);
|
||||
await loadImages(page);
|
||||
await wholePixels(page);
|
||||
await expect(section).toHaveScreenshot(`${template}-${type}-${variant}-${name}.png`, {
|
||||
mask: [page.locator("main video"), page.locator("main [data-map]"), page.locator('main img[src*="/api/thumbnails/"]')],
|
||||
animations: "disabled",
|
||||
maxDiffPixelRatio: 0.01,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@crosscode/website-frontend",
|
||||
"version": "0.1.0",
|
||||
"version": "1.0.2",
|
||||
"private": true,
|
||||
"description": "Church Website: the church's public site in its template, and the admin",
|
||||
"scripts": {
|
||||
|
||||
@@ -16,6 +16,11 @@ const PROBLEMS: Record<string, { title: string; text: string; retry: boolean }>
|
||||
text: "Owners and Admins of this website sign in with a second step. Turn on two-step sign-in in your church account, then try again.",
|
||||
retry: true,
|
||||
},
|
||||
ACCOUNTS_NOT_LINKED: {
|
||||
title: "This website isn't linked to your church's sign-in yet",
|
||||
text: "It links by itself shortly after it's installed. Please try again in a minute. If this keeps happening, contact Cross Code.",
|
||||
retry: true,
|
||||
},
|
||||
ACCOUNTS_UNAVAILABLE: {
|
||||
title: "Signing in isn't available right now",
|
||||
text: "The website can't reach your church's sign-in at the moment. Please try again in a few minutes.",
|
||||
|
||||
@@ -66,11 +66,15 @@ h1, h2, h3 {
|
||||
/* Text on a dark background (Bold's cards and bands, a dark section): light, and still AA. */
|
||||
.cc-dark .cc-muted, [data-template="bold"] .cc-card .cc-muted,
|
||||
[data-section-colour="mixed"] .cc-section:not(.cc-own-bg):nth-of-type(3n) .cc-muted { color: rgb(255 255 255 / 0.8); }
|
||||
.cc-dark .cc-link, .cc-dark .cc-eyebrow, [data-template="bold"] .cc-card .cc-link, [data-template="bold"] .cc-card .cc-eyebrow,
|
||||
.cc-dark .cc-link, .cc-dark .cc-eyebrow, .cc-dark .cc-brand-text,
|
||||
[data-template="bold"] .cc-card .cc-link, [data-template="bold"] .cc-card .cc-eyebrow, [data-template="bold"] .cc-card .cc-brand-text,
|
||||
[data-section-colour="mixed"] .cc-section:not(.cc-own-bg):nth-of-type(3n) .cc-link,
|
||||
[data-section-colour="mixed"] .cc-section:not(.cc-own-bg):nth-of-type(3n) .cc-eyebrow { color: rgb(255 255 255); }
|
||||
[data-section-colour="mixed"] .cc-section:not(.cc-own-bg):nth-of-type(3n) .cc-eyebrow,
|
||||
[data-section-colour="mixed"] .cc-section:not(.cc-own-bg):nth-of-type(3n) .cc-brand-text { color: rgb(255 255 255); }
|
||||
|
||||
.cc-muted { color: rgb(75 85 99); }
|
||||
/* The church's colour as text (made AA on light by the palette): here, not a utility, so the dark rules above win. */
|
||||
.cc-brand-text { color: rgb(var(--brand-text)); }
|
||||
.cc-link { color: rgb(var(--brand-text)); @apply underline-offset-4 hover:underline; }
|
||||
.cc-eyebrow { @apply text-sm font-semibold uppercase tracking-widest; color: rgb(var(--brand-text)); }
|
||||
[data-template="heritage"] .cc-eyebrow { @apply font-normal tracking-[0.25em]; font-variant: small-caps; text-transform: none; }
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { NextResponse, type NextRequest } from "next/server";
|
||||
import type { NextRequest } from "next/server";
|
||||
import { localRedirect } from "@/lib/localRedirect";
|
||||
|
||||
/**
|
||||
* A shared preview link (§4): keeps its token in a cookie for the rest of the visit, so every page
|
||||
* shows the working copy. The backend checks the token (7 days, until revoked) on every page.
|
||||
*/
|
||||
export async function GET(request: NextRequest, { params }: { params: Promise<{ token: string }> }) {
|
||||
export async function GET(_request: NextRequest, { params }: { params: Promise<{ token: string }> }) {
|
||||
const { token } = await params;
|
||||
const res = NextResponse.redirect(new URL("/", request.url), 303);
|
||||
const res = localRedirect("/");
|
||||
if (/^[A-Za-z0-9_-]{20,100}$/.test(token)) {
|
||||
res.cookies.set("ccw_preview", token, { httpOnly: true, sameSite: "lax", secure: process.env.NODE_ENV === "production", path: "/", maxAge: 7 * 86400 });
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { NextResponse, type NextRequest } from "next/server";
|
||||
import type { NextRequest } from "next/server";
|
||||
import { localRedirect } from "@/lib/localRedirect";
|
||||
|
||||
/** Leaves the preview: an admin goes back to editing, someone with a shared link to the live site. */
|
||||
export function GET(request: NextRequest) {
|
||||
const admin = request.cookies.get("ccw_preview")?.value === "admin";
|
||||
const trying = !!request.cookies.get("ccw_preview_template")?.value;
|
||||
const to = admin ? (request.nextUrl.searchParams.get("published") ? "/admin/publish" : trying ? "/admin/template" : "/admin") : "/";
|
||||
const res = NextResponse.redirect(new URL(to, request.url), 303);
|
||||
const res = localRedirect(to);
|
||||
res.cookies.delete("ccw_preview");
|
||||
res.cookies.delete("ccw_preview_template");
|
||||
return res;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { NextResponse, type NextRequest } from "next/server";
|
||||
import type { NextRequest } from "next/server";
|
||||
import { localRedirect } from "@/lib/localRedirect";
|
||||
|
||||
/**
|
||||
* Preview (WEBSITE-1.0-PLAN §4): a signed-in admin sees the working copy on the site's own
|
||||
@@ -6,7 +7,7 @@ import { NextResponse, type NextRequest } from "next/server";
|
||||
* on every page (site/preview), so it shows nothing to anyone else.
|
||||
*/
|
||||
export function GET(request: NextRequest) {
|
||||
const res = NextResponse.redirect(new URL("/", request.url), 303);
|
||||
const res = localRedirect("/");
|
||||
const opts = { httpOnly: true, sameSite: "lax" as const, secure: process.env.NODE_ENV === "production", path: "/" };
|
||||
res.cookies.set("ccw_preview", "admin", opts);
|
||||
// "Choose your template": the church's own content in another template, nothing saved.
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
/**
|
||||
* 1.0.2: a 303 to a page of this site with a relative Location ("/admin"), so the browser stays on the
|
||||
* address it's on. `new URL(path, request.url)` used the address the request reached Next.js on,
|
||||
* which behind the proxy is the server's own (http://localhost:<web port>): Preview sent admins there.
|
||||
*/
|
||||
export function localRedirect(path: string): NextResponse {
|
||||
if (!path.startsWith("/") || path.startsWith("//")) throw new Error(`Not a path on this site: ${path}`);
|
||||
return new NextResponse(null, { status: 303, headers: { Location: path } });
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
|
||||
/**
|
||||
* The OpenStreetMap embed, loaded only once it's on screen (no Google, no cookies). An iframe's own
|
||||
* `loading="lazy"` loads anything within about 1,250px of the screen, so on a phone the map
|
||||
* (300 KB of OpenStreetMap's script) loaded with the page and slowed it down (Lighthouse,
|
||||
* WEBSITE-1.0-PLAN §13), and OpenStreetMap saw every visitor. Until then: a link to the map.
|
||||
*/
|
||||
export function LazyMap({ src, href }: { src: string; href: string | null }) {
|
||||
const box = useRef<HTMLDivElement>(null);
|
||||
const [show, setShow] = useState(false);
|
||||
useEffect(() => {
|
||||
const el = box.current;
|
||||
if (!el || typeof IntersectionObserver === "undefined") { setShow(true); return; }
|
||||
const io = new IntersectionObserver((entries) => {
|
||||
if (entries.some((e) => e.isIntersecting)) { setShow(true); io.disconnect(); }
|
||||
}, { rootMargin: "100px" });
|
||||
io.observe(el);
|
||||
return () => io.disconnect();
|
||||
}, []);
|
||||
return (
|
||||
<div ref={box} data-map className="cc-frame min-h-[18rem] bg-gray-100">
|
||||
{show ? (
|
||||
<iframe title="Map" className="h-full min-h-[18rem] w-full border-0" src={src} />
|
||||
) : (
|
||||
href && <a href={href} rel="noopener" className="flex h-full min-h-[18rem] items-center justify-center font-semibold text-gray-700 underline">Open the map</a>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -4,9 +4,11 @@ import { useState } from "react";
|
||||
|
||||
/**
|
||||
* A message's video or audio, loaded only when clicked (WEBSITE-1.0-PLAN §7): a thumbnail first,
|
||||
* then youtube-nocookie or Spotify's player. Nothing loads from YouTube or Spotify until then.
|
||||
* then youtube-nocookie or Spotify's player. Nothing loads from YouTube or Spotify until then: the
|
||||
* thumbnail is served by the site (`/api/thumbnails/<id>.jpg`, backend site/thumbnails.ts).
|
||||
*/
|
||||
export function MessagePlayer({ title, embedUrl, thumbnail, url, source, className }: { title: string; embedUrl: string | null; thumbnail: string | null; url: string; source: "youtube" | "spotify"; className?: string }) {
|
||||
/** `priority`: the first thing on screen (the messages page's first message), so its thumbnail isn't lazy (it's the LCP image). */
|
||||
export function MessagePlayer({ title, embedUrl, thumbnail, url, source, className, priority }: { title: string; embedUrl: string | null; thumbnail: string | null; url: string; source: "youtube" | "spotify"; className?: string; priority?: boolean }) {
|
||||
const [playing, setPlaying] = useState(false);
|
||||
const ratio = source === "spotify" ? "aspect-[16/7]" : "aspect-video";
|
||||
if (playing && embedUrl) {
|
||||
@@ -18,7 +20,7 @@ export function MessagePlayer({ title, embedUrl, thumbnail, url, source, classNa
|
||||
}
|
||||
return (
|
||||
<div className={`cc-frame relative ${ratio} ${className ?? ""} bg-gray-900`}>
|
||||
{thumbnail && <img src={thumbnail} alt="" className="cc-img absolute inset-0 opacity-80" loading="lazy" />}
|
||||
{thumbnail && <img src={thumbnail} alt="" className="cc-img absolute inset-0 opacity-80" {...(priority ? { fetchPriority: "high" as const } : { loading: "lazy" as const })} />}
|
||||
{embedUrl ? (
|
||||
<button type="button" onClick={() => setPlaying(true)} className="absolute inset-0 flex items-center justify-center" aria-label={`Play ${title}`}>
|
||||
<span className="flex h-16 w-16 items-center justify-center rounded-full bg-white/95 text-gray-900 shadow-lg">
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* A page other than home (WEBSITE-1.0-PLAN §6): its title, what its kind lists (ministries,
|
||||
* leaders, events, messages, contact details), then its blocks.
|
||||
*/
|
||||
import { preload } from "react-dom";
|
||||
import { MessagePlayer } from "./MessagePlayer";
|
||||
import { t } from "./load";
|
||||
import { cx, DateBadge, dayName, fmtDate, Img, Paragraphs } from "./parts";
|
||||
@@ -68,13 +69,17 @@ function Listing({ page, site }: { page: Page; site: Published }) {
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
case "messages":
|
||||
case "messages": {
|
||||
// The first thumbnail is the largest thing on screen (Lighthouse's LCP): ask for it from the
|
||||
// <head>, rather than once the HTML has been read. Thumbnails come from the site itself.
|
||||
const thumb = site.messages[0]?.thumbnail;
|
||||
if (thumb) preload(thumb, { as: "image", fetchPriority: "high" });
|
||||
return (
|
||||
<section className="cc-section">
|
||||
<div className="cc-wrap grid gap-10 sm:grid-cols-2">
|
||||
{site.messages.map((m) => (
|
||||
{site.messages.map((m, i) => (
|
||||
<article key={m.slug} id={m.slug} className="scroll-mt-24">
|
||||
<MessagePlayer title={m.title} embedUrl={m.embedUrl} thumbnail={m.thumbnail} url={m.url} source={m.source} />
|
||||
<MessagePlayer title={m.title} embedUrl={m.embedUrl} thumbnail={m.thumbnail} url={m.url} source={m.source} priority={i === 0} />
|
||||
{m.series && <p className="cc-eyebrow mt-4">{m.series}</p>}
|
||||
<h2 className="cc-h3 mt-1">{m.title}</h2>
|
||||
<p className="cc-muted text-sm">{[m.speaker, m.passage, fmtDate(m.date, zone, { day: "numeric", month: "long", year: "numeric" })].filter(Boolean).join(" · ")}</p>
|
||||
@@ -83,6 +88,7 @@ function Listing({ page, site }: { page: Page; site: Published }) {
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
case "contact": {
|
||||
const c = site.church;
|
||||
if (!c) return null;
|
||||
|
||||
@@ -90,7 +90,7 @@ export function messagesLd(site: Published, messages: SiteMessage[]): string | n
|
||||
const description = [m.speaker, m.passage, m.series].filter(Boolean).join(" · ") || m.title;
|
||||
return m.source === "spotify"
|
||||
? { "@type": "PodcastEpisode", name: m.title, datePublished: m.date.slice(0, 10), description, url: m.url }
|
||||
: { "@type": "VideoObject", name: m.title, uploadDate: m.date, description, ...(m.thumbnail ? { thumbnailUrl: [m.thumbnail] } : {}), ...(m.embedUrl ? { embedUrl: m.embedUrl.replace("?autoplay=1", "") } : {}), contentUrl: m.url };
|
||||
: { "@type": "VideoObject", name: m.title, uploadDate: m.date, description, ...(m.thumbnail ? { thumbnailUrl: [abs(site, m.thumbnail)] } : {}), ...(m.embedUrl ? { embedUrl: m.embedUrl.replace("?autoplay=1", "") } : {}), contentUrl: m.url };
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* The homepage sections after the hero (WEBSITE-1.0-PLAN §3), each in its variants. Templates
|
||||
* restyle the same markup through globals.css (cc-* classes) and the `t()` choices here.
|
||||
*/
|
||||
import { LazyMap } from "../LazyMap";
|
||||
import { MessagePlayer } from "../MessagePlayer";
|
||||
import { media, str, t } from "../load";
|
||||
import { Button, cx, DateBadge, dayName, fmtDate, fmtTime, Img, Paragraphs, Picture, SectionHeading, type ButtonData } from "../parts";
|
||||
@@ -62,7 +63,7 @@ function ServiceTimes(p: SectionProps) {
|
||||
}
|
||||
|
||||
const panel = (
|
||||
<div className={cx("p-8", t(p.template, { heritage: "border-4 border-double border-brand-text/40 text-center", bold: "bg-gray-950 text-white", community: "cc-card", clean: "border-l-4 border-accent" }))}>
|
||||
<div className={cx("p-8", t(p.template, { heritage: "border-4 border-double border-brand-text/40 text-center", bold: "cc-dark bg-gray-950 text-white", community: "cc-card", clean: "border-l-4 border-accent" }))}>
|
||||
<h2 className="cc-h2 mb-6">{heading}</h2>
|
||||
<Times p={p} className={p.template === "heritage" ? "inline-block text-left" : ""} />
|
||||
{d.note && <p className="cc-muted mt-6">{d.note}</p>}
|
||||
@@ -82,11 +83,8 @@ function ServiceTimes(p: SectionProps) {
|
||||
<div className="cc-wrap grid items-stretch gap-8 md:grid-cols-2">
|
||||
{panel}
|
||||
{geo ? (
|
||||
<div className="cc-frame min-h-[18rem]">
|
||||
{/* OpenStreetMap, loaded only when scrolled to (no Google, no cookies). */}
|
||||
<iframe title="Map" loading="lazy" className="h-full min-h-[18rem] w-full border-0"
|
||||
src={`https://www.openstreetmap.org/export/embed.html?bbox=${geo.lng - 0.006}%2C${geo.lat - 0.004}%2C${geo.lng + 0.006}%2C${geo.lat + 0.004}&layer=mapnik&marker=${geo.lat}%2C${geo.lng}`} />
|
||||
</div>
|
||||
<LazyMap href={dir}
|
||||
src={`https://www.openstreetmap.org/export/embed.html?bbox=${geo.lng - 0.006}%2C${geo.lat - 0.004}%2C${geo.lng + 0.006}%2C${geo.lat + 0.004}&layer=mapnik&marker=${geo.lat}%2C${geo.lng}`} />
|
||||
) : <Img image={null} ratio="min-h-[18rem]" />}
|
||||
</div>
|
||||
</Section>
|
||||
@@ -302,8 +300,9 @@ function Events(p: SectionProps) {
|
||||
<ol className="flex snap-x gap-4 overflow-x-auto pb-4">
|
||||
{list.map((e) => (
|
||||
<li key={e.url + e.startsAt} className="cc-card w-64 shrink-0 snap-start p-5">
|
||||
<p className="font-heading text-4xl font-bold text-brand-text">{fmtDate(e.startsAt, zone, { day: "numeric" })}</p>
|
||||
<p className="cc-eyebrow">{fmtDate(e.startsAt, zone, { month: "long", weekday: "short" })}</p>
|
||||
<p className="font-heading text-4xl font-bold cc-brand-text">{fmtDate(e.startsAt, zone, { day: "numeric" })}</p>
|
||||
{/* A weekday and month without a day is "Sun (month: November)" to Intl: two parts. */}
|
||||
<p className="cc-eyebrow">{fmtDate(e.startsAt, zone, { weekday: "short" })} · {fmtDate(e.startsAt, zone, { month: "long" })}</p>
|
||||
<h3 className="cc-h3 mt-3"><a href={e.url} className="no-underline hover:underline">{e.title}</a></h3>
|
||||
{!e.allDay && <p className="cc-muted text-sm">{fmtTime(e.startsAt, zone)}</p>}
|
||||
</li>
|
||||
|
||||
@@ -2,7 +2,8 @@ import { defineConfig, devices } from "@playwright/test";
|
||||
|
||||
// The Website end to end (docs/WEBSITE-1.0-PLAN.md §13): the real backend on an in-memory database
|
||||
// with the demo church (e2e/server.ts), and the Next.js pages (a production build). Run with `npx playwright test` in
|
||||
// apps/website. Nothing needs a database.
|
||||
// apps/website. Nothing needs a database; set E2E_DATABASE_URL (a database ending in _e2e, dropped and
|
||||
// made again) to run the same suite on real Postgres. E2E_REUSE=1 uses servers already running on 5310 / 3310.
|
||||
export default defineConfig({
|
||||
testDir: "./e2e",
|
||||
testMatch: "**/*.spec.ts",
|
||||
@@ -19,7 +20,7 @@ export default defineConfig({
|
||||
command: "npx tsx e2e/server.ts",
|
||||
url: "http://127.0.0.1:5310/api/health",
|
||||
timeout: 120_000,
|
||||
reuseExistingServer: false,
|
||||
reuseExistingServer: !!process.env.E2E_REUSE,
|
||||
stdout: "pipe",
|
||||
},
|
||||
{
|
||||
@@ -28,7 +29,7 @@ export default defineConfig({
|
||||
cwd: "frontend",
|
||||
url: "http://localhost:3310/robots.txt",
|
||||
timeout: 300_000,
|
||||
reuseExistingServer: false,
|
||||
reuseExistingServer: !!process.env.E2E_REUSE,
|
||||
env: { WEBSITE_API_URL: "http://127.0.0.1:5310", WEBSITE_CONTENT_CACHE_SECONDS: "0" },
|
||||
},
|
||||
],
|
||||
|
||||
+18
-4
@@ -1,6 +1,6 @@
|
||||
# Handover — Cross Code, all products
|
||||
|
||||
Last updated: 2026-11-25. **The plan is [ROADMAP-v3.md](./ROADMAP-v3.md)** (decided 2026-11-03,
|
||||
Last updated: 2026-11-26. **The plan is [ROADMAP-v3.md](./ROADMAP-v3.md)** (decided 2026-11-03,
|
||||
decisions table near the end). This file says where each phase stands and what comes next.
|
||||
Product-specific notes (where the code lives, known gaps) stay with each product: Cross Events'
|
||||
are in [`apps/events/docs/HANDOVER.md`](../apps/events/docs/HANDOVER.md), and the Hub's are in
|
||||
@@ -34,7 +34,7 @@ every release).
|
||||
| 3 | Accounts 1.0.0 | **Released, rolled out and tested** (now `accounts@1.6.0`; [ACCOUNTS-1.0-PLAN.md](./ACCOUNTS-1.0-PLAN.md)) |
|
||||
| 4 | Cross Events 3.0.0: sign-in through Accounts | **Released, rolled out and tested** (now `events@3.7.0`; [EVENTS-3.0-PLAN.md](./EVENTS-3.0-PLAN.md)). Churches sign in through their Accounts; crosscode-site `v1.6.0` deployed |
|
||||
| 4+ | Running it: jobs from the dashboard, styled emails, .env from the Hub, sign-in health, the nightly people check; then frp config and one-product uninstalls, and the Hub's popups, pickers and port list | **Released, deployed and tested** 2026-11-20 and 2026-11-23 (below) |
|
||||
| 5 | Church Website 1.0.0 | **Being built** (planned 2026-11-21: [WEBSITE-1.0-PLAN.md](./WEBSITE-1.0-PLAN.md) , all decisions confirmed). Font pairings confirmed 2026-11-24, section variants per template 2026-11-25 (§3). `contracts@1.17.0`, `accounts@1.7.0` and `events@3.7.0` released 2026-11-24, Hub `v2.21.0` 2026-11-25 (the Hub deployed 2026-11-25; the others not rolled out yet). `contracts@1.18.0` and Hub `v2.22.0` (Get more storage) released 2026-11-25, not deployed. `apps/website` being built (0.1.0); `website@1.0.0` next |
|
||||
| 5 | Church Website 1.0.0 | **Released 2026-11-26** (planned 2026-11-21: [WEBSITE-1.0-PLAN.md](./WEBSITE-1.0-PLAN.md), all decisions confirmed). Font pairings confirmed 2026-11-24, section variants per template 2026-11-25 (§3). `contracts@1.17.0`, `accounts@1.7.0` and `events@3.7.0` released 2026-11-24, Hub `v2.21.0` 2026-11-25 (the Hub deployed 2026-11-25; the others not rolled out yet). `contracts@1.18.0` and Hub `v2.22.0` (Get more storage) released 2026-11-25, the Hub deployed 2026-11-26. **`website@1.0.0` and `1.0.1` released 2026-11-26**, crosscode-site `v1.7.0` (the Website on sale) released 2026-11-26, not deployed yet. Left: deploy the site, Hope Family Church, a second church |
|
||||
| 6–7 | App 1.0.0 → App 1.x | Not started |
|
||||
|
||||
## Released 2026-11-23
|
||||
@@ -102,8 +102,22 @@ out").
|
||||
[WEBSITE-1.0-PLAN.md](./WEBSITE-1.0-PLAN.md): decisions all confirmed 2026-11-21. Font pairings
|
||||
confirmed 2026-11-24 (§3). Order: ~~contracts 1.17.0~~ → ~~Accounts 1.7.0~~ (both released 2026-11-24; Accounts
|
||||
ships with contracts because it answers the new `church.update`) → ~~Events 3.7.0~~ (shared fonts and footer; released 2026-11-24) → ~~Hub 2.21.0~~ (released
|
||||
and deployed 2026-11-25; the plan said 2.13.0) → **`website@1.0.0`** (being built in `apps/website` since 2026-11-25: signing in, the four templates and public site, the admin with preview, publish and restore, people and roles, messages with the YouTube feed, simple events, responsive photo sizes without metadata, the event feed both ways, church details through Accounts, settings, audit log, search engine data and redirects, Get more storage (with `contracts@1.18.0` and Hub `v2.22.0`, released 2026-11-25, Hub not deployed); next: screenshot comparison, Lighthouse, axe on every variant, a real-Postgres run, the release checks and the VM test) → Hope Family Church → a second
|
||||
church → crosscode-site 1.7.0.
|
||||
and deployed 2026-11-25; the plan said 2.13.0) → ~~`website@1.0.0`~~ (released 2026-11-26, with
|
||||
`contracts@1.18.0` and Hub `v2.22.0`, deployed 2026-11-26; the release checks are in
|
||||
WEBSITE-1.0-PLAN §13, "Where they are"; the VM test was skipped, so watch the first install
|
||||
closely) → ~~`website@1.0.1`~~ (released 2026-11-26: the messages' thumbnails served from the
|
||||
site, the Calendar dates; VERSIONS.md) → **Hope Family Church**: roll out Accounts 1.7.0 and
|
||||
Events 3.7.0 first (neither is rolled out yet), then New install → Website (1.0.1) → a second
|
||||
church on a different template. ~~crosscode-site 1.7.0~~ (the Website on sale, released 2026-11-26;
|
||||
the Hub already had its prices): **deploy it** (`deploy/deploy.sh` on the server) once Hope
|
||||
Family Church's Website is live, so the first church to buy it isn't the first install.
|
||||
The release checks are all run on 1.0.1's build (WEBSITE-1.0-PLAN §13, "Where they are"): every
|
||||
variant passes axe, the 312 screenshots have baselines (taken again with whole-pixel section
|
||||
heights), Lighthouse passes 12 of 12. Still to do:
|
||||
- **Look through the variant baselines** once (the contact sheet: Bold, Community and Clean were
|
||||
taken, not compared, the first time). A section drawn wrong there is the reference until then.
|
||||
- **The VM test was skipped**: before Hope Family Church, a throwaway install from the Hub (New
|
||||
install → Website 1.0.0, update it to 1.0.1, uninstall with its export) in its place.
|
||||
Done (confirmed by Joshua 2026-11-25): `hope-events` is archived, and every FastPanel site set up
|
||||
before Hub 2.10.0, and the Hub's own site, has `location ^~ /api/`.
|
||||
|
||||
|
||||
+58
-9
@@ -1,6 +1,6 @@
|
||||
# Versions — the latest release of everything
|
||||
|
||||
Last updated: 2026-11-25. Taken from the git tags, which is what a release is here (branch → merge →
|
||||
Last updated: 2026-11-26. Taken from the git tags, which is what a release is here (branch → merge →
|
||||
tag → push, see [HANDOVER.md](./HANDOVER.md) "Releasing"). **Update this file with every release.**
|
||||
|
||||
"Released" means tagged and pushed. Whether a release is **deployed** or rolled out is recorded
|
||||
@@ -10,12 +10,13 @@ separately below; the two often differ.
|
||||
|
||||
| What | Repo | Latest | Tag | Released |
|
||||
|------|------|--------|-----|----------|
|
||||
| Cross Events | `crosscode-platform` (`apps/events`) | **3.7.0** | `events@3.7.0` | 2026-11-24 |
|
||||
| Accounts | `crosscode-platform` (`apps/accounts`) | **1.7.0** | `accounts@1.7.0` | 2026-11-24 |
|
||||
| Cross Events | `crosscode-platform` (`apps/events`) | **3.7.1** | `events@3.7.1` | 2026-11-26 |
|
||||
| Church Website | `crosscode-platform` (`apps/website`) | **1.0.2** | `website@1.0.2` | 2026-11-26 |
|
||||
| Accounts | `crosscode-platform` (`apps/accounts`) | **1.7.1** | `accounts@1.7.1` | 2026-11-26 |
|
||||
| Server agent | `crosscode-platform` (`apps/agent`) | **1.5.0** | `agent@1.5.0` | 2026-11-23 |
|
||||
| Contracts | `crosscode-platform` (`packages/contracts`) | **1.18.0** | `contracts@1.18.0` | 2026-11-25 |
|
||||
| Cross Code Hub | `events-hub` | **2.22.0** | `v2.22.0` | 2026-11-25 |
|
||||
| crosscode.co.za | `crosscode-site` | **1.6.1** | `v1.6.1` | 2026-11-23 |
|
||||
| Cross Code Hub | `events-hub` | **2.23.1** | `v2.23.1` | 2026-11-26 |
|
||||
| crosscode.co.za | `crosscode-site` | **1.7.0** | `v1.7.0` | 2026-11-26 |
|
||||
| `crosscode` script | `crosscode-platform` (`scripts/`) | `main` | none | 2026-11-23 (last change: uninstall, export and purge one product of a church) |
|
||||
|
||||
The `crosscode` script has no version: every server's copy (`/opt/crosscode/tools`) pulls `main`
|
||||
@@ -29,7 +30,7 @@ on each run, so merging to `main` and pushing releases it. Its changes are liste
|
||||
| `@crosscode/auth-client` | `packages/auth-client` | 1.1.0 (released with Events 3.0.0 and Accounts 1.1.0) |
|
||||
| `@crosscode/seo` | `packages/seo` | 1.0.0 (released with Events 2.4.0) |
|
||||
| `@crosscode/ui` | `packages/ui` | 0.3.0 (fonts, `ChurchFooter`; 0.2.0 with Accounts 1.7.0, 0.3.0 with Events 3.7.0) |
|
||||
| Website | `apps/website` | 0.1.0 (phase 5, being built; `website@1.0.0` after the Lighthouse, real-Postgres and VM runs. Built so far: signing in through Accounts, the four templates and public site, the admin with drafts, preview, publish and restore, people and roles, messages with the YouTube feed, simple events, the event feed both ways, church details, settings, audit log, search engine data, Get more storage; HANDOVER "Next up") |
|
||||
| Website | `apps/website` | 1.0.2 (1.0.0–1.0.2 released 2026-11-26; installed for the demo church cross-demo2 (1.0.1) only, Hope Family Church next) |
|
||||
| App | `apps/app` | 0.0.0 (not started, phase 6) |
|
||||
|
||||
These shared packages ship inside the apps that use them, from the same checkout, so they don't
|
||||
@@ -37,12 +38,53 @@ need their own tags until something outside this repo depends on them.
|
||||
|
||||
## What each latest release was for
|
||||
|
||||
- **Accounts 1.7.1 + Church Website 1.0.2 + Cross Events 3.7.1 (2026-11-26):** found installing
|
||||
the Website for cross-demo2. All three: a connect involving an install that isn't in the cached
|
||||
copy of the Hub's list yet asks the Hub for a fresh one (one heartbeat, at most once a minute)
|
||||
instead of refusing, so a new product links straight away. Before, the new Website's admin
|
||||
couldn't sign in for up to 30 minutes ("can't reach your church's sign-in"). Accounts also sends a
|
||||
heartbeat on every start. The Website links on the spot when someone opens `/admin`, its problem
|
||||
page says "not linked yet" (`ACCOUNTS_NOT_LINKED`), and **Preview no longer redirects to the
|
||||
server's own `http://localhost:<web port>`** (the preview routes built absolute URLs from
|
||||
`request.url`; now relative). No migrations. Checked: the backend tests (Accounts 80, Website 100,
|
||||
Events 801), typechecks, the Website's frontend lint and build, the preview redirects against
|
||||
`next start`, and the Website's e2e suite. **Not deployed yet.**
|
||||
- **Hub 2.23.1 (2026-11-26):** New install reads a church's Accounts version from its heartbeat,
|
||||
not the install record. The record only changed with the Hub's own jobs for that product, so
|
||||
cross-demo2's Accounts, updated alongside Events 3.7.0, still showed 1.6.0 there. New install →
|
||||
Website was refused ("this church has 1.6.0") while the installs list showed 1.7.0. Each heartbeat
|
||||
now also updates the record's version. No migration. **Deployed 2026-11-26.**
|
||||
- **Hub 2.23.0 (2026-11-26):** release requirements carry forward. A release needs what every
|
||||
earlier release of its product needed (the highest version per product; a later heading can raise
|
||||
it, never lower or drop it), so `— requires accounts 1.7.0` is written once in WHATS-NEW.md, on
|
||||
the release that first needs it. Found when New install → Website 1.0.1 sent a Website-only
|
||||
`install` job, which agent 1.5.0 refused ("installs one product at a time: Events or Accounts"):
|
||||
1.0.1's heading didn't repeat 1.0.0's requirement, so Accounts wasn't installed first. No
|
||||
migration; the next release sync fixes the stored requirements. **Deployed 2026-11-26.**
|
||||
- **Church Website 1.0.1 (2026-11-26):** the messages' YouTube thumbnails are served from the site
|
||||
(`/api/thumbnails/<id>.jpg`, fetched once by the backend and kept in `uploads/.thumbnails/`), so a
|
||||
visitor asks nothing of YouTube until pressing play (plan §7); the Calendar events' dates read
|
||||
"Sun · November", not "Sun (month: November)". No migration. Checked: the backend tests (97),
|
||||
the whole e2e suite on the release build (Lighthouse 12 of 12, performance 90–100: Heritage's
|
||||
messages from 89 to 95), the 312 variant screenshots (taken again with whole-pixel section heights,
|
||||
which ended a one-pixel flake), and an e2e check that the messages page makes no request to
|
||||
YouTube or Spotify before a click. The `crosscode` script's Website export leaves out
|
||||
`uploads/.thumbnails`. **Not installed for a church yet.**
|
||||
- **Church Website 1.0.0 (2026-11-26):** the first release (WEBSITE-1.0-PLAN): four templates with
|
||||
section variants and style settings, drafts, preview and one Publish, people and roles, messages
|
||||
from YouTube, simple events and the event feed, church details through Accounts, SEO, Get more
|
||||
storage. Requires Accounts 1.7.0. Checked before tagging: the backend tests, the e2e suite (every
|
||||
template, the admin flows, Lighthouse on a phone; axe on every section variant ran in full on an
|
||||
earlier build and on 36 of 104 on the final one), the admin flows
|
||||
and pages on real Postgres (20/20), a backup restored (every table the same) and the uninstall
|
||||
export on Postgres, the migrations against the schema. The VM test was skipped (no VM on
|
||||
this machine; the install path was read through instead). **Not installed for a church yet.**
|
||||
|
||||
- **Contracts 1.18.0 + Hub 2.22.0 (2026-11-25):** "Get more storage" for the Church Website (WEBSITE-1.0-PLAN
|
||||
§10, decision 12). Contracts: `hub.storageRequestSchema` and its reply. Hub: `POST
|
||||
/api/installs/storage-request` (shown on the install, Joshua emailed once, closed when the licence
|
||||
gets more extra storage steps), and the church emailed once at 80% and once when full, from the
|
||||
Website's heartbeat. The Hub vendors contracts 1.18.0. No migration. **Not deployed yet** (the Hub
|
||||
still runs 2.21.0 below); nothing uses it until the Website is installed.
|
||||
Website's heartbeat. The Hub vendors contracts 1.18.0. No migration. **Deployed 2026-11-26.**
|
||||
- **Hub 2.21.0 (2026-11-25):** New install offers the Church Website (Accounts first, at
|
||||
`accounts.<its address>`); the FastPanel email sends a `www.` site's bare domain to `www.` with a
|
||||
301. Extra Website storage is bought in 5 GB steps on the licence (Edit → Extra storage), sent to
|
||||
@@ -101,6 +143,13 @@ need their own tags until something outside this repo depends on them.
|
||||
release in a ⋯ menu); contact and billing details are one form; the history is one timeline with
|
||||
a filter. Record payment is a popup on Billing too. Frontend only: no migration, no API changes.
|
||||
Deployed 2026-11-23.
|
||||
- **crosscode.co.za 1.7.0 (2026-11-26):** the Church Website on sale (ROADMAP §9, phase 5): its own
|
||||
page (`/products/church-website/`: features, the four templates with the same fictional demo church
|
||||
in each, the section layouts, R99 a month, founding R64, extra storage R20 per 5 GB, the 15% bundle
|
||||
with Cross Events, FAQ, `SoftwareApplication` JSON-LD with its offer) and a page per template; the
|
||||
products and home pages, the contact form's topics, the Cross Events page and the brochure updated.
|
||||
Screenshots from the Website's e2e demo (`npm run screenshots:website`). The Hub already had these
|
||||
prices (2.21.0). **Not deployed yet** (`deploy/deploy.sh` on the server).
|
||||
- **crosscode.co.za 1.6.1 (2026-11-23):** the web address choices on the Cross Events page are three
|
||||
cards (name, price, "best if", an example address, short points); the option names were white on
|
||||
a light background and couldn't be seen. Prices unchanged. Deployed 2026-11-23.
|
||||
@@ -229,7 +278,7 @@ you deploy one.
|
||||
|
||||
| What | Running | Since | Notes |
|
||||
|------|---------|-------|-------|
|
||||
| Hub | 2.21.0 | 2026-11-25 | Church Website in New install; `www.` redirect in the FastPanel email; extra Website storage on the licence (migration `Licence.extraStorageSteps`); vendors contracts 1.17.0 |
|
||||
| Hub | 2.23.1 | 2026-11-26 | A church's Accounts version comes from its heartbeat in New install, and heartbeats keep the install record's version current. Before it, 2.23.0 (2026-11-26): release requirements carry forward (`requires accounts …` written once in WHATS-NEW.md) |
|
||||
| Agent on church-server1 | 1.5.0 | 2026-11-23 | Uninstalls one product of a church at a time |
|
||||
| Agent on the central server | 1.5.0 | 2026-11-23 | Reads and changes frps's config from the Hub (no longer read-only; decision 35 superseded) |
|
||||
| Cross Events (churches) | 3.6.1 | 2026-11-20 | Every install adopted onto the monorepo and signing in through Accounts |
|
||||
|
||||
@@ -529,6 +529,31 @@ only freed when neither the working copy nor the last 10 published versions use
|
||||
- **The release checks** (ROADMAP §9) for the Website, and the **VM test**: install the Website
|
||||
next to Accounts and Events through the agent, update it, uninstall it with its export.
|
||||
|
||||
**Where they are (2026-11-26):** `apps/website/e2e/`: `templates.spec.ts` and `admin.spec.ts` (the
|
||||
pages and flows), `variants.spec.ts` (every variant: axe and the 312 screenshots, compared with
|
||||
baselines kept on the machine that runs them, not in git), `lighthouse.spec.ts` (mobile, the median
|
||||
of three runs with the CPU slowdown calibrated to the machine). `E2E_DATABASE_URL=…_e2e` runs the
|
||||
whole suite on real Postgres.
|
||||
|
||||
**Run again on the release build (2026-11-26):** `npx playwright test variants lighthouse`, 19.6 minutes.
|
||||
Every variant in every template passes axe. The screenshot baselines are complete: the 37 that existed
|
||||
(Heritage, and Bold up to Ministries) matched, and the other 67 variants' 201 screenshots were taken
|
||||
(they still need a look through). Lighthouse (mobile): SEO and accessibility 100 on every page;
|
||||
performance 92–99 except Heritage's messages, 89 (LCP 3.0 s: the first message's YouTube thumbnail,
|
||||
from `i.ytimg.com`). Community's home, 84 in the run before, was 97: the machine's benchmark moved
|
||||
between 1169 and 2542 in one run, so a score within a few points of 90 is worth a second run before
|
||||
it counts as a regression. Found in the screenshots: the Calendar events variant prints the date as
|
||||
"Sun (month: November)" (for `website@1.0.1`).
|
||||
|
||||
**On 1.0.1 (2026-11-26):** the whole suite, `npx playwright test` (129 tests, 34.6 minutes): the admin
|
||||
flows, every template's pages, Lighthouse 12 of 12 (performance 90–100; Heritage's messages 95, the
|
||||
thumbnail now from the site), and a new check that the messages page asks nothing of YouTube or
|
||||
Spotify before play. Seven variant screenshots failed by a pixel of height in that run and passed
|
||||
when run again: a section starting at a fractional position came out 534 or 535 pixels tall.
|
||||
`variants.spec.ts` now rounds the header's and each section's height up before the screenshot
|
||||
(`wholePixels`), and the 312 baselines were taken again with it (113 came out the same), then
|
||||
compared in a second full run of the variants.
|
||||
|
||||
## 14. Releasing and rolling it out
|
||||
|
||||
1. `contracts@1.17.0`, then `accounts@1.7.0` (the profile's brand style), then `events@3.7.0`.
|
||||
|
||||
Generated
+1739
-7
File diff suppressed because it is too large
Load Diff
@@ -35,9 +35,11 @@
|
||||
"@types/jest": "^30.0.0",
|
||||
"@types/node": "^20.19.43",
|
||||
"bats": "^1.13.0",
|
||||
"chrome-launcher": "^1.2.3",
|
||||
"concurrently": "^9.2.1",
|
||||
"eslint": "^10.13.0",
|
||||
"jest": "^30.5.2",
|
||||
"lighthouse": "^13.6.0",
|
||||
"shellcheck": "^4.1.0",
|
||||
"ts-jest": "^29.4.15",
|
||||
"tsup": "^9.0.0",
|
||||
|
||||
@@ -98,7 +98,8 @@ website_copy_uploads() {
|
||||
local uploads
|
||||
uploads="$(website_app "$1")/backend/uploads"
|
||||
mkdir -p "$2"
|
||||
[ ! -d "$uploads" ] || rsync -a "$uploads/" "$2/"
|
||||
# .thumbnails is the messages' YouTube thumbnails kept by the site (fetched again), not the church's.
|
||||
[ ! -d "$uploads" ] || rsync -a --exclude .thumbnails "$uploads/" "$2/"
|
||||
}
|
||||
|
||||
# What uninstall keeps for 30 days: the backups and the .env (its WEBSITE_SECRET decrypts what's stored).
|
||||
|
||||
Reference in New Issue
Block a user