Skip to content

refactor(cli): extract withLocal helper for client-free commands#185

Merged
pchuri merged 1 commit into
mainfrom
refactor/with-local-helper
May 12, 2026
Merged

refactor(cli): extract withLocal helper for client-free commands#185
pchuri merged 1 commit into
mainfrom
refactor/with-local-helper

Conversation

@pchuri
Copy link
Copy Markdown
Owner

@pchuri pchuri commented May 12, 2026

Summary

  • stats and convert both built their own const analytics = new Analytics(); try { … } catch (error) { handleCommandError(…) } shell — the same pattern withClient already encapsulates for client-using commands.
  • Add a sibling withLocal(commandName, handler) that skips config loading and ConfluenceClient construction but keeps the analytics + error contract identical. Apply to both commands.
  • Inline validation errors inside convert (process.exit on missing/invalid format flags) are intentionally left alone — that's a separate pattern from what withLocal addresses, and rewriting them would be scope creep.

Test plan

  • npm test — 682/682 pass (added 2 tests in with-client.test.js covering the happy path and the failure-track path for withLocal)
  • npm run lint — clean
  • Verified no ConfluenceClient instantiation in the local path via spy

stats and convert duplicated the analytics + try/catch + handleCommandError
pipeline that withClient already encapsulates. Pull that out as a sibling
helper withLocal, which skips config loading and client construction but
keeps the same analytics/error contract. Apply to both commands.

Inline validation errors in convert (process.exit on missing/invalid
format flags) are left as-is — that pattern predates the refactor and
isn't what withLocal addresses.
@pchuri pchuri self-assigned this May 12, 2026
@pchuri pchuri merged commit 4d82c85 into main May 12, 2026
6 checks passed
@pchuri pchuri deleted the refactor/with-local-helper branch May 12, 2026 13:38
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