Chore(scripts): Simplification and documentation

This commit is contained in:
2023-05-10 02:07:27 +03:00
parent 3fce0ac4dc
commit e7578e4905
6 changed files with 147 additions and 141 deletions

View File

@@ -4,20 +4,21 @@
# shellcheck source="shared.sh"
source "$HOME/.dotfiles/scripts/shared.sh"
have php && {
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
! have php && msg_err "PHP Not Available, cannot install composer" && exit 0;
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]; then
echo >&2 'ERROR: Invalid installer checksum'
rm composer-setup.php
exit 1
fi
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
php composer-setup.php --quiet
RESULT=$?
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]; then
echo >&2 'ERROR: Invalid installer checksum'
rm composer-setup.php
mv composer.phar ~/.local/bin/composer
exit $RESULT
} || msg_err "PHP Not Available, cannot install composer"
exit 1
fi
php composer-setup.php --quiet
RESULT=$?
rm composer-setup.php
mv composer.phar ~/.local/bin/composer
exit $RESULT

View File

@@ -4,42 +4,42 @@
# shellcheck source="shared.sh"
source "$HOME/.dotfiles/scripts/shared.sh"
have gh && {
extensions=(
# GitHub CLI extension for generating a report on repository dependencies.
andyfeller/gh-dependency-report
# GitHub CLI extension to generate montage from GitHub user avatars
andyfeller/gh-montage
# An opinionated GitHub Cli extension for creating
# changelogs that adhere to the keep a changelog specification.
chelnak/gh-changelog
# Safely deletes local branches with no upstream and no un-pushed commits
davidraviv/gh-clean-branches
# A beautiful CLI dashboard for GitHub 🚀
dlvhdr/gh-dash
# A github-cli extension script to clone all repositories
# in an organization, optionally filtering by topic.
matt-bartel/gh-clone-org
# being an extension to view the overall health of
# an organization's use of actions
rsese/gh-actions-status
)
msg "Starting to install GitHub CLI extensions..."
for ext in "${extensions[@]}"; do
# Trim spaces
ext=${ext// /}
# Skip comments
if [[ ${ext:0:1} == "#" ]]; then continue; fi
msg_run "Installing $ext"
gh extensions install "$ext"
echo ""
done
msg_ok "Done"
}
! have gh \
&& msg_err "gh (GitHub Client) could not be found, please install it first"
&& msg_err "gh (GitHub Client) could not be found, please install it first" \
&& exit 0;
extensions=(
# GitHub CLI extension for generating a report on repository dependencies.
andyfeller/gh-dependency-report
# GitHub CLI extension to generate montage from GitHub user avatars
andyfeller/gh-montage
# An opinionated GitHub Cli extension for creating
# changelogs that adhere to the keep a changelog specification.
chelnak/gh-changelog
# Safely deletes local branches with no upstream and no un-pushed commits
davidraviv/gh-clean-branches
# A beautiful CLI dashboard for GitHub 🚀
dlvhdr/gh-dash
# A github-cli extension script to clone all repositories
# in an organization, optionally filtering by topic.
matt-bartel/gh-clone-org
# being an extension to view the overall health of
# an organization's use of actions
rsese/gh-actions-status
)
msg "Starting to install GitHub CLI extensions..."
for ext in "${extensions[@]}"; do
# Trim spaces
ext=${ext// /}
# Skip comments
if [[ ${ext:0:1} == "#" ]]; then continue; fi
msg_run "Installing $ext"
gh extensions install "$ext"
echo ""
done
msg_ok "Done"

View File

@@ -4,38 +4,37 @@
# shellcheck source=shared.sh
source "$HOME/.dotfiles/scripts/shared.sh"
have go && {
packages=(
# sysadmin/scripting utilities, distributed as a single binary
github.com/skx/sysbox@latest
# Git Profile allows you to switch between user profiles in git repos
github.com/dotzero/git-profile@latest
# An extensible command line tool or library to format yaml files.
github.com/google/yamlfmt/cmd/yamlfmt@latest
# Parsing HTML at the command line
github.com/ericchiang/pup@latest
# HTML to Markdown converter
github.com/suntong/html2md@latest
# cheat allows you to create and view interactive cheatsheets on the cli.
github.com/cheat/cheat/cmd/cheat@latest
# Render markdown on the CLI, with pizzazz! 💅
github.com/charmbracelet/glow@latest
# Static checker for GitHub Actions workflow files
github.com/rhysd/actionlint/cmd/actionlint@latest
)
! have go && msg "go hasn't been installed yet." && exit 0;
for pkg in "${packages[@]}"; do
# Trim spaces
pkg=${pkg// /}
# Skip comments
if [[ ${pkg:0:1} == "#" ]]; then continue; fi
packages=(
# sysadmin/scripting utilities, distributed as a single binary
github.com/skx/sysbox@latest
# Git Profile allows you to switch between user profiles in git repos
github.com/dotzero/git-profile@latest
# An extensible command line tool or library to format yaml files.
github.com/google/yamlfmt/cmd/yamlfmt@latest
# Parsing HTML at the command line
github.com/ericchiang/pup@latest
# HTML to Markdown converter
github.com/suntong/html2md@latest
# cheat allows you to create and view interactive cheatsheets on the cli.
github.com/cheat/cheat/cmd/cheat@latest
# Render markdown on the CLI, with pizzazz! 💅
github.com/charmbracelet/glow@latest
# Static checker for GitHub Actions workflow files
github.com/rhysd/actionlint/cmd/actionlint@latest
)
msg_run "Installing go package:" "$pkg"
go install "$pkg"
echo ""
done
for pkg in "${packages[@]}"; do
# Trim spaces
pkg=${pkg// /}
# Skip comments
if [[ ${pkg:0:1} == "#" ]]; then continue; fi
msg_ok "Done"
}
msg_run "Installing go package:" "$pkg"
go install "$pkg"
echo ""
done
msg_ok "Done"
! have go && msg "go hasn't been installed yet."

View File

@@ -4,42 +4,41 @@
# shellcheck source=shared.sh
source "$HOME/.dotfiles/scripts/shared.sh"
have npm && {
packages=(
# This is a tool to check if your files consider your .editorconfig rules.
"editorconfig-checker"
# Node module to create a release or a changelog from
# a tag and uses issues or commits to creating the release notes.
"github-release-notes"
"neovim"
"prettier"
"corepack"
"standardjs"
# CLI and local web plain text notetaking, bookmarking, and archiving
# with linking, tagging, filtering, search, Git versioning & syncing,
# Pandoc conversion, + more, in a single portable script.
"nb.sh"
)
! have npm && msg_err "npm could not be found." && exit 0;
for pkg in "${packages[@]}"; do
# Trim spaces
pkg=${pkg// /}
# Skip comments
if [[ ${pkg:0:1} == "#" ]]; then continue; fi
packages=(
# This is a tool to check if your files consider your .editorconfig rules.
"editorconfig-checker"
# Node module to create a release or a changelog from
# a tag and uses issues or commits to creating the release notes.
"github-release-notes"
"neovim"
"prettier"
"corepack"
"standardjs"
# CLI and local web plain text notetaking, bookmarking, and archiving
# with linking, tagging, filtering, search, Git versioning & syncing,
# Pandoc conversion, + more, in a single portable script.
"nb.sh"
)
if [[ $(npm ls -g -p "$pkg") != "" ]]; then
msg_run_done "$pkg" "already installed"
else
msg_run "Installing npm package:" "$pkg"
npm install -g --no-fund --no-progress --no-timing "$pkg"
fi
for pkg in "${packages[@]}"; do
# Trim spaces
pkg=${pkg// /}
# Skip comments
if [[ ${pkg:0:1} == "#" ]]; then continue; fi
echo ""
done
if [[ $(npm ls -g -p "$pkg") != "" ]]; then
msg_run_done "$pkg" "already installed"
else
msg_run "Installing npm package:" "$pkg"
npm install -g --no-fund --no-progress --no-timing "$pkg"
fi
msg_run "Upgrading all global packages"
npm -g --no-progress --no-timing --no-fund outdated
npm -g --no-timing --no-fund upgrade
}
echo ""
done
msg_run "Upgrading all global packages"
npm -g --no-progress --no-timing --no-fund outdated
npm -g --no-timing --no-fund upgrade
! have npm && msg_err "npm could not be found."

View File

@@ -6,32 +6,31 @@
source "$HOME/.dotfiles/scripts/shared.sh"
set -e
have ntfy && msg "ntfy already installed"
have ntfy && msg "ntfy already installed" && exit 0;
! have ntfy && {
case $(dfm check arch) in
Linux)
NTFY_ARCH="linux_$(arch)"
;;
Darwin)
NTFY_ARCH="macOS_all"
;;
esac
case $(dfm check arch) in
Linux)
NTFY_ARCH="linux_$(arch)"
;;
Darwin)
NTFY_ARCH="macOS_all"
;;
esac
NTFY_VERSION=2.2.0
NTFY_URL="https://github.com/binwiederhier/ntfy"
NTFY_DEST="ntfy_${NTFY_VERSION}_${NTFY_ARCH}"
NTFY_VERSION=2.2.0
NTFY_URL="https://github.com/binwiederhier/ntfy"
NTFY_DEST="ntfy_${NTFY_VERSION}_${NTFY_ARCH}"
curl -L "$NTFY_URL/releases/download/v${NTFY_VERSION}/${NTFY_DEST}.tar.gz" \
> "${NTFY_DEST}.tar.gz"
tar zxvf "${NTFY_DEST}.tar.gz"
cp -a "${NTFY_DEST}/ntfy" ~/.local/bin/ntfy
mkdir -p ~/.config/ntfy
curl -L "$NTFY_URL/releases/download/v${NTFY_VERSION}/${NTFY_DEST}.tar.gz" \
> "${NTFY_DEST}.tar.gz"
tar zxvf "${NTFY_DEST}.tar.gz"
cp -a "${NTFY_DEST}/ntfy" ~/.local/bin/ntfy
mkdir -p ~/.config/ntfy
# copy config only if it does not exist
if [ ! -f "$HOME/.config/ntfy/client.yml" ]; then
cp "${NTFY_DEST}/client/client.yml" ~/.config/ntfy/client.yml
fi
# copy config only if it does not exist
if [ ! -f "$HOME/.config/ntfy/client.yml" ]; then
cp "${NTFY_DEST}/client/client.yml" ~/.config/ntfy/client.yml
fi
rm -rf "${NTFY_DEST}" "${NTFY_DEST}.tar.gz"
rm -rf "${NTFY_DEST}" "${NTFY_DEST}.tar.gz"
}