-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ts
48 lines (42 loc) · 1.72 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
/*
|--------------------------------------------------------------------------
| Configure hook
|--------------------------------------------------------------------------
|
| The configure hook is called when someone runs "node ace configure <package>"
| command. You are free to perform any operations inside this function to
| configure the package.
|
| To make things easier, you have access to the underlying "ConfigureCommand"
| instance and you can use codemods to modify the source files.
|
*/
import ConfigureCommand from "@adonisjs/core/commands/configure";
import { stubsRoot } from "./stubs/main.js";
export async function configure(command: ConfigureCommand) {
const codemods = await command.createCodemods();
await codemods.makeUsingStub(stubsRoot, "config/bull.stub", {});
await codemods.makeUsingStub(stubsRoot, "contracts/queue.stub", {});
await codemods.makeUsingStub(stubsRoot, "start/bull.stub", {});
await codemods.makeUsingStub(stubsRoot, "start/job.stub", {});
await codemods.makeUsingStub(stubsRoot, "jobs/queue.stub", {});
await codemods.makeUsingStub(stubsRoot, "jobs/tasks/main.stub", {});
await codemods.updateRcFile((rcFile: any) => {
rcFile.addProvider("@brighthustle/adonis-jobs/queue_provider");
rcFile.addCommand("@brighthustle/adonis-jobs/commands");
});
await codemods.defineEnvVariables({
REDIS_HOST: "localhost",
REDIS_PORT: 6379,
REDIS_PASSWORD: "",
});
await codemods.defineEnvValidations({
leadingComment: "Variables for configuring the jobs package",
variables: {
REDIS_HOST: `Env.schema.string()`,
REDIS_PORT: `Env.schema.number()`,
REDIS_PASSWORD: `Env.schema.string.optional()`,
REDIS_QUEUE: `Env.schema.string.optional()`,
},
});
}