blob: f91b710666e2e76b7c707cd171ed78c9b8738bd1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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 }
|