Skip to content

Commit ccb98f9

Browse files
authored
Merge pull request #2 from FvdHMBAI/feat/initial-release
feat: initial release
2 parents e73e5ad + 3e44144 commit ccb98f9

4 files changed

Lines changed: 45 additions & 34 deletions

File tree

bin/graphify-auto-rebuild.sh

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,23 @@ for REPO in "${REPOS[@]}"; do
4747
REPO_NAME=$(basename "$REPO")
4848
REPO=$(cd "$REPO" && pwd)
4949

50-
cd "$REPO" || continue
50+
(
51+
cd "$REPO" || exit 1
5152

52-
MODE="full"
53-
FLAGS=""
54-
if [ -f "graphify-out/graph.json" ]; then
55-
MODE="incremental"
56-
FLAGS="--update"
57-
fi
53+
MODE="full"
54+
FLAGS=""
55+
if [ -f "graphify-out/graph.json" ]; then
56+
MODE="incremental"
57+
FLAGS="--update"
58+
fi
5859

59-
echo "$(date -Iseconds) START: $REPO_NAME ($MODE)" >> "$LOG"
60+
echo "$(date -Iseconds) START: $REPO_NAME ($MODE)" >> "$LOG"
6061

61-
if "$GRAPHIFY" . $FLAGS >> "$LOG" 2>&1; then
62-
SIZE=$(du -sh graphify-out/graph.json 2>/dev/null | cut -f1)
63-
echo "$(date -Iseconds) OK: $REPO_NAME graph.json ($SIZE)" >> "$LOG"
64-
else
65-
echo "$(date -Iseconds) ERROR: $REPO_NAME graphify failed" >> "$LOG"
66-
fi
62+
if "$GRAPHIFY" . $FLAGS >> "$LOG" 2>&1; then
63+
SIZE=$(du -sh graphify-out/graph.json 2>/dev/null | cut -f1)
64+
echo "$(date -Iseconds) OK: $REPO_NAME graph.json ($SIZE)" >> "$LOG"
65+
else
66+
echo "$(date -Iseconds) ERROR: $REPO_NAME graphify failed" >> "$LOG"
67+
fi
68+
)
6769
done

bin/graphify-build.sh

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,17 @@ for REPO in "${REPOS[@]}"; do
3838
REPO_NAME=$(basename "$REPO")
3939
echo "=== Graphify: $REPO_NAME ==="
4040

41-
cd "$REPO" || continue
42-
"$GRAPHIFY" . 2>&1 | tail -5
43-
44-
if [ -f "graphify-out/graph.json" ]; then
45-
SIZE=$(du -sh graphify-out/graph.json | cut -f1)
46-
echo " OK: graph.json ($SIZE)"
47-
else
48-
echo " ERROR: No graph.json generated"
49-
fi
41+
(
42+
cd "$REPO" || exit 1
43+
"$GRAPHIFY" . 2>&1 | tail -5
44+
45+
if [ -f "graphify-out/graph.json" ]; then
46+
SIZE=$(du -sh graphify-out/graph.json | cut -f1)
47+
echo " OK: graph.json ($SIZE)"
48+
else
49+
echo " ERROR: No graph.json generated"
50+
fi
51+
)
5052
echo ""
5153
done
5254

bin/graphify-impact.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55
set -uo pipefail
66

77
DEPTH=2
8-
while [[ $# -gt 1 ]]; do
9-
case "${2:-}" in
10-
--depth) DEPTH="${3:-2}"; shift 2 ;;
11-
*) break ;;
8+
TARGET=""
9+
POSITIONAL=()
10+
while [[ $# -gt 0 ]]; do
11+
case "$1" in
12+
--depth) DEPTH="${2:-2}"; shift 2 ;;
13+
--diff) TARGET="--diff"; shift ;;
14+
*) POSITIONAL+=("$1"); shift ;;
1215
esac
1316
done
17+
set -- "${POSITIONAL[@]+"${POSITIONAL[@]}"}"
1418

1519
resolve_graph() {
1620
local filepath="$1"
@@ -113,7 +117,7 @@ if high_impact:
113117
PYEOF
114118
}
115119

116-
if [ -n "${1:-}" ] && [ "$1" != "--diff" ]; then
120+
if [ -n "${1:-}" ] && [ "$TARGET" != "--diff" ]; then
117121
repo=$(resolve_graph "$1")
118122
if [ $? -ne 0 ]; then
119123
echo "No graphify graph found for $1"

bin/graphify-merge.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,26 @@ if [ ${#REPOS[@]} -eq 0 ]; then
1818
fi
1919
fi
2020

21-
REPO_ARGS=""
21+
VALID_REPOS=()
2222
for REPO in "${REPOS[@]}"; do
23-
[ -f "$REPO/graphify-out/graph.json" ] && REPO_ARGS="$REPO_ARGS $REPO"
23+
[ -f "$REPO/graphify-out/graph.json" ] && VALID_REPOS+=("$REPO")
2424
done
2525

26-
if [ -z "$REPO_ARGS" ]; then
26+
if [ ${#VALID_REPOS[@]} -eq 0 ]; then
2727
echo "No repos with graphify-out/graph.json found"
2828
exit 1
2929
fi
3030

31+
export _MERGE_REPOS
32+
_MERGE_REPOS=$(IFS=':'; echo "${VALID_REPOS[*]}")
33+
3134
python3 << 'PYEOF'
32-
import json, sys, os
35+
import json, os
3336
from pathlib import Path
3437
from collections import defaultdict
3538
36-
repos = sys.argv[1:] if len(sys.argv) > 1 else os.environ.get("GRAPHIFY_REPOS", "").split(":")
37-
repos = [r for r in repos if r and Path(r).joinpath("graphify-out/graph.json").exists()]
39+
repos = [r for r in os.environ.get("_MERGE_REPOS", "").split(":") if r]
40+
repos = [r for r in repos if Path(r).joinpath("graphify-out/graph.json").exists()]
3841
out_dir = os.environ.get("GRAPHIFY_SYSTEM_DIR", "./system-graph")
3942
4043
all_nodes = []

0 commit comments

Comments
 (0)