Skip to main content

Function: checkCompatibility()

checkCompatibility(live, registry): CompatibilityReport

Defined in: packages/core/src/checkCompatibility.ts:43

Runs the rollback comparison over every live route at once, and reports each failure with the version delta behind it: which route, which artifact, which block, what the page needs, what is registered. Point a CI job at it before merging a registry change to learn which pages the change would break.

Parameters

live

readonly LiveRoute[]

Every pointer worth checking, each paired with the artifact its hash resolves to. Read them from an ArtifactStore — a pointer the store cannot resolve is passed as null rather than dropped, because that route is already broken. Nothing here reads the store itself, so a caller whose live state sits somewhere else can build the pairs by hand.

registry

Registry

The registry to judge them against, from createRegistry.

Returns

CompatibilityReport

A report over the whole set: how many pointers were examined, whether all of them cleared, and one entry per route that did not. A block the registry gained since publish is not drift, so an added block never appears.

Example

import { checkCompatibility, formatCompatibilityReport } from "@nubbin/core";
import type { LiveRoute } from "@nubbin/core";

const { routes } = await store.manifest();
const live: LiveRoute[] = await Promise.all(
routes.map(async (pointer) => ({ pointer, artifact: await store.read(pointer.hash) })),
);

const report = checkCompatibility(live, registry);
console.log(formatCompatibilityReport(report));
if (!report.compatible) process.exitCode = 1;