Elffuss BraidHub

kikocis/awesome-cli-apps public

master · 1.1 KiB · executableRawPermalink
1#! /bin/bash
2
3J=6
4OUT_FILE=deprecated.txt
5
6if [ "$1" = "--help" ] || [ "$1" = "-h" ] || [ "$1" = "help" ]; then
7 cat <<EOF
8$ check-for-deprecation.sh
9Check all github apps in the readme for deprecation.
10Running $J processes in parallel.
11
12Found deprecated repos are written to: $OUT_FILE
13EOF
14 exit
15fi
16
17check_if_archived_on_github() {
18 APPS=$(grep -e "- \[.\+\]\(.\+\)\s" readme.md | grep 'github.com' | awk -F "(" '{ print $2 }' | cut -d ")" -f1)
19
20 check_deprecation() {
21 REPO="$1"
22 if nice curl -SsL "$REPO" | grep "This repository has been archived by the owner on" >/dev/null; then
23 echo "DEPRECATED $REPO" | tee -a $OUT_FILE
24 else
25 echo "CHECKED $REPO"
26 fi
27 }
28
29 # parallel exec: https://unix.stackexchange.com/a/216475
30 for app in $(echo $APPS); do
31 ((i=i%J)); ((i++==0)) && wait
32 check_deprecation "$app" &
33 done
34}
35
36check_if_link_is_dead() {
37 command -v deadlink >/dev/null || { echo "deadlink is not installed" 1>&2; exit 127; }
38
39 tmp=$(mktemp)
40 grep -Po "http[^)]+" readme.md | grep -v "https://github.com" >$tmp
41 deadlink check $tmp
42}
43
44check_if_archived_on_github
45check_if_link_is_dead