Skip to content

Commit 6db2371

Browse files
committed
Update Readme
1 parent b4aa649 commit 6db2371

1 file changed

Lines changed: 35 additions & 22 deletions

File tree

README.md

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,44 @@
1-
# node-printer
1+
# @ssxv/node-printer
22

3-
Proof-of-concept N-API addon exposing basic printing APIs on Windows (Winspool).
3+
Cross-platform Node.js native printing bindings (Windows & POSIX/CUPS)
44

5-
This repository demonstrates building a small native Node.js addon with `node-addon-api` and provides a JavaScript wrapper with Promise and callback-compatible interfaces.
5+
`@ssxv/node-printer` is an N-API native addon exposing a small set of printing APIs to Node.js. The project started as a Windows (Winspool) proof-of-concept and has been extended to include POSIX (CUPS) support so the addon can be built and used on both Windows and Linux systems.
66

7-
Documentation is under the `docs/` folder. Start at `docs/index.md` for an overview and links.
7+
Key features
8+
- Exports: `getPrinters`, `getPrinter`, `getJob`, `getPrinterDriverOptions`, `printFile`, `printDirect`, `setJob`, `getDefaultPrinterName`, `getSupportedPrintFormats`, and `getSupportedJobCommands`.
9+
- Dual platform support: Win32 (Winspool) and POSIX (libcups).
10+
- Promise and callback-friendly JavaScript wrapper (`printer.js`).
11+
- Unit tests are deterministic and mock-driven; integration tests exercise native bindings on the host platform.
12+
13+
Documentation is under the `docs/` folder. Start at `docs/index.md` for an overview and links; the architecture overview is in `docs/ARCHITECTURE.md`.
814

915
Supported Node.js versions
1016
- Node.js 18.x, 20.x, 22.x
1117

12-
Quick install (Windows development)
18+
Quick start — Development (Windows)
1319

1420
```powershell
15-
# Install dev deps
21+
# Install dev dependencies
1622
npm ci
1723
# Build native addon (requires Visual Studio Build Tools + Python)
1824
npm run build
19-
# Run unit tests (deterministic / mock-driven)
25+
# Run unit tests (mock-driven)
26+
npm test
27+
```
28+
29+
Quick start — Development (Linux / WSL)
30+
31+
```bash
32+
# Install system build deps (Ubuntu/Debian)
33+
sudo apt-get update; sudo apt-get install -y libcups2-dev build-essential python3
34+
# Install node deps and build
35+
npm ci
36+
npm run build
37+
# Run unit tests (mock-driven)
2038
npm test
2139
```
2240

23-
Usage (example)
41+
Usage example
2442

2543
```javascript
2644
const printer = require('./printer');
@@ -33,22 +51,17 @@ async function list() {
3351
list();
3452
```
3553

36-
Testing & mocks
37-
- Unit tests are mock-driven and deterministic; unit tests load a JS mock for the native binding so they run on non-Windows CI.
38-
- Integration/native tests are gated. To run integration tests on Windows set `RUN_INTEGRATION=1` in the environment and ensure a test printer is available.
39-
40-
Prebuilds and publishing
41-
- To provide painless installs for Windows users, publish prebuilt binaries (per Node ABI and architecture) and keep the `install` script in `package.json` as `prebuild-install || node-gyp rebuild` so installations prefer prebuilt binaries and fall back to source builds.
42-
- CI should build and attach prebuild artifacts to GitHub Releases for each supported Node.js version and architecture you want to support.
54+
Prebuilt binaries & publishing
55+
- The repository includes a workflow `.github/workflows/prebuild-and-publish.yml` which builds prebuilt binaries on Windows and Linux runners for supported Node.js versions and uploads them as release artifacts. The install flow prefers prebuilt binaries and falls back to source builds using the `install` script in `package.json` (`prebuild-install || node-gyp rebuild`).
56+
- If you maintain a package registry release, ensure CI publishes prebuilt artifacts for all target Node.js versions and architectures you intend to support.
4357

44-
Documentation
45-
- Start here: `docs/index.md`
46-
- Architecture & data flow: `docs/ARCHITECTURE.md`
47-
- Type definitions: `types/index.d.ts`
58+
Build notes & troubleshooting
59+
- Windows: Visual Studio Build Tools (MSVC) + Python are required to compile the native addon. Follow the Node.js native build tooling docs for setting up `node-gyp` on Windows.
60+
- Linux: `libcups2-dev` (or the distribution equivalent) is required to build the POSIX/CUPS native sources. On Debian/Ubuntu: `sudo apt-get install libcups2-dev build-essential python3`.
61+
- If `prebuild-install` cannot find a compatible prebuilt binary during `npm install`, the package will fall back to a source build and you will need the platform build toolchain installed.
4862

49-
Notes
50-
- This PoC implements Windows (Winspool) functionality only. POSIX/CUPS support is planned separately.
51-
- Consider adding `"os": ["win32"]` to `package.json` to restrict installs to Windows if appropriate.
63+
Notes on driver option parsing (CUPS)
64+
- The POSIX implementation retrieves driver/option information from libcups. Historically the project used deprecated PPD helper APIs; the codebase has been migrated to use non-deprecated libcups APIs and, where available, `cupsCopyDestInfo`-style calls to gather richer printer driver metadata. Builds against older libcups that lack newer APIs will fall back to a conservative mapping of the destination options (name → value).
5265

5366
Contact
5467
- Issues & PRs: https://github.com/ssxv/node-printer

0 commit comments

Comments
 (0)