Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

3 changes: 3 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nodejs 22.20.0
rust 1.92.0
python 3.11.14
26 changes: 11 additions & 15 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ This section applies to all potential contributors, internal and external to the

### Installing dependencies

Install a node version manager such as [fnm](https://github.com/Schniz/fnm?tab=readme-ov-#installation).
Install [asdf](https://asdf-vm.com/) to manage all the language runtimes used by this project.

On Windows, it's also recommended to [upgrade your PowerShell version](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.5#winget), we're using 7.

Then in the repo run the following to install and use the node version specified in `.nvmrc`. You might need to specify your processor architecture with `--arch arm64` or `--arch x64` if it's not autodetected.
Then in the repo run the following to install and use the versions specified in `.tool-versions`:

```
fnm install
fnm use
asdf plugin add nodejs
asdf plugin add rust
asdf plugin add python
asdf install
```

Install the NPM dependencies with:
Expand All @@ -23,21 +25,15 @@ Install the NPM dependencies with:
npm install
```

This project uses a lot of Rust compiled to [WASM](https://webassembly.org/) within it. We have package scripts to run rustup, see `package.json` for reference:
This project uses a lot of Rust compiled to [Wasm](https://webassembly.org/) within it. Make sure Rust is installed (via asdf using `.tool-versions` or your preferred method), then install wasm-pack:

```
# macOS/Linux
npm run install:rust
npm run install:wasm-pack:cargo

# Windows
npm run install:rust:windows
npm run install:wasm-pack:cargo
```

### Building the app

To build the WASM layer, run:
To build the Wasm layer, run:

```
# macOS/Linux
Expand All @@ -57,7 +53,7 @@ npm run fetch:wasm
npm run fetch:wasm:windows
```

That will build the WASM binary and put in the `public` dir (though gitignored).
That will build the Wasm binary and put in the `public` dir (though gitignored).

Finally, to build the desktop app locally, pointing to our production zoo.dev infrastructure, accessible to everyone, run:

Expand Down Expand Up @@ -102,7 +98,7 @@ How to identify the types of tests and where to put your test.
Unit tests should be fast, minimal dependencies, and minimal async code.
Integration tests will be slower, require more dependencies, and could be flaky.

- Vitest [config](./vitest.config.ts)
- Vitest [config](./vitest.config.ts)
- Code written under `/src/**/*`
- Projects
- `unit` -- `npm run test:unit`
Expand All @@ -111,7 +107,7 @@ Integration tests will be slower, require more dependencies, and could be flaky.
- Component mounting and rendering
- `integration` -- `npm run test:integration`
- ends with `*.spec.*`
- Any code that requires the WASM blob loaded into memory
- Any code that requires the Wasm blob loaded into memory
- Any code that requires engine connection lite (websocket)
- Playwright [config](./playwright.config.ts)
- Code written under `/e2e/*/*`
Expand Down
12 changes: 1 addition & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,18 @@ endif
endif

ifdef WINDOWS
CARGO ?= $(USERPROFILE)/.cargo/bin/cargo.exe
WASM_PACK ?= $(USERPROFILE)/.cargo/bin/wasm-pack.exe
else
CARGO ?= $(shell which cargo || echo ~/.cargo/bin/cargo)
WASM_PACK ?= $(shell which wasm-pack || echo ~/.cargo/bin/wasm-pack)
endif

.PHONY: install
install: node_modules/.package-lock.json $(CARGO) $(WASM_PACK) ## Install dependencies
install: node_modules/.package-lock.json $(WASM_PACK) ## Install dependencies

node_modules/.package-lock.json: package.json package-lock.json
npm prune
npm install

$(CARGO): rust/rust-toolchain.toml
ifdef WINDOWS
npm run install:rust:windows
@ powershell -Command "if (Test-Path '$(CARGO)') { (Get-Item '$(CARGO)').LastWriteTime = Get-Date }"
else
npm run install:rust
endif

$(WASM_PACK):
npm run install:wasm-pack:cargo

Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,12 @@
},
"scripts": {
"prepare": "husky",
"install:rust": "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable && source \"$HOME/.cargo/env\" && (cd rust && (rustup show active-toolchain || rustup toolchain install))",
"install:rust:windows": "powershell -Command \"if (-not (Test-Path $env:USERPROFILE\\.cargo\\bin\\cargo.exe)) { winget install Rustlang.Rustup }\"",
"install:wasm-pack:cargo": "cargo install wasm-pack",
"install:tools:windows": "winget install jqlang.jq MikeFarah.yq GitHub.cli",
"start": "vite --port=3000 --host=0.0.0.0",
"start:prod": "vite preview --port=3000",
"serve": "vite serve --port=3000",
"build": "npm run install:rust && . $HOME/.cargo/env && npm run install:wasm-pack:cargo && npm run build:wasm && vite build",
"build": "npm run install:wasm-pack:cargo && npm run build:wasm && vite build",
"build:wasm": "./scripts/build-wasm.sh",
"build:wasm:windows": "powershell -ExecutionPolicy Bypass -File ./scripts/build-wasm.ps1",
"build:wasm-dev": "npm run build:wasm:dev",
Expand Down
Loading