* Initial bug fixes

* fix compile error on non-mac

* Fix even more bugs

* Fix more

* fix more

* fix build

* fix build

* working basic

* removed zip

* working functions

* merge fixes

* fixed loadintg bar bug

* changed to one layer deep

* forge version numbers

* overrides dont include mrpack

* merge

* fixes

* fixes

* fixed deletion

* merge errors

* force sync before export

* removed testing

* missed line

* removed console log

* mac error reverted

---------

Co-authored-by: Jai A <jaiagr+gpg@pm.me>
This commit is contained in:
Wyatt Verchere
2023-06-26 14:29:53 -07:00
committed by GitHub
parent 1c3441a605
commit 47970d932b
14 changed files with 509 additions and 59 deletions

View File

@@ -22,7 +22,7 @@ use tokio::fs;
#[derive(Serialize, Deserialize, Eq, PartialEq)]
#[serde(rename_all = "camelCase")]
struct PackFormat {
pub struct PackFormat {
pub game: String,
pub format_version: i32,
pub version_id: String,
@@ -34,7 +34,7 @@ struct PackFormat {
#[derive(Serialize, Deserialize, Eq, PartialEq)]
#[serde(rename_all = "camelCase")]
struct PackFile {
pub struct PackFile {
pub path: String,
pub hashes: HashMap<PackFileHash, String>,
pub env: Option<HashMap<EnvType, SideType>>,
@@ -44,7 +44,7 @@ struct PackFile {
#[derive(Serialize, Deserialize, Eq, PartialEq, Hash)]
#[serde(rename_all = "camelCase", from = "String")]
enum PackFileHash {
pub enum PackFileHash {
Sha1,
Sha512,
Unknown(String),
@@ -62,14 +62,14 @@ impl From<String> for PackFileHash {
#[derive(Serialize, Deserialize, Eq, PartialEq, Hash)]
#[serde(rename_all = "camelCase")]
enum EnvType {
pub enum EnvType {
Client,
Server,
}
#[derive(Serialize, Deserialize, Clone, Hash, PartialEq, Eq)]
#[serde(rename_all = "kebab-case")]
enum PackDependency {
pub enum PackDependency {
Forge,
FabricLoader,
QuiltLoader,
@@ -299,7 +299,9 @@ async fn install_pack(
mod_loader = Some(ModLoader::Quilt);
loader_version = Some(value);
}
PackDependency::Minecraft => game_version = Some(value),
PackDependency::Minecraft => {
game_version = Some(value.clone())
}
}
}

View File

@@ -3,6 +3,7 @@ use crate::event::emit::{init_loading, loading_try_for_each_concurrent};
use crate::event::LoadingBarType;
use crate::prelude::JavaVersion;
use crate::state::ProjectMetadata;
use crate::util::export;
use crate::{
auth::{self, refresh},
event::{emit::emit_profile, ProfilePayloadType},
@@ -490,6 +491,50 @@ pub async fn remove_project(
}
}
/// Exports the profile to a Modrinth-formatted .mrpack file
// Version ID of uploaded version (ie 1.1.5), not the unique identifying ID of the version (nvrqJg44)
#[tracing::instrument(skip_all)]
pub async fn export_mrpack(
profile_path: &Path,
export_path: PathBuf,
included_overrides: Vec<String>, // which folders to include in the overrides
version_id: Option<String>,
) -> crate::Result<()> {
let state = State::get().await?;
let io_semaphore = state.io_semaphore.0.read().await;
let permit: tokio::sync::SemaphorePermit = io_semaphore.acquire().await?;
let profile = get(profile_path, None).await?.ok_or_else(|| {
crate::ErrorKind::OtherError(format!(
"Tried to export a nonexistent or unloaded profile at path {}!",
profile_path.display()
))
})?;
export::export_mrpack(
&profile,
&export_path,
version_id.unwrap_or("1.0.0".to_string()),
included_overrides,
true,
&permit,
)
.await?;
Ok(())
}
// Given a folder path, populate a Vec of all the subfolders
// Intended to be used for finding potential override folders
// profile
// -- folder1
// -- folder2
// -- file1
// => [folder1, folder2]
#[tracing::instrument]
pub async fn get_potential_override_folders(
profile_path: PathBuf,
) -> crate::Result<Vec<PathBuf>> {
export::get_potential_override_folders(profile_path).await
}
/// Run Minecraft using a profile and the default credentials, logged in credentials,
/// failing with an error if no credentials are available
#[tracing::instrument]