From 395528da3251a80e9fa31645e8b617eaff703340 Mon Sep 17 00:00:00 2001 From: saurabhsharma2u <41580629+saurabhsharma2u@users.noreply.github.com> Date: Wed, 25 Feb 2026 14:28:50 +0000 Subject: [PATCH] Move sitegraph HTML template to separate file for better maintainability - Extracted embedded HTML string from `plugins/core/src/report/sitegraph_template.ts` to `plugins/core/src/report/sitegraph.html`. - Updated `sitegraph_template.ts` to read the HTML file content at runtime using `fs.readFileSync`. - Added `plugins/core/scripts/copy-assets.js` to handle copying the HTML file to `dist` directory during build. - Updated `plugins/core/package.json` build script to execute the copy script. - Fixed escaping issues in the HTML template that were artifacts of TS template literal usage. - Verified functionality with existing tests. --- plugins/core/package.json | 2 +- plugins/core/scripts/copy-assets.js | 10 + plugins/core/src/report/sitegraph.html | 629 +++++++++++++++++ plugins/core/src/report/sitegraph_template.ts | 635 +----------------- 4 files changed, 647 insertions(+), 629 deletions(-) create mode 100644 plugins/core/scripts/copy-assets.js create mode 100644 plugins/core/src/report/sitegraph.html diff --git a/plugins/core/package.json b/plugins/core/package.json index da2b521..728f983 100644 --- a/plugins/core/package.json +++ b/plugins/core/package.json @@ -12,7 +12,7 @@ } }, "scripts": { - "build": "tsc", + "build": "tsc && node scripts/copy-assets.js", "test": "vitest run" }, "dependencies": { diff --git a/plugins/core/scripts/copy-assets.js b/plugins/core/scripts/copy-assets.js new file mode 100644 index 0000000..7bdf1dd --- /dev/null +++ b/plugins/core/scripts/copy-assets.js @@ -0,0 +1,10 @@ +import fs from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const src = path.join(__dirname, '../src/report/sitegraph.html'); +const dest = path.join(__dirname, '../dist/report/sitegraph.html'); + +fs.copyFileSync(src, dest); diff --git a/plugins/core/src/report/sitegraph.html b/plugins/core/src/report/sitegraph.html new file mode 100644 index 0000000..9cb0191 --- /dev/null +++ b/plugins/core/src/report/sitegraph.html @@ -0,0 +1,629 @@ + + + + + + Crawlith Site Graph + + + +
+
Crawlith SiteGraph
+ +
+
-Pages
+
-Max Depth
+
-Efficiency
+
-Orphans
+
+ +
+
+ + +
+
+ + +
+
+
+ +
+
+
+ +
+ +
+
+ + +
+ + + + + + + + + diff --git a/plugins/core/src/report/sitegraph_template.ts b/plugins/core/src/report/sitegraph_template.ts index 75f7549..31f1171 100644 --- a/plugins/core/src/report/sitegraph_template.ts +++ b/plugins/core/src/report/sitegraph_template.ts @@ -1,630 +1,9 @@ -export const SITEGRAPH_HTML = ` - - - - - Crawlith Site Graph - - - -
-
Crawlith SiteGraph
- -
-
-Pages
-
-Max Depth
-
-Efficiency
-
-Orphans
-
- -
-
- - -
-
- - -
-
-
- -
-
-
- -
- -
-
- - -
- - - - - - - - - -`; +export const SITEGRAPH_HTML = fs.readFileSync(templatePath, 'utf-8');