#!/bin/zsh

echo "Generating the lists of explicitly installed packages in ~/.backup"

cd /Users/shixuesen
npm list -g --depth=1 > ~/.backup/npm_packages || echo "npm failed"
pip list > ~/.backup/pip_packages || echo "pip failed"
pip3 list > ~/.backup/pip3_packages || echo "pip3 failed"
cargo --list | tail -n +2 | tr -d " " > ~/.backup/cargo_packages || echo "cargo failed"
composer global show | cut -d ' ' -f1 > ~/.backup/composer_packages || echo "composer failed"
brew update
brew upgrade
source /Users/shixuesen/.zshrc
#iicu64
brew list > ~/.backup/brew_packages

cp back.sh ~/.backup/
git add -f .backup
git commit -am "update at $(date "+%Y-%m-%d %H:%M:%S")"
git push

exit 0
