vacuum-mail-app

Utility to vacuum the Mail.app Envelope Index SQLite database.

View on GitHub

vacuum-mail-app

NPM Version NPM Downloads GitHub tag (with filter) License GitHub commits since latest release (by SemVer including pre-releases) CodeQL QA Tests Coverage Status Dependabot Stargazers pre-commit Prettier TypeScript Yarn eslint vitest

@Tatsh Buy Me A Coffee Libera.Chat Mastodon Follow Patreon

Vacuum (compact) the Mail.app Envelope Index SQLite database to reclaim disk space.

Installation

Install globally and then run vacuum-mail-app.

yarn global add vacuum-mail-app
# or
npm install --global vacuum-mail-app

Usage

vacuum-mail-app

If Mail is running, the script asks it to quit without saving. It then searches ~/Library/Mail/V*/MailData/ for an Envelope Index SQLite file, picking the newest data-store version present (so the same binary works on every macOS release that ships a V<n> folder). It runs sqlite3 <path> vacuum against that file, prints the before/after byte counts and the percentage change, and finally reopens Mail.

Exit status

Code Meaning
0 The database was vacuumed successfully.
1 Vacuum failed because the Envelope Index file could not be located or sqlite3 exited non-zero.

Development

yarn               # install dependencies.
yarn test          # run vitest with coverage.
yarn webpack       # bundle src/index.ts to dist/index.js.
yarn qa            # lint, spell-check, and prettier check.

The CLI is written in TypeScript and bundled with webpack. The runtime relies on jxa-lib for Foundation wrappers and on jxa-types for JXA global type definitions.