#!/usr/bin/env bash # Weekly-ish refresh of the car pokedex (/trackers/cars) on stan-vm. # # ssh stan-vm 'cd ~/dev/website-cars && git fetch -q && git checkout -q --detach origin/main \ # && bun install --frozen-lockfile >/dev/null && scripts/cars-refresh.sh' # # 1. bun scripts/cars-import.ts --report-new rebuilds brands/models/variants from RDW + # fueleconomy.gov and notes which brands/models did not exist before. # 2. bun scripts/cars-photos.ts --missing finds Wikimedia Commons photos for models # that have none yet (new ones included). # stdout: one JSON report {generatedAt, totals, newBrands, newModels[] (with photo)}. # Progress goes to stderr. DB_URL is read from the running app container and never printed. set -euo pipefail cd "$(dirname "$0")/.." if [ -z "${DB_URL:-}" ]; then DB_URL=$(sudo docker inspect personal-website-app-1 --format '{{range .Config.Env}}{{println .}}{{end}}' | sed -n 's/^DB_URL=//p' | sed 's/@db:5432/@127.0.0.1:5440/') export DB_URL fi report=$(mktemp /tmp/cars-report.XXXXXX.json) trap 'rm -f "$report"' EXIT bun scripts/cars-import.ts --report-new "$@" >"$report" bun scripts/cars-photos.ts --missing --enrich "$report" --fetch