A tool for automating the upgrade process of an AdonisJS v6 project to v7.
β οΈ Heads up: This tool was built for a personal project and shared with the community as-is. Use it with responsibility. Feel free to contribute to improve it.
Please make sure your project uses Node v24!
# 1. Clone this repository
git clone https://github.com/nicostuhlfauth/adonis-v7-easy-migration.git
cd adonis-v7-easy-migration
# 2. Install dependencies and build
pnpm install
pnpm run build
# 3. Run the migration tool against your project
node build/bin/run.js /path/to/your/adonis-project
# Or run from inside your project directory (no path argument needed)
cd /path/to/your/adonis-project
node /path/to/adonis-v7-easy-migration/build/bin/run.js
# Preview all changes without modifying files
node build/bin/run.js /path/to/your/adonis-project --dry-runTip: Run inside a clean git branch so you can easily review the diff and revert if needed.
- Node.js 24 or higher
- An AdonisJS v6 project with
package.json,adonisrc.ts, andtsconfig.json - A git repository (strongly recommended β gives you a clean diff to review after the migration)
| Breaking Change | Status |
|---|---|
Replace ts-node-maintained with @poppinss/ts-exec in ace.js |
β Automated |
Remove appKey export from config/app.ts |
β Automated |
Create config/encryption.ts with legacy driver |
β Automated |
Add hooks to adonisrc.ts (indexEntities, Bouncer, Tuyau, Inertia, Vite) |
β Automated |
Rename assembler hooks (onSourceFileChanged β fileChanged, etc.) |
β Automated |
Fix test glob patterns ((.ts|.js) β .{ts,js}) in adonisrc.ts |
β Automated |
Remove assetsBundler property from adonisrc.ts |
β Automated |
Replace router.makeUrl() with urlFor() |
β Automated |
Replace getDirname() / getFilename() with import.meta.dirname/filename |
β Automated |
Replace slash(x) with stringHelpers.toUnixSlash(x) |
β Automated |
Replace joinToURL(a, b) with new URL(b, a) |
β Automated |
Replace parseImports import with parse-imports package |
β Automated |
Rename Request / Response β HttpRequest / HttpResponse |
β Automated |
Update flash message keys (errors.* β inputErrorsBag.*) |
β Automated |
Replace route() with urlFor() in Edge templates |
β Automated |
Add subpath imports to package.json |
β Automated |
Update all @adonisjs/* packages to @latest |
β Automated |
Move inertia/app/app.tsx β inertia/app.tsx (if Inertia) |
β Automated (with confirmation) |
Create InertiaMiddleware and register in start/kernel.ts |
β Automated |
Create tsconfig.inertia.json with references |
β Automated |
Detect cuid() / isCuid() usage |
|
Remove sharedData from Inertia config |
After running the tool, check the report for any items flagged as manual:
AdonisJS v7 removes cuid support. Replace with:
// Simple unique ID
crypto.randomUUID();
// Or use a UUID library
import { v4 as uuidv4 } from "uuid";The sharedData property has been removed from config/inertia.ts.
Move your shared data logic into the generated InertiaMiddleware:
// app/middleware/inertia_middleware.ts
import { BaseInertiaMiddleware } from "@adonisjs/inertia";
import type { HttpContext } from "@adonisjs/core/http";
export default class InertiaMiddleware extends BaseInertiaMiddleware {
share(ctx: HttpContext) {
return {
user: ctx.auth.user,
// ... your shared data
};
}
}These are changes in runtime behavior that cannot be detected or transformed automatically:
request.all()now merges multipart files with fields (previously returned fields only)- Auto-generated route names from controllers may now conflict with manually defined route names
- Status pages (404, 500, etc.) are skipped for requests that expect a JSON response
- VineJS
BaseModifiersclass has been removed β update any custom modifier classes - Shutdown hooks now execute in reverse registration order (last registered = first to run)
The tool auto-detects which packages are installed and applies conditional transforms:
| Package | What gets automated |
|---|---|
@adonisjs/inertia |
File moves, config update, middleware creation, tsconfig references |
@adonisjs/bouncer |
indexPolicies() hook added to adonisrc.ts |
@tuyau/core |
generateRegistry() hook added to adonisrc.ts |
@adonisjs/vite |
buildStarting hook added to adonisrc.ts |
node build/bin/run.js [project-path] [options]
ARGUMENTS
project-path Path to your AdonisJS v6 project (default: current directory)
OPTIONS
-d, --dry-run Preview all changes without modifying any files
-v, --verbose Print every file processed by each transform
--skip-install Skip running the package manager after file changes
-h, --help Show this help message
The tool uses two strategies:
-
jscodeshift codemods β AST-level transformations for TypeScript/JavaScript files. These preserve your original formatting and only change exactly what needs to change.
-
Structural patchers β Direct file mutations for configuration files (
adonisrc.ts,tsconfig.json,package.json) using ts-morph, where targeted surgical edits are easier than full AST rewrites.
A backup of all modified files is created in .adonis-migration-backup/ before any changes are applied.
- Review the migration report output
- Address any
β WARNINGSflagged as manual actions - Review the behavioral changes list
- Run
node aceto verify the application starts - Run your test suite:
node ace test
Found a missing transform or a bug? Open an issue or submit a PR.
To add a new transform:
- Create
src/transforms/your-transform.tsfollowing the existing pattern - Add it to the execution sequence in
src/runner.ts - Add unit tests in
tests/transforms/your-transform.spec.ts - Update the table in this README
MIT β see LICENSE