mirror of
https://git.bits.team/Bits/mod-manager.git
synced 2024-11-21 13:38:21 -05:00
Added a force flag to migrate-possible
This commit is contained in:
parent
d29ab449aa
commit
ca0c596423
@ -10,8 +10,11 @@ export default class MigratePossibleCommand implements Subcommand {
|
|||||||
program.command("migrate-possible")
|
program.command("migrate-possible")
|
||||||
.description("Reports whether it is possible to upgrade to the provided Minecraft version")
|
.description("Reports whether it is possible to upgrade to the provided Minecraft version")
|
||||||
.argument("[version]", "The Minecraft version to try and migrate to")
|
.argument("[version]", "The Minecraft version to try and migrate to")
|
||||||
.action((version) => {
|
.option("-f, --force", "Checks whether a force migration is possible, where only essential mods are included", false)
|
||||||
|
.action((version, options) => {
|
||||||
ModManager.execute(async () => {
|
ModManager.execute(async () => {
|
||||||
|
const force = options.force;
|
||||||
|
|
||||||
// If no version is provided, prompt user for one
|
// If no version is provided, prompt user for one
|
||||||
if (version === "" || version == undefined) {
|
if (version === "" || version == undefined) {
|
||||||
version = await MinecraftUtils.getMinecraftVersionFromInput("What Minecraft version would you like to migrate to?");
|
version = await MinecraftUtils.getMinecraftVersionFromInput("What Minecraft version would you like to migrate to?");
|
||||||
@ -19,12 +22,20 @@ export default class MigratePossibleCommand implements Subcommand {
|
|||||||
|
|
||||||
// If version is valid, check if migration is possible
|
// If version is valid, check if migration is possible
|
||||||
if (await MinecraftUtils.isValidVersion(version)) {
|
if (await MinecraftUtils.isValidVersion(version)) {
|
||||||
const possible = await Mods.isMigratePossible(version);
|
try {
|
||||||
|
const possible = await Mods.isMigratePossible(version, force);
|
||||||
|
|
||||||
if (possible) {
|
if (possible) {
|
||||||
PrintUtils.success(`It is possible to migrate to version ${version}`)
|
PrintUtils.success(`It is possible to migrate to version ${version}`)
|
||||||
} else {
|
} else {
|
||||||
PrintUtils.error(`It is not possible to migrate to version ${version}`)
|
PrintUtils.error(`It is not possible to migrate to version ${version}`)
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
if (!force) {
|
||||||
|
PrintUtils.error("There are no mods installed, try `mod-manager install -h` to learn more!")
|
||||||
|
} else {
|
||||||
|
PrintUtils.error("There are no mods installed that are marked essential. Try `mod-manager essential -h` to learn more!")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PrintUtils.error(`${version} is not a valid Minecraft version`);
|
PrintUtils.error(`${version} is not a valid Minecraft version`);
|
||||||
|
@ -208,8 +208,12 @@ export default class Mods {
|
|||||||
return source
|
return source
|
||||||
}
|
}
|
||||||
|
|
||||||
static async isMigratePossible(version: string): Promise<boolean> {
|
static async isMigratePossible(version: string, force: boolean): Promise<boolean> {
|
||||||
const mods = this.getTrackedMods();
|
const mods = !force ? this.getTrackedMods() : this.getEssentialMods();
|
||||||
|
|
||||||
|
if (Util.isArrayEmpty(mods)) {
|
||||||
|
throw new Error("Mods list is empty")
|
||||||
|
}
|
||||||
|
|
||||||
let availableList = [];
|
let availableList = [];
|
||||||
|
|
||||||
@ -238,4 +242,8 @@ export default class Mods {
|
|||||||
// If the array is empty, all the mods reported as available, and a migration is possible
|
// If the array is empty, all the mods reported as available, and a migration is possible
|
||||||
return Util.isArrayEmpty(availableList);
|
return Util.isArrayEmpty(availableList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static getEssentialMods() {
|
||||||
|
return this.getTrackedMods().filter(mod => mod.essential);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user