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

29 lines
1.3 KiB
JavaScript
Raw Normal View History

import { readFileSync, readdirSync, existsSync } from 'fs';
import { join } from 'path';
// TODO(MediaEngine extraction): this audits legacy pre-SvelteKit `<project>/public/*.html`
// script tags. MediaEngine's webui/ is SvelteKit-based (no per-service `public/` HTML pages), and
// 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.
const projects = ['MediaModerator', 'MediaTools', 'MediaKiosk', 'MediaViewer'];
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();
});