-
-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathconfigure.ts
More file actions
55 lines (48 loc) · 1.25 KB
/
configure.ts
File metadata and controls
55 lines (48 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
* @adonisjs/session
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import type Configure from '@adonisjs/core/commands/configure'
import { stubsRoot } from './stubs/main.ts'
/**
* Configures the package
*/
export async function configure(command: Configure) {
const codemods = await command.createCodemods()
/**
* Publish config file
*/
await codemods.makeUsingStub(stubsRoot, 'config/session.stub', {})
/**
* Define environment variables
*/
await codemods.defineEnvVariables({ SESSION_DRIVER: 'cookie' })
/**
* Define environment variables validations
*/
await codemods.defineEnvValidations({
variables: {
SESSION_DRIVER: `Env.schema.enum(['cookie', 'memory'] as const)`,
},
leadingComment: 'Variables for configuring session package',
})
/**
* Register middleware
*/
await codemods.registerMiddleware('router', [
{
path: '@adonisjs/session/session_middleware',
},
])
/**
* Register provider and commands
*/
await codemods.updateRcFile((rcFile) => {
rcFile.addProvider('@adonisjs/session/session_provider')
rcFile.addCommand('@adonisjs/session/commands')
})
}