everything-dev
Version:
A consolidated product package for building Module Federation apps with oRPC APIs.
44 lines (42 loc) • 1.91 kB
JavaScript
import { compareSemver } from "../../utils/semver.mjs";
//#region src/services/deploy/owed.ts
/**
* Owed-work detection (#571): the train derives release work from live
* state — npm registry reads and the FastKV platform-manifest pointer —
* never git history. Two facts decide the release leg:
*
* - `npmOwed` — a publishable workspace's version is not on npm yet
* - `manifestOwed` — the published pointer's frameworkVersion trails the
* repo's (or no pointer exists at all)
*
* Unknown states (npm unreachable, FastKV read failure) never block: they
* read as not-owed, matching the preflight npm gate's tolerance. The
* cross-check — owed on one side only, with a completed release cycle on
* record — is drift and fails the train loudly (#568's silent-skip class).
*/
/**
* The pure decision core — no I/O. `pointer` is tri-state; `unpublished` is
* optional (the npm leg is not consulted everywhere: the deploy train's
* preflight npm gate already hard-fails unpublished versions before the
* build, so in-train the release classifier is the pointer alone).
*/
function computeOwedWork(input) {
const unpublished = input.unpublished ?? [];
const npmOwed = unpublished.length > 0;
const { pointer, localFrameworkVersion } = input;
const manifestOwed = pointer.state === "unknown" ? false : pointer.state === "absent" ? Boolean(localFrameworkVersion) : Boolean(localFrameworkVersion && pointer.frameworkVersion !== void 0 && compareSemver(pointer.frameworkVersion, localFrameworkVersion) < 0);
return {
npmOwed,
manifestOwed,
release: npmOwed || manifestOwed,
detail: {
unpublished,
...localFrameworkVersion ? { localFrameworkVersion } : {},
...pointer.frameworkVersion ? { pointerFrameworkVersion: pointer.frameworkVersion } : {},
pointerExists: pointer.state === "present"
}
};
}
//#endregion
export { computeOwedWork };
//# sourceMappingURL=owed.mjs.map