-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
configure.ts
47 lines (41 loc) · 1.08 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
/*
* @adonisjs/i18n
*
* (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/i18n.stub', {})
/**
* Publish middleware file
*/
await codemods.makeUsingStub(stubsRoot, 'make/middleware/detect_user_locale.stub', {
entity: command.app.generators.createEntity('detect_user_locale'),
})
/**
* Register middleware
*/
await codemods.registerMiddleware('router', [
{
path: '#middleware/detect_user_locale_middleware',
},
])
/**
* Register provider
*/
await codemods.updateRcFile((rcFile) => {
rcFile.addProvider('@adonisjs/i18n/i18n_provider')
rcFile.addMetaFile('resources/lang/**/*.{json,yaml,yml}', false)
})
}