

















@@ -3,11 +3,13 @@ import { existsSync, readdirSync, readFileSync } from "node:fs";
33import { join, relative, resolve } from "node:path";
44import {
55dormantReservedBundledPluginSdkEntrypoints,
6+dormantReservedBundledPluginSdkEntrypointRecords,
67pluginSdkEntrypoints,
78publicPluginOwnedSdkEntrypoints,
89reservedBundledPluginSdkEntrypoints,
910supportedBundledFacadeSdkEntrypoints,
1011} from "../src/plugin-sdk/entrypoints.ts";
12+import type { DormantReservedBundledPluginSdkEntrypointRecord } from "../src/plugin-sdk/entrypoints.ts";
1113import { PLUGIN_COMPAT_RECORDS } from "../src/plugins/compat/registry.ts";
1214import type { PluginCompatRecord } from "../src/plugins/compat/types.ts";
1315@@ -75,7 +77,9 @@ type BoundaryReport = {
7577 crossOwnerReservedImports: ReservedSdkImport[];
7678 unusedReservedSubpaths: string[];
7779 dormantReservedSubpaths: string[];
80+ dormantReservedRecords: DormantReservedBundledPluginSdkEntrypointRecord[];
7881 unclassifiedUnusedReservedSubpaths: string[];
82+ dormantReservedEligibleForRemovalSubpaths: string[];
7983};
8084 memoryHostSdk: {
8185 privatePackage: boolean;
@@ -106,6 +110,8 @@ type BoundaryReportSummary = {
106110 dormantReservedCountInUnused: number;
107111 unclassifiedUnusedReservedCount: number;
108112 unclassifiedUnusedReservedSubpaths: string[];
113+ dormantReservedEligibleForRemovalCount: number;
114+ dormantReservedEligibleForRemovalSubpaths: string[];
109115 crossOwnerReservedImports: ReservedSdkImport[];
110116};
111117 memoryHostSdk: {
@@ -381,6 +387,10 @@ function resolveMemoryHostImplementation(
381387return "mixed";
382388}
383389390+function isDateDue(removeAfter: string, today = new Date()): boolean {
391+return new Date(`${removeAfter}T00:00:00Z`) <= today;
392+}
393+384394function buildSummary(report: BoundaryReport, owner?: string): BoundaryReportSummary {
385395const eligibleForRemoval = report.compat.records
386396.filter((record) => record.eligibleForRemoval)
@@ -410,6 +420,10 @@ function buildSummary(report: BoundaryReport, owner?: string): BoundaryReportSum
410420dormantReservedCountInUnused: report.pluginSdk.dormantReservedSubpaths.length,
411421unclassifiedUnusedReservedCount: report.pluginSdk.unclassifiedUnusedReservedSubpaths.length,
412422unclassifiedUnusedReservedSubpaths: report.pluginSdk.unclassifiedUnusedReservedSubpaths,
423+dormantReservedEligibleForRemovalCount:
424+report.pluginSdk.dormantReservedEligibleForRemovalSubpaths.length,
425+dormantReservedEligibleForRemovalSubpaths:
426+report.pluginSdk.dormantReservedEligibleForRemovalSubpaths,
413427crossOwnerReservedImports: report.pluginSdk.crossOwnerReservedImports,
414428},
415429memoryHostSdk: {
@@ -434,6 +448,9 @@ function buildReport(options: Pick<CliOptions, "owner"> = {}): BoundaryReport {
434448);
435449const usedReserved = new Set(reservedImports.map((entry) => entry.subpath));
436450const dormantReserved = new Set<string>(dormantReservedBundledPluginSdkEntrypoints);
451+const dormantReservedRecords = dormantReservedBundledPluginSdkEntrypointRecords.filter((record) =>
452+matchesOwner(options.owner, record.owner),
453+);
437454const unusedReservedSubpaths = reservedBundledPluginSdkEntrypoints
438455.filter(
439456(subpath) =>
@@ -444,6 +461,11 @@ function buildReport(options: Pick<CliOptions, "owner"> = {}): BoundaryReport {
444461const dormantReservedSubpaths = unusedReservedSubpaths
445462.filter((subpath) => dormantReserved.has(subpath))
446463.toSorted();
464+const dormantReservedEligibleForRemovalSubpaths = dormantReservedRecords
465+.filter((record) => unusedReservedSubpaths.includes(record.subpath))
466+.filter((record) => isDateDue(record.removeAfter))
467+.map((record) => record.subpath)
468+.toSorted();
447469return {
448470generatedAt: new Date().toISOString(),
449471compat: {
@@ -463,9 +485,11 @@ function buildReport(options: Pick<CliOptions, "owner"> = {}): BoundaryReport {
463485),
464486 unusedReservedSubpaths,
465487 dormantReservedSubpaths,
488+ dormantReservedRecords,
466489unclassifiedUnusedReservedSubpaths: unusedReservedSubpaths
467490.filter((subpath) => !dormantReserved.has(subpath))
468491.toSorted(),
492+ dormantReservedEligibleForRemovalSubpaths,
469493},
470494memoryHostSdk: collectMemoryHostBoundary(files),
471495};
@@ -487,9 +511,15 @@ function renderSummaryText(summary: BoundaryReportSummary): string {
487511lines.push(
488512` dormantUnused=${summary.pluginSdk.dormantReservedCountInUnused} unclassifiedUnused=${summary.pluginSdk.unclassifiedUnusedReservedCount}`,
489513);
514+lines.push(
515+` dormantEligibleForRemoval=${summary.pluginSdk.dormantReservedEligibleForRemovalCount}`,
516+);
490517for (const subpath of summary.pluginSdk.unclassifiedUnusedReservedSubpaths) {
491518lines.push(` unclassified-unused ${subpath}`);
492519}
520+for (const subpath of summary.pluginSdk.dormantReservedEligibleForRemovalSubpaths) {
521+lines.push(` dormant-due ${subpath}`);
522+}
493523for (const entry of summary.pluginSdk.crossOwnerReservedImports) {
494524lines.push(` cross-owner ${entry.file}: ${entry.specifier} owner=${entry.owner ?? "unknown"}`);
495525}
@@ -521,9 +551,15 @@ function renderText(report: BoundaryReport, owner?: string): string {
521551lines.push(
522552` dormantUnused=${report.pluginSdk.dormantReservedSubpaths.length} unclassifiedUnused=${report.pluginSdk.unclassifiedUnusedReservedSubpaths.length}`,
523553);
554+lines.push(
555+` dormantEligibleForRemoval=${report.pluginSdk.dormantReservedEligibleForRemovalSubpaths.length}`,
556+);
524557for (const subpath of report.pluginSdk.unclassifiedUnusedReservedSubpaths) {
525558lines.push(` unclassified-unused ${subpath}`);
526559}
560+for (const subpath of report.pluginSdk.dormantReservedEligibleForRemovalSubpaths) {
561+lines.push(` dormant-due ${subpath}`);
562+}
527563for (const entry of report.pluginSdk.crossOwnerReservedImports) {
528564lines.push(` cross-owner ${entry.file}: ${entry.specifier} owner=${entry.owner ?? "unknown"}`);
529565}
@@ -554,6 +590,14 @@ function collectFailures(report: BoundaryReport, options: CliOptions): string[]
554590`${report.compat.eligibleForRemovalCount} compatibility record(s) are due for removal`,
555591);
556592}
593+if (
594+options.failOnEligibleCompat &&
595+report.pluginSdk.dormantReservedEligibleForRemovalSubpaths.length > 0
596+) {
597+failures.push(
598+`${report.pluginSdk.dormantReservedEligibleForRemovalSubpaths.length} dormant reserved SDK subpath(s) are due for removal`,
599+);
600+}
557601return failures;
558602}
559603此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。