|
| 1 | +# Repository Guidelines |
| 2 | + |
| 3 | +## Project Structure & Module Organization |
| 4 | + |
| 5 | +- `mod.ts`: public entrypoint; re-exports the library API. |
| 6 | +- `src/`: implementation (currently `src/dhash.ts`). |
| 7 | +- `tests/`: Deno tests (`*.test.ts`) and image fixtures used by the tests. |
| 8 | +- `deno.json`: package metadata, import map, and tasks. |
| 9 | + |
| 10 | +Keep public exports flowing through `mod.ts`. If you add a new public |
| 11 | +function/type, export it from `mod.ts` and add/adjust tests under `tests/`. |
| 12 | + |
| 13 | +## Build, Test, and Development Commands |
| 14 | + |
| 15 | +- `deno task test`: runs the full test suite with the required permissions |
| 16 | + (`--allow-read --allow-ffi --allow-env`). |
| 17 | +- `deno test`: useful for quick runs; mirror the permissions from |
| 18 | + `deno task test` if tests fail due to denied access. |
| 19 | +- `deno fmt`: format the repo (preferred before committing). |
| 20 | +- `deno lint`: run Deno’s linter on TypeScript sources. |
| 21 | +- `deno check mod.ts`: type-check the public surface area. |
| 22 | + |
| 23 | +## Coding Style & Naming Conventions |
| 24 | + |
| 25 | +- TypeScript for Deno; follow `deno fmt` output (2-space indent, trailing commas |
| 26 | + where applicable). |
| 27 | +- Prefer `@std/*` imports via `deno.json` import mappings (avoid ad-hoc path |
| 28 | + utilities). |
| 29 | +- Naming: |
| 30 | + - exported functions: `camelCase` (e.g. `toAscii`, `compare`). |
| 31 | + - test files: `*.test.ts`. |
| 32 | + |
| 33 | +## Testing Guidelines |
| 34 | + |
| 35 | +- Use `Deno.test(...)` with `@std/assert`-style assertions (follow existing |
| 36 | + patterns in `tests/dhash.test.ts`). |
| 37 | +- Optional coverage: `deno test --coverage=coverage` then |
| 38 | + `deno coverage coverage` (output is ignored via `.gitignore`). |
| 39 | +- If you change hashing behavior, update expected hashes and/or fixtures in |
| 40 | + `tests/` intentionally (include rationale in the PR). |
| 41 | + |
| 42 | +## Commit & Pull Request Guidelines |
| 43 | + |
| 44 | +- Commit messages follow Conventional Commits in this repo: `feat: ...`, |
| 45 | + `fix: ...`, `chore: ...`, optionally scoped like `fix(dhash): ...`. |
| 46 | +- PRs should include: |
| 47 | + - what changed and why (short, concrete), |
| 48 | + - how to verify (e.g. `deno task test`), |
| 49 | + - notes on permission changes or dependency changes (especially |
| 50 | + `npm:sharp@...`) and any `deno.lock` updates. |
| 51 | + |
| 52 | +## Publishing (JSR) |
| 53 | + |
| 54 | +- Bump `version` in `deno.json`. |
| 55 | +- Validate locally: `deno fmt`, `deno lint`, `deno task test`. |
| 56 | +- Preview package contents: `deno publish --dry-run`. |
| 57 | +- Publish: `deno publish` (auth via token/login). |
| 58 | +- CI publish: push a semver tag matching `deno.json`’s version (e.g. `v0.2.0`). |
| 59 | + GitHub Actions will run checks then publish via JSR’s tokenless GitHub Actions |
| 60 | + flow (OIDC). This requires linking the package to this GitHub repo in the JSR |
| 61 | + package settings. |
0 commit comments