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..8e74bdc 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. `Ctrl+Z` stops both groups with the script, `fg` resumes them. 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