Repository navigation
Expand file tree
/
Copy pathpublish.sh
More file actions
51 lines (47 loc) · 3.12 KB
/
Copy pathpublish.sh
File metadata and controls
51 lines (47 loc) · 3.12 KB
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
50
51
#!/usr/bin/env bash
# © 2026 Roy Borkin. All rights reserved. See LICENSE.
# Publish safely: check this folder for keys and personal data, then copy it into your git clone
# (the public GitHub repo) without the private files, and show `git status`. Nothing is committed or pushed.
# ./publish.sh → copies into ../RoundSpotify (the clone next to this folder)
# ./publish.sh /path/to/clone → another clone
# Your own IPs, network names and IDs: tools/private-patterns.json (copy tools/private-patterns.example.json).
set -euo pipefail
SRC="$(cd "$(dirname "$0")" && pwd)"
DEST="${1:-$SRC/../RoundSpotify}"
command -v node >/dev/null || { echo "node is not installed"; exit 1; }
[ -d "$DEST/.git" ] || { echo "$DEST is not a git clone — give the clone's folder: ./publish.sh /path/to/RoundSpotify"; exit 1; }
DEST="$(cd "$DEST" && pwd)"
[ "$DEST" != "$SRC" ] || { echo "The clone can't be this folder"; exit 1; }
echo "=== 1/3 Checking $SRC for keys and personal data"
node "$SRC/tools/check-public.mjs" "$SRC" || { echo; echo "STOPPED — nothing was copied."; exit 1; }
echo "=== 2/3 Copying into $DEST"
EXCLUDES=(
--exclude=.git/ --exclude=node_modules/ --exclude=/data/ --exclude=/profiles/ --exclude=/cache/
--exclude=/bridge/profiles/ --exclude=/bridge/cache/
--exclude='/games examples/' --exclude='/Rush Hour/' --exclude='/Theme UI Examples/'
--exclude=.rr_md5.txt --exclude=.DS_Store --exclude=/.env --exclude=/tools/private-patterns.json --exclude=/bridge/package-lock.json
--exclude='/bridge/*.p8' --exclude='/bridge/*.tmp' --exclude='/bridge/*.bad'
--include=/bridge/config.example.json --include=/bridge/package.json --exclude='/bridge/*.json'
)
if command -v rsync >/dev/null; then
# --delete mirrors (files deleted here are deleted there too); excluded files are left alone on both sides
rsync -a --delete "${EXCLUDES[@]}" "$SRC/" "$DEST/"
else
echo "(rsync not found: copying with tar, without deleting old files)"
(cd "$SRC" && tar -cf - --exclude=.git --exclude=node_modules --exclude=./data --exclude=./profiles --exclude=./cache \
--exclude=./bridge/profiles --exclude=./bridge/cache --exclude='./games examples' --exclude='./Rush Hour' --exclude='./Theme UI Examples' \
--exclude=.rr_md5.txt --exclude=.DS_Store --exclude=./.env --exclude=./tools/private-patterns.json --exclude=./bridge/package-lock.json \
--exclude='./bridge/*.p8' --exclude='./bridge/*.tmp' --exclude='./bridge/*.bad' \
$(cd "$SRC/bridge" && for f in *.json; do [ "$f" = config.example.json ] || [ "$f" = package.json ] || [ ! -e "$f" ] || printf -- '--exclude=./bridge/%s ' "$f"; done) .) \
| (cd "$DEST" && tar -xf -)
fi
echo "=== 3/3 Checking the copy"
if [ -f "$SRC/tools/private-patterns.json" ]; then
node "$SRC/tools/check-public.mjs" "$DEST" --patterns "$SRC/tools/private-patterns.json" || { echo; echo "The copy has problems — fix them before you commit."; exit 1; }
else
node "$SRC/tools/check-public.mjs" "$DEST" || { echo; echo "The copy has problems — fix them before you commit."; exit 1; }
fi
echo
git -C "$DEST" status --short
echo
echo "Done. Review the changes above, then commit and push from $DEST."