Skip to content

Commit 1785a32

Browse files
authored
Added fetch/sum of jsDelivr hits for GitHub repos
1 parent 69e0d95 commit 1785a32

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

.github/workflows/update-root-stats-daily.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ jobs:
2121
run: |
2222
LC_NUMERIC=en_US # to insert commas
2323
npm_pkgs=("@adamlui/geolocate" "@adamlui/minify.js" "@adamlui/scss-to-css" "generate-ip" "generate-pw" "gulp-minify.js")
24-
jsd_pkgs=("@adamlui/geolocate" "generate-ip" "generate-pw")
24+
jsd_npm_pkgs=("@adamlui/geolocate" "generate-ip" "generate-pw")
25+
jsd_gh_repos=("adamlui/js-utils" "adamlui/minify.js" "adamlui/scss-to-css")
2526
2627
expand_num() { # expand nums abbreviated w/ 'k' or 'm' suffix to integers
2728
local num=$(echo "$1" | tr '[:upper:]' '[:lower:]') # convert to lowercase
@@ -59,22 +60,31 @@ jobs:
5960
echo "$formatted_num"
6061
}
6162
62-
# Fetch/sum download counts
63+
# Fetch/sum npm download counts
6364
for pkg in "${npm_pkgs[@]}" ; do
6465
pkg_downloads=$(curl -s "https://img.shields.io/npm/dm/$pkg.svg" |
6566
sed -n 's/.*<title>downloads: \([0-9,.km]\+\).*<\/title>.*/\1/Ip')
6667
pkg_downloads=$(expand_num "$pkg_downloads")
67-
echo "$pkg downloads: $pkg_downloads"
68+
echo "$pkg npm downloads: $pkg_downloads"
6869
total_downloads=$((total_downloads + pkg_downloads))
6970
done ; echo -e "\nTotal npm downloads: $total_downloads\n"
7071
71-
# Fetch/sum jsDelivr hits
72-
for pkg in "${jsd_pkgs[@]}" ; do
72+
# Fetch/sum jsDelivr hits for npm pkgs
73+
for pkg in "${jsd_npm_pkgs[@]}" ; do
7374
pkg_hits=$(curl -s "https://img.shields.io/jsdelivr/npm/hm/$pkg.svg" |
7475
sed -n -E 's|.*<title>jsdelivr: ([0-9,.km]+).*</title>.*|\1|Ip')
7576
pkg_hits=$(expand_num "$pkg_hits")
76-
echo "$pkg jsDelivr hits: $pkg_hits"
77+
echo "$pkg npm jsDelivr hits: $pkg_hits"
7778
total_hits=$((total_hits + pkg_hits))
79+
done
80+
81+
# Fetch/sum jsDelivr hits for GH repos
82+
for repo in "${jsd_gh_repos[@]}" ; do
83+
repo_hits=$(curl -s "https://img.shields.io/jsdelivr/gh/hm/$repo.svg" |
84+
sed -n -E 's|.*<title>jsdelivr: ([0-9,.km]+).*</title>.*|\1|Ip')
85+
repo_hits=$(expand_num "$repo_hits")
86+
echo "$repo GH jsDelivr hits: $repo_hits"
87+
total_hits=$((total_hits + repo_hits))
7888
done ; echo -e "\nTotal jsDelivr hits: $total_hits\n"
7989
8090
# Format totals

0 commit comments

Comments
 (0)