diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bb54630..d25958b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,8 +24,6 @@ jobs: - name: Setup pnpm uses: pnpm/action-setup@v4 - with: - version: 10 - name: Install Dependencies run: pnpm install diff --git a/package.json b/package.json index a74eb68..3f0a850 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "engines": { "node": ">=20.0.0" }, + "packageManager": "pnpm@9.15.4", "dependencies": { "vite": "7.3.1" } diff --git a/plugins/cli/src/utils/exportRunner.ts b/plugins/cli/src/utils/exportRunner.ts index 08fedb9..b5de965 100644 --- a/plugins/cli/src/utils/exportRunner.ts +++ b/plugins/cli/src/utils/exportRunner.ts @@ -2,7 +2,7 @@ import path from 'node:path'; import fs from 'node:fs/promises'; import chalk from 'chalk'; import { - generateHtml, + renderSitegraphHtml, renderSitegraphMarkdown, renderSitegraphCsvNodes, renderSitegraphCsvEdges, @@ -37,13 +37,13 @@ export async function runSitegraphExports( } if (formats.includes('html')) { - const html = generateHtml(graphData, metrics); + const html = renderSitegraphHtml(graphData, metrics); await fs.writeFile(path.join(outputDir, 'graph.html'), html); console.log(chalk.green(`HTML report saved to ${path.join(outputDir, 'graph.html')}`)); } if (formats.includes('visualize')) { - const siteGraphHtml = generateHtml(graphData, metrics); + const siteGraphHtml = renderSitegraphHtml(graphData, metrics); await fs.writeFile(path.join(outputDir, 'sitegraph.html'), siteGraphHtml); console.log(chalk.green(`Visualization saved to ${path.join(outputDir, 'sitegraph.html')}`)); } diff --git a/plugins/cli/tests/cli.test.ts b/plugins/cli/tests/cli.test.ts index 5e42c21..e185574 100644 --- a/plugins/cli/tests/cli.test.ts +++ b/plugins/cli/tests/cli.test.ts @@ -12,7 +12,7 @@ vi.mock('@crawlith/core', async (importOriginal) => { ...actual, crawl: vi.fn(), calculateMetrics: vi.fn(), - generateHtml: vi.fn(), + renderSitegraphHtml: vi.fn(), compareGraphs: vi.fn(), analyzeSite: vi.fn(), renderAnalysisHtml: vi.fn(), @@ -66,7 +66,7 @@ test('sitegraph command execution (DB-only, no file writes)', async () => { // No file writes in DB-only mode (only lock file from LockManager) expect(fs.mkdir).not.toHaveBeenCalled(); - expect(core.generateHtml).not.toHaveBeenCalled(); + expect(core.renderSitegraphHtml).not.toHaveBeenCalled(); // Verify snapshot ID is logged expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('snapshot #123')); @@ -95,13 +95,13 @@ test('sitegraph --html flag triggers file export', async () => { topPageRankPages: [], limitReached: false }); - vi.mocked(core.generateHtml).mockReturnValue(''); + vi.mocked(core.renderSitegraphHtml).mockReturnValue(''); const consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); await sitegraph.parseAsync(['https://example.com', '--limit', '10', '--export', 'html', '--output', 'test-output'], { from: 'user' }); - expect(core.generateHtml).toHaveBeenCalled(); + expect(core.renderSitegraphHtml).toHaveBeenCalled(); expect(fs.mkdir).toHaveBeenCalledWith(expect.stringContaining('test-output'), { recursive: true }); expect(fs.writeFile).toHaveBeenCalledWith(expect.stringContaining('graph.html'), ''); diff --git a/plugins/core/src/index.ts b/plugins/core/src/index.ts index 6334de0..94f200f 100644 --- a/plugins/core/src/index.ts +++ b/plugins/core/src/index.ts @@ -1,7 +1,6 @@ export * from './crawler/crawl.js'; export * from './crawler/metricsRunner.js'; export * from './graph/metrics.js'; -export * from './report/html.js'; export * from './report/sitegraph_template.js'; export * from './report/sitegraphExport.js'; export * from './graph/graph.js'; diff --git a/plugins/core/src/report/html.ts b/plugins/core/src/report/html.ts deleted file mode 100644 index 69e1312..0000000 --- a/plugins/core/src/report/html.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { Metrics } from '../graph/metrics.js'; -import { SITEGRAPH_HTML } from './sitegraph_template.js'; - -function safeJson(data: any): string { - return JSON.stringify(data).replace(/ { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const { html, ...rest } = n; - return rest; - }) : [] - }; - - const graphJson = safeJson(vizGraphData); - const metricsJson = safeJson(metrics); - - return SITEGRAPH_HTML.replace('', ` - `); -} diff --git a/plugins/core/src/report/sitegraphExport.ts b/plugins/core/src/report/sitegraphExport.ts index cba9383..894e749 100644 --- a/plugins/core/src/report/sitegraphExport.ts +++ b/plugins/core/src/report/sitegraphExport.ts @@ -1,3 +1,31 @@ +import { Metrics } from '../graph/metrics.js'; +import { SITEGRAPH_HTML } from './sitegraph_template.js'; + +function safeJson(data: any): string { + return JSON.stringify(data).replace(/ { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { html, ...rest } = n; + return rest; + }) : [] + }; + + const graphJson = safeJson(vizGraphData); + const metricsJson = safeJson(metrics); + + return SITEGRAPH_HTML.replace('', ` + `); +} + export function renderSitegraphCsvNodes(graphData: any): string { const nodeHeaders = ['URL', 'Depth', 'Status', 'InboundLinks', 'OutboundLinks', 'PageRankScore']; const nodeRows = graphData.nodes.map((n: any) => { diff --git a/plugins/core/tests/html_report.test.ts b/plugins/core/tests/html_report.test.ts index b68f012..fcac22c 100644 --- a/plugins/core/tests/html_report.test.ts +++ b/plugins/core/tests/html_report.test.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from 'vitest'; -import { generateHtml } from '../src/report/html.js'; +import { renderSitegraphHtml } from '../src/report/sitegraphExport.js'; import { Metrics } from '../src/graph/metrics.js'; describe('html report generator', () => { @@ -33,7 +33,7 @@ describe('html report generator', () => { edges: [] }; - const html = generateHtml(mockGraphData, mockMetrics); + const html = renderSitegraphHtml(mockGraphData, mockMetrics); // Check for template content expect(html).toContain(''); @@ -62,7 +62,7 @@ describe('html report generator', () => { topAuthorityPages: [], sessionStats: null }; - const html = generateHtml({ nodes: [], edges: [] }, mockMetrics as any); + const html = renderSitegraphHtml({ nodes: [], edges: [] }, mockMetrics as any); expect(html).toContain('window.METRICS_DATA ='); expect(html).toContain('"totalPages":10'); expect(html).toContain('"sessionStats":null');