@@ -15,10 +15,10 @@ import { getLogScope } from '../../../../system/logger.scope';
1515import { compare } from '../../../../system/version' ;
1616import { run } from '../../git/shell' ;
1717import { getPlatform , isWeb } from '../../platform' ;
18- import { toMcpInstallProvider } from '../mcp/utils' ;
1918import { CliCommandHandlers } from './commands' ;
2019import type { IpcServer } from './ipcServer' ;
2120import { createIpcServer } from './ipcServer' ;
21+ import { runCLICommand , toMcpInstallProvider } from './utils' ;
2222
2323const enum CLIInstallErrorReason {
2424 UnsupportedPlatform ,
@@ -42,7 +42,7 @@ const CLIProxyMCPInstallOutputs = {
4242 checkingForUpdates : / c h e c k i n g f o r u p d a t e s .../ i,
4343 notASupportedClient : / i s n o t a s u p p o r t e d M C P c l i e n t / i,
4444 installedSuccessfully : / G i t K r a k e n M C P S e r v e r S u c c e s s f u l l y I n s t a l l e d ! / i,
45- } ;
45+ } as const ;
4646
4747export class GkCliIntegrationProvider implements Disposable {
4848 private readonly _disposable : Disposable ;
@@ -238,7 +238,7 @@ export class GkCliIntegrationProvider implements Disposable {
238238 }
239239 }
240240
241- let output = await this . runCLICommand (
241+ let output = await runCLICommand (
242242 [ 'mcp' , 'install' , appName , '--source=gitlens' , `--scheme=${ env . uriScheme } ` ] ,
243243 {
244244 cwd : cliPath ,
@@ -555,7 +555,7 @@ export class GkCliIntegrationProvider implements Disposable {
555555
556556 // Set up the local MCP server files
557557 try {
558- const coreInstallOutput = await this . runCLICommand ( [ 'install' ] , {
558+ const coreInstallOutput = await runCLICommand ( [ 'install' ] , {
559559 cwd : globalStoragePath . fsPath ,
560560 } ) ;
561561 const directory = coreInstallOutput . match ( / D i r e c t o r y : ( .* ) / ) ;
@@ -632,21 +632,6 @@ export class GkCliIntegrationProvider implements Disposable {
632632 return { cliVersion : cliVersion , cliPath : cliPath , status : cliInstallStatus } ;
633633 }
634634
635- private async runCLICommand (
636- args : string [ ] ,
637- options ?: {
638- cwd ?: string ;
639- } ,
640- ) : Promise < string > {
641- const platform = getPlatform ( ) ;
642- const cwd = options ?. cwd ?? this . container . storage . get ( 'gk:cli:path' ) ;
643- if ( cwd == null ) {
644- throw new Error ( 'CLI is not installed' ) ;
645- }
646-
647- return run ( platform === 'windows' ? 'gk.exe' : './gk' , args , 'utf8' , { cwd : cwd } ) ;
648- }
649-
650635 private async authCLI ( ) : Promise < void > {
651636 const cliInstall = this . container . storage . get ( 'gk:cli:install' ) ;
652637 const cliPath = this . container . storage . get ( 'gk:cli:path' ) ;
@@ -660,7 +645,7 @@ export class GkCliIntegrationProvider implements Disposable {
660645 }
661646
662647 try {
663- await this . runCLICommand ( [ 'auth' , 'login' , '-t' , currentSessionToken ] ) ;
648+ await runCLICommand ( [ 'auth' , 'login' , '-t' , currentSessionToken ] ) ;
664649 } catch ( ex ) {
665650 Logger . error ( `Failed to auth CLI: ${ ex instanceof Error ? ex . message : String ( ex ) } ` ) ;
666651 }
0 commit comments