🐛 fix(linting): more fotmatting

This commit is contained in:
Pauline 2024-06-18 00:18:19 +02:00
parent d548024991
commit 4c04c07c61
No known key found for this signature in database
GPG key ID: 722BB181973296AE
18 changed files with 123 additions and 133 deletions

View file

@ -8,8 +8,8 @@ use crate::proxy::ClusterPayloadType;
use crate::store::ProcessorChild;
// use crate::package::from::{EnvType, PackDependency, PackFile, PackFileHash, PackFormat};
use crate::prelude::{ClusterPath, JavaVersion, PackagePath};
pub use crate::store::{Cluster, JavaOptions, State};
use crate::store::MinecraftCredentials;
pub use crate::store::{Cluster, JavaOptions, State};
use crate::utils::io::{self, IOError};

View file

@ -66,8 +66,8 @@ pub async fn install_java(java_version: u32) -> crate::Result<PathBuf> {
.await?;
let path = state.directories.java_dir().await;
let mut archive = zip::ZipArchive::new(std::io::Cursor::new(file))
.map_err(IOError::from_zip)?;
let mut archive =
zip::ZipArchive::new(std::io::Cursor::new(file)).map_err(IOError::from_zip)?;
if let Some(file) = archive.file_names().next() {
if let Some(dir) = file.split('/').next() {
@ -79,9 +79,7 @@ pub async fn install_java(java_version: u32) -> crate::Result<PathBuf> {
}
send_ingress(&ingress, 0.0, Some("extracing java binary")).await?;
archive
.extract(&path)
.map_err(IOError::from_zip)?;
archive.extract(&path).map_err(IOError::from_zip)?;
send_ingress(&ingress, 10.0, Some("extracted java binary")).await?;
let mut base_path = path.join(
download

View file

@ -142,9 +142,7 @@ pub async fn get_logs_by_file(
.join(&log_file);
let metadata = std::fs::metadata(&path)?;
let age = metadata
.created()
.unwrap_or(SystemTime::UNIX_EPOCH);
let age = metadata.created().unwrap_or(SystemTime::UNIX_EPOCH);
LogManager::initialize(log_type, age, &cluster_path, log_file, Some(true)).await
}

View file

@ -79,9 +79,7 @@ pub async fn import_instances(import: ImportType, path: PathBuf) -> crate::Resul
ImportType::TLauncher => "instances".to_string(),
ImportType::Technic => "instances".to_string(),
ImportType::FTBLauncher => "instances".to_string(),
_ => {
return Err(anyhow::anyhow!("launcher type unknown, cant import").into())
}
_ => return Err(anyhow::anyhow!("launcher type unknown, cant import").into()),
};
let instances_dir = path.join(&instances_path);
@ -97,11 +95,11 @@ pub async fn import_instances(import: ImportType, path: PathBuf) -> crate::Resul
{
let path = e.path();
if path.is_dir() && is_valid_instance(path.clone(), import).await {
let name = path.file_name();
if let Some(name) = name {
instances.push(name.to_string_lossy().to_string());
}
}
let name = path.file_name();
if let Some(name) = name {
instances.push(name.to_string_lossy().to_string());
}
}
}
Ok(instances)

View file

@ -26,8 +26,7 @@ impl Credentials {
) -> crate::Result<Self> {
let path = SnapshotPath::from_path(path);
let stronghold = iota_stronghold::Stronghold::default();
let keyprovider =
KeyProvider::try_from(password).map_err(StrongholdError::MemoryError)?;
let keyprovider = KeyProvider::try_from(password).map_err(StrongholdError::MemoryError)?;
if path.exists() {
stronghold
.load_snapshot(&keyprovider, &path)

View file

@ -1,6 +1,5 @@
//! Handles MSA Authentication flow.
use std::fmt::Write;
use base64::Engine;
use chrono::{DateTime, Utc};
use p256::ecdsa::signature::Signer;
@ -11,6 +10,7 @@ use serde::{Deserialize, Serialize};
use serde_json::json;
use sha2::Digest;
use std::collections::HashMap;
use std::fmt::Write;
use uuid::Uuid;
const AUTH_STORE: &str = "authentication.json";
@ -878,8 +878,7 @@ async fn send_signed_request<T: serde::de::DeserializeOwned>(
step: MinecraftAuthStep,
current_date: DateTime<Utc>,
) -> Result<SignedRequestResponse<T>, MinecraftAuthError> {
let auth = authorization
.map_or(Vec::new(), |v| v.as_bytes().to_vec());
let auth = authorization.map_or(Vec::new(), |v| v.as_bytes().to_vec());
let body = serde_json::to_vec(&raw_body)
.map_err(|source| MinecraftAuthError::SerializeError { step, source })?;
let time: u128 = { ((current_date.timestamp() as u128) + 11644473600) * 10000000 };

View file

@ -1,7 +1,6 @@
//! Handlers for Mod metadata that can be displayed in a GUI mod list or exported as a mod pack
#[allow(clippy::all)]
use async_zip::tokio::read::fs::ZipFileReader;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};

View file

@ -41,9 +41,9 @@ pub enum IngressProcessType {
}
impl Default for IngressProcessor {
fn default() -> Self {
Self::new()
}
fn default() -> Self {
Self::new()
}
}
impl IngressProcessor {

View file

@ -202,9 +202,7 @@ pub fn extract_archive(archive: &PathBuf, dest: &PathBuf) -> crate::Result<()> {
pub fn extract_zip(archive: &PathBuf, dest: &PathBuf) -> Result<(), IOError> {
let file = File::open(archive).map_err(|err| IOError::with_path(err, archive.as_path()))?;
let archive = zip::ZipArchive::new(file).map_err(IOError::from_zip);
archive?
.extract(dest)
.map_err(IOError::from_zip)?;
archive?.extract(dest).map_err(IOError::from_zip)?;
Ok(())
}

View file

@ -1,26 +1,31 @@
use std::{collections::HashMap, path::PathBuf, str::FromStr};
use std::collections::HashMap;
use std::path::PathBuf;
use std::str::FromStr;
use chrono::DateTime;
use onelauncher::{cluster, data::{ClusterMeta, Loader, PackageData}, store::{Cluster, ClusterPath}, State};
use onelauncher::data::{ClusterMeta, Loader, PackageData};
use onelauncher::store::{Cluster, ClusterPath};
use onelauncher::{cluster, State};
use serde::{Deserialize, Serialize};
use specta::Type;
use uuid::Uuid;
#[macro_export]
macro_rules! collect_commands {
() => {
{
use $crate::api::commands::*;
tauri_specta::ts::builder()
.config(specta::ts::ExportConfig::default().bigint(specta::ts::BigIntExportBehavior::BigInt))
.commands(tauri_specta::collect_commands![
is_dev,
create_cluster,
get_cluster,
get_clusters
])
}
};
() => {{
use $crate::api::commands::*;
tauri_specta::ts::builder()
.config(
specta::ts::ExportConfig::default()
.bigint(specta::ts::BigIntExportBehavior::BigInt),
)
.commands(tauri_specta::collect_commands![
is_dev,
create_cluster,
get_cluster,
get_clusters
])
}};
}
#[specta::specta]
@ -31,7 +36,7 @@ pub fn is_dev() -> bool {
#[derive(Serialize, Deserialize, Type)]
pub struct CreateCluster {
name: String,
name: String,
mc_version: String,
mod_loader: Loader,
loader_version: Option<String>,
@ -45,75 +50,76 @@ pub struct CreateCluster {
#[specta::specta]
#[tauri::command]
pub async fn create_cluster(props: CreateCluster) -> Result<Uuid, String> {
let path = cluster::create::create_cluster(
props.name,
props.mc_version,
props.mod_loader,
props.loader_version,
props.icon,
props.icon_url,
props.package_data,
props.skip,
props.skip_watch,
).await?;
let path = cluster::create::create_cluster(
props.name,
props.mc_version,
props.mod_loader,
props.loader_version,
props.icon,
props.icon_url,
props.package_data,
props.skip,
props.skip_watch,
)
.await?;
if let Some(cluster) = cluster::get(&path, None).await? {
Ok(cluster.uuid)
} else {
Err("Cluster does not exist".to_string())
}
if let Some(cluster) = cluster::get(&path, None).await? {
Ok(cluster.uuid)
} else {
Err("Cluster does not exist".to_string())
}
}
fn placeholder_cluster() -> Cluster {
let path = ClusterPath("test".into());
Cluster {
uuid: Uuid::from_str("56d1cbcf-1961-4477-b263-80e3b1c7a9d1").unwrap(),
stage: onelauncher::store::ClusterStage::Installed,
path: path.0,
meta: ClusterMeta {
created_at: DateTime::from_timestamp_millis(1718297861712).unwrap(),
modified_at: DateTime::from_timestamp_millis(1718297861712).unwrap(),
group: vec![],
icon: None,
icon_url: None,
loader: Loader::Vanilla,
loader_version: None,
mc_version: "1.8.9".into(),
name: "Test Cluster".into(),
overall_played: 58195,
recently_played: 0,
package_data: None,
played_at: None
},
memory: None,
java: None,
resolution: None,
force_fullscreen: None,
init_hooks: None,
packages: HashMap::new(),
update: None
}
let path = ClusterPath("test".into());
Cluster {
uuid: Uuid::from_str("56d1cbcf-1961-4477-b263-80e3b1c7a9d1").unwrap(),
stage: onelauncher::store::ClusterStage::Installed,
path: path.0,
meta: ClusterMeta {
created_at: DateTime::from_timestamp_millis(1718297861712).unwrap(),
modified_at: DateTime::from_timestamp_millis(1718297861712).unwrap(),
group: vec![],
icon: None,
icon_url: None,
loader: Loader::Vanilla,
loader_version: None,
mc_version: "1.8.9".into(),
name: "Test Cluster".into(),
overall_played: 58195,
recently_played: 0,
package_data: None,
played_at: None,
},
memory: None,
java: None,
resolution: None,
force_fullscreen: None,
init_hooks: None,
packages: HashMap::new(),
update: None,
}
}
#[specta::specta]
#[tauri::command]
pub async fn get_cluster(uuid: Uuid) -> Result<Cluster, String> {
Ok(placeholder_cluster())
Ok(placeholder_cluster())
// match cluster::get_by_uuid(uuid, None).await? {
// Some(cluster) => Ok(cluster),
// None => Err("Cluster does not exist".into())
// }
// match cluster::get_by_uuid(uuid, None).await? {
// Some(cluster) => Ok(cluster),
// None => Err("Cluster does not exist".into())
// }
}
#[specta::specta]
#[tauri::command]
pub async fn get_clusters() -> Result<HashMap<ClusterPath, Cluster>, String> {
let mut map = HashMap::<ClusterPath, Cluster>::new();
let cluster = placeholder_cluster();
map.insert(cluster.cluster_path(), cluster);
let mut map = HashMap::<ClusterPath, Cluster>::new();
let cluster = placeholder_cluster();
map.insert(cluster.cluster_path(), cluster);
Ok(map)
// cluster::list(None).await.map_err(|op| op.into())
Ok(map)
// cluster::list(None).await.map_err(|op| op.into())
}

View file

@ -20,20 +20,20 @@ pub type Result<T> = std::result::Result<T, OneLauncherSerializableError>;
#[derive(thiserror::Error, Debug, Serialize, specta::Type)]
pub enum OneLauncherSerializableError {
#[error("{0}")]
CommonError(String),
#[error("{0}")]
CommonError(String),
}
impl From<OneLauncherError> for OneLauncherSerializableError {
fn from(value: OneLauncherError) -> Self {
Self::CommonError(value.to_string())
}
fn from(value: OneLauncherError) -> Self {
Self::CommonError(value.to_string())
}
}
impl From<onelauncher::Error> for OneLauncherSerializableError {
fn from(value: onelauncher::Error) -> Self {
Self::CommonError(value.to_string())
}
fn from(value: onelauncher::Error) -> Self {
Self::CommonError(value.to_string())
}
}
#[derive(thiserror::Error, Debug)]

View file

@ -1,18 +1,19 @@
use tauri::{plugin::TauriPlugin, Manager, Runtime};
use tauri::plugin::TauriPlugin;
use tauri::{Manager, Runtime};
use tauri_plugin_updater::{Update as TauriPluginUpdate, UpdaterExt};
use tokio::sync::Mutex;
#[derive(Debug, Clone, serde::Serialize)]
pub struct Update {
pub version: String,
pub version: String,
}
impl Update {
fn new(update: &TauriPluginUpdate) -> Self {
Self {
version: update.version.clone(),
}
}
fn new(update: &TauriPluginUpdate) -> Self {
Self {
version: update.version.clone(),
}
}
}
#[derive(Default)]

View file

@ -35,9 +35,7 @@ pub async fn run() {
.await;
}
pub async fn run_app<F: FnOnce(&mut tauri::App) + Send + 'static>(
setup: F,
) {
pub async fn run_app<F: FnOnce(&mut tauri::App) + Send + 'static>(setup: F) {
let builder = tauri::Builder::default()
.plugin(tauri_plugin_shell::init())
.plugin(tauri_plugin_single_instance::init(|app, argv, cwd| {
@ -55,22 +53,20 @@ pub async fn run_app<F: FnOnce(&mut tauri::App) + Send + 'static>(
Ok(())
});
let builder = builder
.plugin(api::init())
.invoke_handler({
let builder = collect_commands!();
let builder = builder.plugin(api::init()).invoke_handler({
let builder = collect_commands!();
#[cfg(debug_assertions)]
let builder = builder.path("../src/bindings.ts");
#[cfg(debug_assertions)]
let builder = builder.path("../src/bindings.ts");
builder.build().unwrap()
});
builder.build().unwrap()
});
let app = builder
.build(tauri::tauri_build_context!())
.expect("failed to build tauri application");
initialize_state(app.app_handle().clone()).await;
initialize_state(app.app_handle().clone()).await;
app.run(|_app_handle, _event| {})
}

View file

@ -8,11 +8,10 @@ import NotificationOverlay from './components/overlay/notifications/Notification
import { bridge } from '~index';
function App(props: ParentProps) {
if (!bridge.commands.isDev()) {
if (!bridge.commands.isDev())
document.addEventListener('contextmenu', (event) => {
event.preventDefault();
});
}
return (
<main class="flex flex-col bg-primary w-full min-h-screen overflow-hidden h-screen max-h-screen text-fg-primary">

View file

@ -14,7 +14,7 @@ function Dropdown(props: DropdownProps) {
const [split, rest] = splitProps(props, ['children', 'class', 'text', 'onChange', 'selected']);
const [visible, setVisible] = createSignal(false);
// eslint-disable-next-line solid/reactivity
// eslint-disable-next-line solid/reactivity -- todo
const [selected, setSelected] = createSignal<number>(split.selected || 0);
let ref!: HTMLDivElement;

View file

@ -7,7 +7,7 @@ import type {
Setter } from 'solid-js';
import { Portal } from 'solid-js/web';
// eslint-disable-next-line ts/no-namespace
// eslint-disable-next-line ts/no-namespace -- todo
declare namespace Popup {
type PopupProps = Omit<Parameters<typeof Portal>[0], 'children'> & ParentProps & {
visible: Accessor<boolean>;

View file

@ -14,7 +14,7 @@ export function getCluster(uuid: string | undefined | null): Resource<Cluster> |
}
export function ClusterProvider(props: ParentProps & { uuid: string | undefined }) {
// eslint-disable-next-line solid/reactivity
// eslint-disable-next-line solid/reactivity -- todo
const cluster = getCluster(props.uuid);
return (

View file

@ -4,7 +4,6 @@ import Button from '~ui/components/base/Button';
import Tooltip from '~ui/components/base/Tooltip';
import PlayerHead from '~ui/components/game/PlayerHead';
import ScrollableContainer from '~ui/components/ScrollableContainer';
import SettingsRow from '~ui/components/SettingsRow';
import Sidebar from '~ui/components/Sidebar';
const Accounts: {