add open tunnels to test resolver
This commit is contained in:
parent
af2bcd4d46
commit
ff393a3349
2 changed files with 46 additions and 10 deletions
|
@ -18,7 +18,8 @@
|
||||||
"onResolveRemoteAuthority:test",
|
"onResolveRemoteAuthority:test",
|
||||||
"onCommand:vscode-testresolver.newWindow",
|
"onCommand:vscode-testresolver.newWindow",
|
||||||
"onCommand:vscode-testresolver.newWindowWithError",
|
"onCommand:vscode-testresolver.newWindowWithError",
|
||||||
"onCommand:vscode-testresolver.showLog"
|
"onCommand:vscode-testresolver.showLog",
|
||||||
|
"onCommand:vscode-testresolver.openTunnel"
|
||||||
],
|
],
|
||||||
"main": "./out/extension",
|
"main": "./out/extension",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -52,6 +53,11 @@
|
||||||
"title": "Kill Server and Trigger Handled Error",
|
"title": "Kill Server and Trigger Handled Error",
|
||||||
"category": "Remote-TestResolver",
|
"category": "Remote-TestResolver",
|
||||||
"command": "vscode-testresolver.killServerAndTriggerHandledError"
|
"command": "vscode-testresolver.killServerAndTriggerHandledError"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Open Tunnel 100",
|
||||||
|
"category": "Remote-TestResolver",
|
||||||
|
"command": "vscode-testresolver.openTunnel"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"menus": {
|
"menus": {
|
||||||
|
|
|
@ -213,16 +213,19 @@ export function activate(context: vscode.ExtensionContext) {
|
||||||
title: 'Open TestResolver Remote ([details](command:vscode-testresolver.showLog))',
|
title: 'Open TestResolver Remote ([details](command:vscode-testresolver.showLog))',
|
||||||
cancellable: false
|
cancellable: false
|
||||||
}, (progress) => doResolve(_authority, progress));
|
}, (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' });
|
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' });
|
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();
|
authorityResolverDisposable.dispose();
|
||||||
if (extHostProcess) {
|
if (extHostProcess) {
|
||||||
terminateProcess(extHostProcess, context.extensionPath);
|
terminateProcess(extHostProcess, context.extensionPath);
|
||||||
|
@ -235,12 +238,22 @@ export function activate(context: vscode.ExtensionContext) {
|
||||||
throw vscode.RemoteAuthorityResolverError.NotAvailable('Intentional Error', true);
|
throw vscode.RemoteAuthorityResolverError.NotAvailable('Intentional Error', true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
}));
|
||||||
vscode.commands.registerCommand('vscode-testresolver.showLog', () => {
|
context.subscriptions.push(vscode.commands.registerCommand('vscode-testresolver.showLog', () => {
|
||||||
if (outputChannel) {
|
if (outputChannel) {
|
||||||
outputChannel.show();
|
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; });
|
type ActionItem = (vscode.MessageItem & { execute: () => void; });
|
||||||
|
@ -301,3 +314,20 @@ function sleep(ms: number): Promise<void> {
|
||||||
function getConfiguration<T>(id: string): T | undefined {
|
function getConfiguration<T>(id: string): T | undefined {
|
||||||
return vscode.workspace.getConfiguration('testresolver').get<T>(id);
|
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 a new issue