Repository navigation
Expand file tree
/
Copy pathsetup-plugins.sh
More file actions
executable file
·70 lines (61 loc) · 1.92 KB
/
Copy pathsetup-plugins.sh
File metadata and controls
executable file
·70 lines (61 loc) · 1.92 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
70
#!/bin/bash
# Clone every editor plugin listed in plugins.json into ./<path> as a sibling
# of this monorepo, unless it's already there. Idempotent — re-run any time.
#
# Usage:
# ./setup-plugins.sh # clone any missing plugin
# ./setup-plugins.sh --pull # also `git pull` plugins that exist
#
# The plugin dirs are gitignored in this monorepo (each is its own repo), so
# the orchestrator + bootstrap together replace what a submodule setup would
# do — without the submodule ergonomics tax.
set -euo pipefail
MONOREPO=$(cd "$(dirname "$0")" && pwd)
REGISTRY="$MONOREPO/plugins.json"
if [[ ! -f "$REGISTRY" ]]; then
echo "Error: $REGISTRY not found."
exit 1
fi
PULL=0
case "${1:-}" in
"") ;;
--pull) PULL=1 ;;
*) echo "Usage: $0 [--pull]"; exit 1 ;;
esac
# Each line: "<path>\t<repo>"
REGISTRY_LINES=$(node -e "
const reg = require('$REGISTRY');
for (const p of reg.plugins) {
if (!p.repo) {
console.error('skip ' + p.path + ': no repo URL in plugins.json');
continue;
}
console.log(p.path + '\t' + p.repo);
}
")
CLONED=0
PULLED=0
SKIPPED=0
while IFS=$'\t' read -r PLUGIN_PATH REPO_URL; do
[[ -z "$PLUGIN_PATH" ]] && continue
TARGET="$MONOREPO/$PLUGIN_PATH"
if [[ -d "$TARGET/.git" ]]; then
if [[ "$PULL" -eq 1 ]]; then
echo "→ pulling $PLUGIN_PATH"
( cd "$TARGET" && git pull --ff-only )
PULLED=$((PULLED + 1))
else
echo "✓ $PLUGIN_PATH already cloned"
SKIPPED=$((SKIPPED + 1))
fi
elif [[ -e "$TARGET" ]]; then
echo "WARN: $TARGET exists but is not a git repo — skipping."
SKIPPED=$((SKIPPED + 1))
else
echo "→ cloning $REPO_URL → $PLUGIN_PATH"
git clone "$REPO_URL" "$TARGET"
CLONED=$((CLONED + 1))
fi
done <<< "$REGISTRY_LINES"
echo ""
echo "Cloned: $CLONED Pulled: $PULLED Already present: $SKIPPED"