forked from RomainLanz/adonis-bull-queue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstructions.ts
34 lines (30 loc) · 1.01 KB
/
instructions.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
/**
* @rlanz/bull-queue
*
* @license MIT
* @copyright Romain Lanz <[email protected]>
*/
import { join } from 'node:path';
import * as sinkStatic from '@adonisjs/sink';
import type { ApplicationContract } from '@ioc:Adonis/Core/Application';
function getStub(...relativePaths: string[]) {
return join(__dirname, 'templates', ...relativePaths);
}
export default async function instructions(
projectRoot: string,
app: ApplicationContract,
sink: typeof sinkStatic
) {
// Setup config
const configPath = app.configPath('queue.ts');
new sink.files.MustacheFile(projectRoot, configPath, getStub('config.txt')).commit();
const configDir = app.directoriesMap.get('config') || 'config';
sink.logger.action('create').succeeded(`${configDir}/queue.ts`);
// Setup environment
const env = new sink.files.EnvFile(projectRoot);
env.set('QUEUE_REDIS_HOST', 'localhost');
env.set('QUEUE_REDIS_PORT', '6379');
env.set('QUEUE_REDIS_PASSWORD', '');
env.commit();
sink.logger.action('update').succeeded('.env,.env.example');
}