You've already forked AstralRinth
forked from didirus/AstralRinth
* Base impl * Make project type selectable * Update Browse.vue * address changes * Quick create * Run linter * fix merge * Addressed changes * Installation improvements * Run lint * resourcepacks * automatic installation of dependencies * Fix bugs with search * Addressed changes * Run linter * Fixed direct install not working * Remove back to search * Update Index.vue * Addressed some changes * Shader fix * fix resetting * Update Browse.vue * fixed install not working properly * Update Index.vue --------- Co-authored-by: Geometrically <18202329+Geometrically@users.noreply.github.com> Co-authored-by: Jai A <jaiagr+gpg@pm.me>
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
import { add_project_from_version as installMod } from '@/helpers/profile'
|
|
import { ofetch } from 'ofetch'
|
|
|
|
export const releaseColor = (releaseType) => {
|
|
switch (releaseType) {
|
|
case 'release':
|
|
return 'green'
|
|
case 'beta':
|
|
return 'orange'
|
|
case 'alpha':
|
|
return 'red'
|
|
default:
|
|
return ''
|
|
}
|
|
}
|
|
|
|
export const checkInstalled = (profile, projectId) => {
|
|
return Object.values(profile.projects).some((p) => p.metadata?.project?.id === projectId)
|
|
}
|
|
|
|
export const installVersionDependencies = async (profile, version) => {
|
|
for (const dep of version.dependencies) {
|
|
if (dep.version_id) {
|
|
if (checkInstalled(profile, dep.project_id)) continue
|
|
await installMod(profile.path, dep.version_id)
|
|
} else {
|
|
if (checkInstalled(profile, dep.project_id)) continue
|
|
const depVersions = await ofetch(
|
|
`https://api.modrinth.com/v2/project/${dep.project_id}/version`
|
|
)
|
|
const latest = depVersions.find(
|
|
(v) =>
|
|
v.game_versions.includes(profile.metadata.game_version) &&
|
|
v.loaders.includes(profile.metadata.loader)
|
|
)
|
|
await installMod(profile.path, latest.id)
|
|
}
|
|
}
|
|
}
|