Something went wrong. Try again.
perform your own verifications verifier.psingletary.com/verifier
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142#!/usr/bin/env bash# sync-theme.sh — pull a theme from the web_themes repo into this consumer.## Usage:# bash scripts/sync-theme.sh [theme-name]## Environment overrides:# WEB_THEMES_REPO git URL of the web_themes repo (default: Tangled handle URL)# THEME_DEST destination dir relative to repo root (default: src/styles/theme)## Strategy (build-time pull): shallow-clone the themes repo into a per-user# cache (~/.cache/web_themes), then copy the requested theme's files into the# consumer's src tree. Consumers wire this as a prebuild step:## "build": "npm run sync:theme && react-scripts build"## Requires SSH access to Tangled at build time (Apple Keychain on this Mac).
set -euo pipefail
THEME_NAME="${1:-witchsky-cyan}"REPO="${WEB_THEMES_REPO:-git@tangled.org:psingletary.com/web_themes}"DEST="${THEME_DEST:-src/styles/theme}"CACHE_DIR="${HOME}/.cache/web_themes"
if [ -d "${CACHE_DIR}/.git" ]; then # Cache must track the requested repo even if it was cloned from # a different URL before (e.g. a local path during testing). if [ "$(git -C "${CACHE_DIR}" config --get remote.origin.url)" != "${REPO}" ]; then git -C "${CACHE_DIR}" remote set-url origin "${REPO}" fi git -C "${CACHE_DIR}" fetch --quiet --depth 1 origin main git -C "${CACHE_DIR}" reset --quiet --hard origin/mainelse git clone --quiet --depth 1 --branch main "${REPO}" "${CACHE_DIR}"fi
mkdir -p "${DEST}"cp "${CACHE_DIR}/themes/${THEME_NAME}/theme.css" "${DEST}/theme.css"cp "${CACHE_DIR}/themes/${THEME_NAME}/index.css" "${DEST}/index.css"echo "synced web_themes/${THEME_NAME} -> ${DEST}/"