mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
chore: setup script
This commit is contained in:
@@ -32,7 +32,8 @@
|
||||
"iam:migration:revert": "pnpm run iam:typeorm:cli migration:revert",
|
||||
"iam:migration:show": "pnpm run iam:typeorm:cli migration:show",
|
||||
"iam:seed:run": "cross-env APP_MODULE_PATH=./dist/app.module dotenv -- node ./node_modules/@tria-plc/iamapi-common/dist/db/seed.cli.js",
|
||||
"migrate": "ts-node -r tsconfig-paths/register src/scripts/run-migrations.ts"
|
||||
"migrate": "ts-node -r tsconfig-paths/register src/scripts/run-migrations.ts",
|
||||
"script": "ts-node -r tsconfig-paths/register src/scripts/main.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@edr/api-common": "workspace:*",
|
||||
@@ -84,13 +85,15 @@
|
||||
"@types/node": "^20.14.0",
|
||||
"@types/pg": "^8.6.7",
|
||||
"@types/supertest": "^6.0.2",
|
||||
"@types/vorpal": "^1.12.8",
|
||||
"jest": "^29.7.0",
|
||||
"supertest": "^7.0.0",
|
||||
"ts-jest": "^29.2.5",
|
||||
"ts-loader": "^9.5.1",
|
||||
"ts-node": "^10.9.2",
|
||||
"tsconfig-paths": "^4.2.0",
|
||||
"typescript": "^5.5.4"
|
||||
"typescript": "^5.5.4",
|
||||
"vorpal": "^1.12.0"
|
||||
},
|
||||
"jest": {
|
||||
"moduleFileExtensions": [
|
||||
|
||||
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);
|
||||
});
|
||||
1020
pnpm-lock.yaml
generated
1020
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user