fix: change importModrinth's return type

This commit is contained in:
HerozDotExe 2026-05-27 23:06:04 +02:00
parent 02d4c78fb4
commit ac7a5c3faa
2 changed files with 65 additions and 55 deletions

View file

@ -3,7 +3,7 @@ import { downloadFile } from "../utils/fetch";
import { getTempFolder } from "../utils/temp";
import { unzipAll } from "../utils/unzip";
import { ensureDir, exists, readJson } from "../utils/fs";
import { Modloader, ModrinthManifest, BaseConfig, PoolFile } from "../utils/types";
import { Modloader, ModrinthManifest, BaseConfig, PoolFile, ModrinthPack } from "../utils/types";
function getModloader(manifest: ModrinthManifest): Modloader {
if (manifest.dependencies["fabric-loader"]) {
@ -17,7 +17,7 @@ function getModloader(manifest: ModrinthManifest): Modloader {
}
}
export async function importModrinthModpack(source: string, sourceType: "url" | "file"): Promise<Partial<BaseConfig>> {
export async function importModrinthModpack(source: string, sourceType: "url" | "file"): Promise<ModrinthPack> {
const tempFolder = await getTempFolder("modrinth")
if (sourceType === "url") {

View file

@ -83,7 +83,13 @@ export type Native = {
url: string;
};
type NativeOS = "natives-linux" | "natives-windows"| "natives-windows-32" | "natives-windows-64" | "natives-macos" | "natives-osx";
type NativeOS =
| "natives-linux"
| "natives-windows"
| "natives-windows-32"
| "natives-windows-64"
| "natives-macos"
| "natives-osx";
type Rules = {
action: "allow" | "disallow";
@ -93,9 +99,9 @@ type Rules = {
export type Argument =
| {
rules: Rules[];
value: string[] | string;
}
rules: Rules[];
value: string[] | string;
}
| string;
export type Library = {
@ -229,73 +235,77 @@ export interface InstanceEvents {
total: number,
doneSize: number,
totalSize: number,
],
log: [
step: string,
message: unknown
]
];
log: [step: string, message: unknown];
}
export type ProcessArgs = {
game?: string,
java?: string
}
game?: string;
java?: string;
};
export type ProcessRam = {
max?: string,
min?: string
}
max?: string;
min?: string;
};
export type logger = (step: string, message: unknown) => void
export type logger = (step: string, message: unknown) => void;
export type FabricInstallerMeta = {
url: string,
maven: string,
version: string,
stable: boolean
}
url: string;
maven: string;
version: string;
stable: boolean;
};
export type ModrinthManifestFile = {
path: string,
hashes : {sha1: string, sha512: string},
env: {client: string, server: string},
downloads: string[],
fileSize: number
}
path: string;
hashes: { sha1: string; sha512: string };
env: { client: string; server: string };
downloads: string[];
fileSize: number;
};
export type ModrinthManifest = {
formatVersion: number,
game: string,
versionId: string,
name: string,
files: ModrinthManifestFile[],
formatVersion: number;
game: string;
versionId: string;
name: string;
files: ModrinthManifestFile[];
dependencies: {
minecraft: string,
"fabric-loader": string
forge: string,
neoforge: string
}
}
minecraft: string;
"fabric-loader": string;
forge: string;
neoforge: string;
};
};
export interface BaseConfig {
version: string;
auth: Auth;
paths: Paths
javaExecutable: string
modloader?: Modloader;
args?: ProcessArgs;
ram?: { max?: string; min?: string },
files?: PoolFile[],
overridesPath?: string
version: string;
auth: Auth;
paths: Paths;
javaExecutable: string;
modloader?: Modloader;
args?: ProcessArgs;
ram?: { max?: string; min?: string };
files?: PoolFile[];
overridesPath?: string;
}
export interface Config extends BaseConfig {
paths: Required<Paths>
args: Required<ProcessArgs>
ram: Required<ProcessRam>
files: PoolFile[]
paths: Required<Paths>;
args: Required<ProcessArgs>;
ram: Required<ProcessRam>;
files: PoolFile[];
}
export interface ModloaderConfig extends Config {
modloader: Modloader
}
modloader: Modloader;
}
export interface ModrinthPack {
version: string;
modloader: Modloader;
files: PoolFile[];
overridesPath: string;
}