refactor: Prisma
This commit is contained in:
parent
bfb998f013
commit
e6527f1102
14 changed files with 3349 additions and 240 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -1,3 +1,7 @@
|
|||
|
||||
# Prisma
|
||||
crates/prisma/src/prisma.rs
|
||||
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/node,rust,yarn,linux,macos,windows,rust-analyzer,visualstudiocode,git
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=node,rust,yarn,linux,macos,windows,rust-analyzer,visualstudiocode,git
|
||||
|
||||
|
|
|
|||
30
Cargo.toml
30
Cargo.toml
|
|
@ -8,33 +8,15 @@ members = [
|
|||
[workspace.package]
|
||||
license = "GPL-3.0-only"
|
||||
edition = "2021"
|
||||
repository = "https://github.com/polyfrost/nexus"
|
||||
repository = "https://github.com/Polyfrost/Nexus"
|
||||
|
||||
[workspace.dependencies]
|
||||
prisma-client-rust = { git = "https://github.com/Brendonovich/prisma-client-rust", features = [
|
||||
"specta",
|
||||
"sqlite-create-many",
|
||||
"migrations",
|
||||
"sqlite",
|
||||
], default-features = false, branch = "rspc-0.2.0" }
|
||||
prisma-client-rust-cli = { git = "https://github.com/Brendonovich/prisma-client-rust", features = [
|
||||
"specta",
|
||||
"sqlite-create-many",
|
||||
"migrations",
|
||||
"sqlite",
|
||||
], default-features = false, branch = "rspc-0.2.0" }
|
||||
prisma-client-rust-sdk = { git = "https://github.com/Brendonovich/prisma-client-rust", features = [ "sqlite", ], default-features = false, branch = "rspc-0.2.0" }
|
||||
rspc = { git = "https://github.com/oscartbeaumont/rspc" }
|
||||
specta = { git = "https://github.com/oscartbeaumont/specta" }
|
||||
tauri-specta = { git = "https://github.com/oscartbeaumont/tauri-specta" }
|
||||
tauri = { version = "2.0.0-beta", features = [] }
|
||||
tokio = { version = "1", features = [ "full" ] }
|
||||
serde = { version = "1", features = [ "derive" ] }
|
||||
prisma-client-rust = { git = "https://github.com/Brendonovich/prisma-client-rust", tag = "0.6.11" }
|
||||
prisma-client-rust-cli = { git = "https://github.com/Brendonovich/prisma-client-rust", tag = "0.6.11" }
|
||||
uuid = { version = "1.7.0", features = [ "serde" ] }
|
||||
serde_json = "1"
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = "0.3"
|
||||
tracing-appender = "0.2"
|
||||
serde = { version = "1", features = [ "derive" ] }
|
||||
serde_json = { version = "1" }
|
||||
tokio = { version = "1", features = [ "full" ] }
|
||||
|
||||
[profile.dev]
|
||||
# Make compilation faster on macOS
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
fn main() {
|
||||
prisma_client_rust_cli::run();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,2 +1,2 @@
|
|||
#[allow(warnings, unused)]
|
||||
pub mod prisma;
|
||||
pub mod prisma;
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
"dependencies": {
|
||||
"@fontsource/poppins": "^5.0.12",
|
||||
"@solidjs/router": "^0.13.0",
|
||||
"@tauri-apps/api": "2.0.0-beta.5",
|
||||
"@tauri-apps/api": "2.0.0-beta.6",
|
||||
"@tauri-apps/plugin-shell": "2.0.0-beta.2",
|
||||
"@thisbeyond/solid-dnd": "^0.7.5",
|
||||
"@untitled-theme/icons-solid": "^0.6.0",
|
||||
|
|
@ -30,7 +30,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@flowr/eslint-config": "^2.2.1",
|
||||
"@tauri-apps/cli": "2.0.0-beta.9",
|
||||
"@tauri-apps/cli": "2.0.0-beta.10",
|
||||
"@types/uuid": "^9.0.8",
|
||||
"autoprefixer": "^10.4.18",
|
||||
"eslint": "^8.57.0",
|
||||
|
|
|
|||
76
pnpm-lock.yaml
generated
76
pnpm-lock.yaml
generated
|
|
@ -12,8 +12,8 @@ dependencies:
|
|||
specifier: ^0.13.0
|
||||
version: 0.13.0(solid-js@1.8.15)
|
||||
'@tauri-apps/api':
|
||||
specifier: 2.0.0-beta.5
|
||||
version: 2.0.0-beta.5
|
||||
specifier: 2.0.0-beta.6
|
||||
version: 2.0.0-beta.6
|
||||
'@tauri-apps/plugin-shell':
|
||||
specifier: 2.0.0-beta.2
|
||||
version: 2.0.0-beta.2
|
||||
|
|
@ -44,8 +44,8 @@ devDependencies:
|
|||
specifier: ^2.2.1
|
||||
version: 2.2.1(@vue/compiler-sfc@3.4.21)(eslint-plugin-solid@0.13.1)(eslint@8.57.0)
|
||||
'@tauri-apps/cli':
|
||||
specifier: 2.0.0-beta.9
|
||||
version: 2.0.0-beta.9
|
||||
specifier: 2.0.0-beta.10
|
||||
version: 2.0.0-beta.10
|
||||
'@types/uuid':
|
||||
specifier: ^9.0.8
|
||||
version: 9.0.8
|
||||
|
|
@ -998,13 +998,13 @@ packages:
|
|||
engines: {node: '>= 18', npm: '>= 6.6.0', yarn: '>= 1.19.1'}
|
||||
dev: false
|
||||
|
||||
/@tauri-apps/api@2.0.0-beta.5:
|
||||
resolution: {integrity: sha512-lKRdV3adcNN8N+XLrnhGgWFrHsb7/I1VgweLjqTdOpEU7PKZcKvn1j3WOQGNNGSTD/RPSYBaGuXeE0Nk8eW3jw==}
|
||||
/@tauri-apps/api@2.0.0-beta.6:
|
||||
resolution: {integrity: sha512-ay3kAXYQoqC3rX4Vr3y6uGwrBhRPM7UQqZ9wr1VYzN6lkcMIcu7+UBvytmcfXDlVctqFoMQJafn6+dK/Oqh8+Q==}
|
||||
engines: {node: '>= 18', npm: '>= 6.6.0', yarn: '>= 1.19.1'}
|
||||
dev: false
|
||||
|
||||
/@tauri-apps/cli-darwin-arm64@2.0.0-beta.9:
|
||||
resolution: {integrity: sha512-7OthLcko0Z2FUpP6fqJQhjaVKmxgXW6tWOi+X67HDjP1Iixquhh/vP5JqdSi7gYK8bphcegPp9UETuAgHx7MtA==}
|
||||
/@tauri-apps/cli-darwin-arm64@2.0.0-beta.10:
|
||||
resolution: {integrity: sha512-ZCNrvCn+hKsGXK6CZXmFMyWWR0MdQIq4TtEbQUG1vcepsb8ITJLo0yFmP/Dy5oSjQ1OO2/t5f7mkYj/yGut4xQ==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
|
|
@ -1012,8 +1012,8 @@ packages:
|
|||
dev: true
|
||||
optional: true
|
||||
|
||||
/@tauri-apps/cli-darwin-x64@2.0.0-beta.9:
|
||||
resolution: {integrity: sha512-Pwf6GBGZuV9y7PEtaLQlzS3x91hFPkA0Ro8vaUxTirYkFiJFTgoigXDHjMsjfjy+E/8oAAHr7Z0zeA6ijR5t1w==}
|
||||
/@tauri-apps/cli-darwin-x64@2.0.0-beta.10:
|
||||
resolution: {integrity: sha512-9sasAhH9zWEV4YKBeF9hcxcgA43ff1Y25OdkM9GsZSxo6gceNOaDuYAwaQL5KS35lM01JZLKioStAGRyzz+sxA==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
|
|
@ -1021,8 +1021,8 @@ packages:
|
|||
dev: true
|
||||
optional: true
|
||||
|
||||
/@tauri-apps/cli-linux-arm-gnueabihf@2.0.0-beta.9:
|
||||
resolution: {integrity: sha512-daAXSac82vbYlwxbRT0DwFr4gP4v1XnHEwA72EeKRiKGw7GeHwzqoY/URVolBGY7sIBwwL+0qc1hqPde9dsm1g==}
|
||||
/@tauri-apps/cli-linux-arm-gnueabihf@2.0.0-beta.10:
|
||||
resolution: {integrity: sha512-g/YzvHoGD8Sr3j3stiBVx1gPuGPznklTOCQ8qHBPhW243xeLG/IwMBF8jDDtqfnRIwJBIIltS733ZJRlsFnXNA==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
|
|
@ -1030,8 +1030,8 @@ packages:
|
|||
dev: true
|
||||
optional: true
|
||||
|
||||
/@tauri-apps/cli-linux-arm64-gnu@2.0.0-beta.9:
|
||||
resolution: {integrity: sha512-qHyACvFWIAbcl1C7cq64ciIXxaLOnZAgGXIEE48JLc5VeXkpYUF5sNLPjafidY/CxYoFoE453lh3dLc3DjNhuw==}
|
||||
/@tauri-apps/cli-linux-arm64-gnu@2.0.0-beta.10:
|
||||
resolution: {integrity: sha512-KYuDwbQSky98NhEcIY47r7lR6yQgx2fLiLtW7nL63zZGW0eCLRTY1gVZUjYlLAJtaPmg2dyup/gbCvVrdq+/hQ==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
|
|
@ -1039,8 +1039,8 @@ packages:
|
|||
dev: true
|
||||
optional: true
|
||||
|
||||
/@tauri-apps/cli-linux-arm64-musl@2.0.0-beta.9:
|
||||
resolution: {integrity: sha512-DkrkxGKlQ1Sonvo4ltv6XqNxNuNxDyxfdZdvx3CEecKomMyFV6xTxp0/IcqF9fIRPL2Gp2PaPBWOuj+K8v95vw==}
|
||||
/@tauri-apps/cli-linux-arm64-musl@2.0.0-beta.10:
|
||||
resolution: {integrity: sha512-Xwnsjqsd9cGdvzNhJ/RrQA0w8LsykzXf9qwoJY9Ds6baCWhjb7pP3nJuEO4pWGkzpvWlLa+F5znRdQnZ9ydS9g==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
|
|
@ -1048,8 +1048,8 @@ packages:
|
|||
dev: true
|
||||
optional: true
|
||||
|
||||
/@tauri-apps/cli-linux-x64-gnu@2.0.0-beta.9:
|
||||
resolution: {integrity: sha512-pY0DOrWAwSkIkhw7UdRK0VNVFLwP+yltqCoQ+Zji5Vwk/x98mBo0L2bF3nSOLhYPAaW41v3AIOIZY1sBYWSq/w==}
|
||||
/@tauri-apps/cli-linux-x64-gnu@2.0.0-beta.10:
|
||||
resolution: {integrity: sha512-mTas7uznEwBtmpZld0m0cLR7tZRg1EOIPDFcaGiA97nA1ZLN6Za6ZgcNWc6Jehu6yTNk0UMx8a6c3kP/CkR5pw==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
|
|
@ -1057,8 +1057,8 @@ packages:
|
|||
dev: true
|
||||
optional: true
|
||||
|
||||
/@tauri-apps/cli-linux-x64-musl@2.0.0-beta.9:
|
||||
resolution: {integrity: sha512-GYQy1bKWbrRyr4X2epbltq82k4Vhr9TzNFky/fflOyDXlMP36IqBOjQ6PEzvKTajNglciIdTPQfdoUKX4+PA/Q==}
|
||||
/@tauri-apps/cli-linux-x64-musl@2.0.0-beta.10:
|
||||
resolution: {integrity: sha512-682kO1kZMoWrQqvI7IrVFrZ4i4/t1WdBnjXS1B2SiTuC7SkIFczV2w1YLtGQyBmLRhY574CBZx+rZJAp/W8UwA==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
|
|
@ -1066,8 +1066,8 @@ packages:
|
|||
dev: true
|
||||
optional: true
|
||||
|
||||
/@tauri-apps/cli-win32-arm64-msvc@2.0.0-beta.9:
|
||||
resolution: {integrity: sha512-0DTM06N/x57+vV/itT3l/34ZHjXIxPc315OWHE9MmY+vE37t/QFp9FNZDN/VdveZ1ZgmEn3rSQNchqcMaMdD3w==}
|
||||
/@tauri-apps/cli-win32-arm64-msvc@2.0.0-beta.10:
|
||||
resolution: {integrity: sha512-5lgGQflb7XhEmMAPIVVb5kOhXTLyXwUhJHKNS09GZCGHiwHHNjBN/Q1CVVjUdZ4yalYosYkYnJLMdZxwWhBe9w==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
|
|
@ -1075,8 +1075,8 @@ packages:
|
|||
dev: true
|
||||
optional: true
|
||||
|
||||
/@tauri-apps/cli-win32-ia32-msvc@2.0.0-beta.9:
|
||||
resolution: {integrity: sha512-HxrSAVjYRjPGm97lf18BvuoirgrE5uyvpALvGO98m8ZO9Y9CHklEadYi19nCVlr5d4mmP2GUbxCCx1Mc8XRAuA==}
|
||||
/@tauri-apps/cli-win32-ia32-msvc@2.0.0-beta.10:
|
||||
resolution: {integrity: sha512-iedmBO7Uo1EIjU9YgNw1rt/ikgWYTB9TV/UiIarL3gy3DHqKo3aMinfzHU6NJQPKK2bvF06a3cee7roqWa4baQ==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [ia32]
|
||||
os: [win32]
|
||||
|
|
@ -1084,8 +1084,8 @@ packages:
|
|||
dev: true
|
||||
optional: true
|
||||
|
||||
/@tauri-apps/cli-win32-x64-msvc@2.0.0-beta.9:
|
||||
resolution: {integrity: sha512-abdCoiMjit9sSXziRCEf9VdEFbqqbEqg3ySOQmNAQTCsenr33iWjIoCMv/ThORtXKJ209yGyXlxBZY7Muxfi3A==}
|
||||
/@tauri-apps/cli-win32-x64-msvc@2.0.0-beta.10:
|
||||
resolution: {integrity: sha512-m7oQMZwbj0UtTMTO1HSukcFUcnacRTZ1so/gsjmeOoDIa9WWccrxro9OQ5Upkz1UtZSO4sHdlFrxAhSBS8r5/Q==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
|
@ -1093,21 +1093,21 @@ packages:
|
|||
dev: true
|
||||
optional: true
|
||||
|
||||
/@tauri-apps/cli@2.0.0-beta.9:
|
||||
resolution: {integrity: sha512-QYBuCAAdV10tGOTMWGLbt6d+2+Tq8K9bb4oiinChUV/JmCNe9SaTlG6VW1cCJDf+/F0AuGOTgjyBNw8DOiTrow==}
|
||||
/@tauri-apps/cli@2.0.0-beta.10:
|
||||
resolution: {integrity: sha512-1W4m86t5RrCyVZ+oV5xo160sOxtS33vo9s+MPzHLwrb37ApyAEaIUfXjDjoejsLH9ZDskupxnzzWKzBOM90SrA==}
|
||||
engines: {node: '>= 10'}
|
||||
hasBin: true
|
||||
optionalDependencies:
|
||||
'@tauri-apps/cli-darwin-arm64': 2.0.0-beta.9
|
||||
'@tauri-apps/cli-darwin-x64': 2.0.0-beta.9
|
||||
'@tauri-apps/cli-linux-arm-gnueabihf': 2.0.0-beta.9
|
||||
'@tauri-apps/cli-linux-arm64-gnu': 2.0.0-beta.9
|
||||
'@tauri-apps/cli-linux-arm64-musl': 2.0.0-beta.9
|
||||
'@tauri-apps/cli-linux-x64-gnu': 2.0.0-beta.9
|
||||
'@tauri-apps/cli-linux-x64-musl': 2.0.0-beta.9
|
||||
'@tauri-apps/cli-win32-arm64-msvc': 2.0.0-beta.9
|
||||
'@tauri-apps/cli-win32-ia32-msvc': 2.0.0-beta.9
|
||||
'@tauri-apps/cli-win32-x64-msvc': 2.0.0-beta.9
|
||||
'@tauri-apps/cli-darwin-arm64': 2.0.0-beta.10
|
||||
'@tauri-apps/cli-darwin-x64': 2.0.0-beta.10
|
||||
'@tauri-apps/cli-linux-arm-gnueabihf': 2.0.0-beta.10
|
||||
'@tauri-apps/cli-linux-arm64-gnu': 2.0.0-beta.10
|
||||
'@tauri-apps/cli-linux-arm64-musl': 2.0.0-beta.10
|
||||
'@tauri-apps/cli-linux-x64-gnu': 2.0.0-beta.10
|
||||
'@tauri-apps/cli-linux-x64-musl': 2.0.0-beta.10
|
||||
'@tauri-apps/cli-win32-arm64-msvc': 2.0.0-beta.10
|
||||
'@tauri-apps/cli-win32-ia32-msvc': 2.0.0-beta.10
|
||||
'@tauri-apps/cli-win32-x64-msvc': 2.0.0-beta.10
|
||||
dev: true
|
||||
|
||||
/@tauri-apps/plugin-shell@2.0.0-beta.2:
|
||||
|
|
|
|||
3273
src-tauri/Cargo.lock
generated
3273
src-tauri/Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -10,31 +10,18 @@ tauri-build = { version = "2.0.0-beta", features = [] }
|
|||
|
||||
[dependencies]
|
||||
poly-prisma = { path = "../crates/prisma" }
|
||||
rspc = { workspace = true, features = [
|
||||
"tracing",
|
||||
"unstable",
|
||||
] }
|
||||
tauri-specta = { workspace = true, features = [ "typescript" ] }
|
||||
specta = { workspace = true }
|
||||
prisma-client-rust = { workspace = true }
|
||||
tauri = { workspace = true, features = [] }
|
||||
tokio = { workspace = true, features = [
|
||||
"sync",
|
||||
"rt-multi-thread",
|
||||
"io-util",
|
||||
"macros",
|
||||
"time",
|
||||
"process",
|
||||
] }
|
||||
serde = { workspace = true }
|
||||
serde_json = "1"
|
||||
tauri = { version = "2.0.0-beta", features = [] }
|
||||
tauri-plugin-shell = "2.0.0-beta.2"
|
||||
tauri-plugin-http = "2.0.0-beta"
|
||||
tokio = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
flate2 = "1.0.28"
|
||||
tar = "0.4.40"
|
||||
zip = "0.6.6"
|
||||
uuid = { workspace = true }
|
||||
async-trait = "0.1.78"
|
||||
prisma-client-rust = { workspace = true }
|
||||
|
||||
[features]
|
||||
# This feature is used for production builds or when a dev server is not specified, DO NOT REMOVE!!
|
||||
|
|
|
|||
|
|
@ -5,9 +5,7 @@ datasource db {
|
|||
|
||||
generator client {
|
||||
provider = "cargo prisma"
|
||||
output = "../../crates/prisma/src/prisma"
|
||||
module_path = "prisma"
|
||||
client_format = "folder"
|
||||
output = "../../crates/prisma/src/prisma.rs"
|
||||
}
|
||||
|
||||
// todo: replace all `path` fields with a model with a checksum n shit
|
||||
|
|
|
|||
|
|
@ -1,32 +0,0 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use crate::Node;
|
||||
|
||||
pub type Ctx = Arc<Node>;
|
||||
pub type Router = rspc::Router<Ctx>;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Type)]
|
||||
pub enum CoreEvent {
|
||||
InvalidateOperation(),
|
||||
MSALogin(),
|
||||
}
|
||||
|
||||
pub(crate) fn mount() -> Arc<Router> {
|
||||
let r = R
|
||||
.router();
|
||||
|
||||
let r = r.build({
|
||||
let config = rspc::ExportConfig::new(std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../src/client.ts")).set_header("/* eslint-disable */");
|
||||
config
|
||||
});
|
||||
|
||||
r
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn export() {
|
||||
super::mount();
|
||||
}
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ pub fn get_game_client(handle: AppHandle, details: GameClientDetails) -> Box<dyn
|
|||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait GameClient {
|
||||
pub trait GameClient: Send + Sync {
|
||||
fn new(handle: AppHandle, details: GameClientDetails) -> Self where Self: Sized;
|
||||
fn get_version_urls() -> HashMap<String, String> where Self: Sized;
|
||||
fn get_details_from_version(version: String) -> Result<GameClientDetails, Box<dyn Error>> where Self: Sized;
|
||||
|
|
@ -70,7 +70,7 @@ pub trait GameClient {
|
|||
}
|
||||
|
||||
async fn launch(&self) -> Result<(), Box<dyn Error>>;
|
||||
async fn install(&self) -> Result<(), Box<dyn Error>>;
|
||||
async fn setup(&self) -> Result<(), Box<dyn Error>>;
|
||||
|
||||
async fn download_java(&self) -> Result<PathBuf, JavaDownloadError> {
|
||||
let config_dir = match self.get_handle().path().app_config_dir() {
|
||||
|
|
|
|||
|
|
@ -9,22 +9,6 @@ use crate::{create_client, create_manifest, game::client::{GameClient, GameClien
|
|||
create_manifest!(VanillaManifest {});
|
||||
create_client!(VanillaClient {});
|
||||
|
||||
pub mod vanilla_impl {
|
||||
use std::error::Error;
|
||||
|
||||
pub async fn install_libraries() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn install_natives() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn install_assets() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl GameClient for VanillaClient {
|
||||
fn new(handle: AppHandle, details: GameClientDetails) -> Self {
|
||||
|
|
@ -54,10 +38,10 @@ impl GameClient for VanillaClient {
|
|||
&self.get_details().client_type
|
||||
}
|
||||
|
||||
async fn install(&self) -> Result<(), Box<dyn Error>> {
|
||||
vanilla_impl::install_libraries().await?;
|
||||
vanilla_impl::install_natives().await?;
|
||||
vanilla_impl::install_assets().await?;
|
||||
async fn setup(&self) -> Result<(), Box<dyn Error>> {
|
||||
// vanilla_impl::setup_libraries().await?;
|
||||
// vanilla_impl::setup_natives().await?;
|
||||
// vanilla_impl::setup_assets().await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -70,4 +54,60 @@ impl GameClient for VanillaClient {
|
|||
stdout().flush().await?; // why...
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub mod vanilla_impl {
|
||||
use std::error::Error;
|
||||
|
||||
use serde_json::{Map, Value};
|
||||
use tauri::AppHandle;
|
||||
|
||||
pub async fn setup_libraries(manifest: &Value) -> Result<Vec<String>, Box<dyn Error>> {
|
||||
let libraries = match manifest.get("libraries") {
|
||||
Some(libraries) => {
|
||||
if libraries.is_array() {
|
||||
libraries
|
||||
} else {
|
||||
return Err("Invalid libraries object".into())
|
||||
}
|
||||
},
|
||||
None => return Ok(vec![])
|
||||
};
|
||||
|
||||
let mut natives: Vec<&Map<String, Value>> = vec![];
|
||||
for library in libraries.as_array().unwrap() {
|
||||
let library: &Map<String, Value> = library.as_object().unwrap();
|
||||
|
||||
if let Some(_) = library.get("natives") {
|
||||
natives.push(library);
|
||||
continue;
|
||||
}
|
||||
|
||||
let name = library.get("name").ok_or("No name object")?
|
||||
.as_str().ok_or("Invalid name object")?;
|
||||
|
||||
let artifact = library.get("downloads").ok_or("No downloads object")?
|
||||
.as_object().ok_or("Invalid downloads object")?
|
||||
.get("artifact").ok_or("No artifact object")?
|
||||
.as_object().ok_or("Invalid artifact object")?;
|
||||
|
||||
let path = artifact.get("path").ok_or("No path object")?
|
||||
.as_str().ok_or("Invalid path object")?;
|
||||
let url = artifact.get("url").ok_or("No url object")?
|
||||
.as_str().ok_or("Invalid url object")?;
|
||||
|
||||
// TODO: Add checks for rules + platform
|
||||
|
||||
}
|
||||
|
||||
Ok(vec![])
|
||||
}
|
||||
|
||||
pub async fn setup_natives() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn setup_assets() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
@ -61,13 +61,17 @@ async fn launch_game(state: tauri::State<'_, Mutex<GameManagerState>>) -> Result
|
|||
None => return Err("No client selected".into())
|
||||
};
|
||||
|
||||
let res = selected_client.launch().await;
|
||||
match res {
|
||||
if let Err(err) = selected_client.setup().await {
|
||||
return Err(format!("An error has occurred during install: {}", err));
|
||||
}
|
||||
|
||||
match selected_client.launch().await {
|
||||
Ok(_) => Ok(()),
|
||||
Err(e) => Err(format!("An error has occurred: {}", e))
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Implement setting client by UUID, as currently this is creating a new client and setting that
|
||||
#[tauri::command]
|
||||
async fn set_selected_client(handle: tauri::AppHandle, state: tauri::State<'_, Mutex<GameManagerState>>, details: client::GameClientDetails) -> Result<(), String> {
|
||||
let mut state = state.lock().await;
|
||||
|
|
|
|||
|
|
@ -1,51 +1,4 @@
|
|||
use std::{env, f32::consts::E, path::{Path, PathBuf}, sync::Arc};
|
||||
|
||||
use rspc::Router;
|
||||
use tokio::sync::broadcast;
|
||||
|
||||
pub mod auth;
|
||||
pub mod game;
|
||||
pub mod utils;
|
||||
pub mod constants;
|
||||
|
||||
pub(crate) mod api;
|
||||
|
||||
// represents all data and stuff idk
|
||||
// holds references to services like http and microsoft and stuff for ease of use
|
||||
pub struct Node {
|
||||
pub config: something,
|
||||
pub data_dir: PathBuf,
|
||||
pub env: Arc<>,
|
||||
}
|
||||
|
||||
impl Node {
|
||||
pub async fn new(
|
||||
data_dir: impl AsRef<Path>,
|
||||
env: idikdjasdgjsbana,
|
||||
) -> Result<(Arc<Node>, Arc<Router>), NodeError> {
|
||||
let data_dir = data_dir.as_ref();
|
||||
|
||||
print!("starting with data dir '{}'", data_dir.display());
|
||||
|
||||
let env = Arc::new(env);
|
||||
|
||||
let _ = fs::create_dir_all(&data_dir).await;
|
||||
let event_bus = broadcast::channel(1024);
|
||||
|
||||
|
||||
let node = Arc::new(Node {
|
||||
data_dir: data_dir.to_path_buf(),
|
||||
env,
|
||||
});
|
||||
|
||||
let router = api::mount();
|
||||
|
||||
Ok((node, router));
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum NodeError {
|
||||
#[error("the error error error: {0}")]
|
||||
ErrorErrorError(String),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue