Ran a reformat

This commit is contained in:
Kallum Jones 2022-08-03 16:55:12 +01:00
parent 4a16f8c69d
commit 6b700d465b
No known key found for this signature in database
GPG Key ID: D7F4589C4D7F81A9
8 changed files with 65 additions and 65 deletions

View File

@ -1,13 +1,13 @@
import { Command } from "commander";
import {Command} from "commander";
import Initialiser from "../util/initialiser.js";
import Subcommand from "./subcommand.js";
export default class InitCommand implements Subcommand {
registerCommand(program: Command) {
program.command("init")
.description("Initialises mod manager")
.action(() => {
Initialiser.initialise();
});
.description("Initialises mod manager")
.action(() => {
Initialiser.initialise();
});
}
}

View File

@ -1,4 +1,4 @@
import { Command } from "commander";
import {Command} from "commander";
import Subcommand from "./subcommand.js"
import ModManager from "../mod-manager.js";
import Mods from "../mods/mods.js";

View File

@ -1,4 +1,4 @@
import { Command } from "commander";
import {Command} from "commander";
export default interface Subcommand {
registerCommand(program: Command): void;

View File

@ -10,50 +10,49 @@ import {Logger, pino} from "pino"
export default class ModManager {
public static logger: Logger | null = null;
private static readonly LOG_FILE: string = path.join(Initialiser.getModManagerFolderPath(), "logs", `${new Date().valueOf()}.log.json`);
public static logger: Logger | null = null;
private static readonly LOG_FILE: string = path.join(Initialiser.getModManagerFolderPath(), "logs", `${new Date().valueOf()}.log.json`);
private static program: Command = new Command();
private static program: Command = new Command();
private static subcommands: Array<Subcommand> = [
new InitCommand(),
new InstallCommand()
];
private static subcommands: Array<Subcommand> = [
new InitCommand(),
new InstallCommand()
];
static init() {
if (Initialiser.isInitialised()) {
this.logger = ModManager.createLogger();
static init() {
if (Initialiser.isInitialised()) {
this.logger = ModManager.createLogger();
}
this.program
.name('mod-manager')
.description('A package (mod) manager for Fabric Minecraft Servers');
for (const command of this.subcommands) {
command.registerCommand(this.program);
}
this.program.parse();
}
this.program
.name('mod-manager')
.description('A package (mod) manager for Fabric Minecraft Servers');
for (const command of this.subcommands) {
command.registerCommand(this.program);
static execute(callback: () => any): void {
if (Initialiser.isInitialised()) {
callback();
} else {
PrintUtils.error("Mod Manager is not initialised");
}
}
this.program.parse();
}
static createLogger(): Logger {
let logger = pino({base: {pid: undefined, hostname: undefined}}, pino.destination({dest: this.LOG_FILE}));
process.on("uncaughtException", error => {
logger.error(error);
setTimeout(() => process.exit(1), 1)
})
static execute(callback: () => any): void {
if (Initialiser.isInitialised()) {
callback();
} else {
PrintUtils.error("Mod Manager is not initialised");
return logger;
}
}
static createLogger(): Logger {
let logger = pino({base: {pid: undefined, hostname: undefined}}, pino.destination({dest: this.LOG_FILE}));
process.on("uncaughtException", error => {
logger.error(error);
setTimeout(() => process.exit(1), 1)
})
return logger;
}
}
ModManager.init();

View File

@ -1,4 +1,3 @@
import path from "path";
import Initialiser from "../util/initialiser.js";
import PrintUtils from "../util/print_utils.js";

View File

@ -1,5 +1,7 @@
export default interface ModSource {
search(query: string): Promise<string>;
install(id: string): Promise<void>;
getName(): string;
}

View File

@ -35,6 +35,10 @@ export default class Initialiser {
return existsSync(this.getModManagerFolderPath());
}
public static getModManagerFolderPath(): string {
return path.join(this.MOD_MANAGER_FOLDER);
}
private static isDirFabricServer(): boolean {
const serverProperties = path.join("server.properties");
const fabric = path.join(".fabric");
@ -53,8 +57,4 @@ export default class Initialiser {
}
}
public static getModManagerFolderPath(): string {
return path.join(this.MOD_MANAGER_FOLDER);
}
}

View File

@ -1,24 +1,8 @@
import chalk from "chalk";
import ora, { Ora } from "ora";
import ora, {Ora} from "ora";
export default class PrintUtils {
static info(print: string) {
console.log(chalk.white(print));
}
static warn(print: string) {
console.log(chalk.yellowBright(print));
}
static success(print: string) {
console.log(chalk.greenBright(print));
}
static error(print: string) {
console.log(chalk.redBright(print));
}
static Spinner = class {
private spinner: Ora;
@ -26,7 +10,7 @@ export default class PrintUtils {
if (text == null || undefined) {
text = "";
}
this.spinner = ora(text);
}
@ -54,4 +38,20 @@ export default class PrintUtils {
this.spinner.clear();
}
}
static info(print: string) {
console.log(chalk.white(print));
}
static warn(print: string) {
console.log(chalk.yellowBright(print));
}
static success(print: string) {
console.log(chalk.greenBright(print));
}
static error(print: string) {
console.log(chalk.redBright(print));
}
}