website 1.8.0: demo scenarios (the scenario's people lead, Events' events through the feed)

- `npm run demo -- --profile <p> --scenario <p>`: each profile's `scenarioTeam` names four
  parts, roles and portraits; the names are the scenario's people from @crosscode/demo, the
  pastor first (home page and messages' speaker).
- With a linked Cross Events, a scenario load makes no events of its own, turns on Show events
  from and fetches Events' whole feed at once; an unreachable Events doesn't fail the load.
- A scenario on a site with no church profile saves the scenario's church, not Acacia Hill.
- crosscode script: `crosscode demo <church> website --scenario` passes it on and refuses a
  Website before 1.8.0; the Website installs and builds packages/demo.
- Docs: HANDOVER, APP-1.0-PLAN, VERSIONS, CHANGELOGs, What's New.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-30 15:23:12 +02:00
co-authored by Claude Opus 5.5
parent b2a163bb39
commit c8e270dbf1
17 changed files with 315 additions and 76 deletions
+66 -11
View File
@@ -8,6 +8,10 @@
* icon and the admins, and name the church in the copy. A template alone (development, e2e) is
* still Acacia Hill, profile and all, exactly as before.
*
* 1.8.0: a demo scenario (`--scenario`, APP-1.0-PLAN §12) loads a profile as part of the same
* church in every product: the leaders are the scenario's people (`@crosscode/demo`), and with a
* linked Cross Events the site shows Events' events through the feed instead of making its own.
*
* It replaces the Website's content (never the admins), so the script refuses on a site that has
* been published unless told otherwise.
*/
@@ -18,12 +22,13 @@ import { fileURLToPath } from 'node:url';
import { CHURCH_SCHEMA, WEBSITE_TEMPLATES, type agent, type Church, type WebsiteTemplate } from '@crosscode/contracts';
import type { Ctx } from '../context.js';
import { churchProfile } from '../church/profile.js';
import { markRemoved, notifyLinks } from '../feed/feed.js';
import { demoChurch, demoParts, demoPeople } from '@crosscode/demo';
import { markRemoved, notifyLinks, syncLink, type SyncResult } from '../feed/feed.js';
import type { SectionData } from '../site/sections.js';
import { publish } from '../site/snapshot.js';
import { TEMPLATE_HEADERS, TEMPLATE_VARIANTS, SECTION_TYPES, defaultDesign, type SiteDesign } from '../site/variants.js';
import { MAX_WIDTH, WIDTHS, processImage, type Sizes } from '../admin/media.js';
import { DEMO_SEEDS, type DemoPhotos, type DemoSeed } from './seeds.js';
import { DEMO_SEEDS, type DemoPhotos, type DemoSeed, type ProfileSeed } from './seeds.js';
export const DEMO_COLOURS = { primary: '#1d5c63', accent: '#e0a458' };
@@ -57,6 +62,41 @@ export function demoProfile(publicUrl: string): Church {
} as Church;
}
/**
* 1.8.0: a scenario's church as a profile, for a scenario loaded on a site that has no profile at
* all (Accounts normally has it first and the site reads it from there).
*/
export function scenarioProfile(publicUrl: string, scenario: agent.DemoScenarioKey): Church {
const p = demoChurch(scenario).profile;
const base = demoProfile(publicUrl);
return {
...base,
name: p.name, shortName: p.shortName, timezone: p.timezone, locale: p.locale, campuses: p.campuses, serviceTimes: p.serviceTimes, social: p.social,
branding: { ...base.branding, colours: p.colours, style: p.style },
contact: { ...p.contact, phone: null, whatsapp: null },
links: { ...base.links, accounts: `https://example.com/accounts/${demoChurch(scenario).slug}` },
} as Church;
}
/**
* 1.8.0: a profile's seed with the scenario's people as its leaders (`scenarioTeam`), the pastor
* first, each with the portrait chosen for them.
*/
export function scenarioSeed(seed: ProfileSeed, scenario: agent.DemoScenarioKey): DemoSeed {
const parts = demoParts(scenario);
const leads = demoPeople(scenario).filter((p) => parts.has(p.email));
const team = seed.scenarioTeam.map(([part, role, photo]) => {
const person = leads.find((p) => parts.get(p.email)!.includes(part));
if (!person) throw new Error(`The ${scenario} scenario has no one who is ${part}.`);
return { name: person.name, role, photo };
});
return {
...seed,
leaders: team.map((l) => [l.name, l.role]),
photos: { ...seed.photos, pastor: team[0]!.photo, team: [team[1]!.photo, team[2]!.photo, team[3]!.photo] },
};
}
/** Hills, a sun and a path in the church's colours (SVG): what stands in for a demo photo that is missing. */
export function illustration(seed: number, w = 1600, h = 1000, colours: { primary: string; accent: string } = DEMO_COLOURS): string {
const hues = [colours.primary, colours.accent, '#7fb7be', '#f3e3c3', '#284b52'];
@@ -132,14 +172,14 @@ async function demoAsset(ctx: Ctx, uploadDir: string, key: string, alt: string,
}
/** The demo's pictures by slot (hero, collage2, collage3, welcome, pastor, invite, and the four ministries). */
async function demoMedia(ctx: Ctx, uploadDir: string, photos: DemoPhotos, pastorName: string, team: string[], colours: { primary: string; accent: string }): Promise<Ids> {
async function demoMedia(ctx: Ctx, uploadDir: string, photos: DemoPhotos, pastorName: string, team: string[], colours: { primary: string; accent: string }, withEvents: boolean): Promise<Ids> {
const slots: [string, string, string | null][] = [
['hero', photos.hero, null], ['collage2', photos.collage[0], null], ['collage3', photos.collage[1], null],
['welcome', photos.welcome, null], ['pastor', photos.pastor, pastorName], ['invite', photos.invite, null],
...photos.ministries.map((p, i) => [`ministry${i}`, p, null] as [string, string, string | null]),
...photos.team.map((p, i) => [`team${i}`, p, team[i] ?? null] as [string, string, string | null]),
...photos.messages.map((p, i) => [`message${i}`, p, null] as [string, string, string | null]),
...photos.events.map((p, i) => [`event${i}`, p, null] as [string, string, string | null]),
...(withEvents ? photos.events : []).map((p, i) => [`event${i}`, p, null] as [string, string, string | null]),
];
fs.mkdirSync(path.join(uploadDir, 'demo'), { recursive: true });
const ids: Ids = {};
@@ -224,18 +264,27 @@ export const isDemoTemplate = (v: string): v is WebsiteTemplate => (WEBSITE_TEMP
* Replaces the content with a demo, then publishes it. `what`: a template (the Acacia Hill church,
* its profile saved too) or a demo profile (keeps the church's profile; Acacia Hill's is saved
* only on a site that has none at all, so the site still has a name).
*
* `scenario` (1.8.0): part of loading that demo scenario, whose church the profile is (the same
* name: the script refuses any other). The leaders are the scenario's people, and with a linked
* Cross Events the site makes no events of its own: it shows Events' through the feed.
*/
export async function loadDemo(ctx: Ctx, what: WebsiteTemplate | agent.WebsiteDemoProfile, opts: { uploadDir?: string; publishedBy?: string } = {}) {
export async function loadDemo(ctx: Ctx, what: WebsiteTemplate | agent.WebsiteDemoProfile, opts: { uploadDir?: string; publishedBy?: string; scenario?: agent.DemoScenarioKey } = {}) {
const db = ctx.db;
const uploadDir = opts.uploadDir ?? ctx.config.uploadDir ?? defaultUploadDir();
const classic = isDemoTemplate(what);
const seed: DemoSeed = classic ? { ...CLASSIC, template: what } : DEMO_SEEDS[what];
const scenario = opts.scenario ?? null;
if (scenario && scenario !== what) throw new Error(`The ${scenario} scenario loads the ${scenario} profile, not ${what}.`);
const seed: DemoSeed = classic ? { ...CLASSIC, template: what } : scenario ? scenarioSeed(DEMO_SEEDS[what], scenario) : DEMO_SEEDS[what];
const extra = classic ? CLASSIC : null;
// A scenario's events are Cross Events' when the church has it: shown through the feed, never copied.
const eventsLink = scenario ? await db.productLink.findFirst({ where: { product: 'events' } }) : null;
// The church: Acacia Hill for a template; else whoever the site belongs to.
// The church: Acacia Hill for a template; else whoever the site belongs to (in a scenario,
// Accounts has the scenario's church by now).
let church = classic ? null : await churchProfile(ctx);
if (!church) {
church = demoProfile(ctx.config.publicUrl);
church = scenario ? scenarioProfile(ctx.config.publicUrl, scenario) : demoProfile(ctx.config.publicUrl);
await ctx.settings.set('church_profile_local', JSON.stringify(church));
}
const name = church.name;
@@ -261,7 +310,7 @@ export async function loadDemo(ctx: Ctx, what: WebsiteTemplate | agent.WebsiteDe
const [pastorName] = seed.leaders[0]!;
const ministryNames = seed.ministries.map(([, n]) => t(n));
const speaker = extra?.pastorName ?? pastorName;
const img = await demoMedia(ctx, uploadDir, seed.photos, speaker, seed.leaders.slice(1).map(([name]) => name), colours);
const img = await demoMedia(ctx, uploadDir, seed.photos, speaker, seed.leaders.slice(1).map(([name]) => name), colours, !eventsLink);
const design = classic ? defaultDesign(seed.template) : seedDesign(seed.template, seed.alternate);
await db.siteDesign.create({ data: { id: 1, template: seed.template, variants: design.variants as never, home: design.home as never, style: design.style as never } });
@@ -330,12 +379,18 @@ export async function loadDemo(ctx: Ctx, what: WebsiteTemplate | agent.WebsiteDe
}
n = 0;
const made: string[] = [];
for (const [slug, title, inDays, description] of seed.events) {
for (const [slug, title, inDays, description] of eventsLink ? [] : seed.events) {
const startsAt = new Date(Math.floor((now.getTime() + inDays * day) / day) * day + 8 * 3600e3);
made.push((await db.simpleEvent.create({ data: { slug, title, startsAt, endsAt: new Date(startsAt.getTime() + 3 * 3600e3), location: t(seed.venue), description: t(description), imageId: img[`event${n++}`] ?? null, publishedAt: now } })).id);
}
const version = await publish(ctx, { id: opts.publishedBy ?? 'demo', role: 'system' }, classic ? `Demo church on ${seed.template}` : `Demo: ${seed.label}`);
// Linked products fetch the feed now, not at their next poll (one try; the poll catches up).
await notifyLinks(ctx, [...gone, ...made]).catch(() => {});
return version;
let eventsSync: SyncResult | null = null;
if (eventsLink) {
// Show Events' events (the scenario loaded them just before), the whole list at once.
const link = await db.productLink.update({ where: { installId: eventsLink.installId }, data: { showEvents: true } });
eventsSync = await syncLink(ctx, link, { full: true });
}
return { ...version, eventsSync };
}
+24 -2
View File
@@ -8,9 +8,15 @@
* profile of each template starts on the template's other recommended variants and header, so the
* eight show every recommended look.
*
* 1.8.0: a profile is also a demo scenario's church (contracts `agent.DEMO_SCENARIOS`, APP-1.0-PLAN
* §12). Loaded as part of the scenario (`--scenario`), its leaders are the scenario's people from
* `@crosscode/demo` (`scenarioTeam`: their part, role and portrait), the same people as in Accounts,
* Cross Events and the App.
*
* Every person and place in here is made up. A profile id never changes once released.
*/
import { agent, type WebsiteTemplate } from '@crosscode/contracts';
import type { DemoPart } from '@crosscode/demo';
type WebsiteDemoProfile = agent.WebsiteDemoProfile;
@@ -36,6 +42,11 @@ export type DemoSeed = {
ministries: [string, string, string][];
/** Four: [name, role]. The first is the pastor on the home page and the speaker of the messages. */
leaders: [string, string][];
/**
* 1.8.0, a scenario load: four leaders as [part, role, portrait], the pastor first. Their names
* are the scenario's people with that part (`demoPeople`); the portraits suit them (photos.json).
*/
scenarioTeam?: [DemoPart, string, string][];
series: [string, string];
/** Three: [slug, title, days ago, passage]. */
messages: [string, string, number, string][];
@@ -68,7 +79,10 @@ export type DemoPhotos = {
const visitButton: Button = { label: 'Plan your visit', href: '/visit' };
export const DEMO_SEEDS: Record<WebsiteDemoProfile, DemoSeed> = {
/** A demo profile: one of the eight, each also a demo scenario's church. */
export type ProfileSeed = DemoSeed & { id: WebsiteDemoProfile; scenarioTeam: [DemoPart, string, string][] };
export const DEMO_SEEDS: Record<WebsiteDemoProfile, ProfileSeed> = {
'heritage-parish': {
id: 'heritage-parish', template: 'heritage', label: 'Heritage: a parish church with a long history', alternate: false,
hero: { headline: 'Worshipping together since 1896', subline: 'An old church with a warm welcome in the heart of {city}. Traditional services, every generation together.', button: visitButton },
@@ -95,6 +109,7 @@ export const DEMO_SEEDS: Record<WebsiteDemoProfile, DemoSeed> = {
['pastoral-care', 'Pastoral visiting', 'Home communion and visits for those who can\'t come to church.'],
],
leaders: [['The Revd Margaret Pillay', 'Rector'], ['The Revd Sipho Ndlovu', 'Assistant priest'], ['Anne Fourie', 'Director of music'], ['David Smith', 'Churchwarden']],
scenarioTeam: [['pastor', 'Rector', 'pastor-margaret'], ['worship', 'Director of music', 'team-sipho'], ['kids', 'Sunday school', 'team-anne'], ['prayer-coordinator', 'Prayer coordinator', 'team-david']],
series: ['the-lords-prayer', 'The Lord\'s Prayer'],
messages: [['your-kingdom-come', 'Your kingdom come', 3, 'Matthew 6:10'], ['our-daily-bread', 'Our daily bread', 10, 'Matthew 6:11'], ['forgive-us', 'Forgive us as we forgive', 17, 'Matthew 6:12']],
events: [
@@ -131,6 +146,7 @@ export const DEMO_SEEDS: Record<WebsiteDemoProfile, DemoSeed> = {
['soup-kitchen', 'The soup kitchen', 'Soup and bread for anyone who needs it, every weekday at noon.'],
],
leaders: [['Canon Peter Mahlangu', 'Vicar'], ['The Revd Claire Jacobs', 'City chaplain'], ['Tom Venter', 'Organist'], ['Nomsa Khumalo', 'Soup kitchen coordinator']],
scenarioTeam: [['pastor', 'Vicar', 'pastor-peter'], ['prayer-coordinator', 'Prayer coordinator', 'team-claire'], ['worship', 'Organist', 'team-nomsa'], ['youth', 'Students and young adults', 'team-tom']],
series: ['songs-of-ascent', 'Songs of Ascent'],
messages: [['unless-the-lord-builds', 'Unless the Lord builds the house', 4, 'Psalm 127'], ['i-lift-up-my-eyes', 'I lift up my eyes', 11, 'Psalm 121'], ['how-good-and-pleasant', 'How good and pleasant', 18, 'Psalm 133']],
events: [
@@ -167,6 +183,7 @@ export const DEMO_SEEDS: Record<WebsiteDemoProfile, DemoSeed> = {
['groups', 'Connect groups', 'Meet in a home during the week and do life together.'],
],
leaders: [['Jason and Lindi Naidoo', 'Lead pastors'], ['Kagiso Molefe', 'Youth pastor'], ['Megan Steyn', 'Worship pastor'], ['Ruan Pretorius', 'Connect groups']],
scenarioTeam: [['pastor', 'Lead pastor', 'team-kagiso'], ['youth', 'Youth pastor', 'team-ayesha'], ['worship', 'Worship pastor', 'team-megan'], ['prayer-coordinator', 'Prayer and connect groups', 'team-ruan']],
series: ['unstoppable', 'Unstoppable'],
messages: [['fearless', 'Fearless', 3, 'Joshua 1:9'], ['all-in', 'All in', 10, 'Romans 12:1-2'], ['no-turning-back', 'No turning back', 17, 'Luke 9:62']],
events: [
@@ -203,6 +220,7 @@ export const DEMO_SEEDS: Record<WebsiteDemoProfile, DemoSeed> = {
['dinner-church', 'Dinner church', 'Supper and a conversation about Jesus on Wednesdays.'],
],
leaders: [['Ben and Zanele Moore', 'Church planters'], ['Ayesha Patel', 'Kids'], ['Chris Hendricks', 'Music'], ['Grace Okafor', 'Community']],
scenarioTeam: [['pastor', 'Church planter', 'team-sipho'], ['kids', 'Kids', 'team-ayesha'], ['worship', 'Music', 'team-ruan'], ['prayer-coordinator', 'Prayer and community', 'team-lerato']],
series: ['new-beginnings', 'New beginnings'],
messages: [['why-church', 'Why church?', 4, 'Acts 2:42-47'], ['the-first-step', 'The first step', 11, 'Mark 1:16-20'], ['a-seat-at-the-table', 'A seat at the table', 18, 'Luke 14:15-24']],
events: [
@@ -239,6 +257,7 @@ export const DEMO_SEEDS: Record<WebsiteDemoProfile, DemoSeed> = {
['home-groups', 'Home groups', 'Twelve groups across {city}, every Tuesday or Wednesday.'],
],
leaders: [['Pastor Andile Zulu', 'Senior pastor'], ['Michelle de Beer', 'Children\'s pastor'], ['Kevin and Tracy Reddy', 'Home groups'], ['Lwazi Mthembu', 'Youth']],
scenarioTeam: [['pastor', 'Senior pastor', 'pastor-andile'], ['kids', 'Children\'s pastor', 'team-michelle'], ['prayer-coordinator', 'Prayer coordinator', 'team-lerato'], ['youth', 'Youth', 'team-johan']],
series: ['family-matters', 'Family matters'],
messages: [['love-at-home', 'Love at home', 3, '1 Corinthians 13'], ['raising-faith', 'Raising faith', 10, 'Deuteronomy 6:4-9'], ['better-together', 'Better together', 17, 'Ecclesiastes 4:9-12']],
events: [
@@ -275,6 +294,7 @@ export const DEMO_SEEDS: Record<WebsiteDemoProfile, DemoSeed> = {
['outreach', 'Farm outreach', 'Visits, food parcels and prayer for farmworker families.'],
],
leaders: [['Ds. Willem Coetzee', 'Minister'], ['Elsie Maritz', 'Sunday school'], ['Bongani Sithole', 'Farm outreach'], ['Marie Louw', 'Music']],
scenarioTeam: [['pastor', 'Minister', 'pastor-willem'], ['kids', 'Sunday school', 'team-elsie'], ['worship', 'Music', 'team-pieter'], ['prayer-coordinator', 'Prayer', 'team-marie']],
series: ['seasons', 'Seasons'],
messages: [['a-time-to-plant', 'A time to plant', 4, 'Ecclesiastes 3:1-8'], ['waiting-for-rain', 'Waiting for rain', 11, 'James 5:7-8'], ['the-harvest-is-plentiful', 'The harvest is plentiful', 18, 'Matthew 9:35-38']],
events: [
@@ -311,6 +331,7 @@ export const DEMO_SEEDS: Record<WebsiteDemoProfile, DemoSeed> = {
['alpha', 'Alpha', 'Ten weeks, a meal and a conversation about life and faith.'],
],
leaders: [['Daniel Joubert', 'Pastor'], ['Refilwe Mokoena', 'Kids'], ['Sam Abrahams', 'Music'], ['Nadia Govender', 'Alpha']],
scenarioTeam: [['pastor', 'Pastor', 'pastor-daniel'], ['kids', 'Kids', 'team-bongani'], ['worship', 'Music', 'team-nadia'], ['prayer-coordinator', 'Prayer', 'team-refilwe']],
series: ['questions', 'Questions'],
messages: [['why-suffering', 'Why is there suffering?', 3, 'Romans 8:18-28'], ['can-i-trust-the-bible', 'Can I trust the Bible?', 10, '2 Timothy 3:14-17'], ['who-is-jesus', 'Who is Jesus?', 17, 'Mark 8:27-30']],
events: [
@@ -347,6 +368,7 @@ export const DEMO_SEEDS: Record<WebsiteDemoProfile, DemoSeed> = {
['international', 'International students', 'A welcome, a meal and help settling in.'],
],
leaders: [['Dr Ian Mabaso', 'Pastor'], ['Lisa Roberts', 'Student worker'], ['Thabo Nkosi', 'Music'], ['Priya Singh', 'International students']],
scenarioTeam: [['pastor', 'Pastor', 'pastor-ian'], ['youth', 'Students', 'team-thabo'], ['worship', 'Music', 'team-lisa'], ['prayer-coordinator', 'Prayer', 'team-priya']],
series: ['big-questions', 'Big questions'],
messages: [['what-is-truth', 'What is truth?', 4, 'John 18:37-38'], ['does-god-care', 'Does God care?', 11, 'Psalm 139'], ['what-makes-a-good-life', 'What makes a good life?', 18, 'Micah 6:8']],
events: [
@@ -360,4 +382,4 @@ export const DEMO_SEEDS: Record<WebsiteDemoProfile, DemoSeed> = {
};
/** The profiles in the contracts' order (what the Hub offers). */
export const demoSeeds = (): DemoSeed[] => agent.WEBSITE_DEMO_PROFILES.map((id: WebsiteDemoProfile) => DEMO_SEEDS[id]);
export const demoSeeds = (): ProfileSeed[] => agent.WEBSITE_DEMO_PROFILES.map((id: WebsiteDemoProfile) => DEMO_SEEDS[id]);