( diagnostics: ResolutionDiagnostics )
| 60 | * Builds a not-found error message with diagnostics from local bin resolution. |
| 61 | */ |
| 62 | export function getCliNotFoundMessage( |
| 63 | diagnostics: ResolutionDiagnostics |
| 64 | ): string { |
| 65 | const details: string[] = []; |
| 66 | const { localBinSearch } = diagnostics; |
| 67 | |
| 68 | if (localBinSearch.stopReason === 'project-root-marker') { |
| 69 | details.push( |
| 70 | `Local bin lookup stopped at ${JSON.stringify(localBinSearch.stoppedAt)} (${JSON.stringify(localBinSearch.markerPath)}).` |
| 71 | ); |
| 72 | } else if (localBinSearch.stopReason === 'filesystem-root') { |
| 73 | details.push( |
| 74 | `No project root marker was found from ${JSON.stringify(localBinSearch.searchRoot)}; local bin lookup reached the filesystem root.` |
| 75 | ); |
| 76 | } |
| 77 | |
| 78 | for (const skippedNodeModules of localBinSearch.skippedNodeModules) { |
| 79 | details.push( |
| 80 | `Skipped ${JSON.stringify(skippedNodeModules.directory)}: ${skippedNodeModules.reason}.` |
| 81 | ); |
| 82 | } |
| 83 | |
| 84 | for (const skippedLocalBin of diagnostics.skippedLocalBins) { |
| 85 | details.push( |
| 86 | `Skipped ${JSON.stringify(skippedLocalBin.candidate)}: ${skippedLocalBin.reason}.` |
| 87 | ); |
| 88 | } |
| 89 | |
| 90 | if (details.length === 0) { |
| 91 | return 'Unable to find a usable Vercel CLI installation.'; |
| 92 | } |
| 93 | |
| 94 | return ['Unable to find a usable Vercel CLI installation.', ...details].join( |
| 95 | '\n' |
| 96 | ); |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Verifies that the resolved working directory exists and is a directory. |
no test coverage detected