Files
CollabTable/shared/scripts/media/audit-html-js.mjs
T

29 lines
1.3 KiB
JavaScript
Raw Normal View History

2026-09-01 08:43:25 +02:00
import { readFileSync, readdirSync, existsSync } from 'fs';
import { join } from 'path';
// TODO(shared extraction): this audits legacy pre-SvelteKit `<project>/public/*.html`
// script tags. this repo's webui/ is SvelteKit-based (no per-service `public/` HTML pages), and
2026-09-01 08:43:25 +02:00
// none of the sibling monorepo service directories below live inside this repo anymore (they're
// now separate repos: MediaModerator, MediaTools, MediaKiosk, MediaViewer). The existsSync guard
// below means this currently no-ops safely (nothing to audit) rather than erroring. Left as-is
// rather than guessing at a SvelteKit-equivalent audit — remove or repurpose if useful.
2026-09-06 22:50:38 +02:00
const projects = ['MediaModerator', 'CraftStudio', 'MediaKiosk', 'MediaViewer'];
2026-09-01 08:43:25 +02:00
const scriptSrcRe = /<script[^>]+src="([^"]+)"[^>]*>/g;
projects.forEach(proj => {
const pubDir = join(proj, 'public');
if (!existsSync(pubDir)) return;
const htmlFiles = readdirSync(pubDir)
.filter(f => f.endsWith('.html'))
.sort();
console.log(`=== ${proj} ===`);
htmlFiles.forEach(htmlFile => {
const content = readFileSync(join(pubDir, htmlFile), 'utf8');
const scripts = [];
let m;
scriptSrcRe.lastIndex = 0;
while ((m = scriptSrcRe.exec(content)) !== null) scripts.push(m[1]);
console.log(` ${htmlFile} -> ${scripts.join(', ')}`);
});
console.log();
});