@@ -17,6 +17,7 @@ import {
17
17
handleInspectCommand ,
18
18
handleShowLogsCommand ,
19
19
} from "./logs"
20
+ import { execCombined } from "./utils"
20
21
21
22
export function activate ( context : vscode . ExtensionContext ) {
22
23
preflightCheckCoderInstalled ( )
@@ -49,13 +50,33 @@ export function activate(context: vscode.ExtensionContext) {
49
50
vscode . workspace . registerTextDocumentContentProvider ( "coder-inspect" , coderWorkspaceInspectDocumentProvider )
50
51
}
51
52
53
+ export const outputChannel = vscode . window . createOutputChannel ( "Coder" )
54
+
52
55
const preflightCheckCoderInstalled = ( ) => {
53
56
which ( "coder" , ( err : any ) => {
54
57
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
+ } )
59
80
}
60
81
} )
61
82
}
0 commit comments