mirror of
https://git.bits.team/Bits/mod-manager.git
synced 2025-06-30 17:19:43 -04:00
Added an "migrate-possible" command
This commit is contained in:
@ -2,9 +2,7 @@ import {existsSync, mkdirSync, writeFileSync} from "fs";
|
||||
import path from "path";
|
||||
import PrintUtils from "./print_utils.js";
|
||||
import ModManager from "../mod-manager.js";
|
||||
import inquirer from "inquirer";
|
||||
import MinecraftUtils from "./minecraft_utils.js";
|
||||
import MinecraftVersionError from "../errors/minecraft_version_error.js";
|
||||
|
||||
export default class Initialiser {
|
||||
public static async initialise(): Promise<void> {
|
||||
@ -13,7 +11,7 @@ export default class Initialiser {
|
||||
const success: boolean = this.setupFolderStructure();
|
||||
|
||||
if (success) {
|
||||
const version = await this.getMinecraftVersionFromInput();
|
||||
const version = await MinecraftUtils.getMinecraftVersionFromInput("What Minecraft version is your server running?");
|
||||
await MinecraftUtils.updateCurrentMinecraftVersion(version)
|
||||
|
||||
PrintUtils.success("Sucessfully initialised Mod Manager!");
|
||||
@ -56,30 +54,4 @@ export default class Initialiser {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static async getMinecraftVersionFromInput() {
|
||||
let isVersionValid = false;
|
||||
|
||||
let version: string | undefined = undefined;
|
||||
while (!isVersionValid) {
|
||||
const answer = await inquirer.prompt([{
|
||||
type: "input",
|
||||
name: "minecraft_version",
|
||||
message: "What version of Minecraft is the server running?"
|
||||
}])
|
||||
version = answer.minecraft_version;
|
||||
|
||||
if (await MinecraftUtils.isValidVersion(version)) {
|
||||
isVersionValid = true;
|
||||
} else {
|
||||
PrintUtils.error(`${version} is not a valid Minecraft version for a Fabric server. Please try again`);
|
||||
}
|
||||
}
|
||||
|
||||
if (version == undefined) {
|
||||
throw new MinecraftVersionError("Escaped version input without a valid version")
|
||||
}
|
||||
|
||||
return version;
|
||||
}
|
||||
}
|
@ -2,6 +2,8 @@ import {readFileSync, writeFileSync} from "fs";
|
||||
import axios from "axios";
|
||||
import ModManager from "../mod-manager.js";
|
||||
import MinecraftVersionError from "../errors/minecraft_version_error.js";
|
||||
import inquirer from "inquirer";
|
||||
import PrintUtils from "./print_utils.js";
|
||||
|
||||
export default class MinecraftUtils {
|
||||
static async getCurrentMinecraftVersion(): Promise<string> {
|
||||
@ -34,5 +36,31 @@ export default class MinecraftUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static async getMinecraftVersionFromInput(question: string) {
|
||||
let isVersionValid = false;
|
||||
|
||||
let version: string | undefined = undefined;
|
||||
while (!isVersionValid) {
|
||||
const answer = await inquirer.prompt([{
|
||||
type: "input",
|
||||
name: "minecraft_version",
|
||||
message: question
|
||||
}])
|
||||
version = answer.minecraft_version;
|
||||
|
||||
if (await MinecraftUtils.isValidVersion(version)) {
|
||||
isVersionValid = true;
|
||||
} else {
|
||||
PrintUtils.error(`${version} is not a valid Minecraft version for a Fabric server. Please try again`);
|
||||
}
|
||||
}
|
||||
|
||||
if (version == undefined) {
|
||||
throw new MinecraftVersionError("Escaped version input without a valid version")
|
||||
}
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user