Accounts 1.9.0, @crosscode/demo 1.0.0: messaging.get, WhatsApp opt-out, demo scenarios
Accounts 1.9.0 (one migration): - messaging.get (sealed settings) and the messaging.changed hint to products that asked, on admin or product changes - the WhatsApp opt-out for every product: whatsapp.optout, Accounts' own WAWP webhook, WhatsAppOptOut kept per number, whatsapp_opted_out in user.updated, no WhatsApp from Accounts to an opted-out person, "Turn WhatsApp back on" - demo scenarios: npm run demo -- --profile <scenario> --force replaces the church profile (with an SVG logo and icon at /api/demo-assets/) and the demo people, ids kept across loads @crosscode/demo 1.0.0 (new): the eight scenarios' churches, people and logos. crosscode script: crosscode demo <church> accounts, --scenario on every demo, Accounts installs and builds packages/demo. Checked on PostgreSQL 18: migrations, scenario loads, opt-out, npm run demo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+53
-2
@@ -16,6 +16,11 @@ crosscode demo <church> website --profile <profile>
|
||||
bold-plant, community-family, community-town,
|
||||
clean-modern, clean-campus); a backup is taken
|
||||
first; the church's profile, settings and admins stay
|
||||
crosscode demo <church> accounts --profile <scenario> [--scenario <scenario>]
|
||||
a demo scenario's church (profile, logo, icon) and
|
||||
people in Accounts (the eight scenarios, as the
|
||||
Website's profiles); a backup is taken first;
|
||||
real people 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
|
||||
@@ -91,24 +96,41 @@ 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"
|
||||
# The demo scenarios (contracts agent.DEMO_SCENARIO_KEYS, 1.21.0): one per Website profile. Accounts'
|
||||
# profiles are the scenarios themselves.
|
||||
DEMO_SCENARIOS="$WEBSITE_DEMO_PROFILES"
|
||||
|
||||
# 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).
|
||||
# `crosscode demo <church> accounts --profile <scenario>`: a scenario's church and people (cmd_demo_accounts).
|
||||
# `--scenario <s>` (agent 1.7.0): part of loading that scenario; the profile must be the scenario's.
|
||||
cmd_demo() {
|
||||
local church="" product="events" profile="" email="" dir user app
|
||||
local church="" product="events" profile="" email="" scenario="" 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 ;;
|
||||
--scenario) [ $# -ge 2 ] || die "--scenario needs a value."; scenario="$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 ;;
|
||||
events|website|accounts) [ -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 [ -n "$scenario" ]; then
|
||||
[[ " $DEMO_SCENARIOS " == *" $scenario "* ]] || die "--scenario: one of $DEMO_SCENARIOS."
|
||||
# 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
|
||||
if [ "$product" = accounts ]; then
|
||||
[[ " $DEMO_SCENARIOS " == *" $profile "* ]] || die "--profile: one of $DEMO_SCENARIOS."
|
||||
[ -z "$email" ] || die "--admin-email: Accounts' demo keeps every admin."
|
||||
cmd_demo_accounts "$church" "$profile"
|
||||
return
|
||||
fi
|
||||
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."
|
||||
@@ -144,6 +166,35 @@ cmd_demo() {
|
||||
die "Events didn't answer after the reload (sudo -u $user pm2 logs)."
|
||||
}
|
||||
|
||||
# Accounts' part of a demo scenario (Accounts 1.9.0+, backend/scripts/demo.ts): the scenario's
|
||||
# church profile (with its logo and icon) and its people; real people and admins stay. Backup first;
|
||||
# Accounts tells the linked products the church changed. Loaded before the other products'.
|
||||
cmd_demo_accounts() {
|
||||
local church="$1" profile="$2" dir user app
|
||||
require_root
|
||||
load_church "$church"
|
||||
church_has_product accounts || die "$church has no Accounts."
|
||||
# shellcheck source=/dev/null
|
||||
source "$CROSSCODE_HOME/products/accounts.sh"
|
||||
dir="$(pvar accounts DIR)"
|
||||
user="$(pvar accounts USER)"
|
||||
app="$(accounts_app "$dir")"
|
||||
[ -f "$app/backend/scripts/demo.ts" ] || die "This release of Accounts ($(checkout_ref "$dir" accounts)) has no demo scenarios (1.9.0 or later has)."
|
||||
|
||||
step "Accounts: backup first"
|
||||
accounts_backup "$dir" "$user" || die "The backup failed, so the demo wasn't loaded."
|
||||
|
||||
step "Accounts: demo scenario ($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 data from before."
|
||||
|
||||
step "Accounts: reloading PM2"
|
||||
accounts_reload "$dir" "$user"
|
||||
step "Accounts: waiting for it to answer"
|
||||
wait_for_version "$(accounts_health_url)" "$(accounts_expected_version "$dir")" 60 ||
|
||||
die "Accounts 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.
|
||||
|
||||
Reference in New Issue
Block a user