| 1 | ---
|
| 2 | description: posprint development conventions
|
| 3 | globs: **/*
|
| 4 | alwaysApply: true
|
| 5 | ---
|
| 6 |
|
| 7 | # posprint development rules
|
| 8 |
|
| 9 | ## Language and dependencies
|
| 10 |
|
| 11 | - Single language: **Rust** with **egui** (eframe) for the UI.
|
| 12 | - Prefer std library and in-house code. Add a crate only when reimplementing would be unreasonable (e.g. `serialport`, `serde`, `image`, UI framework).
|
| 13 | - ESC/POS encoding lives in `src/escpos.rs` — do not add the `escpos` crates.io package.
|
| 14 | - Printing: USB printer-class (`rusb`), Windows spooler, USB-serial, and OS-paired Classic Bluetooth SPP (`serialport`). Do not add BLE or network printing until explicitly requested.
|
| 15 |
|
| 16 | ## Testing
|
| 17 |
|
| 18 | - **Every module must have unit tests** in `#[cfg(test)] mod tests` (or `tests/` for integration).
|
| 19 | - New behaviour requires new tests in the same commit.
|
| 20 | - Run `cargo test` before merging; all tests must pass.
|
| 21 | - Use `MockTransport` for printer I/O in tests; never require hardware in CI.
|
| 22 |
|
| 23 | ## Branches and commits
|
| 24 |
|
| 25 | - Default branch: `master`.
|
| 26 | - Use `feature/` or `fix/` branches for changes.
|
| 27 | - **Always commit without waiting for the user to ask.** There is no reason to leave work uncommitted; frequent, focused commits are required so changes can be reverted if something goes wrong.
|
| 28 | - Commit after every logical unit of work (e.g. a bug fix, a new feature slice, tests for that slice, or a doc sync tied to the same change). Do not batch an entire session into one commit at the end.
|
| 29 | - **Never end a task with uncommitted changes** in the working tree. If you edited files, commit them before finishing.
|
| 30 | - Commit messages: short imperative summary of *why* (one line is fine); body optional for non-obvious context.
|
| 31 | - Merge to `master` only after `cargo test` is green.
|
| 32 |
|
| 33 | ## Git merges
|
| 34 |
|
| 35 | - **Never fast-forward.** Always create a merge commit:
|
| 36 | ```bash
|
| 37 | git checkout master
|
| 38 | git merge --no-ff feature/your-branch
|
| 39 | ```
|
| 40 | - Do not use `git pull --ff-only` when integrating a merged feature branch into `master`.
|
| 41 |
|
| 42 | ## Branch cleanup
|
| 43 |
|
| 44 | - After a successful merge to `master`, delete the local branch:
|
| 45 | ```bash
|
| 46 | git branch -d feature/your-branch
|
| 47 | ```
|
| 48 | - If a feature branch was pushed to the remote, delete it there too once merged:
|
| 49 | ```bash
|
| 50 | git push origin --delete feature/your-branch
|
| 51 | ```
|
| 52 | - Periodically prune stale remote-tracking refs: `git fetch --prune`
|
| 53 |
|
| 54 | ## Documentation
|
| 55 |
|
| 56 | - See `.cursor/rules/documentation.mdc` for full doc-sync rules.
|
| 57 | - Keep `docs/HELP.md` in sync with supported DSL and UI features.
|
| 58 | - The in-app Help tab must mirror `docs/HELP.md` (via `include_str!` in `src/lib.rs`).
|
| 59 | - Update `docs/ARCHITECTURE.md`, `docs/PRINTING.md`, etc. when implementation diverges from design.
|
| 60 |
|
| 61 | ## Releases
|
| 62 |
|
| 63 | - GitLab CI (`.gitlab-ci.yml`) runs tests on **merge requests**; tagged releases build artifacts.
|
| 64 | - Tagged releases produce Windows `.exe`, Debian `.deb` (apt), and Arch `.pkg.tar.zst` (pacman).
|
| 65 | - Debian packages use `cargo-deb` and `[package.metadata.deb]` in `Cargo.toml`.
|
| 66 | - Arch packages use `packaging/arch/PKGBUILD` and `makepkg`.
|