DSFHSGDSHRILFDHILAEASHSILDFHLICVDHsrhsdbasadaaaa

This commit is contained in:
Pauline 2024-03-19 20:00:39 +01:00
parent 2b039cdb04
commit bfb998f013
No known key found for this signature in database
GPG key ID: 722BB181973296AE
14 changed files with 257 additions and 6 deletions

2
.cargo/config.toml Normal file
View file

@ -0,0 +1,2 @@
[alias]
prisma = "run -p prisma-cli --bin prisma --"

4
.npmrc Normal file
View file

@ -0,0 +1,4 @@
; make all engine requirements (e.g. node version) strictly kept
engine-strict=true
; tempfix for pnpm#5909: https://github.com/pnpm/pnpm/issues/5909#issuecomment-1397758156
prefer-symlinked-executables=false

1
.nvmrc Normal file
View file

@ -0,0 +1 @@
18

12
.rustfmt.toml Normal file
View file

@ -0,0 +1,12 @@
max_width = 100
hard_tabs = true
newline_style = "Unix"
use_small_heuristics = "Default"
reorder_imports = true
reorder_modules = true
remove_nested_parens = true
edition = "2021"
merge_derives = true
use_try_shorthand = false
use_field_init_shorthand = false
force_explicit_abi = true

50
Cargo.toml Normal file
View file

@ -0,0 +1,50 @@
[workspace]
resolver = "2"
members = [
"src-tauri",
"crates/*",
]
[workspace.package]
license = "GPL-3.0-only"
edition = "2021"
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" ] }
uuid = { version = "1.7.0", features = [ "serde" ] }
serde_json = "1"
tracing = "0.1"
tracing-subscriber = "0.3"
tracing-appender = "0.2"
[profile.dev]
# Make compilation faster on macOS
split-debuginfo = "unpacked"
# Set the settings for build scripts and proc-macros.
[profile.dev.build-override]
opt-level = 3
# Set the default for dependencies, except workspace members.
[profile.dev.package."*"]
opt-level = 3
incremental = false

View file

@ -0,0 +1,9 @@
[package]
name = "prisma-cli"
version = "0.1.0"
license = { workspace = true }
repository = { workspace = true }
edition = { workspace = true }
[dependencies]
prisma-client-rust-cli = { workspace = true }

View file

@ -0,0 +1,3 @@
fn main() {
prisma_client_rust_cli::run();
}

10
crates/prisma/Cargo.toml Normal file
View file

@ -0,0 +1,10 @@
[package]
name = "poly-prisma"
version = "0.1.0"
edition = "2021"
[dependencies]
prisma-client-rust = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
uuid = { workspace = true }

2
crates/prisma/src/lib.rs Normal file
View file

@ -0,0 +1,2 @@
#[allow(warnings, unused)]
pub mod prisma;

View file

@ -11,7 +11,9 @@
"serve": "vite preview",
"tauri": "tauri",
"lint": "eslint . --cache",
"format": "pnpm lint --fix"
"format": "pnpm lint --fix",
"prisma": "cd src-tauri && cargo prisma",
"codegen": "cargo test -p polyfrost-launcher api::tests::export -- --exact"
},
"dependencies": {
"@fontsource/poppins": "^5.0.12",

View file

@ -9,16 +9,31 @@ edition = "2021"
tauri-build = { version = "2.0.0-beta", features = [] }
[dependencies]
tauri = { version = "2.0.0-beta", features = [] }
tokio = { version = "1", features = [ "full" ] }
serde = { version = "1", features = [ "derive" ] }
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-plugin-shell = "2.0.0-beta.2"
tauri-plugin-http = "2.0.0-beta"
flate2 = "1.0.28"
tar = "0.4.40"
zip = "0.6.6"
uuid = { version = "1.7.0", features = [ "serde" ] }
uuid = { workspace = true }
async-trait = "0.1.78"
[features]

View file

@ -0,0 +1,62 @@
datasource db {
provider = "sqlite"
url = "file:dev.db"
}
generator client {
provider = "cargo prisma"
output = "../../crates/prisma/src/prisma"
module_path = "prisma"
client_format = "folder"
}
// todo: replace all `path` fields with a model with a checksum n shit
// represents a single minecraft instance
model Instance {
id Int @id @default(autoincrement())
name String?
path String?
hidden Boolean?
time_played DateTime
last_played DateTime
date_created DateTime
mods Mod[]
// java_instance JavaInstance
@@map("instance")
}
model JavaInstance {
id Int @id @default(autoincrement())
name String?
path String?
version String?
arch String?
/// @local
instance_id Int?
// instance Instance? @relation(fields: [instance_id], references: [id])
@@map("java_instance")
}
model Mod {
id Int @id @default(autoincrement())
name String?
path String?
enabled Boolean @default(true)
hidden Boolean?
date_added DateTime?
/// @local
instance_id Int?
instance Instance? @relation(fields: [instance_id], references: [id], onDelete: SetNull)
@@map("location")
}
// todo the rest of this shit loll

32
src-tauri/src/api.rs Normal file
View file

@ -0,0 +1,32 @@
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();
}
}

View file

@ -1,4 +1,51 @@
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 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),
}