All files / apps/developer-portal/layers/health/app/composables useDepsPage.ts

100% Statements 10/10
100% Branches 12/12
100% Functions 2/2
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26    2x     2x 5x 5x 5x 5x   5x   5x 20x                 5x    
import type { PageFact } from "~/types/PageFact";
 
const SEVERITIES = ["critical", "high", "moderate", "low"] as const;
 
/** The dependency snapshot and the header facts drawn from it. */
export const useDepsPage = () => {
    const { t } = useI18n();
    const deps = depsArtifact();
    const counts = deps?.vulnerabilities ?? null;
    const outdated = deps?.outdated ?? null;
 
    const provenance = t("deps.provenance", { age: relativeTime(deps?.generatedAt, t) });
 
    const facts: PageFact[] = [
        ...SEVERITIES.map((severity) => ({
            label: t(`common.severity.${severity}`),
            value: counts ? String(counts[severity]) : "—",
            class: counts?.[severity] ? toneClass(severityTone(severity)) : "",
        })),
        { label: t("deps.facts.outdated"), value: outdated ? String(outdated.length) : "—" },
        { label: t("deps.facts.dependencies"), value: String(deps?.totalDependencies ?? "—") },
    ];
 
    return { deps, provenance, facts };
};