Clean Up Vercel with VP CLI
Problem
I’ve been working with Vercel for a while now, and I love how easy it is to deploy applications. However, one thing that always bothered me was the deployment clutter. Vercel keeps all deployments, including previews from pull requests, indefinitely. This means that after months of active development, you can end up with hundreds, if not thousands, of old deployments taking up space. Managing these manually through Vercel’s dashboard is incredibly tedious, especially when you’re juggling multiple projects. I searched for an automated solution, but couldn’t find anything that fit my needs.
Solution
To solve this problem, I developed Vercel Purge or in short vp, a CLI tool designed to automatically clean up unused deployments in Vercel projects. With a single command, you can remove all old deployments from a specific project or even from all your projects at once. The tool is straightforward to use, provides confirmation prompts to prevent accidents, and supports bulk operations when you’re confident about what you’re removing. It’s fully functional and ready to use today!
Design
vp is written in Python and leverages the Vercel CLI under the hood. It uses the Vercel API to list and delete deployments, making it reliable and fast.
The tool supports several powerful options:
- Project targeting: Remove deployments from a specific project or all projects at once.
- Status checking: View deployment counts across your projects.
- Project listing: See all your Vercel projects without making changes.
- Force mode: Skip confirmation prompts for automated workflows.
- Delay option: Schedule cleanup to run after a specified delay.
The command can be invoked as vercel_purge or its shorter alias vp, after it’s been installed, making it quick to type and remember.
Conclusion
I use vp regularly on my own projects, and it’s saved me countless hours of manual cleanup work. Since it’s such a practical tool that solves a real problem in the Vercel workflow, I’ve open-sourced it. If you spend time managing Vercel deployments, this tool can significantly streamline your workflow. Check out vp on GitLab and give it a try!