From c442fe0d42cc02c17f8ff77b60bd4df39079eefc Mon Sep 17 00:00:00 2001 From: Joshua Oosthuizen Date: Thu, 12 Nov 2026 19:17:06 +0200 Subject: [PATCH] =?UTF-8?q?crosscode=20script:=20deploy,=20status,=20insta?= =?UTF-8?q?ll,=20adopt=20(Events=202.2.0,=20plan=20=C2=A74-5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit One script for installing, updating and moving church installs, replacing hope-events' scripts/deploy.sh and install.sh: - deploy [events] / --every-church, with --version, --main, --check and --allow-local-changes: checks every product first (files changed by hand, Node, release requirements from WHATS-NEW.md headings), then each product in order with backup, checkout, install, migrate, build, PM2 reload and a /health version check; a failure rolls that product back and stops. - status []: checked-out and latest release, /health, and the old folder kept after adopt. - install --products events --domain
: a new church under /var/www/sites/, writing church.env. - adopt --events-dir builds the monorepo checkout next to the running install and switches PM2 over; adopt --undo goes back to it. Product hooks live in scripts/products/events.sh. shellcheck (lint:scripts) and 47 bats tests (test:scripts) are part of npm run check. Co-Authored-By: Claude Opus 5.5 --- docs/EVENTS-2.2-PLAN.md | 26 + docs/HANDOVER.md | 2 +- package-lock.json | 1061 +++++++++++++++++++++++++++++++++++- package.json | 6 +- scripts/.shellcheckrc | 3 + scripts/crosscode | 77 +++ scripts/lib/adopt.sh | 289 ++++++++++ scripts/lib/common.sh | 328 +++++++++++ scripts/lib/deploy.sh | 293 ++++++++++ scripts/lib/install.sh | 254 +++++++++ scripts/lib/status.sh | 89 +++ scripts/products/events.sh | 79 +++ scripts/tests/adopt.bats | 52 ++ scripts/tests/cli.bats | 87 +++ scripts/tests/common.bats | 261 +++++++++ scripts/tests/deploy.bats | 211 +++++++ 16 files changed, 3111 insertions(+), 7 deletions(-) create mode 100644 scripts/.shellcheckrc create mode 100755 scripts/crosscode create mode 100644 scripts/lib/adopt.sh create mode 100644 scripts/lib/common.sh create mode 100644 scripts/lib/deploy.sh create mode 100644 scripts/lib/install.sh create mode 100644 scripts/lib/status.sh create mode 100644 scripts/products/events.sh create mode 100644 scripts/tests/adopt.bats create mode 100644 scripts/tests/cli.bats create mode 100644 scripts/tests/common.bats create mode 100644 scripts/tests/deploy.bats diff --git a/docs/EVENTS-2.2-PLAN.md b/docs/EVENTS-2.2-PLAN.md index d54efcb..ccea050 100644 --- a/docs/EVENTS-2.2-PLAN.md +++ b/docs/EVENTS-2.2-PLAN.md @@ -181,6 +181,32 @@ Secrets stay in each product's own `.env`, never in `church.env`. | `adopt --undo` | Yes (decision 26): goes back to the old folder and the 2.1.x it ran, within the days the old folder is kept | | `add ` | **Later** (phase 3), when there's a second product to add | +**Built 2026-11-12** (branch `feat/crosscode-script`), as above, with these details settled while +writing it: + +- **Run as root.** `church.env` is root-only (mode 600), so every command needs root; each app's + commands (git, npm, Prisma, PM2) run as its app user through `sudo -u`. +- `church.env` is read as data, never sourced: only `CHURCH`, `PRODUCTS`, `ADDRESS` and + `_*` keys are taken. +- `--allow-local-changes` replaces `ALLOW_LOCAL_CHANGES=1` (the variable still works). `--check` + never passes with changes. +- "Latest" only counts plain `events@x.y.z` tags, so test tags such as `events@2.2.0-test` are + only ever deployed with `--version`. +- `--every-church` stops at the first church that fails (its products roll back as usual), and + names the churches it didn't reach. +- `install`: the app user defaults to `cc-`, PM2 names to `-events-backend` / + `-frontend`, the database to `_events`, and ports to the first free ones from 5000 + (API) and 3000 (web), counting every church's `church.env` and anything listening. +- `adopt` writes `church.env` only once the switch has worked, and refuses to start if nginx + refers to the old folder by path (it gets renamed). It also records `EVENTS_OLD_DIR`, + `EVENTS_OLD_REF` and `EVENTS_ADOPTED_AT` for `--undo` and `status`. +- `adopt --undo` refuses if the new checkout has migrations the old release doesn't have, and + moves `/var/www/sites/` aside to `.undone--