add open tunnels to test resolver
parent
af2bcd4d46
commit
ff393a3349
|
@ -18,7 +18,8 @@
|
|||
"onResolveRemoteAuthority:test",
|
||||
"onCommand:vscode-testresolver.newWindow",
|
||||
"onCommand:vscode-testresolver.newWindowWithError",
|
||||
"onCommand:vscode-testresolver.showLog"
|
||||
"onCommand:vscode-testresolver.showLog",
|
||||
"onCommand:vscode-testresolver.openTunnel"
|
||||
],
|
||||
"main": "./out/extension",
|
||||
"devDependencies": {
|
||||
|
@ -52,6 +53,11 @@
|
|||
"title": "Kill Server and Trigger Handled Error",
|
||||
"category": "Remote-TestResolver",
|
||||
"command": "vscode-testresolver.killServerAndTriggerHandledError"
|
||||
},
|
||||
{
|
||||
"title": "Open Tunnel 100",
|
||||
"category": "Remote-TestResolver",
|
||||
"command": "vscode-testresolver.openTunnel"
|
||||
}
|
||||
],
|
||||
"menus": {
|
||||
|
|
|
@ -213,16 +213,19 @@ export function activate(context: vscode.ExtensionContext) {
|
|||
title: 'Open TestResolver Remote ([details](command:vscode-testresolver.showLog))',
|
||||
cancellable: false
|
||||
}, (progress) => doResolve(_authority, progress));
|
||||
}
|
||||
},
|
||||
tunnelFactory,
|
||||
tunnelFeatures: { elevation: true, public: false }
|
||||
});
|
||||
context.subscriptions.push(authorityResolverDisposable);
|
||||
|
||||
vscode.commands.registerCommand('vscode-testresolver.newWindow', () => {
|
||||
context.subscriptions.push(vscode.commands.registerCommand('vscode-testresolver.newWindow', () => {
|
||||
return vscode.commands.executeCommand('vscode.newWindow', { remoteAuthority: 'test+test' });
|
||||
});
|
||||
vscode.commands.registerCommand('vscode-testresolver.newWindowWithError', () => {
|
||||
}));
|
||||
context.subscriptions.push(vscode.commands.registerCommand('vscode-testresolver.newWindowWithError', () => {
|
||||
return vscode.commands.executeCommand('vscode.newWindow', { remoteAuthority: 'test+error' });
|
||||
});
|
||||
vscode.commands.registerCommand('vscode-testresolver.killServerAndTriggerHandledError', () => {
|
||||
}));
|
||||
context.subscriptions.push(vscode.commands.registerCommand('vscode-testresolver.killServerAndTriggerHandledError', () => {
|
||||
authorityResolverDisposable.dispose();
|
||||
if (extHostProcess) {
|
||||
terminateProcess(extHostProcess, context.extensionPath);
|
||||
|
@ -235,12 +238,22 @@ export function activate(context: vscode.ExtensionContext) {
|
|||
throw vscode.RemoteAuthorityResolverError.NotAvailable('Intentional Error', true);
|
||||
}
|
||||
});
|
||||
});
|
||||
vscode.commands.registerCommand('vscode-testresolver.showLog', () => {
|
||||
}));
|
||||
context.subscriptions.push(vscode.commands.registerCommand('vscode-testresolver.showLog', () => {
|
||||
if (outputChannel) {
|
||||
outputChannel.show();
|
||||
}
|
||||
});
|
||||
}));
|
||||
context.subscriptions.push(vscode.commands.registerCommand('vscode-testresolver.openTunnel', () => {
|
||||
vscode.workspace.openTunnel({
|
||||
remoteAddress: {
|
||||
host: 'localhost',
|
||||
port: 100
|
||||
},
|
||||
localAddressPort: 100
|
||||
});
|
||||
}));
|
||||
vscode.commands.executeCommand('setContext', 'forwardedPortsViewEnabled', true);
|
||||
}
|
||||
|
||||
type ActionItem = (vscode.MessageItem & { execute: () => void; });
|
||||
|
@ -301,3 +314,20 @@ function sleep(ms: number): Promise<void> {
|
|||
function getConfiguration<T>(id: string): T | undefined {
|
||||
return vscode.workspace.getConfiguration('testresolver').get<T>(id);
|
||||
}
|
||||
|
||||
function tunnelFactory(tunnelOptions: vscode.TunnelOptions): Promise<vscode.Tunnel> | undefined {
|
||||
const onDidDispose: vscode.EventEmitter<void> = new vscode.EventEmitter();
|
||||
let isDisposed = false;
|
||||
return Promise.resolve({
|
||||
localAddress: { host: 'localhost', port: (tunnelOptions.localAddressPort === undefined ? tunnelOptions.remoteAddress.port : tunnelOptions.localAddressPort) + 1 },
|
||||
remoteAddress: tunnelOptions.remoteAddress,
|
||||
public: tunnelOptions.public,
|
||||
onDidDispose: onDidDispose.event,
|
||||
dispose: () => {
|
||||
if (!isDisposed) {
|
||||
isDisposed = true;
|
||||
onDidDispose.fire();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue