whynot-design/examples/consumer-fixture/run.sh

39 lines
1.3 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# Exercise the consumer drift loop against this repo's own ir/manifest.json,
# without a real npm install. Non-destructive: the committed adopted.lock is
# copied into a scratch dir; only that copy is mutated.
#
# In a REAL consuming repo you would not pass --manifest at all — the installed
# @whynot/design package supplies its own ir/manifest.json, and the lock lives at
# ./.whynot-design.lock. Here we point at the repo copy so the demo is hermetic.
set -euo pipefail
cd "$(dirname "$0")"
REPO_ROOT="$(cd ../.. && pwd)"
CLI="$REPO_ROOT/bin/whynot-design.mjs"
MANIFEST="$REPO_ROOT/ir/manifest.json"
WORK="$(mktemp -d)"
trap 'rm -rf "$WORK"' EXIT
cp adopted.lock "$WORK/.whynot-design.lock"
LOCK="$WORK/.whynot-design.lock"
echo "### 1. Inspect — what's in this version"
sed -n '1,6p' "$REPO_ROOT/ir/INDEX.md"
echo
echo "### 2. drift — what changed since the adopted (0.2.0) sync-point (expect exit 3)"
set +e
node "$CLI" drift --manifest "$MANIFEST" --lock "$LOCK"
echo "(exit $?)"
set -e
echo
echo "### 3. drift --update — adopt the current version as the new sync-point"
node "$CLI" drift --manifest "$MANIFEST" --lock "$LOCK" --update >/dev/null
echo
echo "### 4. drift again — now in sync (expect exit 0)"
node "$CLI" drift --manifest "$MANIFEST" --lock "$LOCK"
echo "(exit $?)"