Skip to content

Commit

Permalink
☁️ chore(automation): Applying changes from upstream repository.
Browse files Browse the repository at this point in the history
  • Loading branch information
Megabyte Labs committed Dec 6, 2022
1 parent d68f54f commit 02f4e2b
Show file tree
Hide file tree
Showing 14 changed files with 674 additions and 529 deletions.
19 changes: 13 additions & 6 deletions .config/husky/commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@
# @brief A git hook script for the `commit-msg` hook
# @arg $1 Path to a temporary file that contains the commit message written by the developer (e.g. .git/COMMIT_EDITMSG)

[ -f .config/log ] && chmod +x .config/log
# @description Register appropriate logging utility
if [ -f "$(dirname "$0")/../.config/log" ]; then
alias logger="$(dirname "$0")/../.config/log"
chmod +x "$(dirname "$0")/../.config/log"
elif command -v logg > /dev/null; then
alias logger='logg'
fi

if [ -f "$(dirname "$0")/_/husky.sh" ]; then
. "$(dirname "$0")/_/husky.sh"

# Attempt to register Bodega/Task from common places if it is not in PATH
# Attempt to register Task from common places if it is not in PATH
if ! type task > /dev/null; then
PATH="$PATH:$HOME/.local/go/bin:$HOME/.local/bin:$HOME/bin:$HOME/go/bin:$HOME/.asdf/shims"
if ! type task > /dev/null; then
Expand All @@ -22,13 +29,13 @@ if [ -f "$(dirname "$0")/_/husky.sh" ]; then
fi
fi

# Show warning if Bodega/Task is still not registered/installed, else proceed with hook
# Show warning if Task is still not registered/installed, else proceed with hook
if ! type task > /dev/null; then
.config/log warn 'Bodega `task` does not appear to be installed or is not registered in the `PATH` variable - please manually include it'
.config/log info 'Get Bodega here -> `https://github.com/megabyte-labs/Bodega`'
logger warn '`task` does not appear to be installed or is not registered in the `PATH` variable - please manually include it'
logger info 'More on Task here -> `https://taskfile.dev`'
else
task git:hook:commit-msg -- "$1"
fi
else
.config/log warn 'Husky pre-commit hooks are currently not properly setup.'
logger warn 'Husky pre-commit hooks are currently not properly setup.'
fi
19 changes: 13 additions & 6 deletions .config/husky/post-checkout
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@
# @arg $2 The ref of the new HEAD
# @arg $3 Equal to 1 if changing branches

[ -f .config/log ] && chmod +x .config/log
# @description Register appropriate logging utility
if [ -f "$(dirname "$0")/../.config/log" ]; then
alias logger="$(dirname "$0")/../.config/log"
chmod +x "$(dirname "$0")/../.config/log"
elif command -v logg > /dev/null; then
alias logger='logg'
fi

if [ -f "$(dirname "$0")/_/husky.sh" ]; then
. "$(dirname "$0")/_/husky.sh"

# Attempt to register Bodega/Task from common places if it is not in PATH
# Attempt to register Task from common places if it is not in PATH
if ! type task > /dev/null; then
PATH="$PATH:$HOME/.local/go/bin:$HOME/.local/bin:$HOME/bin:$HOME/go/bin:$HOME/.asdf/shims"
if ! type task > /dev/null; then
Expand All @@ -24,13 +31,13 @@ if [ -f "$(dirname "$0")/_/husky.sh" ]; then
fi
fi

# Show warning if Bodega/Task is still not registered/installed, else proceed with hook
# Show warning if Task is still not registered/installed, else proceed with hook
if ! type task > /dev/null; then
.config/log warn 'Bodega `task` does not appear to be installed or is not registered in the `PATH` variable - please manually include it'
.config/log info 'Get Bodega here -> `https://github.com/megabyte-labs/Bodega`'
logger warn '`task` does not appear to be installed or is not registered in the `PATH` variable - please manually include it'
logger info 'Get `task` here -> https://taskfile.dev'
else
task git:hook:post-checkout
fi
else
.config/log warn 'Husky pre-commit hooks are currently not properly setup.'
logger warn 'Husky pre-commit hooks are currently not properly setup.'
fi
19 changes: 13 additions & 6 deletions .config/husky/post-commit
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@
# @brief A git hook script for the `post-commit` hook. There are no parameters but you can easily get the
# last commit by running `git log -1 HEAD`. Generally, this script is used for notifications or something similar.

[ -f .config/log ] && chmod +x .config/log
# @description Register appropriate logging utility
if [ -f "$(dirname "$0")/../.config/log" ]; then
alias logger="$(dirname "$0")/../.config/log"
chmod +x "$(dirname "$0")/../.config/log"
elif command -v logg > /dev/null; then
alias logger='logg'
fi

if [ -f "$(dirname "$0")/_/husky.sh" ]; then
. "$(dirname "$0")/_/husky.sh"

# Attempt to register Bodega/Task from common places if it is not in PATH
# Attempt to register Task from common places if it is not in PATH
if ! type task > /dev/null; then
PATH="$PATH:$HOME/.local/go/bin:$HOME/.local/bin:$HOME/bin:$HOME/go/bin:$HOME/.asdf/shims"
if ! type task > /dev/null; then
Expand All @@ -22,13 +29,13 @@ if [ -f "$(dirname "$0")/_/husky.sh" ]; then
fi
fi

# Show warning if Bodega/Task is still not registered/installed, else proceed with hook
# Show warning if Task is still not registered/installed, else proceed with hook
if ! type task > /dev/null; then
.config/log warn 'Bodega `task` does not appear to be installed or is not registered in the `PATH` variable - please manually include it'
.config/log info 'Get Bodega here -> `https://github.com/megabyte-labs/Bodega`'
logger warn '`task` does not appear to be installed or is not registered in the `PATH` variable - please manually include it'
logger info 'Get `task` here -> https://taskfile.dev'
else
task git:hook:post-commit
fi
else
.config/log warn 'Husky pre-commit hooks are currently not properly setup.'
logger warn 'Husky pre-commit hooks are currently not properly setup.'
fi
19 changes: 13 additions & 6 deletions .config/husky/post-merge
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@
# @brief A git hook script for the `post-merge` hook
# @arg $1 A status flag specifying whether or not the merge being done was a squash merge

[ -f .config/log ] && chmod +x .config/log
# @description Register appropriate logging utility
if [ -f "$(dirname "$0")/../.config/log" ]; then
alias logger="$(dirname "$0")/../.config/log"
chmod +x "$(dirname "$0")/../.config/log"
elif command -v logg > /dev/null; then
alias logger='logg'
fi

if [ -f "$(dirname "$0")/_/husky.sh" ]; then
. "$(dirname "$0")/_/husky.sh"

# Attempt to register Bodega/Task from common places if it is not in PATH
# Attempt to register Task from common places if it is not in PATH
if ! type task > /dev/null; then
PATH="$PATH:$HOME/.local/go/bin:$HOME/.local/bin:$HOME/bin:$HOME/go/bin:$HOME/.asdf/shims"
if ! type task > /dev/null; then
Expand All @@ -22,13 +29,13 @@ if [ -f "$(dirname "$0")/_/husky.sh" ]; then
fi
fi

# Show warning if Bodega/Task is still not registered/installed, else proceed with hook
# Show warning if Task is still not registered/installed, else proceed with hook
if ! type task > /dev/null; then
.config/log warn 'Bodega `task` does not appear to be installed or is not registered in the `PATH` variable - please manually include it'
.config/log info 'Get Bodega here -> `https://github.com/megabyte-labs/Bodega`'
logger warn '`task` does not appear to be installed or is not registered in the `PATH` variable - please manually include it'
logger info 'Get `task` here -> https://taskfile.dev'
else
task git:hook:post-merge
fi
else
.config/log warn 'Husky pre-commit hooks are currently not properly setup.'
logger warn 'Husky pre-commit hooks are currently not properly setup.'
fi
19 changes: 13 additions & 6 deletions .config/husky/post-rewrite
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@
# that rewrite commits (e.g. git pull origin master --rebase)
# @arg $1 Denotes the command it was invoked by: currently one of amend or rebase

[ -f .config/log ] && chmod +x .config/log
# @description Register appropriate logging utility
if [ -f "$(dirname "$0")/../.config/log" ]; then
alias logger="$(dirname "$0")/../.config/log"
chmod +x "$(dirname "$0")/../.config/log"
elif command -v logg > /dev/null; then
alias logger='logg'
fi

if [ -f "$(dirname "$0")/_/husky.sh" ]; then
. "$(dirname "$0")/_/husky.sh"

# Attempt to register Bodega/Task from common places if it is not in PATH
# Attempt to register Task from common places if it is not in PATH
if ! type task > /dev/null; then
PATH="$PATH:$HOME/.local/go/bin:$HOME/.local/bin:$HOME/bin:$HOME/go/bin:$HOME/.asdf/shims"
if ! type task > /dev/null; then
Expand All @@ -23,13 +30,13 @@ if [ -f "$(dirname "$0")/_/husky.sh" ]; then
fi
fi

# Show warning if Bodega/Task is still not registered/installed, else proceed with hook
# Show warning if Task is still not registered/installed, else proceed with hook
if ! type task > /dev/null; then
.config/log warn 'Bodega `task` does not appear to be installed or is not registered in the `PATH` variable - please manually include it'
.config/log info 'Get Bodega here -> `https://github.com/megabyte-labs/Bodega`'
logger warn '`task` does not appear to be installed or is not registered in the `PATH` variable - please manually include it'
logger info 'Get `task` here -> https://taskfile.dev'
else
task git:hook:post-rewrite
fi
else
.config/log warn 'Husky pre-commit hooks are currently not properly setup.'
logger warn 'Husky pre-commit hooks are currently not properly setup.'
fi
28 changes: 17 additions & 11 deletions .config/husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@
# @file .config/husky/pre-commit
# @brief A git hook script for the `pre-commit` hook

[ -f .config/log ] && chmod +x .config/log
# @description Register appropriate logging utility
if [ -f "$(dirname "$0")/../.config/log" ]; then
alias logger="$(dirname "$0")/../.config/log"
chmod +x "$(dirname "$0")/../.config/log"
elif command -v logg > /dev/null; then
alias logger='logg'
fi

if [ -f "$(dirname "$0")/_/husky.sh" ]; then
. "$(dirname "$0")/_/husky.sh"

# Attempt to register Bodega/Task from common places if it is not in PATH
# Attempt to register Task from common places if it is not in PATH
if ! type task > /dev/null; then
PATH="$PATH:$HOME/.local/go/bin:$HOME/.local/bin:$HOME/bin:$HOME/go/bin:$HOME/.asdf/shims"
if ! type task > /dev/null; then
Expand All @@ -21,13 +28,12 @@ if [ -f "$(dirname "$0")/_/husky.sh" ]; then
fi
fi

# Show warning if Bodega/Task is still not registered/installed, else proceed with hook
# Show warning if Task is still not registered/installed, else proceed with hook
if ! type task > /dev/null; then
.config/log warn 'Bodega `task` does not appear to be installed or is not registered in the `PATH` variable - please manually include it'
.config/log info 'Get Bodega here -> `https://github.com/megabyte-labs/Bodega`'
.config/log warn '`task` does not appear to be installed or is not registered in the `PATH` variable - please manually include it'
logger info 'Get `task` here -> https://taskfile.dev'
else
.config/log info "Performing various pre-commit tasks on staged files (like autofixing, detecting private keys, etc.)"

logger info "Performing various pre-commit tasks on staged files (like autofixing, detecting private keys, etc.)"
STAGED_FILES=$(git diff --cached --name-only)
for FILE in "$STAGED_FILES"; do
if [ -f "$1" ]; then
Expand All @@ -36,14 +42,14 @@ if [ -f "$(dirname "$0")/_/husky.sh" ]; then
done
wait

.config/log info 'Linting and fixing the staged files with `lint-staged`'
logger info 'Linting and fixing the staged files with `lint-staged`'
task lint:lint-staged

.config/log info 'Reporting possible spelling errors in the staged files with `cspell`'
logger info 'Reporting possible spelling errors in the staged files with `cspell`'
task lint:spelling

.config/log success 'Pre-commit validation complete!'
logger success 'Pre-commit validation complete!'
fi
else
.config/log warn 'Husky pre-commit hooks are currently not properly setup.'
logger warn 'Husky pre-commit hooks are currently not properly setup.'
fi
19 changes: 13 additions & 6 deletions .config/husky/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@
# @arg $1 The name of the remote (e.g. origin)
# @arg $2 The location of the remote (e.g. [email protected]:megabyte-labs/common/angular.git)

[ -f .config/log ] && chmod +x .config/log
# @description Register appropriate logging utility
if [ -f "$(dirname "$0")/../.config/log" ]; then
alias logger="$(dirname "$0")/../.config/log"
chmod +x "$(dirname "$0")/../.config/log"
elif command -v logg > /dev/null; then
alias logger='logg'
fi

if [ -f "$(dirname "$0")/_/husky.sh" ]; then
. "$(dirname "$0")/_/husky.sh"

# Attempt to register Bodega/Task from common places if it is not in PATH
# Attempt to register Task from common places if it is not in PATH
if ! type task > /dev/null; then
PATH="$PATH:$HOME/.local/go/bin:$HOME/.local/bin:$HOME/bin:$HOME/go/bin:$HOME/.asdf/shims"
if ! type task > /dev/null; then
Expand All @@ -23,13 +30,13 @@ if [ -f "$(dirname "$0")/_/husky.sh" ]; then
fi
fi

# Show warning if Bodega/Task is still not registered/installed, else proceed with hook
# Show warning if Task is still not registered/installed, else proceed with hook
if ! type task > /dev/null; then
.config/log warn 'Bodega `task` does not appear to be installed or is not registered in the `PATH` variable - please manually include it'
.config/log info 'Get Bodega here -> `https://github.com/megabyte-labs/Bodega`'
logger warn '`task` does not appear to be installed or is not registered in the `PATH` variable - please manually include it'
logger info 'Get `task` here -> https://taskfile.dev'
else
task git:hook:pre-push -- "$1 $2"
fi
else
.config/log warn 'Husky pre-commit hooks are currently not properly setup.'
logger warn 'Husky pre-commit hooks are currently not properly setup.'
fi
17 changes: 12 additions & 5 deletions .config/husky/prepare-commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,29 @@
# @arg $2 string The type of the `prepare-commit-msg` event. For a `git pull origin master`
# command, the event type is 'merge'.

[ -f .config/log ] && chmod +x .config/log
# @description Register appropriate logging utility
if [ -f "$(dirname "$0")/../.config/log" ]; then
alias logger="$(dirname "$0")/../.config/log"
chmod +x "$(dirname "$0")/../.config/log"
elif command -v logg > /dev/null; then
alias logger='logg'
fi

if [ -f "$(dirname "$0")/_/husky.sh" ]; then
. "$(dirname "$0")/_/husky.sh"
if [ "$2" != 'merge' ]; then
.config/log info 'This git hook is configured to run even when --no-verify is used. In order to bypass this prompt, use the -n flag instead.'
.config/log info 'Opening a `git commit` dialog'
logger info 'This git hook is configured to run even when --no-verify is used. In order to bypass this prompt, use the -n flag instead.'
logger info 'Opening a `git commit` dialog'
if ! type pnpx > /dev/null && type npm > /dev/null; then
npm install -g pnpm
elif ! type pnpx > /dev/null; then
.config/log error '`pnpm` or `npm` must be installed'
logger error '`pnpm` or `npm` must be installed'
fi
if ! type git-cz &> /dev/null; then
pnpm install -g commitizen
fi
exec < /dev/tty && (git-cz --hook || true)
fi
else
.config/log warn 'Husky pre-commit hooks are currently not properly setup.'
logger warn 'Husky pre-commit hooks are currently not properly setup.'
fi
Loading

0 comments on commit 02f4e2b

Please sign in to comment.