Skip to content

chore: update for build, config, CLI and tests:#423

Merged
modesty merged 10 commits intomasterfrom
scratch/infraEnhance
Apr 16, 2026
Merged

chore: update for build, config, CLI and tests:#423
modesty merged 10 commits intomasterfrom
scratch/infraEnhance

Conversation

@modesty
Copy link
Copy Markdown
Owner

@modesty modesty commented Apr 15, 2026

Build System

  • tsconfig.json: Removed dead decorator options; updated moduleResolution/module to node16; disabled unused importHelpers
  • package.json: Fixed exports map with proper types entries for both ESM and CJS TypeScript consumers; removed unused tslib dependency; added test:coverage script
  • rollup.config.js: Enabled tree-shaking for CLI bundle; removed dead code; documented build order dependency
  • .prettierrc.cjs: Inlined config to remove missing prettier-config-standard dependency

CLI (src/cli/)

  • 7 bug fixes: Promise constructor anti-pattern, callback fs.writeFile/fs.readdir replaced with fs.promises, addResultCount type mismatch, dead warningCount removed, TOCTOU race condition in validateParams removed, broken --singleton flag fixed (now shares parser instance from PDFCLI level), -si short flag parsing bug fixed
  • New --json flag: Structured JSON summary to stdout (version, output paths, stats, errors, elapsed time) for programmatic consumption and Claude Code Skill integration
  • New --quiet flag: Suppresses all non-error output including timer and status messages
  • Granular exit codes: 0=success, 1=parse failure, 2=argument error, 3=I/O error (previously only 0 or 1)
  • Improved directory filter: Only skips dotfiles now (previously silently skipped files starting with -, _, spaces, etc.)
  • Enhanced help output: Accurate flag descriptions, usage examples, and exit code documentation

Tests

  • 3 new test suites (22 new tests): CLI integration (_test_cli.cjs), Stream API (_test_stream.cjs), Error paths (_test_errors.cjs) -- all previously had zero coverage
  • Fixed existing tests: Listener leak in multi-parse test (once() + removeAllListeners()); standardized on Jest expect() over Node assert(); restored VLines/HLines/Fills/Texts count assertions that were commented out
  • Renamed misleading _test_getRawTextContent.cjs to _test_sortBidiTexts.cjs
  • Regenerated 37 baseline files to reflect current parser output (baselines were stale since v0.6.8)
  • Test count: 52 tests / 4 suites -> 74 tests / 7 suites

CI & Polish

  • CI workflow: Upgraded to actions v4; added tsc --noEmit type-check step; added coverage step
  • ESLint: Removed deprecated no-extra-semi and no-var-requires rules
  • CLAUDE.md: Added CLI flags table, exit codes, and test suite listing

modesty and others added 10 commits April 14, 2026 18:37
Build System

  - tsconfig.json: Removed dead decorator options; updated moduleResolution/module to node16; disabled
  unused importHelpers
  - package.json: Fixed exports map with proper types entries for both ESM and CJS TypeScript consumers;
  removed unused tslib dependency; added test:coverage script
  - rollup.config.js: Enabled tree-shaking for CLI bundle; removed dead code; documented build order
  dependency
  - .prettierrc.cjs: Inlined config to remove missing prettier-config-standard dependency

  CLI (src/cli/)

  - 7 bug fixes: Promise constructor anti-pattern, callback fs.writeFile/fs.readdir replaced with
  fs.promises, addResultCount type mismatch, dead warningCount removed, TOCTOU race condition in
  validateParams removed, broken --singleton flag fixed (now shares parser instance from PDFCLI level), -si
  short flag parsing bug fixed
  - New --json flag: Structured JSON summary to stdout (version, output paths, stats, errors, elapsed time)
  for programmatic consumption and Claude Code Skill integration
  - New --quiet flag: Suppresses all non-error output including timer and status messages
  - Granular exit codes: 0=success, 1=parse failure, 2=argument error, 3=I/O error (previously only 0 or 1)
  - Improved directory filter: Only skips dotfiles now (previously silently skipped files starting with -,
  _, spaces, etc.)
  - Enhanced help output: Accurate flag descriptions, usage examples, and exit code documentation

  Tests

  - 3 new test suites (22 new tests): CLI integration (_test_cli.cjs), Stream API (_test_stream.cjs), Error
  paths (_test_errors.cjs) -- all previously had zero coverage
  - Fixed existing tests: Listener leak in multi-parse test (once() + removeAllListeners()); standardized on
   Jest expect() over Node assert(); restored VLines/HLines/Fills/Texts count assertions that were commented
   out
  - Renamed misleading _test_getRawTextContent.cjs to _test_sortBidiTexts.cjs
  - Regenerated 37 baseline files to reflect current parser output (baselines were stale since v0.6.8)
  - Test count: 52 tests / 4 suites -> 74 tests / 7 suites

  CI & Polish

  - CI workflow: Upgraded to actions v4; added tsc --noEmit type-check step; added coverage step
  - ESLint: Removed deprecated no-extra-semi and no-var-requires rules
  - CLAUDE.md: Added CLI flags table, exit codes, and test suite listing
npm ci was crashing with "Exit handler never called!" because the
package-lock.json was generated with npm 11.x (Node 22) but CI ran
npm 10.8.2 (Node 20.18.0). This left node_modules empty, causing
all subsequent build steps to fail. Node 22 LTS also satisfies the
^20.19.0 engine requirements of eslint devDependencies.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…atch

npm ci crashes with "Exit handler never called!" because the
package-lock.json was generated with npm 11.x but CI runs npm 10.9.7
(bundled with Node 22). npm ci is strict about lockfile compatibility.
npm install resolves dependencies fresh, matching the previous CI
behavior (rm -rf node_modules && npm i).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix mkdir error handling in validateParams: replace try/finally with
  try/catch so mkdir failures set the error string and return exit code 3
  (EXIT_IO_ERROR) instead of propagating as an unhandled rejection

- Reorder validation guards in initialize(): check Array.isArray before
  typeof string so users passing -f multiple times get the specific
  "can only be specified once" error instead of a generic message

- Use structured .code property instead of string-matching on
  error.message for I/O error classification, preventing misclassification
  if a PDF engine error message happens to contain errno strings

- Restore diagnostic console.error in _test_.cjs catch path so CI logs
  show which PDF caused a failure

- Fix stream test to use os.tmpdir() instead of test/target/ to prevent
  ENOENT on clean checkout

- Re-enable baseline diff validation in p2j.one.sh now that all 37
  baselines have been regenerated

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@modesty modesty merged commit eed63fb into master Apr 16, 2026
1 check passed
@modesty modesty deleted the scratch/infraEnhance branch April 16, 2026 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant