Auto-formatting of root-level files.
This commit is contained in:
parent
12891ceac6
commit
90cdd6eea1
@ -1,4 +1,4 @@
|
|||||||
FROM node:16-buster as builder
|
FROM node:16-buster AS builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
@ -9,7 +9,6 @@ COPY tsconfig.json tsconfig.base.json ./
|
|||||||
COPY src ./src
|
COPY src ./src
|
||||||
RUN yarn test:comp-linux
|
RUN yarn test:comp-linux
|
||||||
|
|
||||||
|
|
||||||
##############################################
|
##############################################
|
||||||
|
|
||||||
FROM debian:buster
|
FROM debian:buster
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
/* eslint-disable @typescript-eslint/naming-convention */
|
|
||||||
|
|
||||||
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";
|
||||||
@ -10,7 +8,7 @@ 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";
|
||||||
import manifest from "./package.json" assert { type: "json" };
|
import manifest from "./package.json" assert {type: "json"};
|
||||||
|
|
||||||
const nodeVersion = "node18"; // As of pkg-fetch v3.5, it's v18.15.0
|
const nodeVersion = "node18"; // As of pkg-fetch v3.5, it's v18.15.0
|
||||||
const stdio = "inherit";
|
const stdio = "inherit";
|
||||||
@ -22,14 +20,14 @@ const pkgConfig = "pkgconfig.json";
|
|||||||
const entries = {
|
const entries = {
|
||||||
release: path.join("obj", "ide", "ReleaseEntry.js"),
|
release: path.join("obj", "ide", "ReleaseEntry.js"),
|
||||||
debug: path.join("obj", "ide", "DebugEntry.js"),
|
debug: path.join("obj", "ide", "DebugEntry.js"),
|
||||||
bleeding: path.join("obj", "ide", "BleedingEdgeEntry.js")
|
bleeding: path.join("obj", "ide", "BleedingEdgeEntry.js"),
|
||||||
};
|
};
|
||||||
const licenseFile = "../LICENSE.md";
|
const licenseFile = "../LICENSE.md";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transpiles the src files into javascript with swc
|
* Transpile src files into Javascript with SWC
|
||||||
*/
|
*/
|
||||||
const compile = async () => await exec("swc src -d obj", { stdio });
|
const compile = async () => await exec("swc src -d obj", {stdio});
|
||||||
|
|
||||||
// Packaging
|
// Packaging
|
||||||
const fetchPackageImage = async () =>
|
const fetchPackageImage = async () =>
|
||||||
@ -37,7 +35,12 @@ const fetchPackageImage = async () =>
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
const output = "./.pkg-cache/v3.5";
|
const output = "./.pkg-cache/v3.5";
|
||||||
const fetchedPkg = await pkgfetch.need({ arch: process.arch, nodeRange: nodeVersion, platform: process.platform, output });
|
const fetchedPkg = await pkgfetch.need({
|
||||||
|
arch: process.arch,
|
||||||
|
nodeRange: nodeVersion,
|
||||||
|
platform: process.platform,
|
||||||
|
output,
|
||||||
|
});
|
||||||
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);
|
||||||
@ -66,7 +69,7 @@ const updateBuildProperties = async () =>
|
|||||||
res.entries,
|
res.entries,
|
||||||
1,
|
1,
|
||||||
1033,
|
1033,
|
||||||
iconFile.icons.map(item => item.data)
|
iconFile.icons.map((item) => item.data),
|
||||||
);
|
);
|
||||||
|
|
||||||
const vi = ResEdit.Resource.VersionInfo.fromEntries(res.entries)[0];
|
const vi = ResEdit.Resource.VersionInfo.fromEntries(res.entries)[0];
|
||||||
@ -77,8 +80,8 @@ const updateBuildProperties = async () =>
|
|||||||
ProductName: manifest.author,
|
ProductName: manifest.author,
|
||||||
FileDescription: manifest.description,
|
FileDescription: manifest.description,
|
||||||
CompanyName: manifest.name,
|
CompanyName: manifest.name,
|
||||||
LegalCopyright: manifest.license
|
LegalCopyright: manifest.license,
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
vi.removeStringValue({lang: 1033, codepage: 1200}, "OriginalFilename");
|
vi.removeStringValue({lang: 1033, codepage: 1200}, "OriginalFilename");
|
||||||
vi.removeStringValue({lang: 1033, codepage: 1200}, "InternalName");
|
vi.removeStringValue({lang: 1033, codepage: 1200}, "InternalName");
|
||||||
@ -92,12 +95,16 @@ const updateBuildProperties = async () =>
|
|||||||
/**
|
/**
|
||||||
* Copy various asset files to the destination directory
|
* Copy various asset files to the destination directory
|
||||||
*/
|
*/
|
||||||
const copyAssets = () => gulp.src(["assets/**/*.json", "assets/**/*.json5", "assets/**/*.png", "assets/**/*.jpg", "assets/**/*.ico"]).pipe(gulp.dest(dataDir));
|
const copyAssets = () =>
|
||||||
|
gulp.src(["assets/**/*.json", "assets/**/*.json5", "assets/**/*.png", "assets/**/*.jpg", "assets/**/*.ico"]).pipe(
|
||||||
|
gulp.dest(dataDir),
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy executables from node_modules
|
* Copy executables from node_modules
|
||||||
*/
|
*/
|
||||||
const copyExecutables = () => gulp.src(["node_modules/@pnpm/exe/**/*"]).pipe(gulp.dest(path.join(dataDir, "@pnpm", "exe")));
|
const copyExecutables = () =>
|
||||||
|
gulp.src(["node_modules/@pnpm/exe/**/*"]).pipe(gulp.dest(path.join(dataDir, "@pnpm", "exe")));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rename and copy the license file
|
* Rename and copy the license file
|
||||||
@ -116,7 +123,7 @@ const writeCommitHashToCoreJSON = async () =>
|
|||||||
const parsed = JSON.parse(coreJSON);
|
const parsed = JSON.parse(coreJSON);
|
||||||
|
|
||||||
// Fetch the latest Git commit hash
|
// Fetch the latest Git commit hash
|
||||||
const gitResult = await exec("git rev-parse HEAD", { stdout: "pipe" });
|
const gitResult = await exec("git rev-parse HEAD", {stdout: "pipe"});
|
||||||
|
|
||||||
// Update the commit hash in the core.json object
|
// Update the commit hash in the core.json object
|
||||||
parsed.commit = gitResult.stdout.trim() || "";
|
parsed.commit = gitResult.stdout.trim() || "";
|
||||||
@ -150,12 +157,12 @@ const addAssets = gulp.series(copyAssets, copyExecutables, copyLicense, writeCom
|
|||||||
/**
|
/**
|
||||||
* Cleans the build directory.
|
* Cleans the build directory.
|
||||||
*/
|
*/
|
||||||
const cleanBuild = async () => await fs.rm(buildDir, { recursive: true, force: true });
|
const cleanBuild = async () => await fs.rm(buildDir, {recursive: true, force: true});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cleans the transpiled javascript directory.
|
* Cleans the transpiled javascript directory.
|
||||||
*/
|
*/
|
||||||
const cleanCompiled = async () => await fs.rm("./obj", { recursive: true, force: true });
|
const cleanCompiled = async () => await fs.rm("./obj", {recursive: true, force: true});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recursively builds an array of paths for json files.
|
* Recursively builds an array of paths for json files.
|
||||||
@ -244,7 +251,7 @@ const loadRecursiveAsync = async (filepath) =>
|
|||||||
|
|
||||||
// set all loadRecursive to be executed asynchronously
|
// set all loadRecursive to be executed asynchronously
|
||||||
const resEntries = Object.entries(result);
|
const resEntries = Object.entries(result);
|
||||||
const resResolved = await Promise.all(resEntries.map(ent => ent[1]));
|
const resResolved = await Promise.all(resEntries.map((ent) => ent[1]));
|
||||||
for (let resIdx = 0; resIdx < resResolved.length; resIdx++)
|
for (let resIdx = 0; resIdx < resResolved.length; resIdx++)
|
||||||
{
|
{
|
||||||
resEntries[resIdx][1] = resResolved[resIdx];
|
resEntries[resIdx][1] = resResolved[resIdx];
|
||||||
@ -259,7 +266,16 @@ const build = (packagingType) =>
|
|||||||
{
|
{
|
||||||
const anonPackaging = () => packaging(entries[packagingType]);
|
const anonPackaging = () => packaging(entries[packagingType]);
|
||||||
anonPackaging.displayName = `packaging-${packagingType}`;
|
anonPackaging.displayName = `packaging-${packagingType}`;
|
||||||
const tasks = [cleanBuild, validateJSONs, compile, fetchPackageImage, anonPackaging, addAssets, updateBuildProperties, cleanCompiled];
|
const tasks = [
|
||||||
|
cleanBuild,
|
||||||
|
validateJSONs,
|
||||||
|
compile,
|
||||||
|
fetchPackageImage,
|
||||||
|
anonPackaging,
|
||||||
|
addAssets,
|
||||||
|
updateBuildProperties,
|
||||||
|
cleanCompiled,
|
||||||
|
];
|
||||||
return gulp.series(tasks);
|
return gulp.series(tasks);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -269,7 +285,18 @@ const packaging = async (entry) =>
|
|||||||
const target = `${nodeVersion}-${process.platform}-${process.arch}`;
|
const target = `${nodeVersion}-${process.platform}-${process.arch}`;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await pkg.exec([entry, "--compress", "GZip", "--target", target, "--output", serverExe, "--config", pkgConfig, "--public"]);
|
await pkg.exec([
|
||||||
|
entry,
|
||||||
|
"--compress",
|
||||||
|
"GZip",
|
||||||
|
"--target",
|
||||||
|
target,
|
||||||
|
"--output",
|
||||||
|
serverExe,
|
||||||
|
"--config",
|
||||||
|
pkgConfig,
|
||||||
|
"--public",
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
catch (error)
|
catch (error)
|
||||||
{
|
{
|
||||||
@ -281,11 +308,11 @@ 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:build", async () => await exec("Aki.Server.exe", { stdio, cwd: buildDir }));
|
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:debug", async () => await exec("ts-node-dev -r tsconfig-paths/register src/ide/TestEntry.ts", {stdio}));
|
||||||
gulp.task("run:profiler", async () =>
|
gulp.task("run:profiler", async () =>
|
||||||
{
|
{
|
||||||
await cleanCompiled();
|
await cleanCompiled();
|
||||||
await compile();
|
await compile();
|
||||||
await exec("node --prof --inspect --trace-warnings obj/ide/TestEntry.js", { stdio });
|
await exec("node --prof --inspect --trace-warnings obj/ide/TestEntry.js", {stdio});
|
||||||
});
|
});
|
||||||
|
@ -14,7 +14,7 @@ export class ErrorHandler
|
|||||||
this.logger = new WinstonMainLogger(new AsyncQueue());
|
this.logger = new WinstonMainLogger(new AsyncQueue());
|
||||||
this.readLine = readline.createInterface({
|
this.readLine = readline.createInterface({
|
||||||
input: process.stdin,
|
input: process.stdin,
|
||||||
output: process.stdout
|
output: process.stdout,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,7 +27,6 @@ export class ErrorHandler
|
|||||||
this.logger.error(`\nStacktrace:\n${err.stack}`);
|
this.logger.error(`\nStacktrace:\n${err.stack}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
||||||
this.readLine.question("Press Enter to close the window", (_ans) => this.readLine.close());
|
this.readLine.question("Press Enter to close the window", (_ans) => this.readLine.close());
|
||||||
this.readLine.on("close", () => process.exit(1));
|
this.readLine.on("close", () => process.exit(1));
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
import { container } from "tsyringe";
|
import { container } from "tsyringe";
|
||||||
|
|
||||||
import { ErrorHandler } from "@spt-aki/ErrorHandler";
|
|
||||||
import { Container } from "@spt-aki/di/Container";
|
import { Container } from "@spt-aki/di/Container";
|
||||||
|
import { ErrorHandler } from "@spt-aki/ErrorHandler";
|
||||||
import type { PreAkiModLoader } from "@spt-aki/loaders/PreAkiModLoader";
|
import type { PreAkiModLoader } from "@spt-aki/loaders/PreAkiModLoader";
|
||||||
import { App } from "@spt-aki/utils/App";
|
import { App } from "@spt-aki/utils/App";
|
||||||
import { Watermark } from "@spt-aki/utils/Watermark";
|
import { Watermark } from "@spt-aki/utils/Watermark";
|
||||||
|
|
||||||
export class Program
|
export class Program
|
||||||
{
|
{
|
||||||
|
|
||||||
private errorHandler: ErrorHandler;
|
private errorHandler: ErrorHandler;
|
||||||
constructor()
|
constructor()
|
||||||
{
|
{
|
||||||
@ -36,7 +35,7 @@ export class Program
|
|||||||
}
|
}
|
||||||
catch (err: any)
|
catch (err: any)
|
||||||
{
|
{
|
||||||
this.errorHandler.handleCriticalError((err instanceof Error ? err : new Error(err)));
|
this.errorHandler.handleCriticalError(err instanceof Error ? err : new Error(err));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable @typescript-eslint/naming-convention */
|
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { defineConfig } from "vitest/config";
|
import { defineConfig } from "vitest/config";
|
||||||
|
|
||||||
@ -9,7 +8,7 @@ export default defineConfig({
|
|||||||
root: "./",
|
root: "./",
|
||||||
include: ["**/*.{test,spec}.?(c|m)[jt]s?(x)"],
|
include: ["**/*.{test,spec}.?(c|m)[jt]s?(x)"],
|
||||||
cache: {
|
cache: {
|
||||||
dir: "./tests/__cache__"
|
dir: "./tests/__cache__",
|
||||||
},
|
},
|
||||||
environment: "./tests/CustomEnvironment.ts",
|
environment: "./tests/CustomEnvironment.ts",
|
||||||
globals: true,
|
globals: true,
|
||||||
@ -20,18 +19,18 @@ export default defineConfig({
|
|||||||
reportOnFailure: true,
|
reportOnFailure: true,
|
||||||
all: true,
|
all: true,
|
||||||
include: ["src"],
|
include: ["src"],
|
||||||
exclude: ["src/models/**", "tests/**"]
|
exclude: ["src/models/**", "tests/**"],
|
||||||
},
|
},
|
||||||
pool: "threads",
|
pool: "threads",
|
||||||
poolOptions: {
|
poolOptions: {
|
||||||
threads: {
|
threads: {
|
||||||
singleThread: true,
|
singleThread: true,
|
||||||
isolate: false
|
isolate: false,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
alias: {
|
alias: {
|
||||||
"@spt-aki": path.resolve(__dirname, "src"),
|
"@spt-aki": path.resolve(__dirname, "src"),
|
||||||
"@tests": path.resolve(__dirname, "tests")
|
"@tests": path.resolve(__dirname, "tests"),
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user