mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-12-05 03:34:46 +01:00
Added support for neoforge.mods.toml
See https://neoforged.net/news/20.5release/ Closes #118
This commit is contained in:
parent
c0f30ad683
commit
bb3c76b765
6 changed files with 15 additions and 6 deletions
|
@ -4,7 +4,7 @@ import { readAllZippedText } from "@/utils/io/file-info";
|
|||
import { LoaderType } from "../loader-type";
|
||||
import { LoaderMetadataReader } from "../loader-metadata-reader";
|
||||
import { NeoForgeMetadata } from "./neoforge-metadata";
|
||||
import { MODS_TOML } from "./raw-neoforge-metadata";
|
||||
import { NEOFORGE_MODS_TOML, MODS_TOML } from "./raw-neoforge-metadata";
|
||||
|
||||
/**
|
||||
* A metadata reader that is able to read NeoForge mod metadata from a zipped file.
|
||||
|
@ -14,7 +14,10 @@ export class NeoForgeMetadataReader implements LoaderMetadataReader<NeoForgeMeta
|
|||
* @inheritdoc
|
||||
*/
|
||||
async readMetadataFile(path: PathLike): Promise<NeoForgeMetadata> {
|
||||
const metadataText = await readAllZippedText(path, MODS_TOML);
|
||||
// Prefer `neoforge.mods.toml` over `mods.toml`.
|
||||
const metadataText = await readAllZippedText(path, NEOFORGE_MODS_TOML)
|
||||
.catch(() => readAllZippedText(path, MODS_TOML));
|
||||
|
||||
const metadata = NeoForgeMetadata.from(parseToml(metadataText));
|
||||
if (!metadata.dependencies.some(x => x.id === LoaderType.NEOFORGE)) {
|
||||
throw new Error("A NeoForge metadata file must contain a 'neoforge' dependency");
|
||||
|
|
|
@ -73,3 +73,8 @@ export interface RawNeoForgeMetadata {
|
|||
* Name of the `mods.toml` file, that contains raw NeoForge metadata.
|
||||
*/
|
||||
export const MODS_TOML = "META-INF/mods.toml";
|
||||
|
||||
/**
|
||||
* Name of the `neoforge.mods.toml` file, that contains raw NeoForge metadata.
|
||||
*/
|
||||
export const NEOFORGE_MODS_TOML = "META-INF/neoforge.mods.toml";
|
||||
|
|
|
@ -13,7 +13,8 @@ beforeEach(async () => {
|
|||
"fabric.jar": await zipFile([__dirname, "../../content/fabric/fabric.mod.json"]),
|
||||
"quilt.jar": await zipFile([__dirname, "../../content/quilt/quilt.mod.json"]),
|
||||
"forge.jar": await zipFile([__dirname, "../../content/forge/mods.toml"], "META-INF/mods.toml"),
|
||||
"neoforge.jar": await zipFile([__dirname, "../../content/neoforge/mods.toml"], "META-INF/mods.toml"),
|
||||
"neoforge.jar": await zipFile([__dirname, "../../content/neoforge/neoforge.mods.toml"], "META-INF/neoforge.mods.toml"),
|
||||
"neoforge.legacy.jar": await zipFile([__dirname, "../../content/neoforge/neoforge.mods.toml"], "META-INF/mods.toml"),
|
||||
"text.txt": "",
|
||||
});
|
||||
});
|
||||
|
|
|
@ -5,7 +5,7 @@ import { NeoForgeMetadataReader } from "@/loaders/neoforge/neoforge-metadata-rea
|
|||
|
||||
beforeEach(async () => {
|
||||
mockFs({
|
||||
"neoforge.mod.jar": await zipFile([__dirname, "../../../content/neoforge/mods.toml"], "META-INF/mods.toml"),
|
||||
"neoforge.mod.jar": await zipFile([__dirname, "../../../content/neoforge/neoforge.mods.toml"], "META-INF/neoforge.mods.toml"),
|
||||
"text.txt": "",
|
||||
});
|
||||
});
|
||||
|
@ -15,7 +15,7 @@ afterEach(() => {
|
|||
});
|
||||
|
||||
describe("NeoForgeMetadataReader", () => {
|
||||
test("successfully reads mods.toml", async () => {
|
||||
test("successfully reads neoforge.mods.toml", async () => {
|
||||
const reader = new NeoForgeMetadataReader();
|
||||
|
||||
const metadata = await reader.readMetadataFile("neoforge.mod.jar");
|
||||
|
|
|
@ -7,7 +7,7 @@ import { RawNeoForgeMetadata } from "@/loaders/neoforge/raw-neoforge-metadata";
|
|||
import { NeoForgeMetadata } from "@/loaders/neoforge/neoforge-metadata";
|
||||
|
||||
const RAW_METADATA: RawNeoForgeMetadata = Object.freeze(parseToml(
|
||||
readFileSync(resolvePath(__dirname, "../../../content/neoforge/mods.toml"), "utf8")
|
||||
readFileSync(resolvePath(__dirname, "../../../content/neoforge/neoforge.mods.toml"), "utf8")
|
||||
));
|
||||
|
||||
describe("NeoForgeMetadata", () => {
|
||||
|
|
Loading…
Reference in a new issue