chore: initial commit

This commit is contained in:
alecodes 2025-02-19 12:01:32 +00:00 committed by aleidk
commit b7452c7996
17 changed files with 592 additions and 0 deletions

View file

View file

@ -0,0 +1,30 @@
#!/usr/bin/env bash
set -euo pipefail
root="$(git rev-parse --show-toplevel)"
export PATH=$root/.devfiles/bin:$root/.devfiles/scripts:$PATH
devtools=(
age
agebox
cog
gitleaks
)
missing_tools=()
for cmd in "${devtools[@]}"; do
if ! command -v "$cmd" &>/dev/null; then
missing_tools+=("$cmd")
fi
done
if [[ ${#missing_tools[@]} != 0 ]]; then
echo "The following tools where not found:"
printf "%s\n" "${missing_tools[@]}"
exit 1
else
echo -e "All tools are installed!"
fi

42
.devfiles/scripts/gitignore.sh Executable file
View file

@ -0,0 +1,42 @@
#!/usr/bin/env bash
set -euo pipefail
root="$(git rev-parse --show-toplevel)"
base_url="https://git.alecodes.page/api/v1/gitignore/templates"
query="$*"
list_available() {
curl -Ssl $base_url | jq -r '.[]'
}
if [[ -z $query ]]; then
list_available
exit 0
fi
tmp_file="$(mktemp)"
for template in $query; do
# Capitalize the string
template=${template,,}
template=${template^}
response="$(curl -Ssl "$base_url/$template")"
name="$(echo "$response" | jq -r '.name')"
content="$(echo "$response" | jq -r '.source')"
if [[ "$content" == "null" ]]; then
echo "Template not found, available options:"
list_available
exit 1
fi
printf "\n### %s\n\n%s\n\n" "$name" "$content" >>"$tmp_file"
done
sed -i -ne "/#### -- TEMPLATES BEGIN -- ####/ {p; r $tmp_file" -e ':a; n; /#### -- TEMPLATES END -- ####/ {p; b}; ba}; p' "$root/.gitignore"
rm "$tmp_file"