feat: initial support for segatools pkgs

This commit is contained in:
2025-03-15 00:08:33 +01:00
parent b525e74467
commit caa20a3aa0
20 changed files with 246 additions and 112 deletions

View File

@ -3,7 +3,7 @@ use derive_more::Display;
use serde::{Deserialize, Serialize};
use std::{collections::BTreeSet, path::{Path, PathBuf}};
use tokio::fs;
use crate::{model::{local, rainy}, util};
use crate::{model::{local::{self, PackageManifest}, rainy}, util};
// {namespace}-{name}
#[derive(Eq, Hash, PartialEq, PartialOrd, Ord, Clone, Serialize, Deserialize, Display)]
@ -27,8 +27,10 @@ pub struct Package {
#[derive(Clone, Default, PartialEq, Serialize, Deserialize)]
pub enum Kind {
Unchecked,
Unsupported,
#[default] Mod,
Unsupported
Hook,
IO,
}
#[derive(Clone, Default, Serialize, Deserialize)]
@ -84,6 +86,7 @@ impl Package {
.unwrap()
.to_owned();
let kind = Self::parse_kind(&mft);
let dependencies = Self::sanitize_deps(mft.dependencies);
Ok(Package {
@ -94,7 +97,7 @@ impl Package {
loc: Some(Local {
version: mft.version_number,
path: dir.to_owned(),
kind: Kind::Mod,
kind,
dependencies
}),
rmt: None
@ -166,4 +169,25 @@ impl Package {
}
res
}
fn parse_kind(mft: &PackageManifest) -> Kind {
if mft.installers.len() == 0 {
return Kind::Mod;//Unchecked
} else if mft.installers.len() == 1 {
if let Some(serde_json::Value::String(id)) = &mft.installers[0].get("identifier") {
if id == "rainycolor" {
return Kind::Mod
} else if id == "segatools" {
if let Some(serde_json::Value::String(module)) = mft.installers[0].get("module") {
if module.ends_with("hook") {
return Kind::Hook;
} else if module.ends_with("io") {
return Kind::IO;
}
}
}
}
}
return Kind::Unsupported
}
}