build fixes
This commit is contained in:
parent
3070f6a742
commit
4a6d698b47
6 changed files with 34 additions and 15 deletions
|
@ -1,10 +1,8 @@
|
|||
console.clear();
|
||||
|
||||
import { ConsoleHelper } from "./ConsoleHelper";
|
||||
import { readFileSync, existsSync } from "fs";
|
||||
if (!existsSync("./config.json")) {
|
||||
ConsoleHelper.printError("You must have a config file in the root of Binato's folder structure.");
|
||||
ConsoleHelper.printError("Check the GitHub for an example file");
|
||||
ConsoleHelper.printError("Config file missing!");
|
||||
ConsoleHelper.printError("Check the GitHub for an example or create one with the example you have.");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import * as dyetty from "dyetty";
|
||||
|
||||
console.clear();
|
||||
|
||||
enum LogType {
|
||||
INFO,
|
||||
WARN,
|
||||
|
|
|
@ -4,11 +4,12 @@ import Database from "../objects/Database";
|
|||
import DataStreamArray from "../objects/DataStreamArray";
|
||||
import MultiplayerManager from "../MultiplayerManager";
|
||||
import PrivateChatManager from "../PrivateChatManager";
|
||||
import { readFileSync } from "fs";
|
||||
import { existsSync, readFileSync } from "fs";
|
||||
import UserArray from "../objects/UserArray";
|
||||
import User from "./User";
|
||||
import LatLng from "./LatLng";
|
||||
import Bot from "../Bot";
|
||||
import { ConsoleHelper } from "../../ConsoleHelper";
|
||||
|
||||
export default class Shared {
|
||||
public readonly chatManager:ChatManager;
|
||||
|
@ -21,6 +22,11 @@ export default class Shared {
|
|||
public readonly bot:Bot;
|
||||
|
||||
public constructor() {
|
||||
if (!existsSync("./config.json")) {
|
||||
ConsoleHelper.printError("Config file missing!");
|
||||
ConsoleHelper.printError("Check the GitHub for an example or create one with the example you have.");
|
||||
process.exit(1);
|
||||
}
|
||||
this.config = JSON.parse(readFileSync("./config.json").toString()) as Config;
|
||||
this.database = new Database(this.config.database.address, this.config.database.port, this.config.database.username, this.config.database.password, this.config.database.name);
|
||||
this.streams = new DataStreamArray();
|
||||
|
|
|
@ -3,7 +3,7 @@ import { readdirSync, rmSync, renameSync } from "fs";
|
|||
const libFiles = readdirSync("./build");
|
||||
|
||||
for (const file of libFiles) {
|
||||
if (!file.startsWith("index.min.js")) {
|
||||
if (!file.startsWith("Binato.min.js")) {
|
||||
rmSync(`./build/${file}`, { recursive: true });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
import { readdirSync, lstatSync, readFileSync, writeFileSync } from "fs";
|
||||
|
||||
let tsFileData:Array<string> = new Array<string>();
|
||||
const tsEvenFirsterData:Array<string> = new Array<string>();
|
||||
const tsVeryFirstData:Array<string> = new Array<string>();
|
||||
const tsFirstFileData:Array<string> = new Array<string>();
|
||||
const tsLastFileData:Array<string> = new Array<string>();
|
||||
const tsEverythingElse:Array<string> = new Array<string>();
|
||||
|
@ -23,7 +25,11 @@ function readDir(nam:string) {
|
|||
} else if (file.endsWith(".ts")) {
|
||||
if (file == "Binato.ts") {
|
||||
tsLastFileData.push(readFileSync((`${nam}/${file}`).replace("//", "/")).toString());
|
||||
} else if (nam.includes("enum") || nam.includes("packets") || file.includes("FunkyArray") || file.includes("SpectatorManager") || file.includes("Shared")) {
|
||||
} else if (nam.includes("commands") || file.includes("ConsoleHelper")) {
|
||||
tsEvenFirsterData.push(readFileSync((`${nam}/${file}`).replace("//", "/")).toString());
|
||||
} else if (file.includes("FunkyArray") || file.includes("ChatManager") || file.includes("MultiplayerManager") || file === "Bot.ts") {
|
||||
tsVeryFirstData.push(readFileSync((`${nam}/${file}`).replace("//", "/")).toString());
|
||||
} else if (nam.includes("enum") || nam.includes("packets") || (nam.includes("objects") && !file.includes("FunkyArray") ) || file.includes("SpectatorManager")) {
|
||||
tsFirstFileData.push(readFileSync((`${nam}/${file}`).replace("//", "/")).toString());
|
||||
} else {
|
||||
tsEverythingElse.push(readFileSync((`${nam}/${file}`).replace("//", "/")).toString());
|
||||
|
@ -34,7 +40,7 @@ function readDir(nam:string) {
|
|||
|
||||
readDir("./");
|
||||
|
||||
tsFileData = tsFileData.concat(tsFirstFileData).concat(tsEverythingElse).concat(tsLastFileData);
|
||||
tsFileData = tsFileData.concat(tsEvenFirsterData).concat(tsVeryFirstData).concat(tsFirstFileData).concat(tsEverythingElse).concat(tsLastFileData);
|
||||
|
||||
const combinedFiles = tsFileData.join("\n");
|
||||
|
||||
|
|
|
@ -1,10 +1,17 @@
|
|||
import { readFileSync, writeFileSync } from "fs";
|
||||
import { minify } from "terser";
|
||||
|
||||
(async () => {
|
||||
const DISABLE = false;
|
||||
|
||||
if (DISABLE) {
|
||||
writeFileSync("./build/Binato.min.js", readFileSync("./build/combined.js"));
|
||||
console.warn("[WARNING] mangle.ts is disabled!");
|
||||
} else {
|
||||
(async () => {
|
||||
const mangled = await minify(readFileSync("./build/combined.js").toString(), {
|
||||
mangle: true,
|
||||
toplevel: true,
|
||||
});
|
||||
writeFileSync("./build/index.min.js", `${mangled.code}`);
|
||||
})();
|
||||
writeFileSync("./build/Binato.min.js", `${mangled.code}`);
|
||||
})();
|
||||
}
|
Loading…
Reference in a new issue