Compare commits

..
Author SHA1 Message Date
joshua d3e04127f3 Merge branch 'feat/website-demo-seeds' 2026-11-27 09:30:15 +02:00
joshuaandClaude Opus 5.5 2fb7ac57da Website 1.3.0, agent 1.6.0, contracts 1.19.0: demo data for the Church Website
Eight demo churches, two per template (the second on the template's other
recommended variants and header), loaded from the Hub on demo sites with
`crosscode demo <church> website --profile <p>`. A profile replaces the
content only: the church's profile from Accounts, the site settings, the
site icon and the admins stay, and the copy names the church.

- contracts: WEBSITE_DEMO_PROFILES, DEMO_PRODUCTS, SEED_WEBSITE_DEMO_MIN_AGENT;
  seed-demo takes an optional product (events by default)
- agent: a Website seed-demo job runs `crosscode demo <church> website`
- crosscode script: backup, demo as the site's user, reload, health check

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 09:20:09 +02:00
joshua 81c01d8a9f Merge branch 'docs/deployed-hub-2.24.1-website-1.2.0' 2026-11-27 08:44:56 +02:00
joshuaandClaude Opus 5.5 2335fd46e4 docs: Hub 2.24.1 deployed, Website 1.2.0 on cross-demo2
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 08:44:55 +02:00
joshua f58711603a Merge branch 'docs/hub-2.24.1' 2026-11-27 08:36:19 +02:00
joshuaandClaude Opus 5.5 d1354a6a17 docs: Hub 2.24.1 released
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 08:36:18 +02:00
joshua 175a6b41eb Merge branch 'docs/hub-2.24.0' 2026-11-27 08:30:15 +02:00
joshuaandClaude Opus 5.5 80d8e903dd docs: Hub 2.24.0 deployed (Website 1.2.0 not on cross-demo2 yet)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 08:30:15 +02:00
23 changed files with 824 additions and 120 deletions
+20
View File
@@ -2,6 +2,26 @@
Each package and app has its own section and its own tags (`contracts@1.0.0`, `accounts@1.0.0`, …).
## contracts@1.19.0 + agent@1.6.0 + website@1.3.0 + crosscode script - 2026-11-27
Demo data for the Church Website, from the Hub (Hub 2.25.0). Additive: an Events `seed-demo` job
means what it did. Details in each app's CHANGELOG.md. No migrations.
- **contracts 1.19.0:** `agent.WEBSITE_DEMO_PROFILES` (eight, two per template:
`heritage-parish`, `heritage-city`, `bold-youth`, `bold-plant`, `community-family`,
`community-town`, `clean-modern`, `clean-campus`), `DEMO_PRODUCTS`, `DEMO_PROFILES_BY_PRODUCT`,
`SEED_WEBSITE_DEMO_MIN_AGENT` (1.6.0). `seed-demo` args take an optional `product` (`events`,
the default, or `website`); the profile must be one of that product's, and a Website demo takes
no `adminEmail`.
- **agent 1.6.0:** a Website `seed-demo` job runs `crosscode demo <church> website --profile <p>`.
- **website 1.3.0:** the eight demo churches (`backend/src/demo/seeds.ts`,
`npm run demo -- --profile <p>`, `--list`). They replace the content only: the church's profile
from Accounts, the site settings, the site icon and the admins stay, and the copy names the
church. `--template` alone is still the Acacia Hill development church.
- **crosscode script:** `crosscode demo <church> website --profile <p>`: backup, the demo as the
site's user (`--force`), reload, wait for `/api/health`. Refused on a Website release without
the profiles (before 1.3.0).
## accounts@1.8.0 + website@1.1.0 - 2026-11-26
The admins of both, redesigned as Cross Events' admin dashboard and settings. Details in each app's
+6
View File
@@ -13,6 +13,12 @@ Write for the person updating servers: what the agent can now do from the Hub, a
contracts version needs it. The developer log is the commit history of apps/agent.
-->
## 1.6.0
- **Demo data for the Church Website.** The Hub (2.25.0 and later) can load one of the Website's
eight demo churches on a demo site, as it already could for Cross Events. Needs Website 1.3.0 on
the site. Cross Events' demo data works as before.
## 1.5.0
- **One product of a church at a time.** Uninstall, export and purge jobs can name products: only
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@crosscode/agent",
"version": "1.5.0",
"version": "1.6.0",
"private": true,
"description": "The server agent: runs the crosscode script for signed jobs from Cross Code Hub, reports stats (docs/AGENT-1.0-PLAN.md)",
"license": "UNLICENSED",
+3 -1
View File
@@ -59,7 +59,9 @@ export function crosscodeArgs(job: agent.AgentJob, opts: { exportFile?: string }
return out;
}
case "seed-demo":
return ["demo", job.args.church, "--profile", job.args.profile, ...(job.args.adminEmail ? ["--admin-email", job.args.adminEmail] : [])];
// 1.6.0: the Website's demo names the product; Events' (no product) keeps its old form.
return ["demo", job.args.church, ...(job.args.product === "website" ? ["website"] : []), "--profile", job.args.profile,
...(job.args.adminEmail ? ["--admin-email", job.args.adminEmail] : [])];
case "export":
if (!opts.exportFile) throw new Error("export needs a file to write");
return ["export", job.args.church, ...(job.args.products ?? []), "--out", opts.exportFile];
+1 -1
View File
@@ -12,7 +12,7 @@ import { paths } from "./paths";
* the tools that are there; anything missing is null rather than an error.
*/
export const AGENT_VERSION = "1.5.0";
export const AGENT_VERSION = "1.6.0";
function run(cmd: string, args: string[], timeoutMs = 10_000): Promise<string | null> {
return new Promise((resolve) => {
+3
View File
@@ -47,6 +47,9 @@ describe("crosscode arguments for each job", () => {
expect(crosscodeArgs(parsed({ type: "seed-demo", args: { church: "hope", profile: "ministry" } }))).toEqual(["demo", "hope", "--profile", "ministry"]);
expect(crosscodeArgs(parsed({ type: "seed-demo", args: { church: "hope", profile: "events", adminEmail: "jane@hope.test" } })))
.toEqual(["demo", "hope", "--profile", "events", "--admin-email", "jane@hope.test"]);
// 1.6.0: the Website's demo.
expect(crosscodeArgs(parsed({ type: "seed-demo", args: { church: "hope", product: "website", profile: "bold-plant" } }))).toEqual(["demo", "hope", "website", "--profile", "bold-plant"]);
expect(crosscodeArgs(parsed({ type: "seed-demo", args: { church: "hope", product: "events", profile: "small" } }))).toEqual(["demo", "hope", "--profile", "small"]);
});
it("env-read and env-set (1.3.0): crosscode env, each value its own argument", () => {
+24
View File
@@ -1,5 +1,29 @@
# Changelog — Church Website
## [1.3.0] — 2026-11-27
No migration, no new environment settings. Needs contracts 1.19.0 (in this checkout).
### Added
- **Eight demo churches**, two per template, for the Hub's demo sites (Hub 2.25.0, agent 1.6.0,
`crosscode demo <church> website --profile <p>`): `heritage-parish`, `heritage-city`,
`bold-youth`, `bold-plant`, `community-family`, `community-town`, `clean-modern`,
`clean-campus` (`src/demo/seeds.ts`, ids from contracts `agent.WEBSITE_DEMO_PROFILES`). Each is
its own kind of church: home page, Plan your visit, About, Give, four ministries, four leaders, a
message series with three messages, and three upcoming events. The second of each template starts
on the template's second recommended variant of every homepage section and its second header, so
the eight show every recommended look.
- **They keep the organisation settings:** a profile replaces the content only. The church's
profile (from Accounts, else `church_profile_local`) stays, the copy names the church
(`{name}`, `{short}`, `{city}`) and the illustrations use its colours. The site settings, the
site icon (`favicon_media_id` and its picture) and the admins stay. Acacia Hill's profile is
saved only on a site with no profile at all, so it still has a name. Slug history and preview
links go with the old content.
- `npm run demo -- --profile <p> [--force]` and `--list`. `--template <t>` alone still loads the
Acacia Hill development church exactly as before (its profile too), so the e2e suite and its
screenshots are unchanged.
## [1.2.0] — 2026-11-27
No migration, no new environment settings. Its first start on an existing site adds the missing
+5
View File
@@ -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.3.0
- Nothing changes on your site. Behind the scenes, Cross Code can now load demo content on the
websites it uses for demonstrations.
## 1.2.0
- **Your home page and the other pages are there from the start:** a new website now comes with
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@crosscode/website-backend",
"version": "1.2.0",
"version": "1.3.0",
"description": "Church Website: the public site's content API, the admin API, publishing and uploads",
"private": true,
"type": "module",
+21 -9
View File
@@ -1,25 +1,37 @@
/**
* Loads the demo church (src/demo/demoChurch.ts) into a template and publishes it.
* Loads a demo into the site and publishes it.
*
* npm run demo -- --template heritage|bold|community|clean [--force]
* npm run demo -- --template heritage|bold|community|clean [--force] the Acacia Hill church (development)
* npm run demo -- --profile <profile> [--force] one of the eight demo churches (1.3.0),
* keeping the church's profile and settings
* npm run demo -- --list the profiles
*
* It replaces the site's content, so a site that has been published needs --force.
* It replaces the site's content, so a site that has been published needs --force. On a server,
* `crosscode demo <church> website --profile …` runs it (backup first), for the Hub's demo sites.
*/
import 'dotenv/config';
import { PrismaPg } from '@prisma/adapter-pg';
import { websiteTemplateSchema } from '@crosscode/contracts';
import { agent, websiteTemplateSchema } from '@crosscode/contracts';
import { PrismaClient } from '../src/generated/prisma/client.js';
import { createCtx } from '../src/context.js';
import { loadDemo } from '../src/demo/demoChurch.js';
import { demoSeeds } from '../src/demo/seeds.js';
import { loadConfig } from '../src/lib/config.js';
const arg = (name: string) => {
const i = process.argv.indexOf(`--${name}`);
return i > 0 ? process.argv[i + 1] : undefined;
};
const template = websiteTemplateSchema.safeParse(arg('template') ?? 'heritage');
if (!template.success) {
console.error('Usage: npm run demo -- --template heritage|bold|community|clean [--force]');
const usage = 'Usage: npm run demo -- --template heritage|bold|community|clean | --profile <profile> [--force] | --list';
if (process.argv.includes('--list')) {
for (const s of demoSeeds()) console.log(`${s.id.padEnd(18)} ${s.label}`);
process.exit(0);
}
const profileArg = arg('profile');
const what = profileArg !== undefined ? agent.websiteDemoProfileSchema.safeParse(profileArg) : websiteTemplateSchema.safeParse(arg('template') ?? 'heritage');
if (!what.success) {
console.error(profileArg !== undefined ? `Unknown profile "${profileArg}" (npm run demo -- --list).` : usage);
process.exit(2);
}
@@ -31,6 +43,6 @@ if (published && !process.argv.includes('--force')) {
await db.$disconnect();
process.exit(1);
}
const version = await loadDemo(ctx, template.data);
console.log(`Demo church loaded on ${template.data} and published (version ${version.number}).`);
const version = await loadDemo(ctx, what.data);
console.log(`Demo ${what.data} loaded and published (version ${version.number}).`);
await db.$disconnect();
+160 -76
View File
@@ -3,17 +3,24 @@
* illustrated images (no photos of anyone), loaded into a template for development, the Hub's demo
* sites and the crosscode-site screenshots. `npm run demo -- --template bold`.
*
* 1.3.0: also the eight demo profiles (seeds.ts, `npm run demo -- --profile bold-plant`), which
* keep the church's own profile (Accounts' organisation settings), the site settings, the site
* 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.
*
* It replaces the Website's content (never the admins), so the script refuses on a site that has
* been published unless told otherwise.
*/
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { CHURCH_SCHEMA, type Church, type WebsiteTemplate } from '@crosscode/contracts';
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 type { SectionData } from '../site/sections.js';
import { publish } from '../site/snapshot.js';
import { defaultDesign } from '../site/variants.js';
import { TEMPLATE_HEADERS, TEMPLATE_VARIANTS, SECTION_TYPES, defaultDesign, type SiteDesign } from '../site/variants.js';
import { DEMO_SEEDS, type DemoSeed } from './seeds.js';
export const DEMO_COLOURS = { primary: '#1d5c63', accent: '#e0a458' };
@@ -48,8 +55,8 @@ export function demoProfile(publicUrl: string): Church {
}
/** An illustrated "photo": hills, a sun and a path in the church's colours (SVG, no people). */
export function illustration(seed: number, w = 1600, h = 1000): string {
const hues = [DEMO_COLOURS.primary, DEMO_COLOURS.accent, '#7fb7be', '#f3e3c3', '#284b52'];
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'];
const c = (i: number) => hues[(seed + i) % hues.length];
const y = (f: number) => Math.round(h * f);
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${w} ${h}" width="${w}" height="${h}">
@@ -64,26 +71,17 @@ export function illustration(seed: number, w = 1600, h = 1000): string {
type Ids = Record<string, string>;
async function demoMedia(ctx: Ctx, uploadDir: string): Promise<Ids> {
const items: [string, string, number][] = [
['hero', 'The hills behind Acacia Hill at sunrise (illustration)', 0],
['collage2', 'A path through the veld (illustration)', 1],
['collage3', 'Evening over the valley (illustration)', 2],
['welcome', 'The church garden (illustration)', 3],
['pastor', 'Illustration standing in for the pastor\'s photo', 4],
['invite', 'A sunny Sunday morning (illustration)', 5],
['kids', 'Illustration for Kids church', 6],
['youth', 'Illustration for Youth', 7],
['care', 'Illustration for Care and prayer', 8],
['music', 'Illustration for Worship', 9],
];
const HEX = /^#[0-9a-f]{6}$/i;
async function demoMedia(ctx: Ctx, uploadDir: string, alts: Record<string, string>, colours: { primary: string; accent: string }): Promise<Ids> {
const items: [string, number][] = [['hero', 0], ['collage2', 1], ['collage3', 2], ['welcome', 3], ['pastor', 4], ['invite', 5], ['kids', 6], ['youth', 7], ['care', 8], ['music', 9]];
const ids: Ids = {};
fs.mkdirSync(path.join(uploadDir, 'demo'), { recursive: true });
for (const [key, alt, seed] of items) {
for (const [key, seed] of items) {
const filename = `demo/${key}.svg`;
const svg = illustration(seed);
const svg = illustration(seed, 1600, 1000, colours);
fs.writeFileSync(path.join(uploadDir, filename), svg);
const row = await ctx.db.mediaAsset.create({ data: { filename, mime: 'image/svg+xml', bytes: Buffer.byteLength(svg), width: 1600, height: 1000, alt } });
const row = await ctx.db.mediaAsset.create({ data: { filename, mime: 'image/svg+xml', bytes: Buffer.byteLength(svg), width: 1600, height: 1000, alt: alts[key]! } });
ids[key] = row.id;
}
return ids;
@@ -91,57 +89,160 @@ async function demoMedia(ctx: Ctx, uploadDir: string): Promise<Ids> {
export const defaultUploadDir = () => path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..', 'uploads');
/** Replaces the content with the demo church's on `template`, then publishes it. */
export async function loadDemo(ctx: Ctx, template: WebsiteTemplate, opts: { uploadDir?: string; publishedBy?: string } = {}) {
/** The development demo church (Acacia Hill), on any template: what a template alone loads. */
const CLASSIC: Omit<DemoSeed, 'template'> & { pastorName: string; ctaText: string; descriptions: Record<string, string>; alts: Record<string, string> } = {
id: 'classic', label: 'Acacia Hill (development)', alternate: false,
hero: { headline: 'A home for everyone on the hill', subline: 'Sundays at 08:30 and 10:00 in Westridge, Pretoria. Come as you are.', button: { label: 'Plan your visit', href: '/visit' } },
serviceNote: 'Kids church runs during the 10:00 service. Parking on Acacia Avenue and behind the hall.',
welcome: {
heading: 'Welcome to Acacia Hill', mission: 'Loving God, loving our neighbours, from Westridge to the nations.',
body: 'We are a family of ordinary people who have found good news in Jesus. Whether you have followed him for years or are just curious, there is a seat for you here, and coffee after the service.',
quote: 'We would love to meet you. Come and say hello at the welcome table.',
},
ministriesIntro: 'There is something for every age and stage.',
teamIntro: null,
invitation: { heading: 'We saved you a seat', text: 'New here? Let us know you are coming and we will meet you at the door.', button: { label: 'Plan your visit', href: '/visit' } },
visit: {
expect: 'Services last about an hour and a quarter. We sing together, pray, and hear a message from the Bible. Dress is casual.',
kids: 'Kids church (ages 3 to 12) runs during the 10:00 service. Sign your children in at the kids desk in the hall.',
cta: 'Questions before you come?',
},
ctaText: 'Send us a WhatsApp and we will get back to you.',
about: { story: 'Acacia Hill began in 1998 as a Bible study in a lounge in Westridge. Today we are a church of all ages that meets in the old school hall on Acacia Avenue.', quote: 'Love one another. As I have loved you, so you must love one another.', by: 'John 13:34' },
give: 'Thank you for giving. You can give by EFT to Acacia Hill Church (demo details only: this is not a real account).',
ministries: [
['kids', 'Kids church', 'Ages 3 to 12, every Sunday at 10:00.'],
['youth', 'Youth', 'High schoolers, Friday nights at 18:30.'],
['worship', 'Worship', 'Musicians and sound, rehearsing on Thursdays.'],
['care', 'Care and prayer', 'Meals, visits and prayer for anyone who needs it.'],
],
leaders: [['Thandi Mokoena', 'Lead pastor'], ['Pieter van Wyk', 'Associate pastor'], ['Lerato Dlamini', 'Kids and families'], ['Johan Botha', 'Worship']],
pastorName: 'Pastor Thandi Mokoena',
series: ['hope-for-today', 'Hope for today'],
messages: [['hope-that-holds', 'A hope that holds', 3, 'Psalm 23'], ['bread-for-the-road', 'Bread for the road', 10, 'Psalm 23'], ['the-good-shepherd', 'The good shepherd', 17, 'Psalm 23']],
events: [
['family-picnic', 'Family picnic', 6, 'Bring a blanket and something to share. Games for the kids.'],
['carols-by-candlelight', 'Carols by candlelight', 20, 'Our Christmas carol service on the lawn.'],
['new-here-lunch', 'New here lunch', 34, 'Meet the pastors over lunch after the 10:00 service.'],
],
venue: 'Acacia Hill Church',
descriptions: {
home: 'Acacia Hill Church in Westridge, Pretoria: Sundays at 08:30 and 10:00. Come as you are.',
visit: 'What to expect on your first Sunday at Acacia Hill Church.',
about: 'Our story, what we believe and what we value.',
ministries: 'Kids, youth, worship, care and prayer at Acacia Hill.',
leadership: 'The team who lead Acacia Hill Church.',
events: 'What is coming up at Acacia Hill Church.',
messages: 'Sunday messages from Acacia Hill Church.',
give: 'How to give to Acacia Hill Church.',
contact: 'Find Acacia Hill Church in Westridge, Pretoria.',
},
alts: {
hero: 'The hills behind Acacia Hill at sunrise (illustration)', collage2: 'A path through the veld (illustration)', collage3: 'Evening over the valley (illustration)',
welcome: 'The church garden (illustration)', pastor: 'Illustration standing in for the pastor\'s photo', invite: 'A sunny Sunday morning (illustration)',
kids: 'Illustration for Kids church', youth: 'Illustration for Youth', care: 'Illustration for Care and prayer', music: 'Illustration for Worship',
},
};
/** A demo profile's design: the template's defaults, or (alternate) its second recommendations and header. */
export function seedDesign(template: WebsiteTemplate, alternate: boolean): SiteDesign {
const design = defaultDesign(template);
if (!alternate) return design;
const variants = Object.fromEntries(SECTION_TYPES.map((s) => {
const options = TEMPLATE_VARIANTS[template][s] as readonly string[];
return [s, options[1] ?? options[0]!];
})) as SiteDesign['variants'];
const headers = TEMPLATE_HEADERS[template] as readonly string[];
return { ...design, variants, style: { ...design.style, header: headers[1] ?? headers[0]! } };
}
export const isDemoTemplate = (v: string): v is WebsiteTemplate => (WEBSITE_TEMPLATES as readonly string[]).includes(v);
/**
* 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).
*/
export async function loadDemo(ctx: Ctx, what: WebsiteTemplate | agent.WebsiteDemoProfile, opts: { uploadDir?: string; publishedBy?: string } = {}) {
const db = ctx.db;
const uploadDir = opts.uploadDir ?? ctx.config.uploadDir ?? defaultUploadDir();
for (const m of ['section', 'page', 'ministry', 'leader', 'message', 'messageSeries', 'simpleEvent', 'mediaAsset', 'siteVersion', 'siteDesign'] as const) {
const classic = isDemoTemplate(what);
const seed: DemoSeed = classic ? { ...CLASSIC, template: what } : DEMO_SEEDS[what];
const extra = classic ? CLASSIC : null;
// The church: Acacia Hill for a template; else whoever the site belongs to.
let church = classic ? null : await churchProfile(ctx);
if (!church) {
church = demoProfile(ctx.config.publicUrl);
await ctx.settings.set('church_profile_local', JSON.stringify(church));
}
const name = church.name;
const short = church.shortName || church.name;
const city = church.contact?.address?.city || church.contact?.address?.suburb || 'town';
const t = (s: string) => s.replaceAll('{name}', name).replaceAll('{short}', short).replaceAll('{city}', city);
const brand = church.branding?.colours;
const colours = classic || !brand?.primary || !HEX.test(brand.primary)
? DEMO_COLOURS
: { primary: brand.primary, accent: brand.accent && HEX.test(brand.accent) ? brand.accent : DEMO_COLOURS.accent };
// The site icon is a setting, so its picture stays; every other picture goes with the content.
const faviconId = classic ? null : await ctx.settings.get('favicon_media_id');
for (const m of ['section', 'page', 'ministry', 'leader', 'message', 'messageSeries', 'simpleEvent', 'siteVersion', 'siteDesign', 'slugHistory', 'previewLink'] as const) {
await (db[m] as unknown as { deleteMany: (a?: object) => Promise<unknown> }).deleteMany({});
}
const img = await demoMedia(ctx, uploadDir);
const design = defaultDesign(template);
await db.siteDesign.create({ data: { id: 1, template, variants: design.variants as never, home: design.home as never, style: design.style as never } });
await ctx.settings.set('church_profile_local', JSON.stringify(demoProfile(ctx.config.publicUrl)));
await db.mediaAsset.deleteMany(faviconId ? { where: { NOT: { id: faviconId } } } : undefined);
const [pastorName] = seed.leaders[0]!;
const ministryNames = seed.ministries.map(([, n]) => t(n));
const alts = extra?.alts ?? {
hero: `${t(seed.hero.headline)} (illustration)`, collage2: 'A path through the veld (illustration)', collage3: 'Evening over the valley (illustration)',
welcome: `${short} (illustration)`, pastor: `Illustration standing in for ${pastorName}'s photo`, invite: 'A sunny Sunday morning (illustration)',
kids: `Illustration for ${ministryNames[0]}`, youth: `Illustration for ${ministryNames[1]}`, music: `Illustration for ${ministryNames[2]}`, care: `Illustration for ${ministryNames[3]}`,
};
const img = await demoMedia(ctx, uploadDir, alts, colours);
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 } });
const speaker = extra?.pastorName ?? pastorName;
const home: SectionData = {
hero: { headline: 'A home for everyone on the hill', subline: 'Sundays at 08:30 and 10:00 in Westridge, Pretoria. Come as you are.', images: [img.hero!, img.collage2!, img.collage3!], videoId: null, button: { label: 'Plan your visit', href: '/visit' } },
serviceTimes: { heading: 'Join us this Sunday', note: 'Kids church runs during the 10:00 service. Parking on Acacia Avenue and behind the hall.' },
hero: { headline: t(seed.hero.headline), subline: t(seed.hero.subline), images: [img.hero!, img.collage2!, img.collage3!], videoId: null, button: seed.hero.button },
serviceTimes: { heading: 'Join us this Sunday', note: t(seed.serviceNote) },
welcome: {
heading: 'Welcome to Acacia Hill', mission: 'Loving God, loving our neighbours, from Westridge to the nations.',
body: 'We are a family of ordinary people who have found good news in Jesus. Whether you have followed him for years or are just curious, there is a seat for you here, and coffee after the service.',
imageId: img.welcome!, pastor: { name: 'Pastor Thandi Mokoena', role: 'Lead pastor', quote: 'We would love to meet you. Come and say hello at the welcome table.', photoId: img.pastor! },
heading: t(seed.welcome.heading), mission: t(seed.welcome.mission), body: t(seed.welcome.body),
imageId: img.welcome!, pastor: { name: speaker, role: seed.leaders[0]![1], quote: t(seed.welcome.quote), photoId: img.pastor! },
},
ministries: { heading: 'Find your place', intro: 'There is something for every age and stage.' },
team: { heading: 'Our team', intro: null },
ministries: { heading: 'Find your place', intro: t(seed.ministriesIntro) },
team: { heading: 'Our team', intro: seed.teamIntro ? t(seed.teamIntro) : null },
events: { heading: 'Coming up', count: 3 },
latestMessage: { heading: 'Latest message' },
invitation: { heading: 'We saved you a seat', text: 'New here? Let us know you are coming and we will meet you at the door.', button: { label: 'Plan your visit', href: '/visit' }, imageId: img.invite! },
invitation: { heading: t(seed.invitation.heading), text: t(seed.invitation.text), button: seed.invitation.button, imageId: img.invite! },
};
const d = (kind: string, fallback: string) => extra?.descriptions[kind] ?? t(fallback);
const pages: { kind: string; slug: string; title: string; position: number; description: string; sections: { type: string; variant?: string; data: unknown }[] }[] = [
{ kind: 'home', slug: 'home', title: 'Home', position: 0, description: 'Acacia Hill Church in Westridge, Pretoria: Sundays at 08:30 and 10:00. Come as you are.', sections: Object.entries(home).map(([type, data]) => ({ type, data })) },
{ kind: 'home', slug: 'home', title: 'Home', position: 0, description: d('home', `${seed.hero.subline}`), sections: Object.entries(home).map(([type, data]) => ({ type, data })) },
{
kind: 'visit', slug: 'visit', title: 'Plan your visit', position: 1, description: 'What to expect on your first Sunday at Acacia Hill Church.', sections: [
{ type: 'text', data: { heading: 'What to expect', body: 'Services last about an hour and a quarter. We sing together, pray, and hear a message from the Bible. Dress is casual.' } },
{ type: 'image-text', variant: 'image-text', data: { heading: 'Bringing children', body: 'Kids church (ages 3 to 12) runs during the 10:00 service. Sign your children in at the kids desk in the hall.', imageId: img.kids, button: null } },
{ type: 'cta', data: { heading: 'Questions before you come?', text: 'Send us a WhatsApp and we will get back to you.', button: { label: 'Contact us', href: '/contact' } } },
kind: 'visit', slug: 'visit', title: 'Plan your visit', position: 1, description: d('visit', 'What to expect on your first Sunday at {name}.'), sections: [
{ type: 'text', data: { heading: 'What to expect', body: t(seed.visit.expect) } },
{ type: 'image-text', variant: 'image-text', data: { heading: 'Bringing children', body: t(seed.visit.kids), imageId: img.kids, button: null } },
{ type: 'cta', data: { heading: t(seed.visit.cta), text: extra?.ctaText ?? 'Send us a message and we will get back to you.', button: { label: 'Contact us', href: '/contact' } } },
],
},
{
kind: 'about', slug: 'about', title: 'About us', position: 2, description: 'Our story, what we believe and what we value.', sections: [
{ type: 'text', data: { heading: 'Our story', body: 'Acacia Hill began in 1998 as a Bible study in a lounge in Westridge. Today we are a church of all ages that meets in the old school hall on Acacia Avenue.' } },
{ type: 'quote', data: { quote: 'Love one another. As I have loved you, so you must love one another.', by: 'John 13:34' } },
kind: 'about', slug: 'about', title: 'About us', position: 2, description: d('about', 'Our story, what we believe and what we value.'), sections: [
{ type: 'text', data: { heading: 'Our story', body: t(seed.about.story) } },
{ type: 'quote', data: { quote: seed.about.quote, by: seed.about.by } },
],
},
{ kind: 'ministries', slug: 'ministries', title: 'Ministries', position: 3, description: 'Kids, youth, worship, care and prayer at Acacia Hill.', sections: [] },
{ kind: 'leadership', slug: 'leadership', title: 'Leadership', position: 4, description: 'The team who lead Acacia Hill Church.', sections: [] },
{ kind: 'events', slug: 'events', title: 'Events', position: 5, description: 'What is coming up at Acacia Hill Church.', sections: [] },
{ kind: 'messages', slug: 'messages', title: 'Messages', position: 6, description: 'Sunday messages from Acacia Hill Church.', sections: [] },
{ kind: 'ministries', slug: 'ministries', title: 'Ministries', position: 3, description: d('ministries', `${ministryNames.join(', ')} at {short}.`), sections: [] },
{ kind: 'leadership', slug: 'leadership', title: 'Leadership', position: 4, description: d('leadership', 'The team who lead {name}.'), sections: [] },
{ kind: 'events', slug: 'events', title: 'Events', position: 5, description: d('events', 'What is coming up at {name}.'), sections: [] },
{ kind: 'messages', slug: 'messages', title: 'Messages', position: 6, description: d('messages', 'Sunday messages from {name}.'), sections: [] },
{
kind: 'give', slug: 'give', title: 'Give', position: 7, description: 'How to give to Acacia Hill Church.', sections: [
{ type: 'text', data: { heading: 'Giving', body: 'Thank you for giving. You can give by EFT to Acacia Hill Church (demo details only: this is not a real account).' } },
kind: 'give', slug: 'give', title: 'Give', position: 7, description: d('give', 'How to give to {name}.'), sections: [
{ type: 'text', data: { heading: 'Giving', body: t(seed.give) } },
],
},
{ kind: 'contact', slug: 'contact', title: 'Contact', position: 8, description: 'Find Acacia Hill Church in Westridge, Pretoria.', sections: [] },
{ kind: 'contact', slug: 'contact', title: 'Contact', position: 8, description: d('contact', 'Find {name} in {city}.'), sections: [] },
];
for (const p of pages) {
const page = await db.page.create({ data: { kind: p.kind as never, slug: p.slug, title: p.title, position: p.position, description: p.description } });
@@ -149,38 +250,21 @@ export async function loadDemo(ctx: Ctx, template: WebsiteTemplate, opts: { uplo
for (const s of p.sections) await db.section.create({ data: { pageId: page.id, type: s.type, variant: s.variant ?? null, position: i++, data: s.data as never } });
}
const ministries: [string, string, string, string][] = [
['kids', 'Kids church', 'Ages 3 to 12, every Sunday at 10:00.', img.kids!],
['youth', 'Youth', 'High schoolers, Friday nights at 18:30.', img.youth!],
['worship', 'Worship', 'Musicians and sound, rehearsing on Thursdays.', img.music!],
['care', 'Care and prayer', 'Meals, visits and prayer for anyone who needs it.', img.care!],
];
const pictures = [img.kids!, img.youth!, img.music!, img.care!];
let n = 0;
for (const [slug, name, summary, imageId] of ministries) await db.ministry.create({ data: { slug, name, summary, imageId, position: n++ } });
const leaders: [string, string, string | null][] = [
['Thandi Mokoena', 'Lead pastor', img.pastor!],
['Pieter van Wyk', 'Associate pastor', null],
['Lerato Dlamini', 'Kids and families', null],
['Johan Botha', 'Worship', null],
];
for (const [slug, , summary] of seed.ministries) await db.ministry.create({ data: { slug, name: ministryNames[n]!, summary: t(summary), imageId: pictures[n]!, position: n++ } });
n = 0;
for (const [name, role, photoId] of leaders) await db.leader.create({ data: { name, role, photoId, position: n++ } });
for (const [leader, role] of seed.leaders) await db.leader.create({ data: { name: leader, role, photoId: n === 0 ? img.pastor! : null, position: n++ } });
const now = ctx.now();
const day = 864e5;
const series = await db.messageSeries.create({ data: { slug: 'hope-for-today', title: 'Hope for today' } });
const messages: [string, string, number][] = [['hope-that-holds', 'A hope that holds', 3], ['bread-for-the-road', 'Bread for the road', 10], ['the-good-shepherd', 'The good shepherd', 17]];
for (const [slug, title, ago] of messages) {
await db.message.create({ data: { slug, title, date: new Date(now.getTime() - ago * day), source: 'youtube', mediaUrl: 'https://www.youtube.com/watch?v=aqz-KE-bpKQ', speaker: 'Pastor Thandi Mokoena', passage: 'Psalm 23', seriesId: series.id, publishedAt: now } });
const series = await db.messageSeries.create({ data: { slug: seed.series[0], title: seed.series[1] } });
for (const [slug, title, ago, passage] of seed.messages) {
await db.message.create({ data: { slug, title, date: new Date(now.getTime() - ago * day), source: 'youtube', mediaUrl: 'https://www.youtube.com/watch?v=aqz-KE-bpKQ', speaker, passage, seriesId: series.id, publishedAt: now } });
}
const events: [string, string, number, string][] = [
['family-picnic', 'Family picnic', 6, 'Bring a blanket and something to share. Games for the kids.'],
['carols-by-candlelight', 'Carols by candlelight', 20, 'Our Christmas carol service on the lawn.'],
['new-here-lunch', 'New here lunch', 34, 'Meet the pastors over lunch after the 10:00 service.'],
];
for (const [slug, title, inDays, description] of events) {
for (const [slug, title, inDays, description] of seed.events) {
const startsAt = new Date(Math.floor((now.getTime() + inDays * day) / day) * day + 8 * 3600e3);
await db.simpleEvent.create({ data: { slug, title, startsAt, endsAt: new Date(startsAt.getTime() + 3 * 3600e3), location: 'Acacia Hill Church', description, publishedAt: now } });
await db.simpleEvent.create({ data: { slug, title, startsAt, endsAt: new Date(startsAt.getTime() + 3 * 3600e3), location: t(seed.venue), description: t(description), publishedAt: now } });
}
return publish(ctx, { id: opts.publishedBy ?? 'demo', role: 'system' }, `Demo church on ${template}`);
return publish(ctx, { id: opts.publishedBy ?? 'demo', role: 'system' }, classic ? `Demo church on ${seed.template}` : `Demo: ${seed.label}`);
}
+334
View File
@@ -0,0 +1,334 @@
/**
* The Website's demo profiles (1.3.0, contracts `WEBSITE_DEMO_PROFILES`): eight fictional churches,
* two per template, for the Hub's demo sites (`crosscode demo <church> website --profile …`).
*
* A demo replaces the content only. The church's profile (name, logo, colours, service times,
* contact: Accounts' organisation settings) stays, so the copy names the church with placeholders:
* `{name}` (Hope Family Church), `{short}` (Hope Family) and `{city}` (Pretoria). The second
* profile of each template starts on the template's other recommended variants and header, so the
* eight show every recommended look.
*
* Every person and place in here is made up. A profile id never changes once released.
*/
import { agent, type WebsiteTemplate } from '@crosscode/contracts';
type WebsiteDemoProfile = agent.WebsiteDemoProfile;
type Button = { label: string; href: string };
export type DemoSeed = {
id: WebsiteDemoProfile | 'classic';
template: WebsiteTemplate;
/** What the Hub shows: "Heritage: a parish church". */
label: string;
/** Start on the template's second recommended variant of every section, and its second header. */
alternate: boolean;
hero: { headline: string; subline: string; button: Button };
serviceNote: string;
welcome: { heading: string; mission: string; body: string; quote: string };
ministriesIntro: string;
teamIntro: string | null;
invitation: { heading: string; text: string; button: Button };
visit: { expect: string; kids: string; cta: string };
about: { story: string; quote: string; by: string };
give: string;
/** Four: [slug, name, summary]. Their pictures are the kids, youth, music and care illustrations, in order. */
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][];
series: [string, string];
/** Three: [slug, title, days ago, passage]. */
messages: [string, string, number, string][];
/** Three: [slug, title, in days, description]. */
events: [string, string, number, string][];
/** Where the events are. */
venue: string;
};
const visitButton: Button = { label: 'Plan your visit', href: '/visit' };
export const DEMO_SEEDS: Record<WebsiteDemoProfile, DemoSeed> = {
'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 },
serviceNote: 'Holy Communion on the first Sunday of the month. Tea in the parish hall after every service.',
welcome: {
heading: 'Welcome to {name}', mission: 'Rooted in prayer, open to all, serving {city}.',
body: 'For more than a century people have gathered here to pray, to sing the old hymns and to hear God\'s word. Our services follow the prayer book, our choir sings most Sundays, and our doors are open to anyone who wants to come in out of the noise.',
quote: 'Whether this is your first time in a church or your thousandth, you are welcome here.',
},
ministriesIntro: 'Ways to belong, from the choir stalls to the Sunday school.',
teamIntro: 'The clergy and lay ministers who care for the parish.',
invitation: { heading: 'There is always a place in the pews', text: 'Join us this Sunday. Someone at the door will show you the way.', button: visitButton },
visit: {
expect: 'Our services follow a set order with readings, prayers and hymns. The words are printed in the service sheet, so you can follow along. A service lasts about an hour.',
kids: 'Sunday school meets in the hall during the sermon, and the children come back in for the blessing.',
cta: 'Would you like to talk to the rector before you come?',
},
about: { story: '{name} was founded by a handful of families in 1896, and the stone church was finished in 1912. The stained glass, the organ and the bell are all gifts from the parish over the years.', quote: 'Be still, and know that I am God.', by: 'Psalm 46:10' },
give: 'Thank you for supporting the life of the parish and the upkeep of the church building. You can give by EFT or in the plate on Sundays (demo details only: this is not a real account).',
ministries: [
['sunday-school', 'Sunday school', 'Bible stories, songs and crafts for ages 4 to 11 during the sermon.'],
['servers', 'Altar servers', 'Teenagers who help lead worship on Sunday mornings.'],
['choir', 'The parish choir', 'Choral evensong once a month and anthems every Sunday. New voices welcome.'],
['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']],
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: [
['family-picnic', 'Family picnic', 6, 'Bring a blanket and something to share on the rectory lawn. Games for the children.'],
['advent-carols', 'Advent carol service', 13, 'Readings and carols by candlelight, sung by the parish choir.'],
['christmas-eve', 'Christmas Eve midnight mass', 27, 'The first Communion of Christmas, with carols from 23:15.'],
],
venue: '{name}',
},
'heritage-city': {
id: 'heritage-city', template: 'heritage', label: 'Heritage: a city-centre church with weekday services', alternate: true,
hero: { headline: 'A quiet place in a busy city', subline: 'In the middle of {city}, open every weekday for prayer, lunchtime services and a cup of tea.', button: { label: 'Come in this week', href: '/visit' } },
serviceNote: 'Lunchtime service on weekdays at 13:05, twenty-five minutes, back at your desk in time.',
welcome: {
heading: 'Right in the heart of {city}', mission: 'A church for the city: for workers, students, visitors and neighbours.',
body: 'Thousands of people walk past our doors every day. Some come in to sit in the quiet, some to light a candle, some for the lunchtime service. On Sundays we worship as a congregation drawn from all over {city}.',
quote: 'The city needs places that are quiet and kind. We try to be one.',
},
ministriesIntro: 'Serving the city through the week.',
teamIntro: null,
invitation: { heading: 'The doors are open', text: 'Monday to Friday from 08:00 to 16:00. Come in for a moment, or for the service.', button: { label: 'When we are open', href: '/visit' } },
visit: {
expect: 'The weekday service is short and simple: a reading, a short talk and prayers. On Sundays the service is longer, with the choir and Communion.',
kids: 'Children are welcome at every service. There are activity bags at the back of the church.',
cta: 'Want to know more about the city ministries?',
},
about: { story: '{name} has stood on this corner since the city was young. Today our congregation is students, office workers, families and people who sleep on the streets nearby, all at the same tables.', quote: 'Seek the welfare of the city, and pray to the Lord on its behalf.', by: 'Jeremiah 29:7' },
give: 'Your gifts keep the doors open on weekdays and fund the soup kitchen (demo details only: this is not a real account).',
ministries: [
['students', 'Students', 'Supper and a Bible study for students on Tuesday evenings.'],
['young-workers', 'Young professionals', 'Breakfast before work on Thursdays at 07:00.'],
['lunchtime-music', 'Lunchtime concerts', 'Free organ and chamber music on Wednesdays.'],
['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']],
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: [
['organ-recital', 'Lunchtime organ recital', 2, 'Bach and Buxtehude, 13:05 to 13:40. Free, with a retiring collection.'],
['blue-christmas', 'Blue Christmas', 16, 'A quiet service for anyone who finds Christmas hard.'],
['city-carols', 'Carols for the city', 23, 'Readings and carols for everyone who works in {city}.'],
],
venue: '{name}',
},
'bold-youth': {
id: 'bold-youth', template: 'bold', label: 'Bold: a young, music-led church', alternate: false,
hero: { headline: 'Loud worship. Real people. Good news.', subline: '{short} is a church for {city}: come for the music, stay for the family.', button: { label: 'Visit this Sunday', href: '/visit' } },
serviceNote: 'Doors open half an hour before. Coffee bar in the foyer, kids church at the morning service.',
welcome: {
heading: 'This is {short}', mission: 'Helping people find and follow Jesus, together.',
body: 'We are a young church with a big heart for {city}. Sundays are full of energy: a live band, a message you can use on Monday, and people who will remember your name. Wherever you are coming from, you belong here.',
quote: 'We are not a perfect church. We are a family learning to follow Jesus together.',
},
ministriesIntro: 'Get connected. There is a place for you.',
teamIntro: null,
invitation: { heading: 'Your seat is waiting', text: 'Tell us you are coming and we will have a coffee ready for you.', button: { label: 'I am coming', href: '/visit' } },
visit: {
expect: 'Expect about 30 minutes of live worship and a 30-minute message. Come as you are: jeans are fine.',
kids: 'Kids church is high energy, safe and fun. Check your kids in at the kids desk when you arrive.',
cta: 'Got questions? Our team will get back to you.',
},
about: { story: '{short} started in a living room with twelve students and a guitar. Today we are a church of every age, but we have never lost the joy of that first night.', quote: 'I have come that they may have life, and have it to the full.', by: 'John 10:10' },
give: 'Generosity is part of who we are. Give online, by EFT or at the giving station (demo details only: this is not a real account).',
ministries: [
['kids', 'Kids', 'Ages 2 to 12, every Sunday morning.'],
['youth', 'Youth', 'Grades 8 to 12, Friday nights. Games, worship, real talk.'],
['creative', 'Worship and creative', 'Band, sound, lights and media. Auditions every term.'],
['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']],
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: [
['worship-night', 'Worship night', 5, 'Two hours of worship and prayer. Bring your friends.'],
['youth-camp', 'Summer youth camp', 19, 'Three days at the river for grades 8 to 12. Registration is open.'],
['christmas-experience', 'The Christmas experience', 26, 'Music, lights and the Christmas story for the whole family.'],
],
venue: 'The {short} auditorium',
},
'bold-plant': {
id: 'bold-plant', template: 'bold', label: 'Bold: a new church plant meeting in a school', alternate: true,
hero: { headline: 'A new church for {city}', subline: 'We are launching soon. Meet us on Sundays in the school hall and be part of something new.', button: { label: 'Find out more', href: '/about' } },
serviceNote: 'We meet in the school hall. Look for the flags at the gate; parking is on the field.',
welcome: {
heading: 'Something new is starting', mission: 'A church for people who don\'t go to church.',
body: '{short} is a brand-new church. We are a small team who moved to {city} to start a church for our neighbours. Every week we set up chairs in a school hall, and every week new people walk in. There is room for you on the team.',
quote: 'Every great church was once a few people setting out chairs.',
},
ministriesIntro: 'Small team, big vision. Find where you fit.',
teamIntro: 'The launch team.',
invitation: { heading: 'Join the launch team', text: 'Help us set up, welcome, play or pray. Every hand matters right now.', button: { label: 'Get involved', href: '/contact' } },
visit: {
expect: 'Our services are relaxed and short: songs, a talk and time to talk over coffee afterwards. Nobody will put you on the spot.',
kids: 'Kids are part of the service for the songs, then go to their own room in the classroom next door.',
cta: 'Want to meet the team first?',
},
about: { story: '{short} was planted last year by a team of eight with the support of churches across the country. We have met in lounges, a coffee shop and now the school hall.', quote: 'See, I am doing a new thing! Now it springs up; do you not perceive it?', by: 'Isaiah 43:19' },
give: 'Every gift helps us reach a new neighbourhood with the good news (demo details only: this is not a real account).',
ministries: [
['kids-room', 'Kids room', 'A safe, fun room for children during the service.'],
['set-up', 'Set-up team', 'Chairs, sound and signs from 07:30. Breakfast is on us.'],
['band', 'Band', 'Guitar, keys, drums or voice. We need you.'],
['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']],
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: [
['launch-sunday', 'Launch Sunday', 7, 'Our first public service. Bring everyone you know.'],
['street-braai', 'Street braai', 14, 'Food and games for the neighbourhood in the school grounds.'],
['christmas-in-the-hall', 'Christmas in the hall', 24, 'A family carol service with mince pies.'],
],
venue: 'The school hall',
},
'community-family': {
id: 'community-family', template: 'community', label: 'Community: a family church with small groups', alternate: false,
hero: { headline: 'Come as you are, bring the family', subline: 'A friendly church in {city} where kids are noisy, coffee is hot and everyone knows your name.', button: visitButton },
serviceNote: 'Kids church for every age during the service. Coffee and juice afterwards on the lawn.',
welcome: {
heading: 'Hello, we are {short}', mission: 'Families following Jesus together, every day of the week.',
body: 'We are mums, dads, grandparents, singles, teenagers and toddlers. On Sundays we worship together, and during the week we meet in homes across {city} to eat, pray and look after each other.',
quote: 'Church is not a building we go to. It is a family we belong to.',
},
ministriesIntro: 'Something for every member of the family.',
teamIntro: 'The people who look after our church family.',
invitation: { heading: 'Pop in this Sunday', text: 'Let us know you are coming and we will save you a spot (and a muffin).', button: visitButton },
visit: {
expect: 'Our services are friendly and informal and last about an hour and a quarter. You don\'t need to know the songs or the Bible to feel at home.',
kids: 'Babies to grade 7 have their own groups with trained, screened leaders. There is a parents\' room with the service on a screen.',
cta: 'Questions about the kids? Ask us anything.',
},
about: { story: '{short} began when three families started meeting for a Bible study and the kids outnumbered the grown-ups. We still think that is a good sign.', quote: 'As for me and my household, we will serve the Lord.', by: 'Joshua 24:15' },
give: 'Thank you for helping us care for families in {city} (demo details only: this is not a real account).',
ministries: [
['little-ones', 'Little ones', 'Babies and toddlers, with a play area and story time.'],
['teens', 'Teens', 'Grades 6 to 12 on Friday evenings: games, food and faith.'],
['worship-team', 'Worship team', 'Singers and musicians of all ages lead us on Sundays.'],
['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']],
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: [
['fun-day', 'Family fun day', 6, 'Jumping castles, a cake sale and a soccer match for dads.'],
['holiday-club', 'Holiday club', 15, 'Four mornings of games, crafts and stories for ages 4 to 12.'],
['christmas-family-service', 'Christmas family service', 25, 'Our nativity, sung by the kids, followed by tea.'],
],
venue: '{name}',
},
'community-town': {
id: 'community-town', template: 'community', label: 'Community: a country-town church serving its district', alternate: true,
hero: { headline: 'Neighbours, friends, family', subline: 'The church in {city} that has been part of farm and town life for generations.', button: { label: 'Meet us on Sunday', href: '/visit' } },
serviceNote: 'Combined service on the last Sunday of the month, with a bring-and-share lunch.',
welcome: {
heading: 'Welcome to {name}', mission: 'Loving God and serving our district, farm and town alike.',
body: 'In a small town everyone knows everyone, and the church is where we meet in good times and hard ones. We pray for the rain, we help with the harvest festival, and when someone is in need we turn up with a casserole.',
quote: 'A small church can have a big heart. Come and see.',
},
ministriesIntro: 'Serving town and farm through the week.',
teamIntro: null,
invitation: { heading: 'You are always welcome here', text: 'Visiting the district? Join us on Sunday morning and stay for tea.', button: { label: 'Find us', href: '/contact' } },
visit: {
expect: 'A friendly, simple service with hymns and newer songs, a Bible message and prayers for the district. About an hour.',
kids: 'Children start in the service and go to Sunday school after the first songs.',
cta: 'Need a lift to church? Let us know.',
},
about: { story: 'The first service in {city} was held under a tree in the square. The church was built by local farmers and townspeople, stone by stone, and it is still the heart of the town.', quote: 'While the earth remains, seedtime and harvest shall not cease.', by: 'Genesis 8:22' },
give: 'Your gifts help us support families in the district through hard seasons (demo details only: this is not a real account).',
ministries: [
['sunday-school', 'Sunday school', 'Every Sunday for children of the town and the farms.'],
['youth', 'Youth', 'Friday evenings for high schoolers from the district.'],
['music', 'Choir and band', 'Old hymns and new songs, rehearsing on Thursdays.'],
['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']],
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: [
['harvest-festival', 'Harvest festival', 8, 'Produce, baking and crafts in the church hall, for the district\'s food bank.'],
['farm-carols', 'Carols on the farm', 20, 'An evening carol service at the Botha family\'s farm. Bring a chair.'],
['new-year-prayer', 'New Year prayer breakfast', 36, 'Pray for the year ahead over breakfast in the hall.'],
],
venue: '{name}',
},
'clean-modern': {
id: 'clean-modern', template: 'clean', label: 'Clean: a contemporary church, simply put', alternate: false,
hero: { headline: 'Faith for real life', subline: 'Sundays in {city}. Honest conversations, good coffee, and Jesus at the centre.', button: visitButton },
serviceNote: 'One service, about an hour. Kids programme included.',
welcome: {
heading: 'A church without the fuss', mission: 'Clear about Jesus. Open to questions.',
body: 'We keep things simple so the important things stand out. Our Sundays are thoughtful and relaxed, and our groups are a good place to ask the questions you have been carrying around.',
quote: 'Bring your questions. We are not afraid of them.',
},
ministriesIntro: 'A few things, done well.',
teamIntro: null,
invitation: { heading: 'See you on Sunday', text: 'No pressure, no spotlight. Just come.', button: visitButton },
visit: {
expect: 'A few songs, a talk that takes the Bible and your life seriously, and time to chat afterwards.',
kids: 'Kids have their own programme during the service, in age groups up to grade 7.',
cta: 'Prefer to message first?',
},
about: { story: '{short} began in 2015 with a simple idea: a church where it is normal to doubt, to ask and to grow. We are still that church.', quote: 'Come to me, all you who are weary and burdened, and I will give you rest.', by: 'Matthew 11:28' },
give: 'Giving is simple: by EFT or with a card at the welcome desk (demo details only: this is not a real account).',
ministries: [
['kids', 'Kids', 'Age groups up to grade 7, every Sunday.'],
['students', 'Students', 'University and college students, Sunday evenings.'],
['music', 'Music', 'A small band leading simple, honest worship.'],
['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']],
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: [
['alpha-starts', 'Alpha starts', 9, 'Ten Thursday evenings with dinner. Ask anything.'],
['carols-and-coffee', 'Carols and coffee', 18, 'A short carol service and a coffee cart.'],
['christmas-day', 'Christmas Day', 28, 'One family service at 09:00, about 45 minutes.'],
],
venue: '{name}',
},
'clean-campus': {
id: 'clean-campus', template: 'clean', label: 'Clean: a church near the university', alternate: true,
hero: { headline: 'Students, staff and neighbours', subline: 'A church across the road from campus in {city}. Sunday evenings, with supper.', button: { label: 'First time?', href: '/visit' } },
serviceNote: 'Evening service with free supper afterwards during term.',
welcome: {
heading: 'Welcome to {short}', mission: 'Thinking hard, loving well, following Jesus.',
body: 'Most of us are students or work at the university, and plenty of us live in the streets around it. We meet on Sunday evenings, eat together, and spend the week in small groups across campus.',
quote: 'University is where you ask the big questions. Church is a good place to ask them out loud.',
},
ministriesIntro: 'Find your people.',
teamIntro: 'The staff team.',
invitation: { heading: 'Supper is on us', text: 'Every Sunday in term, after the evening service.', button: { label: 'Come for supper', href: '/visit' } },
visit: {
expect: 'The evening service has songs, a Bible talk and prayer, and ends with supper in the hall. It lasts about an hour before the food.',
kids: 'Staff and neighbours with children: there is a morning family service on the first Sunday of the month.',
cta: 'New to the city? We would love to help you settle in.',
},
about: { story: '{short} started as a student Bible study in a residence common room. It grew into a church for the whole campus community and the neighbourhood around it.', quote: 'Love the Lord your God with all your heart and with all your soul and with all your mind.', by: 'Matthew 22:37' },
give: 'If you are a student, please don\'t worry about giving. If you can, your gifts fund supper every Sunday (demo details only: this is not a real account).',
ministries: [
['families', 'Families', 'A monthly family service for staff and neighbours with children.'],
['res-groups', 'Residence groups', 'Bible studies in every residence, weeknights.'],
['music', 'Music', 'Student musicians lead the evening service.'],
['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']],
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: [
['exam-prayer', 'Exam prayer and pizza', 3, 'A break from studying: prayer, pizza and encouragement.'],
['end-of-term-dinner', 'End of term dinner', 12, 'A three-course dinner to celebrate the end of term.'],
['carols-on-campus', 'Carols on campus', 19, 'Carols on the library lawn for students who are still here.'],
],
venue: '{name}',
},
};
/** The profiles in the contracts' order (what the Hub offers). */
export const demoSeeds = (): DemoSeed[] => agent.WEBSITE_DEMO_PROFILES.map((id: WebsiteDemoProfile) => DEMO_SEEDS[id]);
+64 -2
View File
@@ -4,8 +4,9 @@ import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import request from 'supertest';
import { WEBSITE_TEMPLATES } from '@crosscode/contracts';
import { loadDemo } from '../src/demo/demoChurch.js';
import { WEBSITE_TEMPLATES, agent } from '@crosscode/contracts';
import { demoProfile, loadDemo, seedDesign } from '../src/demo/demoChurch.js';
import { DEMO_SEEDS, demoSeeds } from '../src/demo/seeds.js';
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';
@@ -122,6 +123,67 @@ describe('the public site\'s content', () => {
});
}
for (const profile of agent.WEBSITE_DEMO_PROFILES) {
it(`1.3.0: loads the ${profile} demo, keeping the church's own profile and naming it`, async () => {
const h = await harness({ linked: false });
const dir = tmp();
const own = { ...demoProfile('http://x.test'), name: 'Grace Point Church', shortName: 'Grace Point', branding: { ...demoProfile('').branding, colours: { primary: '#8a1538', accent: '#f2c14e' } } };
await h.ctx.settings.set('church_profile_local', JSON.stringify(own));
await loadDemo(h.ctx, profile, { uploadDir: dir });
const c = await siteContent(h.ctx);
assert.equal(c.mode, 'published');
if (c.mode !== 'published') return;
const seed = DEMO_SEEDS[profile];
assert.equal(c.snapshot.design.template, seed.template);
assert.equal(c.church?.name, 'Grace Point Church', 'the organisation settings stay');
assert.equal(c.snapshot.pages.length, 9);
assert.equal(c.snapshot.ministries.length, 4);
assert.equal(c.messages.length, 3);
assert.equal(c.events.length, 3);
const all = JSON.stringify(c.snapshot);
assert.doesNotMatch(all, /\{(name|short|city)\}/, 'every placeholder is filled in');
assert.doesNotMatch(all, /Acacia/, 'nothing of the development church');
assert.equal(c.snapshot.design.variants.hero, seedDesign(seed.template, seed.alternate).variants.hero);
assert.match(fs.readFileSync(path.join(dir, 'demo', 'hero.svg'), 'utf8'), /#8a1538/, 'pictures in the church\'s colours');
});
}
it('1.3.0: the two profiles of a template differ, the second on its other recommended variants and header', () => {
for (const template of WEBSITE_TEMPLATES) {
const [a, b] = demoSeeds().filter((s) => s.template === template);
assert.ok(a && b && !a.alternate && b.alternate, template);
const alt = seedDesign(template, true);
assert.notDeepEqual(alt.variants, seedDesign(template, false).variants);
assert.notEqual(alt.style.header, seedDesign(template, false).style.header);
assert.notEqual(a.hero.headline, b.hero.headline);
}
});
it('1.3.0: a profile keeps the site icon and the settings, and clears the old content, slugs and preview links', async () => {
const h = await harness({ linked: false });
const dir = tmp();
await loadDemo(h.ctx, 'heritage', { uploadDir: dir });
const icon = (await h.db.mediaAsset.create({ data: { filename: 'icon.png', mime: 'image/png', bytes: 10, width: 64, height: 64, alt: 'Icon' } })) as { id: string };
await h.ctx.settings.set('favicon_media_id', icon.id);
await h.ctx.settings.set('coming_soon_text', 'Soon!');
await h.db.slugHistory.create({ data: { slug: 'old-about', pageId: 'gone' } });
await loadDemo(h.ctx, 'community-town', { uploadDir: dir });
assert.ok(await h.db.mediaAsset.findUnique({ where: { id: icon.id } }), 'the site icon stays');
assert.equal(await h.ctx.settings.get('favicon_media_id'), icon.id);
assert.equal(await h.ctx.settings.get('coming_soon_text'), 'Soon!');
assert.equal(await h.db.mediaAsset.count(), 11, 'the ten pictures and the icon');
assert.equal(await h.db.slugHistory.count(), 0);
assert.equal((await siteContent(h.ctx)).church?.name, 'Acacia Hill Church', 'the profile saved by the first demo stays');
});
it('1.3.0: a profile on a site with no church profile at all saves the demo one, so the site has a name', async () => {
const h = await harness({ linked: false });
await loadDemo(h.ctx, 'clean-campus', { uploadDir: tmp() });
const c = await siteContent(h.ctx);
assert.equal(c.church?.name, 'Acacia Hill Church');
assert.ok(c.mode === 'published' && JSON.stringify(c.snapshot).includes('Welcome to Acacia Hill'));
});
it('serves the uploads, never a folder or outside it, and the content over HTTP', async () => {
const dir = tmp();
const h = await harness({ linked: false, env: { UPLOAD_DIR: dir } });
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@crosscode/website-frontend",
"version": "1.2.0",
"version": "1.3.0",
"private": true,
"description": "Church Website: the church's public site in its template, and the admin",
"scripts": {
+11 -5
View File
@@ -15,7 +15,7 @@ separately below; the two often differ.
| Accounts | `crosscode-platform` (`apps/accounts`) | **1.8.0** | `accounts@1.8.0` | 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.24.0** | `v2.24.0` | 2026-11-27 |
| Cross Code Hub | `events-hub` | **2.24.1** | `v2.24.1` | 2026-11-27 |
| 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) |
@@ -30,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` | 1.2.0 (1.0.0–1.1.0 released 2026-11-26, 1.2.0 on 2026-11-27; installed for the demo church cross-demo2 (1.1.0) only, Hope Family Church next) |
| Website | `apps/website` | 1.2.0 (1.0.0–1.1.0 released 2026-11-26, 1.2.0 on 2026-11-27; installed for the demo church cross-demo2 (1.2.0) 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
@@ -38,6 +38,11 @@ need their own tags until something outside this repo depends on them.
## What each latest release was for
- **Hub 2.24.1 (2026-11-27):** Servers → Updates offers every product. Its tabs were a fixed list of
Cross Events and Accounts from before the Church Website, so Website installs couldn't be updated
in a batch there; now Events, Accounts, the Church Website, and the App once it has an install.
Frontend only, plus one error message. No migration. Checked: the backend tests (279), frontend
typecheck and lint. **Deployed 2026-11-27.**
- **Church Website 1.2.0 + Hub 2.24.0 (2026-11-27):** Website: a new install had no pages, so the
home page and its live preview showed only the header and footer (found on cross-demo2); the
backend now adds the fixed pages with starter text at startup (all of them to a site with none,
@@ -48,7 +53,8 @@ need their own tags until something outside this repo depends on them.
first, one at a time, stopping at the first failure), scheduled or as an emergency, planned whole
or not at all; later products keep Accounts at the batch's new version. No migration. Checked:
the Website's backend tests (104), the admin e2e (11, with axe), typechecks and lint; the Hub's
backend tests (279), frontend typecheck and lint. **Not deployed yet.**
backend tests (279), frontend typecheck and lint. **Hub 2.24.0 deployed 2026-11-27; Website
1.2.0 on cross-demo2 the same day** (its health check says 1.2.0, `/site-icon` serves the default).
- **Accounts 1.8.0 + Church Website 1.1.0 (2026-11-26):** both admins redesigned as Cross Events' admin
dashboard and settings. Accounts: `/admin` is an overview, People moved to `/admin/people`, a
grouped sidebar showing the part you're in. Website: an icon sidebar, a dashboard, steps to the
@@ -300,10 +306,10 @@ you deploy one.
| What | Running | Since | Notes |
|------|---------|-------|-------|
| 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) |
| Hub | 2.24.1 | 2026-11-27 | Servers → Updates offers every product (the Church Website too). Before it, 2.24.0 (2026-11-27): "Update everything to latest" on a customer's Sites card: every product that's behind, in one batch (Accounts first); before that, 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; 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 |
| Accounts (churches) | 1.6.0 | 2026-11-20 | |
| cross-demo2 (demo church) | Accounts 1.7.1, Cross Events 3.7.1, Church Website 1.1.0 (its health check, 2026-11-27) | 2026-11-26 | The first Church Website install (`demo2.crosscode.co.za`, added next to the church's Accounts) |
| cross-demo2 (demo church) | Accounts 1.7.1, Cross Events 3.7.1, Church Website 1.2.0 | 2026-11-27 | The first Church Website install (`demo2.crosscode.co.za`, added next to the church's Accounts) |
| crosscode.co.za | 1.6.1 | 2026-11-23 | Clearer web address choices on the Cross Events page |
+4 -4
View File
@@ -114,7 +114,7 @@
},
"apps/agent": {
"name": "@crosscode/agent",
"version": "1.5.0",
"version": "1.6.0",
"license": "UNLICENSED",
"dependencies": {
"@crosscode/contracts": "*",
@@ -360,7 +360,7 @@
},
"apps/website/backend": {
"name": "@crosscode/website-backend",
"version": "1.2.0",
"version": "1.3.0",
"hasInstallScript": true,
"dependencies": {
"@crosscode/auth-client": "*",
@@ -387,7 +387,7 @@
},
"apps/website/frontend": {
"name": "@crosscode/website-frontend",
"version": "1.2.0",
"version": "1.3.0",
"dependencies": {
"@crosscode/contracts": "*",
"@crosscode/seo": "*",
@@ -23183,7 +23183,7 @@
},
"packages/contracts": {
"name": "@crosscode/contracts",
"version": "1.18.0",
"version": "1.19.0",
"license": "UNLICENSED",
"dependencies": {
"zod": "^4.6.7"
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@crosscode/contracts",
"version": "1.18.0",
"version": "1.19.0",
"description": "The shared JSON formats used by every Cross Code product: zod schemas, JSON Schema, TypeScript types and sample payloads",
"license": "UNLICENSED",
"type": "commonjs",
+28 -4
View File
@@ -819,13 +819,37 @@
"type": "string",
"pattern": "^[a-z][a-z0-9-]{1,30}$"
},
"profile": {
"product": {
"type": "string",
"enum": [
"small",
"events",
"ministry",
"multicampus"
"website"
]
},
"profile": {
"anyOf": [
{
"type": "string",
"enum": [
"small",
"events",
"ministry",
"multicampus"
]
},
{
"type": "string",
"enum": [
"heritage-parish",
"heritage-city",
"bold-youth",
"bold-plant",
"community-family",
"community-town",
"clean-modern",
"clean-campus"
]
}
]
},
"adminEmail": {
+39 -4
View File
@@ -59,9 +59,33 @@ export const DEMO_PROFILES = ["small", "events", "ministry", "multicampus"] as c
export const demoProfileSchema = z.enum(DEMO_PROFILES);
export type DemoProfile = z.infer<typeof demoProfileSchema>;
/**
* The Church Website's demo data sets (1.19.0, `apps/website/backend/src/demo/seeds.ts`): two per
* template, each its own kind of church, the second on the template's other recommended variants.
*/
export const WEBSITE_DEMO_PROFILES = [
"heritage-parish", "heritage-city",
"bold-youth", "bold-plant",
"community-family", "community-town",
"clean-modern", "clean-campus",
] as const;
export const websiteDemoProfileSchema = z.enum(WEBSITE_DEMO_PROFILES);
export type WebsiteDemoProfile = z.infer<typeof websiteDemoProfileSchema>;
/** The products with demo data (`seed-demo` jobs). */
export const DEMO_PRODUCTS = ["events", "website"] as const;
export const demoProductSchema = z.enum(DEMO_PRODUCTS);
export type DemoProduct = z.infer<typeof demoProductSchema>;
/** Each demo product's profiles. */
export const DEMO_PROFILES_BY_PRODUCT: Record<DemoProduct, readonly string[]> = { events: DEMO_PROFILES, website: WEBSITE_DEMO_PROFILES };
/** The first agent that runs `seed-demo` jobs (an older one refuses the unknown type). */
export const SEED_DEMO_MIN_AGENT = "1.2.0";
/** The first agent that runs `seed-demo` jobs for the Website (`product: "website"`; an older one refuses the unknown key). */
export const SEED_WEBSITE_DEMO_MIN_AGENT = "1.6.0";
/** The first agent that runs `env-read` and `env-set` jobs (an older one refuses the unknown types). */
export const ENV_JOBS_MIN_AGENT = "1.3.0";
@@ -135,11 +159,22 @@ export const jobArgsSchemas = {
/** `crosscode restart <church> [product] --json` (PM2 reload) */
restart: z.strictObject({ church: shortNameSchema, product: productSchema.optional() }),
/**
* `crosscode demo <church> --profile <profile> [--admin-email <email>] --json`: replaces Cross
* Events' data with a demo set (a backup is taken first). The Hub only makes it for installs
* marked as demo sites. `adminEmail`: the account kept (default: the release's own choice).
* `crosscode demo <church> [website] --profile <profile> [--admin-email <email>] --json`: replaces
* Cross Events' data (or, 1.19.0 with `product: "website"`, the Website's content) with a demo
* set (a backup is taken first). The Hub only makes it for installs marked as demo sites.
* `adminEmail` (Events only): the account kept (default: the release's own choice). No `product`
* is Events, so older Hubs' jobs mean what they did.
*/
"seed-demo": z.strictObject({ church: shortNameSchema, profile: demoProfileSchema, adminEmail: z.email().max(254).optional() }),
"seed-demo": z.strictObject({
church: shortNameSchema,
product: demoProductSchema.optional(),
profile: z.union([demoProfileSchema, websiteDemoProfileSchema]),
adminEmail: z.email().max(254).optional(),
}).superRefine((a, ctx) => {
const product = a.product ?? "events";
if (!DEMO_PROFILES_BY_PRODUCT[product].includes(a.profile)) ctx.addIssue({ code: "custom", path: ["profile"], message: `${a.profile} isn't a ${product} demo` });
if (product === "website" && a.adminEmail) ctx.addIssue({ code: "custom", path: ["adminEmail"], message: "the Website's demo keeps every admin" });
}),
/**
* `crosscode env <church> <product> --json`: the product's .env values, secrets hidden (only
* whether they're set). The report's `result` is an {@link envReadResultSchema}.
+9
View File
@@ -165,6 +165,15 @@ describe("seed-demo jobs", () => {
expect(agent.JOB_TYPES).toContain("seed-demo");
expect(agent.CENTRAL_JOB_TYPES).not.toContain("seed-demo");
});
it("1.19.0: a Website demo names the product and takes only a Website profile", () => {
expect(args({ church: "hope", product: "website", profile: "bold-plant" })).toBe(true);
expect(args({ church: "hope", product: "events", profile: "small" })).toBe(true);
expect(args({ church: "hope", product: "website", profile: "small" })).toBe(false);
expect(args({ church: "hope", profile: "bold-plant" })).toBe(false);
expect(args({ church: "hope", product: "website", profile: "clean-campus", adminEmail: "jane@hope.test" })).toBe(false);
expect(args({ church: "hope", product: "accounts", profile: "small" })).toBe(false);
expect(agent.WEBSITE_DEMO_PROFILES).toHaveLength(8);
});
});
describe("env-read and env-set jobs (1.12.0)", () => {
+1 -1
View File
@@ -96,7 +96,7 @@ crosscode: Cross Code installs on this server ($(git -C "${CROSSCODE_FROM:-.}" r
crosscode adopt <church> --events-dir <old folder> move an existing Cross Events install here
crosscode adopt <church> --undo go back to the old folder (within 14 days)
crosscode restart <church> [events] reload the PM2 processes
crosscode demo <church> --profile <profile> replace Events' data with a demo set
crosscode demo <church> [website] --profile <p> replace Events' (or the Website's) data with a demo
crosscode env <church> <product> [--set NAME=value] show or change a product's .env values
crosscode export <church> [product …] --out <zip> the church's data and uploads
crosscode uninstall <church> [product …] --confirm <church>
+46 -1
View File
@@ -10,6 +10,12 @@ crosscode demo <church> --profile <profile> [--admin-email <email>]
replace Cross Events' data with a demo set
(small, events, ministry, multicampus); a backup
is taken first, one admin account is kept
crosscode demo <church> website --profile <profile>
replace the Website's content with a demo church
(heritage-parish, heritage-city, bold-youth,
bold-plant, community-family, community-town,
clean-modern, clean-campus); a backup is taken
first; the church's profile, settings and admins stay
crosscode env <church> <product> the product's .env values (secrets hidden)
crosscode env <church> <product> [--file backend/.env] --set NAME=value … [--unset NAME …] [--restart]
change values (a copy is kept; never secrets or
@@ -83,22 +89,32 @@ cmd_restart() {
}
DEMO_PROFILES="small events ministry multicampus"
# The Website's (contracts WEBSITE_DEMO_PROFILES): two per template.
WEBSITE_DEMO_PROFILES="heritage-parish heritage-city bold-youth bold-plant community-family community-town clean-modern clean-campus"
# Replaces Events' data with a demo set (apps/events/backend/scripts/set-demo.js), as the site's
# user (its .env is readable only by that user). The Hub sends it only for installs marked as demo
# sites. Afterwards Events is reloaded: the demo switches campuses on or off.
# `crosscode demo <church> website --profile <p>`: the Website's content instead (cmd_demo_website).
cmd_demo() {
local church="" profile="" email="" dir user app
local church="" product="events" profile="" email="" dir user app
while [ $# -gt 0 ]; do
case "$1" in
--profile) [ $# -ge 2 ] || die "--profile needs a value."; profile="$2"; shift 2 ;;
--admin-email) [ $# -ge 2 ] || die "--admin-email needs a value."; email="$2"; shift 2 ;;
-h|--help) manage_usage; return 0 ;;
-*) die "Unknown option $1 (crosscode help demo)." ;;
events|website) [ -n "$church" ] || die "Name the church first (crosscode demo hope website …)."; product="$1"; shift ;;
*) [ -z "$church" ] || die "One church at a time."; church="$1"; shift ;;
esac
done
[ -n "$church" ] || die "Name the church."
if [ "$product" = website ]; then
[[ " $WEBSITE_DEMO_PROFILES " == *" $profile "* ]] || die "--profile: one of $WEBSITE_DEMO_PROFILES."
[ -z "$email" ] || die "--admin-email: the Website's demo keeps every admin."
cmd_demo_website "$church" "$profile"
return
fi
[[ " $DEMO_PROFILES " == *" $profile "* ]] || die "--profile: one of $DEMO_PROFILES."
[ -z "$email" ] || [[ "$email" =~ ^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$ ]] || die "--admin-email: not an email address."
require_root
@@ -128,6 +144,35 @@ cmd_demo() {
die "Events didn't answer after the reload (sudo -u $user pm2 logs)."
}
# The Website's demo (Website 1.3.0+, backend/src/demo/seeds.ts): its content replaced with one of
# the eight demo churches, keeping the church's profile, the site settings and the admins. Backup
# first; then reloaded, so nothing cached from before is shown.
cmd_demo_website() {
local church="$1" profile="$2" dir user app
require_root
load_church "$church"
church_has_product website || die "$church has no Church Website."
# shellcheck source=/dev/null
source "$CROSSCODE_HOME/products/website.sh"
dir="$(pvar website DIR)"
user="$(pvar website USER)"
app="$(website_app "$dir")"
[ -f "$app/backend/src/demo/seeds.ts" ] || die "This release of the Website ($(checkout_ref "$dir" website)) has no demo profiles (1.3.0 or later has)."
step "Website: backup first"
website_backup "$dir" "$user" || die "The backup failed, so the demo wasn't loaded."
step "Website: demo ($profile)"
run_as "$user" "$app/backend" npm run --silent demo -- --profile "$profile" --force ||
die "The demo wasn't loaded (see above). If it got as far as changing anything, the backup from just now has the content from before."
step "Website: reloading PM2"
website_reload "$dir" "$user"
step "Website: waiting for it to answer"
wait_for_version "$(website_health_url)" "$(website_expected_version "$dir")" 60 ||
die "The Website didn't answer after the reload (sudo -u $user pm2 logs)."
}
# crosscode env <church> <product>: the product's .env values, secrets hidden (the Hub's env-read).
# With --set / --unset (the Hub's env-set): changes one file (--file, default backend/.env), keeping
# a copy first; when the frontend's file changed, the frontend is rebuilt (Next.js builds its values
+41 -8
View File
@@ -17,6 +17,15 @@ setup() {
export CROSSCODE_HOME="$TMP/home"
mkdir -p "$CROSSCODE_HOME/products" "$TMP/sites/hope/events/apps/events/backend/scripts"
touch "$TMP/sites/hope/events/apps/events/backend/scripts/set-demo.js"
mkdir -p "$TMP/sites/hope/website/apps/website/backend/src/demo"
touch "$TMP/sites/hope/website/apps/website/backend/src/demo/seeds.ts"
cat > "$CROSSCODE_HOME/products/website.sh" <<EOF2
website_app() { printf '%s/apps/website' "\$1"; }
website_backup() { echo "backup \$2" >> "$CALLS"; [ -z "\${FAIL_BACKUP:-}" ]; }
website_reload() { echo "reload \$2" >> "$CALLS"; }
website_health_url() { echo http://127.0.0.1:5300/api/health; }
website_expected_version() { echo 1.3.0; }
EOF2
cat > "$CROSSCODE_HOME/products/events.sh" <<EOF
events_app() { printf '%s/apps/events' "\$1"; }
events_backup() { echo "backup \$2" >> "$CALLS"; [ -z "\${FAIL_BACKUP:-}" ]; }
@@ -26,9 +35,9 @@ events_expected_version() { echo 2.4.1; }
EOF
require_root() { :; }
load_church() { [ "$1" = hope ] || die "There's no church $1 here."; }
church_has_product() { [ "$1" = events ]; }
pvar() { case "$2" in DIR) echo "$TMP/sites/hope/events" ;; USER) echo cc-hope ;; esac; }
checkout_ref() { echo events@2.4.1; }
church_has_product() { [ "$1" = events ] || [ "$1" = website ]; }
pvar() { case "$2" in DIR) echo "$TMP/sites/hope/$1" ;; USER) echo "cc-hope-$1" ;; esac; }
checkout_ref() { echo "$2@1.0.0"; }
wait_for_version() { echo "wait $2" >> "$CALLS"; }
run_as() { local user="$1" dir="$2"; shift 2; echo "run $user ${dir#"$TMP"/} $*" >> "$CALLS"; [ -z "${FAIL_SEED:-}" ]; }
}
@@ -49,23 +58,23 @@ EOF
@test "backup, then the demo as the site's user (no prompt), then a reload" {
run cmd_demo hope --profile ministry
[ "$status" -eq 0 ]
[ "$(cat "$CALLS")" = "backup cc-hope
run cc-hope sites/hope/events/apps/events/backend env node scripts/set-demo.js --profile=ministry --yes
reload cc-hope
[ "$(cat "$CALLS")" = "backup cc-hope-events
run cc-hope-events sites/hope/events/apps/events/backend env node scripts/set-demo.js --profile=ministry --yes
reload cc-hope-events
wait 2.4.1" ]
}
@test "the admin to keep goes in DEMO_ADMIN_EMAIL (older releases only read that)" {
run cmd_demo hope --profile small --admin-email jane@hope.test
[ "$status" -eq 0 ]
grep -qx 'run cc-hope sites/hope/events/apps/events/backend env DEMO_ADMIN_EMAIL=jane@hope.test node scripts/set-demo.js --profile=small --yes' "$CALLS"
grep -qx 'run cc-hope-events sites/hope/events/apps/events/backend env DEMO_ADMIN_EMAIL=jane@hope.test node scripts/set-demo.js --profile=small --yes' "$CALLS"
}
@test "a failed backup stops it before the data is touched" {
FAIL_BACKUP=1 run cmd_demo hope --profile small
[ "$status" -eq 1 ]
[[ "$output" == *"The backup failed"* ]]
[ "$(cat "$CALLS")" = "backup cc-hope" ]
[ "$(cat "$CALLS")" = "backup cc-hope-events" ]
}
@test "a failed demo isn't followed by a reload" {
@@ -81,3 +90,27 @@ wait 2.4.1" ]
[[ "$output" == *"has no demo data"* ]]
[ ! -s "$CALLS" ]
}
@test "website: backup, then the demo profile as the site's user, then a reload" {
run cmd_demo hope website --profile bold-plant
[ "$status" -eq 0 ]
[ "$(cat "$CALLS")" = "backup cc-hope-website
run cc-hope-website sites/hope/website/apps/website/backend npm run --silent demo -- --profile bold-plant --force
reload cc-hope-website
wait 1.3.0" ]
}
@test "website: only its own profiles, no admin email, and only a release that has them" {
run cmd_demo hope website --profile small
[ "$status" -eq 1 ]
[[ "$output" == *"heritage-parish"* ]]
run cmd_demo hope website --profile clean-campus --admin-email jane@hope.test
[ "$status" -eq 1 ]
run cmd_demo hope --profile clean-campus
[ "$status" -eq 1 ]
rm "$TMP/sites/hope/website/apps/website/backend/src/demo/seeds.ts"
run cmd_demo hope website --profile clean-campus
[ "$status" -eq 1 ]
[[ "$output" == *"no demo profiles"* ]]
[ ! -s "$CALLS" ]
}