Create a new CodeTransformer instance
The current working directory URL
Utility function for installing packages
Utility function for detecting the package manager
The TsMorph project instance for AST manipulation
Add new env variable validation in the env.ts file
Environment validation definition containing variables and comment
Define new middlewares inside the start/kernel.ts file
This function is highly based on some assumptions
and will not work if you significantly tweaked
your start/kernel.ts file.
The middleware stack to add to ('server', 'router', or 'named')
Array of middleware entries to add
Update the adonisrc.ts file using the provided callback
Function that receives the RcFileTransformer for modifications
Add a new Japa plugin in the tests/bootstrap.ts file
The plugin function call to add
Import declarations needed for the plugin
Add a new Vite plugin to the vite.config.ts file
The plugin function call to add
Import declarations needed for the plugin
Adds a policy to the list of policies object configured
inside the app/policies/main.ts file.
Array of bouncer policy entries to add
This class is responsible for transforming AdonisJS project code, including updating middleware, environment validations, and other code generation tasks.
The CodeTransformer provides methods for modifying various AdonisJS configuration files and code structures using AST manipulation through ts-morph. It can update middleware stacks, add environment validations, register plugins, and modify RC file configurations.
Example