Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ scripts/dev/bin/
scripts/dev/.cache/
scripts/dev/sandbox/

# Local data of scripts/start.sh (configs, schedules, logs)
# Local data of bun run dev (configs, schedules, logs)
/snapraid/
!apps/server/src/parsers/__tests__/fixtures/*.log

Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,7 @@ December 23.

## 🛠️ Development

Requires Bun (the version in `package.json`) and the fish shell for `scripts/start.sh`;
the end-to-end tests run on Bun too.
Requires Bun (the version in `package.json`); the end-to-end tests run on Bun too.

```bash
git clone https://github.com/firsttris/snapraid-ui && cd snapraid-ui
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/system/demo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Stand-ins for `snapraid smart` and `probe` in the demo sandbox (scripts/start.sh --demo).
// Stand-ins for `snapraid smart` and `probe` in the demo sandbox (bun run demo).
// Its disks are directories, so SnapRAID finds no device to query. The output below has
// the structured log format of the real commands and goes through the same parsers.
// The sandbox disks also hold only a few KiB on the host's filesystem: `status` and the
Expand Down
18 changes: 10 additions & 8 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ This page gets you from a fresh clone to a running development setup, and covers
| Tool | Version | Needed for |
|---|---|---|
| [Bun](https://bun.com/) | the version in `packageManager` of the root `package.json` (1.4.4) | Everything JavaScript: runs the backend and its tests, installs the packages, runs Vite and Vitest and Playwright's test runner (`bun --bun playwright test`), compiles the standalone binary (CI and the image use the same version) |
| [fish](https://fishshell.com/) | | `scripts/start.sh` is a fish script |
| `curl`, `tar`, `gcc`, `make` | | Building SnapRAID for the demo sandbox (`scripts/dev/setup.sh`) |
| SnapRAID | 14.0 or newer | Only for running against a real array without `--demo`; it has to be on your `PATH` or set via `SNAPRAID_BIN` |
| Docker or Podman | | Only for building the image |
Expand All @@ -18,19 +17,23 @@ This page gets you from a fresh clone to a running development setup, and covers
git clone https://github.com/firsttris/snapraid-ui
cd snapraid-ui
bun install # all packages of the workspace, from the one bun.lock
bun run demo # scripts/start.sh --demo: sandbox with fake disks, no real array needed
bun run demo # sandbox with fake disks, no real array needed
```

Open **http://localhost:3000**. The frontend dev server runs on port 3000, the backend API and WebSocket on port 8080. `Ctrl+C` stops both.
Open **http://localhost:3000**. The frontend dev server runs on port 3000, the backend API and WebSocket on port 8080.

`scripts/start.sh` (`bun run dev`, `bun run demo`) has two modes:
There are two ways to start, both scripts in the root `package.json`:

| Command | Data directory | SnapRAID binary | Extra |
|---|---|---|---|
| `bun run dev` (`scripts/start.sh`) | `./snapraid/` (created on first start, ignored by git) | `snapraid` from your `PATH` | Works against your real configs |
| `bun run demo` (`scripts/start.sh --demo`) | `scripts/dev/sandbox/` | `scripts/dev/bin/snapraid` | Sets `SNAPRAID_EXTRA_ARGS=--test-skip-device` and `SNAPRAID_DEMO=1` |
| `bun run dev` | `./snapraid/` (created on first start, ignored by git) | `snapraid` from your `PATH` | Works against your real configs |
| `bun run demo` | `scripts/dev/sandbox/` | `scripts/dev/bin/snapraid` | Runs `scripts/dev/setup.sh` first (stops if it fails), sets `SNAPRAID_EXTRA_ARGS=--test-skip-device` and `SNAPRAID_DEMO=1` |

Under the hood it starts `bun run dev` in `apps/server/` (`bun --watch`, so the backend restarts on changes) and `bun run dev` in `apps/web/` (Vite with hot reload). You can run these two commands yourself in separate terminals; set `SNAPRAID_BASE_PATH` and friends first (see [Configuration](configuration.md)), otherwise the backend uses `snapraid/` in the repository's root (`../../snapraid` relative to `apps/server/`).
Both set the environment and then start the scripts `dev:server` (`bun run dev` in `apps/server/`: `bun --watch`, so the backend restarts on changes) and `dev:web` (`bun run dev` in `apps/web/`: Vite with hot reload) side by side with `bun run --parallel`, which prefixes each line with the script's name and stops the other script when one fails. `--parallel` passes the output through a pipe, so both scripts set `FORCE_COLOR=1` when you start them in a terminal to keep the colours (not when the output goes into a file or a pipe).

There is no start script of its own: the terminal sends `Ctrl+C` to the whole foreground process group, so it stops both servers; `Ctrl+Z` suspends both and gives you the shell back, `fg` resumes them.

You can also run `bun run dev:server` and `bun run dev:web` yourself in separate terminals; set `SNAPRAID_BASE_PATH` and friends first (see [Configuration](configuration.md)), otherwise the backend uses `snapraid/` in the repository's root (`../../snapraid` relative to `apps/server/`).

> [!NOTE]
> In development the frontend calls the backend directly at `http://localhost:8080` (`apps/web/src/lib/api/constants.ts`), and the backend only accepts credentials from the same hostname. Open the dev frontend as `http://localhost:3000`, not via a LAN IP.
Expand Down Expand Up @@ -121,7 +124,6 @@ packages/shared/ @snapraid-ui/shared: types and logic used by backend and
docker/ Dockerfile, Compose file, Quadlet units
scripts/build-binary.sh the standalone binary (bun build --compile)
scripts/install.sh installer of the binary with a systemd service, attached to each release
scripts/start.sh local start (bun run dev, bun run demo)
scripts/dev/setup.sh demo sandbox
scripts/social-preview/ the social preview image
e2e/ end-to-end tests (Playwright) against real SnapRAID and snapraid-daemon
Expand Down
2 changes: 1 addition & 1 deletion e2e/harness/demo-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default async function demoSetup() {
for (const server of servers.reverse()) await server.stop()
}
try {
// As scripts/start.sh --demo
// As bun run demo
servers.push(
await startBackend({
SNAPRAID_BASE_PATH: SANDBOX,
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"e2e"
],
"scripts": {
"dev": "fish scripts/start.sh",
"demo": "fish scripts/start.sh --demo"
"dev": "mkdir -p snapraid && if [ -t 1 ]; then export FORCE_COLOR=1; fi && SNAPRAID_BASE_PATH=$PWD/snapraid bun run --parallel dev:server dev:web",
"demo": "bash scripts/dev/setup.sh && if [ -t 1 ]; then export FORCE_COLOR=1; fi && SNAPRAID_BASE_PATH=$PWD/scripts/dev/sandbox SNAPRAID_BIN=$PWD/scripts/dev/bin/snapraid SNAPRAID_EXTRA_ARGS=--test-skip-device SNAPRAID_DEMO=1 bun run --parallel dev:server dev:web",
"dev:server": "bun run --cwd apps/server dev",
"dev:web": "bun run --cwd apps/web dev"
}
}
2 changes: 1 addition & 1 deletion scripts/dev/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,4 @@ snapraid_logged status
(cd "$BACKEND_DIR" && bun scripts/seed-demo.ts "$SANDBOX")

echo
echo "Sandbox ready. Start the app with: bun run demo (scripts/start.sh --demo)"
echo "Sandbox ready. Start the app with: bun run demo"
62 changes: 0 additions & 62 deletions scripts/start.sh

This file was deleted.

Loading