-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync-docs
More file actions
executable file
·69 lines (58 loc) · 1.94 KB
/
sync-docs
File metadata and controls
executable file
·69 lines (58 loc) · 1.94 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env bash
# sync-docs — auto-update README.md and install.sh from actual tools in the repo
# Usage: sync-docs [--dry-run]
set -uo pipefail
REPO="${REPO:-$HOME/.openclaw/workspace/teebot-tools}"
DRY_RUN=0
[[ "${1:-}" == "--dry-run" ]] && DRY_RUN=1
cd "$REPO"
# Discover all tool scripts (executable files, not install.sh/sync-docs/README etc)
TOOLS=()
for f in *; do
[[ -x "$f" && -f "$f" && "$f" != "install.sh" && "$f" != "sync-docs" && ! "$f" =~ \. ]] && TOOLS+=("$f")
done
COUNT=${#TOOLS[@]}
TOOL_LIST=$(printf '%s ' "${TOOLS[@]}")
echo "📦 sync-docs — found $COUNT tools"
echo " ${TOOL_LIST}"
if ((DRY_RUN)); then
echo ""
echo " (dry run — checking what needs updating)"
fi
# Check install.sh
CURRENT_INSTALL=$(grep '^TOOLS=' install.sh 2>/dev/null | sed 's/TOOLS="//' | sed 's/"//')
EXPECTED_INSTALL="${TOOL_LIST% }"
INSTALL_CHANGED=0
if [[ "$CURRENT_INSTALL" != "$EXPECTED_INSTALL" ]]; then
INSTALL_CHANGED=1
echo ""
echo "⚠️ install.sh TOOLS list out of date"
echo " Current: $CURRENT_INSTALL"
echo " Expected: $EXPECTED_INSTALL"
if ((! DRY_RUN)); then
sed -i "s|^TOOLS=\".*\"|TOOLS=\"$EXPECTED_INSTALL\"|" install.sh
echo " ✓ Updated install.sh"
fi
fi
# Check README table
README_CHANGED=0
for tool in "${TOOLS[@]}"; do
if ! grep -q "**$tool**" README.md 2>/dev/null; then
README_CHANGED=1
echo ""
echo "⚠️ $tool missing from README.md"
# Extract description from tool's --help or header comment
desc=$(sed -n '2s/^# //p' "$tool" 2>/dev/null || echo "")
[[ -z "$desc" ]] && desc="(no description)"
echo " Description: $desc"
if ((! DRY_RUN)); then
# Append to table before the closing empty line
sed -i "/^$/i | **$tool** | ${desc} |" README.md 2>/dev/null || true
echo " ✓ Added to README.md (may need manual formatting)"
fi
fi
done
if ((INSTALL_CHANGED == 0 && README_CHANGED == 0)); then
echo ""
echo "✓ Everything in sync!"
fi