Upgrading SveltyCMS
Guide on how to safely upgrade your SveltyCMS installation.
On this page
SveltyCMS is designed to be upgraded easily while preserving your custom collections and configurations. We provide a CLI tool to automate the process, including dependency updates, database migrations, and automated code transformations (codemods).
The Upgrade Process
The upgrade tool performs the following steps:
-
Git Verification: Ensures you are in a valid Git repository.
-
Auto-Stash: If you have uncommitted changes and use the
--forceflag, the tool automatically stashes them and restores them after the upgrade. -
Rollback Tag: Creates a local Git tag (e.g.,
pre-upgrade-2026-04-06-12-00-00) as a safety net before any changes are merged. -
Upstream Fetch: Fetches the latest changes from the official SveltyCMS repository.
-
Pre-commit Merge: Merges changes into your local branch without committing, allowing you to review.
-
Dependency Refresh: Runs
bun installto ensure all new packages are installed. On Windows,npm installis used instead to avoid knownbun installcorruption issues. -
SBOM Sync: Runs
bun run audit:sbomto regenerate the CycloneDX SBOM (sbom.json) so it matches the updated dependency tree (see Dependency Updates & SBOM below). -
Codemods: Automatically executes scripts in
scripts/codemods/. Scripts starting with an underscore (e.g.,_utils.ts) are ignored by the runner. -
Database & Tests: Runs
db:pushandtest:unitto ensure everything is working correctly.
How to Run the Upgrade
Run the following command in your project root:
bun run scripts/upgrade.ts
Advanced Options
| Flag | Description |
|---|---|
--dry-run |
See what would happen without making any changes. |
--skip-tests |
Do not run the unit test suite after upgrade. |
--skip-db |
Do not run db:push after upgrade. |
--skip-sbom |
Do not regenerate the SBOM after install. |
--skip-merge |
Skip fetch+merge (useful if resuming after manual conflict resolution). |
--force |
Auto-stash uncommitted changes before upgrade. |
--branch=NAME |
Upgrade from a specific branch (defaults to next). |
Dependency Updates & SBOM
SveltyCMS ships a dedicated dependency-update flow that keeps the CycloneDX SBOM (sbom.json) in lockstep with the resolved dependency tree:
- Check for outdated packages:
bun outdated - Update + regenerate SBOM in one command:
bun run update— runsbun updateand thenbun run audit:sbom, sosbom.json(name + version + SHA-512 hashes per package) always reflects what was actually installed. - Safety net: If you change dependencies any other way (native
bun update,bun install,bun add,bun remove), the pre-commit hook detectsbun.lock/package.jsonchanges and regenerates + stagessbom.jsonautomatically before every commit.
The SBOM feeds vulnerability scanners (e.g., Dependency-Track, Grype) and supports SOC 2 / GDPR Art. 32 supply-chain compliance. See Security Overview.
Note on
bun outdated: packages pinned to an exact version (e.g.,graphqlis pinned to16.14.2) or released as a new major outside your declared range will appear as “outdated” but are intentionally left untouched bybun update. Review the output and bumppackage.jsondeliberately for those.
Codemods
SveltyCMS uses “codemods” to automate the tedious parts of an upgrade. If a new version renames a property in a configuration file or changes a component’s API, a codemod script will automatically update your local files during the upgrade.
Naming Convention
Codemods in scripts/codemods/ follow a specific naming pattern:
NN-description.ts: Numbered prefix (e.g.,01-migrate-schema.ts) determines the execution order._name.ts: Files starting with an underscore are treated as internal utilities and are not executed by the upgrade runner.
Codemod Utilities (_utils.ts)
The shared utilities module provides reusable helpers used by all codemod scripts:
MigrationManager— Chains multiple migration rules and tracks which changes were applied per file.deepUpsertProperty(obj, path, value)— Inserts or updates a nested property using dot-notation paths, creating intermediate objects as needed.validateSchema(obj)— Post-migration validation that checks required fields (name,fields) still exist after transformation.upsertProperty/renameProperty— Single-level property insertion, update, and rename operations.
Current Codemods
| # | File | What it does |
|---|---|---|
| 01 | 01-migrate-collection-schema-v2.ts |
Adds version: 2 marker and renames deprecated schema fields |
| 02 | 02-update-permissions-structure.ts |
Converts legacy publicAccess to structured permissions object with merge logic preserving existing role permissions |
| 03 | 03-add-soft-delete-fields.ts |
Injects isDeleted boolean field into every collection schema for soft-delete support |
| 04 | 04-migrate-role-names.ts |
Role name standardization (planned) |
| — | _utils.ts |
Shared utilities: MigrationManager, deepUpsertProperty, validateSchema, upsertProperty, renameProperty, createCodemodProject |
Best Practices
- Review the Rollback Tag: Before starting, the tool provides a rollback tag. If anything goes wrong, you can return to your previous state using
git reset --hard <tag-name>. - Review Changes: After the script finishes, use
git diffto review the changes before committing. - Resolve Conflicts: If the merge fails, the tool will pause. Resolve conflicts in your editor,
git addthe changes, then run the upgrade again with--skip-merge.
Troubleshooting
Rolling Back
If the upgrade causes issues, you can roll back to the state before the upgrade started:
# List available rollback tags
git tag --list "pre-upgrade-*"
# Reset to the desired tag
git reset --hard pre-upgrade-YYYY-MM-DD-HH-MM-SS
“bun install” corruption on Windows
If you’re on Windows and bun install produces errors or corrupted node_modules:
- Delete
node_modules(but keepbun.lock) - Run
npm installinstead bun run devwill work normally after npm install
“Merge conflict — manual resolution required”
If conflicts occur:
- Resolve them in your IDE.
git add .- Run
bun run scripts/upgrade.ts --skip-mergeto complete the remaining steps (install, codemods, etc.).