diff options
Diffstat (limited to 'packages/core/src')
| -rw-r--r-- | packages/core/src/ide/detect-ide.ts | 9 | ||||
| -rw-r--r-- | packages/core/src/ide/ide-installer.test.ts | 30 | ||||
| -rw-r--r-- | packages/core/src/ide/ide-installer.ts | 13 |
3 files changed, 11 insertions, 41 deletions
diff --git a/packages/core/src/ide/detect-ide.ts b/packages/core/src/ide/detect-ide.ts index ae46789e..f3d8cc63 100644 --- a/packages/core/src/ide/detect-ide.ts +++ b/packages/core/src/ide/detect-ide.ts @@ -11,9 +11,12 @@ export enum DetectedIde { export function getIdeDisplayName(ide: DetectedIde): string { switch (ide) { case DetectedIde.VSCode: - return 'VSCode'; - default: - throw new Error(`Unsupported IDE: ${ide}`); + return 'VS Code'; + default: { + // This ensures that if a new IDE is added to the enum, we get a compile-time error. + const exhaustiveCheck: never = ide; + return exhaustiveCheck; + } } } diff --git a/packages/core/src/ide/ide-installer.test.ts b/packages/core/src/ide/ide-installer.test.ts index 83459d6b..698c3173 100644 --- a/packages/core/src/ide/ide-installer.test.ts +++ b/packages/core/src/ide/ide-installer.test.ts @@ -45,32 +45,6 @@ describe('ide-installer', () => { vi.restoreAllMocks(); }); - describe('isInstalled', () => { - it('should return true if command is in PATH', async () => { - expect(await installer.isInstalled()).toBe(true); - }); - - it('should return true if command is in a known location', async () => { - vi.spyOn(child_process, 'execSync').mockImplementation(() => { - throw new Error('Command not found'); - }); - vi.spyOn(fs, 'existsSync').mockReturnValue(true); - // Re-create the installer so it re-runs findVsCodeCommand - installer = getIdeInstaller(DetectedIde.VSCode)!; - expect(await installer.isInstalled()).toBe(true); - }); - - it('should return false if command is not found', async () => { - vi.spyOn(child_process, 'execSync').mockImplementation(() => { - throw new Error('Command not found'); - }); - vi.spyOn(fs, 'existsSync').mockReturnValue(false); - // Re-create the installer so it re-runs findVsCodeCommand - installer = getIdeInstaller(DetectedIde.VSCode)!; - expect(await installer.isInstalled()).toBe(false); - }); - }); - describe('install', () => { it('should return a failure message if VS Code is not installed', async () => { vi.spyOn(child_process, 'execSync').mockImplementation(() => { @@ -81,9 +55,7 @@ describe('ide-installer', () => { installer = getIdeInstaller(DetectedIde.VSCode)!; const result = await installer.install(); expect(result.success).toBe(false); - expect(result.message).toContain( - 'not found in your PATH or common installation locations', - ); + expect(result.message).toContain('VS Code CLI not found'); }); }); }); diff --git a/packages/core/src/ide/ide-installer.ts b/packages/core/src/ide/ide-installer.ts index 725f4f7c..7db8e2d2 100644 --- a/packages/core/src/ide/ide-installer.ts +++ b/packages/core/src/ide/ide-installer.ts @@ -18,7 +18,6 @@ const VSCODE_COMPANION_EXTENSION_FOLDER = 'vscode-ide-companion'; export interface IdeInstaller { install(): Promise<InstallResult>; - isInstalled(): Promise<boolean>; } export interface InstallResult { @@ -95,16 +94,12 @@ class VsCodeInstaller implements IdeInstaller { this.vsCodeCommand = findVsCodeCommand(); } - async isInstalled(): Promise<boolean> { - return (await this.vsCodeCommand) !== null; - } - async install(): Promise<InstallResult> { const commandPath = await this.vsCodeCommand; if (!commandPath) { return { success: false, - message: `VS Code command-line tool not found in your PATH or common installation locations.`, + message: `VS Code CLI not found. Please ensure 'code' is in your system's PATH. For help, see https://code.visualstudio.com/docs/configure/command-line#_code-is-not-recognized-as-an-internal-or-external-command. You can also install the companion extension manually from the VS Code marketplace.`, }; } @@ -141,12 +136,12 @@ class VsCodeInstaller implements IdeInstaller { return { success: true, message: - 'VS Code companion extension installed successfully. Restart gemini-cli in a fresh terminal window.', + 'VS Code companion extension was installed successfully. Please restart your terminal to complete the setup.', }; } catch (_error) { return { success: false, - message: 'Failed to install VS Code companion extension.', + message: `Failed to install VS Code companion extension. Please try installing it manually from the VS Code marketplace.`, }; } } @@ -154,7 +149,7 @@ class VsCodeInstaller implements IdeInstaller { export function getIdeInstaller(ide: DetectedIde): IdeInstaller | null { switch (ide) { - case 'vscode': + case DetectedIde.VSCode: return new VsCodeInstaller(); default: return null; |
