One Script to Rule Them All: Upgrade All The Things šŸ› ļø

  • #homebrew
  • #nvm
  • #script

As a software and web developer, I know the pain of upgrading CLI tools like Node, Homebrew stuff, and others individually. To simplify this process, Iā€™ve created a simple upgrade script, ā€œUpgrade All The Thingsā€. And gave it a handy shell alias.

An adorably cute robot package manager
An adorably cute robot package manager.

The Script

The script itself is just a simple shell script that runs the following commands:

#!/bin/zsh
# Homebrew
brew update && brew upgrade && brew cleanup && brew doctor
# Source nvm
. ~/.nvm/nvm.sh
# Node
nvm install 19 --reinstall-packages-from=node --latest-npm
# Global npm packages
ncu -g
# corepack
corepack disable

Whatā€™s going on here?

The Homebrew stuff is pretty straightforward. For Node, I use nvm as the version manager, so I have to load it before using it. Then I install the latest version of Node (which I have pinned to a specific version) and reinstall all global packages.

I also use ncu to check for outdated global npm packages. Finally, I disable Corepack, because it messes up my pnpm installation from Homebrew (since Corepack does not always ship the latest version).

Shell Alias

To make it easier to run the script, Iā€™ve created a shell alias for it. Iā€™ve added the following line to my .zshrc file:

Terminal window
alias uatt="~/Scripts/upgrade-all-the-things.sh"