-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
configure.ts
45 lines (40 loc) · 1.13 KB
/
configure.ts
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
/*
* @adonisjs/bouncer
*
* (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.js'
/**
* Configures the package
*/
export async function configure(command: Configure) {
const codemods = await command.createCodemods()
/**
* Publish stubs to define abilities and collect
* policies
*/
await codemods.makeUsingStub(stubsRoot, 'abilities.stub', {})
await codemods.makeUsingStub(stubsRoot, 'policies.stub', {})
/**
* Register provider
*/
await codemods.updateRcFile((rcFile) => {
rcFile.addCommand('@adonisjs/bouncer/commands')
rcFile.addProvider('@adonisjs/bouncer/bouncer_provider')
})
/**
* Publish and register middleware
*/
await codemods.makeUsingStub(stubsRoot, 'initialize_bouncer_middleware.stub', {
entity: command.app.generators.createEntity('initialize_bouncer'),
})
await codemods.registerMiddleware('router', [
{
path: '#middleware/initialize_bouncer_middleware',
},
])
}