#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

export PATH="$(dirname "$0")/../node_modules/.bin:$PATH"

COLOR_GREEN=`tput setaf 2`
COLOR_BLUE=`tput setaf 4`
RESET=`tput sgr0`
SPACER='                    '

function info {
  printf "${COLOR_BLUE}→ info    ${RESET}- $1${RESET}"
}

function success {
  printf "\r${COLOR_GREEN}✔ success ${RESET}- $1${SPACER}${RESET}\n"
}

info "Updating packages..."

taze -w major
pnpm i

git stage package.json
git stage pnpm-lock.yaml

info "Checking for errors..."

if [ -n "$(git status src --porcelain)" ]; then
  zx scripts/check.mjs || exit 1
fi

success "No errors found. Attempting to commit your changes!"