import { resolve } from 'node:path'; import { checkDestinations, loadManifest, validateManifest } from './lib/migration.mjs'; const allowMissing = process.argv.slice(2).includes('--allow-missing'); const manifest = await loadManifest('docs/migration-manifest.json'); const { entries } = validateManifest(manifest); const result = await checkDestinations({ entries }, resolve('.')); console.log(`Migration manifest accounts for ${result.total} source pages.`); for (const destination of result.missing) { console.log(`Missing destination: ${destination}`); } for (const destination of result.notFiles) { console.log(`Destination is not a regular file: ${destination}`); } if ((result.missing.length > 0 && !allowMissing) || result.notFiles.length > 0) { console.error(`Migration check failed: ${result.missing.length} destination file(s) are missing and ${result.notFiles.length} destination path(s) are not regular files.`); process.exitCode = 1; }