bin/mkstats
#!/usr/bin/env bash
function getNoServices() {
cat stats/services | sort | uniq | wc -l | xargs
}
function getNoActions() {
cat stats/actions/* | sort | uniq | wc -l | xargs
}
function getNoResourceTypes() {
cat stats/resources/* | sort | uniq | wc -l | xargs
}
function getNoGlobalConditions() {
grep -R --include="*.ts" "public ifAws" lib/shared | wc -l | xargs
}
function getNoServiceConditions() {
cat stats/conditions/* | sort | uniq | wc -l | xargs
}
function getNoConditions() {
global="$(getNoGlobalConditions)"
service="$(getNoServiceConditions)"
echo "$((global + service))"
}
read -r -d '' stats << EOF
Support for:
- $(getNoServices) Services
- $(getNoActions) Actions
- $(getNoResourceTypes) Resource Types
- $(getNoConditions) Condition keys
EOF
perl -0777 -pi -e "s/^(<!-- stats -->)[\s\n\w*-:\d<>]+(<!-- \/stats -->)/\\1\\n${stats}\\n\\2/gm" README.md
perl -0777 -pi -e "s/^(..\\n stats\\n)[\s\n\w*-:\d<>]+(\\n..\\n \/stats)/\\1\\n${stats}\\n\\2/gm" docs/source/index.rst