|
| 1 | +# homebridge-wiz-lan — maintainer guide |
| 2 | + |
| 3 | +This file documents the consistent release ritual for this repo, derived from past tags and merge history. Follow it whenever a PR is merged or a release is cut. |
| 4 | + |
| 5 | +## Release ritual |
| 6 | + |
| 7 | +Releases are always cut as a **separate direct commit to `master`**, never bundled into a PR merge. |
| 8 | + |
| 9 | +### 1. Merge the PR |
| 10 | +- Use a true merge commit (no squash). |
| 11 | +- Dependabot PRs and human-contributor PRs are both merged the same way. |
| 12 | + |
| 13 | +### 2. Decide whether to release now or batch |
| 14 | +- **Release immediately** for user-visible features or fixes. |
| 15 | +- **Batch** for dependabot bumps and small follow-ups — fold them into the next human-driven release. |
| 16 | + |
| 17 | +### 3. Cut the release (single direct commit on `master`) |
| 18 | + |
| 19 | +In one commit, update all of: |
| 20 | + |
| 21 | +- **`package.json`** — bump `version` (semver: patch for fix, minor for feature, major for breaking). |
| 22 | +- **`CHANGELOG.md`** — add a new section at the top in the existing format: |
| 23 | + ``` |
| 24 | + ## X.Y.Z |
| 25 | + - [FEAT] / [FIX] short description |
| 26 | + - Thank you [@handle](https://github.com/handle) for [#NN](https://github.com/kpsuperplane/homebridge-wiz-lan/pull/NN) |
| 27 | + ``` |
| 28 | + - Use `[FEAT]` and `[FIX]` prefixes. |
| 29 | + - Credit human contributors by handle + PR link. Omit credit for dependabot. |
| 30 | +- **`README.md` contributors block** — if this release includes a first-time external contributor, add them under the credits section in the same format as existing entries (`#### [@handle]` then `[#NN title](url)`). |
| 31 | +- **`package-lock.json`** — regenerate via `npm install` so it matches the new version. |
| 32 | + |
| 33 | +The commit message is just the version string, e.g. `3.2.6`. |
| 34 | + |
| 35 | +### 4. Tag and push |
| 36 | +- Tag the bump commit with **`vX.Y.Z`** (always include the `v` prefix — historical tags were inconsistent; new tags should standardize on `v`). |
| 37 | +- Push the commit and the tag to `origin/master`. |
| 38 | +- npm publish runs from `.github/workflows/npm-publish.yml` on tag push. |
| 39 | + |
| 40 | +## What NOT to do |
| 41 | +- Don't bump `package.json` inside a feature PR — the version bump is a separate maintainer commit on master. |
| 42 | +- Don't squash-merge — preserve the merge-commit history. |
| 43 | +- Don't tag the merge commit; tag the version-bump commit that follows it. |
| 44 | +- Don't credit dependabot in CHANGELOG or README. |
| 45 | +- Don't create a release per dependabot PR — batch them. |
| 46 | + |
| 47 | +## Quick reference: file touch list per release |
| 48 | + |
| 49 | +| File | Why | |
| 50 | +| --- | --- | |
| 51 | +| `package.json` | version bump | |
| 52 | +| `package-lock.json` | sync with new version | |
| 53 | +| `CHANGELOG.md` | new section with FEAT/FIX bullets and contributor credit | |
| 54 | +| `README.md` | add new external contributor to credits block (only if applicable) | |
| 55 | + |
| 56 | +## Testing |
| 57 | + |
| 58 | +- Test runner: **Bun** (`bun test`). Production runtime is still Node — Bun is used only for the test suite. Tests live in `test/`, mirroring the `src/` layout. |
| 59 | +- Run locally: |
| 60 | + - `bun test` — run the suite. |
| 61 | + - `bun test --coverage` — run with coverage (text + lcov reports). |
| 62 | + - `bun test --watch` — watch mode for iterative work. |
| 63 | +- Required before cutting a release: **`bun test` must pass**. Run it before the version-bump commit in the ritual above. |
| 64 | +- Coverage target: **≥80% lines** on `src/` (excluding `src/index.ts`, `src/constants.ts`, `src/types.ts`). Don't lower this — instead, add tests when adding code. |
| 65 | +- CI runs `.github/workflows/test.yml` on every PR and push to master. Two jobs: |
| 66 | + - `bun-test` runs the suite + coverage upload. |
| 67 | + - `node-smoke` runs `npm run build` across Node 18/20/22 to ensure the published JS still compiles on every supported Node line. |
| 68 | +- When fixing a regression, add a test that would have caught it. The cache/state and network layers have history — see `test/accessories/WizLight/pilot.test.ts` for examples tied to issues #96/#101/#143/#145/#159. |
| 69 | +- Mocking conventions: |
| 70 | + - `test/__mocks__/homebridge.ts` provides the Homebridge HAP surface (Service, Characteristic, PlatformAccessory, AdaptiveLightingController). |
| 71 | + - `test/__helpers__/factories.ts` provides `makeFakeWiz()`, `makeDevice()`, `makeLightPilot()`, `makeSocketPilot()`, `FakeSocket`. |
| 72 | + - For `pilot.ts` tests, stub `src/util/network`'s `getPilot`/`setPilot` via `mock.module` and synthesize replies. For `wiz.ts` tests, mock only `dgram` so the real network functions still operate on the FakeSocket. |
0 commit comments