Skip to content

Instantly share code, notes, and snippets.

@jahed
Last active November 24, 2021 22:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jahed/f0d583897bcc301d9fdc97f1ea5b9b33 to your computer and use it in GitHub Desktop.
Save jahed/f0d583897bcc301d9fdc97f1ea5b9b33 to your computer and use it in GitHub Desktop.
Upgrade NPM Dependencies
#!/usr/bin/env bash
set -euo pipefail
echo "SETTING UP"
npm ci
npm install npm-check-updates
npm upgrade npm-check-updates
echo
echo "UPGRADING MINOR VERSIONS"
npx ncu --deep --format repo --target minor --upgrade
npm install
git add package-lock.json '*package.json'
if ! git diff --quiet --cached --exit-code; then
git commit -m 'build(deps): upgrade minor versions'
fi
echo
echo "UPGRADING TRANSITIVES"
npm upgrade
npm install # workaround for consistency
git add package-lock.json '*package.json'
if ! git diff --quiet --cached --exit-code; then
git commit -m 'build(deps): upgrade transitive dependencies'
fi
echo
echo "CHECKING MAJOR VERSIONS"
npx ncu --deep --format repo --target latest
echo
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment