-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigure.ts
46 lines (43 loc) · 1.54 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
import type Configure from '@adonisjs/core/commands/configure'
import pkg from './package.json'
import { stubsRoot } from './stubs/index.js'
const packageName = pkg.name
/**
* Configures the package
*/
export async function configure(command: Configure) {
const codemods = await command.createCodemods()
await codemods.makeUsingStub(stubsRoot, 'config/clickhouse.stub', {})
/**
* Add environment variables
*/
await codemods.defineEnvVariables({
CLICKHOUSE_HOST: 'http://localhost:8123',
CLICKHOUSE_USER: 'default',
CLICKHOUSE_PASSWORD: '',
CLICKHOUSE_DB: 'default',
CLICKHOUSE_REQUEST_TIMEOUT: 30000,
CLICKHOUSE_COMPRESSION_REQUEST: false,
CLICKHOUSE_COMPRESSION_RESPONSE: true
})
/**
* Validate environment variables
*/
await codemods.defineEnvValidations({
variables: {
CLICKHOUSE_HOST: `Env.schema.string.optional({ format: 'url', tld: false })`,
CLICKHOUSE_USER: 'Env.schema.string.optional()',
CLICKHOUSE_PASSWORD: 'Env.schema.string.optional()',
CLICKHOUSE_DB: 'Env.schema.string.optional()',
CLICKHOUSE_REQUEST_TIMEOUT: 'Env.schema.number.optional()',
CLICKHOUSE_COMPRESSION_REQUEST: 'Env.schema.boolean.optional()',
CLICKHOUSE_COMPRESSION_RESPONSE: 'Env.schema.boolean.optional()',
},
})
/**
* Register provider
*/
await codemods.updateRcFile((rcFile) => {
rcFile.addProvider(`${packageName}/providers/clickhouse_provider`)
})
}