print-check-cli 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -22
- package/dist/index.js +10 -3
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
# print-check-cli
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/print-check-cli)
|
|
3
4
|
[](https://github.com/ryancalacsan/print-check-cli/actions/workflows/ci.yml)
|
|
4
5
|
[](https://codecov.io/gh/ryancalacsan/print-check-cli)
|
|
5
6
|
|
|
6
7
|
A Node.js + TypeScript CLI tool that validates print-ready PDF files. Runs eight checks and reports pass/warn/fail results in the terminal.
|
|
7
8
|
|
|
9
|
+
**[View on npm](https://www.npmjs.com/package/print-check-cli)**
|
|
10
|
+
|
|
11
|
+

|
|
12
|
+
|
|
8
13
|
## Demo
|
|
9
14
|
|
|
10
15
|

|
|
11
16
|
|
|
12
|
-
##
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
- **8 prepress checks** — bleed/trim boxes, font embedding, color space (CMYK/RGB), image DPI, PDF/X compliance, total ink coverage, transparency, and page size consistency
|
|
20
|
+
- **Built-in print profiles** — presets for standard, magazine, newspaper, and large-format workflows with one `--profile` flag
|
|
21
|
+
- **Per-check severity overrides** — downgrade failures to warnings or skip checks entirely with `--severity fonts:warn,transparency:off`
|
|
22
|
+
- **Multi-file support** — validate entire directories with shell globbing (`print-check *.pdf`)
|
|
23
|
+
- **JSON output for CI** — structured JSON reports via `--format json` for pipeline integration
|
|
24
|
+
- **RC file configuration** — set project defaults in `.printcheckrc`, `.printcheckrc.json`, or `printcheck.config.js` with auto-discovery
|
|
25
|
+
- **Dual PDF engine** — combines mupdf (WASM-powered deep object traversal) with pdf-lib (page box reading) for thorough analysis
|
|
26
|
+
- **Colorized terminal output** — clear pass/warn/fail results with verbose per-page detail mode
|
|
13
27
|
|
|
14
28
|
| Check | What it validates |
|
|
15
29
|
| ---------------------- | ------------------------------------------------------------------------------- |
|
|
@@ -22,7 +36,29 @@ A Node.js + TypeScript CLI tool that validates print-ready PDF files. Runs eight
|
|
|
22
36
|
| **Transparency** | Detects unflattened transparency (groups, soft masks, blend modes) |
|
|
23
37
|
| **Page Size** | Verifies consistent page dimensions and optional expected size match |
|
|
24
38
|
|
|
25
|
-
##
|
|
39
|
+
## Tech Stack
|
|
40
|
+
|
|
41
|
+
| Package | Purpose |
|
|
42
|
+
| ------------------------------------------------------- | ----------------------------------------------------------- |
|
|
43
|
+
| [mupdf](https://www.npmjs.com/package/mupdf) (mupdf.js) | PDF engine — WASM-powered, deep PDF object traversal |
|
|
44
|
+
| [pdf-lib](https://www.npmjs.com/package/pdf-lib) | Supplemental — reading page boxes (TrimBox, BleedBox, etc.) |
|
|
45
|
+
| [commander](https://www.npmjs.com/package/commander) | CLI framework |
|
|
46
|
+
| [picocolors](https://www.npmjs.com/package/picocolors) | Terminal colors |
|
|
47
|
+
| [zod](https://www.npmjs.com/package/zod) | CLI option validation |
|
|
48
|
+
| [tsup](https://www.npmjs.com/package/tsup) | TypeScript build |
|
|
49
|
+
| [vitest](https://www.npmjs.com/package/vitest) | Testing |
|
|
50
|
+
|
|
51
|
+
## Getting Started
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Install globally
|
|
55
|
+
npm install -g print-check-cli
|
|
56
|
+
|
|
57
|
+
# Or run directly with npx
|
|
58
|
+
npx print-check-cli flyer.pdf
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Usage
|
|
26
62
|
|
|
27
63
|
```
|
|
28
64
|
print-check <file.pdf ...> [options]
|
|
@@ -87,11 +123,6 @@ Built-in profiles provide preset thresholds for common print scenarios. Explicit
|
|
|
87
123
|
| `newspaper` | 150 | any | 0 | 240 | Newsprint / low-fidelity |
|
|
88
124
|
| `large-format` | 150 | cmyk | 5 | 300 | Banners, posters, signage |
|
|
89
125
|
|
|
90
|
-
### Exit codes
|
|
91
|
-
|
|
92
|
-
- `0` — all checks passed (or warned)
|
|
93
|
-
- `1` — one or more checks failed
|
|
94
|
-
|
|
95
126
|
### Severity Overrides
|
|
96
127
|
|
|
97
128
|
Override the default severity for any check using `--severity`:
|
|
@@ -115,11 +146,16 @@ print-check flyer.pdf --severity fonts:warn,transparency:off
|
|
|
115
146
|
|
|
116
147
|
Available check names: `bleed`, `fonts`, `colorspace`, `resolution`, `pdfx`, `tac`, `transparency`, `pagesize`.
|
|
117
148
|
|
|
118
|
-
|
|
149
|
+
### Exit Codes
|
|
150
|
+
|
|
151
|
+
- `0` — all checks passed (or warned)
|
|
152
|
+
- `1` — one or more checks failed
|
|
153
|
+
|
|
154
|
+
### Configuration
|
|
119
155
|
|
|
120
156
|
Create a config file to set default options for your project:
|
|
121
157
|
|
|
122
|
-
|
|
158
|
+
#### `.printcheckrc` / `.printcheckrc.json`
|
|
123
159
|
|
|
124
160
|
```json
|
|
125
161
|
{
|
|
@@ -136,7 +172,7 @@ Create a config file to set default options for your project:
|
|
|
136
172
|
}
|
|
137
173
|
```
|
|
138
174
|
|
|
139
|
-
|
|
175
|
+
#### `printcheck.config.js`
|
|
140
176
|
|
|
141
177
|
```js
|
|
142
178
|
export default {
|
|
@@ -150,18 +186,6 @@ export default {
|
|
|
150
186
|
Config files are auto-discovered from the current directory upward.
|
|
151
187
|
CLI flags always override config file values.
|
|
152
188
|
|
|
153
|
-
## Tech Stack
|
|
154
|
-
|
|
155
|
-
| Package | Purpose |
|
|
156
|
-
| ------------------------------------------------------- | ----------------------------------------------------------- |
|
|
157
|
-
| [mupdf](https://www.npmjs.com/package/mupdf) (mupdf.js) | PDF engine — WASM-powered, deep PDF object traversal |
|
|
158
|
-
| [pdf-lib](https://www.npmjs.com/package/pdf-lib) | Supplemental — reading page boxes (TrimBox, BleedBox, etc.) |
|
|
159
|
-
| [commander](https://www.npmjs.com/package/commander) | CLI framework |
|
|
160
|
-
| [picocolors](https://www.npmjs.com/package/picocolors) | Terminal colors |
|
|
161
|
-
| [zod](https://www.npmjs.com/package/zod) | CLI option validation |
|
|
162
|
-
| [tsup](https://www.npmjs.com/package/tsup) | TypeScript build |
|
|
163
|
-
| [vitest](https://www.npmjs.com/package/vitest) | Testing |
|
|
164
|
-
|
|
165
189
|
## Project Structure
|
|
166
190
|
|
|
167
191
|
```
|
|
@@ -200,6 +224,14 @@ npm run format:check # Prettier check
|
|
|
200
224
|
|
|
201
225
|
See [CONTRIBUTING.md](CONTRIBUTING.md) for full development guidelines.
|
|
202
226
|
|
|
227
|
+
## Deployment
|
|
228
|
+
|
|
229
|
+
Published to npm via GitHub Actions with [OIDC trusted publishing](https://docs.npmjs.com/generating-provenance-statements). Every release includes a verified provenance attestation.
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
npm install -g print-check-cli
|
|
233
|
+
```
|
|
234
|
+
|
|
203
235
|
## Known Limitations (MVP)
|
|
204
236
|
|
|
205
237
|
- **mupdf PDFObject nulls** — mupdf.js returns PDFObject wrappers with `.isNull() === true` rather than JavaScript `null`. All mupdf access goes through `src/engine/pdf-utils.ts` safe wrappers to handle this.
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { Command } from "commander";
|
|
|
5
5
|
import { z as z2 } from "zod";
|
|
6
6
|
import * as fs3 from "fs";
|
|
7
7
|
import * as path2 from "path";
|
|
8
|
+
import { createRequire } from "module";
|
|
8
9
|
|
|
9
10
|
// src/checks/bleed-trim.ts
|
|
10
11
|
var PT_TO_MM = 25.4 / 72;
|
|
@@ -107,7 +108,7 @@ function collectFonts(fontDict, pageNum, seen) {
|
|
|
107
108
|
safeForEach(fontDict, (value, key) => {
|
|
108
109
|
const font = safeResolve(value);
|
|
109
110
|
if (!font) return;
|
|
110
|
-
const baseFontName = safeName(safeGet(font, "BaseFont")) ?? key;
|
|
111
|
+
const baseFontName = safeName(safeGet(font, "BaseFont")) ?? String(key);
|
|
111
112
|
if (seen.has(baseFontName)) return;
|
|
112
113
|
seen.add(baseFontName);
|
|
113
114
|
const subtype = safeName(safeGet(font, "Subtype"));
|
|
@@ -825,12 +826,18 @@ async function loadConfig() {
|
|
|
825
826
|
}
|
|
826
827
|
|
|
827
828
|
// src/index.ts
|
|
829
|
+
var require2 = createRequire(import.meta.url);
|
|
830
|
+
var { version } = require2("../package.json");
|
|
831
|
+
var SEVERITY_LEVELS = ["fail", "warn", "off"];
|
|
832
|
+
function isSeverityOverride(level) {
|
|
833
|
+
return SEVERITY_LEVELS.includes(level);
|
|
834
|
+
}
|
|
828
835
|
function parseSeverityString(val) {
|
|
829
836
|
if (!val.trim()) return {};
|
|
830
837
|
const result = {};
|
|
831
838
|
for (const pair of val.split(",")) {
|
|
832
839
|
const [check, level] = pair.split(":").map((s) => s.trim());
|
|
833
|
-
if (check && level) result[check] = level;
|
|
840
|
+
if (check && level && isSeverityOverride(level)) result[check] = level;
|
|
834
841
|
}
|
|
835
842
|
return result;
|
|
836
843
|
}
|
|
@@ -875,7 +882,7 @@ var OptionsSchema = z2.object({
|
|
|
875
882
|
]).default({})
|
|
876
883
|
});
|
|
877
884
|
var program = new Command();
|
|
878
|
-
program.name("print-check").description("Validate print-ready PDF files").version(
|
|
885
|
+
program.name("print-check").description("Validate print-ready PDF files").version(version).argument("<files...>", "PDF file(s) to check").option("--min-dpi <number>", "Minimum acceptable DPI").option("--color-space <mode>", "Expected color space: cmyk | any").option("--bleed <mm>", "Required bleed in mm").option("--max-tac <percent>", "Maximum total ink coverage %").option("--page-size <WxH>", "Expected page size in mm (e.g. 210x297)").option("--checks <list>", "Comma-separated checks to run", "all").option("--verbose", "Show detailed per-page results", false).option("--format <type>", "Output format: text | json", "text").option("--profile <name>", "Print profile: standard | magazine | newspaper | large-format").option("--severity <overrides>", "Per-check severity: check:level,... (fail|warn|off)").action(async (files, rawOpts) => {
|
|
879
886
|
const config = await loadConfig();
|
|
880
887
|
const stripped = {};
|
|
881
888
|
for (const [key, value] of Object.entries(rawOpts)) {
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "print-check-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"print-check": "./dist/index.js"
|
|
7
7
|
},
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "tsup",
|
|
10
|
+
"typecheck": "tsc --noEmit",
|
|
10
11
|
"dev": "tsx src/index.ts",
|
|
11
12
|
"test": "vitest run",
|
|
12
13
|
"test:coverage": "vitest run --coverage",
|
|
@@ -57,10 +58,10 @@
|
|
|
57
58
|
]
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
|
60
|
-
"@eslint/js": "^
|
|
61
|
-
"@types/node": "^
|
|
61
|
+
"@eslint/js": "^10.0.1",
|
|
62
|
+
"@types/node": "^26.0.0",
|
|
62
63
|
"@vitest/coverage-v8": "^4.0.18",
|
|
63
|
-
"eslint": "^
|
|
64
|
+
"eslint": "^10.5.0",
|
|
64
65
|
"eslint-config-prettier": "^10.1.8",
|
|
65
66
|
"husky": "^9.1.7",
|
|
66
67
|
"lint-staged": "^16.2.7",
|