Updated dependencies + A few other things (!150)

Initially this was going to be an update to dependencies but it seems i got a little carried away!

Anyways this PR removes 2 unused dependencies (`jshint` and `utf-8-validate`), and 2 other, `del` and `fs-extra` that were replaced by the built-in `fs/promises`.

It also renames all `tsconfig` and `Dockerfile` files, in a way that when viewed in a file tree sorted alphabetically they will be next to each other.

It also updates the typescript target to `ES2022`, and changes moduleResolution from `Node` to `Node10` (this isn't an update, they are the same thing but `Node` is now deprecated).

It also adds the `node:` discriminator to every import from built-in modules.

It also has major changes to the build script, `del` and `fs-extra` were only being used in the build script, it's now using `fs/promises` instead, cleaned up the code from some functions, adds better documentation to a few functions, and renames some gulp tasks and npm scripts to better represent what they actually do.

And finally it updates dependencies, except for `atomically` which can't be updated unless the project switches to ESM.

Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/150
Co-authored-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
Co-committed-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
This commit is contained in:
TheSparta 2023-10-14 09:01:41 +00:00 committed by chomp
parent 8c972908d2
commit 723f8db572
38 changed files with 223 additions and 253 deletions

View File

@ -181,7 +181,7 @@ steps:
from_secret: DOCKER_PASSWORD from_secret: DOCKER_PASSWORD
username: username:
from_secret: DOCKER_USERNAME from_secret: DOCKER_USERNAME
dockerfile: project/docs.Dockerfile dockerfile: project/Dockerfile.docs
context: project/ context: project/
tags: latest tags: latest
depends_on: depends_on:

View File

@ -1,4 +1,4 @@
# NCSA Open Source License # NCSA Open Source License
Copyright (c) 2022 Merijn Hendriks. All rights reserved. Copyright (c) 2022 Merijn Hendriks. All rights reserved.

View File

@ -2,7 +2,7 @@
!src !src
!types !types
!base_tsconfig.json !tsconfig.base.json
!tsconfig.json !tsconfig.json
!package.json !package.json
!typedoc.json !typedoc.json

View File

@ -9,7 +9,7 @@
"transform": { "transform": {
"decoratorMetadata": true "decoratorMetadata": true
}, },
"target": "es2020", "target": "es2022",
"loose": true, "loose": true,
"externalHelpers": false, "externalHelpers": false,
// Requires v1.2.50 or upper and requires target to be es2016 or upper. // Requires v1.2.50 or upper and requires target to be es2016 or upper.

View File

@ -5,7 +5,7 @@ WORKDIR /app
COPY package.json . COPY package.json .
RUN yarn RUN yarn
COPY .parcelrc tsconfig.json base_tsconfig.json ./ COPY .parcelrc tsconfig.json tsconfig.base.json ./
COPY src ./src COPY src ./src
RUN yarn test:comp-linux RUN yarn test:comp-linux

View File

@ -1,13 +1,12 @@
/* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable @typescript-eslint/naming-convention */
import crypto from "crypto";
import { deleteSync } from "del";
import fs from "fs-extra";
import gulp from "gulp"; import gulp from "gulp";
import { exec } from "gulp-execa"; import { exec } from "gulp-execa";
import rename from "gulp-rename"; import rename from "gulp-rename";
import os from "os"; import crypto from "node:crypto";
import path from "path"; import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import pkg from "pkg"; import pkg from "pkg";
import pkgfetch from "pkg-fetch"; import pkgfetch from "pkg-fetch";
import * as ResEdit from "resedit"; import * as ResEdit from "resedit";
@ -27,8 +26,15 @@ const entries = {
}; };
const licenseFile = "../LICENSE.md"; const licenseFile = "../LICENSE.md";
// Compilation /**
const compileTest = async () => exec("swc src -d obj", { stdio }); * Transpiles the src files into javascript with swc
*/
const compile = async () => await exec("swc src -d obj", { stdio });
/**
* Transpiles the src files into javascript with tsc for the profiler run
*/
const compileProfiler = async () => await exec("tsc -p tsconfig.test.json", { stdio });
// Packaging // Packaging
const fetchPackageImage = async () => const fetchPackageImage = async () =>
@ -40,18 +46,6 @@ const fetchPackageImage = async () =>
console.log(`fetched node binary at ${fetchedPkg}`); console.log(`fetched node binary at ${fetchedPkg}`);
const builtPkg = fetchedPkg.replace("node", "built"); const builtPkg = fetchedPkg.replace("node", "built");
await fs.copyFile(fetchedPkg, builtPkg); await fs.copyFile(fetchedPkg, builtPkg);
if (process.platform === "win32" || process.platform === "win64")
{
await exec(`dir ${output}`, {
stdio
});
}
else
{
await exec(`ls ${output}`, {
stdio
});
}
} }
catch (e) catch (e)
{ {
@ -60,18 +54,18 @@ const fetchPackageImage = async () =>
} }
}; };
const updateBuildProperties = async (cb) => const updateBuildProperties = async () =>
{ {
if(os.platform() !== "win32") { if (os.platform() !== "win32")
cb(); {
return; return;
} }
const exe = ResEdit.NtExecutable.from(fs.readFileSync(serverExe)); const exe = ResEdit.NtExecutable.from(await fs.readFile(serverExe));
const res = ResEdit.NtExecutableResource.from(exe); const res = ResEdit.NtExecutableResource.from(exe);
const iconPath = path.resolve(manifest.icon); const iconPath = path.resolve(manifest.icon);
const iconFile = ResEdit.Data.IconFile.from(fs.readFileSync(iconPath)); const iconFile = ResEdit.Data.IconFile.from(await fs.readFile(iconPath));
ResEdit.Resource.IconGroupEntry.replaceIconsForResource( ResEdit.Resource.IconGroupEntry.replaceIconsForResource(
res.entries, res.entries,
@ -97,45 +91,33 @@ const updateBuildProperties = async (cb) =>
vi.setProductVersion(...manifest.version.split(".").map(Number)); vi.setProductVersion(...manifest.version.split(".").map(Number));
vi.outputToResourceEntries(res.entries); vi.outputToResourceEntries(res.entries);
res.outputResource(exe, true); res.outputResource(exe, true);
fs.writeFileSync(serverExe, Buffer.from(exe.generate())); await fs.writeFile(serverExe, Buffer.from(exe.generate()));
cb();
}; };
// Copy various asset files to the destination directory /**
function copyAssets() * Copy various asset files to the destination directory
{ */
return gulp.src(["assets/**/*.json", "assets/**/*.json5", "assets/**/*.png", "assets/**/*.jpg", "assets/**/*.ico"]) const copyAssets = () => gulp.src(["assets/**/*.json", "assets/**/*.json5", "assets/**/*.png", "assets/**/*.jpg", "assets/**/*.ico"]).pipe(gulp.dest(dataDir));
.pipe(gulp.dest(dataDir));
}
// Copy executables from node_modules /**
function copyExecutables() * Copy executables from node_modules
{ */
return gulp.src(["node_modules/@pnpm/exe/**/*"]) const copyExecutables = () => gulp.src(["node_modules/@pnpm/exe/**/*"]).pipe(gulp.dest(path.join(dataDir, "@pnpm", "exe")));
.pipe(gulp.dest(path.join(dataDir, "@pnpm", "exe")));
}
// Rename and copy the license file /**
function copyLicense() * Rename and copy the license file
{ */
return gulp.src([licenseFile]) const copyLicense = () => gulp.src([licenseFile]).pipe(rename("LICENSE-Server.txt")).pipe(gulp.dest(buildDir));
.pipe(rename("LICENSE-Server.txt"))
.pipe(gulp.dest(buildDir));
}
/** /**
* Writes the latest Git commit hash to the core.json configuration file. * Writes the latest Git commit hash to the core.json configuration file.
* @param {*} cb Callback to run after completion of function
*/ */
async function writeCommitHashToCoreJSON(cb) const writeCommitHashToCoreJSON = async () =>
{ {
const coreJSONPath = path.resolve(dataDir, "configs", "core.json");
if (fs.existsSync(coreJSONPath))
{
try try
{ {
const coreJSON = fs.readFileSync(coreJSONPath, "utf8"); const coreJSONPath = path.resolve(dataDir, "configs", "core.json");
const coreJSON = await fs.readFile(coreJSONPath, "utf8");
const parsed = JSON.parse(coreJSON); const parsed = JSON.parse(coreJSON);
// Fetch the latest Git commit hash // Fetch the latest Git commit hash
@ -148,51 +130,52 @@ async function writeCommitHashToCoreJSON(cb)
parsed.buildTime = new Date().getTime(); parsed.buildTime = new Date().getTime();
// Write the updated object back to core.json // Write the updated object back to core.json
fs.writeFileSync(coreJSONPath, JSON.stringify(parsed, null, 4)); await fs.writeFile(coreJSONPath, JSON.stringify(parsed, null, 4));
} }
catch (error) catch (error)
{ {
throw new Error(`Failed to write commit hash to core.json: ${error.message}`); throw new Error(`Failed to write commit hash to core.json: ${error.message}`);
} }
} };
else
{
console.warn(`core.json not found at ${coreJSONPath}. Skipping commit hash update.`);
}
cb(); /**
} * Create a hash file for asset checks
*/
const createHashFile = async () =>
// Create a hash file for asset checks
async function createHashFile()
{ {
const hashFileDir = path.resolve(dataDir, "checks.dat"); const hashFileDir = path.resolve(dataDir, "checks.dat");
await fs.createFile(hashFileDir);
const assetData = await loadRecursiveAsync("assets/"); const assetData = await loadRecursiveAsync("assets/");
const assetDataString = Buffer.from(JSON.stringify(assetData), "utf-8").toString("base64"); const assetDataString = Buffer.from(JSON.stringify(assetData), "utf-8").toString("base64");
await fs.writeFile(hashFileDir, assetDataString); await fs.writeFile(hashFileDir, assetDataString);
} };
// Combine all tasks into addAssets // Combine all tasks into addAssets
const addAssets = gulp.series(copyAssets, copyExecutables, copyLicense, writeCommitHashToCoreJSON, createHashFile); const addAssets = gulp.series(copyAssets, copyExecutables, copyLicense, writeCommitHashToCoreJSON, createHashFile);
// Cleanup /**
const clean = (cb) => * Cleans the build directory.
{ */
deleteSync(buildDir, { force: true }); const cleanBuild = async () => await fs.rm(buildDir, { recursive: true, force: true });
cb();
};
const removeCompiled = async () => fs.rmSync("./obj", { recursive: true, force: true });
// JSON Validation /**
function getJSONFiles(dir, files = []) * Cleans the transpiled javascript directory.
*/
const cleanCompiled = async () => await fs.rm("./obj", { recursive: true, force: true });
/**
* Recursively builds an array of paths for json files.
*
* @param {fs.PathLike} dir
* @param {string[]} files
* @returns {Promise<string[]>}
*/
const getJSONFiles = async (dir, files = []) =>
{ {
const fileList = fs.readdirSync(dir); const fileList = await fs.readdir(dir);
for (const file of fileList) for (const file of fileList)
{ {
const name = path.resolve(dir,file); const name = path.resolve(dir, file);
if (fs.statSync(name).isDirectory()) if ((await fs.stat(name)).isDirectory())
{ {
getJSONFiles(name, files); getJSONFiles(name, files);
} }
@ -202,22 +185,23 @@ function getJSONFiles(dir, files = [])
} }
} }
return files; return files;
} };
const validateJSONs = (cb) => /**
* Goes through every json file in assets and makes sure they're valid json.
*/
const validateJSONs = async () =>
{ {
const assetsPath = path.resolve("assets"); const assetsPath = path.resolve("assets");
const jsonFileList = getJSONFiles(assetsPath); const jsonFileList = await getJSONFiles(assetsPath);
let jsonFileInProcess = ""; let jsonFileInProcess = "";
try try
{ {
jsonFileList.forEach((jsonFile) => for (const jsonFile of jsonFileList)
{ {
jsonFileInProcess = jsonFile; jsonFileInProcess = jsonFile;
const jsonString = fs.readFileSync(jsonFile).toString(); JSON.parse(await fs.readFile(jsonFile));
JSON.parse(jsonString); }
});
cb();
} }
catch (error) catch (error)
{ {
@ -225,7 +209,12 @@ const validateJSONs = (cb) =>
} }
}; };
// Hash helper function /**
* Hash helper function
*
* @param {crypto.BinaryLike} data
* @returns {string}
*/
const generateHashForData = (data) => const generateHashForData = (data) =>
{ {
const hashSum = crypto.createHash("sha1"); const hashSum = crypto.createHash("sha1");
@ -233,36 +222,29 @@ const generateHashForData = (data) =>
return hashSum.digest("hex"); return hashSum.digest("hex");
}; };
// Loader to recursively find all json files in a folder /**
* Loader to recursively find all json files in a folder
*
* @param {fs.PathLike} filepath
* @returns {}
*/
const loadRecursiveAsync = async (filepath) => const loadRecursiveAsync = async (filepath) =>
{ {
const result = {}; const result = {};
// get all filepaths const filesList = await fs.readdir(filepath);
const files = fs.readdirSync(filepath).filter((item) =>
{
return fs.statSync(path.join(filepath, item)).isFile();
});
const directories = fs.readdirSync(filepath).filter((item) =>
{
return fs.statSync(path.join(filepath, item)).isDirectory();
});
// add file content to result for (const file of filesList)
for (const file of files)
{ {
if (file.split(".").pop() === "json") const curPath = path.parse(path.join(filepath, file));
if ((await fs.stat(path.join(curPath.dir, curPath.base))).isDirectory())
{ {
const filename = file.split(".").slice(0, -1).join("."); result[curPath.name] = loadRecursiveAsync(`${filepath}${file}/`);
const filePathAndName = `${filepath}${file}`;
result[filename] = generateHashForData(fs.readFileSync(filePathAndName));
} }
} else if (curPath.ext === ".json")
// deep tree search
for (const dir of directories)
{ {
result[dir] = loadRecursiveAsync(`${filepath}${dir}/`); result[curPath.name] = generateHashForData(await fs.readFile(`${filepath}${file}`));
}
} }
// set all loadRecursive to be executed asynchronously // set all loadRecursive to be executed asynchronously
@ -277,15 +259,12 @@ const loadRecursiveAsync = async (filepath) =>
return Object.fromEntries(resEntries); return Object.fromEntries(resEntries);
}; };
// Testing
gulp.task("test:debug", async () => exec("ts-node-dev -r tsconfig-paths/register src/ide/TestEntry.ts", { stdio }));
// Main Tasks Generation // Main Tasks Generation
const build = (packagingType) => const build = (packagingType) =>
{ {
const anonPackaging = () => packaging(entries[packagingType]); const anonPackaging = () => packaging(entries[packagingType]);
anonPackaging.displayName = `packaging-${packagingType}`; anonPackaging.displayName = `packaging-${packagingType}`;
const tasks = [clean, validateJSONs, compileTest, fetchPackageImage, anonPackaging, addAssets, updateBuildProperties, removeCompiled]; const tasks = [cleanBuild, validateJSONs, compile, fetchPackageImage, anonPackaging, addAssets, updateBuildProperties, cleanCompiled];
return gulp.series(tasks); return gulp.series(tasks);
}; };
@ -293,6 +272,7 @@ const build = (packagingType) =>
const packaging = async (entry) => const packaging = async (entry) =>
{ {
const target = `${nodeVersion}-${process.platform}-${process.arch}`; const target = `${nodeVersion}-${process.platform}-${process.arch}`;
console.log("target", target);
const args = [entry, "--compress", "GZip", "--target", target, "--output", serverExe, "--config", pkgConfig]; const args = [entry, "--compress", "GZip", "--target", target, "--output", serverExe, "--config", pkgConfig];
try try
{ {
@ -304,14 +284,14 @@ const packaging = async (entry) =>
} }
}; };
// Run server
const runSrv = async (cb) =>
{
await exec("Aki.Server.exe", { stdio, cwd: buildDir });
cb();
};
gulp.task("build:debug", build("debug")); gulp.task("build:debug", build("debug"));
gulp.task("build:release", build("release")); gulp.task("build:release", build("release"));
gulp.task("build:bleeding", build("bleeding")); gulp.task("build:bleeding", build("bleeding"));
gulp.task("run:server", runSrv);
gulp.task("run:build", async () => await exec("Aki.Server.exe", { stdio, cwd: buildDir }));
gulp.task("run:debug", async () => await exec("ts-node-dev -r tsconfig-paths/register src/ide/TestEntry.ts", { stdio }));
gulp.task("run:profiler", async () =>
{
await compileProfiler();
await exec("node --prof --inspect --trace-warnings obj/ide/TestEntry.js", { stdio });
});

View File

@ -11,20 +11,19 @@
"node": "18.15.0" "node": "18.15.0"
}, },
"scripts": { "scripts": {
"profilerCompile": "tsc -p test_tsconfig.json", "check:circular": "madge --circular --extensions ts ./src/",
"run:profiler": "npm run profilerCompile && node --prof --inspect --trace-warnings obj/ide/TestEntry.js",
"check:circular": "npx madge --circular --extensions ts ./src/",
"lint": "rome ci src --formatter-enabled=false --max-diagnostics=200", "lint": "rome ci src --formatter-enabled=false --max-diagnostics=200",
"lint:fix": "eslint --fix --ext .ts src/**", "lint:fix": "eslint --fix --ext .ts src/**",
"test:debug": "gulp test:debug",
"test:run": "jest --colors --runInBand", "test:run": "jest --colors --runInBand",
"test:coverage": "jest --coverage --maxWorkers=1 --no-cache", "test:coverage": "jest --coverage --maxWorkers=1 --no-cache",
"build:release": "cross-env PKG_CACHE_PATH=\"./.pkg-cache\" gulp build:release", "build:release": "cross-env PKG_CACHE_PATH=\"./.pkg-cache\" gulp build:release",
"build:debug": "cross-env PKG_CACHE_PATH=\"./.pkg-cache\" gulp build:debug", "build:debug": "cross-env PKG_CACHE_PATH=\"./.pkg-cache\" gulp build:debug",
"build:bleeding": "cross-env PKG_CACHE_PATH=\"./.pkg-cache\" gulp build:bleeding", "build:bleeding": "cross-env PKG_CACHE_PATH=\"./.pkg-cache\" gulp build:bleeding",
"gen:types": "tsc -p typedef_tsconfig.json", "run:build": "gulp run:build",
"gen:docs": "typedoc --options ./typedoc.json --entryPointStrategy expand ./src", "run:debug": "gulp run:debug",
"run:server": "gulp run:server" "run:profiler": "gulp run:profiler",
"gen:types": "tsc -p tsconfig.typedef.json",
"gen:docs": "typedoc --options ./typedoc.json --entryPointStrategy expand ./src"
}, },
"dependencies": { "dependencies": {
"atomically": "1.7.0", "atomically": "1.7.0",
@ -37,36 +36,33 @@
"semver": "7.5.4", "semver": "7.5.4",
"source-map-support": "0.5.21", "source-map-support": "0.5.21",
"tsyringe": "4.8.0", "tsyringe": "4.8.0",
"typescript": "5.1.6", "typescript": "5.2.2",
"winston": "3.10.0", "winston": "3.11.0",
"winston-daily-rotate-file": "4.7.1", "winston-daily-rotate-file": "4.7.1",
"ws": "8.13.0" "ws": "8.14.2"
}, },
"devDependencies": { "devDependencies": {
"@babel/preset-env": "7.22.9", "@babel/preset-env": "7.23.2",
"@babel/preset-typescript": "7.22.5", "@babel/preset-typescript": "7.23.2",
"@jest/globals": "29.6.2", "@jest/globals": "29.7.0",
"@pnpm/exe": "8.8.0", "@pnpm/exe": "8.9.0",
"@swc/cli": "0.1.62", "@swc/cli": "0.1.62",
"@swc/core": "1.3.72", "@swc/core": "1.3.92",
"@swc/jest": "0.2.27", "@swc/jest": "0.2.29",
"@types/i18n": "0.13.6", "@types/i18n": "0.13.7",
"@types/jest": "29.5.3", "@types/jest": "29.5.5",
"@types/node": "20.4.5", "@types/node": "18.18.4",
"@types/proper-lockfile": "4.1.2", "@types/proper-lockfile": "4.1.2",
"@types/semver": "7.5.0", "@types/semver": "7.5.3",
"@types/ws": "8.5.5", "@types/ws": "8.5.7",
"@typescript-eslint/eslint-plugin": "6.2.0", "@typescript-eslint/eslint-plugin": "6.7.5",
"@typescript-eslint/parser": "6.2.0", "@typescript-eslint/parser": "6.7.5",
"cross-env": "7.0.3", "cross-env": "7.0.3",
"del": "7.0.0", "eslint": "8.51.0",
"eslint": "8.46.0",
"fs-extra": "11.1.1",
"gulp": "4.0.2", "gulp": "4.0.2",
"gulp-execa": "5.0.0", "gulp-execa": "5.0.1",
"gulp-rename": "2.0.0", "gulp-rename": "2.0.0",
"jest": "29.6.2", "jest": "29.7.0",
"jshint": "2.13.6",
"madge": "6.1.0", "madge": "6.1.0",
"pkg": "5.8.1", "pkg": "5.8.1",
"pkg-fetch": "3.5.2", "pkg-fetch": "3.5.2",
@ -75,9 +71,8 @@
"ts-jest": "29.1.1", "ts-jest": "29.1.1",
"ts-node-dev": "2.0.0", "ts-node-dev": "2.0.0",
"tsconfig-paths": "4.2.0", "tsconfig-paths": "4.2.0",
"typedoc": "0.24.8", "typedoc": "0.25.2",
"typemoq": "2.1.0", "typemoq": "2.1.0"
"utf-8-validate": "6.0.3"
}, },
"overrides": { "overrides": {
"pkg": { "pkg": {

View File

@ -35,7 +35,7 @@
"**/*.js", "**/*.js",
"**/*.json", "**/*.json",
"**/*.mjs", "**/*.mjs",
"**/*.Dockerfile", "**/Dockerfile.*",
"**/node_modules/**/*" "**/node_modules/**/*"
] ]
} }

View File

@ -43,8 +43,6 @@ import { TimeUtil } from "../utils/TimeUtil";
@injectable() @injectable()
export class GameController export class GameController
{ {
protected os = require("os");
protected httpConfig: IHttpConfig; protected httpConfig: IHttpConfig;
protected coreConfig: ICoreConfig; protected coreConfig: ICoreConfig;
protected locationConfig: ILocationConfig; protected locationConfig: ILocationConfig;

View File

@ -1,4 +1,4 @@
import { IncomingMessage, ServerResponse } from "http"; import { IncomingMessage, ServerResponse } from "node:http";
export class Serializer export class Serializer
{ {

View File

@ -1,6 +1,6 @@
import { execSync } from "child_process"; import { execSync } from "node:child_process";
import os from "os"; import os from "node:os";
import path from "path"; import path from "node:path";
import semver from "semver"; import semver from "semver";
import { DependencyContainer, inject, injectable } from "tsyringe"; import { DependencyContainer, inject, injectable } from "tsyringe";
import { ModDetails } from "../models/eft/profile/IAkiProfile"; import { ModDetails } from "../models/eft/profile/IAkiProfile";

View File

@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable @typescript-eslint/naming-convention */
import { IncomingMessage, ServerResponse } from "http"; import { IncomingMessage, ServerResponse } from "node:http";
import { injectable } from "tsyringe"; import { injectable } from "tsyringe";
import { HttpMethods } from "../../servers/http/HttpMethods"; import { HttpMethods } from "../../servers/http/HttpMethods";

View File

@ -1,4 +1,4 @@
import { IncomingMessage } from "http"; import { IncomingMessage } from "node:http";
import { injectable, injectAll } from "tsyringe"; import { injectable, injectAll } from "tsyringe";
import { DynamicRouter, Router, StaticRouter } from "../di/Router"; import { DynamicRouter, Router, StaticRouter } from "../di/Router";

View File

@ -1,4 +1,4 @@
import { IncomingMessage, ServerResponse } from "http"; import { IncomingMessage, ServerResponse } from "node:http";
import { inject, injectable } from "tsyringe"; import { inject, injectable } from "tsyringe";
import { ImageRouteService } from "../services/mod/image/ImageRouteService"; import { ImageRouteService } from "../services/mod/image/ImageRouteService";

View File

@ -1,4 +1,4 @@
import { IncomingMessage, ServerResponse } from "http"; import { IncomingMessage, ServerResponse } from "node:http";
import { inject, injectable } from "tsyringe"; import { inject, injectable } from "tsyringe";
import { Serializer } from "../../di/Serializer"; import { Serializer } from "../../di/Serializer";

View File

@ -1,4 +1,4 @@
import { IncomingMessage, ServerResponse } from "http"; import { IncomingMessage, ServerResponse } from "node:http";
import { inject, injectable } from "tsyringe"; import { inject, injectable } from "tsyringe";
import { Serializer } from "../../di/Serializer"; import { Serializer } from "../../di/Serializer";

View File

@ -1,4 +1,4 @@
import { IncomingMessage, ServerResponse } from "http"; import { IncomingMessage, ServerResponse } from "node:http";
import { inject, injectable } from "tsyringe"; import { inject, injectable } from "tsyringe";
import { NotifierController } from "../../controllers/NotifierController"; import { NotifierController } from "../../controllers/NotifierController";

View File

@ -1,4 +1,4 @@
import http, { IncomingMessage, ServerResponse } from "http"; import http, { IncomingMessage, ServerResponse } from "node:http";
import { inject, injectable, injectAll } from "tsyringe"; import { inject, injectable, injectAll } from "tsyringe";
import { ApplicationContext } from "../context/ApplicationContext"; import { ApplicationContext } from "../context/ApplicationContext";

View File

@ -1,4 +1,4 @@
import http, { IncomingMessage } from "http"; import http, { IncomingMessage } from "node:http";
import { inject, injectable } from "tsyringe"; import { inject, injectable } from "tsyringe";
import WebSocket from "ws"; import WebSocket from "ws";

View File

@ -1,6 +1,6 @@
import { IncomingHttpHeaders, IncomingMessage, ServerResponse } from "http"; import { IncomingHttpHeaders, IncomingMessage, ServerResponse } from "node:http";
import zlib from "node:zlib";
import { inject, injectAll, injectable } from "tsyringe"; import { inject, injectAll, injectable } from "tsyringe";
import zlib from "zlib";
import { Serializer } from "../../di/Serializer"; import { Serializer } from "../../di/Serializer";
import { ILogger } from "../../models/spt/utils/ILogger"; import { ILogger } from "../../models/spt/utils/ILogger";

View File

@ -1,4 +1,4 @@
import { IncomingMessage, ServerResponse } from "http"; import { IncomingMessage, ServerResponse } from "node:http";
export interface IHttpListener export interface IHttpListener
{ {

View File

@ -1,12 +1,12 @@
import { I18n } from "i18n"; import { I18n } from "i18n";
import { inject, injectable } from "tsyringe"; import { inject, injectable } from "tsyringe";
import path from "node:path";
import { ILocaleConfig } from "../models/spt/config/ILocaleConfig"; import { ILocaleConfig } from "../models/spt/config/ILocaleConfig";
import { ILogger } from "../models/spt/utils/ILogger"; import { ILogger } from "../models/spt/utils/ILogger";
import { DatabaseServer } from "../servers/DatabaseServer"; import { DatabaseServer } from "../servers/DatabaseServer";
import { RandomUtil } from "../utils/RandomUtil"; import { RandomUtil } from "../utils/RandomUtil";
import { LocaleService } from "./LocaleService"; import { LocaleService } from "./LocaleService";
import path from "path";
/** /**
* Handles translating server text into different langauges * Handles translating server text into different langauges

View File

@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable @typescript-eslint/naming-convention */
import fs from "fs"; import fs from "node:fs";
import path from "path"; import path from "node:path";
import { inject, injectable } from "tsyringe"; import { inject, injectable } from "tsyringe";
import { CompilerOptions, ModuleKind, ScriptTarget, TranspileOptions, transpileModule } from "typescript"; import { CompilerOptions, ModuleKind, ModuleResolutionKind, ScriptTarget, TranspileOptions, transpileModule } from "typescript";
import type { ILogger } from "../models/spt/utils/ILogger"; import type { ILogger } from "../models/spt/utils/ILogger";
import { VFS } from "../utils/VFS"; import { VFS } from "../utils/VFS";
import { HashCacheService } from "./HashCacheService"; import { HashCacheService } from "./HashCacheService";
@ -64,8 +64,9 @@ export class ModCompilerService
{ {
noEmitOnError: true, noEmitOnError: true,
noImplicitAny: false, noImplicitAny: false,
target: ScriptTarget.ES2020, target: ScriptTarget.ES2022,
module: ModuleKind.CommonJS, module: ModuleKind.CommonJS,
moduleResolution: ModuleResolutionKind.Node10,
resolveJsonModule: true, resolveJsonModule: true,
allowJs: true, allowJs: true,
esModuleInterop: true, esModuleInterop: true,

View File

@ -1,4 +1,4 @@
import { IncomingMessage, ServerResponse } from "http"; import { IncomingMessage, ServerResponse } from "node:http";
import { IHttpListener } from "../../../servers/http/IHttpListener"; import { IHttpListener } from "../../../servers/http/IHttpListener";
export class HttpListenerMod implements IHttpListener export class HttpListenerMod implements IHttpListener

View File

@ -1,4 +1,4 @@
import { IncomingMessage, ServerResponse } from "http"; import { IncomingMessage, ServerResponse } from "node:http";
import { DependencyContainer, injectable } from "tsyringe"; import { DependencyContainer, injectable } from "tsyringe";
import { IHttpListener } from "../../../servers/http/IHttpListener"; import { IHttpListener } from "../../../servers/http/IHttpListener";
import { HttpListenerMod } from "./HttpListenerMod"; import { HttpListenerMod } from "./HttpListenerMod";

View File

@ -1,6 +1,7 @@
import sourcemapSupport from "source-map-support"; import sourcemapSupport from "source-map-support";
import { inject, injectable, injectAll } from "tsyringe"; import { inject, injectable, injectAll } from "tsyringe";
import os from "node:os";
import { OnLoad } from "../di/OnLoad"; import { OnLoad } from "../di/OnLoad";
import { OnUpdate } from "../di/OnUpdate"; import { OnUpdate } from "../di/OnUpdate";
import { ILogger } from "../models/spt/utils/ILogger"; import { ILogger } from "../models/spt/utils/ILogger";
@ -12,7 +13,6 @@ import { TimeUtil } from "./TimeUtil";
export class App export class App
{ {
protected onUpdateLastRun = {}; protected onUpdateLastRun = {};
protected os = require("os");
constructor( constructor(
@inject("WinstonLogger") protected logger: ILogger, @inject("WinstonLogger") protected logger: ILogger,
@ -32,9 +32,9 @@ export class App
// execute onLoad callbacks // execute onLoad callbacks
this.logger.info(this.localisationService.getText("executing_startup_callbacks")); this.logger.info(this.localisationService.getText("executing_startup_callbacks"));
this.logger.debug(`OS: ${this.os.arch()} | ${this.os.version()} | ${process.platform}`); this.logger.debug(`OS: ${os.arch()} | ${os.version()} | ${process.platform}`);
this.logger.debug(`CPU: ${this.os?.cpus()[0]?.model} cores: ${this.os.availableParallelism()}`); this.logger.debug(`CPU: ${os.cpus()[0]?.model} cores: ${os.cpus().length}`);
this.logger.debug(`RAM: ${(this.os.totalmem() / 1024 / 1024 / 1024).toFixed(2)}GB`); this.logger.debug(`RAM: ${(os.totalmem() / 1024 / 1024 / 1024).toFixed(2)}GB`);
this.logger.debug(`PATH: ${this.encodingUtil.toBase64(process.argv[0])}`); this.logger.debug(`PATH: ${this.encodingUtil.toBase64(process.argv[0])}`);
this.logger.debug(`PATH: ${this.encodingUtil.toBase64(process.execPath)}`); this.logger.debug(`PATH: ${this.encodingUtil.toBase64(process.execPath)}`);

View File

@ -1,4 +1,4 @@
import crypto from "crypto"; import crypto from "node:crypto";
import { inject, injectable } from "tsyringe"; import { inject, injectable } from "tsyringe";
import { TimeUtil } from "./TimeUtil"; import { TimeUtil } from "./TimeUtil";

View File

@ -1,5 +1,5 @@
import fs from "fs"; import fs from "node:fs";
import { ServerResponse } from "http"; import { ServerResponse } from "node:http";
import { inject, injectable } from "tsyringe"; import { inject, injectable } from "tsyringe";
import { HttpServerHelper } from "../helpers/HttpServerHelper"; import { HttpServerHelper } from "../helpers/HttpServerHelper";

View File

@ -1,4 +1,4 @@
import crypto from "crypto"; import crypto from "node:crypto";
import { TimeUtil } from "./TimeUtil"; import { TimeUtil } from "./TimeUtil";
import { inject, injectable } from "tsyringe"; import { inject, injectable } from "tsyringe";

View File

@ -1,10 +1,10 @@
import { writeFileSync } from "atomically"; import { writeFileSync } from "atomically";
import fs from "fs"; import fs from "node:fs";
import path, { resolve } from "path"; import path, { resolve } from "node:path";
import { promisify } from "node:util";
import lockfile from "proper-lockfile"; import lockfile from "proper-lockfile";
import "reflect-metadata"; import "reflect-metadata";
import { inject, injectable } from "tsyringe"; import { inject, injectable } from "tsyringe";
import { promisify } from "util";
import { IAsyncQueue } from "../models/spt/utils/IAsyncQueue"; import { IAsyncQueue } from "../models/spt/utils/IAsyncQueue";
import { IUUidGenerator } from "../models/spt/utils/IUuidGenerator"; import { IUUidGenerator } from "../models/spt/utils/IUuidGenerator";

View File

@ -10,21 +10,22 @@ import { LocalisationService } from "../services/LocalisationService";
@injectable() @injectable()
export class WatermarkLocale export class WatermarkLocale
{ {
protected description: string[];
protected warning: string[];
protected modding: string[];
constructor( constructor(
@inject("LocalisationService") protected localisationService: LocalisationService @inject("LocalisationService") protected localisationService: LocalisationService
) )
{} {
this.description = [
protected watermark = {
// eslint-disable-next-line @typescript-eslint/naming-convention
"description": [
this.localisationService.getText("watermark-discord_url"), this.localisationService.getText("watermark-discord_url"),
"", "",
this.localisationService.getText("watermark-free_of_charge"), this.localisationService.getText("watermark-free_of_charge"),
this.localisationService.getText("watermark-paid_scammed"), this.localisationService.getText("watermark-paid_scammed"),
this.localisationService.getText("watermark-commercial_use_prohibited") this.localisationService.getText("watermark-commercial_use_prohibited")
], ];
"warning": [ this.warning = [
"", "",
this.localisationService.getText("watermark-testing_build"), this.localisationService.getText("watermark-testing_build"),
this.localisationService.getText("watermark-no_support"), this.localisationService.getText("watermark-no_support"),
@ -33,29 +34,29 @@ export class WatermarkLocale
this.localisationService.getText("watermark-issue_tracker_url"), this.localisationService.getText("watermark-issue_tracker_url"),
"", "",
this.localisationService.getText("watermark-use_at_own_risk") this.localisationService.getText("watermark-use_at_own_risk")
], ];
"modding": [ this.modding = [
"", "",
this.localisationService.getText("watermark-modding_disabled"), this.localisationService.getText("watermark-modding_disabled"),
"", "",
this.localisationService.getText("watermark-not_an_issue"), this.localisationService.getText("watermark-not_an_issue"),
this.localisationService.getText("watermark-do_not_report") this.localisationService.getText("watermark-do_not_report")
] ];
}; }
public getDescription(): string[] public getDescription(): string[]
{ {
return this.watermark.description; return this.description;
} }
public getWarning(): string[] public getWarning(): string[]
{ {
return this.watermark.warning; return this.warning;
} }
public getModding(): string[] public getModding(): string[]
{ {
return this.watermark.modding; return this.modding;
} }
} }

View File

@ -1,5 +1,5 @@
import fs from "fs"; import fs from "node:fs";
import { promisify } from "util"; import { promisify } from "node:util";
import winston, { createLogger, format, transports } from "winston"; import winston, { createLogger, format, transports } from "winston";
import DailyRotateFile from "winston-daily-rotate-file"; import DailyRotateFile from "winston-daily-rotate-file";

View File

@ -1,18 +1,15 @@
{ {
"compilerOptions": { "compilerOptions": {
"allowJs": false, "allowJs": false,
"module": "commonjs", "module": "CommonJS",
"target": "es2021", "target": "ES2022",
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"moduleResolution": "node", "moduleResolution": "Node10",
"esModuleInterop": true, "esModuleInterop": true,
"downlevelIteration": true, "downlevelIteration": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"emitDecoratorMetadata": true "emitDecoratorMetadata": true
}, },
"lib": [
"es2020"
],
"include": [ "include": [
"src/*", "src/*",
"src/**/*" "src/**/*"

View File

@ -1,11 +1,9 @@
{ {
"extends": "./base_tsconfig.json", "extends": "./tsconfig.base.json",
"compilerOptions": { "compilerOptions": {
"resolveJsonModule": true, "resolveJsonModule": true,
"outDir": "obj", "outDir": "obj",
"declaration": true, "declaration": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"baseUrl": ".", "baseUrl": ".",
"paths": { "paths": {
"@spt-aki/*": [ "@spt-aki/*": [

View File

@ -1,5 +1,5 @@
{ {
"extends": "./base_tsconfig.json", "extends": "./tsconfig.base.json",
"compilerOptions": { "compilerOptions": {
"outDir": "obj", "outDir": "obj",
"declaration": true, "declaration": true,

View File

@ -1,5 +1,5 @@
{ {
"extends": "./base_tsconfig.json", "extends": "./tsconfig.base.json",
"compilerOptions": { "compilerOptions": {
"emitDeclarationOnly": true, "emitDeclarationOnly": true,
"declaration": true, "declaration": true,