Fixed pretty much all the things that were triggering my OCD #28

Merged
chomp merged 6 commits from :random-fixes into 3.9.0-DEV 2024-05-20 15:45:36 -04:00
242 changed files with 1359 additions and 1553 deletions

View File

@ -8,4 +8,4 @@ Dive into a specific mod folder and follow the instructions in the `README.md` f
# Mod Upgrade Guide
Read [Here](https://hub.sp-tarkov.com/doc/entry/51-modding-in-2-4-0/)
Read [Here](https://hub.sp-tarkov.com/doc/entry/51-modding-in-spt-3-x-x/)

View File

@ -1,7 +1,8 @@
# Exclude these folders from linting
node_modules
dist/
types/
**/node_modules
/tmp
/dist
/types
# Exclude these filetypes from linting
*.json

View File

@ -47,7 +47,7 @@ Some resources to get you started:
## **Coding Guidelines**
Focus your mod development around the `mod.ts` file. In the `package.json` file, only alter these properties: `"name"`, `"version"`, `"license"`, `"author"`, and `"akiVersion"`.
Focus your mod development around the `mod.ts` file. In the `package.json` file, only alter these properties: `"name"`, `"version"`, `"akiVersion"`, `"loadBefore"`, `"loadAfter"`, `"incompatibilities"`, `"isBundleMod"`, `"author"`, and `"license"`.
New to Typescript? Find comprehensive documentation on the [official website](https://www.typescriptlang.org/docs/).

View File

@ -29,11 +29,10 @@
* @version v1.0.0
*/
import os from "node:os";
import path from "node:path";
import { fileURLToPath } from "node:url";
import fs from "fs-extra";
import os from "os";
import path from "path";
import { fileURLToPath } from "url";
import { dirname } from "path";
import ignore from "ignore";
import archiver from "archiver";
import winston from "winston";
@ -165,7 +164,7 @@ async function main() {
* @returns {string} The absolute path of the current working directory.
*/
function getCurrentDirectory() {
return dirname(fileURLToPath(import.meta.url));
return path.dirname(fileURLToPath(import.meta.url));
}
/**
@ -225,10 +224,9 @@ function createProjectName(packageJson) {
// Remove any non-alphanumeric characters from the author and name.
const author = packageJson.author.replace(/\W/g, "");
const name = packageJson.name.replace(/\W/g, "");
const version = packageJson.version;
// Ensure the name is lowercase, as per the package.json specification.
return `${author}-${name}-${version}`.toLowerCase();
return `${author}-${name}`.toLowerCase();
}
/**

View File

@ -1,12 +1,13 @@
{
"folders": [
{
"path": "."
}
],
"extensions": {
"recommendations": [
"dbaeumer.vscode-eslint"
]
}
"folders": [
{
"path": "."
}
],
"extensions": {
"recommendations": [
"dbaeumer.vscode-eslint",
"refringe.spt-id-highlighter"
]
}
}

View File

@ -1,14 +1,12 @@
{
"name": "ScopesAndTypes",
"version": "1.0.0",
"main": "src/mod.js",
"license": "MIT",
"author": "Chomp",
"akiVersion": "~3.9",
"loadBefore": [],
"loadAfter": [],
"incompatibilities": [],
"contributors": [],
"loadBefore": [],
"loadAfter": [],
"incompatibilities": [],
"isBundleMod": false,
"main": "src/mod.js",
"scripts": {
"setup": "npm i",
"build": "node ./build.mjs",
@ -22,9 +20,11 @@
"eslint": "8.57",
"fs-extra": "11.2",
"ignore": "^5.2",
"os": "^0.1",
"tsyringe": "4.8.0",
"typescript": "5.4",
"winston": "3.12"
}
},
"author": "Chomp",
"contributors": [],
"license": "MIT"
}

View File

@ -1,4 +1,5 @@
import { inject, injectable } from "tsyringe";
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
import { Processing } from "./Processing";
@ -11,7 +12,7 @@ export class MyMod
// All these types are automatically wired when the container resolves the bean creation
constructor(
@inject("Processing") private processing: Processing,
@inject("WinstonLogger") private logger: ILogger
@inject("WinstonLogger") private logger: ILogger,
)
{}

View File

@ -1,4 +1,5 @@
import { inject, injectable } from "tsyringe";
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
@injectable()
@ -9,7 +10,7 @@ export class Processing
private calls = 0;
constructor(
@inject("WinstonLogger") private logger: ILogger
@inject("WinstonLogger") private logger: ILogger,
)
{}

View File

@ -1,4 +1,5 @@
import { DependencyContainer, Lifecycle } from "tsyringe";
import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod";
import { IPostAkiLoadMod } from "@spt-aki/models/external/IPostAkiLoadMod";
import { MyMod } from "./MyMod";
@ -29,4 +30,4 @@ class Mod implements IPreAkiLoadMod, IPostAkiLoadMod
}
}
module.exports = { mod: new Mod() }
export const mod = new Mod();

View File

@ -11,8 +11,8 @@
"resolveJsonModule": true,
"outDir": "tmp",
"paths": {
"@spt-aki/*": [ "./types/*" ],
"@spt-aki/*": ["./types/*"],
},
},
"exclude": [ "node_modules", "dist", "tmp" ],
"exclude": ["node_modules", "dist", "tmp"],
}

View File

@ -1,7 +1,8 @@
# Exclude these folders from linting
node_modules
dist/
types/
**/node_modules
/tmp
/dist
/types
# Exclude these filetypes from linting
*.json

View File

@ -47,7 +47,7 @@ Some resources to get you started:
## **Coding Guidelines**
Focus your mod development around the `mod.ts` file. In the `package.json` file, only alter these properties: `"name"`, `"version"`, `"license"`, `"author"`, and `"akiVersion"`.
Focus your mod development around the `mod.ts` file. In the `package.json` file, only alter these properties: `"name"`, `"version"`, `"akiVersion"`, `"loadBefore"`, `"loadAfter"`, `"incompatibilities"`, `"isBundleMod"`, `"author"`, and `"license"`.
New to Typescript? Find comprehensive documentation on the [official website](https://www.typescriptlang.org/docs/).

View File

@ -29,11 +29,10 @@
* @version v1.0.0
*/
import os from "node:os";
import path from "node:path";
import { fileURLToPath } from "node:url";
import fs from "fs-extra";
import os from "os";
import path from "path";
import { fileURLToPath } from "url";
import { dirname } from "path";
import ignore from "ignore";
import archiver from "archiver";
import winston from "winston";
@ -165,7 +164,7 @@ async function main() {
* @returns {string} The absolute path of the current working directory.
*/
function getCurrentDirectory() {
return dirname(fileURLToPath(import.meta.url));
return path.dirname(fileURLToPath(import.meta.url));
}
/**
@ -225,10 +224,9 @@ function createProjectName(packageJson) {
// Remove any non-alphanumeric characters from the author and name.
const author = packageJson.author.replace(/\W/g, "");
const name = packageJson.name.replace(/\W/g, "");
const version = packageJson.version;
// Ensure the name is lowercase, as per the package.json specification.
return `${author}-${name}-${version}`.toLowerCase();
return `${author}-${name}`.toLowerCase();
}
/**

View File

@ -1,8 +1,8 @@
{
"manifest": [
{
"key": "assets/content/weapons/usable_items/item_bottle/textures/client_assets.bundle",
"dependencyKeys": []
}
]
"manifest": [
{
"key": "assets/content/weapons/usable_items/item_bottle/textures/client_assets.bundle",
"dependencyKeys": []
}
]
}

View File

@ -1,12 +1,13 @@
{
"folders": [
{
"path": "."
}
],
"extensions": {
"recommendations": [
"dbaeumer.vscode-eslint"
]
}
"folders": [
{
"path": "."
}
],
"extensions": {
"recommendations": [
"dbaeumer.vscode-eslint",
"refringe.spt-id-highlighter"
]
}
}

View File

@ -1,15 +1,12 @@
{
"name": "BundleLoading",
"version": "1.0.0",
"author": "Chomp",
"license": "MIT",
"main": "src/mod.js",
"isBundleMod": true,
"name": "BundleLoading",
"version": "1.0.0",
"akiVersion": "~3.9",
"loadBefore": [],
"loadAfter": [],
"incompatibilities": [],
"contributors": [],
"loadBefore": [],
"loadAfter": [],
"incompatibilities": [],
"isBundleMod": true,
"main": "src/mod.js",
"scripts": {
"setup": "npm i",
"build": "node ./build.mjs",
@ -23,9 +20,11 @@
"eslint": "8.57",
"fs-extra": "11.2",
"ignore": "^5.2",
"os": "^0.1",
"tsyringe": "4.8.0",
"typescript": "5.4",
"winston": "3.12"
}
},
"author": "Chomp",
"contributors": [],
"license": "MIT"
}

View File

@ -1,4 +1,5 @@
import { DependencyContainer } from "tsyringe";
import { IPostAkiLoadMod } from "@spt-aki/models/external/IPostAkiLoadMod";
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
@ -6,11 +7,11 @@ class Mod implements IPostAkiLoadMod
{
public postAkiLoad(container: DependencyContainer): void
{
// get the logger from the server container
// get the logger from the server container
const logger = container.resolve<ILogger>("WinstonLogger");
logger.info("Loading: Bundle Loading Sample");
}
}
}
module.exports = { mod: new Mod() }
export const mod = new Mod();

View File

@ -11,8 +11,8 @@
"resolveJsonModule": true,
"outDir": "tmp",
"paths": {
"@spt-aki/*": [ "./types/*" ],
"@spt-aki/*": ["./types/*"],
},
},
"exclude": [ "node_modules", "dist", "tmp" ],
"exclude": ["node_modules", "dist", "tmp"],
}

View File

@ -1,7 +1,8 @@
# Exclude these folders from linting
node_modules
dist/
types/
**/node_modules
/tmp
/dist
/types
# Exclude these filetypes from linting
*.json

View File

@ -47,7 +47,7 @@ Some resources to get you started:
## **Coding Guidelines**
Focus your mod development around the `mod.ts` file. In the `package.json` file, only alter these properties: `"name"`, `"version"`, `"license"`, `"author"`, and `"akiVersion"`.
Focus your mod development around the `mod.ts` file. In the `package.json` file, only alter these properties: `"name"`, `"version"`, `"akiVersion"`, `"loadBefore"`, `"loadAfter"`, `"incompatibilities"`, `"isBundleMod"`, `"author"`, and `"license"`.
New to Typescript? Find comprehensive documentation on the [official website](https://www.typescriptlang.org/docs/).

View File

@ -29,11 +29,10 @@
* @version v1.0.0
*/
import os from "node:os";
import path from "node:path";
import { fileURLToPath } from "node:url";
import fs from "fs-extra";
import os from "os";
import path from "path";
import { fileURLToPath } from "url";
import { dirname } from "path";
import ignore from "ignore";
import archiver from "archiver";
import winston from "winston";
@ -165,7 +164,7 @@ async function main() {
* @returns {string} The absolute path of the current working directory.
*/
function getCurrentDirectory() {
return dirname(fileURLToPath(import.meta.url));
return path.dirname(fileURLToPath(import.meta.url));
}
/**
@ -225,10 +224,9 @@ function createProjectName(packageJson) {
// Remove any non-alphanumeric characters from the author and name.
const author = packageJson.author.replace(/\W/g, "");
const name = packageJson.name.replace(/\W/g, "");
const version = packageJson.version;
// Ensure the name is lowercase, as per the package.json specification.
return `${author}-${name}-${version}`.toLowerCase();
return `${author}-${name}`.toLowerCase();
}
/**

View File

@ -1,12 +1,13 @@
{
"folders": [
{
"path": "."
}
],
"extensions": {
"recommendations": [
"dbaeumer.vscode-eslint"
]
}
"folders": [
{
"path": "."
}
],
"extensions": {
"recommendations": [
"dbaeumer.vscode-eslint",
"refringe.spt-id-highlighter"
]
}
}

View File

@ -1,14 +1,12 @@
{
"name": "ClassExtensionOverride",
"version": "1.0.0",
"main": "src/mod.js",
"license": "MIT",
"author": "Chomp",
"akiVersion": "~3.9",
"loadBefore": [],
"loadAfter": [],
"incompatibilities": [],
"contributors": [],
"loadBefore": [],
"loadAfter": [],
"incompatibilities": [],
"isBundleMod": false,
"main": "src/mod.js",
"scripts": {
"setup": "npm i",
"build": "node ./build.mjs",
@ -22,9 +20,11 @@
"eslint": "8.57",
"fs-extra": "11.2",
"ignore": "^5.2",
"os": "^0.1",
"tsyringe": "4.8.0",
"typescript": "5.4",
"winston": "3.12"
}
},
"author": "Chomp",
"contributors": [],
"license": "MIT"
}

View File

@ -1,3 +1,5 @@
import { inject, injectable } from "tsyringe";
import { LauncherCallbacks } from "@spt-aki/callbacks/LauncherCallbacks";
import { LauncherController } from "@spt-aki/controllers/LauncherController";
import { IEmptyRequestData } from "@spt-aki/models/eft/common/IEmptyRequestData";
@ -5,7 +7,6 @@ import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
import { SaveServer } from "@spt-aki/servers/SaveServer";
import { HttpResponseUtil } from "@spt-aki/utils/HttpResponseUtil";
import { Watermark } from "@spt-aki/utils/Watermark";
import { inject, injectable } from "tsyringe";
// We need to declare this class as injectable, this will add the container
// metadata
@ -15,12 +16,12 @@ export class MyCustomLauncherCallbacks extends LauncherCallbacks // <<<<=== This
{
// We need to make sure we use the constructor and pass the dependencies to the parent class!
constructor(
// @inject() will make sure to find the component with the right token and put them there
@inject("HttpResponseUtil") httpResponse: HttpResponseUtil,
// @inject() will make sure to find the component with the right token and put them there
@inject("HttpResponseUtil") httpResponse: HttpResponseUtil,
@inject("LauncherController") launcherController: LauncherController,
@inject("SaveServer") saveServer: SaveServer,
@inject("Watermark") watermark: Watermark,
@inject("WinstonLogger") private logger: ILogger
@inject("WinstonLogger") private logger: ILogger,
)
{
// Pass the parent class (LauncherCallbacks) the dependencies it needs to work
@ -39,5 +40,4 @@ export class MyCustomLauncherCallbacks extends LauncherCallbacks // <<<<=== This
this.logger.success("Our custom method is dancing baby!");
return "Lets dance";
}
}

View File

@ -1,4 +1,5 @@
import { DependencyContainer } from "tsyringe";
import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod"
import { MyCustomLauncherCallbacks } from "./MyCustomLauncherCallbacks";
@ -18,15 +19,14 @@ class Mod implements IPreAkiLoadMod
// https://dev.sp-tarkov.com/SPT-AKI/Server/src/branch/development/project/src/di/Container.ts
// In this scenario we want to override LauncherCallbacks, so we find the proper registry:
//
// depContainer.register<LauncherCallbacks>("LauncherCallbacks", {useClass: LauncherCallbacks});
// depContainer.register<LauncherCallbacks>("LauncherCallbacks", { useClass: LauncherCallbacks });
//
// So what we want to do is register it with EXACTLY the same token
container.register<MyCustomLauncherCallbacks>("MyCustomLauncherCallbacks", MyCustomLauncherCallbacks);
container.register("LauncherCallbacks", {useToken: "MyCustomLauncherCallbacks"});
container.register("LauncherCallbacks", { useToken: "MyCustomLauncherCallbacks" });
// Now that its registered, the server will automatically find this dependency and use it where ever its needed
}
}
module.exports = { mod: new Mod() }
export const mod = new Mod();

View File

@ -11,8 +11,8 @@
"resolveJsonModule": true,
"outDir": "tmp",
"paths": {
"@spt-aki/*": [ "./types/*" ],
"@spt-aki/*": ["./types/*"],
},
},
"exclude": [ "node_modules", "dist", "tmp" ],
"exclude": ["node_modules", "dist", "tmp"],
}

View File

@ -1,7 +1,8 @@
# Exclude these folders from linting
node_modules
dist/
types/
**/node_modules
/tmp
/dist
/types
# Exclude these filetypes from linting
*.json

View File

@ -47,7 +47,7 @@ Some resources to get you started:
## **Coding Guidelines**
Focus your mod development around the `mod.ts` file. In the `package.json` file, only alter these properties: `"name"`, `"version"`, `"license"`, `"author"`, and `"akiVersion"`.
Focus your mod development around the `mod.ts` file. In the `package.json` file, only alter these properties: `"name"`, `"version"`, `"akiVersion"`, `"loadBefore"`, `"loadAfter"`, `"incompatibilities"`, `"isBundleMod"`, `"author"`, and `"license"`.
New to Typescript? Find comprehensive documentation on the [official website](https://www.typescriptlang.org/docs/).

View File

@ -29,11 +29,10 @@
* @version v1.0.0
*/
import os from "node:os";
import path from "node:path";
import { fileURLToPath } from "node:url";
import fs from "fs-extra";
import os from "os";
import path from "path";
import { fileURLToPath } from "url";
import { dirname } from "path";
import ignore from "ignore";
import archiver from "archiver";
import winston from "winston";
@ -165,7 +164,7 @@ async function main() {
* @returns {string} The absolute path of the current working directory.
*/
function getCurrentDirectory() {
return dirname(fileURLToPath(import.meta.url));
return path.dirname(fileURLToPath(import.meta.url));
}
/**
@ -225,10 +224,9 @@ function createProjectName(packageJson) {
// Remove any non-alphanumeric characters from the author and name.
const author = packageJson.author.replace(/\W/g, "");
const name = packageJson.name.replace(/\W/g, "");
const version = packageJson.version;
// Ensure the name is lowercase, as per the package.json specification.
return `${author}-${name}-${version}`.toLowerCase();
return `${author}-${name}`.toLowerCase();
}
/**

View File

@ -1,12 +1,13 @@
{
"folders": [
{
"path": "."
}
],
"extensions": {
"recommendations": [
"dbaeumer.vscode-eslint"
]
}
"folders": [
{
"path": "."
}
],
"extensions": {
"recommendations": [
"dbaeumer.vscode-eslint",
"refringe.spt-id-highlighter"
]
}
}

View File

@ -1,14 +1,12 @@
{
"name": "13AddTrader",
"version": "1.0.0",
"main": "src/mod.js",
"license": "MIT",
"author": "Shirito",
"akiVersion": "~3.9",
"loadBefore": [],
"loadAfter": [],
"incompatibilities": [],
"contributors": [],
"loadBefore": [],
"loadAfter": [],
"incompatibilities": [],
"isBundleMod": false,
"main": "src/mod.js",
"scripts": {
"setup": "npm i",
"build": "node ./build.mjs",
@ -22,9 +20,11 @@
"eslint": "8.57",
"fs-extra": "11.2",
"ignore": "^5.2",
"os": "^0.1",
"tsyringe": "4.8.0",
"typescript": "5.4",
"winston": "3.12"
}
},
"author": "Shirito",
"contributors": [],
"license": "MIT"
}

View File

@ -23,18 +23,18 @@ export class FluentAssortConstructor
* @param itemTpl Tpl id of the item you want trader to sell
* @param itemId Optional - set your own Id, otherwise unique id will be generated
*/
public createSingleAssortItem(itemTpl: string, itemId = undefined): FluentAssortConstructor
public createSingleAssortItem(itemTpl: string, itemId: string = undefined): FluentAssortConstructor
{
// Create item ready for insertion into assort table
const newItemToAdd: Item = {
_id: !itemId ? this.hashUtil.generate(): itemId,
_id: itemId ?? this.hashUtil.generate(),
_tpl: itemTpl,
parentId: "hideout", // Should always be "hideout"
slotId: "hideout", // Should always be "hideout"
upd: {
UnlimitedCount: false,
StackObjectsCount: 100
}
StackObjectsCount: 100,
},
};
this.itemsToSell.push(newItemToAdd);
@ -47,10 +47,7 @@ export class FluentAssortConstructor
items[0].parentId = "hideout";
items[0].slotId = "hideout";
if (!items[0].upd)
{
items[0].upd = {}
}
items[0].upd ??= {};
items[0].upd.UnlimitedCount = false;
items[0].upd.StackObjectsCount = 100;
@ -99,14 +96,12 @@ export class FluentAssortConstructor
public addMoneyCost(currencyType: Money, amount: number): FluentAssortConstructor
{
this.barterScheme[this.itemsToSell[0]._id] = [
[
{
count: amount,
_tpl: currencyType
}
]
];
this.barterScheme[this.itemsToSell[0]._id] = [[
{
count: amount,
_tpl: currencyType,
},
]];
return this;
}
@ -121,8 +116,8 @@ export class FluentAssortConstructor
this.barterScheme[sellableItemId] = [[
{
count: count,
_tpl: itemTpl
}
_tpl: itemTpl,
},
]];
}
else
@ -139,10 +134,9 @@ export class FluentAssortConstructor
// No barter for item, add it fresh
this.barterScheme[sellableItemId][0].push({
count: count,
_tpl: itemTpl
})
_tpl: itemTpl,
});
}
}
return this;

View File

@ -12,21 +12,22 @@ import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
import { ITraderConfig } from "@spt-aki/models/spt/config/ITraderConfig";
import { IRagfairConfig } from "@spt-aki/models/spt/config/IRagfairConfig";
import { JsonUtil } from "@spt-aki/utils/JsonUtil";
// New trader settings
import * as baseJson from "../db/base.json";
import { TraderHelper } from "./traderHelpers";
import { FluentAssortConstructor as FluentAssortCreator } from "./fluentTraderAssortCreator";
import { Money } from "@spt-aki/models/enums/Money";
import { Traders } from "@spt-aki/models/enums/Traders";
import { HashUtil } from "@spt-aki/utils/HashUtil";
// New trader settings
import * as baseJson from "../db/base.json";
import { TraderHelper } from "./traderHelpers";
import { FluentAssortConstructor as FluentAssortCreator } from "./fluentTraderAssortCreator";
class SampleTrader implements IPreAkiLoadMod, IPostDBLoadMod
{
private mod: string
private logger: ILogger
private traderHelper: TraderHelper
private fluentAssortCreator: FluentAssortCreator
private mod: string;
private logger: ILogger;
private traderHelper: TraderHelper;
private fluentAssortCreator: FluentAssortCreator;
constructor() {
this.mod = "13AddTrader"; // Set name of mod so we can log it to console later
@ -86,39 +87,43 @@ class SampleTrader implements IPreAkiLoadMod, IPostDBLoadMod
// Add milk
const MILK_ID = "575146b724597720a27126d5"; // Can find item ids in `database\templates\items.json` or with https://db.sp-tarkov.com/search
this.fluentAssortCreator.createSingleAssortItem(MILK_ID)
.addStackCount(200)
.addBuyRestriction(10)
.addMoneyCost(Money.ROUBLES, 2000)
.addLoyaltyLevel(1)
.export(tables.traders[baseJson._id]);
this.fluentAssortCreator
.createSingleAssortItem(MILK_ID)
.addStackCount(200)
.addBuyRestriction(10)
.addMoneyCost(Money.ROUBLES, 2000)
.addLoyaltyLevel(1)
.export(tables.traders[baseJson._id]);
// Add 3x bitcoin + salewa for milk barter
const BITCOIN_ID = "59faff1d86f7746c51718c9c"
const BITCOIN_ID = "59faff1d86f7746c51718c9c";
const SALEWA_ID = "544fb45d4bdc2dee738b4568";
this.fluentAssortCreator.createSingleAssortItem(MILK_ID)
.addStackCount(100)
.addBarterCost(BITCOIN_ID, 3)
.addBarterCost(SALEWA_ID, 1)
.addLoyaltyLevel(1)
.export(tables.traders[baseJson._id]);
this.fluentAssortCreator
.createSingleAssortItem(MILK_ID)
.addStackCount(100)
.addBarterCost(BITCOIN_ID, 3)
.addBarterCost(SALEWA_ID, 1)
.addLoyaltyLevel(1)
.export(tables.traders[baseJson._id]);
// Add glock as money purchase
this.fluentAssortCreator.createComplexAssortItem(this.traderHelper.createGlock())
.addUnlimitedStackCount()
.addMoneyCost(Money.ROUBLES, 20000)
.addBuyRestriction(3)
.addLoyaltyLevel(1)
.export(tables.traders[baseJson._id]);
this.fluentAssortCreator
.createComplexAssortItem(this.traderHelper.createGlock())
.addUnlimitedStackCount()
.addMoneyCost(Money.ROUBLES, 20000)
.addBuyRestriction(3)
.addLoyaltyLevel(1)
.export(tables.traders[baseJson._id]);
// Add mp133 preset as mayo barter
this.fluentAssortCreator.createComplexAssortItem(tables.globals.ItemPresets["584148f2245977598f1ad387"]._items)
.addStackCount(200)
.addBarterCost("5bc9b156d4351e00367fbce9", 1)
.addBuyRestriction(3)
.addLoyaltyLevel(1)
.export(tables.traders[baseJson._id]);
this.fluentAssortCreator
.createComplexAssortItem(tables.globals.ItemPresets["584148f2245977598f1ad387"]._items)
.addStackCount(200)
.addBarterCost("5bc9b156d4351e00367fbce9", 1)
.addBuyRestriction(3)
.addLoyaltyLevel(1)
.export(tables.traders[baseJson._id]);
// Add trader to locale file, ensures trader text shows properly on screen
// WARNING: adds the same text to ALL locales (e.g. chinese/french/english)
@ -128,4 +133,4 @@ class SampleTrader implements IPreAkiLoadMod, IPostDBLoadMod
}
}
module.exports = { mod: new SampleTrader() }
export const mod = new SampleTrader();

View File

@ -11,6 +11,7 @@ export class TraderHelper
/**
* Add profile picture to our trader
* @param baseJson json file for trader (db/base.json)
* @param modName mod folder name
* @param preAkiModLoader mod loader class - used to get the mods file path
* @param imageRouter image router class - used to register the trader image path so we see their image on trader page
* @param traderImageName Filename of the trader icon to use
@ -38,8 +39,9 @@ export class TraderHelper
traderId: baseJson._id,
seconds: {
min: refreshTimeSecondsMin,
max: refreshTimeSecondsMax
} };
max: refreshTimeSecondsMax,
},
};
traderConfig.updateTime.push(traderRefreshRecord);
}
@ -60,15 +62,13 @@ export class TraderHelper
questassort: {
started: {},
success: {},
fail: {}
} // questassort is empty as trader has no assorts unlocked by quests
fail: {},
}, // questassort is empty as trader has no assorts unlocked by quests
};
}
/**
* Create basic data for trader + add empty assorts table for trader
* @param tables SPT db
* @param jsonUtil SPT JSON utility class
* @returns ITraderAssort
*/
private createAssortTable(): ITraderAssort
@ -78,8 +78,8 @@ export class TraderHelper
nextResupply: 0,
items: [],
barter_scheme: {},
loyal_level_items: {}
}
loyal_level_items: {},
};
return assortTable;
}
@ -96,7 +96,7 @@ export class TraderHelper
// Add the base first
glock.push({ // Add the base weapon first
_id: "glockBase", // Ids dont matter, as long as they are unique (can use hashUtil.generate() if you dont want to type every id by hand)
_tpl: "5a7ae0c351dfba0017554310" // This is the weapons tpl, found on: https://db.sp-tarkov.com/search
_tpl: "5a7ae0c351dfba0017554310", // This is the weapons tpl, found on: https://db.sp-tarkov.com/search
});
// Add barrel
@ -104,7 +104,7 @@ export class TraderHelper
_id: "glockbarrel",
_tpl: "5a6b60158dc32e000a31138b",
parentId: "glockBase", // This is a sub item, you need to define its parent its attached to / inserted into
slotId: "mod_barrel" // Required for mods, you need to define what 'role' they have
slotId: "mod_barrel", // Required for mods, you need to define what 'role' they have
});
// Add reciever
@ -112,7 +112,7 @@ export class TraderHelper
_id: "glockReciever",
_tpl:"5a9685b1a2750c0032157104",
parentId: "glockBase",
slotId: "mod_reciever"
slotId: "mod_reciever",
});
// Add compensator
@ -120,7 +120,7 @@ export class TraderHelper
_id: "glockCompensator",
_tpl:"5a7b32a2e899ef00135e345a",
parentId: "glockReciever", // The parent of this mod is the reciever NOT weapon, be careful to get the correct parent
slotId: "mod_muzzle"
slotId: "mod_muzzle",
});
// Add Pistol grip
@ -128,7 +128,7 @@ export class TraderHelper
_id: "glockPistolGrip",
_tpl:"5a7b4960e899ef197b331a2d",
parentId: "glockBase",
slotId: "mod_pistol_grip"
slotId: "mod_pistol_grip",
});
// Add front sight
@ -136,7 +136,7 @@ export class TraderHelper
_id: "glockRearSight",
_tpl: "5a6f5d528dc32e00094b97d9",
parentId: "glockReciever",
slotId: "mod_sight_rear"
slotId: "mod_sight_rear",
});
// Add rear sight
@ -144,7 +144,7 @@ export class TraderHelper
_id: "glockFrontSight",
_tpl: "5a6f58f68dc32e000a311390",
parentId: "glockReciever",
slotId: "mod_sight_front"
slotId: "mod_sight_front",
});
// Add magazine
@ -152,7 +152,7 @@ export class TraderHelper
_id: "glockMagazine",
_tpl: "630769c4962d0247b029dc60",
parentId: "glockBase",
slotId: "mod_magazine"
slotId: "mod_magazine",
});
return glock;
@ -171,7 +171,8 @@ export class TraderHelper
public addTraderToLocales(baseJson: any, tables: IDatabaseTables, fullName: string, firstName: string, nickName: string, location: string, description: string)
{
// For each language, add locale for the new trader
const locales = Object.values(tables.locales.global) as Record<string, string>[];
const locales = Object.values(tables.locales.global);
for (const locale of locales) {
locale[`${baseJson._id} FullName`] = fullName;
locale[`${baseJson._id} FirstName`] = firstName;

View File

@ -11,8 +11,8 @@
"resolveJsonModule": true,
"outDir": "tmp",
"paths": {
"@spt-aki/*": [ "./types/*" ],
"@spt-aki/*": ["./types/*"],
},
},
"exclude": [ "node_modules", "dist", "tmp" ],
"exclude": ["node_modules", "dist", "tmp"],
}

View File

@ -1,7 +1,8 @@
# Exclude these folders from linting
node_modules
dist/
types/
**/node_modules
/tmp
/dist
/types
# Exclude these filetypes from linting
*.json

View File

@ -47,7 +47,7 @@ Some resources to get you started:
## **Coding Guidelines**
Focus your mod development around the `mod.ts` file. In the `package.json` file, only alter these properties: `"name"`, `"version"`, `"license"`, `"author"`, and `"akiVersion"`.
Focus your mod development around the `mod.ts` file. In the `package.json` file, only alter these properties: `"name"`, `"version"`, `"akiVersion"`, `"loadBefore"`, `"loadAfter"`, `"incompatibilities"`, `"isBundleMod"`, `"author"`, and `"license"`.
New to Typescript? Find comprehensive documentation on the [official website](https://www.typescriptlang.org/docs/).

View File

@ -29,11 +29,10 @@
* @version v1.0.0
*/
import os from "node:os";
import path from "node:path";
import { fileURLToPath } from "node:url";
import fs from "fs-extra";
import os from "os";
import path from "path";
import { fileURLToPath } from "url";
import { dirname } from "path";
import ignore from "ignore";
import archiver from "archiver";
import winston from "winston";
@ -165,7 +164,7 @@ async function main() {
* @returns {string} The absolute path of the current working directory.
*/
function getCurrentDirectory() {
return dirname(fileURLToPath(import.meta.url));
return path.dirname(fileURLToPath(import.meta.url));
}
/**
@ -225,10 +224,9 @@ function createProjectName(packageJson) {
// Remove any non-alphanumeric characters from the author and name.
const author = packageJson.author.replace(/\W/g, "");
const name = packageJson.name.replace(/\W/g, "");
const version = packageJson.version;
// Ensure the name is lowercase, as per the package.json specification.
return `${author}-${name}-${version}`.toLowerCase();
return `${author}-${name}`.toLowerCase();
}
/**

View File

@ -1,12 +1,13 @@
{
"folders": [
{
"path": "."
}
],
"extensions": {
"recommendations": [
"dbaeumer.vscode-eslint"
]
}
"folders": [
{
"path": "."
}
],
"extensions": {
"recommendations": [
"dbaeumer.vscode-eslint",
"refringe.spt-id-highlighter"
]
}
}

View File

@ -1,14 +1,12 @@
{
"name": "AfterDBLoadHook",
"version": "1.0.0",
"main": "src/mod.js",
"license": "MIT",
"author": "Chomp",
"akiVersion": "~3.9",
"loadBefore": [],
"loadAfter": [],
"incompatibilities": [],
"contributors": [],
"loadBefore": [],
"loadAfter": [],
"incompatibilities": [],
"isBundleMod": false,
"main": "src/mod.js",
"scripts": {
"setup": "npm i",
"build": "node ./build.mjs",
@ -22,9 +20,11 @@
"eslint": "8.57",
"fs-extra": "11.2",
"ignore": "^5.2",
"os": "^0.1",
"tsyringe": "4.8.0",
"typescript": "5.4",
"winston": "3.12"
}
},
"author": "Chomp",
"contributors": [],
"license": "MIT"
}

View File

@ -47,4 +47,4 @@ class Mod implements IPreAkiLoadMod, IPostAkiLoadMod, IPostDBLoadMod
}
}
module.exports = { mod: new Mod() }
export const mod = new Mod();

View File

@ -11,8 +11,8 @@
"resolveJsonModule": true,
"outDir": "tmp",
"paths": {
"@spt-aki/*": [ "./types/*" ],
"@spt-aki/*": ["./types/*"],
},
},
"exclude": [ "node_modules", "dist", "tmp" ],
"exclude": ["node_modules", "dist", "tmp"],
}

View File

@ -1,7 +1,8 @@
# Exclude these folders from linting
node_modules
dist/
types/
**/node_modules
/tmp
/dist
/types
# Exclude these filetypes from linting
*.json

View File

@ -47,7 +47,7 @@ Some resources to get you started:
## **Coding Guidelines**
Focus your mod development around the `mod.ts` file. In the `package.json` file, only alter these properties: `"name"`, `"version"`, `"license"`, `"author"`, and `"akiVersion"`.
Focus your mod development around the `mod.ts` file. In the `package.json` file, only alter these properties: `"name"`, `"version"`, `"akiVersion"`, `"loadBefore"`, `"loadAfter"`, `"incompatibilities"`, `"isBundleMod"`, `"author"`, and `"license"`.
New to Typescript? Find comprehensive documentation on the [official website](https://www.typescriptlang.org/docs/).

View File

@ -29,11 +29,10 @@
* @version v1.0.0
*/
import os from "node:os";
import path from "node:path";
import { fileURLToPath } from "node:url";
import fs from "fs-extra";
import os from "os";
import path from "path";
import { fileURLToPath } from "url";
import { dirname } from "path";
import ignore from "ignore";
import archiver from "archiver";
import winston from "winston";
@ -165,7 +164,7 @@ async function main() {
* @returns {string} The absolute path of the current working directory.
*/
function getCurrentDirectory() {
return dirname(fileURLToPath(import.meta.url));
return path.dirname(fileURLToPath(import.meta.url));
}
/**
@ -225,10 +224,9 @@ function createProjectName(packageJson) {
// Remove any non-alphanumeric characters from the author and name.
const author = packageJson.author.replace(/\W/g, "");
const name = packageJson.name.replace(/\W/g, "");
const version = packageJson.version;
// Ensure the name is lowercase, as per the package.json specification.
return `${author}-${name}-${version}`.toLowerCase();
return `${author}-${name}`.toLowerCase();
}
/**

View File

@ -1,12 +1,13 @@
{
"folders": [
{
"path": "."
}
],
"extensions": {
"recommendations": [
"dbaeumer.vscode-eslint"
]
}
"folders": [
{
"path": "."
}
],
"extensions": {
"recommendations": [
"dbaeumer.vscode-eslint",
"refringe.spt-id-highlighter"
]
}
}

View File

@ -1,14 +1,12 @@
{
"name": "HttpListenerExample",
"version": "1.0.0",
"main": "src/mod.js",
"license": "MIT",
"author": "Alex",
"akiVersion": "~3.9",
"loadBefore": [],
"loadAfter": [],
"incompatibilities": [],
"contributors": [],
"loadBefore": [],
"loadAfter": [],
"incompatibilities": [],
"isBundleMod": false,
"main": "src/mod.js",
"scripts": {
"setup": "npm i",
"build": "node ./build.mjs",
@ -22,9 +20,11 @@
"eslint": "8.57",
"fs-extra": "11.2",
"ignore": "^5.2",
"os": "^0.1",
"tsyringe": "4.8.0",
"typescript": "5.4",
"winston": "3.12"
}
},
"author": "clodan",
"contributors": [],
"license": "MIT"
}

View File

@ -1,5 +1,6 @@
import { IncomingMessage, ServerResponse } from "node:http";
import { IHttpListener } from "@spt-aki/servers/http/IHttpListener";
import { IncomingMessage, ServerResponse } from "http";
export class Type2HttpListener implements IHttpListener
{
@ -7,10 +8,10 @@ export class Type2HttpListener implements IHttpListener
{
return req.method === "GET" && req.url?.includes("/type2-custom-url");
}
public handle(sessionId: string, req: IncomingMessage, resp: ServerResponse): void
public async handle(sessionId: string, req: IncomingMessage, resp: ServerResponse): Promise<void>
{
resp.writeHead(200, "OK");
resp.end("[2] This is the second example of a mod hooking into the HttpServer");
}
}

View File

@ -1,7 +1,8 @@
import { IncomingMessage, ServerResponse } from "node:http";
import { DependencyContainer } from "tsyringe";
import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod";
import { HttpListenerModService } from "@spt-aki/services/mod/httpListener/HttpListenerModService";
import { IncomingMessage, ServerResponse } from "http";
import { Type2HttpListener } from "./Type2HttpListener";
class Mod implements IPreAkiLoadMod
@ -28,4 +29,4 @@ class Mod implements IPreAkiLoadMod
}
}
module.exports = { mod: new Mod() }
export const mod = new Mod();

View File

@ -11,8 +11,8 @@
"resolveJsonModule": true,
"outDir": "tmp",
"paths": {
"@spt-aki/*": [ "./types/*" ],
"@spt-aki/*": ["./types/*"],
},
},
"exclude": [ "node_modules", "dist", "tmp" ],
"exclude": ["node_modules", "dist", "tmp"],
}

View File

@ -1,7 +1,8 @@
# Exclude these folders from linting
node_modules
dist/
types/
**/node_modules
/tmp
/dist
/types
# Exclude these filetypes from linting
*.json

View File

@ -47,7 +47,7 @@ Some resources to get you started:
## **Coding Guidelines**
Focus your mod development around the `mod.ts` file. In the `package.json` file, only alter these properties: `"name"`, `"version"`, `"license"`, `"author"`, and `"akiVersion"`.
Focus your mod development around the `mod.ts` file. In the `package.json` file, only alter these properties: `"name"`, `"version"`, `"akiVersion"`, `"loadBefore"`, `"loadAfter"`, `"incompatibilities"`, `"isBundleMod"`, `"author"`, and `"license"`.
New to Typescript? Find comprehensive documentation on the [official website](https://www.typescriptlang.org/docs/).

View File

@ -29,11 +29,10 @@
* @version v1.0.0
*/
import os from "node:os";
import path from "node:path";
import { fileURLToPath } from "node:url";
import fs from "fs-extra";
import os from "os";
import path from "path";
import { fileURLToPath } from "url";
import { dirname } from "path";
import ignore from "ignore";
import archiver from "archiver";
import winston from "winston";
@ -165,7 +164,7 @@ async function main() {
* @returns {string} The absolute path of the current working directory.
*/
function getCurrentDirectory() {
return dirname(fileURLToPath(import.meta.url));
return path.dirname(fileURLToPath(import.meta.url));
}
/**
@ -225,10 +224,9 @@ function createProjectName(packageJson) {
// Remove any non-alphanumeric characters from the author and name.
const author = packageJson.author.replace(/\W/g, "");
const name = packageJson.name.replace(/\W/g, "");
const version = packageJson.version;
// Ensure the name is lowercase, as per the package.json specification.
return `${author}-${name}-${version}`.toLowerCase();
return `${author}-${name}`.toLowerCase();
}
/**

View File

@ -1,3 +1,3 @@
{
"myProperty": "wow"
"myProperty": "wow"
}

View File

@ -1,3 +1,3 @@
{
"myProperty": "wow inside db"
"myProperty": "wow inside db"
}

View File

@ -1,3 +1,3 @@
{
"myProperty": "wow inside db inside moredb"
"myProperty": "wow inside db inside moredb"
}

View File

@ -1,12 +1,13 @@
{
"folders": [
{
"path": "."
}
],
"extensions": {
"recommendations": [
"dbaeumer.vscode-eslint"
]
}
"folders": [
{
"path": "."
}
],
"extensions": {
"recommendations": [
"dbaeumer.vscode-eslint",
"refringe.spt-id-highlighter"
]
}
}

View File

@ -1,14 +1,12 @@
{
"name": "ImporterUtil",
"version": "1.0.0",
"main": "src/mod.js",
"license": "MIT",
"author": "Chomp",
"akiVersion": "~3.9",
"loadBefore": [],
"loadAfter": [],
"incompatibilities": [],
"contributors": [],
"loadBefore": [],
"loadAfter": [],
"incompatibilities": [],
"isBundleMod": false,
"main": "src/mod.js",
"scripts": {
"setup": "npm i",
"build": "node ./build.mjs",
@ -22,9 +20,11 @@
"eslint": "8.57",
"fs-extra": "11.2",
"ignore": "^5.2",
"os": "^0.1",
"tsyringe": "4.8.0",
"typescript": "5.4",
"winston": "3.12"
}
},
"author": "Chomp",
"contributors": [],
"license": "MIT"
}

View File

@ -1,25 +1,26 @@
import { DependencyContainer } from "tsyringe";
import { PreAkiModLoader } from "@spt-aki/loaders/PreAkiModLoader";
import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod";
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
import { ImporterUtil } from "@spt-aki/utils/ImporterUtil";
import { DependencyContainer } from "tsyringe";
import { ConfigsModelBase } from "./model/ConfigsModel";
class Mod implements IPreAkiLoadMod {
public preAkiLoad(container: DependencyContainer): void {
// get logger
const logger = container.resolve<ILogger>("WinstonLogger");
public preAkiLoad(container: DependencyContainer): void {
// get logger
const logger = container.resolve<ILogger>("WinstonLogger");
const importerUtil = container.resolve<ImporterUtil>("ImporterUtil");
const modImporter = container.resolve<PreAkiModLoader>("PreAkiModLoader");
const path = modImporter.getModPath("16ImporterUtil");
const importerUtil = container.resolve<ImporterUtil>("ImporterUtil");
const modImporter = container.resolve<PreAkiModLoader>("PreAkiModLoader");
const path = modImporter.getModPath("16ImporterUtil");
const configPath = `${path}config/`;
const configs = importerUtil.loadRecursive<ConfigsModelBase>(configPath);
logger.info(
`16ImporterUtil Configurations found: ${JSON.stringify(configs)}`,
);
}
const configPath = `${path}config/`;
const configs = importerUtil.loadRecursive<ConfigsModelBase>(configPath);
logger.info(
`16ImporterUtil Configurations found: ${JSON.stringify(configs)}`,
);
}
}
module.exports = { mod: new Mod() };
export const mod = new Mod();

View File

@ -1,17 +1,17 @@
export class ConfigsModelBase {
db: ConfigsModelDb;
config: ConfigModel;
db: ConfigsModelDb;
config: ConfigModel;
}
export class ConfigsModelDb {
moredb: ConfigsModelMoreDb;
config: ConfigModel;
moredb: ConfigsModelMoreDb;
config: ConfigModel;
}
export class ConfigsModelMoreDb {
config: ConfigModel;
config: ConfigModel;
}
export class ConfigModel {
myProperty: string;
myProperty: string;
}

View File

@ -11,8 +11,8 @@
"resolveJsonModule": true,
"outDir": "tmp",
"paths": {
"@spt-aki/*": [ "./types/*" ],
"@spt-aki/*": ["./types/*"],
},
},
"exclude": [ "node_modules", "dist", "tmp" ],
"exclude": ["node_modules", "dist", "tmp"],
}

View File

@ -1,7 +1,8 @@
# Exclude these folders from linting
node_modules
dist/
types/
**/node_modules
/tmp
/dist
/types
# Exclude these filetypes from linting
*.json

View File

@ -47,7 +47,7 @@ Some resources to get you started:
## **Coding Guidelines**
Focus your mod development around the `mod.ts` file. In the `package.json` file, only alter these properties: `"name"`, `"version"`, `"license"`, `"author"`, and `"akiVersion"`.
Focus your mod development around the `mod.ts` file. In the `package.json` file, only alter these properties: `"name"`, `"version"`, `"akiVersion"`, `"loadBefore"`, `"loadAfter"`, `"incompatibilities"`, `"isBundleMod"`, `"author"`, and `"license"`.
New to Typescript? Find comprehensive documentation on the [official website](https://www.typescriptlang.org/docs/).

View File

@ -29,11 +29,10 @@
* @version v1.0.0
*/
import os from "node:os";
import path from "node:path";
import { fileURLToPath } from "node:url";
import fs from "fs-extra";
import os from "os";
import path from "path";
import { fileURLToPath } from "url";
import { dirname } from "path";
import ignore from "ignore";
import archiver from "archiver";
import winston from "winston";
@ -165,7 +164,7 @@ async function main() {
* @returns {string} The absolute path of the current working directory.
*/
function getCurrentDirectory() {
return dirname(fileURLToPath(import.meta.url));
return path.dirname(fileURLToPath(import.meta.url));
}
/**
@ -225,10 +224,9 @@ function createProjectName(packageJson) {
// Remove any non-alphanumeric characters from the author and name.
const author = packageJson.author.replace(/\W/g, "");
const name = packageJson.name.replace(/\W/g, "");
const version = packageJson.version;
// Ensure the name is lowercase, as per the package.json specification.
return `${author}-${name}-${version}`.toLowerCase();
return `${author}-${name}`.toLowerCase();
}
/**

View File

@ -1,3 +1,3 @@
{
"myProperty": "wow"
"myProperty": "wow"
}

View File

@ -1,3 +1,3 @@
{
"myProperty": "wow inside db"
"myProperty": "wow inside db"
}

View File

@ -1,3 +1,3 @@
{
"myProperty": "wow inside db inside moredb"
"myProperty": "wow inside db inside moredb"
}

View File

@ -1,12 +1,13 @@
{
"folders": [
{
"path": "."
}
],
"extensions": {
"recommendations": [
"dbaeumer.vscode-eslint"
]
}
"folders": [
{
"path": "."
}
],
"extensions": {
"recommendations": [
"dbaeumer.vscode-eslint",
"refringe.spt-id-highlighter"
]
}
}

View File

@ -1,22 +1,20 @@
{
"name": "AsyncWithDependency1",
"version": "1.0.0",
"main": "src/mod.js",
"license": "MIT",
"author": "Chomp",
"akiVersion": "~3.9",
"loadBefore": [],
"loadAfter": [],
"incompatibilities": [],
"contributors": [],
"modDependencies": {
"17AsyncImporterWithDependency2": "~1"
},
"loadBefore": [],
"loadAfter": [],
"incompatibilities": [],
"isBundleMod": false,
"main": "src/mod.js",
"scripts": {
"setup": "npm i",
"build": "node ./build.mjs",
"buildinfo": "node ./build.mjs --verbose"
},
"modDependencies": {
"17AsyncImporterWithDependency2": "~1"
},
"devDependencies": {
"@types/node": "20.11",
"@typescript-eslint/eslint-plugin": "7.2",
@ -25,9 +23,11 @@
"eslint": "8.57",
"fs-extra": "11.2",
"ignore": "^5.2",
"os": "^0.1",
"tsyringe": "4.8.0",
"typescript": "5.4",
"winston": "3.12"
}
},
"author": "Chomp",
"contributors": [],
"license": "MIT"
}

View File

@ -1,30 +1,31 @@
import { DependencyContainer } from "tsyringe";
import { PreAkiModLoader } from "@spt-aki/loaders/PreAkiModLoader";
import { IPreAkiLoadModAsync } from "@spt-aki/models/external/IPreAkiLoadModAsync";
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
import { ImporterUtil } from "@spt-aki/utils/ImporterUtil";
import { DependencyContainer } from "tsyringe";
import { ConfigsModelBase } from "./model/ConfigsModel";
class Mod implements IPreAkiLoadModAsync {
public async preAkiLoadAsync(container: DependencyContainer): Promise<void> {
// get logger
const logger = container.resolve<ILogger>("WinstonLogger");
public async preAkiLoadAsync(container: DependencyContainer): Promise<void> {
// get logger
const logger = container.resolve<ILogger>("WinstonLogger");
const importerUtil = container.resolve<ImporterUtil>("ImporterUtil");
const modImporter = container.resolve<PreAkiModLoader>("PreAkiModLoader");
const path = modImporter.getModPath("16ImporterUtil");
const importerUtil = container.resolve<ImporterUtil>("ImporterUtil");
const modImporter = container.resolve<PreAkiModLoader>("PreAkiModLoader");
const path = modImporter.getModPath("16ImporterUtil");
const configPath = `${path}config/`;
return importerUtil
.loadAsync<ConfigsModelBase>(configPath)
.then((configs) => {
logger.info(
`17ImporterWithDependency1 Configurations found: ${JSON.stringify(
configs,
)}`,
);
});
}
const configPath = `${path}config/`;
return importerUtil
.loadAsync<ConfigsModelBase>(configPath)
.then((configs) => {
logger.info(
`17ImporterWithDependency1 Configurations found: ${JSON.stringify(
configs,
)}`,
);
});
}
}
module.exports = { mod: new Mod() };
export const mod = new Mod();

View File

@ -1,17 +1,17 @@
export class ConfigsModelBase {
db: ConfigsModelDb;
config: ConfigModel;
db: ConfigsModelDb;
config: ConfigModel;
}
export class ConfigsModelDb {
moredb: ConfigsModelMoreDb;
config: ConfigModel;
moredb: ConfigsModelMoreDb;
config: ConfigModel;
}
export class ConfigsModelMoreDb {
config: ConfigModel;
config: ConfigModel;
}
export class ConfigModel {
myProperty: string;
myProperty: string;
}

View File

@ -11,8 +11,8 @@
"resolveJsonModule": true,
"outDir": "tmp",
"paths": {
"@spt-aki/*": [ "./types/*" ],
"@spt-aki/*": ["./types/*"],
},
},
"exclude": [ "node_modules", "dist", "tmp" ],
"exclude": ["node_modules", "dist", "tmp"],
}

View File

@ -1,7 +1,8 @@
# Exclude these folders from linting
node_modules
dist/
types/
**/node_modules
/tmp
/dist
/types
# Exclude these filetypes from linting
*.json

View File

@ -47,7 +47,7 @@ Some resources to get you started:
## **Coding Guidelines**
Focus your mod development around the `mod.ts` file. In the `package.json` file, only alter these properties: `"name"`, `"version"`, `"license"`, `"author"`, and `"akiVersion"`.
Focus your mod development around the `mod.ts` file. In the `package.json` file, only alter these properties: `"name"`, `"version"`, `"akiVersion"`, `"loadBefore"`, `"loadAfter"`, `"incompatibilities"`, `"isBundleMod"`, `"author"`, and `"license"`.
New to Typescript? Find comprehensive documentation on the [official website](https://www.typescriptlang.org/docs/).

View File

@ -29,11 +29,10 @@
* @version v1.0.0
*/
import os from "node:os";
import path from "node:path";
import { fileURLToPath } from "node:url";
import fs from "fs-extra";
import os from "os";
import path from "path";
import { fileURLToPath } from "url";
import { dirname } from "path";
import ignore from "ignore";
import archiver from "archiver";
import winston from "winston";
@ -165,7 +164,7 @@ async function main() {
* @returns {string} The absolute path of the current working directory.
*/
function getCurrentDirectory() {
return dirname(fileURLToPath(import.meta.url));
return path.dirname(fileURLToPath(import.meta.url));
}
/**
@ -225,10 +224,9 @@ function createProjectName(packageJson) {
// Remove any non-alphanumeric characters from the author and name.
const author = packageJson.author.replace(/\W/g, "");
const name = packageJson.name.replace(/\W/g, "");
const version = packageJson.version;
// Ensure the name is lowercase, as per the package.json specification.
return `${author}-${name}-${version}`.toLowerCase();
return `${author}-${name}`.toLowerCase();
}
/**

View File

@ -1,3 +1,3 @@
{
"myProperty": "wow"
"myProperty": "wow"
}

View File

@ -1,3 +1,3 @@
{
"myProperty": "wow inside db"
"myProperty": "wow inside db"
}

View File

@ -1,3 +1,3 @@
{
"myProperty": "wow inside db inside moredb"
"myProperty": "wow inside db inside moredb"
}

View File

@ -1,12 +1,13 @@
{
"folders": [
{
"path": "."
}
],
"extensions": {
"recommendations": [
"dbaeumer.vscode-eslint"
]
}
"folders": [
{
"path": "."
}
],
"extensions": {
"recommendations": [
"dbaeumer.vscode-eslint",
"refringe.spt-id-highlighter"
]
}
}

View File

@ -1,14 +1,12 @@
{
"name": "AsyncWithDependency2",
"version": "1.0.0",
"main": "src/mod.js",
"license": "MIT",
"author": "Chomp",
"akiVersion": "~3.9",
"loadBefore": [],
"loadAfter": [],
"incompatibilities": [],
"contributors": [],
"loadBefore": [],
"loadAfter": [],
"incompatibilities": [],
"isBundleMod": false,
"main": "src/mod.js",
"scripts": {
"setup": "npm i",
"build": "node ./build.mjs",
@ -22,9 +20,11 @@
"eslint": "8.57",
"fs-extra": "11.2",
"ignore": "^5.2",
"os": "^0.1",
"tsyringe": "4.8.0",
"typescript": "5.4",
"winston": "3.12"
}
},
"author": "Chomp",
"contributors": [],
"license": "MIT"
}

View File

@ -1,30 +1,31 @@
import { DependencyContainer } from "tsyringe";
import { PreAkiModLoader } from "@spt-aki/loaders/PreAkiModLoader";
import { IPreAkiLoadModAsync } from "@spt-aki/models/external/IPreAkiLoadModAsync";
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
import { ImporterUtil } from "@spt-aki/utils/ImporterUtil";
import { DependencyContainer } from "tsyringe";
import { ConfigsModelBase } from "./model/ConfigsModel";
class Mod implements IPreAkiLoadModAsync {
public async preAkiLoadAsync(container: DependencyContainer): Promise<void> {
// get logger
const logger = container.resolve<ILogger>("WinstonLogger");
public async preAkiLoadAsync(container: DependencyContainer): Promise<void> {
// get logger
const logger = container.resolve<ILogger>("WinstonLogger");
const importerUtil = container.resolve<ImporterUtil>("ImporterUtil");
const modImporter = container.resolve<PreAkiModLoader>("PreAkiModLoader");
const path = modImporter.getModPath("16ImporterUtil");
const importerUtil = container.resolve<ImporterUtil>("ImporterUtil");
const modImporter = container.resolve<PreAkiModLoader>("PreAkiModLoader");
const path = modImporter.getModPath("16ImporterUtil");
const configPath = `${path}config/`;
return importerUtil
.loadAsync<ConfigsModelBase>(configPath)
.then((configs) => {
logger.info(
`17ImporterWithDependency2 Configurations found: ${JSON.stringify(
configs,
)}`,
);
});
}
const configPath = `${path}config/`;
return importerUtil
.loadAsync<ConfigsModelBase>(configPath)
.then((configs) => {
logger.info(
`17ImporterWithDependency2 Configurations found: ${JSON.stringify(
configs,
)}`,
);
});
}
}
module.exports = { mod: new Mod() };
export const mod = new Mod();

View File

@ -1,17 +1,17 @@
export class ConfigsModelBase {
db: ConfigsModelDb;
config: ConfigModel;
db: ConfigsModelDb;
config: ConfigModel;
}
export class ConfigsModelDb {
moredb: ConfigsModelMoreDb;
config: ConfigModel;
moredb: ConfigsModelMoreDb;
config: ConfigModel;
}
export class ConfigsModelMoreDb {
config: ConfigModel;
config: ConfigModel;
}
export class ConfigModel {
myProperty: string;
myProperty: string;
}

View File

@ -11,8 +11,8 @@
"resolveJsonModule": true,
"outDir": "tmp",
"paths": {
"@spt-aki/*": [ "./types/*" ],
"@spt-aki/*": ["./types/*"],
},
},
"exclude": [ "node_modules", "dist", "tmp" ],
"exclude": ["node_modules", "dist", "tmp"],
}

View File

@ -1,7 +1,8 @@
# Exclude these folders from linting
node_modules
dist/
types/
**/node_modules
/tmp
/dist
/types
# Exclude these filetypes from linting
*.json

View File

@ -47,7 +47,7 @@ Some resources to get you started:
## **Coding Guidelines**
Focus your mod development around the `mod.ts` file. In the `package.json` file, only alter these properties: `"name"`, `"version"`, `"license"`, `"author"`, and `"akiVersion"`.
Focus your mod development around the `mod.ts` file. In the `package.json` file, only alter these properties: `"name"`, `"version"`, `"akiVersion"`, `"loadBefore"`, `"loadAfter"`, `"incompatibilities"`, `"isBundleMod"`, `"author"`, and `"license"`.
New to Typescript? Find comprehensive documentation on the [official website](https://www.typescriptlang.org/docs/).

View File

@ -29,11 +29,10 @@
* @version v1.0.0
*/
import os from "node:os";
import path from "node:path";
import { fileURLToPath } from "node:url";
import fs from "fs-extra";
import os from "os";
import path from "path";
import { fileURLToPath } from "url";
import { dirname } from "path";
import ignore from "ignore";
import archiver from "archiver";
import winston from "winston";
@ -165,7 +164,7 @@ async function main() {
* @returns {string} The absolute path of the current working directory.
*/
function getCurrentDirectory() {
return dirname(fileURLToPath(import.meta.url));
return path.dirname(fileURLToPath(import.meta.url));
}
/**
@ -225,10 +224,9 @@ function createProjectName(packageJson) {
// Remove any non-alphanumeric characters from the author and name.
const author = packageJson.author.replace(/\W/g, "");
const name = packageJson.name.replace(/\W/g, "");
const version = packageJson.version;
// Ensure the name is lowercase, as per the package.json specification.
return `${author}-${name}-${version}`.toLowerCase();
return `${author}-${name}`.toLowerCase();
}
/**

View File

@ -1,12 +1,13 @@
{
"folders": [
{
"path": "."
}
],
"extensions": {
"recommendations": [
"dbaeumer.vscode-eslint"
]
}
"folders": [
{
"path": "."
}
],
"extensions": {
"recommendations": [
"dbaeumer.vscode-eslint",
"refringe.spt-id-highlighter"
]
}
}

View File

@ -1,14 +1,12 @@
{
"name": "CustomItemService",
"version": "1.0.0",
"main": "src/mod.js",
"license": "MIT",
"author": "Choccy",
"akiVersion": "~3.9",
"loadBefore": [],
"loadAfter": [],
"incompatibilities": [],
"contributors": [],
"loadBefore": [],
"loadAfter": [],
"incompatibilities": [],
"isBundleMod": false,
"main": "src/mod.js",
"scripts": {
"setup": "npm i",
"build": "node ./build.mjs",
@ -22,9 +20,11 @@
"eslint": "8.57",
"fs-extra": "11.2",
"ignore": "^5.2",
"os": "^0.1",
"tsyringe": "4.8.0",
"typescript": "5.4",
"winston": "3.12"
}
},
"author": "Choccy",
"contributors": [],
"license": "MIT"
}

View File

@ -19,13 +19,13 @@ class Mod implements IPostDBLoadMod, IPostAkiLoadMod
overrideProperties: {
Chambers: [
{
"_name": "patron_in_weapon_000",
"_id": "61f7c9e189e6fb1a5e3ea791",
"_parent": "CustomMP18",
"_props": {
"filters": [
_name: "patron_in_weapon_000",
_id: "61f7c9e189e6fb1a5e3ea791",
_parent: "CustomMP18",
_props: {
filters: [
{
"Filter": [
Filter: [
"560d5e524bdc2d25448b4571",
"5d6e6772a4b936088465b17c",
"5d6e67fba4b9361bc73bc779",
@ -41,16 +41,16 @@ class Mod implements IPostDBLoadMod, IPostAkiLoadMod
"5d6e68b3a4b9361bca7e50b5",
"5d6e6891a4b9361bd473feea",
"5d6e689ca4b9361bc8618956",
"5d6e68d1a4b93622fe60e845"
]
}
]
"5d6e68d1a4b93622fe60e845",
],
},
],
},
"_required": false,
"_mergeSlotWithChildren": false,
"_proto": "55d4af244bdc2d962f8b4571"
}
]
_required: false,
_mergeSlotWithChildren: false,
_proto: "55d4af244bdc2d962f8b4571",
},
],
}, //Overried properties basically tell the server on what data inside _props to be modified from the cloned item, in this example i am modifying the ammo used to be 12G
parentId: "5447b6094bdc2dc3278b4567", //ParentId refers to the Node item the gun will be under, you can check it in https://db.sp-tarkov.com/search
newId: "CustomMP18", //The new id of our cloned item
@ -59,22 +59,24 @@ class Mod implements IPostDBLoadMod, IPostAkiLoadMod
handbookParentId: "5b5f78e986f77447ed5636b1", //Handbook Parent Id refers to the category the gun will be under
//you see those side box tab thing that only select gun under specific icon? Handbook parent can be found in Aki_Data\Server\database\templates.
locales: {
"en": {
en: {
name: "MP-18 12g",
shortName: "Custom MP18",
description: "A custom MP18 chambered in 12G"
}
}
}
description: "A custom MP18 chambered in 12G",
},
},
};
CustomItem.createItemFromClone(ExampleCloneItem); //Basically calls the function and tell the server to add our Cloned new item into the server
}
//Check if our item is in the server or not
public postAkiLoad(container: DependencyContainer): void {
const db = container.resolve<DatabaseServer>("DatabaseServer");
const item = db.getTables().templates.items;
console.log(item["CustomMP18"]._props)
console.log(item["CustomMP18"]._props);
}
}
module.exports = { mod: new Mod() }
export const mod = new Mod();

View File

@ -11,8 +11,8 @@
"resolveJsonModule": true,
"outDir": "tmp",
"paths": {
"@spt-aki/*": [ "./types/*" ],
"@spt-aki/*": ["./types/*"],
},
},
"exclude": [ "node_modules", "dist", "tmp" ],
"exclude": ["node_modules", "dist", "tmp"],
}

View File

@ -1,7 +1,8 @@
# Exclude these folders from linting
node_modules
dist/
types/
**/node_modules
/tmp
/dist
/types
# Exclude these filetypes from linting
*.json

View File

@ -47,7 +47,7 @@ Some resources to get you started:
## **Coding Guidelines**
Focus your mod development around the `mod.ts` file. In the `package.json` file, only alter these properties: `"name"`, `"version"`, `"license"`, `"author"`, and `"akiVersion"`.
Focus your mod development around the `mod.ts` file. In the `package.json` file, only alter these properties: `"name"`, `"version"`, `"akiVersion"`, `"loadBefore"`, `"loadAfter"`, `"incompatibilities"`, `"isBundleMod"`, `"author"`, and `"license"`.
New to Typescript? Find comprehensive documentation on the [official website](https://www.typescriptlang.org/docs/).

View File

@ -29,11 +29,10 @@
* @version v1.0.0
*/
import os from "node:os";
import path from "node:path";
import { fileURLToPath } from "node:url";
import fs from "fs-extra";
import os from "os";
import path from "path";
import { fileURLToPath } from "url";
import { dirname } from "path";
import ignore from "ignore";
import archiver from "archiver";
import winston from "winston";
@ -165,7 +164,7 @@ async function main() {
* @returns {string} The absolute path of the current working directory.
*/
function getCurrentDirectory() {
return dirname(fileURLToPath(import.meta.url));
return path.dirname(fileURLToPath(import.meta.url));
}
/**
@ -225,10 +224,9 @@ function createProjectName(packageJson) {
// Remove any non-alphanumeric characters from the author and name.
const author = packageJson.author.replace(/\W/g, "");
const name = packageJson.name.replace(/\W/g, "");
const version = packageJson.version;
// Ensure the name is lowercase, as per the package.json specification.
return `${author}-${name}-${version}`.toLowerCase();
return `${author}-${name}`.toLowerCase();
}
/**

View File

@ -1,12 +1,13 @@
{
"folders": [
{
"path": "."
}
],
"extensions": {
"recommendations": [
"dbaeumer.vscode-eslint"
]
}
"folders": [
{
"path": "."
}
],
"extensions": {
"recommendations": [
"dbaeumer.vscode-eslint",
"refringe.spt-id-highlighter"
]
}
}

View File

@ -1,22 +1,20 @@
{
"name": "UseExternalLibraries",
"version": "1.0.0",
"main": "src/mod.js",
"license": "MIT",
"author": "TheSparta",
"akiVersion": "~3.9",
"loadBefore": [],
"loadAfter": [],
"incompatibilities": [],
"contributors": [],
"loadBefore": [],
"loadAfter": [],
"incompatibilities": [],
"isBundleMod": false,
"main": "src/mod.js",
"scripts": {
"setup": "npm i",
"build": "node ./build.mjs",
"buildinfo": "node ./build.mjs --verbose"
},
"dependencies": {
"ora-classic": "5.4.2"
},
"dependencies": {
"ora-classic": "5.4.2"
},
"devDependencies": {
"@types/node": "20.11",
"@typescript-eslint/eslint-plugin": "7.2",
@ -25,9 +23,11 @@
"eslint": "8.57",
"fs-extra": "11.2",
"ignore": "^5.2",
"os": "^0.1",
"tsyringe": "4.8.0",
"typescript": "5.4",
"winston": "3.12"
}
},
"author": "TheSparta",
"contributors": [],
"license": "MIT"
}

View File

@ -1,198 +0,0 @@
lockfileVersion: '6.0'
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
dependencies:
ora-classic:
specifier: 5.4.2
version: 5.4.2
packages:
/ansi-regex@5.0.1:
resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==}
engines: {node: '>=8'}
dev: false
/ansi-styles@4.3.0:
resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==}
engines: {node: '>=8'}
dependencies:
color-convert: 2.0.1
dev: false
/base64-js@1.5.1:
resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==}
dev: false
/bl@4.1.0:
resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==}
dependencies:
buffer: 5.7.1
inherits: 2.0.4
readable-stream: 3.6.2
dev: false
/buffer@5.7.1:
resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==}
dependencies:
base64-js: 1.5.1
ieee754: 1.2.1
dev: false
/chalk@4.1.2:
resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==}
engines: {node: '>=10'}
dependencies:
ansi-styles: 4.3.0
supports-color: 7.2.0
dev: false
/cli-cursor@3.1.0:
resolution: {integrity: sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==}
engines: {node: '>=8'}
dependencies:
restore-cursor: 3.1.0
dev: false
/cli-spinners@2.9.1:
resolution: {integrity: sha512-jHgecW0pxkonBJdrKsqxgRX9AcG+u/5k0Q7WPDfi8AogLAdwxEkyYYNWwZ5GvVFoFx2uiY1eNcSK00fh+1+FyQ==}
engines: {node: '>=6'}
dev: false
/clone@1.0.4:
resolution: {integrity: sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==}
engines: {node: '>=0.8'}
dev: false
/color-convert@2.0.1:
resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==}
engines: {node: '>=7.0.0'}
dependencies:
color-name: 1.1.4
dev: false
/color-name@1.1.4:
resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==}
dev: false
/defaults@1.0.4:
resolution: {integrity: sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A==}
dependencies:
clone: 1.0.4
dev: false
/has-flag@4.0.0:
resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==}
engines: {node: '>=8'}
dev: false
/ieee754@1.2.1:
resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}
dev: false
/inherits@2.0.4:
resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==}
dev: false
/is-interactive@1.0.0:
resolution: {integrity: sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==}
engines: {node: '>=8'}
dev: false
/is-unicode-supported@0.1.0:
resolution: {integrity: sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==}
engines: {node: '>=10'}
dev: false
/log-symbols@4.1.0:
resolution: {integrity: sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==}
engines: {node: '>=10'}
dependencies:
chalk: 4.1.2
is-unicode-supported: 0.1.0
dev: false
/mimic-fn@2.1.0:
resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==}
engines: {node: '>=6'}
dev: false
/onetime@5.1.2:
resolution: {integrity: sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==}
engines: {node: '>=6'}
dependencies:
mimic-fn: 2.1.0
dev: false
/ora-classic@5.4.2:
resolution: {integrity: sha512-/xX8D5AMHB+LnvEJHOglmq6pXwm65CQ/gqPrIjIN5GJ1Bl9KC9fSmgzR/FwjrtalDj/WVxukAVuH8GP00Zpiaw==}
engines: {node: '>=10'}
dependencies:
bl: 4.1.0
chalk: 4.1.2
cli-cursor: 3.1.0
cli-spinners: 2.9.1
is-interactive: 1.0.0
is-unicode-supported: 0.1.0
log-symbols: 4.1.0
strip-ansi: 6.0.1
wcwidth: 1.0.1
dev: false
/readable-stream@3.6.2:
resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==}
engines: {node: '>= 6'}
dependencies:
inherits: 2.0.4
string_decoder: 1.3.0
util-deprecate: 1.0.2
dev: false
/restore-cursor@3.1.0:
resolution: {integrity: sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==}
engines: {node: '>=8'}
dependencies:
onetime: 5.1.2
signal-exit: 3.0.7
dev: false
/safe-buffer@5.2.1:
resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==}
dev: false
/signal-exit@3.0.7:
resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==}
dev: false
/string_decoder@1.3.0:
resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==}
dependencies:
safe-buffer: 5.2.1
dev: false
/strip-ansi@6.0.1:
resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==}
engines: {node: '>=8'}
dependencies:
ansi-regex: 5.0.1
dev: false
/supports-color@7.2.0:
resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==}
engines: {node: '>=8'}
dependencies:
has-flag: 4.0.0
dev: false
/util-deprecate@1.0.2:
resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==}
dev: false
/wcwidth@1.0.1:
resolution: {integrity: sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==}
dependencies:
defaults: 1.0.4
dev: false

View File

@ -1,43 +1,41 @@
import { DependencyContainer } from 'tsyringe';
import path from "node:path";
import { DependencyContainer } from "tsyringe";
import { IPostAkiLoadMod } from "@spt-aki/models/external/IPostAkiLoadMod";
import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod";
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
import { VFS } from "@spt-aki/utils/VFS";
import { jsonc } from 'jsonc';
import { jsonc } from "jsonc";
// Our dynamically imported package (via pnpm) not bundled into the server
import ora from "ora-classic";
import path from "path";
class Mod implements IPreAkiLoadMod, IPostAkiLoadMod {
public preAkiLoad(container: DependencyContainer): void {
const VFS = container.resolve<VFS>("VFS");
const logger = container.resolve<ILogger>("WinstonLogger");
public preAkiLoad(container: DependencyContainer): void {
const vfs = container.resolve<VFS>("VFS");
const logger = container.resolve<ILogger>("WinstonLogger");
const parsedJsonC = jsonc.parse(VFS.readFile(path.resolve(__dirname, "../test.jsonc")));
const parsedJsonC = jsonc.parse(vfs.readFile(path.resolve(__dirname, "../test.jsonc")));
logger.success(jsonc.stringify(parsedJsonC, null, "\t")); // you could use the built in JSON api here if you really wanted too aswell, i used jsonc to really drive home the point that it works
}
logger.success(jsonc.stringify(parsedJsonC, null, "\t")); // you could use the built in JSON api here if you really wanted too aswell, i used jsonc to really drive home the point that it works
}
public postAkiLoad(container: DependencyContainer): void {
// this first timeout is just to prevent a weird formatting problem on the console, you can ignore it, you don't really need it anyways, it's just so that it looks right on the console
setTimeout(() => {
const spinner = ora({
text: "Hacking into the mainframe...",
spinner: "line",
hideCursor: false,
discardStdin: false
}).start();
public postAkiLoad(container: DependencyContainer): void {
// this first timeout is just to prevent a weird formatting problem on the console, you can ignore it, you don't really need it anyways, it's just so that it looks right on the console
setTimeout(() => {
const spinner = ora({
text: "Hacking into the mainframe...",
spinner: "line",
hideCursor: false,
discardStdin: false
}).start();
// this second timeout is to simulate the time it takes to hack into the mainframe, as it turns out, not a lot!
setTimeout(() => {
spinner.succeed("Successfully hacked into the mainframe!");
}, 3000);
}, 1000);
}
// this second timeout is to simulate the time it takes to hack into the mainframe, as it turns out, not a lot!
setTimeout(() => {
spinner.succeed("Successfully hacked into the mainframe!");
}, 3000);
}, 1000);
}
}
module.exports = {
mod: new Mod()
}
export const mod = new Mod();

View File

@ -1,4 +1,4 @@
// comment
{
"data": /* comment */ "value"
"data": /* comment */ "value"
}

View File

@ -11,8 +11,8 @@
"resolveJsonModule": true,
"outDir": "tmp",
"paths": {
"@spt-aki/*": [ "./types/*" ],
"@spt-aki/*": ["./types/*"],
},
},
"exclude": [ "node_modules", "dist", "tmp" ],
"exclude": ["node_modules", "dist", "tmp"],
}

View File

@ -1,7 +1,8 @@
# Exclude these folders from linting
node_modules
dist/
types/
**/node_modules
/tmp
/dist
/types
# Exclude these filetypes from linting
*.json

Some files were not shown because too many files have changed in this diff Show More