Skip to content

chore(deps): bump commander to 15.1.0 and add CLI tests - #627

Merged
bkendall merged 2 commits into
mainfrom
bump_commander_esm
Dec 4, 2026
Merged

bkendall merged 2 commits into
mainfrom
bump_commander_esm

Conversation

@bkendall

@bkendall bkendall commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator

Supersedes #582.

Summary

  • Bumps commander from ^10.0.0 (10.0.1) to ^15.1.0 (15.1.0).
  • Tightens engines.node from 22 || 24 || 26 to ^22.12.0 || 24 || 26 to align with Commander 15's ESM-only require(esm) requirement (>=22.12.0).
  • Extracts createCli in src/cli/index.ts (preserving the default cli export) so CLI option parsing and .env.json handling can be tested cleanly in isolation.
  • Adds test/unit/cli.spec.ts covering Commander ESM loading from CJS, default and custom CLI flags (including --host/--hostname), invalid port fallback, --version, Commander 13+ excess positional argument rejection, .env.json loading, and a real server smoke test.

Verification

  • npm test (eslint + nyc mocha): 365 passing (src/cli/index.ts at 100% statements/functions/lines)
  • npm run build & npm run prepare
  • npm run license:check
  • npm install --package-lock-only --ignore-scripts --registry=https://registry.npmjs.org (no lockfile diff)
  • Verified CLI tests and compiled lib/bin/server.js on Node v24.22.1 and Node v26.12.1

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the Superstatic CLI to support better testability by introducing a createCli factory function that allows overriding dependencies like the server factory, working directory, and environment variables. It also upgrades the commander dependency to version 15.1.0 and adds a comprehensive suite of unit tests. Feedback on these changes includes improving port validation to prevent runtime crashes with invalid port numbers, and moving the server startup log inside the listen callback while dynamically resolving the bound port to handle dynamic port allocation (port 0) correctly.

Comment thread src/cli/index.ts Resolved
Comment thread src/cli/index.ts Resolved
@bkendall
bkendall requested a review from joehan December 4, 2026 18:57
@bkendall
bkendall merged commit bc97a08 into main Dec 4, 2026
25 checks passed
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.

2 participants