Server/project/src/tools/ItemTplGenerator/ItemTplGeneratorProgram.ts
DrakiaXYZ edfe995c52 Initial implementation of an ItemTpl and Weapon enum generator (!364)
ItemTplGenerator will create a full ItemTpl.ts and Weapons.ts file with all items and weapons respectively
Renamed WeaponTypes to Weapons to better indicate its new format
Updated all references to these enums to use the new names
New npm command `npm run gen:items` to run this tool

Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT/Server/pulls/364
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
2024-06-16 08:33:01 +00:00

45 lines
1.4 KiB
TypeScript

import "reflect-metadata";
import "source-map-support/register";
import { Lifecycle, container } from "tsyringe";
import { Container } from "@spt/di/Container";
import { ErrorHandler } from "@spt/ErrorHandler";
import { ItemTplGenerator } from "@spt/tools/ItemTplGenerator/ItemTplGenerator";
export class ItemTplGeneratorProgram
{
private errorHandler: ErrorHandler;
constructor()
{
// set window properties
process.stdout.setEncoding("utf8");
process.title = "SPT ItemTplGenerator";
this.errorHandler = new ErrorHandler();
}
public async start(): Promise<void>
{
try
{
Container.registerTypes(container);
const childContainer = container.createChildContainer();
childContainer.register<ItemTplGenerator>("ItemTplGenerator", ItemTplGenerator, {
lifecycle: Lifecycle.Singleton,
});
Container.registerListTypes(childContainer);
Container.registerPostLoadTypes(container, childContainer);
await childContainer.resolve<ItemTplGenerator>("ItemTplGenerator").run();
}
catch (err: any)
{
this.errorHandler.handleCriticalError(err instanceof Error ? err : new Error(err));
}
// Kill the process, something holds it open so we need to manually kill it
process.exit();
}
}
const program = new ItemTplGeneratorProgram();
program.start();