peer-kit / deploy / check-dist.sh
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env bash
# The committed dist/ must be exactly what a fresh build of src/ produces —
# a stale dist would ship behavior the sources don't show.
set -euo pipefail
cd "$(dirname "$0")/.."

# a stale in-tree shadow cache can mask clean-clone divergence: a warm
# incremental build assigns Closure property renames from a slightly different
# pool than a cold one (dev/docs/CLJS.md)
rm -rf .shadow-cljs

npm run --silent build >/dev/null
if [ -n "$(git status --porcelain dist)" ]; then
  echo "ABORT: dist/ is stale — commit the rebuilt output first:" >&2
  git status --porcelain dist >&2
  exit 1
fi

# macOS home-dir prefix, built from pieces: the published bytes of this
# script must never contain the pattern the idpat leak scan hunts for
LEAKPAT='/Use''rs/'
if grep -rF "$LEAKPAT" dist; then
  echo "ABORT: local filesystem path embedded in dist/" >&2
  exit 1
fi

# ---- THE TWO-STACK LAW (the suite's house rule 11) --------------------------
# peer-kit is the libp2p v3 / node-datachannel 0.33 side. rooms-kit is libp2p
# v2 / @ipshipyard/node-datachannel 0.26. The two load different builds of
# libdatachannel, and two copies of that native library in ONE process abort it
# (ThreadSafeCallback cancellation). npm deps stay external imports here, so
# the emitted bundles name every stack they pull — grep them.
for bad in "ardegazu-rooms-kit" "@ipshipyard/node-datachannel"; do
  if grep -rF "$bad" dist; then
    echo "ABORT: dist/ imports '$bad' — that is the OTHER WebRTC stack (rule 11)" >&2
    exit 1
  fi
done
# libp2p v2's helper packages carry distinct names from the v3 family we use;
# any of them in the emitted bundles means a v2 dependency slipped in
for bad in "@libp2p/kad-dht" "@chainsafe/libp2p-gossipsub" "libp2p/index.js"; do
  if grep -rF "$bad" dist; then
    echo "ABORT: dist/ names '$bad' — a libp2p v2-era specifier (rule 11)" >&2
    exit 1
  fi
done
echo "two-stack gate: OK (no rooms-kit / @ipshipyard / libp2p-v2 specifiers in dist)"

echo "check-dist: OK (committed dist matches a cold build, no local paths)"

static mirror of HEAD · about · clone: git clone https://git.ardegazu.ro/peer-kit.git