-
Notifications
You must be signed in to change notification settings - Fork 211
Expand file tree
/
Copy pathcli.ts
More file actions
44 lines (37 loc) · 1.52 KB
/
cli.ts
File metadata and controls
44 lines (37 loc) · 1.52 KB
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
/*
* Copyright © 2025 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/
import { NestFactory } from '@nestjs/core';
import moduleAlias from 'module-alias';
moduleAlias.addAliases({
'@': __dirname,
});
import { HexabotModule } from './app.module';
import { LoggerService } from './logger/logger.service';
import { MigrationCommand } from './migration/migration.command';
const ALLOWED_COMMANDS = ['migration'];
async function bootstrap() {
const [command, ...restArgs] = process.argv.slice(2);
const appContext = await NestFactory.createApplicationContext(HexabotModule, {
logger: false,
});
const logger = await appContext.resolve(LoggerService);
if (!ALLOWED_COMMANDS.includes(command)) {
logger.error(`unknown command '${command}'`);
process.exit(1);
} else if (command === 'migration') {
const migrationCommand = appContext.get(MigrationCommand);
try {
await migrationCommand.run(restArgs);
} catch (error) {
logger.error(`Migration command failed: ${error.message}`);
process.exit(1);
}
}
await appContext.close();
}
bootstrap();