| 87 | } |
| 88 | |
| 89 | class VsCodeInstaller implements IdeInstaller { |
| 90 | private vsCodeCommand: Promise<string | null>; |
| 91 | |
| 92 | constructor() { |
| 93 | this.vsCodeCommand = findVsCodeCommand(); |
| 94 | } |
| 95 | |
| 96 | async install(): Promise<InstallResult> { |
| 97 | const commandPath = await this.vsCodeCommand; |
| 98 | if (!commandPath) { |
| 99 | return { |
| 100 | success: false, |
| 101 | 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 '${ANUS_CLI_COMPANION_EXTENSION_NAME}' extension manually from the VS Code marketplace.`, |
| 102 | }; |
| 103 | } |
| 104 | |
| 105 | const command = `"${commandPath}" --install-extension google.anus-cli-vscode-ide-companion --force`; |
| 106 | try { |
| 107 | child_process.execSync(command, { stdio: 'pipe' }); |
| 108 | return { |
| 109 | success: true, |
| 110 | message: 'VS Code companion extension was installed successfully.', |
| 111 | }; |
| 112 | } catch (_error) { |
| 113 | return { |
| 114 | success: false, |
| 115 | message: `Failed to install VS Code companion extension. Please try installing '${ANUS_CLI_COMPANION_EXTENSION_NAME}' manually from the VS Code extension marketplace.`, |
| 116 | }; |
| 117 | } |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | export function getIdeInstaller(ide: DetectedIde): IdeInstaller | null { |
| 122 | switch (ide) { |
nothing calls this directly
no outgoing calls
no test coverage detected