cameras/scripts/install-mediamtx.mjs
Michael Mainguy daaecb7452 Fix the published package: compile the CLI, bundle onvif (0.1.1)
Installing 0.1.0 failed twice, both my mistakes.

- Node refuses to strip types under node_modules, so shipping .ts for the
  CLI could never work from an installed package. tsconfig.cli.json now
  compiles those modules to dist/ as ES modules, and the helper scripts
  are plain .mjs.
- serverExternalPackages made Turbopack emit require("onvif-<hash>"),
  a name that resolves nowhere, because onvif comes from a git URL.
  Bundling it fixes that; checked from an installed tarball, where
  /api/discover answered 200 and a real camera's info and snapshot came
  back through the packaged server.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-19 19:21:53 -05:00

19 lines
716 B
JavaScript

// Installs the pinned MediaMTX video bridge into ./bin (vrek dec-xkn4z0e). The download is
// checked against a SHA-256 committed in src/lib/mediamtx-install.ts before anything is
// written. Safe to re-run: an installed matching build is left alone.
//
// npm run video:install
import { installMediamtx } from "../dist/lib/mediamtx-install.js";
try {
const result = await installMediamtx();
console.log(
result.status === "installed"
? `Installed MediaMTX ${result.version} at ${result.binary} (checksum verified).`
: `MediaMTX ${result.version} is already installed at ${result.binary}.`,
);
} catch (err) {
console.error(err instanceof Error ? err.message : err);
process.exit(1);
}