* feat: Start work on package api * feat: Browser Context Controller * feat: Add packages to cluster metadata feat: Change structure of Package * 🐛 fix: format * 🔨 feat: Add more functions wrapping around Modrinth * 🔨 feat: Start working on browser frontend * feat: BrowserPackage work + markdown support * 🐛 fix: fmt Signed-off-by: Pauline <git@ethanlibs.co> * 🚧 wip: h Signed-off-by: Pauline <git@ethanlibs.co> * feat: Download button for packages for suitable clusters + tweaks * 🚧 wip: markdown and stuff Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: some patches Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: remove react bloat Signed-off-by: Pauline <git@ethanlibs.co> * 🔨 chore(pkg/infer): try to reduce reused code Signed-off-by: Pauline <git@ethanlibs.co> * 🔨 chore: bump deps Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: markdown innerhtml Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: h Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: tweak Signed-off-by: Pauline <git@ethanlibs.co> * 🚧 wip: idk Signed-off-by: Pauline <git@ethanlibs.co> * fix: Gamemode compile error chore: Add missing and remove unused libraries feat: usePreventLeave hook feat: ClusterOverview edit mode continues with navigation (assuming there was a navigation attempt) after pressing Yes or No for save * feat: Add reload clusters button on home page * feat: More information provided to BrowserPackage * fix: Minor fixes (Navbar isActive, Markdown click prevention, Markdown list styling) * 🐛 fix: h Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: highlighting Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: forge modern Signed-off-by: Pauline <git@ethanlibs.co> * 🔨 chore: bump deps Signed-off-by: Pauline <git@ethanlibs.co> * fix: Markdown-it issue + Added promptOpener hook for Markdown links * feat: Made BrowserPackage sidebar sticky * refactor: Package system (not yet in a working state) * 🚧 wip: bump deps temp Signed-off-by: Pauline <git@ethanlibs.co> * feat: Added a package manager * ✨ feature: start prisma work, but it doesnt break anything so we can keep it until its done. also fix some stuff Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: pushing Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: linting Signed-off-by: Pauline <git@ethanlibs.co> * ✨ feature: start ingress integration Signed-off-by: Pauline <git@ethanlibs.co> * feat: Package Manager should work now 👍 * fix: Package manager tracing spam * feat: Added tauri commands for cluster packages format: Auto formatted frontend + backend * 🐛 fix: tmp Signed-off-by: Pauline <git@ethanlibs.co> * 🔨 chore: format Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: specta extension Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: github actions Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: alias Signed-off-by: Pauline <git@ethanlibs.co> * chore: Some tweaks and fixes * chore: Rebase + gitignore bindings.ts * chore: Remove bindings.ts * 🐛 fix: migrate Signed-off-by: Pauline <git@ethanlibs.co> * 🚧 wip: not sure Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: finalize prisma init schema Signed-off-by: Pauline <git@ethanlibs.co> * 🔨 chore: format Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: bump deps Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: system deps Signed-off-by: Pauline <git@ethanlibs.co> * fix: solid-router navigation issue * feat: Added new BrowserMain page * feat: Tweaks + new package list view * 🐛 fix: bump + format (todo: tauri2, etc) Signed-off-by: Pauline <git@ethanlibs.co> * 🐛 fix: devx (fixes #126) Signed-off-by: Pauline <git@ethanlibs.co> * 🔨 chore: migrate to consola Signed-off-by: Pauline <git@ethanlibs.co> --------- Signed-off-by: Pauline <git@ethanlibs.co> Co-authored-by: LynithDev <61880709+LynithDev@users.noreply.github.com>
112 lines
2.5 KiB
Rust
112 lines
2.5 KiB
Rust
use onelauncher::data::{Loader, PackageType};
|
|
use onelauncher::package::content::Providers;
|
|
use onelauncher::store::Cluster;
|
|
use onelauncher::{cluster, Result};
|
|
|
|
const CLUSTER_NAME: &str = "Test Packages";
|
|
|
|
const MODRINTH_PACKAGE_ONE: &str = "behindyou";
|
|
const MODRINTH_PACKAGE_ONE_VERSION: &str = "v3.2.2";
|
|
|
|
const MODRINTH_PACKAGE_TWO: &str = "keystrokes";
|
|
const MODRINTH_PACKAGE_TWO_VERSION: &str = "v1.0.0";
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<()> {
|
|
let mut cluster = create_cluster().await?;
|
|
|
|
// Print Packages first
|
|
print_packages(&cluster).await?;
|
|
|
|
// Download the first mod, add it to the PackageManager and sync packages
|
|
download_mod(
|
|
&mut cluster,
|
|
MODRINTH_PACKAGE_ONE,
|
|
MODRINTH_PACKAGE_ONE_VERSION,
|
|
true,
|
|
)
|
|
.await?;
|
|
cluster::content::package::sync_packages_by_type(&cluster.cluster_path(), PackageType::Mod)
|
|
.await?;
|
|
|
|
// Print Packages again
|
|
print_packages(&cluster).await?;
|
|
|
|
// Download the second mod, DON'T add it to the PackageManager and sync packages
|
|
download_mod(
|
|
&mut cluster,
|
|
MODRINTH_PACKAGE_TWO,
|
|
MODRINTH_PACKAGE_TWO_VERSION,
|
|
false,
|
|
)
|
|
.await?;
|
|
cluster::content::package::sync_packages_by_type(&cluster.cluster_path(), PackageType::Mod)
|
|
.await?;
|
|
|
|
// Print Packages again
|
|
print_packages(&cluster).await?;
|
|
|
|
Ok(())
|
|
}
|
|
|
|
async fn create_cluster() -> Result<Cluster> {
|
|
if let Some(cluster) = cluster::get_by_name(CLUSTER_NAME).await? {
|
|
return Ok(cluster);
|
|
}
|
|
|
|
let cluster_path = cluster::create::create_cluster(
|
|
CLUSTER_NAME.to_owned(),
|
|
"1.8.9".to_owned(),
|
|
Loader::Forge,
|
|
None,
|
|
None,
|
|
None,
|
|
None,
|
|
Some(true),
|
|
Some(false),
|
|
)
|
|
.await?;
|
|
|
|
let cluster = cluster::get(&cluster_path)
|
|
.await?
|
|
.expect("Cluster not found");
|
|
|
|
Ok(cluster)
|
|
}
|
|
|
|
async fn download_mod(cluster: &mut Cluster, pkg: &str, ver: &str, add: bool) -> Result<()> {
|
|
let package = Providers::Modrinth.get(pkg).await?;
|
|
|
|
let (package_path, package) = cluster::content::package::download_package(
|
|
&package,
|
|
cluster,
|
|
None,
|
|
None,
|
|
Some(ver.to_owned()),
|
|
)
|
|
.await?;
|
|
|
|
if add {
|
|
cluster::content::package::add_package(
|
|
&cluster.cluster_path(),
|
|
package_path.clone(),
|
|
package,
|
|
Some(PackageType::Mod),
|
|
)
|
|
.await?;
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
|
|
async fn print_packages(cluster: &Cluster) -> Result<()> {
|
|
let packages =
|
|
cluster::content::package::get_packages(&cluster.cluster_path(), PackageType::Mod).await?;
|
|
|
|
println!("Packages for cluster: {:?}", cluster.cluster_path());
|
|
for package in packages {
|
|
println!("{:?}: {:?}", package.file_name, package.meta);
|
|
}
|
|
|
|
Ok(())
|
|
}
|