-
Notifications
You must be signed in to change notification settings - Fork 4
/
configure.ts
51 lines (45 loc) · 1.32 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
46
47
48
49
50
51
import ConfigureCommand from '@adonisjs/core/commands/configure'
import { stubsRoot } from './stubs/main.js'
/**
* Configures the package
*/
export async function configure(command: ConfigureCommand) {
const codemods = await command.createCodemods()
/**
* Publish config file
*/
await codemods.makeUsingStub(stubsRoot, 'config/rabbit.stub', {})
await codemods.makeUsingStub(stubsRoot, 'start/rabbit.stub', {})
/**
* Publish provider and command
*/
await codemods.updateRcFile((rcFile: any) => {
rcFile.addProvider('rabbitmq-adonis-v6/rabbitmq_provider')
rcFile.addPreloadFile('#start/rabbit', ['web'])
})
/**
* Define env variables
*/
await codemods.defineEnvVariables({
RABBITMQ_HOSTNAME: 'localhost',
RABBITMQ_USER: '',
RABBITMQ_PASSWORD: '',
RABBITMQ_PORT: '',
RABBITMQ_PROTOCOL: 'ampq',
RABBITMQ_HEARTBEAT: 60,
})
/**
* Define env variables validation
*/
await codemods.defineEnvValidations({
variables: {
RABBITMQ_HOSTNAME: 'Env.schema.string()',
RABBITMQ_USER: 'Env.schema.string()',
RABBITMQ_PASSWORD: 'Env.schema.string()',
RABBITMQ_PORT: 'Env.schema.number()',
RABBITMQ_PROTOCOL: 'Env.schema.string()',
RABBITMQ_HEARTBEAT: 'Env.schema.number.optional()',
},
leadingComment: 'Variables for Rabbitmq',
})
}