Skip to content

refactor(cli): finish withClient migration — comment + tests#182

Merged
pchuri merged 2 commits into
mainfrom
refactor/comment-with-client
May 11, 2026
Merged

refactor(cli): finish withClient migration — comment + tests#182
pchuri merged 2 commits into
mainfrom
refactor/comment-with-client

Conversation

@pchuri
Copy link
Copy Markdown
Owner

@pchuri pchuri commented May 11, 2026

Summary

  • Migrate the comment command — the last client-using command still on the old manual scaffolding after refactor(cli): extract withClient helper to remove command boilerplate #181 — onto withClient, via a new onError(error, ...actionArgs) hook that preserves the command's API-response dump and inline-meta hint.
  • Add the first direct unit tests for the withClient wrapper (6 cases). Until now this shared error/analytics/client path on every server-touching command had zero direct coverage.

Why

Follow-up to the review of #181:

  1. The automated release is failing 🚨 #1 in the review: the commit message claimed all 26 client-using commands were extracted, but comment was left on the old pattern because its catch block does extra work. The new onError hook gives it a place to live.
  2. feat: Enhanced Markdown Support with Bidirectional Conversion #5 in the review: 26 commands share withClient's try/exit/track path with no direct test. Any regression here would silently break every command's error handling.

The remaining DRY issue around handlers re-typing the command name in analytics.track('name', true) (#2) is intentionally left out to keep this PR small. It would touch all 26 handlers and is better as its own follow-up.

Test plan

  • npm test — 676 tests pass (16 suites), including the 6 new with-client.test.js cases
  • npm run lint — clean
  • Manual smoke: run confluence comment --help on a writable profile to confirm command still registers
  • Manual smoke: trigger an inline-comment error path to confirm the API response + inline-meta hints still print in the same order

🤖 Generated with Claude Code

pchuri and others added 2 commits May 11, 2026 11:57
The comment command was the only client-using command left with manual
analytics + getConfig + assertWritable + ConfluenceClient + try/catch
scaffolding after #181, because its catch block needed to print API
response details and inline-comment-specific hints.

Add an `onError(error, ...actionArgs)` option to withClient that runs
between the standard `Error:` log line and process.exit, and extend
handleCommandError with a matching `onExtra` callback. The hook is
wrapped in try/catch so a throwing hint path cannot break the error
flow. Move the comment command's API-response dump and inline-meta
hint into the hook. Existing behavior (output ordering, exit code,
failure tracking) is preserved.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The withClient helper sits on the shared error/analytics/client path for
every CLI command that talks to the server but had no direct test
coverage. Add six cases covering: context injection ({ client, config,
analytics } + forwarded action args), the writable-on-readOnly exit
path, failure tracking on handler throw, the new onError hook
(invocation order before process.exit, action-arg forwarding, throw
isolation), and getConfig failure being treated as a tracked failure.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@pchuri pchuri self-assigned this May 11, 2026
@pchuri pchuri merged commit 1899375 into main May 11, 2026
6 checks passed
@pchuri pchuri deleted the refactor/comment-with-client branch May 11, 2026 02:59
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 2.6.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant