refactor(cli): extract withLocal helper for client-free commands#185
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
statsandconvertboth built their ownconst analytics = new Analytics(); try { … } catch (error) { handleCommandError(…) }shell — the same patternwithClientalready encapsulates for client-using commands.withLocal(commandName, handler)that skips config loading andConfluenceClientconstruction but keeps the analytics + error contract identical. Apply to both commands.convert(process.exiton missing/invalid format flags) are intentionally left alone — that's a separate pattern from whatwithLocaladdresses, and rewriting them would be scope creep.Test plan
npm test— 682/682 pass (added 2 tests inwith-client.test.jscovering the happy path and the failure-track path forwithLocal)npm run lint— cleanConfluenceClientinstantiation in the local path via spy