Q&D cmd-line to show dependency graphs for `brew outdated`
```
brew outdated -q | while read searchRoot; do
echo 'checking for '$searchRoot'...'
searchIterations=10
outFile=/tmp/$(date +%Y%m%d-%H%M%S)_brew_${searchRoot}.gv
fullGraph=$(brew deps --installed --dot --graph --include-requirements --for-each --annotate)
nodeList="$searchRoot"
for i in $(seq 1 $searchIterations); do
nodeListNew=''
newNodes=$(echo "$fullGraph" | egrep " -> \"($nodeList)" | cut -d\" -f2,4 -s | tr '"' '\n' | sort | uniq | tr '\n' "|" | sed 's/|$//')
if [ -n "$newNodes" ]
then
nodeListNew=$(echo "$nodeList"$'\n'"$newNodes" | tr '|' '\n' | egrep -v '^$' | sort | uniq | tr '\n' "|" | sed 's/|$//')
else
break
fi
if [ "$nodeListNew" = "$nodeList" ]
then
break
fi
nodeList=$nodeListNew
done
potOut=$(echo "$fullGraph" | egrep "$nodeList" | sort | uniq)
echo 'digraph {'"$potOut"'}' > "$outFile"
dot -O -Tpdf "$outFile"
open "$outFile".pdf
done
```
Code tested on macOS 14.4, with the following extras: brew
, graphviz
(containing dot
)