diff --git a/.gitignore b/.gitignore index c1cd63f..91777c5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ result target *.jks +.prettiercache diff --git a/.prettierignore b/.prettierignore index 0f0fd33..41f6f58 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,5 +1,7 @@ frontend/dist frontend/node_modules +frontend/package-lock.json backend/gen backend/target result +.prettiercache diff --git a/frontend/.prettierrc.yaml b/.prettierrc.yaml similarity index 100% rename from frontend/.prettierrc.yaml rename to .prettierrc.yaml diff --git a/README.md b/README.md index 89328b0..4cc94a3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Man Hunt +[![built with garnix](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Fgarnix.io%2Fapi%2Fbadges%2FBwc9876%2Fmanhunt-app%3Fbranch%3Dmain)](https://garnix.io/repo/Bwc9876/manhunt-app) + An iOS and Android app that lets you play man hunt with friends. The game is played over WebRTC Data Channels and is entirely P2P (except for the @@ -15,10 +17,12 @@ If you have [nix](https://nixos.org) installed, all of these are handled for you - [Rust](https://rustup.rs) - [Just](https://just.systems) (`cargo install just`) + - **On Windows**: Some implementation of `sh` (Git for Windows works well) - [Tauri's Pre-reqs](https://tauri.app/start/prerequisites/) - - [(Also pre-reqs for mobile dev if you are working on the app part)](https://tauri.app/start/prerequisites/#configure-for-mobile-targets) + - [(Also pre-reqs for mobile dev if you are working on the app part)](https://tauri.app/start/prerequisites/#configure-for-mobile-targets) - Tauri's CLI (`cargo install tauri-cli`) - [NodeJS](https://nodejs.org) +- [Prettier](https://prettier.io/) (`npm add -G prettier`) #### With Nix @@ -34,8 +38,8 @@ You can then call the `just` recipes mentioned below. - `just dev`: Will run the app locally on your computer, this will open a WebView with the frontend - - Note: all geolocation returned from tauri-plugin-geolocation will be hard - coded to `(0.0, 0.0)` in this mode. + - Note: all geolocation returned from tauri-plugin-geolocation will be hard + coded to `(0.0, 0.0)` in this mode. - `just dev-android`: Will run the app on a connect Android device or VM via ADB - `just signaling`: Will run the signaling server on port `3536` (this is needed for clients to connect) diff --git a/backend/capabilities/default.json b/backend/capabilities/default.json index 360237d..0dc7e6d 100644 --- a/backend/capabilities/default.json +++ b/backend/capabilities/default.json @@ -1,15 +1,13 @@ { - "$schema": "../gen/schemas/desktop-schema.json", - "identifier": "default", - "description": "Capability for the main window", - "windows": [ - "main" - ], - "permissions": [ - "core:default", - "opener:default", - "notification:default", - "log:default", - "geolocation:default" - ] + "$schema": "../gen/schemas/desktop-schema.json", + "identifier": "default", + "description": "Capability for the main window", + "windows": ["main"], + "permissions": [ + "core:default", + "opener:default", + "notification:default", + "log:default", + "geolocation:default" + ] } diff --git a/flake.nix b/flake.nix index 784367a..2b308e5 100644 --- a/flake.nix +++ b/flake.nix @@ -15,10 +15,21 @@ }; flakelight.builtinFormatters = false; - formatters = pkgs: { - "*.nix" = "${pkgs.alejandra}/bin/alejandra ."; - "*.{js,ts,jsx,tsx,md,json}" = "${pkgs.prettier}/bin/prettier --write . --config frontend/.prettierrc.yaml"; - "*.rs" = "${pkgs.rustfmt}"; + formatters = pkgs: let + prettier = "${pkgs.prettier}/bin/prettier --write ."; + alejandra = "${pkgs.alejandra}/bin/alejandra ."; + rustfmt = "${pkgs.rustfmt}/bin/rustfmt"; + just = "${pkgs.just}/bin/just --fmt --unstable"; + in { + "justfile" = just; + "*.nix" = alejandra; + "*.js" = prettier; + "*.ts" = prettier; + "*.jsx" = prettier; + "*.tsx" = prettier; + "*.md" = prettier; + "*.json" = prettier; + "*.rs" = rustfmt; }; devShell = pkgs: let diff --git a/frontend/.prettierignore b/frontend/.prettierignore deleted file mode 100644 index 76255e0..0000000 --- a/frontend/.prettierignore +++ /dev/null @@ -1,4 +0,0 @@ -dist -node_modules -package-lock.json - diff --git a/frontend/package.json b/frontend/package.json index 38ecdb7..7edeff0 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -8,7 +8,6 @@ "build": "tsc && vite build", "preview": "vite preview", "lint": "prettier --check . && tsc && eslint --cache", - "format": "prettier --write .", "tauri": "tauri" }, "dependencies": { diff --git a/garnix.yaml b/garnix.yaml index 48bace0..a275822 100644 --- a/garnix.yaml +++ b/garnix.yaml @@ -1,5 +1,5 @@ $schema: https://garnix.io/api/garnix-config-schema.json builds: - exclude: [] - include: - - "checks.x86_64-linux.*" + exclude: [] + include: + - "checks.x86_64-linux.*" diff --git a/justfile b/justfile index d63a999..4d18de7 100644 --- a/justfile +++ b/justfile @@ -1,9 +1,8 @@ _default: - @just --list --unsorted --justfile {{justfile()}} - + @just --list --unsorted --justfile {{ justfile() }} # Perform setup for the frontend using `npm` -[working-directory: 'frontend'] +[working-directory('frontend')] setup-frontend: npm install --no-fund --no-audit @@ -14,37 +13,38 @@ dev: # Format everything fmt: cargo fmt - cd frontend && npm run format + prettier --write . --cache --cache-location .prettiercache --log-level warn + just --fmt --unstable # Connect and run on an Android VM/Physical device dev-android: cargo tauri android dev # Run a check on the backend -[working-directory: 'backend'] +[working-directory('backend')] check-backend: cargo fmt --check cargo check cargo clippy --fix --allow-dirty --allow-staged -- -D warnings -[working-directory: 'manhunt-signaling'] +[working-directory('manhunt-signaling')] check-signaling: cargo fmt --check cargo check cargo clippy --fix --allow-dirty --allow-staged -- -D warnings # Run lint on the frontend -[working-directory: 'frontend'] +[working-directory('frontend')] check-frontend: npm run lint # Export types from the backend to TypeScript bindings -[working-directory: 'backend'] +[working-directory('backend')] export-types: cargo run --bin export-types ../frontend/src/bindings.ts - prettier --write ../frontend/src/bindings.ts + prettier --write ../frontend/src/bindings.ts --config ../.prettierrc.yaml # Start the signaling server on localhost:3536 -[working-directory: 'manhunt-signaling'] +[working-directory('manhunt-signaling')] signaling: cargo run 0.0.0.0:3536