Add a `seed-demo` subcommand (cmd/seed_demo.go + internal/demoseed/) that inserts a fixed reference catalog into the member-console DB so the operator panel has rows to walk through for UX research. Catalog: 6 demo-* products (4 by product_type + 2 extra plans), 1 plan ladder with 3 tiers, 1 entitlement set with 2 rules (limit + boolean), and 1 grant on Alice's personal org (once she's logged in). Person rows for bob/carlos/diana are seeded via provisioning.AutoProvision keyed on the pinned Keycloak UUIDs — no longer fragile now that seed-keycloak.sh's partialImport switch preserves the pinned id. Alice is intentionally NOT pre-seeded so the lazy-creation OIDC flow stays exercised on every fresh stack. Idempotency: list+filter by `name` for catalog rows, by `oidc_subject` for persons. Re-running is a no-op for created rows; warns + skips the grant if alice hasn't logged in yet. Host-side invocation only — run `./test/seed-demo.sh` after bootstrap-stack.sh. Mirrors how member-console itself runs on the host (config + secrets live under test/). Two OpenSpec changes folded in: 2026-05-10-member-console-demo-seeder (the seeder) and 2026-05-11-demo-seeder-persons (the persons follow-up unlocked by the Keycloak fix).
36 lines
1.1 KiB
Bash
Executable File
36 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# test/seed-demo.sh — host-side invocation of the member-console demo seeder.
|
|
#
|
|
# Loads the worktree-isolated env (DB port, DSN) from test/.env and runs
|
|
# `go run . seed-demo --config test/mc-config.yaml` from the repo root.
|
|
#
|
|
# Opt-in only: the default bootstrap-stack.sh + docker compose up workflow
|
|
# does NOT invoke this. Use it before walking the operator UI for M7-7a.
|
|
#
|
|
# Idempotent — re-running is a no-op once the catalog is seeded.
|
|
# Person rows for bob/carlos/diana are NOT seeded (Keycloak does not honor
|
|
# pinned `sub` IDs); log in once as each demo user to populate them via the
|
|
# existing OIDC lazy-creation path.
|
|
#
|
|
# See openspec/changes/2026-05-10-member-console-demo-seeder/ for design.
|
|
|
|
set -euo pipefail
|
|
|
|
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
repo_root="$(cd "$here/.." && pwd)"
|
|
|
|
env_file="$here/.env"
|
|
if [[ ! -f "$env_file" ]]; then
|
|
echo "error: $env_file not found. Run ./bootstrap-stack.sh first." >&2
|
|
exit 1
|
|
fi
|
|
|
|
set -a
|
|
# shellcheck source=/dev/null
|
|
source "$env_file"
|
|
set +a
|
|
|
|
cd "$repo_root"
|
|
exec go run . seed-demo --config test/mc-config.yaml
|