crosscode: the Church App (app.sh, add, demo) and the App's changelog

scripts/products/app.sh and app.env.template.json; app in
SUPPORTED_PRODUCTS; crosscode add <church> app (Accounts first);
crosscode demo <church> app --profile <s>, and the App's turn, last,
in a whole demo scenario. app.bats and demo.bats; app.sh linted.
The full bats suite wasn't run (stopped for low memory); app.bats and
demo.bats pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-01 16:11:41 +02:00
co-authored by Claude Opus 5.5
parent acd3b259a1
commit 71f2f02ee5
11 changed files with 407 additions and 25 deletions
+3 -3
View File
@@ -8,7 +8,7 @@ CROSSCODE_REPO="${CROSSCODE_REPO:-https://c-git.crosscode.co.za/joshua/crosscode
# through it.
PRODUCT_ORDER=(accounts events website app)
# Products this version of the script can deploy (a products/<name>.sh exists for each).
SUPPORTED_PRODUCTS=(accounts events website)
SUPPORTED_PRODUCTS=(accounts events website app)
# Releases older than this get a warning; older than CROSSCODE_NODE_MIN the deploy is refused.
CROSSCODE_NODE_MIN=20
CROSSCODE_NODE_WARN=22
@@ -358,8 +358,8 @@ node_major() { node -p 'process.versions.node.split(".")[0]' 2>/dev/null || echo
# 1.0–1.1 has no .gitignore for its ecosystem.config.cjs). Nor do the files in the folders this
# script writes into (Accounts below 1.3.0 doesn't ignore the database dumps made before each
# deploy, so the dump would stop the very deploy that brings the .gitignore).
CROSSCODE_OWN_FILES=(apps/events/ecosystem.config.js apps/accounts/ecosystem.config.cjs apps/website/ecosystem.config.cjs)
CROSSCODE_OWN_DIRS=(apps/accounts/backend/backups/ apps/website/backend/backups/)
CROSSCODE_OWN_FILES=(apps/events/ecosystem.config.js apps/accounts/ecosystem.config.cjs apps/website/ecosystem.config.cjs apps/app/ecosystem.config.cjs)
CROSSCODE_OWN_DIRS=(apps/accounts/backend/backups/ apps/website/backend/backups/ apps/app/backend/backups/)
local_changes() {
git_in "$1" status --porcelain --untracked-files=all |
awk -v own="${CROSSCODE_OWN_FILES[*]}" -v dirs="${CROSSCODE_OWN_DIRS[*]}" '
+11 -7
View File
@@ -214,6 +214,7 @@ install_product() {
events) install_events "$@" ;;
accounts) install_accounts "$@" ;;
website) install_website "$@" ;;
app) install_app_product "$@" ;;
*) die "This version of crosscode can't install $product." ;;
esac
}
@@ -242,7 +243,7 @@ install_done() {
info "DNS (if not set yet): $domain → this server (A record, or a CNAME)."
fi
case "$product" in
website) info "Open https://$domain/admin and sign in with the admin email the Hub was given: that account becomes the first Owner." ;;
website|app) info "Open https://$domain/admin and sign in with the admin email the Hub was given: that account becomes the first Owner." ;;
*) info "Open https://$domain/setup to create the admin account." ;;
esac
if [ "$product" = accounts ]; then info "Updates: crosscode deploy $church (Accounts is always updated first)"; else info "Updates: crosscode deploy $church $product"; fi
@@ -252,10 +253,10 @@ add_usage() {
cat <<'EOF'
crosscode add <church> <product> [options]
Adds a product to a church already installed here (Accounts next to Events, the Website next to
Accounts), in
its own folder, database, PM2 processes and site, run by the church's app user. If a step fails,
what this run made is removed again; the church's other products aren't touched.
Adds a product to a church already installed here (Accounts next to Events, the Website or the
App next to Accounts), in its own folder, database, PM2 processes and site, run by the church's
app user. If a step fails, what this run made is removed again; the church's other products
aren't touched.
--domain <domain> where it's served (default: <product>.<the church's address>; the
Website: www.<address>, or the address itself on a Cross Code address)
@@ -298,13 +299,15 @@ cmd_add() {
[ -n "$church" ] && [ -n "$product" ] || { add_usage; die "Name the church and the product."; }
valid_slug "$church" || die "\"$church\" isn't a church name."
is_known_product "$product" || die "Unknown product \"$product\"."
case "$product" in events|accounts|website) ;; *) die "This version of crosscode can only add events, accounts and website." ;; esac
case "$product" in events|accounts|website|app) ;; *) die "This version of crosscode can only add events, accounts, website and app." ;; esac
install_check_options "$product" "$ssl" "$email" "$version" "$main" "$frp" "$api" "$web"
require_root
load_church "$church"
! church_has_product "$product" || die "$church already has $product (crosscode status $church)."
# The Website signs in through the church's Accounts and can't be reached without it (WEBSITE-1.0-PLAN §11).
[ "$product" != website ] || church_has_product accounts || die "The Website needs the church's Accounts: add it first (crosscode add $church accounts)."
# The App too: everyone signs in through Accounts, and its licence needs the church's Accounts (APP-1.0-PLAN §12).
[ "$product" != app ] || church_has_product accounts || die "The App needs the church's Accounts: add it first (crosscode add $church accounts)."
local address user="" existing
address="$(cenv ADDRESS)"
[ -n "$domain" ] || [ -n "$address" ] || die "--domain is needed: the church has no address in church.env."
@@ -448,9 +451,10 @@ install_events() {
install_accounts() { install_app accounts Accounts ACCOUNTS_SECRET "$@"; }
install_website() { install_app website Website WEBSITE_SECRET "$@"; }
install_app_product() { install_app app App APP_SECRET "$@"; }
# install_app <product> <title> <generated secret> <church> <user> <domain> <api> <web> <version>
# <main> <ssl> <email> <frp>: Accounts and the Website (and later the App), which share one shape:
# <main> <ssl> <email> <frp>: Accounts, the Website and the App, which share one shape:
# a checkout of crosscode-platform, apps/<product>/{backend,frontend}, ecosystem.config.cjs, and
# one secret generated here that never leaves the server.
install_app() {
+43 -4
View File
@@ -24,6 +24,11 @@ crosscode demo <church> accounts --profile <scenario> [--scenario <scenario>]
people in Accounts (the eight scenarios, as the
Website's profiles); a backup is taken first;
real people and admins stay
crosscode demo <church> app --profile <scenario> [--scenario <scenario>]
a demo scenario's prayer wall, requests,
announcements, devotionals and events in the App
(App 1.0.0, the eight scenarios); a backup is taken
first; real members stay
crosscode demo <church> --scenario <scenario> [--admin-email <email>]
a whole demo scenario on every product the church
has here, Accounts first (then Events, the Website,
@@ -115,6 +120,7 @@ DEMO_SCENARIOS="$WEBSITE_DEMO_PROFILES"
# 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).
# `crosscode demo <church> accounts --profile <scenario>`: a scenario's church and people (cmd_demo_accounts).
# `crosscode demo <church> app --profile <scenario>`: the App's part of a scenario (cmd_demo_app).
# `--scenario <s>` (agent 1.7.0): part of loading that scenario; the profile must be the scenario's.
# `--scenario <s>` with no product and no profile (the Hub's seed-scenario job): the whole scenario
# on every product the church has (cmd_demo_scenario).
@@ -144,8 +150,12 @@ cmd_demo() {
# Every product loads the profile named after the scenario (contracts DEMO_SCENARIOS).
[ "$profile" = "$scenario" ] || die "--scenario $scenario loads the $scenario profile in $product, not $profile."
fi
# Agent 1.7.0 sends the App's demo jobs; the App and its demo come with App 1.0.0.
[ "$product" != app ] || die "The Church App's demo data comes with App 1.0.0 (this crosscode has none yet)."
if [ "$product" = app ]; then
[[ " $DEMO_SCENARIOS " == *" $profile "* ]] || die "--profile: one of $DEMO_SCENARIOS."
[ -z "$email" ] || die "--admin-email: the App's demo keeps every real member."
cmd_demo_app "$church" "$profile"
return
fi
if [ "$product" = accounts ]; then
[[ " $DEMO_SCENARIOS " == *" $profile "* ]] || die "--profile: one of $DEMO_SCENARIOS."
[ -z "$email" ] || die "--admin-email: Accounts' demo keeps every admin."
@@ -221,8 +231,6 @@ cmd_demo_scenario() {
step "Demo scenario $scenario: checking ${todo[*]}"
[ "${#skipped[@]}" -eq 0 ] || info "Not installed, so skipped: ${skipped[*]}"
for p in "${todo[@]}"; do
# The App and its demo come with App 1.0.0 (scripts/products/app.sh).
[ "$p" != app ] || die "The Church App's demo data comes with App 1.0.0 (this crosscode has none yet). Nothing was changed."
# shellcheck source=/dev/null
source "$CROSSCODE_HOME/products/$p.sh"
v="$("${p}_expected_version" "$(pvar "$p" DIR)" 2>/dev/null || true)"
@@ -239,6 +247,7 @@ cmd_demo_scenario() {
accounts) cmd_demo_accounts "$church" "$scenario" ;;
events) cmd_demo_events "$church" "$scenario" "$email" ;;
website) cmd_demo_website "$church" "$scenario" "$scenario" ;;
app) cmd_demo_app "$church" "$scenario" ;;
esac
); then
seen=0
@@ -283,6 +292,36 @@ cmd_demo_accounts() {
die "Accounts didn't answer after the reload (sudo -u $user pm2 logs)."
}
# The App's demo (App 1.0.0+, backend/scripts/demo.ts, APP-1.0-PLAN §12): a scenario's prayer wall,
# requests, announcements, devotionals and events around the scenario's people (Accounts has them
# by now), replacing the App's content and its demo members; real members stay. Every App profile is
# a scenario, so it always loads as one. Backup first; then reloaded.
cmd_demo_app() {
local church="$1" profile="$2" dir user app
require_root
load_church "$church"
church_has_product app || die "$church has no Church App."
# shellcheck source=/dev/null
source "$CROSSCODE_HOME/products/app.sh"
dir="$(pvar app DIR)"
user="$(pvar app USER)"
app="$(app_app "$dir")"
[ -f "$app/backend/scripts/demo.ts" ] || die "This release of the App ($(checkout_ref "$dir" app)) has no demo (1.0.0 or later has)."
step "App: backup first"
app_backup "$dir" "$user" || die "The backup failed, so the demo wasn't loaded."
step "App: demo scenario ($profile)"
run_as "$user" "$app/backend" npm run --silent demo -- --profile "$profile" --scenario "$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 data from before."
step "App: reloading PM2"
app_reload "$dir" "$user"
step "App: waiting for it to answer"
wait_for_version "$(app_health_url)" "$(app_expected_version "$dir")" 60 ||
die "The App 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.