From 095d2747939cd2781689fdce462ec79991b9b1f5 Mon Sep 17 00:00:00 2001 From: Pauline Date: Wed, 24 Jul 2024 02:50:20 +0200 Subject: [PATCH 01/11] =?UTF-8?q?=F0=9F=94=A8=20chore:=20h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.toml | 2 ++ crates/testing/Cargo.toml | 4 ++-- crates/testing/src/main.rs | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d22b5fbb..afd22df0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -151,6 +151,8 @@ sys-info = { version = "0.9" } whoami = { version = "1.5" } cocoa = { version = "0.25" } objc = { version = "0.2" } +webbrowser = { version = "0.8" } +url = { version = "2.5.2" } [patch.crates-io] specta = { git = "https://github.com/oscartbeaumont/specta", rev = "fadef54000e131008ff6e9dd7efe2ba36479c077" } diff --git a/crates/testing/Cargo.toml b/crates/testing/Cargo.toml index 35c98890..38b194bd 100644 --- a/crates/testing/Cargo.toml +++ b/crates/testing/Cargo.toml @@ -14,5 +14,5 @@ authors = { workspace = true } onelauncher = { path = "../core", features = [ "cli" ] } tokio = { workspace = true } -webbrowser = { version = "0.8" } -url = { version = "2.5.2" } +webbrowser = { workspace = true } +url = { workspace = true } diff --git a/crates/testing/src/main.rs b/crates/testing/src/main.rs index 206b832c..f48cc93f 100644 --- a/crates/testing/src/main.rs +++ b/crates/testing/src/main.rs @@ -57,9 +57,9 @@ async fn main() -> onelauncher::Result<()> { } } - let name = "examplecluster".to_string(); - let game = "1.20.4".to_string(); - let loader = Loader::Vanilla; + let name = "Example".to_string(); + let game = "1.21".to_string(); + let loader = Loader::Fabric; let loader_version = "stable".to_string(); let cluster = create_cluster( From ba95190fc05438493954d34fd772ae06ff7fe917 Mon Sep 17 00:00:00 2001 From: Pauline Date: Wed, 24 Jul 2024 07:18:03 +0200 Subject: [PATCH 02/11] =?UTF-8?q?=E2=9C=A8=20feature:=20test=20prisma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .cargo/config.toml | 1 + .clippy.toml | 1 - .envrc | 1 - .gitignore | 2 +- Cargo.toml | 63 +++++++++++++------ crates/core/Cargo.toml | 5 +- .../20240724045148_init/migration.sql | 15 +++++ .../prisma/migrations/migration_lock.toml | 3 + crates/core/prisma/schema.prisma | 28 +++++++++ crates/prisma-cli/Cargo.toml | 13 ++++ crates/prisma-cli/src/bin/prisma.rs | 3 + crates/prisma/Cargo.toml | 16 +++++ crates/prisma/src/lib.rs | 3 + flake.nix | 38 ----------- package.json | 18 ++++-- 15 files changed, 144 insertions(+), 66 deletions(-) delete mode 100644 .clippy.toml delete mode 100644 .envrc create mode 100644 crates/core/prisma/migrations/20240724045148_init/migration.sql create mode 100644 crates/core/prisma/migrations/migration_lock.toml create mode 100644 crates/core/prisma/schema.prisma create mode 100644 crates/prisma-cli/Cargo.toml create mode 100644 crates/prisma-cli/src/bin/prisma.rs create mode 100644 crates/prisma/Cargo.toml create mode 100644 crates/prisma/src/lib.rs delete mode 100644 flake.nix diff --git a/.cargo/config.toml b/.cargo/config.toml index 48c6e34b..40371165 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -5,3 +5,4 @@ rustflags = [ ] [alias] +prisma = "run -p prisma-cli --bin prisma --" diff --git a/.clippy.toml b/.clippy.toml deleted file mode 100644 index 154626ef..00000000 --- a/.clippy.toml +++ /dev/null @@ -1 +0,0 @@ -allow-unwrap-in-tests = true diff --git a/.envrc b/.envrc deleted file mode 100644 index 3550a30f..00000000 --- a/.envrc +++ /dev/null @@ -1 +0,0 @@ -use flake diff --git a/.gitignore b/.gitignore index 3b9a11a3..d239a252 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ repl-result-out* .direnv # Prisma -crates/prisma/src/prisma.rs +crates/prisma/src/prisma dev.db dev.db-journal diff --git a/Cargo.toml b/Cargo.toml index afd22df0..afd76276 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,21 +54,6 @@ tauri-specta = { version = "=2.0.0-rc.11", features = [ # rspc-tauri2 is updated on the main branch rspc-tauri2 = { version = "=0.0.1" } -# prisma-client-rust* is updated on the main branch -prisma-client-rust = { version = "=0.6.8", features = [ - "migrations", - "specta", - "sqlite", - "sqlite-create-many", -], default-features = false } -prisma-client-rust-cli = { version = "=0.6.8", features = [ - "migrations", - "specta", - "sqlite", - "sqlite-create-many", -], default-features = false } -prisma-client-rust-sdk = { version = "=0.6.8", features = [ "sqlite" ], default-features = false } - # interpulse is updated on the main branch interpulse = { version = "=1.0.0", features = [ "specta" ] } @@ -154,6 +139,29 @@ objc = { version = "0.2" } webbrowser = { version = "0.8" } url = { version = "2.5.2" } +[workspace.dependencies.prisma-client-rust] +git = "https://github.com/brendonovich/prisma-client-rust" +rev = "4f9ef9d38ca732162accff72b2eb684d2f120bab" +features = [ + "migrations", + "specta", + "sqlite", + "sqlite-create-many", + "rspc" +] +default-features = false + +[workspace.dependencies.prisma-client-rust-cli] +git = "https://github.com/brendonovich/prisma-client-rust" +rev = "4f9ef9d38ca732162accff72b2eb684d2f120bab" +features = [ + "migrations", + "specta", + "sqlite", + "sqlite-create-many" +] +default-features = false + [patch.crates-io] specta = { git = "https://github.com/oscartbeaumont/specta", rev = "fadef54000e131008ff6e9dd7efe2ba36479c077" } rspc = { git = "https://github.com/oscartbeaumont/rspc", rev = "9f26d6400affdb501837cb023678268ad72feb9b" } @@ -161,18 +169,28 @@ tauri-specta = { git = "https://github.com/oscartbeaumont/tauri-specta", rev = " rspc-tauri2 = { git = "https://github.com/specta-rs/tauri2", rev = "6b9419566e2a826fb2a62538c7647f4524ab0fea" } interpulse = { git = "https://github.com/pulseflow/workers", rev = "4d247c78545703200435a4a063c3f77fd644370f" } -prisma-client-rust = { git = "https://github.com/brendonovich/prisma-client-rust", rev = "4f9ef9d38ca732162accff72b2eb684d2f120bab" } -prisma-client-rust-cli = { git = "https://github.com/brendonovich/prisma-client-rust", rev = "4f9ef9d38ca732162accff72b2eb684d2f120bab" } -prisma-client-rust-sdk = { git = "https://github.com/brendonovich/prisma-client-rust", rev = "4f9ef9d38ca732162accff72b2eb684d2f120bab" } - [profile.dev] # add debug symbols/logic and optimize for reduced build time (parallel) debug = true +# opt-level = 0 +# strip = "none" +# incremental = true +# split-debuginfo = "unpacked" lto = false codegen-units = 256 rpath = false panic = "unwind" +[profile.dev-debug] +inherits = "dev" +split-debuginfo = "none" +opt-level = 0 +debug = "full" +strip = "none" +lto = "off" +codegen-units = 256 +incremental = true + # Set the settings for build scripts and proc-macros. [profile.dev.build-override] opt-level = 3 @@ -182,6 +200,13 @@ opt-level = 3 opt-level = 3 incremental = false +# Set the default for dependencies, except workspace members. +[profile.dev-debug.package."*"] +inherits = "dev" +opt-level = 3 +debug = "full" +incremental = false + # optimize for speed and reduce size for release [profile.release] panic = "abort" # strip panic cleanup logic diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index 3b423ae0..418989db 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -17,17 +17,20 @@ default = [] tauri = [ "dep:tauri", "dep:tauri-specta", - "dep:specta" + "dep:specta", ] cli = [ "dep:indicatif" ] [dependencies] onelauncher_debug = { path = "../debugger" } +onelauncher_prisma = { path = "../prisma" } # GUI-only deps tauri = { workspace = true, optional = true } tauri-specta = { workspace = true, optional = true } specta = { workspace = true, optional = true } +# rspc = { workspace = true } +# rspc-tauri2 = { workspace = true, optional = true } # CLI-only deps indicatif = { workspace = true, optional = true } diff --git a/crates/core/prisma/migrations/20240724045148_init/migration.sql b/crates/core/prisma/migrations/20240724045148_init/migration.sql new file mode 100644 index 00000000..aeedbbd9 --- /dev/null +++ b/crates/core/prisma/migrations/20240724045148_init/migration.sql @@ -0,0 +1,15 @@ +-- CreateTable +CREATE TABLE "settings" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT DEFAULT 0, + "theme" TEXT NOT NULL DEFAULT 'dark', + "hide_close_prompt" BOOLEAN NOT NULL DEFAULT true, + "disable_animations" BOOLEAN NOT NULL DEFAULT false, + "force_fullscreen" BOOLEAN NOT NULL DEFAULT false, + "resolution_x" INTEGER NOT NULL DEFAULT 854, + "resolution_y" INTEGER NOT NULL DEFAULT 480, + "memory_max" INTEGER NOT NULL DEFAULT 2048, + "memory_min" INTEGER NOT NULL DEFAULT 1024, + "hook_pre" TEXT, + "hook_wrapper" TEXT, + "hook_post" TEXT +); diff --git a/crates/core/prisma/migrations/migration_lock.toml b/crates/core/prisma/migrations/migration_lock.toml new file mode 100644 index 00000000..e5e5c470 --- /dev/null +++ b/crates/core/prisma/migrations/migration_lock.toml @@ -0,0 +1,3 @@ +# Please do not edit this file manually +# It should be added in your version-control system (i.e. Git) +provider = "sqlite" \ No newline at end of file diff --git a/crates/core/prisma/schema.prisma b/crates/core/prisma/schema.prisma new file mode 100644 index 00000000..0cafb70b --- /dev/null +++ b/crates/core/prisma/schema.prisma @@ -0,0 +1,28 @@ +datasource db { + provider = "sqlite" + url = "file:dev.db" +} + +generator client { + provider = "cargo prisma" + output = "../../prisma/src/prisma" + module_path = "prisma" + client_format = "folder" +} + +model Settings { + id Int @id @default(0) + theme String @default("dark") + hide_close_prompt Boolean @default(true) + disable_animations Boolean @default(false) + force_fullscreen Boolean @default(false) + resolution_x Int @default(854) + resolution_y Int @default(480) + memory_max Int @default(2048) + memory_min Int @default(1024) + hook_pre String? + hook_wrapper String? + hook_post String? + + @@map("settings") +} diff --git a/crates/prisma-cli/Cargo.toml b/crates/prisma-cli/Cargo.toml new file mode 100644 index 00000000..3fa52bbe --- /dev/null +++ b/crates/prisma-cli/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "prisma-cli" +version = "0.1.0" +license = { workspace = true } +edition = { workspace = true } +repository = { workspace = true } +documentation = { workspace = true } +readme = { workspace = true } +homepage = { workspace = true } +authors = { workspace = true } + +[dependencies] +prisma-client-rust-cli = { workspace = true } diff --git a/crates/prisma-cli/src/bin/prisma.rs b/crates/prisma-cli/src/bin/prisma.rs new file mode 100644 index 00000000..f7580155 --- /dev/null +++ b/crates/prisma-cli/src/bin/prisma.rs @@ -0,0 +1,3 @@ +fn main() { + prisma_client_rust_cli::run(); +} diff --git a/crates/prisma/Cargo.toml b/crates/prisma/Cargo.toml new file mode 100644 index 00000000..e06d15a7 --- /dev/null +++ b/crates/prisma/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "onelauncher_prisma" +version = "0.1.0" +license = { workspace = true } +edition = { workspace = true } +repository = { workspace = true } +documentation = { workspace = true } +readme = { workspace = true } +homepage = { workspace = true } +authors = { workspace = true } + +[dependencies] +prisma-client-rust = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +uuid = { workspace = true } diff --git a/crates/prisma/src/lib.rs b/crates/prisma/src/lib.rs new file mode 100644 index 00000000..aedd2283 --- /dev/null +++ b/crates/prisma/src/lib.rs @@ -0,0 +1,3 @@ +#![recursion_limit = "256"] +#[allow(warnings, unused)] +pub mod prisma; diff --git a/flake.nix b/flake.nix deleted file mode 100644 index 423d4b0c..00000000 --- a/flake.nix +++ /dev/null @@ -1,38 +0,0 @@ -{ - description = "OneLauncher: Next-generation open source Minecraft launcher"; - - inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; - - inputs.crane.url = "github:ipetkov/crane"; - inputs.crane.inputs.nixpkgs.follows = "nixpkgs"; - - inputs.fenix.url = "github:nix-community/fenix"; - inputs.fenix.inputs.nixpkgs.follows = "nixpkgs"; - - inputs.utils.url = "github:numtide/flake-utils"; - inputs.utils.inputs.nixpkgs.follows = "nixpkgs"; - - inputs.rust.url = "github:numtide/rust-overlay"; - inputs.rust.inputs.nixpkgs.follows = "nixpkgs"; - - inputs.advisory.url = "github:rustsec/advisory-db"; - inputs.advisory.flake = false; - - outputs = { self, nixpkgs, crane, fenix, utils, rust, advisory, ... }: - utils.lib.eachDefaultSystem (system: - let - pkgs = nixpkgs.legacyPackages.${system}; - inherit (pkgs) lib; - - craneLib = crane.lib.${system}; - cargoSrc = craneLib.cleanCargoSource (craneLib.path ./.); - arguments = { - inherit cargoSrc; - strictDeps = true; - - }; - in { - - } - ); -} diff --git a/package.json b/package.json index 30134038..ab76efa8 100644 --- a/package.json +++ b/package.json @@ -12,14 +12,22 @@ "bugs": { "url": "https://github.com/polyfrost/onelauncher/issues" }, + "engines": { + "pnpm": "9.5.0", + "npm": "pnpm", + "yarn": "pnpm", + "node": ">=18" + }, "scripts": { - "gui": "pnpm --filter @onelauncher/gui", - "client": "pnpm --filter @onelauncher/client", - "dev": "pnpm gui tauri dev", - "build": "pnpm gui tauri build", + "gui": "pnpm --filter @onelauncher/gui --", + "client": "pnpm --filter @onelauncher/client --", + "tauri": "pnpm gui tauri", "lint": "pnpm eslint . --cache", "format": "pnpm lint --fix", - "release:node": "pnpm bumpp -r" + "prep": "pnpm gen:prisma", + "release:node": "pnpm bumpp -r", + "gen:prisma": "cd crates/core && cargo prisma generate", + "gen:migrations": "cd crates/core && cargo prisma migrate dev" }, "devDependencies": { "@flowr/eslint-config": "^3.9.1", From e78f94a18260fb6daafcbad76a1ef69a4329a258 Mon Sep 17 00:00:00 2001 From: Pauline Date: Wed, 24 Jul 2024 08:53:18 +0200 Subject: [PATCH 03/11] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor:=20adios=20?= =?UTF-8?q?proc=20macros=20i=20hate=20you?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.toml | 3 +- crates/core/Cargo.toml | 1 - crates/core/src/api/cluster/create.rs | 2 -- crates/core/src/api/cluster/mod.rs | 2 -- crates/core/src/api/java.rs | 1 - crates/core/src/api/package/from.rs | 3 -- .../core/src/api/package/import/atlauncher.rs | 1 - crates/core/src/api/package/import/mod.rs | 4 --- .../core/src/api/package/import/multibased.rs | 1 - crates/core/src/api/package/mrpack.rs | 3 -- crates/core/src/api/proxy/send.rs | 3 -- crates/core/src/api/proxy/utils.rs | 1 - crates/core/src/game/metadata.rs | 5 --- crates/core/src/game/mod.rs | 2 -- crates/core/src/store/clusters.rs | 5 --- crates/core/src/store/metadata.rs | 1 - crates/core/src/store/mod.rs | 2 -- crates/core/src/store/package.rs | 2 -- crates/core/src/store/processor.rs | 3 -- crates/core/src/utils/http.rs | 4 --- crates/core/src/utils/java.rs | 2 -- crates/debugger/Cargo.toml | 18 ---------- crates/debugger/src/lib.rs | 36 ------------------- 23 files changed, 2 insertions(+), 103 deletions(-) delete mode 100644 crates/debugger/Cargo.toml delete mode 100644 crates/debugger/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index afd76276..f97e4400 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -158,7 +158,8 @@ features = [ "migrations", "specta", "sqlite", - "sqlite-create-many" + "sqlite-create-many", + "rspc" ] default-features = false diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index 418989db..f6d29549 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -22,7 +22,6 @@ tauri = [ cli = [ "dep:indicatif" ] [dependencies] -onelauncher_debug = { path = "../debugger" } onelauncher_prisma = { path = "../prisma" } # GUI-only deps diff --git a/crates/core/src/api/cluster/create.rs b/crates/core/src/api/cluster/create.rs index d7e63895..1292b4ca 100644 --- a/crates/core/src/api/cluster/create.rs +++ b/crates/core/src/api/cluster/create.rs @@ -13,7 +13,6 @@ use std::path::PathBuf; /// Creates a [`Cluster`] and adds it to the memory [`State`]. /// Returns a relative filepath ([`ClusterPath`]) which can be used to access the cluster. #[tracing::instrument] -#[onelauncher_debug::debugger] #[allow(clippy::too_many_arguments)] pub async fn create_cluster( mut name: String, @@ -207,7 +206,6 @@ pub async fn create_cluster_from_duplicate(from: ClusterPath) -> crate::Result crate::Result /// run a Minecraft [`Cluster`] using [`MinecraftCredentials`] for authentication. /// returns an [`Arc`] pointer to [`RwLock`] to [`ProcessorChild`]. #[tracing::instrument(skip(creds))] -#[onelauncher_debug::debugger] pub async fn run_credentials( path: &ClusterPath, creds: &MinecraftCredentials, @@ -359,7 +358,6 @@ pub async fn get_optimal_java_version(path: &ClusterPath) -> crate::Result crate::Result<()> { let state = State::get().await?; let cluster = get(path, None) diff --git a/crates/core/src/api/java.rs b/crates/core/src/api/java.rs index 6b0cf46a..e666d498 100644 --- a/crates/core/src/api/java.rs +++ b/crates/core/src/api/java.rs @@ -27,7 +27,6 @@ pub async fn filter_java_version(java_version: Option) -> crate::Result crate::Result { let state = State::get().await?; diff --git a/crates/core/src/api/package/from.rs b/crates/core/src/api/package/from.rs index 1de7c8a5..9b6e3a71 100644 --- a/crates/core/src/api/package/from.rs +++ b/crates/core/src/api/package/from.rs @@ -185,7 +185,6 @@ pub fn get_cluster_from_pack(location: CreatePackLocation) -> CreatePackCluster } #[tracing::instrument] -#[onelauncher_debug::debugger] pub async fn generate_pack_from_version_id( package_id: String, version_id: String, @@ -295,7 +294,6 @@ pub async fn generate_pack_from_version_id( } #[tracing::instrument] -#[onelauncher_debug::debugger] pub async fn generate_pack_from_file( path: PathBuf, cluster_path: ClusterPath, @@ -316,7 +314,6 @@ pub async fn generate_pack_from_file( /// Sets generated cluster attributes to the pack attributes (using `cluster::edit`). /// This includes the pack name, icon, game version, loader version, and loader. -#[onelauncher_debug::debugger] pub async fn set_cluster_information( cluster_path: ClusterPath, description: &CreatePackDescription, diff --git a/crates/core/src/api/package/import/atlauncher.rs b/crates/core/src/api/package/import/atlauncher.rs index afa0ea3c..b3d48188 100644 --- a/crates/core/src/api/package/import/atlauncher.rs +++ b/crates/core/src/api/package/import/atlauncher.rs @@ -113,7 +113,6 @@ pub async fn is_valid_atlauncher(instance_folder: PathBuf) -> bool { } #[tracing::instrument] -#[onelauncher_debug::debugger] pub async fn import_atlauncher( // The path to the base ATLauncher folder. atlauncher_base_path: PathBuf, diff --git a/crates/core/src/api/package/import/mod.rs b/crates/core/src/api/package/import/mod.rs index d6571ed8..814794db 100644 --- a/crates/core/src/api/package/import/mod.rs +++ b/crates/core/src/api/package/import/mod.rs @@ -107,7 +107,6 @@ pub async fn import_instances(import: ImportType, path: PathBuf) -> crate::Resul } #[tracing::instrument] -#[onelauncher_debug::debugger] pub async fn import_instance( cluster_path: ClusterPath, import: ImportType, @@ -185,7 +184,6 @@ pub fn default_launcher_path(r#type: ImportType) -> Option { /// Checks if a [`PathBuf`] is a valid instance for a given [`ImportType`] #[tracing::instrument] -#[onelauncher_debug::debugger] pub async fn is_valid_instance(instance_path: PathBuf, r#type: ImportType) -> bool { match r#type { ImportType::MultiMC | ImportType::PrismLauncher => { @@ -204,7 +202,6 @@ pub async fn is_valid_instance(instance_path: PathBuf, r#type: ImportType) -> bo } #[tracing::instrument] -#[onelauncher_debug::debugger] pub async fn cache_icon(icon_path: PathBuf) -> crate::Result> { let state = crate::State::get().await?; let bytes = tokio::fs::read(&icon_path).await; @@ -254,7 +251,6 @@ pub async fn copy_minecraft( } /// recursively get a [`Vec`] of all subfiles. -#[onelauncher_debug::debugger] #[async_recursion::async_recursion] #[tracing::instrument] pub async fn sub(path: &Path) -> crate::Result> { diff --git a/crates/core/src/api/package/import/multibased.rs b/crates/core/src/api/package/import/multibased.rs index 8fc99efa..379ec917 100644 --- a/crates/core/src/api/package/import/multibased.rs +++ b/crates/core/src/api/package/import/multibased.rs @@ -169,7 +169,6 @@ async fn load_instance_cfg(file_path: &Path) -> crate::Result { } #[tracing::instrument] -#[onelauncher_debug::debugger] pub async fn import_mmc( mmc_base_path: PathBuf, instance_folder: String, diff --git a/crates/core/src/api/package/mrpack.rs b/crates/core/src/api/package/mrpack.rs index bdf24df2..cc285e92 100644 --- a/crates/core/src/api/package/mrpack.rs +++ b/crates/core/src/api/package/mrpack.rs @@ -25,7 +25,6 @@ use super::from::{ /// Wrapper around [`install_pack_files`] that generates a pack creation description, and /// attempts to install the pack files. If it fails, it will remove the cluster (fail safely) /// Install a modpack from a mrpack file (a modrinth .zip format) -#[onelauncher_debug::debugger] pub async fn install_zipped_mrpack( location: CreatePackLocation, cluster_path: ClusterPath, @@ -66,7 +65,6 @@ pub async fn install_zipped_mrpack( } /// Install all pack files from a description. Does not remove the cluster if it fails -#[onelauncher_debug::debugger] pub async fn install_zipped_mrpack_files( create_pack: CreatePack, ignore_lock: bool, @@ -241,7 +239,6 @@ pub async fn install_zipped_mrpack_files( } #[tracing::instrument(skip(mrpack_file))] -#[onelauncher_debug::debugger] pub async fn remove_all_related_files( cluster_path: ClusterPath, mrpack_file: bytes::Bytes, diff --git a/crates/core/src/api/proxy/send.rs b/crates/core/src/api/proxy/send.rs index 4449fcd0..0e961c12 100644 --- a/crates/core/src/api/proxy/send.rs +++ b/crates/core/src/api/proxy/send.rs @@ -11,7 +11,6 @@ use crate::api::proxy::{ClusterPayload, IngressPayload, MessagePayload, ProcessP #[cfg(feature = "tauri")] use tauri::Manager; -#[onelauncher_debug::debugger] pub async fn init_ingress( ingress_type: IngressType, total: f64, @@ -25,7 +24,6 @@ pub async fn init_ingress( #[cfg(feature = "cli")] const CLI_TOTAL_INGRESS: u64 = 1000; -#[onelauncher_debug::debugger] pub async fn init_ingress_internal( ingress_type: IngressType, total: f64, @@ -100,7 +98,6 @@ pub async fn edit_ingress( #[allow(unused_variables)] #[tracing::instrument(level = "debug")] -#[onelauncher_debug::debugger] pub async fn send_ingress( key: &IngressId, increment: f64, diff --git a/crates/core/src/api/proxy/utils.rs b/crates/core/src/api/proxy/utils.rs index 7463b8e4..f7379356 100644 --- a/crates/core/src/api/proxy/utils.rs +++ b/crates/core/src/api/proxy/utils.rs @@ -45,7 +45,6 @@ macro_rules! ingress_join { /// TryStreamExt concurrently for Ingress feeds #[tracing::instrument(skip(stream, f))] -#[onelauncher_debug::debugger] pub async fn ingress_try_for_each( stream: I, limit: Option, diff --git a/crates/core/src/game/metadata.rs b/crates/core/src/game/metadata.rs index 492aa578..c4f1b960 100644 --- a/crates/core/src/game/metadata.rs +++ b/crates/core/src/game/metadata.rs @@ -50,7 +50,6 @@ pub async fn download_minecraft( } #[tracing::instrument(skip_all, fields(version = version.id.as_str(), loader = ?loader))] -#[onelauncher_debug::debugger] pub async fn download_version_info( st: &State, version: &GameVersion, @@ -113,7 +112,6 @@ pub async fn fetch_partial_version( } #[tracing::instrument(skip_all)] -#[onelauncher_debug::debugger] pub async fn download_assets_index( st: &State, version: &GameVersionInfo, @@ -162,7 +160,6 @@ pub async fn fetch_assets_index( } #[tracing::instrument(skip(st, index))] -#[onelauncher_debug::debugger] pub async fn download_assets( st: &State, legacy: bool, @@ -224,7 +221,6 @@ pub async fn download_assets( } #[tracing::instrument(skip(st, libraries))] -#[onelauncher_debug::debugger] #[allow(clippy::too_many_arguments)] pub async fn download_libraries( st: &State, @@ -319,7 +315,6 @@ pub async fn download_libraries( } #[tracing::instrument(skip_all)] -#[onelauncher_debug::debugger] pub async fn download_client( st: &State, version: &GameVersionInfo, diff --git a/crates/core/src/game/mod.rs b/crates/core/src/game/mod.rs index 18dbdfd2..895022be 100644 --- a/crates/core/src/game/mod.rs +++ b/crates/core/src/game/mod.rs @@ -36,7 +36,6 @@ macro_rules! data_entry { } #[tracing::instrument(skip(cluster))] -#[onelauncher_debug::debugger] pub async fn install_minecraft( cluster: &Cluster, old_ingress: Option, @@ -243,7 +242,6 @@ pub async fn install_minecraft( } #[tracing::instrument(skip_all)] -#[onelauncher_debug::debugger] #[allow(clippy::too_many_arguments)] pub async fn launch_minecraft( cluster: &Cluster, diff --git a/crates/core/src/store/clusters.rs b/crates/core/src/store/clusters.rs index 6488e961..61be7b2e 100644 --- a/crates/core/src/store/clusters.rs +++ b/crates/core/src/store/clusters.rs @@ -512,7 +512,6 @@ impl Cluster { /// watch the filesystem for changes with [`notify`]. #[tracing::instrument(skip(watcher))] - #[onelauncher_debug::debugger] pub async fn watch( cluster_path: &Path, watcher: &mut Debouncer, @@ -543,7 +542,6 @@ impl Cluster { impl Clusters { /// Initialize the cluster manager and HashMap. #[tracing::instrument(skip(watcher))] - #[onelauncher_debug::debugger] pub async fn initialize( dirs: &Directories, watcher: &mut Debouncer, @@ -580,7 +578,6 @@ impl Clusters { /// update registered packages #[tracing::instrument] - #[onelauncher_debug::debugger] pub async fn update_packages() { let res = async { let state = State::get().await?; @@ -634,7 +631,6 @@ impl Clusters { /// update all available package versions #[tracing::instrument] - #[onelauncher_debug::debugger] pub async fn update_versions() { let res = async { let state = State::get().await?; @@ -670,7 +666,6 @@ impl Clusters { /// insert a cluster into the HashMap #[tracing::instrument(skip(self, cluster))] - #[onelauncher_debug::debugger] pub async fn insert(&mut self, cluster: Cluster, dont_watch: bool) -> crate::Result<&Self> { send_cluster( cluster.uuid, diff --git a/crates/core/src/store/metadata.rs b/crates/core/src/store/metadata.rs index af8ed387..dcaf2fa7 100644 --- a/crates/core/src/store/metadata.rs +++ b/crates/core/src/store/metadata.rs @@ -144,7 +144,6 @@ impl Metadata { /// Initialize the core Metadata manager. #[tracing::instrument(skip(io_semaphore, fetch_semaphore))] - #[onelauncher_debug::debugger] pub async fn initialize( dirs: &Directories, online: bool, diff --git a/crates/core/src/store/mod.rs b/crates/core/src/store/mod.rs index 38f978bb..40797868 100644 --- a/crates/core/src/store/mod.rs +++ b/crates/core/src/store/mod.rs @@ -112,7 +112,6 @@ impl State { /// Initializes the core OneLauncher state fully. #[tracing::instrument] - #[onelauncher_debug::debugger] async fn initialize() -> crate::Result> { let ingress = init_ingress_internal(crate::IngressType::Initialize, 100.0, "initializing state") @@ -205,7 +204,6 @@ impl State { /// Synchronizes data that can change outside of our control. #[tracing::instrument] - #[onelauncher_debug::debugger] pub async fn sync() -> crate::Result<()> { let state = Self::get().await?; let sync_settings = async { diff --git a/crates/core/src/store/package.rs b/crates/core/src/store/package.rs index 65abfc56..716be9de 100644 --- a/crates/core/src/store/package.rs +++ b/crates/core/src/store/package.rs @@ -20,7 +20,6 @@ use super::{Cluster, PackagePath}; /// Creates [`Package`] data for a given [`Cluster`] from on-device files and APIs. /// Paths must be the full paths and not relative paths. #[tracing::instrument(skip(paths, _cluster, _io_semaphore, _fetch_semaphore))] -#[onelauncher_debug::debugger] pub async fn generate_context( _cluster: Cluster, paths: Vec, @@ -299,7 +298,6 @@ pub enum PackageFile { } #[tracing::instrument(skip(io_semaphore))] -#[onelauncher_debug::debugger] async fn read_icon( icon_path: Option, cache_path: &Path, diff --git a/crates/core/src/store/processor.rs b/crates/core/src/store/processor.rs index 05a11342..423d80c7 100644 --- a/crates/core/src/store/processor.rs +++ b/crates/core/src/store/processor.rs @@ -412,7 +412,6 @@ impl Processor { /// insert a process with a command and [`ClusterPath`]. #[tracing::instrument(skip(self, uuid, command, post, censors))] #[tracing::instrument(level = "trace", skip(self))] - #[onelauncher_debug::debugger] pub async fn insert_process( &mut self, uuid: Uuid, @@ -456,7 +455,6 @@ impl Processor { /// Insert a cached process with a [`ProcessorCache`]. #[tracing::instrument(skip(self, cache))] #[tracing::instrument(level = "trace", skip(self))] - #[onelauncher_debug::debugger] pub async fn insert_restored( &mut self, cache: ProcessorCache, @@ -544,7 +542,6 @@ impl Processor { /// Get a process manager and runner awaiting for the exit status. #[tracing::instrument(skip(current_child))] - #[onelauncher_debug::debugger] async fn manager( uuid: Uuid, post: Option, diff --git a/crates/core/src/utils/http.rs b/crates/core/src/utils/http.rs index 5dd6bd55..ca7ea9cf 100644 --- a/crates/core/src/utils/http.rs +++ b/crates/core/src/utils/http.rs @@ -76,7 +76,6 @@ where /// Advanced HTTP fetch interface with json, sha1 validation, and ingress support. #[tracing::instrument(skip(json_body, semaphore))] -#[onelauncher_debug::debugger] pub async fn fetch_advanced( method: Method, url: &str, @@ -167,7 +166,6 @@ pub async fn fetch_advanced( /// A utility to fetch from multiple mirrored sources. #[tracing::instrument(skip(semaphore))] -#[onelauncher_debug::debugger] pub async fn fetch_from_mirrors( mirrors: &[&str], sha1: Option<&str>, @@ -189,7 +187,6 @@ pub async fn fetch_from_mirrors( /// Checks if we are playing offline by contacting a reliable server. #[tracing::instrument] -#[onelauncher_debug::debugger] pub async fn check_internet_connection(timeout: u64) -> bool { REQWEST_CLIENT .get("https://api.polyfrost.org/") @@ -201,7 +198,6 @@ pub async fn check_internet_connection(timeout: u64) -> bool { /// Post JSON to a specified URL (helpful for Microsoft auth) #[tracing::instrument(skip(json_body, semaphore))] -#[onelauncher_debug::debugger] pub async fn post_json( url: &str, json_body: serde_json::Value, diff --git a/crates/core/src/utils/java.rs b/crates/core/src/utils/java.rs index a299faad..22c6cb5f 100644 --- a/crates/core/src/utils/java.rs +++ b/crates/core/src/utils/java.rs @@ -183,7 +183,6 @@ pub async fn locate_java() -> Result, JavaError> { /// Locate JRE's auto-installed by the launcher instance. #[tracing::instrument] -#[onelauncher_debug::debugger] async fn locate_installed_java() -> Result, JavaError> { Box::pin(async move { let state = State::get().await.map_err(|_| JavaError::MutexError)?; @@ -245,7 +244,6 @@ pub async fn check_java(paths: HashSet) -> HashSet { /// Verifies that a java instance [`Path`] is valid. /// java_check from https://github.com/modrinth/theseus/blob/master/theseus/library/JavaInfo.class under MIT #[tracing::instrument] -#[onelauncher_debug::debugger] pub async fn check_java_instance(path: &Path) -> Option { let Ok(path) = io::canonicalize(path) else { return None; diff --git a/crates/debugger/Cargo.toml b/crates/debugger/Cargo.toml deleted file mode 100644 index 18bbbfe3..00000000 --- a/crates/debugger/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -[package] -name = "onelauncher_debug" -version = "0.0.0" -description = "Debugger macros for OneLauncher" -license = { workspace = true } -edition = { workspace = true } -repository = { workspace = true } -documentation = { workspace = true } -readme = { workspace = true } -homepage = { workspace = true } -authors = { workspace = true } - -[lib] -proc-macro = true - -[dependencies] -syn = { workspace = true } -quote = { workspace = true } diff --git a/crates/debugger/src/lib.rs b/crates/debugger/src/lib.rs deleted file mode 100644 index 84c8666d..00000000 --- a/crates/debugger/src/lib.rs +++ /dev/null @@ -1,36 +0,0 @@ -extern crate proc_macro; - -use proc_macro::TokenStream; -use quote::quote; -use syn::{parse_macro_input, ItemFn}; - -/// Macro that isolates s that automatically are isolated in Tauri Debug environments -/// This is useful for debugging functions that manage memory. -#[proc_macro_attribute] -pub fn debugger(_attr: TokenStream, item: TokenStream) -> TokenStream { - let input = parse_macro_input!(item as ItemFn); - - let attrs = &input.attrs; - let vis = &input.vis; - let sig = &input.sig; - let body = &input.block; - - #[cfg(debug_assertions)] - let result = quote! { - #(#attrs)* - #vis #sig { - Box::pin(async move { - #body - }).await - } - }; - #[cfg(not(debug_assertions))] - let result = quote! { - #(#attrs)* - #vis #sig { - #body - } - }; - - TokenStream::from(result) -} From e17b4eea916d4d9262df533db05dd49fb991ec49 Mon Sep 17 00:00:00 2001 From: Pauline Date: Thu, 25 Jul 2024 00:05:33 +0200 Subject: [PATCH 04/11] =?UTF-8?q?=F0=9F=94=A8=20chore:=20h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/core/src/store/flags.rs | 1 - crates/core/src/store/mod.rs | 2 -- package.json | 9 ++++++--- 3 files changed, 6 insertions(+), 6 deletions(-) delete mode 100644 crates/core/src/store/flags.rs diff --git a/crates/core/src/store/flags.rs b/crates/core/src/store/flags.rs deleted file mode 100644 index c3b2029b..00000000 --- a/crates/core/src/store/flags.rs +++ /dev/null @@ -1 +0,0 @@ -//! Global Package Metadata management. diff --git a/crates/core/src/store/mod.rs b/crates/core/src/store/mod.rs index 40797868..538b3e0b 100644 --- a/crates/core/src/store/mod.rs +++ b/crates/core/src/store/mod.rs @@ -46,8 +46,6 @@ pub use self::package::*; mod oneconfig; pub use self::oneconfig::*; -mod flags; - /// The static [`OnceCell>`] for storing the global runtime launcher state. static LAUNCHER_STATE: OnceCell> = OnceCell::const_new(); diff --git a/package.json b/package.json index ab76efa8..71a954fc 100644 --- a/package.json +++ b/package.json @@ -23,11 +23,14 @@ "client": "pnpm --filter @onelauncher/client --", "tauri": "pnpm gui tauri", "lint": "pnpm eslint . --cache", - "format": "pnpm lint --fix", + "lint:fix": "pnpm lint --fix", + "format": "pnpm lint:fix && pnpm core:prisma format", "prep": "pnpm gen:prisma", "release:node": "pnpm bumpp -r", - "gen:prisma": "cd crates/core && cargo prisma generate", - "gen:migrations": "cd crates/core && cargo prisma migrate dev" + "core": "cd crates/core && cargo", + "gen:prisma": "pnpm core prisma generate", + "gen:migrations": "pnpm core prisma migrate dev", + "gen:code": "pnpm core test gen" }, "devDependencies": { "@flowr/eslint-config": "^3.9.1", From a409f8248608f04027f56ea0b177d3fd06a77862 Mon Sep 17 00:00:00 2001 From: Pauline Date: Thu, 25 Jul 2024 03:52:47 +0200 Subject: [PATCH 05/11] =?UTF-8?q?=F0=9F=94=A8=20chore:=20h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.toml | 1 + apps/desktop/src-tauri/Info.plist | 4 ++-- apps/desktop/src-tauri/tauri.conf.json | 4 ++-- crates/core/Cargo.toml | 1 + crates/core/src/constants.rs | 2 -- crates/core/src/store/dirs.rs | 2 +- package.json | 4 ++-- packages/distribution/brew/onelauncher.rb | 10 +++++----- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f97e4400..3c56ca15 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -122,6 +122,7 @@ open = { version = "5.1" } discord-rich-presence = { version = "0.2" } winreg = { version = "0.52" } paste = { version = "1.0" } +dashmap = { version = "6.0", features = [ "serde" ] } sha1_smol = { version = "1.0.0", features = [ "std" ] } sha2 = { version = "0.10" } bytes = { version = "1.6" } diff --git a/apps/desktop/src-tauri/Info.plist b/apps/desktop/src-tauri/Info.plist index 6534396c..8173ce39 100644 --- a/apps/desktop/src-tauri/Info.plist +++ b/apps/desktop/src-tauri/Info.plist @@ -7,10 +7,10 @@ CFBundleURLName - org.polyfrost.launcher + OneLauncher CFBundleURLSchemes - onelauncher + OneLauncher diff --git a/apps/desktop/src-tauri/tauri.conf.json b/apps/desktop/src-tauri/tauri.conf.json index 2eed77bd..cc11f880 100644 --- a/apps/desktop/src-tauri/tauri.conf.json +++ b/apps/desktop/src-tauri/tauri.conf.json @@ -1,8 +1,8 @@ { "$schema": "https://raw.githubusercontent.com/tauri-apps/tauri/dev/core/tauri-config-schema/schema.json", - "productName": "onelauncher", + "productName": "OneLauncher", "version": "../package.json", - "identifier": "org.polyfrost.launcher", + "identifier": "OneLauncher", "app": { "withGlobalTauri": true, "macOSPrivateApi": true, diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index f6d29549..0353fb84 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -53,6 +53,7 @@ serde = { workspace = true } serde_json = { workspace = true } serde_ini = { workspace = true } flate2 = { workspace = true } +dashmap = { workspace = true } paste = { workspace = true } futures = { workspace = true } tar = { workspace = true } diff --git a/crates/core/src/constants.rs b/crates/core/src/constants.rs index 2f721576..edb36773 100644 --- a/crates/core/src/constants.rs +++ b/crates/core/src/constants.rs @@ -8,8 +8,6 @@ pub const NAME: &str = "OneLauncher"; /// The version of the launcher pub const VERSION: &str = "0.1.0"; // todo: env -/// The ID of the launcher. -pub const ID: &str = "org.polyfrost.launcher"; // =========== Authentication =========== /// The Discord RPC client ID. diff --git a/crates/core/src/store/dirs.rs b/crates/core/src/store/dirs.rs index 38aa9b36..4104791a 100644 --- a/crates/core/src/store/dirs.rs +++ b/crates/core/src/store/dirs.rs @@ -30,7 +30,7 @@ impl Directories { /// Bootstrap the initial settings directory on first startup. pub fn init_settings_dir() -> Option { Self::env_path("ONELAUNCHER_CONFIG") - .or_else(|| Some(dirs::config_dir()?.join(constants::ID))) + .or_else(|| Some(dirs::data_dir()?.join(constants::NAME))) } /// Bootstrap the initial settings directory on first startup. diff --git a/package.json b/package.json index 71a954fc..a70bab05 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@onelauncher/root", "type": "module", "version": "1.0.0", - "packageManager": "pnpm@9.5.0", + "packageManager": "pnpm@9.6.0", "description": "Next-generation open source Minecraft launcher and tools for interacting with Polyfrost", "license": "GPL-3.0-only", "repository": { @@ -13,7 +13,7 @@ "url": "https://github.com/polyfrost/onelauncher/issues" }, "engines": { - "pnpm": "9.5.0", + "pnpm": "9.6.0", "npm": "pnpm", "yarn": "pnpm", "node": ">=18" diff --git a/packages/distribution/brew/onelauncher.rb b/packages/distribution/brew/onelauncher.rb index e9cd12bd..f0d995a2 100644 --- a/packages/distribution/brew/onelauncher.rb +++ b/packages/distribution/brew/onelauncher.rb @@ -17,12 +17,12 @@ app "OneLauncher.app" - uninstall quit: "org.polyfrost.launcher" + uninstall quit: "OneLauncher" zap trash: [ - "~/Library/Application Support/org.polyfrost.launcher", - "~/Library/Caches/org.polyfrost.launcher", - "~/Library/Saved Application State/org.polyfrost.launcher.savedState", - "~/Library/WebKit/org.polyfrost.launcher", + "~/Library/Application Support/OneLauncher", + "~/Library/Caches/OneLauncher", + "~/Library/Saved Application State/OneLauncher.savedState", + "~/Library/WebKit/OneLauncher", ] end From 76e862a08d2ff417cd2016250d96dff3ad90b7e3 Mon Sep 17 00:00:00 2001 From: Pauline Date: Thu, 25 Jul 2024 04:48:14 +0200 Subject: [PATCH 06/11] =?UTF-8?q?=E2=9C=A8=20feature:=20finish=20prisma=20?= =?UTF-8?q?schema?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20240724045148_init/migration.sql | 15 --- .../20240725024623_init/migration.sql | 115 ++++++++++++++++ crates/core/prisma/schema.prisma | 125 +++++++++++++++++- 3 files changed, 233 insertions(+), 22 deletions(-) delete mode 100644 crates/core/prisma/migrations/20240724045148_init/migration.sql create mode 100644 crates/core/prisma/migrations/20240725024623_init/migration.sql diff --git a/crates/core/prisma/migrations/20240724045148_init/migration.sql b/crates/core/prisma/migrations/20240724045148_init/migration.sql deleted file mode 100644 index aeedbbd9..00000000 --- a/crates/core/prisma/migrations/20240724045148_init/migration.sql +++ /dev/null @@ -1,15 +0,0 @@ --- CreateTable -CREATE TABLE "settings" ( - "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT DEFAULT 0, - "theme" TEXT NOT NULL DEFAULT 'dark', - "hide_close_prompt" BOOLEAN NOT NULL DEFAULT true, - "disable_animations" BOOLEAN NOT NULL DEFAULT false, - "force_fullscreen" BOOLEAN NOT NULL DEFAULT false, - "resolution_x" INTEGER NOT NULL DEFAULT 854, - "resolution_y" INTEGER NOT NULL DEFAULT 480, - "memory_max" INTEGER NOT NULL DEFAULT 2048, - "memory_min" INTEGER NOT NULL DEFAULT 1024, - "hook_pre" TEXT, - "hook_wrapper" TEXT, - "hook_post" TEXT -); diff --git a/crates/core/prisma/migrations/20240725024623_init/migration.sql b/crates/core/prisma/migrations/20240725024623_init/migration.sql new file mode 100644 index 00000000..a43ab655 --- /dev/null +++ b/crates/core/prisma/migrations/20240725024623_init/migration.sql @@ -0,0 +1,115 @@ +-- CreateTable +CREATE TABLE "settings" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT DEFAULT 0, + "theme" TEXT NOT NULL DEFAULT 'dark', + "hide_close_prompt" BOOLEAN NOT NULL DEFAULT true, + "disable_animations" BOOLEAN NOT NULL DEFAULT false, + "disable_analytics" BOOLEAN NOT NULL DEFAULT false, + "debug_mode" BOOLEAN NOT NULL DEFAULT false, + "hide_on_launch" BOOLEAN NOT NULL DEFAULT false, + "force_fullscreen" BOOLEAN NOT NULL DEFAULT false, + "disable_discord" BOOLEAN NOT NULL DEFAULT false, + "custom_java_args" TEXT NOT NULL, + "custom_env_args" TEXT NOT NULL, + "max_async_io_operations" INTEGER NOT NULL DEFAULT 10, + "max_async_fetches" INTEGER NOT NULL DEFAULT 10, + "resolution_x" INTEGER NOT NULL DEFAULT 854, + "resolution_y" INTEGER NOT NULL DEFAULT 480, + "memory_max" INTEGER NOT NULL DEFAULT 2048, + "memory_min" INTEGER NOT NULL DEFAULT 1024, + "hook_pre" TEXT, + "hook_wrapper" TEXT, + "hook_post" TEXT +); + +-- CreateTable +CREATE TABLE "java_version" ( + "major_version" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "full_version" TEXT NOT NULL, + "architecture" TEXT NOT NULL, + "path" TEXT NOT NULL +); + +-- CreateTable +CREATE TABLE "minecraft_user" ( + "uuid" TEXT NOT NULL PRIMARY KEY, + "active" BOOLEAN NOT NULL DEFAULT false, + "username" TEXT NOT NULL, + "access_token" TEXT NOT NULL, + "refresh_token" TEXT NOT NULL, + "expires" INTEGER NOT NULL +); + +-- CreateTable +CREATE TABLE "minecraft_device_token" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT DEFAULT 0, + "uuid" TEXT NOT NULL, + "private_key" TEXT NOT NULL, + "x" TEXT NOT NULL, + "y" TEXT NOT NULL, + "issue_instant" INTEGER NOT NULL, + "not_after" INTEGER NOT NULL, + "token" TEXT NOT NULL, + "display_claims" TEXT NOT NULL +); + +-- CreateTable +CREATE TABLE "cache" ( + "id" TEXT NOT NULL PRIMARY KEY, + "data_type" TEXT NOT NULL, + "alias" TEXT, + "data" TEXT, + "expires" DATETIME NOT NULL, + "created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +-- CreateTable +CREATE TABLE "cluster" ( + "path" TEXT NOT NULL PRIMARY KEY, + "stage" TEXT NOT NULL, + "name" TEXT NOT NULL, + "icon_path" TEXT, + "mc_version" TEXT NOT NULL, + "loader" TEXT NOT NULL DEFAULT 'vanilla', + "loader_version" TEXT DEFAULT 'stable', + "groups" TEXT NOT NULL, + "created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "modified_at" DATETIME NOT NULL, + "played_at" DATETIME, + "overall_played" INTEGER NOT NULL DEFAULT 0, + "recently_played" INTEGER NOT NULL DEFAULT 0, + "override_java_path" TEXT, + "override_custom_java_args" TEXT NOT NULL, + "override_custom_env_args" TEXT NOT NULL, + "override_memory_max" INTEGER, + "override_memory_min" INTEGER, + "override_force_fullscreen" INTEGER, + "override_resolution_x" INTEGER, + "override_resolution_y" INTEGER, + "override_hook_pre" TEXT, + "override_hook_wrapper" TEXT, + "override_hook_post" TEXT +); + +-- CreateTable +CREATE TABLE "process" ( + "pid" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "start_time" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "name" TEXT NOT NULL, + "executable" TEXT NOT NULL, + "cluster_path" TEXT NOT NULL, + "post_exit" TEXT, + CONSTRAINT "process_cluster_path_fkey" FOREIGN KEY ("cluster_path") REFERENCES "cluster" ("path") ON DELETE RESTRICT ON UPDATE CASCADE +); + +-- CreateIndex +CREATE UNIQUE INDEX "minecraft_user_active_key" ON "minecraft_user"("active"); + +-- CreateIndex +CREATE UNIQUE INDEX "cache_data_type_alias_key" ON "cache"("data_type", "alias"); + +-- CreateIndex +CREATE INDEX "process_cluster_path_idx" ON "process"("cluster_path"); + +-- CreateIndex +CREATE UNIQUE INDEX "process_pid_key" ON "process"("pid"); diff --git a/crates/core/prisma/schema.prisma b/crates/core/prisma/schema.prisma index 0cafb70b..80c49481 100644 --- a/crates/core/prisma/schema.prisma +++ b/crates/core/prisma/schema.prisma @@ -15,14 +15,125 @@ model Settings { theme String @default("dark") hide_close_prompt Boolean @default(true) disable_animations Boolean @default(false) + disable_analytics Boolean @default(false) + debug_mode Boolean @default(false) + hide_on_launch Boolean @default(false) force_fullscreen Boolean @default(false) - resolution_x Int @default(854) - resolution_y Int @default(480) - memory_max Int @default(2048) - memory_min Int @default(1024) - hook_pre String? - hook_wrapper String? - hook_post String? + disable_discord Boolean @default(false) + + custom_java_args String + custom_env_args String + + max_async_io_operations Int @default(10) + max_async_fetches Int @default(10) + + resolution_x Int @default(854) + resolution_y Int @default(480) + + memory_max Int @default(2048) + memory_min Int @default(1024) + + hook_pre String? + hook_wrapper String? + hook_post String? @@map("settings") } + +model JavaVersion { + major_version Int @id + full_version String + architecture String + path String + + @@map("java_version") +} + +model MinecraftUser { + uuid String @id + active Boolean @default(false) + username String + access_token String + refresh_token String + expires Int + + @@unique([active]) + @@map("minecraft_user") +} + +model MinecraftDeviceToken { + id Int @id @default(0) + uuid String + private_key String + x String + y String + issue_instant Int + not_after Int + token String + display_claims String + + @@map("minecraft_device_token") +} + +model Cache { + id String @id + data_type String + alias String? + data String? + expires DateTime + created DateTime @default(now()) + + @@unique([data_type, alias]) + @@map("cache") +} + +model Cluster { + path String @id + stage String + name String + icon_path String? + + mc_version String + loader String @default("vanilla") + loader_version String? @default("stable") + + groups String + + created_at DateTime @default(now()) + modified_at DateTime + played_at DateTime? + + overall_played Int @default(0) + recently_played Int @default(0) + + override_java_path String? + override_custom_java_args String + override_custom_env_args String + override_memory_max Int? + override_memory_min Int? + override_force_fullscreen Int? + override_resolution_x Int? + override_resolution_y Int? + override_hook_pre String? + override_hook_wrapper String? + override_hook_post String? + + processes Process[] + + @@map("cluster") +} + +model Process { + pid Int @id + start_time DateTime @default(now()) + name String + executable String + cluster_path String + post_exit String? + + cluster Cluster @relation(fields: [cluster_path], references: [path]) + + @@unique([pid]) + @@index([cluster_path]) + @@map("process") +} From 23ca7d02d671503009080863563e139f323c2cfd Mon Sep 17 00:00:00 2001 From: Pauline Date: Thu, 25 Jul 2024 06:09:17 +0200 Subject: [PATCH 07/11] =?UTF-8?q?=F0=9F=90=9B=20fix:=20versioning=20change?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ATTRIBUTION.md | 4 ++-- Cargo.toml | 5 +++-- apps/desktop/package.json | 2 +- apps/desktop/src-tauri/Cargo.toml | 2 +- crates/core/Cargo.toml | 2 +- crates/prisma-cli/Cargo.toml | 2 +- crates/prisma/Cargo.toml | 2 +- crates/testing/Cargo.toml | 2 +- packages/client/package.json | 2 +- packages/distribution/package.json | 17 +++++++++++++++++ packages/scripts/package.json | 2 +- pnpm-lock.yaml | 2 ++ 12 files changed, 32 insertions(+), 12 deletions(-) create mode 100644 packages/distribution/package.json diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md index c6ad26d7..4102e35c 100644 --- a/ATTRIBUTION.md +++ b/ATTRIBUTION.md @@ -26,8 +26,8 @@ All rights reserved. Copyright (C) 2022~2024 Polyfrost This includes, but may not be limited to, the following files: -* [`desktop/.icons/*`](./desktop/.icons/) -* [`desktop/src/assets/licensed/*`](./desktop/src/assets/licensed/) +* [`apps/desktop/.icons/*`](./apps/desktop/.icons/) +* [`apps/desktop/src/assets/licensed/*`](./apps/desktop/src/assets/licensed/) ## Additional Libraries diff --git a/Cargo.toml b/Cargo.toml index 3c56ca15..587679d5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,7 @@ authors = [ "Polyfrost", "Polyfrost Contributors" ] +version = "1.0.0" [workspace.dependencies] # tauri uses latest crates.io beta channel (temporarily can use v2 and main branches if necessary) @@ -123,7 +124,7 @@ discord-rich-presence = { version = "0.2" } winreg = { version = "0.52" } paste = { version = "1.0" } dashmap = { version = "6.0", features = [ "serde" ] } -sha1_smol = { version = "1.0.0", features = [ "std" ] } +sha1_smol = { version = "1.0", features = [ "std" ] } sha2 = { version = "0.10" } bytes = { version = "1.6" } lazy_static = { version = "1.4" } @@ -137,7 +138,7 @@ sys-info = { version = "0.9" } whoami = { version = "1.5" } cocoa = { version = "0.25" } objc = { version = "0.2" } -webbrowser = { version = "0.8" } +webbrowser = { version = "1.0" } url = { version = "2.5.2" } [workspace.dependencies.prisma-client-rust] diff --git a/apps/desktop/package.json b/apps/desktop/package.json index be8af1b3..fa69dbd9 100644 --- a/apps/desktop/package.json +++ b/apps/desktop/package.json @@ -7,7 +7,7 @@ "repository": { "type": "git", "url": "git@github.com:polyfrost/onelauncher", - "directory": "desktop" + "directory": "apps/desktop" }, "scripts": { "tauri": "tauri", diff --git a/apps/desktop/src-tauri/Cargo.toml b/apps/desktop/src-tauri/Cargo.toml index ad5d5053..e8e7740b 100644 --- a/apps/desktop/src-tauri/Cargo.toml +++ b/apps/desktop/src-tauri/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "onelauncher_gui" -version = "1.0.0" description = "Next-generation open source Minecraft launcher" +version = { workspace = true } license = { workspace = true } edition = { workspace = true } repository = { workspace = true } diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index 0353fb84..18f52807 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "onelauncher" -version = "0.0.0" description = "The core of OneLauncher" +version = { workspace = true } license = { workspace = true } edition = { workspace = true } repository = { workspace = true } diff --git a/crates/prisma-cli/Cargo.toml b/crates/prisma-cli/Cargo.toml index 3fa52bbe..ab73cec7 100644 --- a/crates/prisma-cli/Cargo.toml +++ b/crates/prisma-cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "prisma-cli" -version = "0.1.0" +version = { workspace = true } license = { workspace = true } edition = { workspace = true } repository = { workspace = true } diff --git a/crates/prisma/Cargo.toml b/crates/prisma/Cargo.toml index e06d15a7..400cca59 100644 --- a/crates/prisma/Cargo.toml +++ b/crates/prisma/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "onelauncher_prisma" -version = "0.1.0" +version = { workspace = true } license = { workspace = true } edition = { workspace = true } repository = { workspace = true } diff --git a/crates/testing/Cargo.toml b/crates/testing/Cargo.toml index 38b194bd..0f87ae7b 100644 --- a/crates/testing/Cargo.toml +++ b/crates/testing/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "onelauncher_test" -version = "0.0.0" description = "test implementation of onelauncher" +version = { workspace = true } license = { workspace = true } edition = { workspace = true } repository = { workspace = true } diff --git a/packages/client/package.json b/packages/client/package.json index a24f4996..238cd6d5 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -8,7 +8,7 @@ "repository": { "type": "git", "url": "git@github.com:polyfrost/onelauncher", - "directory": "client" + "directory": "packages/client" }, "sideEffects": false, "main": "./src/index.ts", diff --git a/packages/distribution/package.json b/packages/distribution/package.json new file mode 100644 index 00000000..4c43f780 --- /dev/null +++ b/packages/distribution/package.json @@ -0,0 +1,17 @@ +{ + "name": "@onelauncher/distribution", + "type": "module", + "version": "1.0.0", + "private": true, + "description": "distribution files for OneLauncher", + "license": "GPL-3.0-only", + "repository": { + "type": "git", + "url": "git@github.com:polyfrost/onelauncher", + "directory": "packages/distribution" + }, + "sideEffects": false, + "scripts": {}, + "dependencies": {}, + "devDependencies": {} +} diff --git a/packages/scripts/package.json b/packages/scripts/package.json index 9ef0a3cf..0a5bb421 100644 --- a/packages/scripts/package.json +++ b/packages/scripts/package.json @@ -8,7 +8,7 @@ "repository": { "type": "git", "url": "git@github.com:polyfrost/onelauncher", - "directory": "client" + "directory": "packages/scripts" }, "sideEffects": false, "main": "./src/index.ts", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 81282ad5..9d706d84 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -172,6 +172,8 @@ importers: specifier: ^3.23.8 version: 3.23.8 + packages/distribution: {} + packages/scripts: dependencies: '@flowr/utils': From 70eecd64d76283c690ad65b7cccaf6f2efc08d86 Mon Sep 17 00:00:00 2001 From: Pauline Date: Thu, 25 Jul 2024 06:22:08 +0200 Subject: [PATCH 08/11] =?UTF-8?q?=F0=9F=90=9B=20fix:=20update=20readme=20l?= =?UTF-8?q?inks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 757c0101..757f8b7e 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,8 @@ Rust-based Minecraft launcher utilizing Tauri, SolidJS, and Tailwind ## Project Structure -* [`desktop`](./desktop/) - Rust-based Minecraft launcher utilizing Tauri, SolidJS, and Tailwind. -* [`core`](./core/) - The core for our Minecraft launcher (platform agnostic), along with Rust-based utilities for other Polyfrost projects and interactions. -* [`backend`](./backend/) - Our `actix-web` based API, accessible at , with documentation on our [docs(docs)](https://contributing.polyfrost.org/api/). -* [`testing`](./testing/) - Testing playground for our Rust core, independant of Tauri. -* [`debugger`](./debugger/) - Procedural macro utilities for our Rust libraries. -* [`distribution`](./distribution/) - Distribution utilties and meta files for the [`desktop`](./desktop/) app. +* [`apps/esktop`](./apps/desktop/) - Rust-based Minecraft launcher utilizing Tauri, SolidJS, and Tailwind. +* [`crates/core`](./crates/core/) - The core for our Minecraft launcher (platform agnostic), along with Rust-based utilities for other Polyfrost projects and interactions. +* [`apps/backend`](./backend/) - Our `actix-web` based API, accessible at , with documentation on our [docs(docs)](https://contributing.polyfrost.org/api/). +* [`testing`](./crates/testing/) - Testing playground for our Rust core, independant of Tauri. +* [`distribution`](./packages/distribution/) - Distribution utilties and meta files for the [`apps/desktop`](./apps/desktop/) app. From 76e037b7d6015b7894b0adc6c2c0997f2183a755 Mon Sep 17 00:00:00 2001 From: Pauline Date: Thu, 25 Jul 2024 07:02:54 +0200 Subject: [PATCH 09/11] =?UTF-8?q?=F0=9F=90=9B=20fix:=20setup.sh=20deps=20b?= =?UTF-8?q?ump?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .editorconfig | 23 +++++++++++++++++++++++ Cargo.toml | 5 +++++ apps/backend/Cargo.toml | 16 ++++++++++++++++ apps/backend/src/lib.rs | 0 apps/backend/src/main.rs | 2 ++ packages/scripts/setup.sh | 8 ++++---- 6 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 .editorconfig create mode 100644 apps/backend/Cargo.toml create mode 100644 apps/backend/src/lib.rs create mode 100644 apps/backend/src/main.rs diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..1405749a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,23 @@ +root = true + +[*] +indent_style = tab +indent_size = 4 +end_of_line = lf +trim_trailing_whitespace = true +insert_final_newline = true + +[*.nix] +indent_style = space +indent_size = 2 + +# Rust +# https://github.com/rust-lang/rust/blob/master/src/doc/style/style/whitespace.md +[*.rs] +indent_size = 4 +insert_final_newline = false +trim_trailing_whitespace = true + +[*.{yaml,yml}] +indent_style = space +indent_size = 2 diff --git a/Cargo.toml b/Cargo.toml index 587679d5..879e3bd9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,7 @@ resolver = "2" members = [ "crates/*", "apps/desktop/src-tauri", + "apps/backend" ] [workspace.package] @@ -141,6 +142,10 @@ objc = { version = "0.2" } webbrowser = { version = "1.0" } url = { version = "2.5.2" } +# backend dependencies +actix-web = { version = "4.8" } +roxmltree = { version = "0.20" } + [workspace.dependencies.prisma-client-rust] git = "https://github.com/brendonovich/prisma-client-rust" rev = "4f9ef9d38ca732162accff72b2eb684d2f120bab" diff --git a/apps/backend/Cargo.toml b/apps/backend/Cargo.toml new file mode 100644 index 00000000..7a269dea --- /dev/null +++ b/apps/backend/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "polyfrost_api" +version = { workspace = true } +license = { workspace = true } +edition = { workspace = true } +repository = { workspace = true } +documentation = { workspace = true } +readme = { workspace = true } +homepage = { workspace = true } +authors = { workspace = true } + +[dependencies] +actix-web = { workspace = true } +serde = { workspace = true } +reqwest = { workspace = true } +roxmltree = { workspace = true } diff --git a/apps/backend/src/lib.rs b/apps/backend/src/lib.rs new file mode 100644 index 00000000..e69de29b diff --git a/apps/backend/src/main.rs b/apps/backend/src/main.rs new file mode 100644 index 00000000..ff8866bc --- /dev/null +++ b/apps/backend/src/main.rs @@ -0,0 +1,2 @@ +async fn main() -> std::io::Result<()> { +} diff --git a/packages/scripts/setup.sh b/packages/scripts/setup.sh index e880ce4e..f9afa934 100755 --- a/packages/scripts/setup.sh +++ b/packages/scripts/setup.sh @@ -84,7 +84,7 @@ case "$(uname)" in # Tauri dependencies set -- build-essential curl wget file libssl-dev libgtk-3-dev librsvg2-dev \ - libwebkit2gtk-4.1-dev libayatana-appindicator3-dev libxdo-dev libvips42 + libwebkit2gtk-4.1-dev libayatana-appindicator3-dev libxdo-dev libdbus-1-dev libvips42 sudo apt-get -y update sudo apt-get -y install "$@" @@ -93,7 +93,7 @@ case "$(uname)" in echo "Installing dependencies with pacman..." # Tauri dependencies - set -- appmenu-gtk-module libappindicator-gtk3 base-devel curl wget file openssl gtk3 librsvg webkit2gtk-4.1 libayatana-appindicator xdotool libvips + set -- appmenu-gtk-module libappindicator-gtk3 base-devel curl wget file openssl gtk3 librsvg webkit2gtk-4.1 libayatana-appindicator dbus xdotool libvips sudo pacman -Sy --needed "$@" elif has dnf; then @@ -107,7 +107,7 @@ case "$(uname)" in fi # Tauri dependencies - set -- openssl webkit2gtk4.1-devel openssl-devel curl wget file libappindicator-gtk3-devel librsvg2-devel libxdo-devel vips + set -- openssl webkit2gtk4.1-devel openssl-devel curl wget file libappindicator-gtk3-devel librsvg2-devel libxdo-devel dbus vips sudo dnf install "$@" elif has apk; then @@ -117,7 +117,7 @@ case "$(uname)" in # Tauri dependencies set -- build-base curl wget file openssl-dev gtk+3.0-dev librsvg-dev \ - webkit2gtk-4.1-dev libayatana-indicator-dev xdotool vips + webkit2gtk-4.1-dev libayatana-indicator-dev xdotool-dev dbus-dev vips sudo apk add "$@" elif has emerge; then From 93c4549c65ef22796e3370d624c9164b14b47565 Mon Sep 17 00:00:00 2001 From: Pauline Date: Thu, 25 Jul 2024 07:50:48 +0200 Subject: [PATCH 10/11] =?UTF-8?q?=F0=9F=94=A8=20chore:=20add=20contributin?= =?UTF-8?q?g.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CONTRIBUTING.md | 124 +++++++++++++++++++++++++++++++++++++ packages/scripts/setup.ps1 | 50 ++++++++------- packages/scripts/setup.sh | 14 ++++- 3 files changed, 162 insertions(+), 26 deletions(-) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..d8eb1911 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,124 @@ +# Contributing to OneLauncher + +Welcome! + +Please read our [Code of Conduct] to keep our community approachable and respectable. + +## New Contributor Guide + +To familiarize yourself with the project, please read the [README]. Here are some resources to help you get started with open-source contributions: + +- [Finding ways to contribute to open-source on GitHub] +- [Setting up Git] +- [GitHub flow] +- [Collaborating with pull requests] +- [Tauri essentials] +- [the `pnpm` CLI] + +## Getting Started + +### Issues + +#### Creating a New Issue + +If you come across an issue or have a feature request for OneLauncher, please [search if a related issue has already been reported]. If no relevant issue exists, you can open a new issue using the appropriate [issue form]. + +#### Solving an Issue + +To find an issue that interests you, you can browse through our [existing issues] and use the available `labels` to narrow down your search (See [Labels] for more information). As a general rule, if you find an issue you want to work on, you are welcome to open a PR with a fix. + +### Making Changes + +#### Making Changes Locally + +This project uses [`Cargo`] and [`pnpm`]. Make ensure you have them installed before proceeding. + +To make changes locally, follow these steps: + +1. Clone the repository: `git clone https://github.com/polyfrost/onelauncher` +2. Navigate to the project directory: `cd onelauncher` +3. Configure your system environment for OneLauncher development: + 1. For Linux users, run: `./packages/scripts/setup.sh` + > The [Unix script] will check if Rust and pnpm are installed then proceed to install Clang, NASM, LLVM, libvips, [Tauri essentials] and any other required dependencies for OneLauncher to build. + 2. For macOS users, run: `./packages/scripts/setup.sh` + > The [Unix script] will check if Rust, pnpm and Xcode are installed and proceed to use Homebrew to install NASM, [Tauri essentials] and install any other required dependencies for OneLauncher to build. + 3. For Windows users, run in PowerShell: `.\packages\scripts\setup.ps1` + > The [Unix script] will install pnpm, LLVM, C++ build tools, NASM, Rust + Cargo, Rust tools, Edge Webview 2, [Tauri essentials] and any other required dependencies for OneLauncher to build. +4. Install dependencies: `pnpm i` +5. Prepare the build: `pnpm prep` (This will run all necessary codegen and build required dependencies) + +To quickly run only the desktop app after `prep`, you can use: + +- `pnpm dev` + + If necessary, the webview devtools can be opened by pressing `Ctrl + Shift + I` (Linux and Windows) or `Command + Option + I` (macOS) in the desktop app. + +If you encounter any issues, ensure that you are using the following versions (or later) of Rust, Node and Pnpm: + +- Rust version: **1.79** +- Node version: **18.18** +- Pnpm version: **9.4.0** + +After cleaning out your build artifacts using `pnpm clean`, `git clean`, or `cargo clean`, it is necessary to re-run the `setup` script. + +After you finish making your changes and committed them to your branch, make sure to execute `pnpm format` to fix any style inconsistency in your code. + +### Pull Request + +Once you have finished making your changes, create a pull request (PR) to submit them. + +- Fill out the template to help reviewers understand your changes and the purpose of your PR. +- If you are addressing an existing issue, don't forget to [link your PR to the issue]. +- Enable the checkbox to [allow maintainer edits] so that the branch can be updated for merging. +- Once you submit your PR, a team member will review your proposal. They may ask questions or request additional information. +- You may be asked to make changes before the PR can be merged, either through [suggested changes] or pull request comments. You can apply suggested changes directly through the UI. For other changes, you can make them in your fork and commit them to your branch. +- As you update your PR and apply changes, [mark each conversation as resolved]. +- If you run into any merge issues, refer to this [git tutorial] to help you resolve merge conflicts and other issues. + +### Your PR is Merged! + +Congratulations! 🎉🎉 Polyfrost thanks you for your contribution! ✨ +Once your PR is merged, your changes will be included in the next release. + +### Common Errors + +#### macOS errors with XCode tools & Rosetta + +This error occurs when Xcode is not installed or when the Xcode command line tools are not in your `PATH`. + +Run `xcode-select --install` in the terminal to install the command line tools. If they are already installed, ensure that you update macOS to the latest version available. + +If that doesn't work, ensure that macOS is fully updated, and that you have Xcode installed (via the app store). + +Also ensure that Rosetta is installed, as a few of our dependencies require it. You can install Rosetta with `softwareupdate --install-rosetta --agree-to-license`. + +### Translations + +Check out the [i18n README](apps/desktop/locales/README.md) for more information on how to contribute to translations. + +### Credits + +This CONTRIBUTING.md file was inspired by the [`github/docs` CONTRIBUTING.md] file, and we extend our gratitude to the original authors. + +[Tauri essentials]: https://v2.tauri.app/start/prerequisites/ +[Unix script]: https://github.com/polyfrost/onelauncher/blob/main/packages/scripts/setup.sh +[Windows script]: https://github.com/polyfrost/onelauncher/blob/main/packages/scripts/setup.ps1 +[`cargo`]: https://doc.rust-lang.org/cargo/getting-started/installation.html +[`pnpm`]: https://pnpm.io/installation +[Labels]: https://github.com/polyfrost/onelauncher/labels +[the `pnpm` CLI]: https://pnpm.io/pnpm-cli +[Collaborating with pull requests]: https://docs.github.com/en/github/collaborating-with-pull-requests +[GitHub flow]: https://docs.github.com/en/get-started/quickstart/github-flow +[Setting up Git]: https://docs.github.com/en/get-started/quickstart/set-up-git +[Finding ways to contribute to open-source on GitHub]: https://docs.github.com/en/get-started/exploring-projects-on-github/finding-ways-to-contribute-to-open-source-on-github +[Code of Conduct]: ./CODE_OF_CONDUCT.md +[README]: ./README.md +[search if a related issue has already been reported]: https://docs.github.com/en/github/searching-for-information-on-github/searching-on-github/searching-issues-and-pull-requests#search-by-the-title-body-or-comments +[issue form]: https://github.com/polyfrost/onelauncher/issues/new/choose +[existing issues]: https://github.com/polyfrost/onelauncher/issues +[`github/docs` CONTRIBUTING.md]: https://github.com/github/docs/blob/main/CONTRIBUTING.md +[link your PR to the issue]: https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue +[allow maintainer edits]: https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/allowing-changes-to-a-pull-request-branch-created-from-a-fork +[suggested changes]: https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/incorporating-feedback-in-your-pull-request +[mark each conversation as resolved]: https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/commenting-on-a-pull-request#resolving-conversations +[git tutorial]: https://lab.github.com/githubtraining/managing-merge-conflicts diff --git a/packages/scripts/setup.ps1 b/packages/scripts/setup.ps1 index b375ce39..e605a595 100644 --- a/packages/scripts/setup.ps1 +++ b/packages/scripts/setup.ps1 @@ -1,6 +1,6 @@ -# Set default value of 0 for external command exit code +# set default value of 0 for external command exit code $LASTEXITCODE = 0 -# Enables strict mode, which causes PowerShell to treat uninitialized variables, undefined functions, and other common errors as terminating errors. +# enables strict mode, which causes PowerShell to treat uninitialized variables, undefined functions, and other common errors as terminating errors. $ErrorActionPreference = if ($env:CI) { 'Stop' } else { 'Inquire' } Set-StrictMode -Version Latest @@ -12,7 +12,7 @@ function Reset-Path { ) } -# Verify if environment is Windows 64-bit and if the user is an administrator +# verifies if the environment is Windows 64-bit and if the user is an administrator if ((-not [string]::IsNullOrEmpty($env:PROCESSOR_ARCHITEW6432)) -or ( "$env:PROCESSOR_ARCHITECTURE" -eq 'ARM64' ) -or ( @@ -25,19 +25,20 @@ if ((-not [string]::IsNullOrEmpty($env:PROCESSOR_ARCHITEW6432)) -or ( if (Test-Path "$($env:WINDIR)\SysNative\WindowsPowerShell\v1.0\powershell.exe" -PathType Leaf) { throw 'You are using PowerShell (32-bit), please re-run in PowerShell (64-bit)' } else { - throw 'This script is only supported on Windows 64-bit' + throw 'This script is only supported on Windows 64-bit operating systems, use the script.sh for Unix systems.' } Exit 1 } elseif ( -not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) ) { - # Start a new PowerShell process with administrator privileges and set the working directory to the directory where the script is located + # starts a new PowerShell process with administrator privileges and set the working directory to the directory where the script is located $proc = Start-Process -PassThru -Wait -FilePath 'PowerShell.exe' -Verb RunAs -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$($MyInvocation.MyCommand.Definition)`"" -WorkingDirectory "$PSScriptRoot" - # Reset path so the user doesn't have to restart the shell to use the tools installed by this script + # resets path so the user doesn't have to restart the shell to use the tools installed by this script Reset-Path Exit $proc.ExitCode } +# exits the script with an error function Exit-WithError($err, $help = $null) { if ($null -ne $help) { Write-Host @@ -47,6 +48,7 @@ function Exit-WithError($err, $help = $null) { Exit 1 } +# adds a directory to the path env variable function Add-DirectoryToPath($directory) { Reset-Path if ($env:Path.Split([IO.Path]::PathSeparator) -notcontains $directory) { @@ -57,21 +59,21 @@ function Add-DirectoryToPath($directory) { ) if ($env:CI) { - # If running in CI, we need to use GITHUB_PATH instead of the normal PATH env variables + # if running in CI, we need to use GITHUB_PATH instead of the normal PATH env variables Add-Content $env:GITHUB_PATH "$directory`n" } } Reset-Path } -# Reset PATH to ensure the script doesn't have stale Path entries +# resets PATH to ensure the script doesn't have stale Path entries Reset-Path -# Get project dir (get grandparent dir from script location: \scripts\setup.ps1) +# gets project dir (get grandparent dir from script location: \packages\scripts\setup.ps1) $projectRoot = Split-Path -Path $PSScriptRoot -Parent $packageJson = Get-Content -Raw -Path "$projectRoot\package.json" | ConvertFrom-Json -# Valid winget exit status +# valid winget exit statuses $wingetValidExit = 0, -1978335189, -1978335153, -1978335135 Write-Host 'OneLauncher Development Environment Setup' -ForegroundColor Magenta @@ -81,8 +83,8 @@ To set up your machine for OneLauncher development, this script will do the foll 1) Install Windows C++ build tools 2) Install Edge Webview 2 3) Install Rust and Cargo -4) Install Rust tools -5) Install Node.js, npm and pnpm +4) Install Rust tools (if not already installed) +5) Install Node.js, npm and pnpm (if not already installed) "@ # Install System dependencies (GitHub Actions already has all of those installed) @@ -94,7 +96,7 @@ https://learn.microsoft.com/windows/package-manager/winget/ '@ } - # Check system winget version is greater or equal to v1.4.10052 + # check system winget version is greater or equal to v1.4.10052 $wingetVersion = [Version]((winget --version) -replace '.*?(\d+)\.(\d+)\.(\d+).*', '$1.$2.$3') $requiredVersion = [Version]'1.4.10052' if ($wingetVersion.CompareTo($requiredVersion) -lt 0) { @@ -102,7 +104,7 @@ https://learn.microsoft.com/windows/package-manager/winget/ Exit-WithError $errorMessage } - # Check connectivity to GitHub + # check connectivity to github $ProgressPreference = 'SilentlyContinue' if (-not ((Test-NetConnection -ComputerName 'github.com' -Port 80).TcpTestSucceeded)) { Exit-WithError "Can't connect to github, check your internet connection and run this script again" @@ -118,7 +120,7 @@ https://learn.microsoft.com/windows/package-manager/winget/ Write-Host 'This will take some time as it involves downloading several gigabytes of data....' -ForegroundColor Cyan winget install -e --accept-source-agreements --force --disable-interactivity --id Microsoft.VisualStudio.2022.BuildTools ` --override 'updateall --quiet --wait' - # Force install because BuildTools is itself a package manager, so let it decide if something needs to be installed or not + # force install because BuildTools is itself a package manager, so let it decide if something needs to be installed or not winget install -e --accept-source-agreements --force --disable-interactivity --id Microsoft.VisualStudio.2022.BuildTools ` --override '--wait --quiet --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended' if (-not ($wingetValidExit -contains $LASTEXITCODE)) { @@ -129,7 +131,7 @@ https://learn.microsoft.com/windows/package-manager/winget/ Write-Host Write-Host 'Installing Edge Webview 2...' -ForegroundColor Yellow - # This is normally already available, but on some early Windows 10 versions it isn't + # this is normally already available, but on some early windows 10 versions it isn't winget install -e --accept-source-agreements --disable-interactivity --id Microsoft.EdgeWebView2Runtime if (-not ($wingetValidExit -contains $LASTEXITCODE)) { Exit-WithError 'Failed to install Edge Webview 2' @@ -157,7 +159,7 @@ https://learn.microsoft.com/windows/package-manager/winget/ Write-Host Write-Host 'Installing NodeJS...' -ForegroundColor Yellow - # Check if Node.JS is already installed and if it's compatible with the project + # check if nodejs is already installed and if it's compatible with the project $currentNode = Get-Command node -ea 0 $currentNodeVersion = if (-not $currentNode) { $null } elseif ($currentNode.Version) { $currentNode.Version } elseif ((node --version) -match '(?sm)(\d+(\.\d+)*)') { [Version]$matches[1] } else { $null } $enginesNodeVersion = if ($packageJson.engines.node -match '(?sm)(\d+(\.\d+)*)') { [Version]$matches[1] } else { $null } @@ -165,17 +167,17 @@ https://learn.microsoft.com/windows/package-manager/winget/ Exit-WithError "Current Node.JS version: $currentNodeVersion (required: $enginesNodeVersion)" ` 'Uninstall the current version of Node.JS and run this script again' } - # Install Node.JS + # installs nodejs winget install -e --accept-source-agreements --disable-interactivity --id OpenJS.NodeJS if (-not ($wingetValidExit -contains $LASTEXITCODE)) { Exit-WithError 'Failed to install NodeJS' } else { $LASTEXITCODE = 0 } - # Add NodeJS to the PATH + # adds nodejs to the PATH Add-DirectoryToPath "$env:SystemDrive\Program Files\nodejs" - # Reset Path to ensure that executable installed above are available to rest of the script + # rests PATH to ensure that executable installed above are available to rest of the script Reset-Path Write-Host @@ -194,22 +196,22 @@ https://learn.microsoft.com/windows/package-manager/winget/ Write-Host Write-Host 'Installing for pnpm...' -ForegroundColor Yellow - # Check if pnpm is already installed and if it's compatible with the project + # checks if pnpm is already installed and if it's compatible with the project $currentPnpmVersion = if (-not (Get-Command pnpm -ea 0)) { $null } elseif ((pnpm --version) -match '(?sm)(\d+(\.\d+)*)') { [Version]$matches[1] } else { $null } $enginesPnpmVersion = if ($packageJson.engines.pnpm -match '(?sm)(\d+(\.\d+)*)') { [Version]$matches[1] } else { $null } if (-not $currentPnpmVersion) { - # Remove possible remaining envvars from old pnpm installation + # removes possible remaining envvars from old pnpm installation [System.Environment]::SetEnvironmentVariable('PNPM_HOME', $null, [System.EnvironmentVariableTarget]::Machine) [System.Environment]::SetEnvironmentVariable('PNPM_HOME', $null, [System.EnvironmentVariableTarget]::User) - # Install pnpm + # installs pnpm npm install -g "pnpm@latest-$($enginesPnpmVersion.Major)" if ($LASTEXITCODE -ne 0) { Exit-WithError 'Failed to install pnpm' } - # Add NPM global modules to the PATH + # adds NPM global modules to the PATH if (Test-Path "$env:APPDATA\npm" -PathType Container) { Add-DirectoryToPath "$env:APPDATA\npm" } diff --git a/packages/scripts/setup.sh b/packages/scripts/setup.sh index f9afa934..a4dafefa 100755 --- a/packages/scripts/setup.sh +++ b/packages/scripts/setup.sh @@ -6,6 +6,7 @@ if [ "${CI:-}" = "true" ]; then set -x fi +# displays an error message and exits the script err() { for _line in "$@"; do echo "$_line" >&2 @@ -13,6 +14,7 @@ err() { exit 1 } +# checks if a command/program exists has() { for prog in "$@"; do if ! command -v "$prog" 1>/dev/null 2>&1; then @@ -21,6 +23,7 @@ has() { done } +# runs a specified command with sudo sudo() { if [ "$(id -u)" -eq 0 ]; then "$@" @@ -29,6 +32,7 @@ sudo() { fi } +# fails the script at a specific line with an unknown error script_failure() { if [ -n "${1:-}" ]; then _line="on line $1" @@ -40,9 +44,10 @@ script_failure() { trap 'script_failure ${LINENO:-}' ERR +# checks if we are running in a windows environment case "${OSTYPE:-}" in 'msys' | 'mingw' | 'cygwin') - err 'Bash for Windows is not supported, please use Powershell or CMD' + err 'Bash for Windows is not supported, please use Powershell or CMD and run setup.ps1' ;; esac @@ -53,6 +58,7 @@ if [ "${CI:-}" != "true" ]; then echo 'Press Enter to continue' read -r + # checks if pnpm is installed if ! has pnpm; then err 'pnpm was not found.' \ "Ensure the 'pnpm' command is in your \$PATH." \ @@ -60,6 +66,7 @@ if [ "${CI:-}" != "true" ]; then 'https://pnpm.io/installation' fi + # checks if rustc and cargo are installed if ! has rustc cargo; then err 'Rust was not found.' \ "Ensure the 'rustc' and 'cargo' binaries are in your \$PATH." \ @@ -69,12 +76,14 @@ if [ "${CI:-}" != "true" ]; then echo fi -# Install system deps +# installs system deps case "$(uname)" in "Darwin") if [ "$(uname -m)" = 'x86_64' ] && ! [ "${CI:-}" = "true" ]; then brew install nasm fi + + echo ;; "Linux") # https://v2.tauri.app/start/prerequisites/ @@ -154,6 +163,7 @@ case "$(uname)" in ;; esac +# installs cargo-watch for development purposes if [ "${CI:-}" != "true" ]; then echo "Installing Rust tools..." From b73963b5461842e70e754d03575cfdf3682730f4 Mon Sep 17 00:00:00 2001 From: Pauline Date: Thu, 25 Jul 2024 09:42:46 +0200 Subject: [PATCH 11/11] =?UTF-8?q?=F0=9F=94=A8=20chore:=20committing=20unst?= =?UTF-8?q?aged=20stuff=20to=20switch=20branch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.toml | 5 ----- apps/backend/Cargo.toml | 16 ---------------- apps/backend/src/lib.rs | 0 apps/backend/src/main.rs | 2 -- 4 files changed, 23 deletions(-) delete mode 100644 apps/backend/Cargo.toml delete mode 100644 apps/backend/src/lib.rs delete mode 100644 apps/backend/src/main.rs diff --git a/Cargo.toml b/Cargo.toml index 879e3bd9..587679d5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,6 @@ resolver = "2" members = [ "crates/*", "apps/desktop/src-tauri", - "apps/backend" ] [workspace.package] @@ -142,10 +141,6 @@ objc = { version = "0.2" } webbrowser = { version = "1.0" } url = { version = "2.5.2" } -# backend dependencies -actix-web = { version = "4.8" } -roxmltree = { version = "0.20" } - [workspace.dependencies.prisma-client-rust] git = "https://github.com/brendonovich/prisma-client-rust" rev = "4f9ef9d38ca732162accff72b2eb684d2f120bab" diff --git a/apps/backend/Cargo.toml b/apps/backend/Cargo.toml deleted file mode 100644 index 7a269dea..00000000 --- a/apps/backend/Cargo.toml +++ /dev/null @@ -1,16 +0,0 @@ -[package] -name = "polyfrost_api" -version = { workspace = true } -license = { workspace = true } -edition = { workspace = true } -repository = { workspace = true } -documentation = { workspace = true } -readme = { workspace = true } -homepage = { workspace = true } -authors = { workspace = true } - -[dependencies] -actix-web = { workspace = true } -serde = { workspace = true } -reqwest = { workspace = true } -roxmltree = { workspace = true } diff --git a/apps/backend/src/lib.rs b/apps/backend/src/lib.rs deleted file mode 100644 index e69de29b..00000000 diff --git a/apps/backend/src/main.rs b/apps/backend/src/main.rs deleted file mode 100644 index ff8866bc..00000000 --- a/apps/backend/src/main.rs +++ /dev/null @@ -1,2 +0,0 @@ -async fn main() -> std::io::Result<()> { -}