#!/usr/bin/env node import fs from 'node:fs' import path from 'node:path' import process from 'node:process' import { fileURLToPath } from 'node:url' const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..') const booterPkgPath = path.join(root, 'packages/bare-os-booter/package.json') const outPath = path.join(root, 'docs/audit/holepunch-runtime-compat.json') const mirrorRoot = String( process.env.BARE_OS_HOLEPUNCH_CLONES_ROOT || path.join(process.env.HOME || '', 'dev/pearcli/holepunch-repos/holepunchto_repos') ).trim() const CORE_REPOS = [ 'bare-runtime', 'bare-module', 'bare-fs', 'bare-net', 'hypercore', 'corestore', 'hyperdrive', 'hyperdht', 'hyperswarm', 'pear', 'pear-runtime' ] function readJson(p, fallback = null) { try { return JSON.parse(fs.readFileSync(p, 'utf8')) } catch { return fallback } } function main() { const booterPkg = readJson(booterPkgPath, {}) const deps = { ...(booterPkg.dependencies || {}), ...(booterPkg.optionalDependencies || {}) } const rows = CORE_REPOS.map((repo) => { const clonePkgPath = path.join(mirrorRoot, repo, 'package.json') const clonePkg = readJson(clonePkgPath, {}) const cloneVersion = String(clonePkg?.version || '').trim() const depRange = String(deps[repo] || '').trim() return { repo, booterRange: depRange || null, cloneVersion: cloneVersion || null, clonePath: path.join(mirrorRoot, repo), rangeMentionsLocalFile: depRange.startsWith('file:'), semverDrift: Boolean(depRange && cloneVersion && !depRange.includes(cloneVersion)) } }) const out = { schema: 1, generatedAt: new Date().toISOString(), mirrorRoot, booterPackage: path.relative(root, booterPkgPath), rows } fs.mkdirSync(path.dirname(outPath), { recursive: true }) fs.writeFileSync(outPath, JSON.stringify(out, null, 2) + '\n', 'utf8') console.log( 'report-holepunch-runtime-compat: wrote', path.relative(root, outPath), 'rows=', rows.length ) } main()