@@ -7,13 +7,13 @@ import { errToStr } from "./api/api-helper";
77import { CoderApi } from "./api/coderApi" ;
88import { needToken } from "./api/utils" ;
99import { Commands } from "./commands" ;
10+ import { BinaryManager } from "./core/binaryManager" ;
1011import { CliConfigManager } from "./core/cliConfig" ;
1112import { MementoManager } from "./core/mementoManager" ;
1213import { PathResolver } from "./core/pathResolver" ;
1314import { SecretsManager } from "./core/secretsManager" ;
1415import { CertificateError , getErrorDetail } from "./error" ;
1516import { Remote } from "./remote" ;
16- import { Storage } from "./storage" ;
1717import { toSafeHost } from "./util" ;
1818import { WorkspaceQuery , WorkspaceProvider } from "./workspacesProvider" ;
1919
@@ -62,7 +62,6 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
6262 const secretsManager = new SecretsManager ( ctx . secrets ) ;
6363
6464 const output = vscode . window . createOutputChannel ( "Coder" , { log : true } ) ;
65- const storage = new Storage ( output , pathResolver ) ;
6665
6766 // Try to clear this flag ASAP
6867 const isFirstConnect = await mementoManager . getAndClearFirstConnect ( ) ;
@@ -74,20 +73,20 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
7473 const client = CoderApi . create (
7574 url || "" ,
7675 await secretsManager . getSessionToken ( ) ,
77- storage . output ,
76+ output ,
7877 ( ) => vscode . workspace . getConfiguration ( ) ,
7978 ) ;
8079
8180 const myWorkspacesProvider = new WorkspaceProvider (
8281 WorkspaceQuery . Mine ,
8382 client ,
84- storage ,
83+ output ,
8584 5 ,
8685 ) ;
8786 const allWorkspacesProvider = new WorkspaceProvider (
8887 WorkspaceQuery . All ,
8988 client ,
90- storage ,
89+ output ,
9190 ) ;
9291
9392 // createTreeView, unlike registerTreeDataProvider, gives us the tree view API
@@ -257,15 +256,18 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
257256 } ,
258257 } ) ;
259258
259+ const binaryManager = new BinaryManager ( output , pathResolver ) ;
260+
260261 // Register globally available commands. Many of these have visibility
261262 // controlled by contexts, see `when` in the package.json.
262263 const commands = new Commands (
263264 vscodeProposed ,
264265 client ,
265- storage ,
266+ output ,
266267 pathResolver ,
267268 mementoManager ,
268269 secretsManager ,
270+ binaryManager ,
269271 ) ;
270272 vscode . commands . registerCommand ( "coder.login" , commands . login . bind ( commands ) ) ;
271273 vscode . commands . registerCommand (
@@ -322,10 +324,11 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
322324 if ( remoteSSHExtension && vscodeProposed . env . remoteAuthority ) {
323325 const remote = new Remote (
324326 vscodeProposed ,
325- storage ,
327+ output ,
326328 commands ,
327329 ctx . extensionMode ,
328330 pathResolver ,
331+ binaryManager ,
329332 ) ;
330333 try {
331334 const details = await remote . setup (
@@ -340,7 +343,7 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
340343 }
341344 } catch ( ex ) {
342345 if ( ex instanceof CertificateError ) {
343- storage . output . warn ( ex . x509Err || ex . message ) ;
346+ output . warn ( ex . x509Err || ex . message ) ;
344347 await ex . showModal ( "Failed to open workspace" ) ;
345348 } else if ( isAxiosError ( ex ) ) {
346349 const msg = getErrorMessage ( ex , "None" ) ;
@@ -349,7 +352,7 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
349352 const method = ex . config ?. method ?. toUpperCase ( ) || "request" ;
350353 const status = ex . response ?. status || "None" ;
351354 const message = `API ${ method } to '${ urlString } ' failed.\nStatus code: ${ status } \nMessage: ${ msg } \nDetail: ${ detail } ` ;
352- storage . output . warn ( message ) ;
355+ output . warn ( message ) ;
353356 await vscodeProposed . window . showErrorMessage (
354357 "Failed to open workspace" ,
355358 {
@@ -360,7 +363,7 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
360363 ) ;
361364 } else {
362365 const message = errToStr ( ex , "No error message was provided" ) ;
363- storage . output . warn ( message ) ;
366+ output . warn ( message ) ;
364367 await vscodeProposed . window . showErrorMessage (
365368 "Failed to open workspace" ,
366369 {
@@ -379,12 +382,12 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
379382 // See if the plugin client is authenticated.
380383 const baseUrl = client . getAxiosInstance ( ) . defaults . baseURL ;
381384 if ( baseUrl ) {
382- storage . output . info ( `Logged in to ${ baseUrl } ; checking credentials` ) ;
385+ output . info ( `Logged in to ${ baseUrl } ; checking credentials` ) ;
383386 client
384387 . getAuthenticatedUser ( )
385388 . then ( async ( user ) => {
386389 if ( user && user . roles ) {
387- storage . output . info ( "Credentials are valid" ) ;
390+ output . info ( "Credentials are valid" ) ;
388391 vscode . commands . executeCommand (
389392 "setContext" ,
390393 "coder.authenticated" ,
@@ -402,13 +405,13 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
402405 myWorkspacesProvider . fetchAndRefresh ( ) ;
403406 allWorkspacesProvider . fetchAndRefresh ( ) ;
404407 } else {
405- storage . output . warn ( "No error, but got unexpected response" , user ) ;
408+ output . warn ( "No error, but got unexpected response" , user ) ;
406409 }
407410 } )
408411 . catch ( ( error ) => {
409412 // This should be a failure to make the request, like the header command
410413 // errored.
411- storage . output . warn ( "Failed to check user authentication" , error ) ;
414+ output . warn ( "Failed to check user authentication" , error ) ;
412415 vscode . window . showErrorMessage (
413416 `Failed to check user authentication: ${ error . message } ` ,
414417 ) ;
@@ -417,7 +420,7 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
417420 vscode . commands . executeCommand ( "setContext" , "coder.loaded" , true ) ;
418421 } ) ;
419422 } else {
420- storage . output . info ( "Not currently logged in" ) ;
423+ output . info ( "Not currently logged in" ) ;
421424 vscode . commands . executeCommand ( "setContext" , "coder.loaded" , true ) ;
422425
423426 // Handle autologin, if not already logged in.
0 commit comments