Implement Curseforge profile codes

This commit is contained in:
tomasalias
2025-07-24 03:41:41 +02:00
parent 7716a0c524
commit 5fd8c38c1c
8 changed files with 1085 additions and 5 deletions

View File

@@ -61,3 +61,31 @@ export async function is_valid_importable_instance(instanceFolder, launcherType)
export async function get_default_launcher_path(launcherType) {
return await invoke('plugin:import|get_default_launcher_path', { launcherType })
}
/// Fetch CurseForge profile metadata from profile code
/// eg: fetch_curseforge_profile_metadata("eSrNlKNo")
export async function fetch_curseforge_profile_metadata(profileCode) {
return await invoke('plugin:import|fetch_curseforge_profile_metadata', { profileCode })
}
/// Import a CurseForge profile from profile code
/// eg: import_curseforge_profile("eSrNlKNo")
export async function import_curseforge_profile(profileCode) {
try {
// First, fetch the profile metadata to get the actual name
const metadata = await fetch_curseforge_profile_metadata(profileCode)
// create a basic, empty instance using the actual profile name
const profilePath = await create(metadata.name, '1.19.4', 'vanilla', 'latest', null, true)
const result = await invoke('plugin:import|import_curseforge_profile', {
profilePath,
profileCode,
})
// Return the profile path for navigation
return { result, profilePath }
} catch (error) {
throw error
}
}