b273bb7aa2
Add a MindSpace public HTML checker for missing companion docx/PDF paths, wire it into runtime packaging and release-portal-runtime-prod.sh, and document the workflow for agents and ops. Co-authored-by: Cursor <cursoragent@cursor.com>
61 lines
2.2 KiB
JavaScript
61 lines
2.2 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Scan MindSpace public/*.html for broken relative links.
|
|
*
|
|
* Default (--downloads-only): attachment / download links only (release gate).
|
|
* --all-links: also check img/src and mindspace-cover assets.
|
|
*
|
|
* Usage:
|
|
* node scripts/check-mindspace-public-links.mjs
|
|
* node scripts/check-mindspace-public-links.mjs --user <uuid>
|
|
* node scripts/check-mindspace-public-links.mjs --root /path/to/MindSpace
|
|
* node scripts/check-mindspace-public-links.mjs --all-links
|
|
*/
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { scanPublicHtmlLinks } from '../mindspace-public-links.mjs';
|
|
|
|
const repoRoot = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
const DEFAULT_PUBLISH_ROOT = 'MindSpace';
|
|
|
|
function parseArgs(argv) {
|
|
let root = path.join(repoRoot, DEFAULT_PUBLISH_ROOT);
|
|
let userId = null;
|
|
let allLinks = false;
|
|
for (let i = 2; i < argv.length; i += 1) {
|
|
if (argv[i] === '--root' && argv[i + 1]) {
|
|
root = path.resolve(argv[i + 1]);
|
|
i += 1;
|
|
} else if (argv[i] === '--user' && argv[i + 1]) {
|
|
userId = argv[i + 1];
|
|
i += 1;
|
|
} else if (argv[i] === '--all-links') {
|
|
allLinks = true;
|
|
} else if (argv[i] === '--downloads-only') {
|
|
allLinks = false;
|
|
} else if (argv[i] === '--help' || argv[i] === '-h') {
|
|
console.log(
|
|
`Usage: node scripts/check-mindspace-public-links.mjs [--root ${DEFAULT_PUBLISH_ROOT}] [--user <uuid>] [--downloads-only|--all-links]`,
|
|
);
|
|
process.exit(0);
|
|
}
|
|
}
|
|
return { root, userId, downloadsOnly: !allLinks };
|
|
}
|
|
|
|
const { root, userId, downloadsOnly } = parseArgs(process.argv);
|
|
const issues = scanPublicHtmlLinks(root, { userId, downloadsOnly });
|
|
const modeLabel = downloadsOnly ? 'download/attachment links' : 'all relative links';
|
|
|
|
if (issues.length === 0) {
|
|
console.log(`OK: no missing ${modeLabel} under ${root}${userId ? ` (user ${userId})` : ''}`);
|
|
process.exit(0);
|
|
}
|
|
|
|
console.error(`Found ${issues.length} missing ${modeLabel} under ${root}:`);
|
|
for (const issue of issues) {
|
|
const relHtml = path.relative(root, issue.htmlPath);
|
|
console.error(`- ${relHtml}: ${issue.ref} (${issue.source})`);
|
|
}
|
|
process.exit(1);
|