-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstructions.ts
33 lines (29 loc) · 969 Bytes
/
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
/**
* @tidaly/mqtt
*
* @license MIT
* @copyright Tidaly <contact@tidaly.fr>
*/
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('mqtt.ts');
new sink.files.MustacheFile(projectRoot, configPath, getStub('config.txt')).commit();
const configDir = app.directoriesMap.get('config') || 'config';
sink.logger.action('create').succeeded(`${configDir}/mqtt.ts`);
// Setup environment
const env = new sink.files.EnvFile(projectRoot);
env.set('MQTT_BROKER', 'localhost');
env.set('MQTT_PORT', '1883');
env.commit();
sink.logger.action('update').succeeded('.env,.env.example');
}