← [homelabdash](README.md) # Contributing ## Setting up You need Node.js 24 and git. ```sh git clone https://github.com/xiaodoudou/homelabdash.git cd homelabdash npm install ``` The first `npm install` also builds the page into `dist/` and points git at `.githooks/`, where the `pre-commit` hook runs the privacy check, lint and the tests, and `commit-msg` checks your message (see [Commit messages](#commit-messages)). Then list your own personal strings in `.privacy-denylist` at the root (it's gitignored, one per line), such as your domain, your LAN prefix and your user name. The privacy check refuses any commit that contains one of them. ## Running it ```sh npm run dev # the commented demo on http://localhost:3000, every service faked npm run dev:showcase # the full homelab of the screenshots ``` Both start Vite on port 3000 with hot reload of the page, in front of the server on 3001. The server restarts when `src/` changes, and picks up edits to the config and the builtin plugins without restarting. `PORT=3300 npm run dev` moves everything to another port. `npm run build` builds the page into `dist/`, which is what `npm start` and the image serve. To try your own config: `node bin/homelabdash.js serve --config-dir path/to/config --data-dir path/to/data`. ## Tests ```sh npm run check # lint, typecheck, privacy check, all tests: what CI runs npm test # the server and plugin tests npm run test:frontend # the page tests (Vitest) ``` [docs/contributing/TESTING.md](docs/contributing/TESTING.md) says what each test file covers and how the fake services work. When a test fails, fix the cause rather than loosening the assertion until it passes. ## Screenshots of the documentation The pictures in `docs/ui/` come from the showcase, through `npm run docs:screenshots`, and never from a real dashboard, because they must not show a real name, address or key. Retake them when a change alters how the page looks, and look at each one before you commit it. ## What CI checks `.github/workflows/test.yml` runs on every push to `main` and `dev` and on every pull request: - the commit messages, and the title of a pull request into `main`; - lint, typecheck, the privacy check, the server, plugin and page tests, the build of the page and `npm audit` of the runtime dependencies, on Node 24; - a secrets scan of the history (gitleaks); - the Docker image: it builds, starts, answers its health check and loads every plugin. ## Project layout and naming conventions [docs/contributing/ARCHITECTURE.md](docs/contributing/ARCHITECTURE.md) maps the code. A few conventions hold everywhere: - The server and the plugins are plain JavaScript modules with JSDoc types. They have no build step, and there are no TypeScript sources. - The page is made of Vue 3 single-file components in `web/src/components`, built by Vite. Anything that doesn't need Vue (formats, layout, view helpers) lives in plain modules next to them, tested in `test/frontend/`. - A builtin plugin lives in `plugins//`, with `index.js`, `README.md`, `fixtures/*.json` and `plugin.test.js`, and its id is the folder name in lower case. - Schemas are strict (`additionalProperties: false`) and carry their own defaults. - A comment says why, in one line, and only where the code can't. Match how densely the file you're editing is commented. - No em dashes, en dashes or middle dots anywhere: code, comments or docs. - New core behaviour comes with a test in `test/`. ## Making a change 1. Branch from `dev`: `feat/`, `fix/`, `docs/`. 2. Make the change with its test. For a plugin, update its README and fixtures too. 3. Add a line under **Unreleased** in `CHANGELOG.md` when users would notice the change. 4. `npm run check`. 5. Commit and open a pull request against `dev`. ## Commit messages Commit messages follow [Conventional Commits 1.0.0](https://www.conventionalcommits.org/en/v1.0.0/): ``` ():