extensionsManagement for remote CLI

This commit is contained in:
Martin Aeschlimann
2021-01-15 15:39:13 +01:00
parent 4974a33511
commit c198925570
9 changed files with 440 additions and 315 deletions

View File

@@ -39,7 +39,15 @@ export interface RunCommandPipeArgs {
args: any[];
}
export type PipeCommand = OpenCommandPipeArgs | StatusPipeArgs | RunCommandPipeArgs | OpenExternalCommandPipeArgs;
export interface ExtensionManagementPipeArgs {
type: 'extensionManagement';
list?: { showVersions?: boolean, category?: string; };
install?: string[];
uninstall?: string[];
force?: boolean;
}
export type PipeCommand = OpenCommandPipeArgs | StatusPipeArgs | RunCommandPipeArgs | OpenExternalCommandPipeArgs | ExtensionManagementPipeArgs;
export interface ICommandsExecuter {
executeCommand<T>(id: string, ...args: any[]): Promise<T>;
@@ -95,6 +103,10 @@ export class CLIServerBase {
this.runCommand(data, res)
.catch(this.logService.error);
break;
case 'extensionManagement':
this.manageExtensions(data, res)
.catch(this.logService.error);
break;
default:
res.writeHead(404);
res.write(`Unknown message type: ${data.type}`, err => {
@@ -143,14 +155,27 @@ export class CLIServerBase {
res.end();
}
private openExternal(data: OpenExternalCommandPipeArgs, res: http.ServerResponse) {
private async openExternal(data: OpenExternalCommandPipeArgs, res: http.ServerResponse) {
for (const uri of data.uris) {
this._commands.executeCommand('_workbench.openExternal', URI.parse(uri), { allowTunneling: true });
await this._commands.executeCommand('_cli.openExternal', URI.parse(uri), { allowTunneling: true });
}
res.writeHead(200);
res.end();
}
private async manageExtensions(data: ExtensionManagementPipeArgs, res: http.ServerResponse) {
console.log('server: manageExtensions');
try {
const output = await this._commands.executeCommand('_cli.manageExtensions', data, { allowTunneling: true });
res.writeHead(200);
res.write(output);
} catch (e) {
res.writeHead(500);
res.write(toString());
}
res.end();
}
private async getStatus(data: StatusPipeArgs, res: http.ServerResponse) {
try {
const status = await this._commands.executeCommand('_issues.getSystemStatus');