Files
soleprint/ctrl/ui.sh

46 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Slices: the part of spr's UI one consumer uses, generated as readable source.
#
# Usage:
# ./ctrl/ui.sh list # what can be sliced, and what each piece pulls in
# ./ctrl/ui.sh scan APP_DIR... # what an app uses; its framework copy against spr
# ./ctrl/ui.sh slice FILE [--only N] [--list] [--force]
# ./ctrl/ui.sh check FILE [--only N] # writes nothing; exit 1 if anything is stale
# ./ctrl/ui.sh reference [--check|--spots|--scaffold] # the ui-reference page of /docs, from common/ui/src
# ./ctrl/ui.sh selftest
#
# FILE is a run file (see soleprint/common/slice/ui.example.toml). It lives beside
# the consumer it describes, never in spr, and is named relative to where you
# stand — resolved here before the cd below would change what it means.
#
# `delivery = "dependency"` is for own projects: spr's names stay and a .spr stamp
# says where the copy came from. `delivery = "vendored"` renames through a mapping
# profile, drops the headers, writes no stamp, scrubs every spr word, and will
# not run without an explicit `notice`.
#
# This is not ./ctrl/theme.sh: that bakes parts into single pages inside spr.
# This writes a slice into a consumer, and checks it for drift both ways.
set -e
CALLER_DIR="$PWD"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(dirname "$SCRIPT_DIR")"
PYTHON="${PYTHON:-python3}"
# The first word is the command, never a path — `docs` is also a directory at the
# repo root, and resolving it turned the command into /…/docs.
args=("${1:-}")
shift || true
for a in "$@"; do
# A bare word that names an existing path is a path the caller typed.
if [[ "$a" != -* && -e "$CALLER_DIR/$a" ]]; then
args+=("$(cd "$CALLER_DIR" && realpath -m -- "$a")")
else
args+=("$a")
fi
done
cd "$ROOT_DIR/soleprint"
exec "$PYTHON" -m common.slice "${args[@]}"