From 5cc4c5a689e124e3951c80f0cfda0de4a797fec7 Mon Sep 17 00:00:00 2001 From: hachem Date: Tue, 9 Dec 2025 23:02:55 +0100 Subject: [add]: merging and refactor --- cli/commands/check.js | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 cli/commands/check.js (limited to 'cli/commands/check.js') diff --git a/cli/commands/check.js b/cli/commands/check.js new file mode 100644 index 0000000..f91b710 --- /dev/null +++ b/cli/commands/check.js @@ -0,0 +1,81 @@ +const { LoadConfig } = require("../../lib/config") +const { GetModVersions, GetCompatibleVersion } = require("../../lib/modrinth") + +const config = LoadConfig() +const { minecraft_version, modrinth_mods } = config + +const Check = async () => +{ + console.log(`\n Checking mod compatibility for MC ${minecraft_version} (Fabric)...\n`) + + const compatible = [] + const incompatible = [] + const failed = [] + + for (const slug of modrinth_mods) + { + try + { + const versions = await GetModVersions(slug) + if (!versions) + { + failed.push(slug) + continue + } + + const match = GetCompatibleVersion(versions, minecraft_version, "fabric") + if (match) + { + const filename = match.files[0]?.filename || match.version_number + compatible.push({ slug, version: filename }) + } + else + { + incompatible.push(slug) + } + } + catch (err) + { + failed.push(slug) + } + } + + // Display results + if (compatible.length) + { + console.log(" [OK] Compatible:") + for (const { slug, version } of compatible) + console.log(` ${slug} -> ${version}`) + console.log("") + } + + if (incompatible.length) + { + console.log(" [FAIL] No compatible version:") + for (const slug of incompatible) + console.log(` ${slug}`) + console.log("") + } + + if (failed.length) + { + console.log(" [WARN] Failed to check:") + for (const slug of failed) + console.log(` ${slug}`) + console.log("") + } + + // Summary + const total = modrinth_mods.length + const ok = compatible.length + + console.log(` Summary: ${ok}/${total} mods compatible\n`) + + if (incompatible.length === 0 && failed.length === 0) + console.log(" [OK] Safe to generate!\n") + else + console.log(" [FAIL] Not all mods are compatible. Generate may have issues.\n") +} + +module.exports = { Check } + -- cgit v1.3