Skip to content

Commit 270ffca

Browse files
committed
global install CLI on extension install
1 parent a773ab4 commit 270ffca

File tree

5 files changed

+48
-4
lines changed

5 files changed

+48
-4
lines changed

.changeset/cli-packaging.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"roo-cline-with-cli": patch
3+
---
4+
5+
Package roo-cli with the main extension so that when the extension is installed, the CLI is also installed globally. Add uninstallation functionality to clean up when the extension is deactivated.

package-lock.json

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

roo-cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "roo-cli",
3-
"version": "0.0.1",
3+
"version": "3.11.8",
44
"description": "Command Line Interface for Roo",
55
"main": "dist/cli.js",
66
"type": "module",

src/extension.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,11 @@ export async function deactivate() {
152152

153153
// Stop the configuration bridge server
154154
configBridgeServer?.stop()
155+
156+
// Uninstall the CLI
157+
try {
158+
await cliInstaller?.uninstallCli()
159+
} catch (error) {
160+
outputChannel.appendLine(`Failed to uninstall Roo CLI: ${error}`)
161+
}
155162
}

src/services/cli/CliInstaller.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import * as vscode from "vscode"
1010
export class CliInstaller {
1111
private outputChannel: vscode.OutputChannel
1212
private extensionPath: string
13+
private isInstalled: boolean = false
1314

1415
constructor(context: vscode.ExtensionContext, outputChannel: vscode.OutputChannel) {
1516
this.outputChannel = outputChannel
@@ -57,18 +58,48 @@ export class CliInstaller {
5758
fs.writeFileSync(path.join(tempDir, "package.json"), JSON.stringify(packageJson, null, 2))
5859

5960
// Install the CLI globally
60-
this.executeCommand("npm", ["install", "-g", tempDir], { cwd: tempDir })
61+
await this.executeCommand("npm", ["install", "-g", tempDir], { cwd: tempDir })
6162
.then(() => {
63+
this.isInstalled = true
6264
this.outputChannel.appendLine("Roo CLI installed successfully")
6365
})
6466
.catch((error) => {
67+
this.isInstalled = false
6568
this.outputChannel.appendLine(`Failed to install Roo CLI: ${error}`)
6669
})
6770
} catch (error) {
6871
this.outputChannel.appendLine(`Error installing Roo CLI: ${error}`)
6972
}
7073
}
7174

75+
/**
76+
* Uninstall the CLI globally
77+
*/
78+
public async uninstallCli(): Promise<void> {
79+
try {
80+
if (!this.isInstalled) {
81+
this.outputChannel.appendLine(
82+
"Roo CLI was not installed by this extension instance, skipping uninstall",
83+
)
84+
return
85+
}
86+
87+
this.outputChannel.appendLine("Uninstalling Roo CLI...")
88+
89+
// Uninstall the CLI globally
90+
await this.executeCommand("npm", ["uninstall", "-g", "roo-cli"], {})
91+
.then(() => {
92+
this.isInstalled = false
93+
this.outputChannel.appendLine("Roo CLI uninstalled successfully")
94+
})
95+
.catch((error) => {
96+
this.outputChannel.appendLine(`Failed to uninstall Roo CLI: ${error}`)
97+
})
98+
} catch (error) {
99+
this.outputChannel.appendLine(`Error uninstalling Roo CLI: ${error}`)
100+
}
101+
}
102+
72103
/**
73104
* Get the extension version from package.json
74105
*/

0 commit comments

Comments
 (0)