|
1 | 1 | import { existsSync, readdirSync, readFileSync, realpathSync, statSync } from 'node:fs'; |
2 | 2 | import { basename, extname, isAbsolute, join, posix, relative, resolve, sep } from 'node:path'; |
3 | 3 |
|
4 | | -import { cliBinCapability } from '../adapters/capability-state.ts'; |
| 4 | +import { capabilityIsSupported, cliBinCapability } from '../adapters/capability-state.ts'; |
5 | 5 | import { type EntryExportScan, scanEntryExportsSource } from '../build/entry-exports.ts'; |
| 6 | +import type { CapabilityState } from '../core/capabilities.ts'; |
6 | 7 | import { toPosixRelative } from '../core/paths.ts'; |
7 | 8 | import { isPlainRecord, isRecord } from '../core/strict-json.ts'; |
8 | 9 | import type { Diagnostic } from '../core/diagnostics.ts'; |
@@ -2146,11 +2147,28 @@ const routedCliBinTargetDiagnostics = ( |
2146 | 2147 | registry: NormalizationTargetRegistry, |
2147 | 2148 | ): Diagnostic[] => { |
2148 | 2149 | const diagnostics: Diagnostic[] = []; |
| 2150 | + // The judgment must be the one emission and `inspect` use: the adapter's |
| 2151 | + // component override when published, otherwise its plain capabilities. A |
| 2152 | + // registry exposing neither accessor falls back to its boolean view. |
| 2153 | + const judgmentFor = (target: string): { readonly known: true; readonly state: CapabilityState | undefined } | { readonly known: false } => { |
| 2154 | + if (registry.componentCapabilityState !== undefined) { |
| 2155 | + return { known: true, state: registry.componentCapabilityState(target, cliBinCapability) }; |
| 2156 | + } |
| 2157 | + if (registry.capabilityState !== undefined) { |
| 2158 | + return { known: true, state: registry.capabilityState(target, cliBinCapability) }; |
| 2159 | + } |
| 2160 | + return { known: false }; |
| 2161 | + }; |
2149 | 2162 | for (const bin of model.packageBuild?.bins ?? []) { |
2150 | 2163 | if (bin.generatedCli === undefined) continue; |
2151 | 2164 | for (const target of model.targets) { |
2152 | | - if (!registry.has(target.name) || registry.supports(target.name, cliBinCapability)) continue; |
2153 | | - const capability = registry.capabilityState?.(target.name, cliBinCapability); |
| 2165 | + if (!registry.has(target.name)) continue; |
| 2166 | + const judged = judgmentFor(target.name); |
| 2167 | + const supported = judged.known |
| 2168 | + ? capabilityIsSupported(judged.state) |
| 2169 | + : registry.supports(target.name, cliBinCapability); |
| 2170 | + if (supported) continue; |
| 2171 | + const capability = judged.known ? judged.state : undefined; |
2154 | 2172 | let judgment: string; |
2155 | 2173 | if (capability === undefined) { |
2156 | 2174 | judgment = `the target publishes no ${cliBinCapability} capability row`; |
|
0 commit comments