Home Auto update all installed shadcn/ui Components
Post
Cancel

Auto update all installed shadcn/ui Components

A simple script to update all your shadcn/ui components in one go. No more updating components one by one!

The Script

#!/bin/bash
# update-shadcn-components.sh
# Script to bulk update all shadcn/ui components in a Next.js project
# Usage: ./update-shadcn-components.sh
# Set error handling
set -e
# Check if we're in a Next.js project
if [ ! -d "src/components/ui" ]; then
echo "Error: src/components/ui directory not found"
echo "Please run this script from your Next.js project root"
exit 1
fi
# Log start of updates
echo "Starting shadcn/ui components update..."
echo "Checking components in src/components/ui/..."
# Initialize counter
updated=0
failed=0
# Update each component
for file in src/components/ui/*.tsx; do
# Extract component name
component=$(basename "$file" .tsx)
echo "Updating component: $component"
# Try to update the component
if npx shadcn@latest add -y -o "$component"; then
updated=$((updated + 1))
echo "✓ Successfully updated $component"
else
failed=$((failed + 1))
echo "✗ Failed to update $component"
fi
done
# Print summary
echo "Update complete!"
echo "Successfully updated: $updated components"
if [ $failed -gt 0 ]; then
echo "Failed to update: $failed components"
exit 1
fi

Quick Start

  1. Save as update-shadcn-components.sh
  2. Make executable: chmod +x update-shadcn-components.sh
  3. Run: ./update-shadcn-components.sh

What it does

  • Updates all shadcn components in src/components/ui/
  • Shows progress for each update
  • Tells you what succeeded and what failed

Before Running

  • Commit your changes
  • Be in your project root directory

That’s it! Simple and effective way to keep your shadcn components up to date.

This post is licensed under CC BY 4.0 by the author.

Auto update uv pyproject.toml dependencies

-

Comments powered by Disqus.