You've already forked AstralRinth
forked from didirus/AstralRinth
Non modpack wireup & Project to profile install (#90)
* 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>
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
import { add_project_from_version as installMod } from '@/helpers/profile'
|
||||
import { ofetch } from 'ofetch'
|
||||
|
||||
export const releaseColor = (releaseType) => {
|
||||
switch (releaseType) {
|
||||
case 'release':
|
||||
@@ -10,3 +13,27 @@ export const releaseColor = (releaseType) => {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user