From 6011804366790cb2634a567a959bbb2596048be2 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Nov 2026 06:14:22 +0000 Subject: [PATCH 1/6] Run bun run dev/demo with Bun alone, without fish scripts/start.sh was a fish script, so `bun run dev` and `bun run demo` needed fish installed. scripts/dev.ts does the same with Bun.spawn: the demo runs scripts/dev/setup.sh first and aborts if it fails, sets the sandbox's SNAPRAID_* variables (or creates ./snapraid without --demo), all paths from the repository's root, then runs `bun run dev` in apps/server and apps/web. Each runs in a process group of its own (as scripts/dev.ts in firsttris/ccu-addon-mui), and SIGINT, SIGTERM and SIGHUP go on to both groups, so a Ctrl+C, an IDE's stop or a closed terminal also stops what bun --watch and Vite started instead of leaving them on :8080 and :3000; what ignores SIGTERM gets SIGKILL after 5 s. When one exits, the other is stopped and its exit code is passed on; on a signal the script exits with 128 + n (130 for Ctrl+C), as before. scripts/dev.test.ts runs it against stand-ins for both apps and setup.sh; CI runs it in the backend job (`bun test ./scripts` in the root), and the backend's typecheck covers scripts/*.ts. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Y3rdfbWb1xDUdPRng7TX9Z --- .github/workflows/ci.yml | 3 + .gitignore | 2 +- README.md | 3 +- apps/server/src/system/demo.ts | 2 +- apps/server/tsconfig.json | 2 +- docs/development.md | 20 +-- e2e/harness/demo-setup.ts | 2 +- package.json | 4 +- scripts/dev.test.ts | 219 +++++++++++++++++++++++++++++++++ scripts/dev.ts | 125 +++++++++++++++++++ scripts/dev/setup.sh | 2 +- scripts/start.sh | 62 ---------- 12 files changed, 366 insertions(+), 80 deletions(-) create mode 100644 scripts/dev.test.ts create mode 100644 scripts/dev.ts delete mode 100755 scripts/start.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 519498d..3826687 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,6 +40,9 @@ jobs: working-directory: . - run: bun run typecheck - run: bun test + # scripts/dev.ts (bun run dev, bun run demo), with stand-ins for both apps + - run: bun test ./scripts + working-directory: . frontend: if: ${{ !github.event.pull_request.draft }} diff --git a/.gitignore b/.gitignore index f149d61..f52c271 100644 --- a/.gitignore +++ b/.gitignore @@ -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 scripts/dev.ts (configs, schedules, logs) /snapraid/ !apps/server/src/parsers/__tests__/fixtures/*.log diff --git a/README.md b/README.md index 51ef7f7..42a616c 100644 --- a/README.md +++ b/README.md @@ -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`), nothing else; the end-to-end tests run on Bun too. ```bash git clone https://github.com/firsttris/snapraid-ui && cd snapraid-ui diff --git a/apps/server/src/system/demo.ts b/apps/server/src/system/demo.ts index 51477b9..6e44bac 100644 --- a/apps/server/src/system/demo.ts +++ b/apps/server/src/system/demo.ts @@ -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 (scripts/dev.ts --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 diff --git a/apps/server/tsconfig.json b/apps/server/tsconfig.json index 84f3c7b..c892897 100644 --- a/apps/server/tsconfig.json +++ b/apps/server/tsconfig.json @@ -14,5 +14,5 @@ "@shared/*": ["./node_modules/@snapraid-ui/shared/src/*"] } }, - "include": ["src", "scripts", "../../packages/shared/src"] + "include": ["src", "scripts", "../../packages/shared/src", "../../scripts/*.ts"] } diff --git a/docs/development.md b/docs/development.md index 5a463dc..ba6de96 100644 --- a/docs/development.md +++ b/docs/development.md @@ -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 | @@ -18,19 +17,19 @@ 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 # scripts/dev.ts --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. -`scripts/start.sh` (`bun run dev`, `bun run demo`) has two modes: +`scripts/dev.ts` (`bun run dev`, `bun run demo`) has two modes: | 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` (`bun scripts/dev.ts`) | `./snapraid/` (created on first start, ignored by git) | `snapraid` from your `PATH` | Works against your real configs | +| `bun run demo` (`bun scripts/dev.ts --demo`) | `scripts/dev/sandbox/` | `scripts/dev/bin/snapraid` | 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/`). +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), each in a process group of its own. `Ctrl+C`, closing the terminal or a `kill` (SIGINT, SIGHUP, SIGTERM) goes on to both groups, so everything they started stops too (whatever is still running after 5 seconds gets SIGKILL), and the script exits with 128 + the signal's number. When one of the two exits, the other is stopped and the script exits with the first one's code. 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/`). > [!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. @@ -121,7 +120,7 @@ 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.ts local start (bun run dev, bun run demo), tested by scripts/dev.test.ts 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 @@ -151,7 +150,7 @@ Backend (`apps/server/package.json`, run with `bun run