-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
configure.ts
50 lines (44 loc) · 1.09 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
/*
* @adonisjs/redis
*
* (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 config file
*/
await codemods.makeUsingStub(stubsRoot, 'config/redis.stub', {})
/**
* Add environment variables
*/
await codemods.defineEnvVariables({
REDIS_HOST: '127.0.0.1',
REDIS_PORT: '6379',
REDIS_PASSWORD: '',
})
/**
* Validate environment variables
*/
await codemods.defineEnvValidations({
variables: {
REDIS_HOST: `Env.schema.string({ format: 'host' })`,
REDIS_PORT: 'Env.schema.number()',
REDIS_PASSWORD: 'Env.schema.string.optional()',
},
})
/**
* Add provider to rc file
*/
await codemods.updateRcFile((rcFile) => {
rcFile.addProvider('@adonisjs/redis/redis_provider')
})
}