Scripts & Tooling
Operational scripts for TeeTime located in tools/scripts/teetime/. These scripts handle data seeding, diagnostics, geocoding, MCA integration audits, and E2E testing.
Quick reference
| Category | Scripts | Purpose |
|---|---|---|
| Auth/Env | run-with-infisical.sh, get-db-urls.sh | Inject secrets, get DB connection strings |
| Import/Seed | import-clubs.mjs, seed-associations.mjs, backfill-user-identities.mjs | Seed clubs, courses, players, associations |
| Geo | geocode-all.mjs, backfill-geo-from-mca.mjs | Geocode clubs/courses, backfill coordinates |
| MCA | audit-mca-collisions.mjs, fix-mca-collisions.mjs | Audit and fix MCA ID collisions |
| E2E | test-multi-club-stream-e2e.mjs, test-tee-times-e2e.mjs | SSE streaming, tee-time API smoke tests |
| Diagnostics | assess-golfrsa-coverage.mjs, assess-teetime-users.mjs | Coverage reports and user audits |
Running scripts
Most scripts are Node ESM and can be run with:
pnpm exec node tools/scripts/teetime/<script>.mjs [flags]
Scripts requiring database access or secrets use the Infisical wrapper:
INFISICAL_ENV=prod tools/scripts/teetime/auth/run-with-infisical.sh \
node tools/scripts/teetime/<script>.mjs
Geo/MCA scripts that need database tunnels use:
tools/scripts/teetime/geo/run-geo-with-tunnel.sh geocode-all.mjs --dry-run
Auth & Environment Helpers
auth/run-with-infisical.sh
Injects Infisical secrets into the environment before running a command.
INFISICAL_ENV=dev tools/scripts/teetime/auth/run-with-infisical.sh \
node tools/scripts/teetime/import-seed/import-clubs.mjs
auth/get-db-urls.sh
Prints database URLs for tunnels or client connections. Useful when setting up local development against remote databases.
auth/validate-golfrsa-credentials.mjs
Sanity-check GolfRSA API credentials to verify they're valid before running imports.
Import & Seeding Scripts
import-seed/backfill-user-identities.mjs
Links IDP users (Auth0/etc) to TeeTime players by creating UserIdentity mappings.
TEETIME_DATABASE_URL=postgres://... \
node tools/scripts/teetime/import-seed/backfill-user-identities.mjs \
--file identities.csv \
--provider auth0 \
[--create] \
[--dry-run]
Input formats:
- CSV with headers:
subject,email,givenName,familyName,preferredName - NDJSON (one JSON per line)
Behavior:
- Check if
(provider, subject)already exists → skip - Find player by email → link identity
- If
--createflag set → create player and link - Otherwise → report as unresolved
import-seed/seed-associations.mjs
Seeds core golf associations (GolfRSA, DotGolf, England Golf, Golf Ireland) required for benefits validation.
node tools/scripts/teetime/import-seed/seed-associations.mjs --dry-run # Preview
node tools/scripts/teetime/import-seed/seed-associations.mjs --apply # Create records
node tools/scripts/teetime/import-seed/seed-associations.mjs --query-mca --apply # Query MCA for IDs
import-seed/import-clubs.mjs / import-courses.mjs
Import club and course data from CSV or external sources.
import-seed/import-mca-players.mjs
Import player data from MCA databases.
import-seed/import-idp-users.mjs
Bulk import users from IDP exports.