diff --git a/src/lib/models/versions.ts b/src/lib/models/versions.ts index 2dadb73b1..8897e68d5 100644 --- a/src/lib/models/versions.ts +++ b/src/lib/models/versions.ts @@ -83,7 +83,6 @@ const validateModZip = async ( .loadAsync(file as any) .then(async (zip) => { const uPluginFiles = zip.filter((filePath) => basename(filePath) == modReference + '.uplugin'); - const targets = uPluginFiles.map((f) => dirname(f.name)); if (uPluginFiles.length === 0) { return { @@ -91,6 +90,29 @@ const validateModZip = async ( }; } + if (uPluginFiles.length === 1 && uPluginFiles[0].name === modReference + '.uplugin') { + // Single-target mod + const uPluginData = await readUPluginJson(await uPluginFiles[0].async('string'), modReference); + + if ('message' in uPluginData) { + return uPluginData; + } + + return { + uplugin: uPluginData, + objects: Object.keys(zip.files).filter( + (f) => f.endsWith('.so') || f.endsWith('.dll') || f.endsWith('.pak') + ), + targets: ['Windows'] + }; + } + + // Do not allow multi-target mods for now + return { + message: 'multi-target mods are not allowed' + }; + + // Multi-target mod if (uPluginFiles.some((f) => f.name === modReference + '.uplugin')) { return { message: @@ -100,6 +122,8 @@ const validateModZip = async ( }; } + const targets = uPluginFiles.map((f) => dirname(f.name)); + const invalidTargets = targets.filter((t) => !ALLOWED_TARGETS.includes(t as TargetName)); if (invalidTargets.length !== 0) { return { @@ -132,6 +156,10 @@ const validateModZip = async ( // Since the .uplugin files are all the same, we only need to parse one const uPluginData = await readUPluginJson(uPluginFilesData[0], modReference); + if ('message' in uPluginData) { + return uPluginData; + } + return { uplugin: uPluginData, objects: Object.keys(zip.files).filter((f) => f.endsWith('.so') || f.endsWith('.dll') || f.endsWith('.pak')),