https://github.com/adonisjs/presets
A collection of presets to configure AdonisJS packages
https://github.com/adonisjs/presets
Last synced: 4 months ago
JSON representation
A collection of presets to configure AdonisJS packages
- Host: GitHub
- URL: https://github.com/adonisjs/presets
- Owner: adonisjs
- License: mit
- Created: 2023-12-18T02:02:44.000Z (over 2 years ago)
- Default Branch: 3.x
- Last Pushed: 2026-01-14T17:10:08.000Z (5 months ago)
- Last Synced: 2026-01-14T21:13:37.646Z (5 months ago)
- Language: TypeScript
- Size: 94.7 KB
- Stars: 8
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# AdonisJS presets
These presets are a collection of functions you can execute to configure an AdonisJS package. This repo contains presets only for those packages that can be configured from multiple user interactions.
For example: When you create a new AdonisJS application, you can configure Lucid and also you can create a new app without Lucid and configure it later.
So, instead of duplicating the code in multiple places, we create re-usable presets and use them with individual packages and the [create-adonisjs](https://npm.im/create-adonisjs) initializer.
> [!NOTE]
> Presets do not trigger any prompts and exposes a coding interface.
## Auth preset
The `auth` presets configures the `@adonisjs/auth` package. The package must be installed to run this preset.
```ts
import { Kernel } from '@adonisjs/core/ace'
import { Application } from '@adonisjs/core/app'
import { presetAuth } from '@adonisjs/presets/auth'
import { Codemods } from '@adonisjs/core/ace/codemods'
/**
* Create application instance. Inside an Ace command, you
* get access to it using `this.app` property.
*/
const app = new Application(baseURL, {
importer: () => {},
})
/**
* Create Ace kernel instance to get CLI logger reference.
* Inside an Ace command you can access it using this.logger
* property.
*/
const cliLogger = new Kernel(app).ui.logger
/**
* Create codemods instance. Codemods are needed to modify
* source files.
*/
const codemods = new Codemods(app, cliLogger)
/**
* Apply preset
*/
await presetAuth(codemods, app, {
guard: 'session',
userProvider: 'lucid',
})
```
## Lucid preset
The `auth` presets configures the `@adonisjs/lucid` package. The package must be installed to run this preset.
```ts
import { Kernel } from '@adonisjs/core/ace'
import { Application } from '@adonisjs/core/app'
import { presetLucid } from '@adonisjs/presets/lucid'
import { Codemods } from '@adonisjs/core/ace/codemods'
/**
* Create application instance. Inside an Ace command, you
* get access to it using `this.app` property.
*/
const app = new Application(baseURL, {
importer: () => {},
})
/**
* Create Ace kernel instance to get CLI logger reference.
* Inside an Ace command you can access it using this.logger
* property.
*/
const cliLogger = new Kernel(app).ui.logger
/**
* Create codemods instance. Codemods are needed to modify
* source files.
*/
const codemods = new Codemods(app, cliLogger)
/**
* Apply preset
*/
await presetLucid(codemods, app, {
dialect: 'sqlite',
installPackages: true,
})
```