@@ -17,6 +17,7 @@ import {
1717 handleInspectCommand ,
1818 handleShowLogsCommand ,
1919} from "./logs"
20+ import { execCombined } from "./utils"
2021
2122export function activate ( context : vscode . ExtensionContext ) {
2223 preflightCheckCoderInstalled ( )
@@ -49,13 +50,33 @@ export function activate(context: vscode.ExtensionContext) {
4950 vscode . workspace . registerTextDocumentContentProvider ( "coder-inspect" , coderWorkspaceInspectDocumentProvider )
5051}
5152
53+ export const outputChannel = vscode . window . createOutputChannel ( "Coder" )
54+
5255const preflightCheckCoderInstalled = ( ) => {
5356 which ( "coder" , ( err : any ) => {
5457 if ( err ) {
55- vscode . window . showErrorMessage (
56- `"coder" CLI not found in $PATH. Please follow the install and authentication instructions here: https://coder.com/docs/cli/installation` ,
57- "Dismiss" ,
58- )
58+ which ( "brew" , async ( err : any ) => {
59+ if ( err ) {
60+ vscode . window . showErrorMessage (
61+ `"coder" CLI not found in $PATH. Please follow the install and authentication [instructions here](https://coder.com/docs/cli/installation)` ,
62+ "Dismiss" ,
63+ )
64+ } else {
65+ const action = await vscode . window . showErrorMessage ( `"coder" CLI not found in $PATH` , "Install with `brew`" )
66+ if ( action ) {
67+ outputChannel . show ( )
68+ const cmd = "brew install cdr/coder/coder-cli"
69+ outputChannel . appendLine ( cmd )
70+ const output = await execCombined ( cmd )
71+ outputChannel . appendLine ( output . stderr )
72+ which ( "coder" , err => err ? (
73+ outputChannel . appendLine ( `Install failed. "coder" still not found in $PATH.` )
74+ ) : (
75+ outputChannel . appendLine ( "Installation successful.\nACTION REQUIRED: run \"coder login [https://coder.domain.com]\"" )
76+ ) )
77+ }
78+ }
79+ } )
5980 }
6081 } )
6182}
0 commit comments