mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 10:10:57 +00:00
chore: setup script
This commit is contained in:
7
apps/edr-freight-api/src/scripts/cmds/index.ts
Normal file
7
apps/edr-freight-api/src/scripts/cmds/index.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import type Vorpal from "vorpal";
|
||||
import type { CommandContext } from "./types";
|
||||
|
||||
export function registerCommands(_vorpal: Vorpal, _ctx: CommandContext): void {
|
||||
// Add more command registrations here:
|
||||
// registerMyNewCommand(vorpal, ctx);
|
||||
}
|
||||
6
apps/edr-freight-api/src/scripts/cmds/types.ts
Normal file
6
apps/edr-freight-api/src/scripts/cmds/types.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import type Vorpal from "vorpal";
|
||||
import type { INestApplicationContext } from "@nestjs/common";
|
||||
|
||||
export type CommandContext = {
|
||||
app: INestApplicationContext;
|
||||
};
|
||||
30
apps/edr-freight-api/src/scripts/main.ts
Normal file
30
apps/edr-freight-api/src/scripts/main.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import "reflect-metadata";
|
||||
import { config } from "dotenv";
|
||||
|
||||
config();
|
||||
|
||||
import Vorpal from "vorpal";
|
||||
import { registerCommands } from "./cmds/index";
|
||||
|
||||
import { NestFactory } from "@nestjs/core";
|
||||
import { AppModule } from "../app.module";
|
||||
|
||||
const vorpal = new Vorpal();
|
||||
|
||||
async function main() {
|
||||
const app = await NestFactory.createApplicationContext(AppModule, {
|
||||
logger: false,
|
||||
});
|
||||
|
||||
try {
|
||||
registerCommands(vorpal, { app });
|
||||
vorpal.parse(process.argv);
|
||||
} finally {
|
||||
await app.close();
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
console.error("Script failed:", err);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user