Skip to content

🧹 Refactor duplicated visualization logic in CLI export#33

Closed
saurabhsharma2u wants to merge 2 commits into
mainfrom
refactor-visualization-logic-8510790301748958396
Closed

🧹 Refactor duplicated visualization logic in CLI export#33
saurabhsharma2u wants to merge 2 commits into
mainfrom
refactor-visualization-logic-8510790301748958396

Conversation

@saurabhsharma2u

Copy link
Copy Markdown
Contributor

This PR addresses the "Duplicated Graph Visualization Code" issue by refactoring plugins/cli/src/utils/exportRunner.ts.

It replaces the duplicated inline logic for generating the visualize format report with the shared generateHtml function from @crawlith/core.

Key changes:

  • Modified plugins/cli/src/utils/exportRunner.ts to use generateHtml for the visualize export format.
  • Removed unused SITEGRAPH_HTML import in plugins/cli.
  • Added a new test file plugins/cli/tests/exportRunner.test.ts to verify the export functionality.

Verification:

  • Ran the new test plugins/cli/tests/exportRunner.test.ts which confirms that sitegraph.html is generated correctly with window.GRAPH_DATA injected.
  • Ran all tests in plugins/cli and plugins/core to ensure no regressions.
  • Confirmed that generateHtml correctly handles node sanitization (removing html property) and JSON escaping via safeJson.

Result:
The codebase is now cleaner with less duplication, and the visualization report generation is centralized in @crawlith/core.


PR created automatically by Jules for task 8510790301748958396 started by @saurabhsharma2u

Consolidate visualization logic by replacing manual HTML generation in `plugins/cli/src/utils/exportRunner.ts` with `generateHtml` from `@crawlith/core`.
This ensures consistent and secure (minified + escaped) JSON output for both `html` and `visualize` export formats.

- Remove `SITEGRAPH_HTML` import in `exportRunner.ts`
- Replace inline HTML generation with `generateHtml` call
- Add `plugins/cli/tests/exportRunner.test.ts` to verify export functionality
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Make the file path assertion in `plugins/cli/tests/exportRunner.test.ts` cross-platform by normalizing path separators.
This resolves an `AssertionError` on Windows where `mock.calls` contained backslashes.

- Normalize backslashes to forward slashes in test assertion
- Check for suffix `output/sitegraph.html` instead of exact path match
@saurabhsharma2u

Copy link
Copy Markdown
Contributor Author

Closing as this refactoring was already completed and merged in PR 37.

@saurabhsharma2u
saurabhsharma2u deleted the refactor-visualization-logic-8510790301748958396 branch February 25, 2026 19:20
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