diff --git a/README.md b/README.md index da21850..d6c1322 100644 --- a/README.md +++ b/README.md @@ -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/) diff --git a/TypeScript/10ScopesAndTypes/.eslintignore b/TypeScript/10ScopesAndTypes/.eslintignore index 9922d9a..f7dd9e1 100644 --- a/TypeScript/10ScopesAndTypes/.eslintignore +++ b/TypeScript/10ScopesAndTypes/.eslintignore @@ -1,9 +1,10 @@ # Exclude these folders from linting -node_modules -dist/ -types/ +**/node_modules +/tmp +/dist +/types # Exclude these filetypes from linting *.json *.txt -*.exe \ No newline at end of file +*.exe diff --git a/TypeScript/10ScopesAndTypes/.eslintrc.json b/TypeScript/10ScopesAndTypes/.eslintrc.json index 071a313..757b0bd 100644 --- a/TypeScript/10ScopesAndTypes/.eslintrc.json +++ b/TypeScript/10ScopesAndTypes/.eslintrc.json @@ -95,4 +95,4 @@ } } ] -} \ No newline at end of file +} diff --git a/TypeScript/10ScopesAndTypes/README.md b/TypeScript/10ScopesAndTypes/README.md index e760f8b..3bd5a99 100644 --- a/TypeScript/10ScopesAndTypes/README.md +++ b/TypeScript/10ScopesAndTypes/README.md @@ -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/). diff --git a/TypeScript/10ScopesAndTypes/build.mjs b/TypeScript/10ScopesAndTypes/build.mjs index d00117c..d5a679f 100644 --- a/TypeScript/10ScopesAndTypes/build.mjs +++ b/TypeScript/10ScopesAndTypes/build.mjs @@ -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(); } /** diff --git a/TypeScript/10ScopesAndTypes/mod.code-workspace b/TypeScript/10ScopesAndTypes/mod.code-workspace index 6732c67..090d8e7 100644 --- a/TypeScript/10ScopesAndTypes/mod.code-workspace +++ b/TypeScript/10ScopesAndTypes/mod.code-workspace @@ -1,12 +1,13 @@ { - "folders": [ - { - "path": "." - } - ], - "extensions": { - "recommendations": [ - "dbaeumer.vscode-eslint" - ] - } -} \ No newline at end of file + "folders": [ + { + "path": "." + } + ], + "extensions": { + "recommendations": [ + "dbaeumer.vscode-eslint", + "refringe.spt-id-highlighter" + ] + } +} diff --git a/TypeScript/10ScopesAndTypes/package.json b/TypeScript/10ScopesAndTypes/package.json index ed225c0..0ac1124 100644 --- a/TypeScript/10ScopesAndTypes/package.json +++ b/TypeScript/10ScopesAndTypes/package.json @@ -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" } diff --git a/TypeScript/10ScopesAndTypes/src/MyMod.ts b/TypeScript/10ScopesAndTypes/src/MyMod.ts index 1016d9d..1d61892 100644 --- a/TypeScript/10ScopesAndTypes/src/MyMod.ts +++ b/TypeScript/10ScopesAndTypes/src/MyMod.ts @@ -1,9 +1,10 @@ import { inject, injectable } from "tsyringe"; + import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; import { Processing } from "./Processing"; @injectable() -export class MyMod +export class MyMod { // Since this is a singleton this class will only have 1 object/bean private calls = 0; @@ -11,15 +12,15 @@ 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, ) {} - public runModLogic(): void + public runModLogic(): void { this.processing.doProcess(); this.logger.info(`This is a singleton bean, so everytime its called the same entity will be returned. This is the call number: ${this.calls}`); this.calls++; } -} \ No newline at end of file +} diff --git a/TypeScript/10ScopesAndTypes/src/Processing.ts b/TypeScript/10ScopesAndTypes/src/Processing.ts index 9fa3fea..02a761c 100644 --- a/TypeScript/10ScopesAndTypes/src/Processing.ts +++ b/TypeScript/10ScopesAndTypes/src/Processing.ts @@ -1,21 +1,22 @@ import { inject, injectable } from "tsyringe"; + import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; @injectable() -export class Processing +export class Processing { // Since this is a transient type, this class will have many of this type // Anything left in variables will always be discarded private calls = 0; constructor( - @inject("WinstonLogger") private logger: ILogger + @inject("WinstonLogger") private logger: ILogger, ) {} - public doProcess(): void + public doProcess(): void { this.logger.info(`Process was triggered, since this is a singleton the calls value is always 0: ${this.calls}`); } -} \ No newline at end of file +} diff --git a/TypeScript/10ScopesAndTypes/src/mod.ts b/TypeScript/10ScopesAndTypes/src/mod.ts index 1b2663e..36c9954 100644 --- a/TypeScript/10ScopesAndTypes/src/mod.ts +++ b/TypeScript/10ScopesAndTypes/src/mod.ts @@ -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"; @@ -12,16 +13,16 @@ class Mod implements IPreAkiLoadMod, IPostAkiLoadMod // This class is registered as a singleton. This means ONE and only ONE bean // of this class will ever exist. container.register("MyMod", MyMod, {lifecycle: Lifecycle.Singleton}); - + // This class is being registered as default or transient. This means that // every time a class requests a bean of this type a new one will be created container.register("Processing", Processing); } - public postAkiLoad(container: DependencyContainer): void + public postAkiLoad(container: DependencyContainer): void { // We will run this in a quick 5 loop to show how singletons and transients work - for (let i = 0; i < 5; i++) + for (let i = 0; i < 5; i++) { // every resolution will return the same MyMod bean container.resolve("MyMod").runModLogic(); @@ -29,4 +30,4 @@ class Mod implements IPreAkiLoadMod, IPostAkiLoadMod } } -module.exports = { mod: new Mod() } \ No newline at end of file +export const mod = new Mod(); diff --git a/TypeScript/10ScopesAndTypes/tsconfig.json b/TypeScript/10ScopesAndTypes/tsconfig.json index eca7728..c5ca53f 100644 --- a/TypeScript/10ScopesAndTypes/tsconfig.json +++ b/TypeScript/10ScopesAndTypes/tsconfig.json @@ -11,8 +11,8 @@ "resolveJsonModule": true, "outDir": "tmp", "paths": { - "@spt-aki/*": [ "./types/*" ], + "@spt-aki/*": ["./types/*"], }, }, - "exclude": [ "node_modules", "dist", "tmp" ], -} \ No newline at end of file + "exclude": ["node_modules", "dist", "tmp"], +} diff --git a/TypeScript/11BundleLoadingSample/.eslintignore b/TypeScript/11BundleLoadingSample/.eslintignore index 9922d9a..f7dd9e1 100644 --- a/TypeScript/11BundleLoadingSample/.eslintignore +++ b/TypeScript/11BundleLoadingSample/.eslintignore @@ -1,9 +1,10 @@ # Exclude these folders from linting -node_modules -dist/ -types/ +**/node_modules +/tmp +/dist +/types # Exclude these filetypes from linting *.json *.txt -*.exe \ No newline at end of file +*.exe diff --git a/TypeScript/11BundleLoadingSample/.eslintrc.json b/TypeScript/11BundleLoadingSample/.eslintrc.json index 071a313..757b0bd 100644 --- a/TypeScript/11BundleLoadingSample/.eslintrc.json +++ b/TypeScript/11BundleLoadingSample/.eslintrc.json @@ -95,4 +95,4 @@ } } ] -} \ No newline at end of file +} diff --git a/TypeScript/11BundleLoadingSample/README.md b/TypeScript/11BundleLoadingSample/README.md index e760f8b..3bd5a99 100644 --- a/TypeScript/11BundleLoadingSample/README.md +++ b/TypeScript/11BundleLoadingSample/README.md @@ -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/). diff --git a/TypeScript/11BundleLoadingSample/build.mjs b/TypeScript/11BundleLoadingSample/build.mjs index d00117c..d5a679f 100644 --- a/TypeScript/11BundleLoadingSample/build.mjs +++ b/TypeScript/11BundleLoadingSample/build.mjs @@ -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(); } /** diff --git a/TypeScript/11BundleLoadingSample/bundles.json b/TypeScript/11BundleLoadingSample/bundles.json index 7b32964..536c404 100644 --- a/TypeScript/11BundleLoadingSample/bundles.json +++ b/TypeScript/11BundleLoadingSample/bundles.json @@ -1,8 +1,8 @@ { - "manifest": [ - { - "key": "assets/content/weapons/usable_items/item_bottle/textures/client_assets.bundle", - "dependencyKeys": [] - } - ] -} \ No newline at end of file + "manifest": [ + { + "key": "assets/content/weapons/usable_items/item_bottle/textures/client_assets.bundle", + "dependencyKeys": [] + } + ] +} diff --git a/TypeScript/11BundleLoadingSample/mod.code-workspace b/TypeScript/11BundleLoadingSample/mod.code-workspace index 6732c67..090d8e7 100644 --- a/TypeScript/11BundleLoadingSample/mod.code-workspace +++ b/TypeScript/11BundleLoadingSample/mod.code-workspace @@ -1,12 +1,13 @@ { - "folders": [ - { - "path": "." - } - ], - "extensions": { - "recommendations": [ - "dbaeumer.vscode-eslint" - ] - } -} \ No newline at end of file + "folders": [ + { + "path": "." + } + ], + "extensions": { + "recommendations": [ + "dbaeumer.vscode-eslint", + "refringe.spt-id-highlighter" + ] + } +} diff --git a/TypeScript/11BundleLoadingSample/package.json b/TypeScript/11BundleLoadingSample/package.json index 8397725..0449c5a 100644 --- a/TypeScript/11BundleLoadingSample/package.json +++ b/TypeScript/11BundleLoadingSample/package.json @@ -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" } diff --git a/TypeScript/11BundleLoadingSample/src/mod.ts b/TypeScript/11BundleLoadingSample/src/mod.ts index 25c5fa9..40d1f9e 100644 --- a/TypeScript/11BundleLoadingSample/src/mod.ts +++ b/TypeScript/11BundleLoadingSample/src/mod.ts @@ -1,16 +1,17 @@ import { DependencyContainer } from "tsyringe"; + import { IPostAkiLoadMod } from "@spt-aki/models/external/IPostAkiLoadMod"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; class Mod implements IPostAkiLoadMod { - public postAkiLoad(container: DependencyContainer): void + public postAkiLoad(container: DependencyContainer): void { - // get the logger from the server container + // get the logger from the server container const logger = container.resolve("WinstonLogger"); - + logger.info("Loading: Bundle Loading Sample"); - } + } } -module.exports = { mod: new Mod() } \ No newline at end of file +export const mod = new Mod(); diff --git a/TypeScript/11BundleLoadingSample/tsconfig.json b/TypeScript/11BundleLoadingSample/tsconfig.json index eca7728..c5ca53f 100644 --- a/TypeScript/11BundleLoadingSample/tsconfig.json +++ b/TypeScript/11BundleLoadingSample/tsconfig.json @@ -11,8 +11,8 @@ "resolveJsonModule": true, "outDir": "tmp", "paths": { - "@spt-aki/*": [ "./types/*" ], + "@spt-aki/*": ["./types/*"], }, }, - "exclude": [ "node_modules", "dist", "tmp" ], -} \ No newline at end of file + "exclude": ["node_modules", "dist", "tmp"], +} diff --git a/TypeScript/12ClassExtensionOverride/.eslintignore b/TypeScript/12ClassExtensionOverride/.eslintignore index 9922d9a..f7dd9e1 100644 --- a/TypeScript/12ClassExtensionOverride/.eslintignore +++ b/TypeScript/12ClassExtensionOverride/.eslintignore @@ -1,9 +1,10 @@ # Exclude these folders from linting -node_modules -dist/ -types/ +**/node_modules +/tmp +/dist +/types # Exclude these filetypes from linting *.json *.txt -*.exe \ No newline at end of file +*.exe diff --git a/TypeScript/12ClassExtensionOverride/.eslintrc.json b/TypeScript/12ClassExtensionOverride/.eslintrc.json index 071a313..757b0bd 100644 --- a/TypeScript/12ClassExtensionOverride/.eslintrc.json +++ b/TypeScript/12ClassExtensionOverride/.eslintrc.json @@ -95,4 +95,4 @@ } } ] -} \ No newline at end of file +} diff --git a/TypeScript/12ClassExtensionOverride/README.md b/TypeScript/12ClassExtensionOverride/README.md index e760f8b..3bd5a99 100644 --- a/TypeScript/12ClassExtensionOverride/README.md +++ b/TypeScript/12ClassExtensionOverride/README.md @@ -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/). diff --git a/TypeScript/12ClassExtensionOverride/build.mjs b/TypeScript/12ClassExtensionOverride/build.mjs index d00117c..d5a679f 100644 --- a/TypeScript/12ClassExtensionOverride/build.mjs +++ b/TypeScript/12ClassExtensionOverride/build.mjs @@ -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(); } /** diff --git a/TypeScript/12ClassExtensionOverride/mod.code-workspace b/TypeScript/12ClassExtensionOverride/mod.code-workspace index 6732c67..090d8e7 100644 --- a/TypeScript/12ClassExtensionOverride/mod.code-workspace +++ b/TypeScript/12ClassExtensionOverride/mod.code-workspace @@ -1,12 +1,13 @@ { - "folders": [ - { - "path": "." - } - ], - "extensions": { - "recommendations": [ - "dbaeumer.vscode-eslint" - ] - } -} \ No newline at end of file + "folders": [ + { + "path": "." + } + ], + "extensions": { + "recommendations": [ + "dbaeumer.vscode-eslint", + "refringe.spt-id-highlighter" + ] + } +} diff --git a/TypeScript/12ClassExtensionOverride/package.json b/TypeScript/12ClassExtensionOverride/package.json index 17aeea6..8328d91 100644 --- a/TypeScript/12ClassExtensionOverride/package.json +++ b/TypeScript/12ClassExtensionOverride/package.json @@ -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" } diff --git a/TypeScript/12ClassExtensionOverride/src/MyCustomLauncherCallbacks.ts b/TypeScript/12ClassExtensionOverride/src/MyCustomLauncherCallbacks.ts index 355242b..34fdbd5 100644 --- a/TypeScript/12ClassExtensionOverride/src/MyCustomLauncherCallbacks.ts +++ b/TypeScript/12ClassExtensionOverride/src/MyCustomLauncherCallbacks.ts @@ -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 @@ -28,7 +29,7 @@ export class MyCustomLauncherCallbacks extends LauncherCallbacks // <<<<=== This } // We override the parent method with the EXACT same signature - public override ping(url: string, info: IEmptyRequestData, sessionID: string): string + public override ping(url: string, info: IEmptyRequestData, sessionID: string): string { // We are overriding the parent method, so ONLY this method will run, not the parent! // If we wanted to run both, you can always write: @@ -39,5 +40,4 @@ export class MyCustomLauncherCallbacks extends LauncherCallbacks // <<<<=== This this.logger.success("Our custom method is dancing baby!"); return "Lets dance"; } - -} \ No newline at end of file +} diff --git a/TypeScript/12ClassExtensionOverride/src/mod.ts b/TypeScript/12ClassExtensionOverride/src/mod.ts index 01f78d4..45aea7a 100644 --- a/TypeScript/12ClassExtensionOverride/src/mod.ts +++ b/TypeScript/12ClassExtensionOverride/src/mod.ts @@ -1,4 +1,5 @@ import { DependencyContainer } from "tsyringe"; + import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod" import { MyCustomLauncherCallbacks } from "./MyCustomLauncherCallbacks"; @@ -9,7 +10,7 @@ class Mod implements IPreAkiLoadMod // you own custom implementations the server will then use. // In this example we will take the LauncherCallbacks class and override the ping() method // for our own custom method that will return "Lets dance" instead of "pong!" - + // Perform these actions before server fully loads public preAkiLoad(container: DependencyContainer): void { // Here we register our override for the component and we NEED to use the same @@ -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", {useClass: LauncherCallbacks}); + // depContainer.register("LauncherCallbacks", { useClass: LauncherCallbacks }); // // So what we want to do is register it with EXACTLY the same token container.register("MyCustomLauncherCallbacks", MyCustomLauncherCallbacks); - container.register("LauncherCallbacks", {useToken: "MyCustomLauncherCallbacks"}); - - // Now that its registered, the server will automatically find this dependency and use it where ever its needed + 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() } \ No newline at end of file +export const mod = new Mod(); diff --git a/TypeScript/12ClassExtensionOverride/tsconfig.json b/TypeScript/12ClassExtensionOverride/tsconfig.json index eca7728..c5ca53f 100644 --- a/TypeScript/12ClassExtensionOverride/tsconfig.json +++ b/TypeScript/12ClassExtensionOverride/tsconfig.json @@ -11,8 +11,8 @@ "resolveJsonModule": true, "outDir": "tmp", "paths": { - "@spt-aki/*": [ "./types/*" ], + "@spt-aki/*": ["./types/*"], }, }, - "exclude": [ "node_modules", "dist", "tmp" ], -} \ No newline at end of file + "exclude": ["node_modules", "dist", "tmp"], +} diff --git a/TypeScript/13AddTrader/.eslintignore b/TypeScript/13AddTrader/.eslintignore index 9922d9a..f7dd9e1 100644 --- a/TypeScript/13AddTrader/.eslintignore +++ b/TypeScript/13AddTrader/.eslintignore @@ -1,9 +1,10 @@ # Exclude these folders from linting -node_modules -dist/ -types/ +**/node_modules +/tmp +/dist +/types # Exclude these filetypes from linting *.json *.txt -*.exe \ No newline at end of file +*.exe diff --git a/TypeScript/13AddTrader/.eslintrc.json b/TypeScript/13AddTrader/.eslintrc.json index 071a313..757b0bd 100644 --- a/TypeScript/13AddTrader/.eslintrc.json +++ b/TypeScript/13AddTrader/.eslintrc.json @@ -95,4 +95,4 @@ } } ] -} \ No newline at end of file +} diff --git a/TypeScript/13AddTrader/README.md b/TypeScript/13AddTrader/README.md index e760f8b..3bd5a99 100644 --- a/TypeScript/13AddTrader/README.md +++ b/TypeScript/13AddTrader/README.md @@ -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/). diff --git a/TypeScript/13AddTrader/build.mjs b/TypeScript/13AddTrader/build.mjs index d00117c..d5a679f 100644 --- a/TypeScript/13AddTrader/build.mjs +++ b/TypeScript/13AddTrader/build.mjs @@ -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(); } /** diff --git a/TypeScript/13AddTrader/mod.code-workspace b/TypeScript/13AddTrader/mod.code-workspace index 6732c67..090d8e7 100644 --- a/TypeScript/13AddTrader/mod.code-workspace +++ b/TypeScript/13AddTrader/mod.code-workspace @@ -1,12 +1,13 @@ { - "folders": [ - { - "path": "." - } - ], - "extensions": { - "recommendations": [ - "dbaeumer.vscode-eslint" - ] - } -} \ No newline at end of file + "folders": [ + { + "path": "." + } + ], + "extensions": { + "recommendations": [ + "dbaeumer.vscode-eslint", + "refringe.spt-id-highlighter" + ] + } +} diff --git a/TypeScript/13AddTrader/package.json b/TypeScript/13AddTrader/package.json index a20e857..02720a1 100644 --- a/TypeScript/13AddTrader/package.json +++ b/TypeScript/13AddTrader/package.json @@ -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" } diff --git a/TypeScript/13AddTrader/src/fluentTraderAssortCreator.ts b/TypeScript/13AddTrader/src/fluentTraderAssortCreator.ts index 07e8155..c98fef0 100644 --- a/TypeScript/13AddTrader/src/fluentTraderAssortCreator.ts +++ b/TypeScript/13AddTrader/src/fluentTraderAssortCreator.ts @@ -17,24 +17,24 @@ export class FluentAssortConstructor this.hashUtil = hashutil this.logger = logger; } - + /** * Start selling item with tpl * @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; @@ -150,7 +144,7 @@ export class FluentAssortConstructor /** * Reset objet ready for reuse - * @returns + * @returns */ public export(data: ITrader): FluentAssortConstructor { @@ -172,4 +166,4 @@ export class FluentAssortConstructor return this; } -} \ No newline at end of file +} diff --git a/TypeScript/13AddTrader/src/mod.ts b/TypeScript/13AddTrader/src/mod.ts index 216e359..279dabc 100644 --- a/TypeScript/13AddTrader/src/mod.ts +++ b/TypeScript/13AddTrader/src/mod.ts @@ -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 @@ -64,7 +65,7 @@ class SampleTrader implements IPreAkiLoadMod, IPostDBLoadMod this.logger.debug(`[${this.mod}] preAki Loaded`); } - + /** * Majority of trader-related work occurs after the aki database has been loaded but prior to SPT code being run * @param container Dependency container @@ -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() } \ No newline at end of file +export const mod = new SampleTrader(); diff --git a/TypeScript/13AddTrader/src/traderHelpers.ts b/TypeScript/13AddTrader/src/traderHelpers.ts index eacbffd..3f969f4 100644 --- a/TypeScript/13AddTrader/src/traderHelpers.ts +++ b/TypeScript/13AddTrader/src/traderHelpers.ts @@ -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 @@ -19,7 +20,7 @@ export class TraderHelper { // Reference the mod "res" folder const imageFilepath = `./${preAkiModLoader.getModPath(modName)}res`; - + // Register a route to point to the profile picture - remember to remove the .jpg from it imageRouter.addRoute(baseJson.avatar.replace(".jpg", ""), `${imageFilepath}/${traderImageName}`); } @@ -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[]; + const locales = Object.values(tables.locales.global); + for (const locale of locales) { locale[`${baseJson._id} FullName`] = fullName; locale[`${baseJson._id} FirstName`] = firstName; @@ -180,4 +181,4 @@ export class TraderHelper locale[`${baseJson._id} Description`] = description; } } -} \ No newline at end of file +} diff --git a/TypeScript/13AddTrader/tsconfig.json b/TypeScript/13AddTrader/tsconfig.json index eca7728..c5ca53f 100644 --- a/TypeScript/13AddTrader/tsconfig.json +++ b/TypeScript/13AddTrader/tsconfig.json @@ -11,8 +11,8 @@ "resolveJsonModule": true, "outDir": "tmp", "paths": { - "@spt-aki/*": [ "./types/*" ], + "@spt-aki/*": ["./types/*"], }, }, - "exclude": [ "node_modules", "dist", "tmp" ], -} \ No newline at end of file + "exclude": ["node_modules", "dist", "tmp"], +} diff --git a/TypeScript/14AfterDBLoadHook/.eslintignore b/TypeScript/14AfterDBLoadHook/.eslintignore index 9922d9a..f7dd9e1 100644 --- a/TypeScript/14AfterDBLoadHook/.eslintignore +++ b/TypeScript/14AfterDBLoadHook/.eslintignore @@ -1,9 +1,10 @@ # Exclude these folders from linting -node_modules -dist/ -types/ +**/node_modules +/tmp +/dist +/types # Exclude these filetypes from linting *.json *.txt -*.exe \ No newline at end of file +*.exe diff --git a/TypeScript/14AfterDBLoadHook/.eslintrc.json b/TypeScript/14AfterDBLoadHook/.eslintrc.json index 071a313..757b0bd 100644 --- a/TypeScript/14AfterDBLoadHook/.eslintrc.json +++ b/TypeScript/14AfterDBLoadHook/.eslintrc.json @@ -95,4 +95,4 @@ } } ] -} \ No newline at end of file +} diff --git a/TypeScript/14AfterDBLoadHook/README.md b/TypeScript/14AfterDBLoadHook/README.md index e760f8b..3bd5a99 100644 --- a/TypeScript/14AfterDBLoadHook/README.md +++ b/TypeScript/14AfterDBLoadHook/README.md @@ -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/). diff --git a/TypeScript/14AfterDBLoadHook/build.mjs b/TypeScript/14AfterDBLoadHook/build.mjs index d00117c..d5a679f 100644 --- a/TypeScript/14AfterDBLoadHook/build.mjs +++ b/TypeScript/14AfterDBLoadHook/build.mjs @@ -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(); } /** diff --git a/TypeScript/14AfterDBLoadHook/mod.code-workspace b/TypeScript/14AfterDBLoadHook/mod.code-workspace index 6732c67..090d8e7 100644 --- a/TypeScript/14AfterDBLoadHook/mod.code-workspace +++ b/TypeScript/14AfterDBLoadHook/mod.code-workspace @@ -1,12 +1,13 @@ { - "folders": [ - { - "path": "." - } - ], - "extensions": { - "recommendations": [ - "dbaeumer.vscode-eslint" - ] - } -} \ No newline at end of file + "folders": [ + { + "path": "." + } + ], + "extensions": { + "recommendations": [ + "dbaeumer.vscode-eslint", + "refringe.spt-id-highlighter" + ] + } +} diff --git a/TypeScript/14AfterDBLoadHook/package.json b/TypeScript/14AfterDBLoadHook/package.json index a823ed7..8152217 100644 --- a/TypeScript/14AfterDBLoadHook/package.json +++ b/TypeScript/14AfterDBLoadHook/package.json @@ -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" } diff --git a/TypeScript/14AfterDBLoadHook/src/mod.ts b/TypeScript/14AfterDBLoadHook/src/mod.ts index 3427014..1f4ee95 100644 --- a/TypeScript/14AfterDBLoadHook/src/mod.ts +++ b/TypeScript/14AfterDBLoadHook/src/mod.ts @@ -17,7 +17,7 @@ class Mod implements IPreAkiLoadMod, IPostAkiLoadMod, IPostDBLoadMod const logger = container.resolve("WinstonLogger"); logger.logWithColor(`Database item table state: ${databaseServer.getTables().templates} (<<< should be undefined)`, LogTextColor.RED, LogBackgroundColor.YELLOW); } - + public postDBLoad(container: DependencyContainer): void { // Database will be loaded, this is the fresh state of the DB so NOTHING from the AKI // logic has modified anything yet. This is the DB loaded straight from the JSON files @@ -25,7 +25,7 @@ class Mod implements IPreAkiLoadMod, IPostAkiLoadMod, IPostDBLoadMod const logger = container.resolve("WinstonLogger"); logger.logWithColor(`Database item size: ${Object.entries(databaseServer.getTables().templates.items).length}`, LogTextColor.RED, LogBackgroundColor.YELLOW); // lets do a quick modification and see how this reflect later on, on the postAkiLoad() - + // find the nvgs item by its Id const nvgs = databaseServer.getTables().templates.items["5c0558060db834001b735271"]; // Lets log the state before the modification: @@ -47,4 +47,4 @@ class Mod implements IPreAkiLoadMod, IPostAkiLoadMod, IPostDBLoadMod } } -module.exports = { mod: new Mod() } \ No newline at end of file +export const mod = new Mod(); diff --git a/TypeScript/14AfterDBLoadHook/tsconfig.json b/TypeScript/14AfterDBLoadHook/tsconfig.json index eca7728..c5ca53f 100644 --- a/TypeScript/14AfterDBLoadHook/tsconfig.json +++ b/TypeScript/14AfterDBLoadHook/tsconfig.json @@ -11,8 +11,8 @@ "resolveJsonModule": true, "outDir": "tmp", "paths": { - "@spt-aki/*": [ "./types/*" ], + "@spt-aki/*": ["./types/*"], }, }, - "exclude": [ "node_modules", "dist", "tmp" ], -} \ No newline at end of file + "exclude": ["node_modules", "dist", "tmp"], +} diff --git a/TypeScript/15HttpListenerExample/.eslintignore b/TypeScript/15HttpListenerExample/.eslintignore index 9922d9a..f7dd9e1 100644 --- a/TypeScript/15HttpListenerExample/.eslintignore +++ b/TypeScript/15HttpListenerExample/.eslintignore @@ -1,9 +1,10 @@ # Exclude these folders from linting -node_modules -dist/ -types/ +**/node_modules +/tmp +/dist +/types # Exclude these filetypes from linting *.json *.txt -*.exe \ No newline at end of file +*.exe diff --git a/TypeScript/15HttpListenerExample/.eslintrc.json b/TypeScript/15HttpListenerExample/.eslintrc.json index 071a313..757b0bd 100644 --- a/TypeScript/15HttpListenerExample/.eslintrc.json +++ b/TypeScript/15HttpListenerExample/.eslintrc.json @@ -95,4 +95,4 @@ } } ] -} \ No newline at end of file +} diff --git a/TypeScript/15HttpListenerExample/README.md b/TypeScript/15HttpListenerExample/README.md index e760f8b..3bd5a99 100644 --- a/TypeScript/15HttpListenerExample/README.md +++ b/TypeScript/15HttpListenerExample/README.md @@ -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/). diff --git a/TypeScript/15HttpListenerExample/build.mjs b/TypeScript/15HttpListenerExample/build.mjs index d00117c..d5a679f 100644 --- a/TypeScript/15HttpListenerExample/build.mjs +++ b/TypeScript/15HttpListenerExample/build.mjs @@ -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(); } /** diff --git a/TypeScript/15HttpListenerExample/mod.code-workspace b/TypeScript/15HttpListenerExample/mod.code-workspace index 6732c67..090d8e7 100644 --- a/TypeScript/15HttpListenerExample/mod.code-workspace +++ b/TypeScript/15HttpListenerExample/mod.code-workspace @@ -1,12 +1,13 @@ { - "folders": [ - { - "path": "." - } - ], - "extensions": { - "recommendations": [ - "dbaeumer.vscode-eslint" - ] - } -} \ No newline at end of file + "folders": [ + { + "path": "." + } + ], + "extensions": { + "recommendations": [ + "dbaeumer.vscode-eslint", + "refringe.spt-id-highlighter" + ] + } +} diff --git a/TypeScript/15HttpListenerExample/package.json b/TypeScript/15HttpListenerExample/package.json index 85a6213..00b9272 100644 --- a/TypeScript/15HttpListenerExample/package.json +++ b/TypeScript/15HttpListenerExample/package.json @@ -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" } diff --git a/TypeScript/15HttpListenerExample/src/Type2HttpListener.ts b/TypeScript/15HttpListenerExample/src/Type2HttpListener.ts index 12b4f7e..d87d66c 100644 --- a/TypeScript/15HttpListenerExample/src/Type2HttpListener.ts +++ b/TypeScript/15HttpListenerExample/src/Type2HttpListener.ts @@ -1,16 +1,17 @@ +import { IncomingMessage, ServerResponse } from "node:http"; + import { IHttpListener } from "@spt-aki/servers/http/IHttpListener"; -import { IncomingMessage, ServerResponse } from "http"; export class Type2HttpListener implements IHttpListener { - public canHandle(sessionId: string, req: IncomingMessage): boolean + public canHandle(sessionId: string, req: IncomingMessage): boolean { 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 { resp.writeHead(200, "OK"); resp.end("[2] This is the second example of a mod hooking into the HttpServer"); } - -} \ No newline at end of file +} diff --git a/TypeScript/15HttpListenerExample/src/mod.ts b/TypeScript/15HttpListenerExample/src/mod.ts index dc93042..3158494 100644 --- a/TypeScript/15HttpListenerExample/src/mod.ts +++ b/TypeScript/15HttpListenerExample/src/mod.ts @@ -1,13 +1,14 @@ +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 { // Code added here will load BEFORE the server has started loading - public preAkiLoad(container: DependencyContainer): void + public preAkiLoad(container: DependencyContainer): void { const httpListenerService = container.resolve("HttpListenerModService"); httpListenerService.registerHttpListener("Type1HttpListener", this.canHandleOverride, this.handleOverride) @@ -28,4 +29,4 @@ class Mod implements IPreAkiLoadMod } } -module.exports = { mod: new Mod() } +export const mod = new Mod(); diff --git a/TypeScript/15HttpListenerExample/tsconfig.json b/TypeScript/15HttpListenerExample/tsconfig.json index eca7728..c5ca53f 100644 --- a/TypeScript/15HttpListenerExample/tsconfig.json +++ b/TypeScript/15HttpListenerExample/tsconfig.json @@ -11,8 +11,8 @@ "resolveJsonModule": true, "outDir": "tmp", "paths": { - "@spt-aki/*": [ "./types/*" ], + "@spt-aki/*": ["./types/*"], }, }, - "exclude": [ "node_modules", "dist", "tmp" ], -} \ No newline at end of file + "exclude": ["node_modules", "dist", "tmp"], +} diff --git a/TypeScript/16ImporterUtil/.eslintignore b/TypeScript/16ImporterUtil/.eslintignore index 9922d9a..f7dd9e1 100644 --- a/TypeScript/16ImporterUtil/.eslintignore +++ b/TypeScript/16ImporterUtil/.eslintignore @@ -1,9 +1,10 @@ # Exclude these folders from linting -node_modules -dist/ -types/ +**/node_modules +/tmp +/dist +/types # Exclude these filetypes from linting *.json *.txt -*.exe \ No newline at end of file +*.exe diff --git a/TypeScript/16ImporterUtil/.eslintrc.json b/TypeScript/16ImporterUtil/.eslintrc.json index 071a313..757b0bd 100644 --- a/TypeScript/16ImporterUtil/.eslintrc.json +++ b/TypeScript/16ImporterUtil/.eslintrc.json @@ -95,4 +95,4 @@ } } ] -} \ No newline at end of file +} diff --git a/TypeScript/16ImporterUtil/README.md b/TypeScript/16ImporterUtil/README.md index e760f8b..3bd5a99 100644 --- a/TypeScript/16ImporterUtil/README.md +++ b/TypeScript/16ImporterUtil/README.md @@ -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/). diff --git a/TypeScript/16ImporterUtil/build.mjs b/TypeScript/16ImporterUtil/build.mjs index d00117c..d5a679f 100644 --- a/TypeScript/16ImporterUtil/build.mjs +++ b/TypeScript/16ImporterUtil/build.mjs @@ -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(); } /** diff --git a/TypeScript/16ImporterUtil/config/config.json b/TypeScript/16ImporterUtil/config/config.json index 2cc3a9f..8333f59 100644 --- a/TypeScript/16ImporterUtil/config/config.json +++ b/TypeScript/16ImporterUtil/config/config.json @@ -1,3 +1,3 @@ { - "myProperty": "wow" -} \ No newline at end of file + "myProperty": "wow" +} diff --git a/TypeScript/16ImporterUtil/config/db/config.json b/TypeScript/16ImporterUtil/config/db/config.json index 9fc7661..6870cbd 100644 --- a/TypeScript/16ImporterUtil/config/db/config.json +++ b/TypeScript/16ImporterUtil/config/db/config.json @@ -1,3 +1,3 @@ { - "myProperty": "wow inside db" -} \ No newline at end of file + "myProperty": "wow inside db" +} diff --git a/TypeScript/16ImporterUtil/config/db/moredb/config.json b/TypeScript/16ImporterUtil/config/db/moredb/config.json index 9a6d9e3..b9feb92 100644 --- a/TypeScript/16ImporterUtil/config/db/moredb/config.json +++ b/TypeScript/16ImporterUtil/config/db/moredb/config.json @@ -1,3 +1,3 @@ { - "myProperty": "wow inside db inside moredb" -} \ No newline at end of file + "myProperty": "wow inside db inside moredb" +} diff --git a/TypeScript/16ImporterUtil/mod.code-workspace b/TypeScript/16ImporterUtil/mod.code-workspace index 6732c67..090d8e7 100644 --- a/TypeScript/16ImporterUtil/mod.code-workspace +++ b/TypeScript/16ImporterUtil/mod.code-workspace @@ -1,12 +1,13 @@ { - "folders": [ - { - "path": "." - } - ], - "extensions": { - "recommendations": [ - "dbaeumer.vscode-eslint" - ] - } -} \ No newline at end of file + "folders": [ + { + "path": "." + } + ], + "extensions": { + "recommendations": [ + "dbaeumer.vscode-eslint", + "refringe.spt-id-highlighter" + ] + } +} diff --git a/TypeScript/16ImporterUtil/package.json b/TypeScript/16ImporterUtil/package.json index b0fc684..97dbd0e 100644 --- a/TypeScript/16ImporterUtil/package.json +++ b/TypeScript/16ImporterUtil/package.json @@ -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" } diff --git a/TypeScript/16ImporterUtil/src/mod.ts b/TypeScript/16ImporterUtil/src/mod.ts index 31c1796..651a43b 100644 --- a/TypeScript/16ImporterUtil/src/mod.ts +++ b/TypeScript/16ImporterUtil/src/mod.ts @@ -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("WinstonLogger"); + public preAkiLoad(container: DependencyContainer): void { + // get logger + const logger = container.resolve("WinstonLogger"); - const importerUtil = container.resolve("ImporterUtil"); - const modImporter = container.resolve("PreAkiModLoader"); - const path = modImporter.getModPath("16ImporterUtil"); + const importerUtil = container.resolve("ImporterUtil"); + const modImporter = container.resolve("PreAkiModLoader"); + const path = modImporter.getModPath("16ImporterUtil"); - const configPath = `${path}config/`; - const configs = importerUtil.loadRecursive(configPath); - logger.info( - `16ImporterUtil Configurations found: ${JSON.stringify(configs)}`, - ); - } + const configPath = `${path}config/`; + const configs = importerUtil.loadRecursive(configPath); + logger.info( + `16ImporterUtil Configurations found: ${JSON.stringify(configs)}`, + ); + } } -module.exports = { mod: new Mod() }; +export const mod = new Mod(); diff --git a/TypeScript/16ImporterUtil/src/model/ConfigsModel.ts b/TypeScript/16ImporterUtil/src/model/ConfigsModel.ts index 07c5138..a6f1ee9 100644 --- a/TypeScript/16ImporterUtil/src/model/ConfigsModel.ts +++ b/TypeScript/16ImporterUtil/src/model/ConfigsModel.ts @@ -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; } diff --git a/TypeScript/16ImporterUtil/tsconfig.json b/TypeScript/16ImporterUtil/tsconfig.json index eca7728..c5ca53f 100644 --- a/TypeScript/16ImporterUtil/tsconfig.json +++ b/TypeScript/16ImporterUtil/tsconfig.json @@ -11,8 +11,8 @@ "resolveJsonModule": true, "outDir": "tmp", "paths": { - "@spt-aki/*": [ "./types/*" ], + "@spt-aki/*": ["./types/*"], }, }, - "exclude": [ "node_modules", "dist", "tmp" ], -} \ No newline at end of file + "exclude": ["node_modules", "dist", "tmp"], +} diff --git a/TypeScript/17AsyncImporterWithDependency1/.eslintignore b/TypeScript/17AsyncImporterWithDependency1/.eslintignore index 9922d9a..f7dd9e1 100644 --- a/TypeScript/17AsyncImporterWithDependency1/.eslintignore +++ b/TypeScript/17AsyncImporterWithDependency1/.eslintignore @@ -1,9 +1,10 @@ # Exclude these folders from linting -node_modules -dist/ -types/ +**/node_modules +/tmp +/dist +/types # Exclude these filetypes from linting *.json *.txt -*.exe \ No newline at end of file +*.exe diff --git a/TypeScript/17AsyncImporterWithDependency1/.eslintrc.json b/TypeScript/17AsyncImporterWithDependency1/.eslintrc.json index 071a313..757b0bd 100644 --- a/TypeScript/17AsyncImporterWithDependency1/.eslintrc.json +++ b/TypeScript/17AsyncImporterWithDependency1/.eslintrc.json @@ -95,4 +95,4 @@ } } ] -} \ No newline at end of file +} diff --git a/TypeScript/17AsyncImporterWithDependency1/README.md b/TypeScript/17AsyncImporterWithDependency1/README.md index e760f8b..3bd5a99 100644 --- a/TypeScript/17AsyncImporterWithDependency1/README.md +++ b/TypeScript/17AsyncImporterWithDependency1/README.md @@ -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/). diff --git a/TypeScript/17AsyncImporterWithDependency1/build.mjs b/TypeScript/17AsyncImporterWithDependency1/build.mjs index d00117c..d5a679f 100644 --- a/TypeScript/17AsyncImporterWithDependency1/build.mjs +++ b/TypeScript/17AsyncImporterWithDependency1/build.mjs @@ -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(); } /** diff --git a/TypeScript/17AsyncImporterWithDependency1/config/config.json b/TypeScript/17AsyncImporterWithDependency1/config/config.json index 2cc3a9f..8333f59 100644 --- a/TypeScript/17AsyncImporterWithDependency1/config/config.json +++ b/TypeScript/17AsyncImporterWithDependency1/config/config.json @@ -1,3 +1,3 @@ { - "myProperty": "wow" -} \ No newline at end of file + "myProperty": "wow" +} diff --git a/TypeScript/17AsyncImporterWithDependency1/config/db/config.json b/TypeScript/17AsyncImporterWithDependency1/config/db/config.json index 9fc7661..6870cbd 100644 --- a/TypeScript/17AsyncImporterWithDependency1/config/db/config.json +++ b/TypeScript/17AsyncImporterWithDependency1/config/db/config.json @@ -1,3 +1,3 @@ { - "myProperty": "wow inside db" -} \ No newline at end of file + "myProperty": "wow inside db" +} diff --git a/TypeScript/17AsyncImporterWithDependency1/config/db/moredb/config.json b/TypeScript/17AsyncImporterWithDependency1/config/db/moredb/config.json index 9a6d9e3..b9feb92 100644 --- a/TypeScript/17AsyncImporterWithDependency1/config/db/moredb/config.json +++ b/TypeScript/17AsyncImporterWithDependency1/config/db/moredb/config.json @@ -1,3 +1,3 @@ { - "myProperty": "wow inside db inside moredb" -} \ No newline at end of file + "myProperty": "wow inside db inside moredb" +} diff --git a/TypeScript/17AsyncImporterWithDependency1/mod.code-workspace b/TypeScript/17AsyncImporterWithDependency1/mod.code-workspace index 6732c67..090d8e7 100644 --- a/TypeScript/17AsyncImporterWithDependency1/mod.code-workspace +++ b/TypeScript/17AsyncImporterWithDependency1/mod.code-workspace @@ -1,12 +1,13 @@ { - "folders": [ - { - "path": "." - } - ], - "extensions": { - "recommendations": [ - "dbaeumer.vscode-eslint" - ] - } -} \ No newline at end of file + "folders": [ + { + "path": "." + } + ], + "extensions": { + "recommendations": [ + "dbaeumer.vscode-eslint", + "refringe.spt-id-highlighter" + ] + } +} diff --git a/TypeScript/17AsyncImporterWithDependency1/package.json b/TypeScript/17AsyncImporterWithDependency1/package.json index 03f8ab4..99e2af1 100644 --- a/TypeScript/17AsyncImporterWithDependency1/package.json +++ b/TypeScript/17AsyncImporterWithDependency1/package.json @@ -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" } diff --git a/TypeScript/17AsyncImporterWithDependency1/src/mod.ts b/TypeScript/17AsyncImporterWithDependency1/src/mod.ts index 13b2fc7..a34a004 100644 --- a/TypeScript/17AsyncImporterWithDependency1/src/mod.ts +++ b/TypeScript/17AsyncImporterWithDependency1/src/mod.ts @@ -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 { - // get logger - const logger = container.resolve("WinstonLogger"); + public async preAkiLoadAsync(container: DependencyContainer): Promise { + // get logger + const logger = container.resolve("WinstonLogger"); - const importerUtil = container.resolve("ImporterUtil"); - const modImporter = container.resolve("PreAkiModLoader"); - const path = modImporter.getModPath("16ImporterUtil"); + const importerUtil = container.resolve("ImporterUtil"); + const modImporter = container.resolve("PreAkiModLoader"); + const path = modImporter.getModPath("16ImporterUtil"); - const configPath = `${path}config/`; - return importerUtil - .loadAsync(configPath) - .then((configs) => { - logger.info( - `17ImporterWithDependency1 Configurations found: ${JSON.stringify( - configs, - )}`, - ); - }); - } + const configPath = `${path}config/`; + return importerUtil + .loadAsync(configPath) + .then((configs) => { + logger.info( + `17ImporterWithDependency1 Configurations found: ${JSON.stringify( + configs, + )}`, + ); + }); + } } -module.exports = { mod: new Mod() }; +export const mod = new Mod(); diff --git a/TypeScript/17AsyncImporterWithDependency1/src/model/ConfigsModel.ts b/TypeScript/17AsyncImporterWithDependency1/src/model/ConfigsModel.ts index 07c5138..a6f1ee9 100644 --- a/TypeScript/17AsyncImporterWithDependency1/src/model/ConfigsModel.ts +++ b/TypeScript/17AsyncImporterWithDependency1/src/model/ConfigsModel.ts @@ -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; } diff --git a/TypeScript/17AsyncImporterWithDependency1/tsconfig.json b/TypeScript/17AsyncImporterWithDependency1/tsconfig.json index eca7728..c5ca53f 100644 --- a/TypeScript/17AsyncImporterWithDependency1/tsconfig.json +++ b/TypeScript/17AsyncImporterWithDependency1/tsconfig.json @@ -11,8 +11,8 @@ "resolveJsonModule": true, "outDir": "tmp", "paths": { - "@spt-aki/*": [ "./types/*" ], + "@spt-aki/*": ["./types/*"], }, }, - "exclude": [ "node_modules", "dist", "tmp" ], -} \ No newline at end of file + "exclude": ["node_modules", "dist", "tmp"], +} diff --git a/TypeScript/17AsyncImporterWithDependency2/.eslintignore b/TypeScript/17AsyncImporterWithDependency2/.eslintignore index 9922d9a..f7dd9e1 100644 --- a/TypeScript/17AsyncImporterWithDependency2/.eslintignore +++ b/TypeScript/17AsyncImporterWithDependency2/.eslintignore @@ -1,9 +1,10 @@ # Exclude these folders from linting -node_modules -dist/ -types/ +**/node_modules +/tmp +/dist +/types # Exclude these filetypes from linting *.json *.txt -*.exe \ No newline at end of file +*.exe diff --git a/TypeScript/17AsyncImporterWithDependency2/.eslintrc.json b/TypeScript/17AsyncImporterWithDependency2/.eslintrc.json index 071a313..757b0bd 100644 --- a/TypeScript/17AsyncImporterWithDependency2/.eslintrc.json +++ b/TypeScript/17AsyncImporterWithDependency2/.eslintrc.json @@ -95,4 +95,4 @@ } } ] -} \ No newline at end of file +} diff --git a/TypeScript/17AsyncImporterWithDependency2/README.md b/TypeScript/17AsyncImporterWithDependency2/README.md index e760f8b..3bd5a99 100644 --- a/TypeScript/17AsyncImporterWithDependency2/README.md +++ b/TypeScript/17AsyncImporterWithDependency2/README.md @@ -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/). diff --git a/TypeScript/17AsyncImporterWithDependency2/build.mjs b/TypeScript/17AsyncImporterWithDependency2/build.mjs index d00117c..d5a679f 100644 --- a/TypeScript/17AsyncImporterWithDependency2/build.mjs +++ b/TypeScript/17AsyncImporterWithDependency2/build.mjs @@ -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(); } /** diff --git a/TypeScript/17AsyncImporterWithDependency2/config/config.json b/TypeScript/17AsyncImporterWithDependency2/config/config.json index 2cc3a9f..8333f59 100644 --- a/TypeScript/17AsyncImporterWithDependency2/config/config.json +++ b/TypeScript/17AsyncImporterWithDependency2/config/config.json @@ -1,3 +1,3 @@ { - "myProperty": "wow" -} \ No newline at end of file + "myProperty": "wow" +} diff --git a/TypeScript/17AsyncImporterWithDependency2/config/db/config.json b/TypeScript/17AsyncImporterWithDependency2/config/db/config.json index 9fc7661..6870cbd 100644 --- a/TypeScript/17AsyncImporterWithDependency2/config/db/config.json +++ b/TypeScript/17AsyncImporterWithDependency2/config/db/config.json @@ -1,3 +1,3 @@ { - "myProperty": "wow inside db" -} \ No newline at end of file + "myProperty": "wow inside db" +} diff --git a/TypeScript/17AsyncImporterWithDependency2/config/db/moredb/config.json b/TypeScript/17AsyncImporterWithDependency2/config/db/moredb/config.json index 9a6d9e3..b9feb92 100644 --- a/TypeScript/17AsyncImporterWithDependency2/config/db/moredb/config.json +++ b/TypeScript/17AsyncImporterWithDependency2/config/db/moredb/config.json @@ -1,3 +1,3 @@ { - "myProperty": "wow inside db inside moredb" -} \ No newline at end of file + "myProperty": "wow inside db inside moredb" +} diff --git a/TypeScript/17AsyncImporterWithDependency2/mod.code-workspace b/TypeScript/17AsyncImporterWithDependency2/mod.code-workspace index 6732c67..090d8e7 100644 --- a/TypeScript/17AsyncImporterWithDependency2/mod.code-workspace +++ b/TypeScript/17AsyncImporterWithDependency2/mod.code-workspace @@ -1,12 +1,13 @@ { - "folders": [ - { - "path": "." - } - ], - "extensions": { - "recommendations": [ - "dbaeumer.vscode-eslint" - ] - } -} \ No newline at end of file + "folders": [ + { + "path": "." + } + ], + "extensions": { + "recommendations": [ + "dbaeumer.vscode-eslint", + "refringe.spt-id-highlighter" + ] + } +} diff --git a/TypeScript/17AsyncImporterWithDependency2/package.json b/TypeScript/17AsyncImporterWithDependency2/package.json index 9864f79..6614a4d 100644 --- a/TypeScript/17AsyncImporterWithDependency2/package.json +++ b/TypeScript/17AsyncImporterWithDependency2/package.json @@ -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" } diff --git a/TypeScript/17AsyncImporterWithDependency2/src/mod.ts b/TypeScript/17AsyncImporterWithDependency2/src/mod.ts index 4fa385d..815a944 100644 --- a/TypeScript/17AsyncImporterWithDependency2/src/mod.ts +++ b/TypeScript/17AsyncImporterWithDependency2/src/mod.ts @@ -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 { - // get logger - const logger = container.resolve("WinstonLogger"); + public async preAkiLoadAsync(container: DependencyContainer): Promise { + // get logger + const logger = container.resolve("WinstonLogger"); - const importerUtil = container.resolve("ImporterUtil"); - const modImporter = container.resolve("PreAkiModLoader"); - const path = modImporter.getModPath("16ImporterUtil"); + const importerUtil = container.resolve("ImporterUtil"); + const modImporter = container.resolve("PreAkiModLoader"); + const path = modImporter.getModPath("16ImporterUtil"); - const configPath = `${path}config/`; - return importerUtil - .loadAsync(configPath) - .then((configs) => { - logger.info( - `17ImporterWithDependency2 Configurations found: ${JSON.stringify( - configs, - )}`, - ); - }); - } + const configPath = `${path}config/`; + return importerUtil + .loadAsync(configPath) + .then((configs) => { + logger.info( + `17ImporterWithDependency2 Configurations found: ${JSON.stringify( + configs, + )}`, + ); + }); + } } -module.exports = { mod: new Mod() }; +export const mod = new Mod(); diff --git a/TypeScript/17AsyncImporterWithDependency2/src/model/ConfigsModel.ts b/TypeScript/17AsyncImporterWithDependency2/src/model/ConfigsModel.ts index 07c5138..a6f1ee9 100644 --- a/TypeScript/17AsyncImporterWithDependency2/src/model/ConfigsModel.ts +++ b/TypeScript/17AsyncImporterWithDependency2/src/model/ConfigsModel.ts @@ -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; } diff --git a/TypeScript/17AsyncImporterWithDependency2/tsconfig.json b/TypeScript/17AsyncImporterWithDependency2/tsconfig.json index eca7728..c5ca53f 100644 --- a/TypeScript/17AsyncImporterWithDependency2/tsconfig.json +++ b/TypeScript/17AsyncImporterWithDependency2/tsconfig.json @@ -11,8 +11,8 @@ "resolveJsonModule": true, "outDir": "tmp", "paths": { - "@spt-aki/*": [ "./types/*" ], + "@spt-aki/*": ["./types/*"], }, }, - "exclude": [ "node_modules", "dist", "tmp" ], -} \ No newline at end of file + "exclude": ["node_modules", "dist", "tmp"], +} diff --git a/TypeScript/18CustomItemService/.eslintignore b/TypeScript/18CustomItemService/.eslintignore index 9922d9a..f7dd9e1 100644 --- a/TypeScript/18CustomItemService/.eslintignore +++ b/TypeScript/18CustomItemService/.eslintignore @@ -1,9 +1,10 @@ # Exclude these folders from linting -node_modules -dist/ -types/ +**/node_modules +/tmp +/dist +/types # Exclude these filetypes from linting *.json *.txt -*.exe \ No newline at end of file +*.exe diff --git a/TypeScript/18CustomItemService/.eslintrc.json b/TypeScript/18CustomItemService/.eslintrc.json index 071a313..757b0bd 100644 --- a/TypeScript/18CustomItemService/.eslintrc.json +++ b/TypeScript/18CustomItemService/.eslintrc.json @@ -95,4 +95,4 @@ } } ] -} \ No newline at end of file +} diff --git a/TypeScript/18CustomItemService/README.md b/TypeScript/18CustomItemService/README.md index e760f8b..3bd5a99 100644 --- a/TypeScript/18CustomItemService/README.md +++ b/TypeScript/18CustomItemService/README.md @@ -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/). diff --git a/TypeScript/18CustomItemService/build.mjs b/TypeScript/18CustomItemService/build.mjs index d00117c..d5a679f 100644 --- a/TypeScript/18CustomItemService/build.mjs +++ b/TypeScript/18CustomItemService/build.mjs @@ -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(); } /** diff --git a/TypeScript/18CustomItemService/mod.code-workspace b/TypeScript/18CustomItemService/mod.code-workspace index 6732c67..090d8e7 100644 --- a/TypeScript/18CustomItemService/mod.code-workspace +++ b/TypeScript/18CustomItemService/mod.code-workspace @@ -1,12 +1,13 @@ { - "folders": [ - { - "path": "." - } - ], - "extensions": { - "recommendations": [ - "dbaeumer.vscode-eslint" - ] - } -} \ No newline at end of file + "folders": [ + { + "path": "." + } + ], + "extensions": { + "recommendations": [ + "dbaeumer.vscode-eslint", + "refringe.spt-id-highlighter" + ] + } +} diff --git a/TypeScript/18CustomItemService/package.json b/TypeScript/18CustomItemService/package.json index b825dee..f9854d3 100644 --- a/TypeScript/18CustomItemService/package.json +++ b/TypeScript/18CustomItemService/package.json @@ -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" } diff --git a/TypeScript/18CustomItemService/src/mod.ts b/TypeScript/18CustomItemService/src/mod.ts index b9493d0..100d342 100644 --- a/TypeScript/18CustomItemService/src/mod.ts +++ b/TypeScript/18CustomItemService/src/mod.ts @@ -8,7 +8,7 @@ import { DatabaseServer } from "@spt-aki/servers/DatabaseServer"; class Mod implements IPostDBLoadMod, IPostAkiLoadMod { - public postDBLoad(container: DependencyContainer): void + public postDBLoad(container: DependencyContainer): void { // Resolve the CustomItemService container const CustomItem = container.resolve("CustomItemService"); @@ -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"); const item = db.getTables().templates.items; - console.log(item["CustomMP18"]._props) + console.log(item["CustomMP18"]._props); } } -module.exports = { mod: new Mod() } \ No newline at end of file +export const mod = new Mod(); diff --git a/TypeScript/18CustomItemService/tsconfig.json b/TypeScript/18CustomItemService/tsconfig.json index eca7728..c5ca53f 100644 --- a/TypeScript/18CustomItemService/tsconfig.json +++ b/TypeScript/18CustomItemService/tsconfig.json @@ -11,8 +11,8 @@ "resolveJsonModule": true, "outDir": "tmp", "paths": { - "@spt-aki/*": [ "./types/*" ], + "@spt-aki/*": ["./types/*"], }, }, - "exclude": [ "node_modules", "dist", "tmp" ], -} \ No newline at end of file + "exclude": ["node_modules", "dist", "tmp"], +} diff --git a/TypeScript/19UseExternalLibraries/.eslintignore b/TypeScript/19UseExternalLibraries/.eslintignore index 9922d9a..f7dd9e1 100644 --- a/TypeScript/19UseExternalLibraries/.eslintignore +++ b/TypeScript/19UseExternalLibraries/.eslintignore @@ -1,9 +1,10 @@ # Exclude these folders from linting -node_modules -dist/ -types/ +**/node_modules +/tmp +/dist +/types # Exclude these filetypes from linting *.json *.txt -*.exe \ No newline at end of file +*.exe diff --git a/TypeScript/19UseExternalLibraries/.eslintrc.json b/TypeScript/19UseExternalLibraries/.eslintrc.json index 071a313..757b0bd 100644 --- a/TypeScript/19UseExternalLibraries/.eslintrc.json +++ b/TypeScript/19UseExternalLibraries/.eslintrc.json @@ -95,4 +95,4 @@ } } ] -} \ No newline at end of file +} diff --git a/TypeScript/19UseExternalLibraries/README.md b/TypeScript/19UseExternalLibraries/README.md index e760f8b..3bd5a99 100644 --- a/TypeScript/19UseExternalLibraries/README.md +++ b/TypeScript/19UseExternalLibraries/README.md @@ -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/). diff --git a/TypeScript/19UseExternalLibraries/build.mjs b/TypeScript/19UseExternalLibraries/build.mjs index d00117c..d5a679f 100644 --- a/TypeScript/19UseExternalLibraries/build.mjs +++ b/TypeScript/19UseExternalLibraries/build.mjs @@ -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(); } /** diff --git a/TypeScript/19UseExternalLibraries/mod.code-workspace b/TypeScript/19UseExternalLibraries/mod.code-workspace index 6732c67..090d8e7 100644 --- a/TypeScript/19UseExternalLibraries/mod.code-workspace +++ b/TypeScript/19UseExternalLibraries/mod.code-workspace @@ -1,12 +1,13 @@ { - "folders": [ - { - "path": "." - } - ], - "extensions": { - "recommendations": [ - "dbaeumer.vscode-eslint" - ] - } -} \ No newline at end of file + "folders": [ + { + "path": "." + } + ], + "extensions": { + "recommendations": [ + "dbaeumer.vscode-eslint", + "refringe.spt-id-highlighter" + ] + } +} diff --git a/TypeScript/19UseExternalLibraries/package.json b/TypeScript/19UseExternalLibraries/package.json index 4361630..4b54b64 100644 --- a/TypeScript/19UseExternalLibraries/package.json +++ b/TypeScript/19UseExternalLibraries/package.json @@ -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" } diff --git a/TypeScript/19UseExternalLibraries/pnpm-lock.yaml b/TypeScript/19UseExternalLibraries/pnpm-lock.yaml deleted file mode 100644 index b21be0a..0000000 --- a/TypeScript/19UseExternalLibraries/pnpm-lock.yaml +++ /dev/null @@ -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 diff --git a/TypeScript/19UseExternalLibraries/src/mod.ts b/TypeScript/19UseExternalLibraries/src/mod.ts index 48d6f18..13bd96b 100644 --- a/TypeScript/19UseExternalLibraries/src/mod.ts +++ b/TypeScript/19UseExternalLibraries/src/mod.ts @@ -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"); - const logger = container.resolve("WinstonLogger"); + public preAkiLoad(container: DependencyContainer): void { + const vfs = container.resolve("VFS"); + const logger = container.resolve("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(); diff --git a/TypeScript/19UseExternalLibraries/test.jsonc b/TypeScript/19UseExternalLibraries/test.jsonc index 5bc6ea6..c330460 100644 --- a/TypeScript/19UseExternalLibraries/test.jsonc +++ b/TypeScript/19UseExternalLibraries/test.jsonc @@ -1,4 +1,4 @@ // comment { - "data": /* comment */ "value" + "data": /* comment */ "value" } diff --git a/TypeScript/19UseExternalLibraries/tsconfig.json b/TypeScript/19UseExternalLibraries/tsconfig.json index eca7728..c5ca53f 100644 --- a/TypeScript/19UseExternalLibraries/tsconfig.json +++ b/TypeScript/19UseExternalLibraries/tsconfig.json @@ -11,8 +11,8 @@ "resolveJsonModule": true, "outDir": "tmp", "paths": { - "@spt-aki/*": [ "./types/*" ], + "@spt-aki/*": ["./types/*"], }, }, - "exclude": [ "node_modules", "dist", "tmp" ], -} \ No newline at end of file + "exclude": ["node_modules", "dist", "tmp"], +} diff --git a/TypeScript/1LogToConsole/.eslintignore b/TypeScript/1LogToConsole/.eslintignore index 9922d9a..f7dd9e1 100644 --- a/TypeScript/1LogToConsole/.eslintignore +++ b/TypeScript/1LogToConsole/.eslintignore @@ -1,9 +1,10 @@ # Exclude these folders from linting -node_modules -dist/ -types/ +**/node_modules +/tmp +/dist +/types # Exclude these filetypes from linting *.json *.txt -*.exe \ No newline at end of file +*.exe diff --git a/TypeScript/1LogToConsole/.eslintrc.json b/TypeScript/1LogToConsole/.eslintrc.json index 071a313..757b0bd 100644 --- a/TypeScript/1LogToConsole/.eslintrc.json +++ b/TypeScript/1LogToConsole/.eslintrc.json @@ -95,4 +95,4 @@ } } ] -} \ No newline at end of file +} diff --git a/TypeScript/1LogToConsole/README.md b/TypeScript/1LogToConsole/README.md index e760f8b..3bd5a99 100644 --- a/TypeScript/1LogToConsole/README.md +++ b/TypeScript/1LogToConsole/README.md @@ -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/). diff --git a/TypeScript/1LogToConsole/build.mjs b/TypeScript/1LogToConsole/build.mjs index d00117c..d5a679f 100644 --- a/TypeScript/1LogToConsole/build.mjs +++ b/TypeScript/1LogToConsole/build.mjs @@ -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(); } /** diff --git a/TypeScript/1LogToConsole/mod.code-workspace b/TypeScript/1LogToConsole/mod.code-workspace index 6732c67..090d8e7 100644 --- a/TypeScript/1LogToConsole/mod.code-workspace +++ b/TypeScript/1LogToConsole/mod.code-workspace @@ -1,12 +1,13 @@ { - "folders": [ - { - "path": "." - } - ], - "extensions": { - "recommendations": [ - "dbaeumer.vscode-eslint" - ] - } -} \ No newline at end of file + "folders": [ + { + "path": "." + } + ], + "extensions": { + "recommendations": [ + "dbaeumer.vscode-eslint", + "refringe.spt-id-highlighter" + ] + } +} diff --git a/TypeScript/1LogToConsole/package.json b/TypeScript/1LogToConsole/package.json index d9875ce..642d0d4 100644 --- a/TypeScript/1LogToConsole/package.json +++ b/TypeScript/1LogToConsole/package.json @@ -1,15 +1,12 @@ { "name": "LogToConsole", "version": "1.0.0", - "main": "src/mod.js", - "license": "MIT", - "author": "Chomp", "akiVersion": "~3.9", - "loadBefore": [], - "loadAfter": [], - "incompatibilities": [], - "contributors": [], - "isBundleMod": false, + "loadBefore": [], + "loadAfter": [], + "incompatibilities": [], + "isBundleMod": false, + "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" } diff --git a/TypeScript/1LogToConsole/src/mod.ts b/TypeScript/1LogToConsole/src/mod.ts index 43ffdd0..ccbb988 100644 --- a/TypeScript/1LogToConsole/src/mod.ts +++ b/TypeScript/1LogToConsole/src/mod.ts @@ -1,4 +1,5 @@ import { DependencyContainer } from "tsyringe"; + import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; import { LogTextColor } from "@spt-aki/models/spt/logging/LogTextColor"; @@ -7,11 +8,11 @@ import { LogBackgroundColor } from "@spt-aki/models/spt/logging/LogBackgroundCol class Mod implements IPreAkiLoadMod { // Code added here will load BEFORE the server has started loading - preAkiLoad(container: DependencyContainer): void + public preAkiLoad(container: DependencyContainer): void { // get the logger from the server container const logger = container.resolve("WinstonLogger"); - + logger.info("I am logging info!"); logger.warning("I am logging a warning!"); logger.error("I am logging an error!"); @@ -19,4 +20,4 @@ class Mod implements IPreAkiLoadMod } } -module.exports = { mod: new Mod() } \ No newline at end of file +export const mod = new Mod(); diff --git a/TypeScript/1LogToConsole/tsconfig.json b/TypeScript/1LogToConsole/tsconfig.json index eca7728..c5ca53f 100644 --- a/TypeScript/1LogToConsole/tsconfig.json +++ b/TypeScript/1LogToConsole/tsconfig.json @@ -11,8 +11,8 @@ "resolveJsonModule": true, "outDir": "tmp", "paths": { - "@spt-aki/*": [ "./types/*" ], + "@spt-aki/*": ["./types/*"], }, }, - "exclude": [ "node_modules", "dist", "tmp" ], -} \ No newline at end of file + "exclude": ["node_modules", "dist", "tmp"], +} diff --git a/TypeScript/20CustomChatBot/.eslintignore b/TypeScript/20CustomChatBot/.eslintignore index 9922d9a..f7dd9e1 100644 --- a/TypeScript/20CustomChatBot/.eslintignore +++ b/TypeScript/20CustomChatBot/.eslintignore @@ -1,9 +1,10 @@ # Exclude these folders from linting -node_modules -dist/ -types/ +**/node_modules +/tmp +/dist +/types # Exclude these filetypes from linting *.json *.txt -*.exe \ No newline at end of file +*.exe diff --git a/TypeScript/20CustomChatBot/.eslintrc.json b/TypeScript/20CustomChatBot/.eslintrc.json index 071a313..757b0bd 100644 --- a/TypeScript/20CustomChatBot/.eslintrc.json +++ b/TypeScript/20CustomChatBot/.eslintrc.json @@ -95,4 +95,4 @@ } } ] -} \ No newline at end of file +} diff --git a/TypeScript/20CustomChatBot/README.md b/TypeScript/20CustomChatBot/README.md index e760f8b..3bd5a99 100644 --- a/TypeScript/20CustomChatBot/README.md +++ b/TypeScript/20CustomChatBot/README.md @@ -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/). diff --git a/TypeScript/20CustomChatBot/build.mjs b/TypeScript/20CustomChatBot/build.mjs index d00117c..d5a679f 100644 --- a/TypeScript/20CustomChatBot/build.mjs +++ b/TypeScript/20CustomChatBot/build.mjs @@ -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(); } /** diff --git a/TypeScript/20CustomChatBot/mod.code-workspace b/TypeScript/20CustomChatBot/mod.code-workspace index 6732c67..090d8e7 100644 --- a/TypeScript/20CustomChatBot/mod.code-workspace +++ b/TypeScript/20CustomChatBot/mod.code-workspace @@ -1,12 +1,13 @@ { - "folders": [ - { - "path": "." - } - ], - "extensions": { - "recommendations": [ - "dbaeumer.vscode-eslint" - ] - } -} \ No newline at end of file + "folders": [ + { + "path": "." + } + ], + "extensions": { + "recommendations": [ + "dbaeumer.vscode-eslint", + "refringe.spt-id-highlighter" + ] + } +} diff --git a/TypeScript/20CustomChatBot/package.json b/TypeScript/20CustomChatBot/package.json index bef5985..04cb178 100644 --- a/TypeScript/20CustomChatBot/package.json +++ b/TypeScript/20CustomChatBot/package.json @@ -1,14 +1,12 @@ { "name": "CustomChatBot", "version": "1.0.0", - "main": "src/mod.js", - "license": "MIT", - "author": "clodan", "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" } diff --git a/TypeScript/20CustomChatBot/src/CustomChatBot.ts b/TypeScript/20CustomChatBot/src/CustomChatBot.ts index fcbe2eb..ff40aac 100644 --- a/TypeScript/20CustomChatBot/src/CustomChatBot.ts +++ b/TypeScript/20CustomChatBot/src/CustomChatBot.ts @@ -1,25 +1,26 @@ +import { inject, injectable } from "tsyringe"; + import { IDialogueChatBot } from "@spt-aki/helpers/Dialogue/IDialogueChatBot"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { MemberCategory } from "@spt-aki/models/enums/MemberCategory"; import { MailSendService } from "@spt-aki/services/MailSendService"; -import { inject, injectable } from "tsyringe"; // \/ dont forger this annotation here! @injectable() export class CustomChatBot implements IDialogueChatBot { - public constructor( + constructor( @inject("MailSendService") protected mailSendService: MailSendService, ) - { - } + {} public getChatBot(): IUserDialogInfo { return { _id: "modderBuddy", - info: { + aid: 9999999, + Info: { Level: 1, MemberCategory: MemberCategory.SHERPA, Nickname: "Buddy", @@ -37,5 +38,4 @@ export class CustomChatBot implements IDialogueChatBot ); return request.dialogId; } - } diff --git a/TypeScript/20CustomChatBot/src/mod.ts b/TypeScript/20CustomChatBot/src/mod.ts index 096d2bb..f5ad0bf 100644 --- a/TypeScript/20CustomChatBot/src/mod.ts +++ b/TypeScript/20CustomChatBot/src/mod.ts @@ -1,17 +1,15 @@ -import { DependencyContainer } from 'tsyringe'; +import { DependencyContainer } from "tsyringe"; import { IPostDBLoadMod } from "@spt-aki/models/external/IPostDBLoadMod"; import { DialogueController } from "@spt-aki/controllers/DialogueController"; -import { CustomChatBot } from './CustomChatBot'; +import { CustomChatBot } from "./CustomChatBot"; class Mod implements IPostDBLoadMod { - public postDBLoad(container: DependencyContainer): void { + public postDBLoad(container: DependencyContainer): void { // We register and re-resolve the dependency so the container takes care of filling in the command dependencies container.register("CustomChatBot", CustomChatBot); container.resolve("DialogueController").registerChatBot(container.resolve("CustomChatBot")); - } + } } -module.exports = { - mod: new Mod() -} +export const mod = new Mod(); diff --git a/TypeScript/20CustomChatBot/tsconfig.json b/TypeScript/20CustomChatBot/tsconfig.json index eca7728..c5ca53f 100644 --- a/TypeScript/20CustomChatBot/tsconfig.json +++ b/TypeScript/20CustomChatBot/tsconfig.json @@ -11,8 +11,8 @@ "resolveJsonModule": true, "outDir": "tmp", "paths": { - "@spt-aki/*": [ "./types/*" ], + "@spt-aki/*": ["./types/*"], }, }, - "exclude": [ "node_modules", "dist", "tmp" ], -} \ No newline at end of file + "exclude": ["node_modules", "dist", "tmp"], +} diff --git a/TypeScript/21CustomCommandoCommand/.eslintignore b/TypeScript/21CustomCommandoCommand/.eslintignore index 9922d9a..f7dd9e1 100644 --- a/TypeScript/21CustomCommandoCommand/.eslintignore +++ b/TypeScript/21CustomCommandoCommand/.eslintignore @@ -1,9 +1,10 @@ # Exclude these folders from linting -node_modules -dist/ -types/ +**/node_modules +/tmp +/dist +/types # Exclude these filetypes from linting *.json *.txt -*.exe \ No newline at end of file +*.exe diff --git a/TypeScript/21CustomCommandoCommand/.eslintrc.json b/TypeScript/21CustomCommandoCommand/.eslintrc.json index 071a313..757b0bd 100644 --- a/TypeScript/21CustomCommandoCommand/.eslintrc.json +++ b/TypeScript/21CustomCommandoCommand/.eslintrc.json @@ -95,4 +95,4 @@ } } ] -} \ No newline at end of file +} diff --git a/TypeScript/21CustomCommandoCommand/README.md b/TypeScript/21CustomCommandoCommand/README.md index e760f8b..3bd5a99 100644 --- a/TypeScript/21CustomCommandoCommand/README.md +++ b/TypeScript/21CustomCommandoCommand/README.md @@ -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/). diff --git a/TypeScript/21CustomCommandoCommand/build.mjs b/TypeScript/21CustomCommandoCommand/build.mjs index d00117c..d5a679f 100644 --- a/TypeScript/21CustomCommandoCommand/build.mjs +++ b/TypeScript/21CustomCommandoCommand/build.mjs @@ -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(); } /** diff --git a/TypeScript/21CustomCommandoCommand/mod.code-workspace b/TypeScript/21CustomCommandoCommand/mod.code-workspace index 6732c67..090d8e7 100644 --- a/TypeScript/21CustomCommandoCommand/mod.code-workspace +++ b/TypeScript/21CustomCommandoCommand/mod.code-workspace @@ -1,12 +1,13 @@ { - "folders": [ - { - "path": "." - } - ], - "extensions": { - "recommendations": [ - "dbaeumer.vscode-eslint" - ] - } -} \ No newline at end of file + "folders": [ + { + "path": "." + } + ], + "extensions": { + "recommendations": [ + "dbaeumer.vscode-eslint", + "refringe.spt-id-highlighter" + ] + } +} diff --git a/TypeScript/21CustomCommandoCommand/package.json b/TypeScript/21CustomCommandoCommand/package.json index 9bf0724..57abc32 100644 --- a/TypeScript/21CustomCommandoCommand/package.json +++ b/TypeScript/21CustomCommandoCommand/package.json @@ -1,14 +1,12 @@ { "name": "CustomCommandoCommand", "version": "1.0.0", - "main": "src/mod.js", - "license": "MIT", - "author": "clodan", "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" } diff --git a/TypeScript/21CustomCommandoCommand/src/CustomCommandoCommand.ts b/TypeScript/21CustomCommandoCommand/src/CustomCommandoCommand.ts index 6594aca..beffa2c 100644 --- a/TypeScript/21CustomCommandoCommand/src/CustomCommandoCommand.ts +++ b/TypeScript/21CustomCommandoCommand/src/CustomCommandoCommand.ts @@ -1,15 +1,16 @@ +import { inject, injectable } from "tsyringe"; + import { IChatCommand } from "@spt-aki/helpers/Dialogue/Commando/IChatCommand"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { DatabaseServer } from "@spt-aki/servers/DatabaseServer"; import { MailSendService } from "@spt-aki/services/MailSendService"; -import { inject, injectable } from "tsyringe"; // \/ dont forger this annotation here! @injectable() export class CustomCommandoCommand implements IChatCommand { - public constructor( + constructor( @inject("MailSendService") protected mailSendService: MailSendService, @inject("DatabaseServer") protected databaseServer: DatabaseServer, ) diff --git a/TypeScript/21CustomCommandoCommand/src/mod.ts b/TypeScript/21CustomCommandoCommand/src/mod.ts index 659ec54..98e3edd 100644 --- a/TypeScript/21CustomCommandoCommand/src/mod.ts +++ b/TypeScript/21CustomCommandoCommand/src/mod.ts @@ -1,17 +1,15 @@ -import { DependencyContainer } from 'tsyringe'; +import { DependencyContainer } from "tsyringe"; import { IPostDBLoadMod } from "@spt-aki/models/external/IPostDBLoadMod"; import { CommandoDialogueChatBot } from "@spt-aki/helpers/Dialogue/CommandoDialogueChatBot"; -import { CustomCommandoCommand } from './CustomCommandoCommand'; +import { CustomCommandoCommand } from "./CustomCommandoCommand"; class Mod implements IPostDBLoadMod { - public postDBLoad(container: DependencyContainer): void { + public postDBLoad(container: DependencyContainer): void { // We register and re-resolve the dependency so the container takes care of filling in the command dependencies container.register("CustomCommandoCommand", CustomCommandoCommand); container.resolve("CommandoDialogueChatBot").registerCommandoCommand(container.resolve("CustomCommandoCommand")); - } + } } -module.exports = { - mod: new Mod() -} +export const mod = new Mod(); diff --git a/TypeScript/21CustomCommandoCommand/tsconfig.json b/TypeScript/21CustomCommandoCommand/tsconfig.json index eca7728..c5ca53f 100644 --- a/TypeScript/21CustomCommandoCommand/tsconfig.json +++ b/TypeScript/21CustomCommandoCommand/tsconfig.json @@ -11,8 +11,8 @@ "resolveJsonModule": true, "outDir": "tmp", "paths": { - "@spt-aki/*": [ "./types/*" ], + "@spt-aki/*": ["./types/*"], }, }, - "exclude": [ "node_modules", "dist", "tmp" ], -} \ No newline at end of file + "exclude": ["node_modules", "dist", "tmp"], +} diff --git a/TypeScript/22CustomAkiCommand/.eslintignore b/TypeScript/22CustomAkiCommand/.eslintignore index 9922d9a..f7dd9e1 100644 --- a/TypeScript/22CustomAkiCommand/.eslintignore +++ b/TypeScript/22CustomAkiCommand/.eslintignore @@ -1,9 +1,10 @@ # Exclude these folders from linting -node_modules -dist/ -types/ +**/node_modules +/tmp +/dist +/types # Exclude these filetypes from linting *.json *.txt -*.exe \ No newline at end of file +*.exe diff --git a/TypeScript/22CustomAkiCommand/.eslintrc.json b/TypeScript/22CustomAkiCommand/.eslintrc.json index 071a313..757b0bd 100644 --- a/TypeScript/22CustomAkiCommand/.eslintrc.json +++ b/TypeScript/22CustomAkiCommand/.eslintrc.json @@ -95,4 +95,4 @@ } } ] -} \ No newline at end of file +} diff --git a/TypeScript/22CustomAkiCommand/README.md b/TypeScript/22CustomAkiCommand/README.md index e760f8b..3bd5a99 100644 --- a/TypeScript/22CustomAkiCommand/README.md +++ b/TypeScript/22CustomAkiCommand/README.md @@ -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/). diff --git a/TypeScript/22CustomAkiCommand/build.mjs b/TypeScript/22CustomAkiCommand/build.mjs index d00117c..d5a679f 100644 --- a/TypeScript/22CustomAkiCommand/build.mjs +++ b/TypeScript/22CustomAkiCommand/build.mjs @@ -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(); } /** diff --git a/TypeScript/22CustomAkiCommand/mod.code-workspace b/TypeScript/22CustomAkiCommand/mod.code-workspace index 6732c67..090d8e7 100644 --- a/TypeScript/22CustomAkiCommand/mod.code-workspace +++ b/TypeScript/22CustomAkiCommand/mod.code-workspace @@ -1,12 +1,13 @@ { - "folders": [ - { - "path": "." - } - ], - "extensions": { - "recommendations": [ - "dbaeumer.vscode-eslint" - ] - } -} \ No newline at end of file + "folders": [ + { + "path": "." + } + ], + "extensions": { + "recommendations": [ + "dbaeumer.vscode-eslint", + "refringe.spt-id-highlighter" + ] + } +} diff --git a/TypeScript/22CustomAkiCommand/package.json b/TypeScript/22CustomAkiCommand/package.json index 85668d5..58dee14 100644 --- a/TypeScript/22CustomAkiCommand/package.json +++ b/TypeScript/22CustomAkiCommand/package.json @@ -1,14 +1,12 @@ { "name": "CustomAkiCommand", "version": "1.0.0", - "main": "src/mod.js", - "license": "MIT", - "author": "clodan", "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" } diff --git a/TypeScript/22CustomAkiCommand/src/CustomAkiCommand.ts b/TypeScript/22CustomAkiCommand/src/CustomAkiCommand.ts index 9da52f2..7b2fff1 100644 --- a/TypeScript/22CustomAkiCommand/src/CustomAkiCommand.ts +++ b/TypeScript/22CustomAkiCommand/src/CustomAkiCommand.ts @@ -1,20 +1,20 @@ +import { inject, injectable } from "tsyringe"; + import { ISptCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/ISptCommand"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { MailSendService } from "@spt-aki/services/MailSendService"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; -import { inject, injectable } from "tsyringe"; // \/ dont forger this annotation here! @injectable() export class CustomAkiCommand implements ISptCommand { - public constructor( + constructor( @inject("ItemHelper") protected itemHelper: ItemHelper, @inject("MailSendService") protected mailSendService: MailSendService, ) - { - } + {} public getCommand(): string { @@ -23,7 +23,7 @@ export class CustomAkiCommand implements ISptCommand public getCommandHelp(): string { - return "Usage: spt getName tplId" + return "Usage: spt getName tplId"; } public performAction(commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string diff --git a/TypeScript/22CustomAkiCommand/src/mod.ts b/TypeScript/22CustomAkiCommand/src/mod.ts index a8fe228..fa4c351 100644 --- a/TypeScript/22CustomAkiCommand/src/mod.ts +++ b/TypeScript/22CustomAkiCommand/src/mod.ts @@ -1,18 +1,15 @@ -import { DependencyContainer } from 'tsyringe'; +import { DependencyContainer } from "tsyringe"; import { IPostDBLoadMod } from "@spt-aki/models/external/IPostDBLoadMod"; import { SptCommandoCommands } from "@spt-aki/helpers/Dialogue/Commando/SptCommandoCommands"; -import { CustomAkiCommand } from './CustomAkiCommand'; +import { CustomAkiCommand } from "./CustomAkiCommand"; class Mod implements IPostDBLoadMod { - public postDBLoad(container: DependencyContainer): void { + public postDBLoad(container: DependencyContainer): void { // We register and re-resolve the dependency so the container takes care of filling in the command dependencies container.register("CustomAkiCommand", CustomAkiCommand); - container.resolve("SptCommandoCommands").registerSptCommandoCommand(container.resolve("CustomAkiCommand")) - } - + container.resolve("SptCommandoCommands").registerSptCommandoCommand(container.resolve("CustomAkiCommand")); + } } -module.exports = { - mod: new Mod() -} +export const mod = new Mod(); diff --git a/TypeScript/22CustomAkiCommand/tsconfig.json b/TypeScript/22CustomAkiCommand/tsconfig.json index eca7728..c5ca53f 100644 --- a/TypeScript/22CustomAkiCommand/tsconfig.json +++ b/TypeScript/22CustomAkiCommand/tsconfig.json @@ -11,8 +11,8 @@ "resolveJsonModule": true, "outDir": "tmp", "paths": { - "@spt-aki/*": [ "./types/*" ], + "@spt-aki/*": ["./types/*"], }, }, - "exclude": [ "node_modules", "dist", "tmp" ], -} \ No newline at end of file + "exclude": ["node_modules", "dist", "tmp"], +} diff --git a/TypeScript/23CustomAbstractChatBot/.eslintignore b/TypeScript/23CustomAbstractChatBot/.eslintignore index 9922d9a..f7dd9e1 100644 --- a/TypeScript/23CustomAbstractChatBot/.eslintignore +++ b/TypeScript/23CustomAbstractChatBot/.eslintignore @@ -1,9 +1,10 @@ # Exclude these folders from linting -node_modules -dist/ -types/ +**/node_modules +/tmp +/dist +/types # Exclude these filetypes from linting *.json *.txt -*.exe \ No newline at end of file +*.exe diff --git a/TypeScript/23CustomAbstractChatBot/.eslintrc.json b/TypeScript/23CustomAbstractChatBot/.eslintrc.json index 071a313..757b0bd 100644 --- a/TypeScript/23CustomAbstractChatBot/.eslintrc.json +++ b/TypeScript/23CustomAbstractChatBot/.eslintrc.json @@ -95,4 +95,4 @@ } } ] -} \ No newline at end of file +} diff --git a/TypeScript/23CustomAbstractChatBot/README.md b/TypeScript/23CustomAbstractChatBot/README.md index e760f8b..3bd5a99 100644 --- a/TypeScript/23CustomAbstractChatBot/README.md +++ b/TypeScript/23CustomAbstractChatBot/README.md @@ -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/). diff --git a/TypeScript/23CustomAbstractChatBot/build.mjs b/TypeScript/23CustomAbstractChatBot/build.mjs index d00117c..d5a679f 100644 --- a/TypeScript/23CustomAbstractChatBot/build.mjs +++ b/TypeScript/23CustomAbstractChatBot/build.mjs @@ -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(); } /** diff --git a/TypeScript/23CustomAbstractChatBot/mod.code-workspace b/TypeScript/23CustomAbstractChatBot/mod.code-workspace index 6732c67..090d8e7 100644 --- a/TypeScript/23CustomAbstractChatBot/mod.code-workspace +++ b/TypeScript/23CustomAbstractChatBot/mod.code-workspace @@ -1,12 +1,13 @@ { - "folders": [ - { - "path": "." - } - ], - "extensions": { - "recommendations": [ - "dbaeumer.vscode-eslint" - ] - } -} \ No newline at end of file + "folders": [ + { + "path": "." + } + ], + "extensions": { + "recommendations": [ + "dbaeumer.vscode-eslint", + "refringe.spt-id-highlighter" + ] + } +} diff --git a/TypeScript/23CustomAbstractChatBot/package.json b/TypeScript/23CustomAbstractChatBot/package.json index e9c3aa0..140bb8e 100644 --- a/TypeScript/23CustomAbstractChatBot/package.json +++ b/TypeScript/23CustomAbstractChatBot/package.json @@ -1,14 +1,12 @@ { "name": "CustomAbstractChatBot", "version": "1.0.0", - "main": "src/mod.js", - "license": "MIT", - "author": "clodan", "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" } diff --git a/TypeScript/23CustomAbstractChatBot/src/AnotherCoolCommand.ts b/TypeScript/23CustomAbstractChatBot/src/AnotherCoolCommand.ts index 05a5bfa..b598ea7 100644 --- a/TypeScript/23CustomAbstractChatBot/src/AnotherCoolCommand.ts +++ b/TypeScript/23CustomAbstractChatBot/src/AnotherCoolCommand.ts @@ -1,15 +1,16 @@ +import { inject, injectable } from "tsyringe"; + import { IChatCommand } from "@spt-aki/helpers/Dialogue/Commando/IChatCommand"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { MailSendService } from "@spt-aki/services/MailSendService"; -import { inject, injectable } from "tsyringe"; // \/ dont forger this annotation here! @injectable() export class AnotherCoolCommand implements IChatCommand { constructor( - @inject("MailSendService") protected mailSendService: MailSendService + @inject("MailSendService") protected mailSendService: MailSendService, ) {} @@ -25,7 +26,7 @@ export class AnotherCoolCommand implements IChatCommand return "Usage: anotherExample test"; } } - + public getCommands(): Set { return new Set(["test"]); @@ -39,5 +40,4 @@ export class AnotherCoolCommand implements IChatCommand return request.dialogId; } } - } diff --git a/TypeScript/23CustomAbstractChatBot/src/CustomSimpleChatBot.ts b/TypeScript/23CustomAbstractChatBot/src/CustomSimpleChatBot.ts index 57ee067..d8fe7aa 100644 --- a/TypeScript/23CustomAbstractChatBot/src/CustomSimpleChatBot.ts +++ b/TypeScript/23CustomAbstractChatBot/src/CustomSimpleChatBot.ts @@ -1,16 +1,17 @@ +import { inject, injectAll, injectable } from "tsyringe"; + import { AbstractDialogueChatBot } from "@spt-aki/helpers/Dialogue/AbstractDialogueChatBot"; import { IChatCommand } from "@spt-aki/helpers/Dialogue/Commando/IChatCommand"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { MemberCategory } from "@spt-aki/models/enums/MemberCategory"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; import { MailSendService } from "@spt-aki/services/MailSendService"; -import { inject, injectAll, injectable } from "tsyringe"; // \/ dont forger this annotation here! @injectable() export class CustomSimpleChatBot extends AbstractDialogueChatBot { - public constructor( + constructor( @inject("WinstonLogger") logger: ILogger, @inject("MailSendService") mailSendService: MailSendService, // Remember to replace MyCommand for something unique to your mod! @@ -19,7 +20,7 @@ export class CustomSimpleChatBot extends AbstractDialogueChatBot @injectAll("MyCommand") chatCommands: IChatCommand[], ) { - super(logger, mailSendService, chatCommands) + super(logger, mailSendService, chatCommands); } public getChatBot(): IUserDialogInfo @@ -37,7 +38,6 @@ export class CustomSimpleChatBot extends AbstractDialogueChatBot protected getUnrecognizedCommandMessage(): string { - return "No clue what you are talking about bud!" + return "No clue what you are talking about bud!"; } - } diff --git a/TypeScript/23CustomAbstractChatBot/src/MyCoolCommand.ts b/TypeScript/23CustomAbstractChatBot/src/MyCoolCommand.ts index 17143bd..49696e2 100644 --- a/TypeScript/23CustomAbstractChatBot/src/MyCoolCommand.ts +++ b/TypeScript/23CustomAbstractChatBot/src/MyCoolCommand.ts @@ -1,15 +1,16 @@ +import { inject, injectable } from "tsyringe"; + import { IChatCommand } from "@spt-aki/helpers/Dialogue/Commando/IChatCommand"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { MailSendService } from "@spt-aki/services/MailSendService"; -import { inject, injectable } from "tsyringe"; // \/ dont forger this annotation here! @injectable() export class MyCoolCommand implements IChatCommand { constructor( - @inject("MailSendService") protected mailSendService: MailSendService + @inject("MailSendService") protected mailSendService: MailSendService, ) {} @@ -39,5 +40,4 @@ export class MyCoolCommand implements IChatCommand return request.dialogId; } } - } diff --git a/TypeScript/23CustomAbstractChatBot/src/mod.ts b/TypeScript/23CustomAbstractChatBot/src/mod.ts index 6f108e9..cea8a8c 100644 --- a/TypeScript/23CustomAbstractChatBot/src/mod.ts +++ b/TypeScript/23CustomAbstractChatBot/src/mod.ts @@ -1,13 +1,13 @@ -import { DependencyContainer } from 'tsyringe'; +import { DependencyContainer } from "tsyringe"; import { IPostDBLoadMod } from "@spt-aki/models/external/IPostDBLoadMod"; import { DialogueController } from "@spt-aki/controllers/DialogueController"; -import { CustomSimpleChatBot } from './CustomSimpleChatBot'; -import { MyCoolCommand } from './MyCoolCommand'; -import { AnotherCoolCommand } from './AnotherCoolCommand'; +import { CustomSimpleChatBot } from "./CustomSimpleChatBot"; +import { MyCoolCommand } from "./MyCoolCommand"; +import { AnotherCoolCommand } from "./AnotherCoolCommand"; class Mod implements IPostDBLoadMod { - public postDBLoad(container: DependencyContainer): void { + public postDBLoad(container: DependencyContainer): void { // We register our commands so they get resolved by our chat bot: container.register("MyCoolCommand", MyCoolCommand); container.register("AnotherCoolCommand", AnotherCoolCommand); @@ -18,9 +18,7 @@ class Mod implements IPostDBLoadMod { // We register and re-resolve the dependency so the container takes care of filling in the command dependencies container.register("CustomSimpleChatBot", CustomSimpleChatBot); container.resolve("DialogueController").registerChatBot(container.resolve("CustomSimpleChatBot")); - } + } } -module.exports = { - mod: new Mod() -} +export const mod = new Mod(); diff --git a/TypeScript/23CustomAbstractChatBot/tsconfig.json b/TypeScript/23CustomAbstractChatBot/tsconfig.json index eca7728..c5ca53f 100644 --- a/TypeScript/23CustomAbstractChatBot/tsconfig.json +++ b/TypeScript/23CustomAbstractChatBot/tsconfig.json @@ -11,8 +11,8 @@ "resolveJsonModule": true, "outDir": "tmp", "paths": { - "@spt-aki/*": [ "./types/*" ], + "@spt-aki/*": ["./types/*"], }, }, - "exclude": [ "node_modules", "dist", "tmp" ], -} \ No newline at end of file + "exclude": ["node_modules", "dist", "tmp"], +} diff --git a/TypeScript/24WebSocket/.eslintignore b/TypeScript/24WebSocket/.eslintignore index 9922d9a..f7dd9e1 100644 --- a/TypeScript/24WebSocket/.eslintignore +++ b/TypeScript/24WebSocket/.eslintignore @@ -1,9 +1,10 @@ # Exclude these folders from linting -node_modules -dist/ -types/ +**/node_modules +/tmp +/dist +/types # Exclude these filetypes from linting *.json *.txt -*.exe \ No newline at end of file +*.exe diff --git a/TypeScript/24WebSocket/.eslintrc.json b/TypeScript/24WebSocket/.eslintrc.json index 071a313..757b0bd 100644 --- a/TypeScript/24WebSocket/.eslintrc.json +++ b/TypeScript/24WebSocket/.eslintrc.json @@ -95,4 +95,4 @@ } } ] -} \ No newline at end of file +} diff --git a/TypeScript/24WebSocket/README.md b/TypeScript/24WebSocket/README.md index e760f8b..3bd5a99 100644 --- a/TypeScript/24WebSocket/README.md +++ b/TypeScript/24WebSocket/README.md @@ -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/). diff --git a/TypeScript/24WebSocket/build.mjs b/TypeScript/24WebSocket/build.mjs index d00117c..d5a679f 100644 --- a/TypeScript/24WebSocket/build.mjs +++ b/TypeScript/24WebSocket/build.mjs @@ -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(); } /** diff --git a/TypeScript/24WebSocket/mod.code-workspace b/TypeScript/24WebSocket/mod.code-workspace index 6732c67..090d8e7 100644 --- a/TypeScript/24WebSocket/mod.code-workspace +++ b/TypeScript/24WebSocket/mod.code-workspace @@ -1,12 +1,13 @@ { - "folders": [ - { - "path": "." - } - ], - "extensions": { - "recommendations": [ - "dbaeumer.vscode-eslint" - ] - } -} \ No newline at end of file + "folders": [ + { + "path": "." + } + ], + "extensions": { + "recommendations": [ + "dbaeumer.vscode-eslint", + "refringe.spt-id-highlighter" + ] + } +} diff --git a/TypeScript/24WebSocket/package.json b/TypeScript/24WebSocket/package.json index 260b207..ffb76e9 100644 --- a/TypeScript/24WebSocket/package.json +++ b/TypeScript/24WebSocket/package.json @@ -1,14 +1,12 @@ { "name": "WebSocket", "version": "1.0.0", - "main": "src/mod.js", - "license": "MIT", - "author": "clodan", "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" } diff --git a/TypeScript/24WebSocket/src/CustomAkiWebSocketMessageHandler.ts b/TypeScript/24WebSocket/src/CustomAkiWebSocketMessageHandler.ts index 834ae0f..a817a10 100644 --- a/TypeScript/24WebSocket/src/CustomAkiWebSocketMessageHandler.ts +++ b/TypeScript/24WebSocket/src/CustomAkiWebSocketMessageHandler.ts @@ -1,17 +1,20 @@ import { inject, injectable } from "tsyringe"; -import { IAkiWebSocketMessageHandler } from "@spt-aki/servers/ws/message/IAkiWebSocketMessageHandler"; import { WebSocket, RawData } from "ws"; + +import { IAkiWebSocketMessageHandler } from "@spt-aki/servers/ws/message/IAkiWebSocketMessageHandler"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; // \/ dont forger this annotation here! @injectable() export class CustomAkiWebSocketMessageHandler implements IAkiWebSocketMessageHandler { - constructor(@inject("WinstonLogger") protected logger: ILogger) + constructor( + @inject("WinstonLogger") protected logger: ILogger, + ) {} - + public onAkiMessage(sessionID: string, client: WebSocket, message: RawData): void { - this.logger.info(`Custom AKI WebSocket Message handler received a message for ${sessionID}: ${message.toString()}`) + this.logger.info(`Custom AKI WebSocket Message handler received a message for ${sessionID}: ${message.toString()}`); } } diff --git a/TypeScript/24WebSocket/src/CustomWebSocketConnectionHandler.ts b/TypeScript/24WebSocket/src/CustomWebSocketConnectionHandler.ts index 6fd899b..9dd0ec8 100644 --- a/TypeScript/24WebSocket/src/CustomWebSocketConnectionHandler.ts +++ b/TypeScript/24WebSocket/src/CustomWebSocketConnectionHandler.ts @@ -1,16 +1,18 @@ +import { IncomingMessage } from "node:http"; +import { inject, injectable } from "tsyringe"; +import { WebSocket } from "ws"; + import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; import { IWebSocketConnectionHandler } from "@spt-aki/servers/ws/IWebSocketConnectionHandler"; -import { IncomingMessage } from "http"; -import { inject, injectable } from "tsyringe"; -import { WebSocket, RawData } from "ws"; // \/ dont forger this annotation here! @injectable() export class CustomWebSocketConnectionHandler implements IWebSocketConnectionHandler { - constructor(@inject("WinstonLogger") protected logger: ILogger) - { - } + constructor( + @inject("WinstonLogger") protected logger: ILogger, + ) + {} public getSocketId(): string { @@ -25,11 +27,11 @@ export class CustomWebSocketConnectionHandler implements IWebSocketConnectionHan public onConnection(ws: WebSocket, req: IncomingMessage): void { this.logger.info("Custom web socket is now connected!"); - ws.on("message", (msg) => + ws.on("message", (msg) => { if (msg.toString() === "toodaloo") { - ws.send("toodaloo back!") + ws.send("toodaloo back!"); } }); } diff --git a/TypeScript/24WebSocket/src/mod.ts b/TypeScript/24WebSocket/src/mod.ts index c8c1e4b..e1f9e1b 100644 --- a/TypeScript/24WebSocket/src/mod.ts +++ b/TypeScript/24WebSocket/src/mod.ts @@ -1,11 +1,10 @@ -import { DependencyContainer } from 'tsyringe'; +import { DependencyContainer } from "tsyringe"; import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod"; -import { CustomWebSocketConnectionHandler } from './CustomWebSocketConnectionHandler'; -import { IWebSocketConnectionHandler } from '@spt-aki/servers/ws/IWebSocketConnectionHandler'; -import { CustomAkiWebSocketMessageHandler } from './CustomAkiWebSocketMessageHandler'; -import { IAkiWebSocketMessageHandler } from '@spt-aki/servers/ws/message/IAkiWebSocketMessageHandler'; - +import { CustomWebSocketConnectionHandler } from "./CustomWebSocketConnectionHandler"; +import { IWebSocketConnectionHandler } from "@spt-aki/servers/ws/IWebSocketConnectionHandler"; +import { CustomAkiWebSocketMessageHandler } from "./CustomAkiWebSocketMessageHandler"; +import { IAkiWebSocketMessageHandler } from "@spt-aki/servers/ws/message/IAkiWebSocketMessageHandler"; class Mod implements IPreAkiLoadMod { public preAkiLoad(container: DependencyContainer): void { @@ -18,6 +17,4 @@ class Mod implements IPreAkiLoadMod { } } -module.exports = { - mod: new Mod() -} +export const mod = new Mod(); diff --git a/TypeScript/24WebSocket/tsconfig.json b/TypeScript/24WebSocket/tsconfig.json index eca7728..c5ca53f 100644 --- a/TypeScript/24WebSocket/tsconfig.json +++ b/TypeScript/24WebSocket/tsconfig.json @@ -11,8 +11,8 @@ "resolveJsonModule": true, "outDir": "tmp", "paths": { - "@spt-aki/*": [ "./types/*" ], + "@spt-aki/*": ["./types/*"], }, }, - "exclude": [ "node_modules", "dist", "tmp" ], -} \ No newline at end of file + "exclude": ["node_modules", "dist", "tmp"], +} diff --git a/TypeScript/2EditDatabase/.eslintignore b/TypeScript/2EditDatabase/.eslintignore index 9922d9a..f7dd9e1 100644 --- a/TypeScript/2EditDatabase/.eslintignore +++ b/TypeScript/2EditDatabase/.eslintignore @@ -1,9 +1,10 @@ # Exclude these folders from linting -node_modules -dist/ -types/ +**/node_modules +/tmp +/dist +/types # Exclude these filetypes from linting *.json *.txt -*.exe \ No newline at end of file +*.exe diff --git a/TypeScript/2EditDatabase/.eslintrc.json b/TypeScript/2EditDatabase/.eslintrc.json index 071a313..757b0bd 100644 --- a/TypeScript/2EditDatabase/.eslintrc.json +++ b/TypeScript/2EditDatabase/.eslintrc.json @@ -95,4 +95,4 @@ } } ] -} \ No newline at end of file +} diff --git a/TypeScript/2EditDatabase/README.md b/TypeScript/2EditDatabase/README.md index e760f8b..3bd5a99 100644 --- a/TypeScript/2EditDatabase/README.md +++ b/TypeScript/2EditDatabase/README.md @@ -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/). diff --git a/TypeScript/2EditDatabase/build.mjs b/TypeScript/2EditDatabase/build.mjs index d00117c..d5a679f 100644 --- a/TypeScript/2EditDatabase/build.mjs +++ b/TypeScript/2EditDatabase/build.mjs @@ -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(); } /** diff --git a/TypeScript/2EditDatabase/mod.code-workspace b/TypeScript/2EditDatabase/mod.code-workspace index 6732c67..090d8e7 100644 --- a/TypeScript/2EditDatabase/mod.code-workspace +++ b/TypeScript/2EditDatabase/mod.code-workspace @@ -1,12 +1,13 @@ { - "folders": [ - { - "path": "." - } - ], - "extensions": { - "recommendations": [ - "dbaeumer.vscode-eslint" - ] - } -} \ No newline at end of file + "folders": [ + { + "path": "." + } + ], + "extensions": { + "recommendations": [ + "dbaeumer.vscode-eslint", + "refringe.spt-id-highlighter" + ] + } +} diff --git a/TypeScript/2EditDatabase/package.json b/TypeScript/2EditDatabase/package.json index 6a12f55..c044a70 100644 --- a/TypeScript/2EditDatabase/package.json +++ b/TypeScript/2EditDatabase/package.json @@ -1,15 +1,12 @@ { "name": "EditDatabase", "version": "1.0.0", - "main": "src/mod.js", - "license": "MIT", - "author": "Chomp", "akiVersion": "~3.9", - "loadBefore": [], - "loadAfter": [], - "incompatibilities": [], - "contributors": [], - "isBundleMod": false, + "loadBefore": [], + "loadAfter": [], + "incompatibilities": [], + "isBundleMod": false, + "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" } diff --git a/TypeScript/2EditDatabase/src/mod.ts b/TypeScript/2EditDatabase/src/mod.ts index acd014b..651c628 100644 --- a/TypeScript/2EditDatabase/src/mod.ts +++ b/TypeScript/2EditDatabase/src/mod.ts @@ -8,11 +8,10 @@ import { BaseClasses } from "@spt-aki/models/enums/BaseClasses"; class Mod implements IPostDBLoadMod { - public postDBLoad(container: DependencyContainer): void + public postDBLoad(container: DependencyContainer): void { // get database from server const databaseServer = container.resolve("DatabaseServer"); - // Get all the in-memory json found in /assets/database const tables: IDatabaseTables = databaseServer.getTables(); @@ -62,4 +61,4 @@ class Mod implements IPostDBLoadMod } } -module.exports = { mod: new Mod() } \ No newline at end of file +export const mod = new Mod(); diff --git a/TypeScript/2EditDatabase/tsconfig.json b/TypeScript/2EditDatabase/tsconfig.json index eca7728..c5ca53f 100644 --- a/TypeScript/2EditDatabase/tsconfig.json +++ b/TypeScript/2EditDatabase/tsconfig.json @@ -11,8 +11,8 @@ "resolveJsonModule": true, "outDir": "tmp", "paths": { - "@spt-aki/*": [ "./types/*" ], + "@spt-aki/*": ["./types/*"], }, }, - "exclude": [ "node_modules", "dist", "tmp" ], -} \ No newline at end of file + "exclude": ["node_modules", "dist", "tmp"], +} diff --git a/TypeScript/3GetSptConfigFile/.eslintignore b/TypeScript/3GetSptConfigFile/.eslintignore index 9922d9a..f7dd9e1 100644 --- a/TypeScript/3GetSptConfigFile/.eslintignore +++ b/TypeScript/3GetSptConfigFile/.eslintignore @@ -1,9 +1,10 @@ # Exclude these folders from linting -node_modules -dist/ -types/ +**/node_modules +/tmp +/dist +/types # Exclude these filetypes from linting *.json *.txt -*.exe \ No newline at end of file +*.exe diff --git a/TypeScript/3GetSptConfigFile/.eslintrc.json b/TypeScript/3GetSptConfigFile/.eslintrc.json index 071a313..757b0bd 100644 --- a/TypeScript/3GetSptConfigFile/.eslintrc.json +++ b/TypeScript/3GetSptConfigFile/.eslintrc.json @@ -95,4 +95,4 @@ } } ] -} \ No newline at end of file +} diff --git a/TypeScript/3GetSptConfigFile/README.md b/TypeScript/3GetSptConfigFile/README.md index e760f8b..3bd5a99 100644 --- a/TypeScript/3GetSptConfigFile/README.md +++ b/TypeScript/3GetSptConfigFile/README.md @@ -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/). diff --git a/TypeScript/3GetSptConfigFile/build.mjs b/TypeScript/3GetSptConfigFile/build.mjs index d00117c..d5a679f 100644 --- a/TypeScript/3GetSptConfigFile/build.mjs +++ b/TypeScript/3GetSptConfigFile/build.mjs @@ -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(); } /** diff --git a/TypeScript/3GetSptConfigFile/mod.code-workspace b/TypeScript/3GetSptConfigFile/mod.code-workspace index 6732c67..090d8e7 100644 --- a/TypeScript/3GetSptConfigFile/mod.code-workspace +++ b/TypeScript/3GetSptConfigFile/mod.code-workspace @@ -1,12 +1,13 @@ { - "folders": [ - { - "path": "." - } - ], - "extensions": { - "recommendations": [ - "dbaeumer.vscode-eslint" - ] - } -} \ No newline at end of file + "folders": [ + { + "path": "." + } + ], + "extensions": { + "recommendations": [ + "dbaeumer.vscode-eslint", + "refringe.spt-id-highlighter" + ] + } +} diff --git a/TypeScript/3GetSptConfigFile/package.json b/TypeScript/3GetSptConfigFile/package.json index b3e4122..fdc26ad 100644 --- a/TypeScript/3GetSptConfigFile/package.json +++ b/TypeScript/3GetSptConfigFile/package.json @@ -1,15 +1,12 @@ { "name": "GetSptConfigFile", "version": "1.0.0", - "main": "src/mod.js", - "license": "MIT", - "author": "Chomp", "akiVersion": "~3.9", - "loadBefore": [], - "loadAfter": [], - "incompatibilities": [], - "contributors": [], - "isBundleMod": false, + "loadBefore": [], + "loadAfter": [], + "incompatibilities": [], + "isBundleMod": false, + "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" } diff --git a/TypeScript/3GetSptConfigFile/src/mod.ts b/TypeScript/3GetSptConfigFile/src/mod.ts index ecf1229..a4b444b 100644 --- a/TypeScript/3GetSptConfigFile/src/mod.ts +++ b/TypeScript/3GetSptConfigFile/src/mod.ts @@ -1,6 +1,6 @@ import { DependencyContainer } from "tsyringe"; -import { IPostAkiLoadMod } from "@spt-aki/models/external/IPostAkiLoadMod"; +import { IPostAkiLoadMod } from "@spt-aki/models/external/IPostAkiLoadMod"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; import { ConfigServer } from "@spt-aki/servers/ConfigServer"; import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes"; @@ -9,7 +9,7 @@ import { ILocationConfig } from "@spt-aki/models/spt/config/ILocationConfig"; class Mod implements IPostAkiLoadMod { public postAkiLoad(container: DependencyContainer): void - { + { // get logger const logger = container.resolve("WinstonLogger"); @@ -21,14 +21,14 @@ class Mod implements IPostAkiLoadMod const locationConfig: ILocationConfig = configServer.getConfig(ConfigTypes.LOCATION); // Log the original customs loose loot multipler - logger.info(`Here is the original customs map loose loot multipler: ${locationConfig.looseLootMultiplier.bigmap}`) + logger.info(`Here is the original customs map loose loot multipler: ${locationConfig.looseLootMultiplier.bigmap}`); // Adjust the multipler (customs is called bigmap in bsg land) locationConfig.looseLootMultiplier.bigmap = 10; // Log the new multipler - logger.info(`Here is the altered customs map loose loot multipler: ${locationConfig.looseLootMultiplier.bigmap}`) + logger.info(`Here is the altered customs map loose loot multipler: ${locationConfig.looseLootMultiplier.bigmap}`); } } -module.exports = { mod: new Mod() } \ No newline at end of file +export const mod = new Mod(); diff --git a/TypeScript/3GetSptConfigFile/tsconfig.json b/TypeScript/3GetSptConfigFile/tsconfig.json index eca7728..c5ca53f 100644 --- a/TypeScript/3GetSptConfigFile/tsconfig.json +++ b/TypeScript/3GetSptConfigFile/tsconfig.json @@ -11,8 +11,8 @@ "resolveJsonModule": true, "outDir": "tmp", "paths": { - "@spt-aki/*": [ "./types/*" ], + "@spt-aki/*": ["./types/*"], }, }, - "exclude": [ "node_modules", "dist", "tmp" ], -} \ No newline at end of file + "exclude": ["node_modules", "dist", "tmp"], +} diff --git a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/.eslintignore b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/.eslintignore index 9922d9a..f7dd9e1 100644 --- a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/.eslintignore +++ b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/.eslintignore @@ -1,9 +1,10 @@ # Exclude these folders from linting -node_modules -dist/ -types/ +**/node_modules +/tmp +/dist +/types # Exclude these filetypes from linting *.json *.txt -*.exe \ No newline at end of file +*.exe diff --git a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/.eslintrc.json b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/.eslintrc.json index 071a313..757b0bd 100644 --- a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/.eslintrc.json +++ b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/.eslintrc.json @@ -95,4 +95,4 @@ } } ] -} \ No newline at end of file +} diff --git a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/README.md b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/README.md index e760f8b..3bd5a99 100644 --- a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/README.md +++ b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/README.md @@ -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/). diff --git a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/build.mjs b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/build.mjs index d00117c..d5a679f 100644 --- a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/build.mjs +++ b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/build.mjs @@ -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(); } /** diff --git a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/config/config.json5 b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/config/config.json5 index 267bce5..a0e8b7b 100644 --- a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/config/config.json5 +++ b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/config/config.json5 @@ -1,3 +1,3 @@ { - "myProperty": "i love json5" -} \ No newline at end of file + myProperty: "i love json5" +} diff --git a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/config/config.jsonc b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/config/config.jsonc index 7ad6098..83bbd56 100644 --- a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/config/config.jsonc +++ b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/config/config.jsonc @@ -1,3 +1,3 @@ { - "myProperty": "i love jsonc" -} \ No newline at end of file + "myProperty": "i love jsonc" +} diff --git a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/mod.code-workspace b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/mod.code-workspace index 6732c67..090d8e7 100644 --- a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/mod.code-workspace +++ b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/mod.code-workspace @@ -1,12 +1,13 @@ { - "folders": [ - { - "path": "." - } - ], - "extensions": { - "recommendations": [ - "dbaeumer.vscode-eslint" - ] - } -} \ No newline at end of file + "folders": [ + { + "path": "." + } + ], + "extensions": { + "recommendations": [ + "dbaeumer.vscode-eslint", + "refringe.spt-id-highlighter" + ] + } +} diff --git a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/package.json b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/package.json index c209e6f..b28fa8d 100644 --- a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/package.json +++ b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/package.json @@ -1,14 +1,12 @@ { "name": "UseACustomJson5OrJsonCConfigFile", "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" } diff --git a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/src/mod.ts b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/src/mod.ts index 35bdbea..1439e17 100644 --- a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/src/mod.ts +++ b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/src/mod.ts @@ -1,3 +1,4 @@ +import path from "node:path"; import { DependencyContainer } from "tsyringe"; import { IPostAkiLoadMod } from "@spt-aki/models/external/IPostAkiLoadMod"; @@ -7,10 +8,8 @@ import { VFS } from "@spt-aki/utils/VFS"; import JSON5 from "json5"; import { jsonc } from "jsonc"; -import path from "path"; - class Mod implements IPostAkiLoadMod -{ +{ public postAkiLoad(container: DependencyContainer): void { // get logger const logger = container.resolve("WinstonLogger"); @@ -30,4 +29,4 @@ class Mod implements IPostAkiLoadMod } } -module.exports = { mod: new Mod() } \ No newline at end of file +export const mod = new Mod(); diff --git a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/tsconfig.json b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/tsconfig.json index eca7728..c5ca53f 100644 --- a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/tsconfig.json +++ b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/tsconfig.json @@ -11,8 +11,8 @@ "resolveJsonModule": true, "outDir": "tmp", "paths": { - "@spt-aki/*": [ "./types/*" ], + "@spt-aki/*": ["./types/*"], }, }, - "exclude": [ "node_modules", "dist", "tmp" ], -} \ No newline at end of file + "exclude": ["node_modules", "dist", "tmp"], +} diff --git a/TypeScript/4UseACustomConfigFile/.eslintignore b/TypeScript/4UseACustomConfigFile/.eslintignore index 9922d9a..f7dd9e1 100644 --- a/TypeScript/4UseACustomConfigFile/.eslintignore +++ b/TypeScript/4UseACustomConfigFile/.eslintignore @@ -1,9 +1,10 @@ # Exclude these folders from linting -node_modules -dist/ -types/ +**/node_modules +/tmp +/dist +/types # Exclude these filetypes from linting *.json *.txt -*.exe \ No newline at end of file +*.exe diff --git a/TypeScript/4UseACustomConfigFile/.eslintrc.json b/TypeScript/4UseACustomConfigFile/.eslintrc.json index 071a313..757b0bd 100644 --- a/TypeScript/4UseACustomConfigFile/.eslintrc.json +++ b/TypeScript/4UseACustomConfigFile/.eslintrc.json @@ -95,4 +95,4 @@ } } ] -} \ No newline at end of file +} diff --git a/TypeScript/4UseACustomConfigFile/README.md b/TypeScript/4UseACustomConfigFile/README.md index e760f8b..3bd5a99 100644 --- a/TypeScript/4UseACustomConfigFile/README.md +++ b/TypeScript/4UseACustomConfigFile/README.md @@ -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/). diff --git a/TypeScript/4UseACustomConfigFile/build.mjs b/TypeScript/4UseACustomConfigFile/build.mjs index d00117c..d5a679f 100644 --- a/TypeScript/4UseACustomConfigFile/build.mjs +++ b/TypeScript/4UseACustomConfigFile/build.mjs @@ -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(); } /** diff --git a/TypeScript/4UseACustomConfigFile/config/config.json b/TypeScript/4UseACustomConfigFile/config/config.json index 2cc3a9f..8333f59 100644 --- a/TypeScript/4UseACustomConfigFile/config/config.json +++ b/TypeScript/4UseACustomConfigFile/config/config.json @@ -1,3 +1,3 @@ { - "myProperty": "wow" -} \ No newline at end of file + "myProperty": "wow" +} diff --git a/TypeScript/4UseACustomConfigFile/mod.code-workspace b/TypeScript/4UseACustomConfigFile/mod.code-workspace index 6732c67..090d8e7 100644 --- a/TypeScript/4UseACustomConfigFile/mod.code-workspace +++ b/TypeScript/4UseACustomConfigFile/mod.code-workspace @@ -1,12 +1,13 @@ { - "folders": [ - { - "path": "." - } - ], - "extensions": { - "recommendations": [ - "dbaeumer.vscode-eslint" - ] - } -} \ No newline at end of file + "folders": [ + { + "path": "." + } + ], + "extensions": { + "recommendations": [ + "dbaeumer.vscode-eslint", + "refringe.spt-id-highlighter" + ] + } +} diff --git a/TypeScript/4UseACustomConfigFile/package.json b/TypeScript/4UseACustomConfigFile/package.json index b6cbb57..f089d0f 100644 --- a/TypeScript/4UseACustomConfigFile/package.json +++ b/TypeScript/4UseACustomConfigFile/package.json @@ -1,14 +1,12 @@ { "name": "UseACustomConfigFile", "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" } diff --git a/TypeScript/4UseACustomConfigFile/src/mod.ts b/TypeScript/4UseACustomConfigFile/src/mod.ts index e269363..c33274e 100644 --- a/TypeScript/4UseACustomConfigFile/src/mod.ts +++ b/TypeScript/4UseACustomConfigFile/src/mod.ts @@ -6,7 +6,7 @@ import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; class Mod implements IPostAkiLoadMod { private modConfig = require("../config/config.json"); - + public postAkiLoad(container: DependencyContainer): void { // get logger const logger = container.resolve("WinstonLogger"); @@ -16,4 +16,4 @@ class Mod implements IPostAkiLoadMod } } -module.exports = { mod: new Mod() } \ No newline at end of file +export const mod = new Mod(); diff --git a/TypeScript/4UseACustomConfigFile/tsconfig.json b/TypeScript/4UseACustomConfigFile/tsconfig.json index eca7728..c5ca53f 100644 --- a/TypeScript/4UseACustomConfigFile/tsconfig.json +++ b/TypeScript/4UseACustomConfigFile/tsconfig.json @@ -11,8 +11,8 @@ "resolveJsonModule": true, "outDir": "tmp", "paths": { - "@spt-aki/*": [ "./types/*" ], + "@spt-aki/*": ["./types/*"], }, }, - "exclude": [ "node_modules", "dist", "tmp" ], -} \ No newline at end of file + "exclude": ["node_modules", "dist", "tmp"], +} diff --git a/TypeScript/5ReplaceMethod/.eslintignore b/TypeScript/5ReplaceMethod/.eslintignore index 9922d9a..f7dd9e1 100644 --- a/TypeScript/5ReplaceMethod/.eslintignore +++ b/TypeScript/5ReplaceMethod/.eslintignore @@ -1,9 +1,10 @@ # Exclude these folders from linting -node_modules -dist/ -types/ +**/node_modules +/tmp +/dist +/types # Exclude these filetypes from linting *.json *.txt -*.exe \ No newline at end of file +*.exe diff --git a/TypeScript/5ReplaceMethod/.eslintrc.json b/TypeScript/5ReplaceMethod/.eslintrc.json index 071a313..757b0bd 100644 --- a/TypeScript/5ReplaceMethod/.eslintrc.json +++ b/TypeScript/5ReplaceMethod/.eslintrc.json @@ -95,4 +95,4 @@ } } ] -} \ No newline at end of file +} diff --git a/TypeScript/5ReplaceMethod/README.md b/TypeScript/5ReplaceMethod/README.md index e760f8b..3bd5a99 100644 --- a/TypeScript/5ReplaceMethod/README.md +++ b/TypeScript/5ReplaceMethod/README.md @@ -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/). diff --git a/TypeScript/5ReplaceMethod/build.mjs b/TypeScript/5ReplaceMethod/build.mjs index d00117c..d5a679f 100644 --- a/TypeScript/5ReplaceMethod/build.mjs +++ b/TypeScript/5ReplaceMethod/build.mjs @@ -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(); } /** diff --git a/TypeScript/5ReplaceMethod/mod.code-workspace b/TypeScript/5ReplaceMethod/mod.code-workspace index 6732c67..090d8e7 100644 --- a/TypeScript/5ReplaceMethod/mod.code-workspace +++ b/TypeScript/5ReplaceMethod/mod.code-workspace @@ -1,12 +1,13 @@ { - "folders": [ - { - "path": "." - } - ], - "extensions": { - "recommendations": [ - "dbaeumer.vscode-eslint" - ] - } -} \ No newline at end of file + "folders": [ + { + "path": "." + } + ], + "extensions": { + "recommendations": [ + "dbaeumer.vscode-eslint", + "refringe.spt-id-highlighter" + ] + } +} diff --git a/TypeScript/5ReplaceMethod/package.json b/TypeScript/5ReplaceMethod/package.json index b63c39e..5876e57 100644 --- a/TypeScript/5ReplaceMethod/package.json +++ b/TypeScript/5ReplaceMethod/package.json @@ -1,14 +1,12 @@ { "name": "ReplaceMethod", "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" } diff --git a/TypeScript/5ReplaceMethod/src/mod.ts b/TypeScript/5ReplaceMethod/src/mod.ts index a9c0208..e10244f 100644 --- a/TypeScript/5ReplaceMethod/src/mod.ts +++ b/TypeScript/5ReplaceMethod/src/mod.ts @@ -1,4 +1,5 @@ import { DependencyContainer } from "tsyringe"; + import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod"; import { LauncherController } from "@spt-aki/controllers/LauncherController"; import { DatabaseServer } from "@spt-aki/servers/DatabaseServer"; @@ -12,20 +13,20 @@ class Mod implements IPreAkiLoadMod // ALWAYS use the container to resolve dependencies // ****** ALWAYS ******* private static container: DependencyContainer; - + // Perform these actions before server fully loads - public preAkiLoad(container: DependencyContainer): void + public preAkiLoad(container: DependencyContainer): void { // We will save a reference to the dependency container to resolve dependencies // that we may need down the line Mod.container = container; - // Wait until LauncherController gets resolved by the server and run code afterwards to replace + // Wait until LauncherController gets resolved by the server and run code afterwards to replace // the login() function with the one below called 'replacementFunction() - container.afterResolution("LauncherController", (_t, result: LauncherController) => + container.afterResolution("LauncherController", (_t, result: LauncherController) => { // We want to replace the original method logic with something different - result.login = (info: ILoginRequestData) => + result.login = (info: ILoginRequestData) => { return this.replacementFunction(info); } @@ -55,7 +56,7 @@ class Mod implements IPreAkiLoadMod // We resolve 2 more dependencies: The logger and the DatabaseServer const logger = Mod.container.resolve("WinstonLogger"); const dbServer = Mod.container.resolve("DatabaseServer"); - + // As an example Im counting the amount of loaded items on the DB const loadedItems = Object.entries(dbServer.getTables().templates.items).length; // Lets do a few informational messages @@ -67,4 +68,4 @@ class Mod implements IPreAkiLoadMod } } -module.exports = { mod: new Mod() } \ No newline at end of file +export const mod = new Mod(); diff --git a/TypeScript/5ReplaceMethod/tsconfig.json b/TypeScript/5ReplaceMethod/tsconfig.json index eca7728..c5ca53f 100644 --- a/TypeScript/5ReplaceMethod/tsconfig.json +++ b/TypeScript/5ReplaceMethod/tsconfig.json @@ -11,8 +11,8 @@ "resolveJsonModule": true, "outDir": "tmp", "paths": { - "@spt-aki/*": [ "./types/*" ], + "@spt-aki/*": ["./types/*"], }, }, - "exclude": [ "node_modules", "dist", "tmp" ], -} \ No newline at end of file + "exclude": ["node_modules", "dist", "tmp"], +} diff --git a/TypeScript/6ReferenceAnotherClass/.eslintignore b/TypeScript/6ReferenceAnotherClass/.eslintignore index 9922d9a..f7dd9e1 100644 --- a/TypeScript/6ReferenceAnotherClass/.eslintignore +++ b/TypeScript/6ReferenceAnotherClass/.eslintignore @@ -1,9 +1,10 @@ # Exclude these folders from linting -node_modules -dist/ -types/ +**/node_modules +/tmp +/dist +/types # Exclude these filetypes from linting *.json *.txt -*.exe \ No newline at end of file +*.exe diff --git a/TypeScript/6ReferenceAnotherClass/.eslintrc.json b/TypeScript/6ReferenceAnotherClass/.eslintrc.json index 071a313..757b0bd 100644 --- a/TypeScript/6ReferenceAnotherClass/.eslintrc.json +++ b/TypeScript/6ReferenceAnotherClass/.eslintrc.json @@ -95,4 +95,4 @@ } } ] -} \ No newline at end of file +} diff --git a/TypeScript/6ReferenceAnotherClass/README.md b/TypeScript/6ReferenceAnotherClass/README.md index e760f8b..3bd5a99 100644 --- a/TypeScript/6ReferenceAnotherClass/README.md +++ b/TypeScript/6ReferenceAnotherClass/README.md @@ -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/). diff --git a/TypeScript/6ReferenceAnotherClass/build.mjs b/TypeScript/6ReferenceAnotherClass/build.mjs index d00117c..d5a679f 100644 --- a/TypeScript/6ReferenceAnotherClass/build.mjs +++ b/TypeScript/6ReferenceAnotherClass/build.mjs @@ -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(); } /** diff --git a/TypeScript/6ReferenceAnotherClass/mod.code-workspace b/TypeScript/6ReferenceAnotherClass/mod.code-workspace index 6732c67..090d8e7 100644 --- a/TypeScript/6ReferenceAnotherClass/mod.code-workspace +++ b/TypeScript/6ReferenceAnotherClass/mod.code-workspace @@ -1,12 +1,13 @@ { - "folders": [ - { - "path": "." - } - ], - "extensions": { - "recommendations": [ - "dbaeumer.vscode-eslint" - ] - } -} \ No newline at end of file + "folders": [ + { + "path": "." + } + ], + "extensions": { + "recommendations": [ + "dbaeumer.vscode-eslint", + "refringe.spt-id-highlighter" + ] + } +} diff --git a/TypeScript/6ReferenceAnotherClass/package.json b/TypeScript/6ReferenceAnotherClass/package.json index 4978de3..a73456f 100644 --- a/TypeScript/6ReferenceAnotherClass/package.json +++ b/TypeScript/6ReferenceAnotherClass/package.json @@ -1,14 +1,12 @@ { "name": "ReferenceAnotherClass", "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" } diff --git a/TypeScript/6ReferenceAnotherClass/src/MoreCode.ts b/TypeScript/6ReferenceAnotherClass/src/MoreCode.ts index cb380e5..7518ab0 100644 --- a/TypeScript/6ReferenceAnotherClass/src/MoreCode.ts +++ b/TypeScript/6ReferenceAnotherClass/src/MoreCode.ts @@ -4,4 +4,4 @@ export class MoreCode { return "flub"; } -} \ No newline at end of file +} diff --git a/TypeScript/6ReferenceAnotherClass/src/mod.ts b/TypeScript/6ReferenceAnotherClass/src/mod.ts index b114e0a..035fcc8 100644 --- a/TypeScript/6ReferenceAnotherClass/src/mod.ts +++ b/TypeScript/6ReferenceAnotherClass/src/mod.ts @@ -6,8 +6,8 @@ import { MoreCode } from "./MoreCode"; class Mod implements IPostAkiLoadMod { - public postAkiLoad(container: DependencyContainer): void - { + public postAkiLoad(container: DependencyContainer): void + { // get logger const logger = container.resolve("WinstonLogger"); @@ -22,4 +22,4 @@ class Mod implements IPostAkiLoadMod } } -module.exports = { mod: new Mod() } \ No newline at end of file +export const mod = new Mod(); diff --git a/TypeScript/6ReferenceAnotherClass/tsconfig.json b/TypeScript/6ReferenceAnotherClass/tsconfig.json index eca7728..c5ca53f 100644 --- a/TypeScript/6ReferenceAnotherClass/tsconfig.json +++ b/TypeScript/6ReferenceAnotherClass/tsconfig.json @@ -11,8 +11,8 @@ "resolveJsonModule": true, "outDir": "tmp", "paths": { - "@spt-aki/*": [ "./types/*" ], + "@spt-aki/*": ["./types/*"], }, }, - "exclude": [ "node_modules", "dist", "tmp" ], -} \ No newline at end of file + "exclude": ["node_modules", "dist", "tmp"], +} diff --git a/TypeScript/7OnLoadHook/.eslintignore b/TypeScript/7OnLoadHook/.eslintignore index 9922d9a..f7dd9e1 100644 --- a/TypeScript/7OnLoadHook/.eslintignore +++ b/TypeScript/7OnLoadHook/.eslintignore @@ -1,9 +1,10 @@ # Exclude these folders from linting -node_modules -dist/ -types/ +**/node_modules +/tmp +/dist +/types # Exclude these filetypes from linting *.json *.txt -*.exe \ No newline at end of file +*.exe diff --git a/TypeScript/7OnLoadHook/.eslintrc.json b/TypeScript/7OnLoadHook/.eslintrc.json index 071a313..757b0bd 100644 --- a/TypeScript/7OnLoadHook/.eslintrc.json +++ b/TypeScript/7OnLoadHook/.eslintrc.json @@ -95,4 +95,4 @@ } } ] -} \ No newline at end of file +} diff --git a/TypeScript/7OnLoadHook/README.md b/TypeScript/7OnLoadHook/README.md index e760f8b..3bd5a99 100644 --- a/TypeScript/7OnLoadHook/README.md +++ b/TypeScript/7OnLoadHook/README.md @@ -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/). diff --git a/TypeScript/7OnLoadHook/build.mjs b/TypeScript/7OnLoadHook/build.mjs index d00117c..d5a679f 100644 --- a/TypeScript/7OnLoadHook/build.mjs +++ b/TypeScript/7OnLoadHook/build.mjs @@ -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(); } /** diff --git a/TypeScript/7OnLoadHook/mod.code-workspace b/TypeScript/7OnLoadHook/mod.code-workspace index 6732c67..090d8e7 100644 --- a/TypeScript/7OnLoadHook/mod.code-workspace +++ b/TypeScript/7OnLoadHook/mod.code-workspace @@ -1,12 +1,13 @@ { - "folders": [ - { - "path": "." - } - ], - "extensions": { - "recommendations": [ - "dbaeumer.vscode-eslint" - ] - } -} \ No newline at end of file + "folders": [ + { + "path": "." + } + ], + "extensions": { + "recommendations": [ + "dbaeumer.vscode-eslint", + "refringe.spt-id-highlighter" + ] + } +} diff --git a/TypeScript/7OnLoadHook/package.json b/TypeScript/7OnLoadHook/package.json index 42e7067..25ac3eb 100644 --- a/TypeScript/7OnLoadHook/package.json +++ b/TypeScript/7OnLoadHook/package.json @@ -1,14 +1,12 @@ { "name": "OnLoadHook", "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" } diff --git a/TypeScript/7OnLoadHook/src/mod.ts b/TypeScript/7OnLoadHook/src/mod.ts index adbb0d6..e8fd335 100644 --- a/TypeScript/7OnLoadHook/src/mod.ts +++ b/TypeScript/7OnLoadHook/src/mod.ts @@ -1,24 +1,26 @@ import { DependencyContainer } from "tsyringe"; -import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod" -import { ILogger } from "@spt-aki/models/spt/utils/ILogger" -import { OnLoadModService } from "@spt-aki/services/mod/onLoad/OnLoadModService" + +import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod"; +import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; +import { OnLoadModService } from "@spt-aki/services/mod/onLoad/OnLoadModService"; class Mod implements IPreAkiLoadMod { - public preAkiLoad(container: DependencyContainer): void + public preAkiLoad(container: DependencyContainer): void { const logger = container.resolve("WinstonLogger"); const onLoadModService = container.resolve("OnLoadModService"); onLoadModService.registerOnLoad( "MyCustomMod", // route key - () => this.customFunctionThatRunsOnLoad(logger), + () => this.customFunctionThatRunsOnLoad(logger), () => "custom-mod" // new route name - ) + ); } public customFunctionThatRunsOnLoad(logger: ILogger): void { - logger.info("MyCustomMod custom function is loading right now") + logger.info("MyCustomMod custom function is loading right now"); } } -module.exports = {mod: new Mod()} \ No newline at end of file + +export const mod = new Mod(); diff --git a/TypeScript/7OnLoadHook/tsconfig.json b/TypeScript/7OnLoadHook/tsconfig.json index eca7728..c5ca53f 100644 --- a/TypeScript/7OnLoadHook/tsconfig.json +++ b/TypeScript/7OnLoadHook/tsconfig.json @@ -11,8 +11,8 @@ "resolveJsonModule": true, "outDir": "tmp", "paths": { - "@spt-aki/*": [ "./types/*" ], + "@spt-aki/*": ["./types/*"], }, }, - "exclude": [ "node_modules", "dist", "tmp" ], -} \ No newline at end of file + "exclude": ["node_modules", "dist", "tmp"], +} diff --git a/TypeScript/8OnUpdateHook/.eslintignore b/TypeScript/8OnUpdateHook/.eslintignore index 9922d9a..f7dd9e1 100644 --- a/TypeScript/8OnUpdateHook/.eslintignore +++ b/TypeScript/8OnUpdateHook/.eslintignore @@ -1,9 +1,10 @@ # Exclude these folders from linting -node_modules -dist/ -types/ +**/node_modules +/tmp +/dist +/types # Exclude these filetypes from linting *.json *.txt -*.exe \ No newline at end of file +*.exe diff --git a/TypeScript/8OnUpdateHook/.eslintrc.json b/TypeScript/8OnUpdateHook/.eslintrc.json index 071a313..757b0bd 100644 --- a/TypeScript/8OnUpdateHook/.eslintrc.json +++ b/TypeScript/8OnUpdateHook/.eslintrc.json @@ -95,4 +95,4 @@ } } ] -} \ No newline at end of file +} diff --git a/TypeScript/8OnUpdateHook/README.md b/TypeScript/8OnUpdateHook/README.md index e760f8b..3bd5a99 100644 --- a/TypeScript/8OnUpdateHook/README.md +++ b/TypeScript/8OnUpdateHook/README.md @@ -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/). diff --git a/TypeScript/8OnUpdateHook/build.mjs b/TypeScript/8OnUpdateHook/build.mjs index d00117c..d5a679f 100644 --- a/TypeScript/8OnUpdateHook/build.mjs +++ b/TypeScript/8OnUpdateHook/build.mjs @@ -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(); } /** diff --git a/TypeScript/8OnUpdateHook/mod.code-workspace b/TypeScript/8OnUpdateHook/mod.code-workspace index 6732c67..090d8e7 100644 --- a/TypeScript/8OnUpdateHook/mod.code-workspace +++ b/TypeScript/8OnUpdateHook/mod.code-workspace @@ -1,12 +1,13 @@ { - "folders": [ - { - "path": "." - } - ], - "extensions": { - "recommendations": [ - "dbaeumer.vscode-eslint" - ] - } -} \ No newline at end of file + "folders": [ + { + "path": "." + } + ], + "extensions": { + "recommendations": [ + "dbaeumer.vscode-eslint", + "refringe.spt-id-highlighter" + ] + } +} diff --git a/TypeScript/8OnUpdateHook/package.json b/TypeScript/8OnUpdateHook/package.json index e0a3fbe..10957b7 100644 --- a/TypeScript/8OnUpdateHook/package.json +++ b/TypeScript/8OnUpdateHook/package.json @@ -1,14 +1,12 @@ { "name": "OnUpdateHook", "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" } diff --git a/TypeScript/8OnUpdateHook/src/mod.ts b/TypeScript/8OnUpdateHook/src/mod.ts index 46d7397..9f9f11b 100644 --- a/TypeScript/8OnUpdateHook/src/mod.ts +++ b/TypeScript/8OnUpdateHook/src/mod.ts @@ -1,7 +1,8 @@ import { DependencyContainer } from "tsyringe"; -import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod" -import { ILogger } from "@spt-aki/models/spt/utils/ILogger" -import { OnUpdateModService } from "@spt-aki/services/mod/onUpdate/OnUpdateModService" + +import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod"; +import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; +import { OnUpdateModService } from "@spt-aki/services/mod/onUpdate/OnUpdateModService"; class Mod implements IPreAkiLoadMod { @@ -10,21 +11,22 @@ class Mod implements IPreAkiLoadMod const onUpdateModService = container.resolve("OnUpdateModService"); onUpdateModService.registerOnUpdate( - "MyCustomOnUpdateMod", - (timeSinceLastRun: number) => this.customFunctionThatRunsOnLoad(timeSinceLastRun, logger), + "MyCustomOnUpdateMod", + (timeSinceLastRun: number) => this.customFunctionThatRunsOnLoad(timeSinceLastRun, logger), () => "custom-onupdate-mod" // new route name - ) + ); } public customFunctionThatRunsOnLoad(timeSinceLastRun: number, logger: ILogger): boolean { if (timeSinceLastRun > 30) { - logger.info("MyCustomMod onupdate custom function is called right now") + logger.info("MyCustomMod onupdate custom function is called right now"); return true; // we did something } return false; // we didnt do anything } } -module.exports = {mod: new Mod()} \ No newline at end of file + +export const mod = new Mod(); diff --git a/TypeScript/8OnUpdateHook/tsconfig.json b/TypeScript/8OnUpdateHook/tsconfig.json index eca7728..c5ca53f 100644 --- a/TypeScript/8OnUpdateHook/tsconfig.json +++ b/TypeScript/8OnUpdateHook/tsconfig.json @@ -11,8 +11,8 @@ "resolveJsonModule": true, "outDir": "tmp", "paths": { - "@spt-aki/*": [ "./types/*" ], + "@spt-aki/*": ["./types/*"], }, }, - "exclude": [ "node_modules", "dist", "tmp" ], -} \ No newline at end of file + "exclude": ["node_modules", "dist", "tmp"], +} diff --git a/TypeScript/9RouterHooks/.eslintignore b/TypeScript/9RouterHooks/.eslintignore index 9922d9a..f7dd9e1 100644 --- a/TypeScript/9RouterHooks/.eslintignore +++ b/TypeScript/9RouterHooks/.eslintignore @@ -1,9 +1,10 @@ # Exclude these folders from linting -node_modules -dist/ -types/ +**/node_modules +/tmp +/dist +/types # Exclude these filetypes from linting *.json *.txt -*.exe \ No newline at end of file +*.exe diff --git a/TypeScript/9RouterHooks/.eslintrc.json b/TypeScript/9RouterHooks/.eslintrc.json index 071a313..757b0bd 100644 --- a/TypeScript/9RouterHooks/.eslintrc.json +++ b/TypeScript/9RouterHooks/.eslintrc.json @@ -95,4 +95,4 @@ } } ] -} \ No newline at end of file +} diff --git a/TypeScript/9RouterHooks/README.md b/TypeScript/9RouterHooks/README.md index e760f8b..3bd5a99 100644 --- a/TypeScript/9RouterHooks/README.md +++ b/TypeScript/9RouterHooks/README.md @@ -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/). diff --git a/TypeScript/9RouterHooks/build.mjs b/TypeScript/9RouterHooks/build.mjs index d00117c..d5a679f 100644 --- a/TypeScript/9RouterHooks/build.mjs +++ b/TypeScript/9RouterHooks/build.mjs @@ -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(); } /** diff --git a/TypeScript/9RouterHooks/mod.code-workspace b/TypeScript/9RouterHooks/mod.code-workspace index 6732c67..090d8e7 100644 --- a/TypeScript/9RouterHooks/mod.code-workspace +++ b/TypeScript/9RouterHooks/mod.code-workspace @@ -1,12 +1,13 @@ { - "folders": [ - { - "path": "." - } - ], - "extensions": { - "recommendations": [ - "dbaeumer.vscode-eslint" - ] - } -} \ No newline at end of file + "folders": [ + { + "path": "." + } + ], + "extensions": { + "recommendations": [ + "dbaeumer.vscode-eslint", + "refringe.spt-id-highlighter" + ] + } +} diff --git a/TypeScript/9RouterHooks/package.json b/TypeScript/9RouterHooks/package.json index e2a4f99..bf2f3c7 100644 --- a/TypeScript/9RouterHooks/package.json +++ b/TypeScript/9RouterHooks/package.json @@ -1,14 +1,12 @@ { "name": "RouterHooks", "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" } diff --git a/TypeScript/9RouterHooks/src/mod.ts b/TypeScript/9RouterHooks/src/mod.ts index be5db05..36ccde9 100644 --- a/TypeScript/9RouterHooks/src/mod.ts +++ b/TypeScript/9RouterHooks/src/mod.ts @@ -1,4 +1,5 @@ import { DependencyContainer } from "tsyringe"; + import type { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod"; import type { ILogger } from "@spt-aki/models/spt/utils/ILogger"; import type {DynamicRouterModService} from "@spt-aki/services/mod/dynamicRouter/DynamicRouterModService"; @@ -10,16 +11,16 @@ class Mod implements IPreAkiLoadMod const logger = container.resolve("WinstonLogger"); const dynamicRouterModService = container.resolve("DynamicRouterModService"); const staticRouterModService = container.resolve("StaticRouterModService"); - + // Hook up a new dynamic route dynamicRouterModService.registerDynamicRouter( "MyDynamicModRouter", [ { url: "/my-dynamic-mod/", - action: (url, info, sessionId, output) => + action: (url, info, sessionId, output) => { - logger.info("Custom dynamic route hit") + logger.info("Custom dynamic route hit"); return JSON.stringify({response: "OK"}); } } @@ -33,9 +34,9 @@ class Mod implements IPreAkiLoadMod [ { url: "/my-static-route-mod/", - action: (url, info, sessionId, output) => + action: (url, info, sessionId, output) => { - logger.info("Custom static route hit") + logger.info("Custom static route hit"); return JSON.stringify({response: "OK"}); } } @@ -49,32 +50,32 @@ class Mod implements IPreAkiLoadMod [ { url: "/client/menu/locale/", - action: (url, info, sessionId, output) => + action: (url, info, sessionId, output) => { - logger.info("/client/menu/locale/ data was: " + JSON.stringify(output)) + logger.info("/client/menu/locale/ data was: " + JSON.stringify(output)); return output; } } ], "aki" ); - + // Hook up to existing AKI static route staticRouterModService.registerStaticRouter( "StaticRoutePeekingAki", [ { url: "/launcher/ping", - action: (url, info, sessionId, output) => + action: (url, info, sessionId, output) => { - logger.info("/launcher/ping data was: " + JSON.stringify(output)) + logger.info("/launcher/ping data was: " + JSON.stringify(output)); return output; } } ], "aki" ); - } } -module.exports = {mod: new Mod()} \ No newline at end of file + +export const mod = new Mod(); diff --git a/TypeScript/9RouterHooks/tsconfig.json b/TypeScript/9RouterHooks/tsconfig.json index eca7728..c5ca53f 100644 --- a/TypeScript/9RouterHooks/tsconfig.json +++ b/TypeScript/9RouterHooks/tsconfig.json @@ -11,8 +11,8 @@ "resolveJsonModule": true, "outDir": "tmp", "paths": { - "@spt-aki/*": [ "./types/*" ], + "@spt-aki/*": ["./types/*"], }, }, - "exclude": [ "node_modules", "dist", "tmp" ], -} \ No newline at end of file + "exclude": ["node_modules", "dist", "tmp"], +}