(
pathProvider: PathProvider,
kind: Extract<RuntimeKind, 'cli' | 'mcp'>,
options?: { version?: string }
)
| 12 | } |
| 13 | |
| 14 | export function assertCliDataDirCompatible( |
| 15 | pathProvider: PathProvider, |
| 16 | kind: Extract<RuntimeKind, 'cli' | 'mcp'>, |
| 17 | options?: { version?: string } |
| 18 | ): RuntimeIdentity { |
| 19 | const runtime: RuntimeIdentity = { version: options?.version ?? getVersion(), kind } |
| 20 | |
| 21 | try { |
| 22 | assertDataDirCompatible(pathProvider, runtime) |
| 23 | } catch (error) { |
| 24 | if ( |
| 25 | error instanceof DataDirCompatibilityError && |
| 26 | error.code === 'DATA_DIR_REQUIRES_NEWER_RUNTIME' && |
| 27 | error.minRuntimeVersion |
| 28 | ) { |
| 29 | throw new Error(formatCliDataDirCompatibilityError(error, runtime), { cause: error }) |
| 30 | } |
| 31 | |
| 32 | throw error |
| 33 | } |
| 34 | |
| 35 | return runtime |
| 36 | } |
| 37 | |
| 38 | function formatCliDataDirCompatibilityError(error: DataDirCompatibilityError, runtime: RuntimeIdentity): string { |
| 39 | return [ |
no test coverage detected