/** * Seeder host entry for standalone binaries: optional pear-runtime OTA, then seeder main. * Kept next to the app so bare-pack traces `./index.js` reliably. */ import { name, version, upgrade } from '../../bin/meta/seeder.mjs' import { startPearOta, parseOtaFlags } from '../../lib/bare-os-ota.mjs' import { applyHostFlagsFromArgv } from '../../lib/bare-os-host-flags.mjs' function pathBasename(p) { const s = String(p || '') const i = Math.max(s.lastIndexOf('/'), s.lastIndexOf('\\')) return i >= 0 ? s.slice(i + 1) : s } const isBare = typeof globalThis.Bare !== 'undefined' const argv = isBare ? globalThis.Bare.argv.slice(pathBasename(globalThis.Bare.argv[0]) === 'bare' ? 2 : 1) : process.argv.slice(2) const { rest: afterHost } = applyHostFlagsFromArgv(argv) const { updates, storage } = parseOtaFlags(afterHost) const ota = await startPearOta({ upgrade, version, name: name || 'bare-os-seeder', updates, storage, }) const onExit = async (code = 0) => { await ota.close() if (typeof globalThis.Bare !== 'undefined') globalThis.Bare.exit(code) else process.exit(code) } if (typeof process !== 'undefined' && process.on) { for (const sig of ['SIGINT', 'SIGTERM', 'SIGHUP']) { process.on(sig, () => { onExit(sig === 'SIGINT' ? 130 : 143).catch(() => {}) }) } } await import('./index.js')