refactor(cli): split bin/confluence.js into domain command modules#186
Merged
Conversation
Move `profile list/use/add/remove` into a dedicated module and migrate the four actions onto the `withLocal` helper so they share the standard analytics + error pipeline instead of inline try/catch + process.exit(1).
Move `versions`, `version-delete`, and `versions-purge` into a dedicated module. No behavior changes — same prompts, exit codes, and analytics keys.
…s.js Move `attachments`, `attachment-upload`, and `attachment-delete` into a dedicated module. The download path's inline `sanitizeFilename` is duplicated here rather than imported, keeping the module self-contained (the export command keeps its own copy when it moves out next).
Move `property-list`, `property-get`, `property-set`, and `property-delete` into a dedicated module.
Move `comments`, `comment`, and `comment-delete` into a dedicated module along with their three rendering helpers (`parseLocationOptions`, `formatBodyBlock`, `buildCommentTree`), which are only used here. The `comment_create` onError hint and the `comment_delete_cancel` analytics key are preserved.
…ort.js Move the `export` command along with EXPORT_MARKER and its six helpers (writeExportMarker, isExportDirectory, sanitizeFilename, uniquePathFor, writeStream, sanitizeTitle, exportRecursive) into a dedicated module. The helpers are re-exposed from the new module for unit testing; the `_test` block in bin/confluence.js drops them since they no longer live there, and tests/export.test.js imports directly from the new module.
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
bin/confluence.jsinto dedicated modules underbin/commands/: profile, versions, attachments, properties, comment, export.bin/confluence.jsfrom 2077 → 869 lines (−58%); each new module is self-contained with its ownrequires and registers via a smallregister*(program, { withClient | withLocal })function called from the entrypoint.profile *actions onto thewithLocalhelper so they share the standard analytics + error pipeline instead of inlinetry/catch + process.exit(1)(knocks out part of the unmigrated-commands review finding).EXPORT_MARKER,writeExportMarker,isExportDirectory,sanitizeFilename,uniquePathFor,writeStream,sanitizeTitle,exportRecursive) intobin/commands/export.js;tests/export.test.jsnow imports them directly from the new module instead of via the_testblock.Each commit is one group, in extraction order: profile → versions → attachments → properties → comment → export. Diffs per commit are small and independently reviewable.
What did NOT change
comment_createonErrorhint and the*_cancelanalytics keys are intact.withClient/withLocalhelpers themselves are unchanged.attachmentsandexportboth needsanitizeFilename; rather than introducing a shared util layer, each module keeps its own copy. Easy to refactor later if more duplication appears.Test plan
npx jest— 16 suites / 682 tests pass after every commitnpx eslint bin/ tests/— cleannode bin/index.js --helplists all 33 commands--helpfor one command in each extracted group preserves option list verbatimconfluence profile add "bad name"triggers the newwithLocalerror pipeline (Error: Invalid profile name..., exit 1)