#!/usr/bin/env node /** * Verify pear tier entries in the manifest. * For the initial shared-manifest approach, validates that pearEntries (if present) * has the expected shape and no obvious structural problems. * * Run from repo root: node scripts/verify-pear-module-manifest-data.mjs */ import { readFile } from 'node:fs/promises' import { dirname, join } from 'node:path' import { fileURLToPath } from 'node:url' const __dirname = dirname(fileURLToPath(import.meta.url)) const root = join(__dirname, '..') const manifestPath = join(root, 'packages/bare-os-booter/lib/bare-module-manifest.json') async function main() { const raw = await readFile(manifestPath, 'utf8') const manifest = JSON.parse(raw) if (!manifest || typeof manifest !== 'object') { console.error('[verify-pear-module-manifest-data] invalid manifest root') process.exit(1) } const pearEntries = manifest.pearEntries if (!pearEntries) { console.log('[verify-pear-module-manifest-data] no pearEntries yet (ok for early stages)') return } if (!Array.isArray(pearEntries)) { console.error('[verify-pear-module-manifest-data] pearEntries must be an array') process.exit(1) } const required = ['ctxKey', 'package'] for (const [i, ent] of pearEntries.entries()) { if (!ent || typeof ent !== 'object') { console.error(`[verify-pear-module-manifest-data] entry ${i} is not an object`) process.exit(1) } for (const field of required) { if (!ent[field] || typeof ent[field] !== 'string') { console.error(`[verify-pear-module-manifest-data] entry ${i} missing or invalid ${field}`) process.exit(1) } } // Basic sanity: ctxKey should be camelCase starting with pear or bare for re-exports if (!/^[a-z][a-zA-Z0-9]*$/.test(ent.ctxKey)) { console.error(`[verify-pear-module-manifest-data] entry ${i} has invalid ctxKey format: ${ent.ctxKey}`) process.exit(1) } } console.log(`[verify-pear-module-manifest-data] ok — ${pearEntries.length} pearEntries`) } main().catch((e) => { console.error(e) process.exit(1) })