#!/usr/bin/env node
// Postinstall step: copy @holepunchto/keet-core + 12 private peer packages
// from the local keet-audit-4.x mirror into node_modules/@holepunchto/.
// These are not on public npm so cannot be declared as dependencies; instead
// the audit script extracts them from the Keet AppImage and we mirror them
// in here at install time.
//
// Idempotent: safe to re-run, overwrites existing.
const fs = require('fs')
const path = require('path')
// keet-4.17.3 era (Keet 4.17.2). Source = holepunchto-deps/@holepunchto (the CI
// overlay-keet-core source), which holds the full 4.17.3 set. keet-room-registry
// is a NEW keet-core 4.17.x dependency; keet-schemas was dropped (not imported by
// keet-daemon, not a keet-core dep). Refresh holepunchto-deps from a current
// keet-audit-<version> extraction when bumping keet-core. See keet-abi-upgrades skill.
const PKGS = [
'keet-core',
'call-swarm', // NEW keet-core 4.22.x dep (Keet 4.22.5)
'keet-room-registry',
'hyperdiscovery',
'hyperindex',
'keet-call',
'keet-core-api',
'keet-core-schemas',
'keet-debug-helper',
'keet-default-config',
'keet-indexing',
'keet-push',
'keet-registry',
'keet-registry-client',
'keet-registry-schema',
'keet-unread-anchors',
'legacy-keet-core-schemas'
]
const repoRoot = path.resolve(__dirname, '..')
const mirrorDir = path.resolve(repoRoot, '..', '..', 'holepunchto-deps', '@holepunchto')
const targetDir = path.join(repoRoot, 'node_modules', '@holepunchto')
if (!fs.existsSync(mirrorDir)) {
console.error('[copy-keet-core-mirror] mirror not found at ' + mirrorDir)
console.error('[copy-keet-core-mirror] expected layout: hyper-fleeky/holepunchto-deps/@holepunchto/<pkg>/')
process.exit(1)
}
fs.mkdirSync(targetDir, { recursive: true })
let copied = 0
let skipped = 0
for (const pkg of PKGS) {
const src = path.join(mirrorDir, pkg)
const dst = path.join(targetDir, pkg)
if (!fs.existsSync(src)) {
console.error('[copy-keet-core-mirror] WARN missing in mirror: ' + pkg)
skipped++
continue
}
fs.rmSync(dst, { recursive: true, force: true })
fs.cpSync(src, dst, { recursive: true, dereference: true })
copied++
}
console.log('[copy-keet-core-mirror] copied ' + copied + ' pkgs from keet-audit-4.x (skipped ' + skipped + ')')